Package ej.microai
Class Tensor
- java.lang.Object
-
- ej.microai.Tensor
-
- Direct Known Subclasses:
InputTensor,OutputTensor
public class Tensor extends java.lang.ObjectTheTensorclass offers services to deal with MicroAI tensors.Tensorare the input/output of yourMLInferenceEngine.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTensor.DataTypeTheTensor.DataTypeclass enumerates the MicroAI data types.static classTensor.QuantizationParametersTheQuantizationParametersclass represents the quantization parameters used by aMLInferenceEngine.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetDataType()Gets tensor data type.intgetNumberBytes()Gets the number of bytes of the tensor.intgetNumberDimensions()Gets the number of dimensions of the tensor.intgetNumberElements()Gets the number of elements of the tensor.Tensor.QuantizationParametersgetQuantizationParams()Gets parameters of asymmetric quantization for the tensor.voidgetShape(int[] sizes)Gets the tensor shape.booleanisQuantized()Gets the quantization status of the tensor.
-
-
-
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 then-thelement of the array correspond to then-thdimension 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:
trueif the tensor is quantized,falseotherwise.
-
-