Class MLCTensor

  • All Implemented Interfaces:
    NSCopying, NSObject

    @Deprecated
    public class MLCTensor
    extends NSObject
    implements NSCopying
    Deprecated.
    MLCTensor A tensor object API-Since: 14.0 Deprecated-Since: 100000.0 Deprecated-Message: Use Metal Performance Shaders Graph or BNNS instead.
    • Constructor Detail

      • MLCTensor

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

      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
        Deprecated.
      • alloc

        public static MLCTensor alloc()
        Deprecated.
      • allocWithZone

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

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

        public boolean bindAndWriteDataToDevice​(@NotNull
                                                @NotNull MLCTensorData data,
                                                @NotNull
                                                @NotNull MLCDevice device)
        Deprecated.
        Associates the given data to the tensor. If the device is GPU, also copies the data to the device memory. 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. For input tensors, we recommend that the bindAndwriteData method provided by MLCTrainingGraph and MLCInferenceGraph be used. This method should only be used to allocate and copy data to device memory for tensors that are typically layer parameters such as weights, bias for convolution layers, beta, gamma for normalization layers.
        Parameters:
        data - The data to associated with the tensor
        device - The compute device
        Returns:
        A Boolean value indicating whether the data is successfully associated with the tensor and copied to the device.
      • bindOptimizerDataDeviceData

        public boolean bindOptimizerDataDeviceData​(@NotNull
                                                   @NotNull NSArray<? extends MLCTensorData> data,
                                                   @Nullable
                                                   @Nullable NSArray<? extends MLCTensorOptimizerDeviceData> deviceData)
        Deprecated.
        Associates the given optimizer data and device data buffers to 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.
        Parameters:
        data - The optimizer data to be associated with the tensor
        deviceData - The optimizer device data to be associated with 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.
      • copyDataFromDeviceMemoryToBytesLengthSynchronizeWithDevice

        public boolean copyDataFromDeviceMemoryToBytesLengthSynchronizeWithDevice​(@NotNull
                                                                                  @NotNull org.moe.natj.general.ptr.VoidPtr bytes,
                                                                                  long length,
                                                                                  boolean synchronizeWithDevice)
        Deprecated.
        Copy tensor data from device memory to user specified memory Before copying tensor data from device memory, one may need to synchronize the device memory for example when device is the GPU. The synchronizeWithDevice argumet can be set appropraitely to indicate this. For CPU this is ignored. If the tensor has been specified in outputs of a graph using addOutputs, synchronizeWithDevice should be set to NO. NOTE: This method should only be called once the graph that this tensor is used with has finished execution; Otherwise the results in device memory may not be up to date. synchronizeWithDevice must be set to NO when this method is called from a completion callback for GPU.
        Parameters:
        bytes - The user specified data in which to copy
        length - The size in bytes to copy
        synchronizeWithDevice - Whether to synchronize device memory if device is GPU
        Returns:
        Returns YES if success, NO if there is a failure to synchronize
      • copyWithZone

        @NotNull
        public @NotNull java.lang.Object copyWithZone​(@Nullable
                                                      @Nullable org.moe.natj.general.ptr.VoidPtr zone)
        Deprecated.
        Specified by:
        copyWithZone in interface NSCopying
      • data

        @Nullable
        public @Nullable NSData data()
        Deprecated.
        [@property] data The tensor data
      • debugDescription_static

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

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

        @NotNull
        public @NotNull MLCTensorDescriptor descriptor()
        Deprecated.
        [@property] descriptor The tensor descriptor
      • device

        @Nullable
        public @Nullable MLCDevice device()
        Deprecated.
        [@property] device The device associated with this tensor.
      • hasValidNumerics

        public boolean hasValidNumerics()
        Deprecated.
        Returns a Boolean value indicating whether the underlying data has valid floating-point numerics, i.e. it does not contain NaN or INF floating-point values.
      • 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.
      • label

        @NotNull
        public @NotNull java.lang.String label()
        Deprecated.
        [@property] label A string to help identify this object.
      • new_objc

        public static MLCTensor new_objc()
        Deprecated.
      • optimizerData

        @NotNull
        public @NotNull NSArray<? extends MLCTensorData> optimizerData()
        Deprecated.
        [@property] optimizer buffers to use if tensor is used as a parameter These are the host side optimizer (momentum and velocity) buffers which developers can query and initialize When customizing optimizer data, the contents of these buffers must be initialized before executing optimizer update for a graph.
      • optimizerDeviceData

        @NotNull
        public @NotNull NSArray<? extends MLCTensorOptimizerDeviceData> optimizerDeviceData()
        Deprecated.
        [@property] optimizer device buffers to use if tensor is used as a parameter These are the device side optimizer (momentum and velocity) buffers which developers can query
      • resolveClassMethod

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

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

        public void setLabel​(@NotNull
                             @NotNull java.lang.String value)
        Deprecated.
        [@property] label A string to help identify this object.
      • setVersion_static

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

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

        public boolean synchronizeData()
        Deprecated.
        Synchronize the data in host memory. Synchronize the data in host memory i.e. tensor.data with latest contents in device memory This should only be called once the graph that this tensor is used with has finished execution; Otherwise the results in device memory may not be up to date. NOTE: This method should not be called from a completion callback when device is the GPU.
        Returns:
        Returns YES if success, NO if there is a failure to synchronize
      • synchronizeOptimizerData

        public boolean synchronizeOptimizerData()
        Deprecated.
        Synchronize the optimizer data in host memory. Synchronize the optimizer data in host memory with latest contents in device memory This should only be called once the graph that this tensor is used with has finished execution; Otherwise the results in device memory may not be up to date. NOTE: This method should not be called from a completion callback when device is the GPU.
        Returns:
        Returns YES if success, NO if there is a failure to synchronize
      • tensorByDequantizingToTypeScaleBias

        @Nullable
        public @Nullable MLCTensor tensorByDequantizingToTypeScaleBias​(int type,
                                                                       @NotNull
                                                                       @NotNull MLCTensor scale,
                                                                       @NotNull
                                                                       @NotNull MLCTensor bias)
        Deprecated.
        Converts a quantized tensor to a 32-bit floating-point tensor Returns a de-quantized tensor
        Parameters:
        type - The de-quantized data type. Must be MLCFloat32
        scale - The scale thst was used for the quantized data
        bias - The offset value that maps to float zero used for the quantized data
        Returns:
        A quantized tensor API-Since: 15.0
      • tensorByDequantizingToTypeScaleBiasAxis

        @Nullable
        public @Nullable MLCTensor tensorByDequantizingToTypeScaleBiasAxis​(int type,
                                                                           @NotNull
                                                                           @NotNull MLCTensor scale,
                                                                           @NotNull
                                                                           @NotNull MLCTensor bias,
                                                                           long axis)
        Deprecated.
        Converts a quantized tensor to a 32-bit floating-point tensor Returns a de-quantized tensor
        Parameters:
        type - The de-quantized data type. Must be MLCFloat32
        scale - The scale thst was used for the quantized data
        bias - The offset value that maps to float zero used for the quantized data
        axis - The dimension on which to apply per-channel quantization
        Returns:
        A quantized tensor API-Since: 15.0
      • tensorByQuantizingToTypeScaleBias

        @Nullable
        public @Nullable MLCTensor tensorByQuantizingToTypeScaleBias​(int type,
                                                                     float scale,
                                                                     long bias)
        Deprecated.
        Converts a 32-bit floating-point tensor with given scale and a zero point Returns a quantized tensor
        Parameters:
        type - The quantized data type. Must be MLCDataTypeInt8, MLCDataTypeUInt8 or MLCDataTypeInt32
        scale - The scale to apply in quantization
        bias - The offset value that maps to float zero
        Returns:
        A quantized tensor API-Since: 15.0
      • tensorByQuantizingToTypeScaleBiasAxis

        @Nullable
        public @Nullable MLCTensor tensorByQuantizingToTypeScaleBiasAxis​(int type,
                                                                         @NotNull
                                                                         @NotNull MLCTensor scale,
                                                                         @NotNull
                                                                         @NotNull MLCTensor bias,
                                                                         long axis)
        Deprecated.
        Converts a 32-bit floating-point tensor with given scale and a zero point Returns a quantized tensor
        Parameters:
        type - The quantized data type. Must be MLCDataTypeInt8, MLCDataTypeUInt8 or MLCDataTypeInt32
        scale - The scale to apply in quantization
        bias - The offset value that maps to float zero
        axis - The dimension on which to apply per-channel quantization
        Returns:
        A quantized tensor API-Since: 15.0
      • tensorID

        public long tensorID()
        Deprecated.
        [@property] tensorID The tensor ID A unique number to identify each tensor. Assigned when the tensor is created.
      • tensorWithDescriptor

        public static MLCTensor tensorWithDescriptor​(@NotNull
                                                     @NotNull MLCTensorDescriptor tensorDescriptor)
        Deprecated.
        Create a MLCTensor object Create a tensor object without any data
        Returns:
        A new MLCTensor object
      • tensorWithDescriptorData

        public static MLCTensor tensorWithDescriptorData​(@NotNull
                                                         @NotNull MLCTensorDescriptor tensorDescriptor,
                                                         @NotNull
                                                         @NotNull MLCTensorData data)
        Deprecated.
        Create a MLCTensor object Create a tensor object with a MLCTensorData object that specifies the tensor data buffer
        Parameters:
        tensorDescriptor - The tensor descriptor
        data - The random initializer type
        Returns:
        A new MLCTensor object
      • tensorWithDescriptorFillWithData

        public static MLCTensor tensorWithDescriptorFillWithData​(@NotNull
                                                                 @NotNull MLCTensorDescriptor tensorDescriptor,
                                                                 @NotNull
                                                                 @NotNull NSNumber fillData)
        Deprecated.
        Create a MLCTensor object Create a tensor object with a MLCTensorData object that specifies the tensor data buffer
        Parameters:
        tensorDescriptor - The tensor descriptor
        fillData - The scalar data to fill to tensor with
        Returns:
        A new MLCTensor object
      • tensorWithDescriptorRandomInitializerType

        public static MLCTensor tensorWithDescriptorRandomInitializerType​(@NotNull
                                                                          @NotNull MLCTensorDescriptor tensorDescriptor,
                                                                          int randomInitializerType)
        Deprecated.
        Create a MLCTensor object Create a tensor object initialized with a random initializer such as Glorot Uniform.
        Parameters:
        tensorDescriptor - The tensor descriptor
        randomInitializerType - The random initializer type
        Returns:
        A new MLCTensor object
      • tensorWithSequenceLengthFeatureChannelCountBatchSize

        public static MLCTensor tensorWithSequenceLengthFeatureChannelCountBatchSize​(long sequenceLength,
                                                                                     long featureChannelCount,
                                                                                     long batchSize)
        Deprecated.
        Create a MLCTensor object Create a tensor typically used by a recurrent layer The tensor data type is MLCDataTypeFloat32.
        Parameters:
        sequenceLength - The length of sequences stored in the tensor
        featureChannelCount - Number of feature channels
        batchSize - The tensor batch size
        Returns:
        A new MLCTensor object
      • tensorWithSequenceLengthFeatureChannelCountBatchSizeData

        public static MLCTensor tensorWithSequenceLengthFeatureChannelCountBatchSizeData​(long sequenceLength,
                                                                                         long featureChannelCount,
                                                                                         long batchSize,
                                                                                         @Nullable
                                                                                         @Nullable MLCTensorData data)
        Deprecated.
        Create a MLCTensor object Create a tensor typically used by a recurrent layer The tensor data type is MLCDataTypeFloat32.
        Parameters:
        sequenceLength - The length of sequences stored in the tensor
        featureChannelCount - Number of feature channels
        batchSize - The tensor batch size
        data - The tensor data
        Returns:
        A new MLCTensor object
      • tensorWithSequenceLengthFeatureChannelCountBatchSizeRandomInitializerType

        public static MLCTensor tensorWithSequenceLengthFeatureChannelCountBatchSizeRandomInitializerType​(long sequenceLength,
                                                                                                          long featureChannelCount,
                                                                                                          long batchSize,
                                                                                                          int randomInitializerType)
        Deprecated.
        Create a MLCTensor object Create a tensor typically used by a recurrent layer The tensor data type is MLCDataTypeFloat32.
        Parameters:
        sequenceLength - The length of sequences stored in the tensor
        featureChannelCount - Number of feature channels
        batchSize - The tensor batch size
        randomInitializerType - The random initializer type
        Returns:
        A new MLCTensor object
      • tensorWithSequenceLengthsSortedSequencesFeatureChannelCountBatchSizeData

        public static MLCTensor tensorWithSequenceLengthsSortedSequencesFeatureChannelCountBatchSizeData​(@NotNull
                                                                                                         @NotNull NSArray<? extends NSNumber> sequenceLengths,
                                                                                                         boolean sortedSequences,
                                                                                                         long featureChannelCount,
                                                                                                         long batchSize,
                                                                                                         @Nullable
                                                                                                         @Nullable MLCTensorData data)
        Deprecated.
        Create a MLCTensor object Create a tensor of variable length sequences typically used by a recurrent layer The tensor data type is MLCDataTypeFloat32.
        Parameters:
        sequenceLengths - An array of sequence lengths
        sortedSequences - A flag to indicate if the sequence lengths are sorted. If yes, they must be sorted in descending order
        featureChannelCount - Number of feature channels
        batchSize - The tensor batch size
        data - The tensor data
        Returns:
        A new MLCTensor object
      • tensorWithSequenceLengthsSortedSequencesFeatureChannelCountBatchSizeRandomInitializerType

        public static MLCTensor tensorWithSequenceLengthsSortedSequencesFeatureChannelCountBatchSizeRandomInitializerType​(@NotNull
                                                                                                                          @NotNull NSArray<? extends NSNumber> sequenceLengths,
                                                                                                                          boolean sortedSequences,
                                                                                                                          long featureChannelCount,
                                                                                                                          long batchSize,
                                                                                                                          int randomInitializerType)
        Deprecated.
        Create a MLCTensor object Create a tensor of variable length sequences typically used by a recurrent layer The tensor data type is MLCDataTypeFloat32.
        Parameters:
        sequenceLengths - An array of sequence lengths
        sortedSequences - A flag to indicate if the sequence lengths are sorted. If yes, they must be sorted in descending order
        featureChannelCount - Number of feature channels
        batchSize - The tensor batch size
        randomInitializerType - The random initializer type
        Returns:
        A new MLCTensor object
      • tensorWithShape

        public static MLCTensor tensorWithShape​(@NotNull
                                                @NotNull NSArray<? extends NSNumber> shape)
        Deprecated.
        Create a MLCTensor object Create a tensor object without any data. The tensor data type is MLCDataTypeFloat32.
        Parameters:
        shape - The tensor shape
        Returns:
        A new MLCTensor object
      • tensorWithShapeDataDataType

        public static MLCTensor tensorWithShapeDataDataType​(@NotNull
                                                            @NotNull NSArray<? extends NSNumber> shape,
                                                            @NotNull
                                                            @NotNull MLCTensorData data,
                                                            int dataType)
        Deprecated.
        Create a MLCTensor object Create a tensor object with data
        Parameters:
        shape - The tensor shape
        data - The tensor data
        dataType - The tensor data type
        Returns:
        A new MLCTensor object
      • tensorWithShapeDataType

        public static MLCTensor tensorWithShapeDataType​(@NotNull
                                                        @NotNull NSArray<? extends NSNumber> shape,
                                                        int dataType)
        Deprecated.
        Create a MLCTensor object Create a tensor object without any data
        Parameters:
        shape - The tensor shape
        dataType - The tensor data type
        Returns:
        A new MLCTensor object
      • tensorWithShapeFillWithDataDataType

        public static MLCTensor tensorWithShapeFillWithDataDataType​(@NotNull
                                                                    @NotNull NSArray<? extends NSNumber> shape,
                                                                    @NotNull
                                                                    @NotNull NSNumber fillData,
                                                                    int dataType)
        Deprecated.
        Create a MLCTensor object Create a tensor object with data
        Parameters:
        shape - The tensor shape
        fillData - The scalar value to initialize the tensor data with
        dataType - The tensor data type
        Returns:
        A new MLCTensor object
      • tensorWithShapeRandomInitializerType

        public static MLCTensor tensorWithShapeRandomInitializerType​(@NotNull
                                                                     @NotNull NSArray<? extends NSNumber> shape,
                                                                     int randomInitializerType)
        Deprecated.
        Create a MLCTensor object Create a tensor object initialized with a random initializer such as Glorot Uniform. The tensor data type is MLCDataTypeFloat32
        Parameters:
        shape - The tensor shape
        randomInitializerType - The random initializer type
        Returns:
        A new MLCTensor object
      • tensorWithShapeRandomInitializerTypeDataType

        public static MLCTensor tensorWithShapeRandomInitializerTypeDataType​(@NotNull
                                                                             @NotNull NSArray<? extends NSNumber> shape,
                                                                             int randomInitializerType,
                                                                             int dataType)
        Deprecated.
        Create a MLCTensor object Create a tensor object initialized with a random initializer such as Glorot Uniform. The tensor data type is MLCDataTypeFloat32
        Parameters:
        shape - The tensor shape
        randomInitializerType - The random initializer type
        dataType - The tensor data type
        Returns:
        A new MLCTensor object
      • tensorWithWidthHeightFeatureChannelCountBatchSize

        public static MLCTensor tensorWithWidthHeightFeatureChannelCountBatchSize​(long width,
                                                                                  long height,
                                                                                  long featureChannelCount,
                                                                                  long batchSize)
        Deprecated.
        Create a MLCTensor object Create a NCHW tensor object with tensor data type = MLCDataTypeFloat32
        Parameters:
        width - The tensor width
        height - The tensor height
        featureChannelCount - Number of feature channels
        batchSize - The tensor batch size
        Returns:
        A new MLCTensor object
      • tensorWithWidthHeightFeatureChannelCountBatchSizeData

        public static MLCTensor tensorWithWidthHeightFeatureChannelCountBatchSizeData​(long width,
                                                                                      long height,
                                                                                      long featureChannelCount,
                                                                                      long batchSize,
                                                                                      @NotNull
                                                                                      @NotNull MLCTensorData data)
        Deprecated.
        Create a MLCTensor object Create a NCHW tensor object with a tensor data object The tensor data type is MLCDataTypeFloat32.
        Parameters:
        width - The tensor width
        height - The tensor height
        featureChannelCount - Number of feature channels
        batchSize - The tensor batch size
        data - The tensor data
        Returns:
        A new MLCTensor object
      • tensorWithWidthHeightFeatureChannelCountBatchSizeDataDataType

        public static MLCTensor tensorWithWidthHeightFeatureChannelCountBatchSizeDataDataType​(long width,
                                                                                              long height,
                                                                                              long featureChannelCount,
                                                                                              long batchSize,
                                                                                              @NotNull
                                                                                              @NotNull MLCTensorData data,
                                                                                              int dataType)
        Deprecated.
        Create a MLCTensor object Create a NCHW tensor object with a tensor data object The tensor data type is MLCDataTypeFloat32.
        Parameters:
        width - The tensor width
        height - The tensor height
        featureChannelCount - Number of feature channels
        batchSize - The tensor batch size
        data - The tensor data
        dataType - The tensor data type
        Returns:
        A new MLCTensor object
      • tensorWithWidthHeightFeatureChannelCountBatchSizeFillWithDataDataType

        public static MLCTensor tensorWithWidthHeightFeatureChannelCountBatchSizeFillWithDataDataType​(long width,
                                                                                                      long height,
                                                                                                      long featureChannelCount,
                                                                                                      long batchSize,
                                                                                                      float fillData,
                                                                                                      int dataType)
        Deprecated.
        Create a MLCTensor object Create a NCHW tensor object initialized with a scalar value
        Parameters:
        width - The tensor width
        height - The tensor height
        featureChannelCount - Number of feature channels
        batchSize - The tensor batch size
        fillData - The scalar value to initialize the tensor data with
        dataType - The tensor data type
        Returns:
        A new MLCTensorData object
      • tensorWithWidthHeightFeatureChannelCountBatchSizeRandomInitializerType

        public static MLCTensor tensorWithWidthHeightFeatureChannelCountBatchSizeRandomInitializerType​(long width,
                                                                                                       long height,
                                                                                                       long featureChannelCount,
                                                                                                       long batchSize,
                                                                                                       int randomInitializerType)
        Deprecated.
        Create a MLCTensor object Create a NCHW tensor object initialized with a random initializer type. The tensor data type is MLCDataTypeFloat32
        Parameters:
        width - The tensor width
        height - The tensor height
        featureChannelCount - Number of feature channels
        batchSize - The tensor batch size
        randomInitializerType - The random initializer type
        Returns:
        A new MLCTensor object
      • version_static

        public static long version_static()
        Deprecated.
      • useStoredAccessor

        @Deprecated
        public static boolean useStoredAccessor()
        Deprecated.