Package ej.microai
Class Tensor
- java.lang.Object
-
- ej.microai.Tensor
-
- Direct Known Subclasses:
InputTensor
,OutputTensor
public class Tensor extends java.lang.Object
TheTensor
class offers services to deal with MicroAI tensors.Tensor
are the input/output of yourMLInferenceEngine
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Tensor.DataType
TheTensor.DataType
class enumerates the MicroAI data types.static class
Tensor.QuantizationParameters
TheQuantizationParameters
class represents the quantization parameters used by aMLInferenceEngine
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getDataType()
Gets tensor data type.int
getNumberBytes()
Gets the number of bytes of the tensor.int
getNumberDimensions()
Gets the number of dimensions of the tensor.int
getNumberElements()
Gets the number of elements of the tensor.Tensor.QuantizationParameters
getQuantizationParams()
Gets parameters of asymmetric quantization for the tensor.void
getShape(int[] sizes)
Gets the tensor shape.boolean
isQuantized()
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-th
element of the array correspond to then-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.
-
-