| Modifier and Type | Class and Description |
|---|---|
static interface |
MLCTrainingGraph.Block_executeForwardWithBatchSizeOptionsCompletionHandler |
static interface |
MLCTrainingGraph.Block_executeForwardWithBatchSizeOptionsOutputsDataCompletionHandler |
static interface |
MLCTrainingGraph.Block_executeGradientWithBatchSizeOptionsCompletionHandler |
static interface |
MLCTrainingGraph.Block_executeGradientWithBatchSizeOptionsOutputsDataCompletionHandler |
static interface |
MLCTrainingGraph.Block_executeOptimizerUpdateWithOptionsCompletionHandler |
static interface |
MLCTrainingGraph.Block_executeWithInputsDataLossLabelsDataLossLabelWeightsDataBatchSizeOptionsCompletionHandler |
static interface |
MLCTrainingGraph.Block_executeWithInputsDataLossLabelsDataLossLabelWeightsDataOutputsDataBatchSizeOptionsCompletionHandler |
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_ret| Modifier | Constructor and Description |
|---|---|
protected |
MLCTrainingGraph(org.moe.natj.general.Pointer peer) |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
accessInstanceVariablesDirectly() |
boolean |
addInputsLossLabels(NSDictionary<java.lang.String,? extends MLCTensor> inputs,
NSDictionary<java.lang.String,? extends MLCTensor> lossLabels)
Add the list of inputs to the training graph
|
boolean |
addInputsLossLabelsLossLabelWeights(NSDictionary<java.lang.String,? extends MLCTensor> inputs,
NSDictionary<java.lang.String,? extends MLCTensor> lossLabels,
NSDictionary<java.lang.String,? extends MLCTensor> lossLabelWeights)
Add the list of inputs to the training graph
|
boolean |
addOutputs(NSDictionary<java.lang.String,? extends MLCTensor> outputs)
Add the list of outputs to the training graph
|
static MLCTrainingGraph |
alloc() |
MLCTensor |
allocateUserGradientForTensor(MLCTensor tensor)
Allocate an entry for a user specified gradient for a tensor
|
static MLCTrainingGraph |
allocWithZone(org.moe.natj.general.ptr.VoidPtr zone) |
static boolean |
automaticallyNotifiesObserversForKey(java.lang.String key) |
boolean |
bindOptimizerDataDeviceDataWithTensor(NSArray<? extends MLCTensorData> data,
NSArray<? extends MLCTensorOptimizerDeviceData> deviceData,
MLCTensor tensor)
Associates the given optimizer data and device data buffers with the tensor.
|
static void |
cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget) |
static void |
cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument) |
static NSArray<java.lang.String> |
classFallbacksForKeyedArchiver() |
static org.moe.natj.objc.Class |
classForKeyedUnarchiver() |
boolean |
compileOptimizer(MLCOptimizer optimizer)
Compile the optimizer to be used with a training graph.
|
boolean |
compileWithOptionsDevice(long options,
MLCDevice device)
Compile the training graph for a device.
|
boolean |
compileWithOptionsDeviceInputTensorsInputTensorsData(long options,
MLCDevice device,
NSDictionary<java.lang.String,? extends MLCTensor> inputTensors,
NSDictionary<java.lang.String,? extends MLCTensorData> inputTensorsData)
Compile the training graph for a device.
|
static java.lang.String |
debugDescription_static() |
static java.lang.String |
description_static() |
long |
deviceMemorySize()
[@property] The device memory size used by the training graph
|
boolean |
executeForwardWithBatchSizeOptionsCompletionHandler(long batchSize,
long options,
MLCTrainingGraph.Block_executeForwardWithBatchSizeOptionsCompletionHandler completionHandler)
Execute the forward pass of the training graph
|
boolean |
executeForwardWithBatchSizeOptionsOutputsDataCompletionHandler(long batchSize,
long options,
NSDictionary<java.lang.String,? extends MLCTensorData> outputsData,
MLCTrainingGraph.Block_executeForwardWithBatchSizeOptionsOutputsDataCompletionHandler completionHandler)
Execute the forward pass for the training graph
|
boolean |
executeGradientWithBatchSizeOptionsCompletionHandler(long batchSize,
long options,
MLCTrainingGraph.Block_executeGradientWithBatchSizeOptionsCompletionHandler completionHandler)
Execute the gradient pass of the training graph
|
boolean |
executeGradientWithBatchSizeOptionsOutputsDataCompletionHandler(long batchSize,
long options,
NSDictionary<java.lang.String,? extends MLCTensorData> outputsData,
MLCTrainingGraph.Block_executeGradientWithBatchSizeOptionsOutputsDataCompletionHandler completionHandler)
Execute the gradient pass of the training graph
|
boolean |
executeOptimizerUpdateWithOptionsCompletionHandler(long options,
MLCTrainingGraph.Block_executeOptimizerUpdateWithOptionsCompletionHandler completionHandler)
Execute the optimizer update pass of the training graph
|
boolean |
executeWithInputsDataLossLabelsDataLossLabelWeightsDataBatchSizeOptionsCompletionHandler(NSDictionary<java.lang.String,? extends MLCTensorData> inputsData,
NSDictionary<java.lang.String,? extends MLCTensorData> lossLabelsData,
NSDictionary<java.lang.String,? extends MLCTensorData> lossLabelWeightsData,
long batchSize,
long options,
MLCTrainingGraph.Block_executeWithInputsDataLossLabelsDataLossLabelWeightsDataBatchSizeOptionsCompletionHandler completionHandler)
Execute the training graph (forward, gradient and optimizer update) with given source and label data
|
boolean |
executeWithInputsDataLossLabelsDataLossLabelWeightsDataOutputsDataBatchSizeOptionsCompletionHandler(NSDictionary<java.lang.String,? extends MLCTensorData> inputsData,
NSDictionary<java.lang.String,? extends MLCTensorData> lossLabelsData,
NSDictionary<java.lang.String,? extends MLCTensorData> lossLabelWeightsData,
NSDictionary<java.lang.String,? extends MLCTensorData> outputsData,
long batchSize,
long options,
MLCTrainingGraph.Block_executeWithInputsDataLossLabelsDataLossLabelWeightsDataOutputsDataBatchSizeOptionsCompletionHandler completionHandler)
Execute the training graph (forward, gradient and optimizer update) with given source and label data
|
NSData |
gradientDataForParameterLayer(MLCTensor parameter,
MLCLayer layer)
Get the gradient data for a trainable parameter associated with a layer
|
MLCTensor |
gradientTensorForInput(MLCTensor input)
Get the gradient tensor for an input tensor
|
static MLCTrainingGraph |
graph() |
static MLCTrainingGraph |
graphWithGraphObjectsLossLayerOptimizer(NSArray<? extends MLCGraph> graphObjects,
MLCLayer lossLayer,
MLCOptimizer optimizer)
Create a training graph
|
static long |
hash_static() |
MLCTrainingGraph |
init() |
static NSObject.Function_instanceMethodForSelector_ret |
instanceMethodForSelector(org.moe.natj.objc.SEL aSelector) |
static NSMethodSignature |
instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector) |
static boolean |
instancesRespondToSelector(org.moe.natj.objc.SEL aSelector) |
static boolean |
isSubclassOfClass(org.moe.natj.objc.Class aClass) |
static NSSet<java.lang.String> |
keyPathsForValuesAffectingValueForKey(java.lang.String key) |
boolean |
linkWithGraphs(NSArray<? extends MLCTrainingGraph> graphs)
Link mutiple training graphs
|
static MLCTrainingGraph |
new_objc() |
MLCOptimizer |
optimizer()
[@property] optimizer
|
static boolean |
resolveClassMethod(org.moe.natj.objc.SEL sel) |
static boolean |
resolveInstanceMethod(org.moe.natj.objc.SEL sel) |
NSArray<? extends MLCTensor> |
resultGradientTensorsForLayer(MLCLayer layer)
Get the result gradient tensors for a layer in the training graph
|
boolean |
setTrainingTensorParameters(NSArray<? extends MLCTensorParameter> parameters)
Set the input tensor parameters that also will be updated by the optimizer
|
static void |
setVersion_static(long aVersion) |
NSArray<? extends MLCTensor> |
sourceGradientTensorsForLayer(MLCLayer layer)
Get the source gradient tensors for a layer in the training graph
|
boolean |
stopGradientForTensors(NSArray<? extends MLCTensor> tensors)
Add the list of tensors whose contributions are not to be taken when computing gradients during gradient pass
|
static org.moe.natj.objc.Class |
superclass_static() |
void |
synchronizeUpdates()
Synchronize updates (weights/biases from convolution, fully connected and LSTM layers, tensor parameters)
from device memory to host memory.
|
static long |
version_static() |
bindAndWriteDataForInputsToDeviceBatchSizeSynchronous, bindAndWriteDataForInputsToDeviceSynchronous, concatenateWithSourcesDimension, device, gatherWithDimensionSourceIndices, layers, nodeWithLayerSource, nodeWithLayerSources, nodeWithLayerSourcesDisableUpdate, nodeWithLayerSourcesLossLabels, reshapeWithShapeSource, resultTensorsForLayer, scatterWithDimensionSourceIndicesCopyFromReductionType, selectWithSourcesCondition, sourceTensorsForLayer, splitWithSourceSplitCountDimension, splitWithSourceSplitSectionLengthsDimension, summarizedDOTDescription, transposeWithDimensionsSourceaccessibilityActivate, accessibilityActivationPoint, accessibilityAssistiveTechnologyFocusedIdentifiers, accessibilityAttributedHint, accessibilityAttributedLabel, accessibilityAttributedUserInputLabels, accessibilityAttributedValue, accessibilityContainerType, accessibilityCustomActions, accessibilityCustomRotors, accessibilityDecrement, accessibilityDragSourceDescriptors, accessibilityDropPointDescriptors, accessibilityElementAtIndex, accessibilityElementCount, accessibilityElementDidBecomeFocused, accessibilityElementDidLoseFocus, accessibilityElementIsFocused, accessibilityElements, accessibilityElementsHidden, accessibilityFrame, accessibilityHint, accessibilityIncrement, accessibilityLabel, accessibilityLanguage, accessibilityNavigationStyle, accessibilityPath, accessibilityPerformEscape, accessibilityPerformMagicTap, accessibilityRespondsToUserInteraction, accessibilityScroll, accessibilityTextualContext, accessibilityTraits, accessibilityUserInputLabels, accessibilityValue, accessibilityViewIsModal, addObserverForKeyPathOptionsContext, attemptRecoveryFromErrorOptionIndex, attemptRecoveryFromErrorOptionIndexDelegateDidRecoverSelectorContextInfo, autoContentAccessingProxy, awakeAfterUsingCoder, awakeFromNib, class_objc, classForCoder, classForKeyedArchiver, copy, dealloc, debugDescription, description, dictionaryWithValuesForKeys, didChangeValueForKey, didChangeValueForKeyWithSetMutationUsingObjects, didChangeValuesAtIndexesForKey, doesNotRecognizeSelector, fileManagerShouldProceedAfterError, fileManagerWillProcessPath, finalize_objc, forwardingTargetForSelector, forwardInvocation, hash, indexOfAccessibilityElement, isAccessibilityElement, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableArrayValueForKey, mutableArrayValueForKeyPath, mutableCopy, mutableOrderedSetValueForKey, mutableOrderedSetValueForKeyPath, mutableSetValueForKey, mutableSetValueForKeyPath, observationInfo, observeValueForKeyPathOfObjectChangeContext, performSelector, performSelectorInBackgroundWithObject, performSelectorOnMainThreadWithObjectWaitUntilDone, performSelectorOnMainThreadWithObjectWaitUntilDoneModes, performSelectorOnThreadWithObjectWaitUntilDone, performSelectorOnThreadWithObjectWaitUntilDoneModes, performSelectorWithObject, performSelectorWithObjectAfterDelay, performSelectorWithObjectAfterDelayInModes, performSelectorWithObjectWithObject, prepareForInterfaceBuilder, provideImageDataBytesPerRowOrigin_Size_UserInfo, removeObserverForKeyPath, removeObserverForKeyPathContext, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, self, setAccessibilityActivationPoint, setAccessibilityAttributedHint, setAccessibilityAttributedLabel, setAccessibilityAttributedUserInputLabels, setAccessibilityAttributedValue, setAccessibilityContainerType, setAccessibilityCustomActions, setAccessibilityCustomRotors, setAccessibilityDragSourceDescriptors, setAccessibilityDropPointDescriptors, setAccessibilityElements, setAccessibilityElementsHidden, setAccessibilityFrame, setAccessibilityHint, setAccessibilityLabel, setAccessibilityLanguage, setAccessibilityNavigationStyle, setAccessibilityPath, setAccessibilityRespondsToUserInteraction, setAccessibilityTextualContext, setAccessibilityTraits, setAccessibilityUserInputLabels, setAccessibilityValue, setAccessibilityViewIsModal, setIsAccessibilityElement, setNilValueForKey, setObservationInfo, setShouldGroupAccessibilityChildren, setValueForKey, setValueForKeyPath, setValueForUndefinedKey, setValuesForKeysWithDictionary, shouldGroupAccessibilityChildren, superclass, validateValueForKeyError, validateValueForKeyPathError, valueForKey, valueForKeyPath, valueForUndefinedKey, willChangeValueForKey, willChangeValueForKeyWithSetMutationUsingObjects, willChangeValuesAtIndexesForKeypublic static boolean accessInstanceVariablesDirectly()
public boolean addInputsLossLabels(NSDictionary<java.lang.String,? extends MLCTensor> inputs, NSDictionary<java.lang.String,? extends MLCTensor> lossLabels)
inputs - The inputslossLabels - The loss label inputspublic boolean addInputsLossLabelsLossLabelWeights(NSDictionary<java.lang.String,? extends MLCTensor> inputs, NSDictionary<java.lang.String,? extends MLCTensor> lossLabels, NSDictionary<java.lang.String,? extends MLCTensor> lossLabelWeights)
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.
inputs - The inputslossLabels - The loss label inputslossLabelWeights - The loss label weightspublic boolean addOutputs(NSDictionary<java.lang.String,? extends MLCTensor> outputs)
outputs - The outputspublic static MLCTrainingGraph alloc()
public static MLCTrainingGraph allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
public MLCTensor allocateUserGradientForTensor(MLCTensor tensor)
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.public static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
public boolean bindOptimizerDataDeviceDataWithTensor(NSArray<? extends MLCTensorData> data, NSArray<? extends MLCTensorOptimizerDeviceData> deviceData, MLCTensor tensor)
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.
data - The optimizer data to be associated with the tensordeviceData - The optimizer device data to be associated with the tensortensor - The tensorpublic static void cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)
public static void cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument)
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
public boolean compileOptimizer(MLCOptimizer optimizer)
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.
optimizer - The MLCOptimizer objectpublic boolean compileWithOptionsDevice(long options,
MLCDevice device)
options - The compiler options to use when compiling the training graphdevice - The MLCDevice objectpublic boolean compileWithOptionsDeviceInputTensorsInputTensorsData(long options,
MLCDevice device,
NSDictionary<java.lang.String,? extends MLCTensor> inputTensors,
NSDictionary<java.lang.String,? extends MLCTensorData> inputTensorsData)
Specifying the list of constant tensors when we compile the graph allows MLCompute to perform additional optimizations at compile time.
options - The compiler options to use when compiling the training graphdevice - The MLCDevice objectinputTensors - The list of input tensors that are constantsinputTensorsData - The tensor data to be used with these constant input tensorspublic static java.lang.String debugDescription_static()
public static java.lang.String description_static()
public long deviceMemorySize()
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.
public boolean executeForwardWithBatchSizeOptionsCompletionHandler(long batchSize,
long options,
MLCTrainingGraph.Block_executeForwardWithBatchSizeOptionsCompletionHandler completionHandler)
batchSize - The batch size to use. For a graph where batch size changes between layers this value must be 0.options - The execution optionscompletionHandler - The completion handlerpublic boolean executeForwardWithBatchSizeOptionsOutputsDataCompletionHandler(long batchSize,
long options,
NSDictionary<java.lang.String,? extends MLCTensorData> outputsData,
MLCTrainingGraph.Block_executeForwardWithBatchSizeOptionsOutputsDataCompletionHandler completionHandler)
batchSize - The batch size to use. For a graph where batch size changes between layers this value must be 0.options - The execution optionsoutputsData - The data objects to use for outputscompletionHandler - The completion handlerpublic boolean executeGradientWithBatchSizeOptionsCompletionHandler(long batchSize,
long options,
MLCTrainingGraph.Block_executeGradientWithBatchSizeOptionsCompletionHandler completionHandler)
batchSize - The batch size to use. For a graph where batch size changes between layers this value must be 0.options - The execution optionscompletionHandler - The completion handlerpublic boolean executeGradientWithBatchSizeOptionsOutputsDataCompletionHandler(long batchSize,
long options,
NSDictionary<java.lang.String,? extends MLCTensorData> outputsData,
MLCTrainingGraph.Block_executeGradientWithBatchSizeOptionsOutputsDataCompletionHandler completionHandler)
batchSize - The batch size to use. For a graph where batch size changes between layers this value must be 0.options - The execution optionsoutputsData - The data objects to use for outputscompletionHandler - The completion handlerpublic boolean executeOptimizerUpdateWithOptionsCompletionHandler(long options,
MLCTrainingGraph.Block_executeOptimizerUpdateWithOptionsCompletionHandler completionHandler)
options - The execution optionscompletionHandler - The completion handlerpublic boolean executeWithInputsDataLossLabelsDataLossLabelWeightsDataBatchSizeOptionsCompletionHandler(NSDictionary<java.lang.String,? extends MLCTensorData> inputsData, NSDictionary<java.lang.String,? extends MLCTensorData> lossLabelsData, NSDictionary<java.lang.String,? extends MLCTensorData> lossLabelWeightsData, long batchSize, long options, MLCTrainingGraph.Block_executeWithInputsDataLossLabelsDataLossLabelWeightsDataBatchSizeOptionsCompletionHandler completionHandler)
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.
inputsData - The data objects to use for inputslossLabelsData - The data objects to use for loss labelslossLabelWeightsData - The data objects to use for loss label weightsbatchSize - The batch size to use. For a graph where batch size changes between layers this value must be 0.options - The execution optionscompletionHandler - The completion handlerpublic boolean executeWithInputsDataLossLabelsDataLossLabelWeightsDataOutputsDataBatchSizeOptionsCompletionHandler(NSDictionary<java.lang.String,? extends MLCTensorData> inputsData, NSDictionary<java.lang.String,? extends MLCTensorData> lossLabelsData, NSDictionary<java.lang.String,? extends MLCTensorData> lossLabelWeightsData, NSDictionary<java.lang.String,? extends MLCTensorData> outputsData, long batchSize, long options, MLCTrainingGraph.Block_executeWithInputsDataLossLabelsDataLossLabelWeightsDataOutputsDataBatchSizeOptionsCompletionHandler completionHandler)
inputsData - The data objects to use for inputslossLabelsData - The data objects to use for loss labelslossLabelWeightsData - The data objects to use for loss label weightsoutputsData - The data objects to use for outputsbatchSize - The batch size to use. For a graph where batch size changes between layers this value must be 0.options - The execution optionscompletionHandler - The completion handlerpublic NSData gradientDataForParameterLayer(MLCTensor parameter, MLCLayer 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
parameter - The updatable parameter associated with the layerlayer - A layer in the training graph. Must be one of the following:
- MLCConvolutionLayer
- MLCFullyConnectedLayer
- MLCBatchNormalizationLayer
- MLCInstanceNormalizationLayer
- MLCGroupNormalizationLayer
- MLCLayerNormalizationLayer
- MLCEmbeddingLayer
- MLCMultiheadAttentionLayerpublic MLCTensor gradientTensorForInput(MLCTensor input)
input - The input tensorpublic static MLCTrainingGraph graph()
public static MLCTrainingGraph graphWithGraphObjectsLossLayerOptimizer(NSArray<? extends MLCGraph> graphObjects, MLCLayer lossLayer, MLCOptimizer optimizer)
graphObjects - The layers from these graph objects will be added to the training graphlossLayer - The loss layer to use. The loss layer can also be added to the training graph
using nodeWithLayer:sources:lossLabelsoptimizer - The optimizer to usepublic static long hash_static()
public MLCTrainingGraph init()
public static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
public static NSMethodSignature instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)
public static boolean instancesRespondToSelector(org.moe.natj.objc.SEL aSelector)
public static boolean isSubclassOfClass(org.moe.natj.objc.Class aClass)
public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
public boolean linkWithGraphs(NSArray<? extends MLCTrainingGraph> 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
graphs - The list of training graphs to linkpublic static MLCTrainingGraph new_objc()
public MLCOptimizer optimizer()
The optimizer to be used with the training graph
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
public NSArray<? extends MLCTensor> resultGradientTensorsForLayer(MLCLayer layer)
layer - A layer in the training graphpublic boolean setTrainingTensorParameters(NSArray<? extends MLCTensorParameter> parameters)
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 - The list of input tensors to be updated by the optimizerpublic static void setVersion_static(long aVersion)
public NSArray<? extends MLCTensor> sourceGradientTensorsForLayer(MLCLayer layer)
layer - A layer in the training graphpublic boolean stopGradientForTensors(NSArray<? extends MLCTensor> tensors)
tensors - The list of tensorspublic static org.moe.natj.objc.Class superclass_static()
public void synchronizeUpdates()
public static long version_static()