Class MLCTrainingGraph

  • All Implemented Interfaces:
    NSObject

    @Deprecated
    public class MLCTrainingGraph
    extends MLCGraph
    Deprecated.
    MLCTrainingGraph A training graph created from one or more MLCGraph objects plus additional layers added directly to the training graph. API-Since: 14.0 Deprecated-Since: 100000.0 Deprecated-Message: Use Metal Performance Shaders Graph or BNNS instead.
    • Constructor Detail

      • MLCTrainingGraph

        protected MLCTrainingGraph​(org.moe.natj.general.Pointer peer)
        Deprecated.
    • Method Detail

      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
        Deprecated.
      • addInputsLossLabels

        public boolean addInputsLossLabels​(@NotNull
                                           @NotNull NSDictionary<java.lang.String,​? extends MLCTensor> inputs,
                                           @Nullable
                                           @Nullable NSDictionary<java.lang.String,​? extends MLCTensor> lossLabels)
        Deprecated.
        Add the list of inputs to the training graph
        Parameters:
        inputs - The inputs
        lossLabels - The loss label inputs
        Returns:
        A boolean indicating success or failure
      • addInputsLossLabelsLossLabelWeights

        public boolean addInputsLossLabelsLossLabelWeights​(@NotNull
                                                           @NotNull NSDictionary<java.lang.String,​? extends MLCTensor> inputs,
                                                           @Nullable
                                                           @Nullable NSDictionary<java.lang.String,​? extends MLCTensor> lossLabels,
                                                           @Nullable
                                                           @Nullable NSDictionary<java.lang.String,​? extends MLCTensor> lossLabelWeights)
        Deprecated.
        Add the list of inputs to the training graph Each input, loss label or label weights tensor is identified by a NSString. When the training graph is executed, this NSString is used to identify which data object should be as input data for each tensor whose device memory needs to be updated before the graph is executed.
        Parameters:
        inputs - The inputs
        lossLabels - The loss label inputs
        lossLabelWeights - The loss label weights
        Returns:
        A boolean indicating success or failure
      • addOutputs

        public boolean addOutputs​(@NotNull
                                  @NotNull NSDictionary<java.lang.String,​? extends MLCTensor> outputs)
        Deprecated.
        Add the list of outputs to the training graph
        Parameters:
        outputs - The outputs
        Returns:
        A boolean indicating success or failure
      • allocWithZone

        public static MLCTrainingGraph allocWithZone​(org.moe.natj.general.ptr.VoidPtr zone)
        Deprecated.
      • allocateUserGradientForTensor

        @Nullable
        public @Nullable MLCTensor allocateUserGradientForTensor​(@NotNull
                                                                 @NotNull MLCTensor tensor)
        Deprecated.
        Allocate an entry for a user specified gradient for a tensor
        Parameters:
        tensor - A result tensor produced by a layer in the training graph that is input to some user specified code and will need to provide a user gradient during the gradient pass.
        Returns:
        A gradient tensor
      • automaticallyNotifiesObserversForKey

        public static boolean automaticallyNotifiesObserversForKey​(@NotNull
                                                                   @NotNull java.lang.String key)
        Deprecated.
      • bindOptimizerDataDeviceDataWithTensor

        public boolean bindOptimizerDataDeviceDataWithTensor​(@NotNull
                                                             @NotNull NSArray<? extends MLCTensorData> data,
                                                             @Nullable
                                                             @Nullable NSArray<? extends MLCTensorOptimizerDeviceData> deviceData,
                                                             @NotNull
                                                             @NotNull MLCTensor tensor)
        Deprecated.
        Associates the given optimizer data and device data buffers with the tensor. Returns true if the data is successfully associated with the tensor and copied to the device. The caller must guarantee the lifetime of the underlying memory of \p data for the entirety of the tensor's lifetime. The \p deviceData buffers are allocated by MLCompute. This method must be called before executeOptimizerUpdateWithOptions or executeWithInputsData is called for the training graph. We recommend using this method instead of using [MLCTensor bindOptimizerData] especially if the optimizer update is being called multiple times for each batch.
        Parameters:
        data - The optimizer data to be associated with the tensor
        deviceData - The optimizer device data to be associated with the tensor
        tensor - The tensor
        Returns:
        A Boolean value indicating whether the data is successfully associated with the tensor .
      • cancelPreviousPerformRequestsWithTarget

        public static void cancelPreviousPerformRequestsWithTarget​(@NotNull
                                                                   @NotNull java.lang.Object aTarget)
        Deprecated.
      • cancelPreviousPerformRequestsWithTargetSelectorObject

        public static void cancelPreviousPerformRequestsWithTargetSelectorObject​(@NotNull
                                                                                 @NotNull java.lang.Object aTarget,
                                                                                 @NotNull
                                                                                 @NotNull org.moe.natj.objc.SEL aSelector,
                                                                                 @Nullable
                                                                                 @Nullable java.lang.Object anArgument)
        Deprecated.
      • classFallbacksForKeyedArchiver

        @NotNull
        public static @NotNull NSArray<java.lang.String> classFallbacksForKeyedArchiver()
        Deprecated.
      • classForKeyedUnarchiver

        @NotNull
        public static @NotNull org.moe.natj.objc.Class classForKeyedUnarchiver()
        Deprecated.
      • compileOptimizer

        public boolean compileOptimizer​(@NotNull
                                        @NotNull MLCOptimizer optimizer)
        Deprecated.
        Compile the optimizer to be used with a training graph. Typically the optimizer to be used with a training graph is specifed when the training graph is created using graphWithGraphObjects:lossLayer:optimizer. The optimizer will be compiled in when compileWithOptions:device is called if an optimizer is specified with the training graph. In the case where the optimizer to be used is not known when the graph is created or compiled, this method can be used to associate and compile a training graph with an optimizer.
        Parameters:
        optimizer - The MLCOptimizer object
        Returns:
        A boolean indicating success or failure
      • compileWithOptionsDevice

        public boolean compileWithOptionsDevice​(long options,
                                                @NotNull
                                                @NotNull MLCDevice device)
        Deprecated.
        Compile the training graph for a device.
        Parameters:
        options - The compiler options to use when compiling the training graph
        device - The MLCDevice object
        Returns:
        A boolean indicating success or failure
      • compileWithOptionsDeviceInputTensorsInputTensorsData

        public boolean compileWithOptionsDeviceInputTensorsInputTensorsData​(long options,
                                                                            @NotNull
                                                                            @NotNull MLCDevice device,
                                                                            @Nullable
                                                                            @Nullable NSDictionary<java.lang.String,​? extends MLCTensor> inputTensors,
                                                                            @Nullable
                                                                            @Nullable NSDictionary<java.lang.String,​? extends MLCTensorData> inputTensorsData)
        Deprecated.
        Compile the training graph for a device. Specifying the list of constant tensors when we compile the graph allows MLCompute to perform additional optimizations at compile time.
        Parameters:
        options - The compiler options to use when compiling the training graph
        device - The MLCDevice object
        inputTensors - The list of input tensors that are constants
        inputTensorsData - The tensor data to be used with these constant input tensors
        Returns:
        A boolean indicating success or failure API-Since: 14.5
      • debugDescription_static

        public static java.lang.String debugDescription_static()
        Deprecated.
      • description_static

        public static java.lang.String description_static()
        Deprecated.
      • deviceMemorySize

        public long deviceMemorySize()
        Deprecated.
        [@property] The device memory size used by the training graph Returns the total size in bytes of device memory used for all intermediate tensors for forward, gradient passes and optimizer update for all layers in the training graph. We recommend executing an iteration before checking the device memory size as the buffers needed get allocated when the corresponding pass such as gradient, optimizer update is executed.
        Returns:
        A NSUInteger value
      • executeForwardWithBatchSizeOptionsCompletionHandler

        public boolean executeForwardWithBatchSizeOptionsCompletionHandler​(long batchSize,
                                                                           long options,
                                                                           @Nullable
                                                                           @Nullable MLCTrainingGraph.Block_executeForwardWithBatchSizeOptionsCompletionHandler completionHandler)
        Deprecated.
        Execute the forward pass of the training graph
        Parameters:
        batchSize - The batch size to use. For a graph where batch size changes between layers this value must be 0.
        options - The execution options
        completionHandler - The completion handler
        Returns:
        A boolean indicating success or failure
      • executeForwardWithBatchSizeOptionsOutputsDataCompletionHandler

        public boolean executeForwardWithBatchSizeOptionsOutputsDataCompletionHandler​(long batchSize,
                                                                                      long options,
                                                                                      @Nullable
                                                                                      @Nullable NSDictionary<java.lang.String,​? extends MLCTensorData> outputsData,
                                                                                      @Nullable
                                                                                      @Nullable MLCTrainingGraph.Block_executeForwardWithBatchSizeOptionsOutputsDataCompletionHandler completionHandler)
        Deprecated.
        Execute the forward pass for the training graph
        Parameters:
        batchSize - The batch size to use. For a graph where batch size changes between layers this value must be 0.
        options - The execution options
        outputsData - The data objects to use for outputs
        completionHandler - The completion handler
        Returns:
        A boolean indicating success or failure
      • executeGradientWithBatchSizeOptionsCompletionHandler

        public boolean executeGradientWithBatchSizeOptionsCompletionHandler​(long batchSize,
                                                                            long options,
                                                                            @Nullable
                                                                            @Nullable MLCTrainingGraph.Block_executeGradientWithBatchSizeOptionsCompletionHandler completionHandler)
        Deprecated.
        Execute the gradient pass of the training graph
        Parameters:
        batchSize - The batch size to use. For a graph where batch size changes between layers this value must be 0.
        options - The execution options
        completionHandler - The completion handler
        Returns:
        A boolean indicating success or failure
      • executeGradientWithBatchSizeOptionsOutputsDataCompletionHandler

        public boolean executeGradientWithBatchSizeOptionsOutputsDataCompletionHandler​(long batchSize,
                                                                                       long options,
                                                                                       @Nullable
                                                                                       @Nullable NSDictionary<java.lang.String,​? extends MLCTensorData> outputsData,
                                                                                       @Nullable
                                                                                       @Nullable MLCTrainingGraph.Block_executeGradientWithBatchSizeOptionsOutputsDataCompletionHandler completionHandler)
        Deprecated.
        Execute the gradient pass of the training graph
        Parameters:
        batchSize - The batch size to use. For a graph where batch size changes between layers this value must be 0.
        options - The execution options
        outputsData - The data objects to use for outputs
        completionHandler - The completion handler
        Returns:
        A boolean indicating success or failure
      • executeOptimizerUpdateWithOptionsCompletionHandler

        public boolean executeOptimizerUpdateWithOptionsCompletionHandler​(long options,
                                                                          @Nullable
                                                                          @Nullable MLCTrainingGraph.Block_executeOptimizerUpdateWithOptionsCompletionHandler completionHandler)
        Deprecated.
        Execute the optimizer update pass of the training graph
        Parameters:
        options - The execution options
        completionHandler - The completion handler
        Returns:
        A boolean indicating success or failure
      • executeWithInputsDataLossLabelsDataLossLabelWeightsDataBatchSizeOptionsCompletionHandler

        public boolean executeWithInputsDataLossLabelsDataLossLabelWeightsDataBatchSizeOptionsCompletionHandler​(@NotNull
                                                                                                                @NotNull NSDictionary<java.lang.String,​? extends MLCTensorData> inputsData,
                                                                                                                @Nullable
                                                                                                                @Nullable NSDictionary<java.lang.String,​? extends MLCTensorData> lossLabelsData,
                                                                                                                @Nullable
                                                                                                                @Nullable NSDictionary<java.lang.String,​? extends MLCTensorData> lossLabelWeightsData,
                                                                                                                long batchSize,
                                                                                                                long options,
                                                                                                                @Nullable
                                                                                                                @Nullable MLCTrainingGraph.Block_executeWithInputsDataLossLabelsDataLossLabelWeightsDataBatchSizeOptionsCompletionHandler completionHandler)
        Deprecated.
        Execute the training graph (forward, gradient and optimizer update) with given source and label data Execute the training graph with given source and label data. If an optimizer is specified, the optimizer update is applied. If MLCExecutionOptionsSynchronous is specified in 'options', this method returns after the graph has been executed. Otherwise, this method returns after the graph has been queued for execution. The completion handler is called after the graph has finished execution.
        Parameters:
        inputsData - The data objects to use for inputs
        lossLabelsData - The data objects to use for loss labels
        lossLabelWeightsData - The data objects to use for loss label weights
        batchSize - The batch size to use. For a graph where batch size changes between layers this value must be 0.
        options - The execution options
        completionHandler - The completion handler
        Returns:
        A boolean indicating success or failure
      • executeWithInputsDataLossLabelsDataLossLabelWeightsDataOutputsDataBatchSizeOptionsCompletionHandler

        public boolean executeWithInputsDataLossLabelsDataLossLabelWeightsDataOutputsDataBatchSizeOptionsCompletionHandler​(@NotNull
                                                                                                                           @NotNull NSDictionary<java.lang.String,​? extends MLCTensorData> inputsData,
                                                                                                                           @Nullable
                                                                                                                           @Nullable NSDictionary<java.lang.String,​? extends MLCTensorData> lossLabelsData,
                                                                                                                           @Nullable
                                                                                                                           @Nullable NSDictionary<java.lang.String,​? extends MLCTensorData> lossLabelWeightsData,
                                                                                                                           @Nullable
                                                                                                                           @Nullable NSDictionary<java.lang.String,​? extends MLCTensorData> outputsData,
                                                                                                                           long batchSize,
                                                                                                                           long options,
                                                                                                                           @Nullable
                                                                                                                           @Nullable MLCTrainingGraph.Block_executeWithInputsDataLossLabelsDataLossLabelWeightsDataOutputsDataBatchSizeOptionsCompletionHandler completionHandler)
        Deprecated.
        Execute the training graph (forward, gradient and optimizer update) with given source and label data
        Parameters:
        inputsData - The data objects to use for inputs
        lossLabelsData - The data objects to use for loss labels
        lossLabelWeightsData - The data objects to use for loss label weights
        outputsData - The data objects to use for outputs
        batchSize - The batch size to use. For a graph where batch size changes between layers this value must be 0.
        options - The execution options
        completionHandler - The completion handler
        Returns:
        A boolean indicating success or failure
      • gradientDataForParameterLayer

        @Nullable
        public @Nullable NSData gradientDataForParameterLayer​(@NotNull
                                                              @NotNull MLCTensor parameter,
                                                              @NotNull
                                                              @NotNull MLCLayer layer)
        Deprecated.
        Get the gradient data for a trainable parameter associated with a layer This can be used to get the gradient data for weights or biases parameters associated with a convolution, fully connected or convolution transpose layer
        Parameters:
        parameter - The updatable parameter associated with the layer
        layer - A layer in the training graph. Must be one of the following: - MLCConvolutionLayer - MLCFullyConnectedLayer - MLCBatchNormalizationLayer - MLCInstanceNormalizationLayer - MLCGroupNormalizationLayer - MLCLayerNormalizationLayer - MLCEmbeddingLayer - MLCMultiheadAttentionLayer
        Returns:
        The gradient data. Will return nil if the layer is marked as not trainable or if training graph is not executed with separate calls to forward and gradient passes.
      • gradientTensorForInput

        @Nullable
        public @Nullable MLCTensor gradientTensorForInput​(@NotNull
                                                          @NotNull MLCTensor input)
        Deprecated.
        Get the gradient tensor for an input tensor
        Parameters:
        input - The input tensor
        Returns:
        The gradient tensor
      • graphWithGraphObjectsLossLayerOptimizer

        public static MLCTrainingGraph graphWithGraphObjectsLossLayerOptimizer​(@NotNull
                                                                               @NotNull NSArray<? extends MLCGraph> graphObjects,
                                                                               @Nullable
                                                                               @Nullable MLCLayer lossLayer,
                                                                               @Nullable
                                                                               @Nullable MLCOptimizer optimizer)
        Deprecated.
        Create a training graph
        Parameters:
        graphObjects - The layers from these graph objects will be added to the training graph
        lossLayer - The loss layer to use. The loss layer can also be added to the training graph using nodeWithLayer:sources:lossLabels
        optimizer - The optimizer to use
        Returns:
        A new training graph object
      • hash_static

        public static long hash_static()
        Deprecated.
      • instanceMethodSignatureForSelector

        public static NSMethodSignature instanceMethodSignatureForSelector​(org.moe.natj.objc.SEL aSelector)
        Deprecated.
      • instancesRespondToSelector

        public static boolean instancesRespondToSelector​(org.moe.natj.objc.SEL aSelector)
        Deprecated.
      • isSubclassOfClass

        public static boolean isSubclassOfClass​(org.moe.natj.objc.Class aClass)
        Deprecated.
      • keyPathsForValuesAffectingValueForKey

        @NotNull
        public static @NotNull NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey​(@NotNull
                                                                                             @NotNull java.lang.String key)
        Deprecated.
      • linkWithGraphs

        public boolean linkWithGraphs​(@NotNull
                                      @NotNull NSArray<? extends MLCTrainingGraph> graphs)
        Deprecated.
        Link mutiple training graphs This is used to link subsequent training graphs with first training sub-graph. This method should be used when we have tensors shared by one or more layers in multiple sub-graphs
        Parameters:
        graphs - The list of training graphs to link
        Returns:
        A boolean indicating success or failure
      • optimizer

        @Nullable
        public @Nullable MLCOptimizer optimizer()
        Deprecated.
        [@property] optimizer The optimizer to be used with the training graph
      • resolveClassMethod

        public static boolean resolveClassMethod​(org.moe.natj.objc.SEL sel)
        Deprecated.
      • resolveInstanceMethod

        public static boolean resolveInstanceMethod​(org.moe.natj.objc.SEL sel)
        Deprecated.
      • resultGradientTensorsForLayer

        @NotNull
        public @NotNull NSArray<? extends MLCTensor> resultGradientTensorsForLayer​(@NotNull
                                                                                   @NotNull MLCLayer layer)
        Deprecated.
        Get the result gradient tensors for a layer in the training graph
        Parameters:
        layer - A layer in the training graph
        Returns:
        A list of tensors
      • setTrainingTensorParameters

        public boolean setTrainingTensorParameters​(@NotNull
                                                   @NotNull NSArray<? extends MLCTensorParameter> parameters)
        Deprecated.
        Set the input tensor parameters that also will be updated by the optimizer These represent the list of input tensors to be updated when we execute the optimizer update Weights, bias or beta, gamma tensors are not included in this list. MLCompute automatically adds them to the parameter list based on whether the layer is marked as updatable or not.
        Parameters:
        parameters - The list of input tensors to be updated by the optimizer
        Returns:
        A boolean indicating success or failure
      • setVersion_static

        public static void setVersion_static​(long aVersion)
        Deprecated.
      • sourceGradientTensorsForLayer

        @NotNull
        public @NotNull NSArray<? extends MLCTensor> sourceGradientTensorsForLayer​(@NotNull
                                                                                   @NotNull MLCLayer layer)
        Deprecated.
        Get the source gradient tensors for a layer in the training graph
        Parameters:
        layer - A layer in the training graph
        Returns:
        A list of tensors
      • stopGradientForTensors

        public boolean stopGradientForTensors​(@NotNull
                                              @NotNull NSArray<? extends MLCTensor> tensors)
        Deprecated.
        Add the list of tensors whose contributions are not to be taken when computing gradients during gradient pass
        Parameters:
        tensors - The list of tensors
        Returns:
        A boolean indicating success or failure
      • superclass_static

        public static org.moe.natj.objc.Class superclass_static()
        Deprecated.
      • synchronizeUpdates

        public void synchronizeUpdates()
        Deprecated.
        Synchronize updates (weights/biases from convolution, fully connected and LSTM layers, tensor parameters) from device memory to host memory.
      • version_static

        public static long version_static()
        Deprecated.
      • useStoredAccessor

        @Deprecated
        public static boolean useStoredAccessor()
        Deprecated.