Class RewriterConfig

  • All Implemented Interfaces:
    Serializable, org.nd4j.shade.protobuf.Message, org.nd4j.shade.protobuf.MessageLite, org.nd4j.shade.protobuf.MessageLiteOrBuilder, org.nd4j.shade.protobuf.MessageOrBuilder, RewriterConfigOrBuilder

    public final class RewriterConfig
    extends org.nd4j.shade.protobuf.GeneratedMessageV3
    implements RewriterConfigOrBuilder
     Graph rewriting is experimental and subject to change, not covered by any
     API stability guarantees.
     
    Protobuf type tensorflow.RewriterConfig
    See Also:
    Serialized Form
    • Field Detail

      • LAYOUT_OPTIMIZER_FIELD_NUMBER

        public static final int LAYOUT_OPTIMIZER_FIELD_NUMBER
        See Also:
        Constant Field Values
      • CONSTANT_FOLDING_FIELD_NUMBER

        public static final int CONSTANT_FOLDING_FIELD_NUMBER
        See Also:
        Constant Field Values
      • SHAPE_OPTIMIZATION_FIELD_NUMBER

        public static final int SHAPE_OPTIMIZATION_FIELD_NUMBER
        See Also:
        Constant Field Values
      • ARITHMETIC_OPTIMIZATION_FIELD_NUMBER

        public static final int ARITHMETIC_OPTIMIZATION_FIELD_NUMBER
        See Also:
        Constant Field Values
      • DEPENDENCY_OPTIMIZATION_FIELD_NUMBER

        public static final int DEPENDENCY_OPTIMIZATION_FIELD_NUMBER
        See Also:
        Constant Field Values
      • LOOP_OPTIMIZATION_FIELD_NUMBER

        public static final int LOOP_OPTIMIZATION_FIELD_NUMBER
        See Also:
        Constant Field Values
      • FUNCTION_OPTIMIZATION_FIELD_NUMBER

        public static final int FUNCTION_OPTIMIZATION_FIELD_NUMBER
        See Also:
        Constant Field Values
      • DEBUG_STRIPPER_FIELD_NUMBER

        public static final int DEBUG_STRIPPER_FIELD_NUMBER
        See Also:
        Constant Field Values
      • DISABLE_MODEL_PRUNING_FIELD_NUMBER

        public static final int DISABLE_MODEL_PRUNING_FIELD_NUMBER
        See Also:
        Constant Field Values
      • SCOPED_ALLOCATOR_OPTIMIZATION_FIELD_NUMBER

        public static final int SCOPED_ALLOCATOR_OPTIMIZATION_FIELD_NUMBER
        See Also:
        Constant Field Values
      • META_OPTIMIZER_ITERATIONS_FIELD_NUMBER

        public static final int META_OPTIMIZER_ITERATIONS_FIELD_NUMBER
        See Also:
        Constant Field Values
      • MEMORY_OPTIMIZATION_FIELD_NUMBER

        public static final int MEMORY_OPTIMIZATION_FIELD_NUMBER
        See Also:
        Constant Field Values
      • MEMORY_OPTIMIZER_TARGET_NODE_NAME_SCOPE_FIELD_NUMBER

        public static final int MEMORY_OPTIMIZER_TARGET_NODE_NAME_SCOPE_FIELD_NUMBER
        See Also:
        Constant Field Values
      • AUTO_PARALLEL_FIELD_NUMBER

        public static final int AUTO_PARALLEL_FIELD_NUMBER
        See Also:
        Constant Field Values
      • SCOPED_ALLOCATOR_OPTS_FIELD_NUMBER

        public static final int SCOPED_ALLOCATOR_OPTS_FIELD_NUMBER
        See Also:
        Constant Field Values
      • OPTIMIZERS_FIELD_NUMBER

        public static final int OPTIMIZERS_FIELD_NUMBER
        See Also:
        Constant Field Values
      • CUSTOM_OPTIMIZERS_FIELD_NUMBER

        public static final int CUSTOM_OPTIMIZERS_FIELD_NUMBER
        See Also:
        Constant Field Values
    • Method Detail

      • newInstance

        protected Object newInstance​(org.nd4j.shade.protobuf.GeneratedMessageV3.UnusedPrivateParameter unused)
        Overrides:
        newInstance in class org.nd4j.shade.protobuf.GeneratedMessageV3
      • getUnknownFields

        public final org.nd4j.shade.protobuf.UnknownFieldSet getUnknownFields()
        Specified by:
        getUnknownFields in interface org.nd4j.shade.protobuf.MessageOrBuilder
        Overrides:
        getUnknownFields in class org.nd4j.shade.protobuf.GeneratedMessageV3
      • getDescriptor

        public static final org.nd4j.shade.protobuf.Descriptors.Descriptor getDescriptor()
      • internalGetFieldAccessorTable

        protected org.nd4j.shade.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
        Specified by:
        internalGetFieldAccessorTable in class org.nd4j.shade.protobuf.GeneratedMessageV3
      • getLayoutOptimizerValue

        public int getLayoutOptimizerValue()
         Optimize tensor layouts (default is ON)
         e.g. This will try to use NCHW layout on GPU which is faster.
         
        .tensorflow.RewriterConfig.Toggle layout_optimizer = 1;
        Specified by:
        getLayoutOptimizerValue in interface RewriterConfigOrBuilder
        Returns:
        The enum numeric value on the wire for layoutOptimizer.
      • getLayoutOptimizer

        public RewriterConfig.Toggle getLayoutOptimizer()
         Optimize tensor layouts (default is ON)
         e.g. This will try to use NCHW layout on GPU which is faster.
         
        .tensorflow.RewriterConfig.Toggle layout_optimizer = 1;
        Specified by:
        getLayoutOptimizer in interface RewriterConfigOrBuilder
        Returns:
        The layoutOptimizer.
      • getConstantFoldingValue

        public int getConstantFoldingValue()
         Fold constants (default is ON)
         Statically infer the value of tensors when possible, and materialize the
         result using constants.
         
        .tensorflow.RewriterConfig.Toggle constant_folding = 3;
        Specified by:
        getConstantFoldingValue in interface RewriterConfigOrBuilder
        Returns:
        The enum numeric value on the wire for constantFolding.
      • getConstantFolding

        public RewriterConfig.Toggle getConstantFolding()
         Fold constants (default is ON)
         Statically infer the value of tensors when possible, and materialize the
         result using constants.
         
        .tensorflow.RewriterConfig.Toggle constant_folding = 3;
        Specified by:
        getConstantFolding in interface RewriterConfigOrBuilder
        Returns:
        The constantFolding.
      • getShapeOptimizationValue

        public int getShapeOptimizationValue()
         Shape optimizations (default is ON)
         Simplify computations made on shapes.
         
        .tensorflow.RewriterConfig.Toggle shape_optimization = 13;
        Specified by:
        getShapeOptimizationValue in interface RewriterConfigOrBuilder
        Returns:
        The enum numeric value on the wire for shapeOptimization.
      • getRemappingValue

        public int getRemappingValue()
         Remapping (default is ON)
         Remap subgraphs onto more efficient implementations.
         
        .tensorflow.RewriterConfig.Toggle remapping = 14;
        Specified by:
        getRemappingValue in interface RewriterConfigOrBuilder
        Returns:
        The enum numeric value on the wire for remapping.
      • getArithmeticOptimizationValue

        public int getArithmeticOptimizationValue()
         Arithmetic optimizations (default is ON)
         e.g. Simplify arithmetic ops; merge ops with same value (like constants).
         
        .tensorflow.RewriterConfig.Toggle arithmetic_optimization = 7;
        Specified by:
        getArithmeticOptimizationValue in interface RewriterConfigOrBuilder
        Returns:
        The enum numeric value on the wire for arithmeticOptimization.
      • getArithmeticOptimization

        public RewriterConfig.Toggle getArithmeticOptimization()
         Arithmetic optimizations (default is ON)
         e.g. Simplify arithmetic ops; merge ops with same value (like constants).
         
        .tensorflow.RewriterConfig.Toggle arithmetic_optimization = 7;
        Specified by:
        getArithmeticOptimization in interface RewriterConfigOrBuilder
        Returns:
        The arithmeticOptimization.
      • getDependencyOptimizationValue

        public int getDependencyOptimizationValue()
         Control dependency optimizations (default is ON).
         Remove redundant control dependencies, which may enable other optimization.
         
        .tensorflow.RewriterConfig.Toggle dependency_optimization = 8;
        Specified by:
        getDependencyOptimizationValue in interface RewriterConfigOrBuilder
        Returns:
        The enum numeric value on the wire for dependencyOptimization.
      • getDependencyOptimization

        public RewriterConfig.Toggle getDependencyOptimization()
         Control dependency optimizations (default is ON).
         Remove redundant control dependencies, which may enable other optimization.
         
        .tensorflow.RewriterConfig.Toggle dependency_optimization = 8;
        Specified by:
        getDependencyOptimization in interface RewriterConfigOrBuilder
        Returns:
        The dependencyOptimization.
      • getLoopOptimizationValue

        public int getLoopOptimizationValue()
         Loop optimizations (default is ON).
         
        .tensorflow.RewriterConfig.Toggle loop_optimization = 9;
        Specified by:
        getLoopOptimizationValue in interface RewriterConfigOrBuilder
        Returns:
        The enum numeric value on the wire for loopOptimization.
      • getFunctionOptimizationValue

        public int getFunctionOptimizationValue()
         Function optimizations (default is ON).
         
        .tensorflow.RewriterConfig.Toggle function_optimization = 10;
        Specified by:
        getFunctionOptimizationValue in interface RewriterConfigOrBuilder
        Returns:
        The enum numeric value on the wire for functionOptimization.
      • getDebugStripperValue

        public int getDebugStripperValue()
         Strips debug-related nodes from the graph (off by default).
         
        .tensorflow.RewriterConfig.Toggle debug_stripper = 11;
        Specified by:
        getDebugStripperValue in interface RewriterConfigOrBuilder
        Returns:
        The enum numeric value on the wire for debugStripper.
      • getDisableModelPruning

        public boolean getDisableModelPruning()
         If true, don't remove unnecessary ops from the graph
         
        bool disable_model_pruning = 2;
        Specified by:
        getDisableModelPruning in interface RewriterConfigOrBuilder
        Returns:
        The disableModelPruning.
      • getScopedAllocatorOptimizationValue

        public int getScopedAllocatorOptimizationValue()
         Try to allocate some independent Op outputs contiguously in order to
         merge or eliminate downstream Ops (off by default).
         
        .tensorflow.RewriterConfig.Toggle scoped_allocator_optimization = 15;
        Specified by:
        getScopedAllocatorOptimizationValue in interface RewriterConfigOrBuilder
        Returns:
        The enum numeric value on the wire for scopedAllocatorOptimization.
      • getScopedAllocatorOptimization

        public RewriterConfig.Toggle getScopedAllocatorOptimization()
         Try to allocate some independent Op outputs contiguously in order to
         merge or eliminate downstream Ops (off by default).
         
        .tensorflow.RewriterConfig.Toggle scoped_allocator_optimization = 15;
        Specified by:
        getScopedAllocatorOptimization in interface RewriterConfigOrBuilder
        Returns:
        The scopedAllocatorOptimization.
      • getMetaOptimizerIterationsValue

        public int getMetaOptimizerIterationsValue()
         Controls how many times we run the optimizers in meta optimizer (default
         is once).
         
        .tensorflow.RewriterConfig.NumIterationsType meta_optimizer_iterations = 12;
        Specified by:
        getMetaOptimizerIterationsValue in interface RewriterConfigOrBuilder
        Returns:
        The enum numeric value on the wire for metaOptimizerIterations.
      • getMemoryOptimizationValue

        public int getMemoryOptimizationValue()
         Configures memory optimization passes through the meta-optimizer. Has no
         effect on manually requested memory optimization passes in the optimizers
         field.
         
        .tensorflow.RewriterConfig.MemOptType memory_optimization = 4;
        Specified by:
        getMemoryOptimizationValue in interface RewriterConfigOrBuilder
        Returns:
        The enum numeric value on the wire for memoryOptimization.
      • getMemoryOptimization

        public RewriterConfig.MemOptType getMemoryOptimization()
         Configures memory optimization passes through the meta-optimizer. Has no
         effect on manually requested memory optimization passes in the optimizers
         field.
         
        .tensorflow.RewriterConfig.MemOptType memory_optimization = 4;
        Specified by:
        getMemoryOptimization in interface RewriterConfigOrBuilder
        Returns:
        The memoryOptimization.
      • getMemoryOptimizerTargetNodeNameScope

        public String getMemoryOptimizerTargetNodeNameScope()
         A node name scope for node names which are valid outputs of recompuations.
         Inputs to nodes that match this scope may be recomputed (subject either to
         manual annotation of those input nodes or to manual annotation and
         heuristics depending on memory_optimization), but the nodes themselves will
         not be recomputed. This matches any sub-scopes as well, meaning the scope
         can appear not just as a top-level scope. For example, if the value is
         "gradients/", the default, it will match node name "gradients/foo",
         "foo/gradients/bar", but not "foo_gradients/"
         
        string memory_optimizer_target_node_name_scope = 6;
        Specified by:
        getMemoryOptimizerTargetNodeNameScope in interface RewriterConfigOrBuilder
        Returns:
        The memoryOptimizerTargetNodeNameScope.
      • getMemoryOptimizerTargetNodeNameScopeBytes

        public org.nd4j.shade.protobuf.ByteString getMemoryOptimizerTargetNodeNameScopeBytes()
         A node name scope for node names which are valid outputs of recompuations.
         Inputs to nodes that match this scope may be recomputed (subject either to
         manual annotation of those input nodes or to manual annotation and
         heuristics depending on memory_optimization), but the nodes themselves will
         not be recomputed. This matches any sub-scopes as well, meaning the scope
         can appear not just as a top-level scope. For example, if the value is
         "gradients/", the default, it will match node name "gradients/foo",
         "foo/gradients/bar", but not "foo_gradients/"
         
        string memory_optimizer_target_node_name_scope = 6;
        Specified by:
        getMemoryOptimizerTargetNodeNameScopeBytes in interface RewriterConfigOrBuilder
        Returns:
        The bytes for memoryOptimizerTargetNodeNameScope.
      • hasAutoParallel

        public boolean hasAutoParallel()
         Configures AutoParallel optimization passes either through the
         meta-optimizer or when manually specified through the optimizers field.
         
        .tensorflow.AutoParallelOptions auto_parallel = 5;
        Specified by:
        hasAutoParallel in interface RewriterConfigOrBuilder
        Returns:
        Whether the autoParallel field is set.
      • getAutoParallel

        public AutoParallelOptions getAutoParallel()
         Configures AutoParallel optimization passes either through the
         meta-optimizer or when manually specified through the optimizers field.
         
        .tensorflow.AutoParallelOptions auto_parallel = 5;
        Specified by:
        getAutoParallel in interface RewriterConfigOrBuilder
        Returns:
        The autoParallel.
      • hasScopedAllocatorOpts

        public boolean hasScopedAllocatorOpts()
        .tensorflow.ScopedAllocatorOptions scoped_allocator_opts = 16;
        Specified by:
        hasScopedAllocatorOpts in interface RewriterConfigOrBuilder
        Returns:
        Whether the scopedAllocatorOpts field is set.
      • getOptimizersList

        public org.nd4j.shade.protobuf.ProtocolStringList getOptimizersList()
         If non-empty, will use this as an alternative way to specify a list of
         optimizations to turn on and the order of the optimizations (replacing the
         meta-optimizer).
         Of the RewriterConfig options, only the AutoParallel configuration options
         (the auto_parallel field) apply to manually requested optimization passes
         ("autoparallel"). Memory optimization passes ("memory") invoked here are
         not configurable (in contrast to memory optimization passes through the
         meta-optimizer) and act only on manual op annotations.
         Custom registered optimizers will be run after the base optimizers, in
         the order that they are specified.
         
        repeated string optimizers = 100;
        Specified by:
        getOptimizersList in interface RewriterConfigOrBuilder
        Returns:
        A list containing the optimizers.
      • getOptimizersCount

        public int getOptimizersCount()
         If non-empty, will use this as an alternative way to specify a list of
         optimizations to turn on and the order of the optimizations (replacing the
         meta-optimizer).
         Of the RewriterConfig options, only the AutoParallel configuration options
         (the auto_parallel field) apply to manually requested optimization passes
         ("autoparallel"). Memory optimization passes ("memory") invoked here are
         not configurable (in contrast to memory optimization passes through the
         meta-optimizer) and act only on manual op annotations.
         Custom registered optimizers will be run after the base optimizers, in
         the order that they are specified.
         
        repeated string optimizers = 100;
        Specified by:
        getOptimizersCount in interface RewriterConfigOrBuilder
        Returns:
        The count of optimizers.
      • getOptimizers

        public String getOptimizers​(int index)
         If non-empty, will use this as an alternative way to specify a list of
         optimizations to turn on and the order of the optimizations (replacing the
         meta-optimizer).
         Of the RewriterConfig options, only the AutoParallel configuration options
         (the auto_parallel field) apply to manually requested optimization passes
         ("autoparallel"). Memory optimization passes ("memory") invoked here are
         not configurable (in contrast to memory optimization passes through the
         meta-optimizer) and act only on manual op annotations.
         Custom registered optimizers will be run after the base optimizers, in
         the order that they are specified.
         
        repeated string optimizers = 100;
        Specified by:
        getOptimizers in interface RewriterConfigOrBuilder
        Parameters:
        index - The index of the element to return.
        Returns:
        The optimizers at the given index.
      • getOptimizersBytes

        public org.nd4j.shade.protobuf.ByteString getOptimizersBytes​(int index)
         If non-empty, will use this as an alternative way to specify a list of
         optimizations to turn on and the order of the optimizations (replacing the
         meta-optimizer).
         Of the RewriterConfig options, only the AutoParallel configuration options
         (the auto_parallel field) apply to manually requested optimization passes
         ("autoparallel"). Memory optimization passes ("memory") invoked here are
         not configurable (in contrast to memory optimization passes through the
         meta-optimizer) and act only on manual op annotations.
         Custom registered optimizers will be run after the base optimizers, in
         the order that they are specified.
         
        repeated string optimizers = 100;
        Specified by:
        getOptimizersBytes in interface RewriterConfigOrBuilder
        Parameters:
        index - The index of the value to return.
        Returns:
        The bytes of the optimizers at the given index.
      • getCustomOptimizersCount

        public int getCustomOptimizersCount()
         list of CustomGraphOptimizers to apply.
         
        repeated .tensorflow.RewriterConfig.CustomGraphOptimizer custom_optimizers = 200;
        Specified by:
        getCustomOptimizersCount in interface RewriterConfigOrBuilder
      • isInitialized

        public final boolean isInitialized()
        Specified by:
        isInitialized in interface org.nd4j.shade.protobuf.MessageLiteOrBuilder
        Overrides:
        isInitialized in class org.nd4j.shade.protobuf.GeneratedMessageV3
      • writeTo

        public void writeTo​(org.nd4j.shade.protobuf.CodedOutputStream output)
                     throws IOException
        Specified by:
        writeTo in interface org.nd4j.shade.protobuf.MessageLite
        Overrides:
        writeTo in class org.nd4j.shade.protobuf.GeneratedMessageV3
        Throws:
        IOException
      • getSerializedSize

        public int getSerializedSize()
        Specified by:
        getSerializedSize in interface org.nd4j.shade.protobuf.MessageLite
        Overrides:
        getSerializedSize in class org.nd4j.shade.protobuf.GeneratedMessageV3
      • equals

        public boolean equals​(Object obj)
        Specified by:
        equals in interface org.nd4j.shade.protobuf.Message
        Overrides:
        equals in class org.nd4j.shade.protobuf.AbstractMessage
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface org.nd4j.shade.protobuf.Message
        Overrides:
        hashCode in class org.nd4j.shade.protobuf.AbstractMessage
      • parseFrom

        public static RewriterConfig parseFrom​(ByteBuffer data)
                                        throws org.nd4j.shade.protobuf.InvalidProtocolBufferException
        Throws:
        org.nd4j.shade.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static RewriterConfig parseFrom​(ByteBuffer data,
                                               org.nd4j.shade.protobuf.ExtensionRegistryLite extensionRegistry)
                                        throws org.nd4j.shade.protobuf.InvalidProtocolBufferException
        Throws:
        org.nd4j.shade.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static RewriterConfig parseFrom​(org.nd4j.shade.protobuf.ByteString data)
                                        throws org.nd4j.shade.protobuf.InvalidProtocolBufferException
        Throws:
        org.nd4j.shade.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static RewriterConfig parseFrom​(org.nd4j.shade.protobuf.ByteString data,
                                               org.nd4j.shade.protobuf.ExtensionRegistryLite extensionRegistry)
                                        throws org.nd4j.shade.protobuf.InvalidProtocolBufferException
        Throws:
        org.nd4j.shade.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static RewriterConfig parseFrom​(byte[] data)
                                        throws org.nd4j.shade.protobuf.InvalidProtocolBufferException
        Throws:
        org.nd4j.shade.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static RewriterConfig parseFrom​(byte[] data,
                                               org.nd4j.shade.protobuf.ExtensionRegistryLite extensionRegistry)
                                        throws org.nd4j.shade.protobuf.InvalidProtocolBufferException
        Throws:
        org.nd4j.shade.protobuf.InvalidProtocolBufferException
      • parseFrom

        public static RewriterConfig parseFrom​(org.nd4j.shade.protobuf.CodedInputStream input,
                                               org.nd4j.shade.protobuf.ExtensionRegistryLite extensionRegistry)
                                        throws IOException
        Throws:
        IOException
      • newBuilderForType

        public RewriterConfig.Builder newBuilderForType()
        Specified by:
        newBuilderForType in interface org.nd4j.shade.protobuf.Message
        Specified by:
        newBuilderForType in interface org.nd4j.shade.protobuf.MessageLite
      • toBuilder

        public RewriterConfig.Builder toBuilder()
        Specified by:
        toBuilder in interface org.nd4j.shade.protobuf.Message
        Specified by:
        toBuilder in interface org.nd4j.shade.protobuf.MessageLite
      • newBuilderForType

        protected RewriterConfig.Builder newBuilderForType​(org.nd4j.shade.protobuf.GeneratedMessageV3.BuilderParent parent)
        Specified by:
        newBuilderForType in class org.nd4j.shade.protobuf.GeneratedMessageV3
      • getDefaultInstance

        public static RewriterConfig getDefaultInstance()
      • parser

        public static org.nd4j.shade.protobuf.Parser<RewriterConfig> parser()
      • getParserForType

        public org.nd4j.shade.protobuf.Parser<RewriterConfig> getParserForType()
        Specified by:
        getParserForType in interface org.nd4j.shade.protobuf.Message
        Specified by:
        getParserForType in interface org.nd4j.shade.protobuf.MessageLite
        Overrides:
        getParserForType in class org.nd4j.shade.protobuf.GeneratedMessageV3
      • getDefaultInstanceForType

        public RewriterConfig getDefaultInstanceForType()
        Specified by:
        getDefaultInstanceForType in interface org.nd4j.shade.protobuf.MessageLiteOrBuilder
        Specified by:
        getDefaultInstanceForType in interface org.nd4j.shade.protobuf.MessageOrBuilder