Package ej.microai

Class Tensor

  • Direct Known Subclasses:
    InputTensor, OutputTensor

    public class Tensor
    extends java.lang.Object
    The Tensor class offers services to deal with MicroAI tensors.

    Tensor are the input/output of your MLInferenceEngine.

    • Method Detail

      • getDataType

        public int getDataType()
        Gets tensor data type.
        Returns:
        the tensor data type (see Tensor.DataType).
      • getNumberBytes

        public int getNumberBytes()
        Gets the number of bytes of the tensor.
        Returns:
        number of bytes of the tensor.
      • getNumberDimensions

        public int getNumberDimensions()
        Gets the number of dimensions of the tensor.
        Returns:
        number of dimensions of the tensor.
      • getNumberElements

        public int getNumberElements()
        Gets the number of elements of the tensor.
        Returns:
        number of elements of the tensor.
      • getQuantizationParams

        public Tensor.QuantizationParameters getQuantizationParams()
        Gets parameters of asymmetric quantization for the tensor.

        Real values can be quantized using: quantized_value = real_value/scale + zero_point.

        Returns:
        the quantization parameters (see Tensor.QuantizationParameters).
      • getShape

        public void getShape​(int[] sizes)
        Gets the tensor shape. Fill an array with the size of each dimension where the n-th element of the array correspond to the n-th dimension of the tensor.
        Parameters:
        sizes - is an array that contains the size of each dimension of the tensor.
      • isQuantized

        public boolean isQuantized()
        Gets the quantization status of the tensor.
        Returns:
        true if the tensor is quantized, false otherwise.