Interface Tensor#
interface Tensor {
data: SupportedTypedArray;
getData(): SupportedTypedArray;
getElementType(): element;
getShape(): number[];
getSize(): number;
}
The Tensor
is a lightweight class that represents data used for
inference. There are different ways to create a tensor. You can find them
in TensorConstructor section.
Defined in: addon.ts:378
Properties#
data
data: SupportedTypedArray
This property provides access to the tensor’s data.
Its getter returns a subclass of TypedArray that corresponds to the tensor element type, e.g.
Float32Array
corresponds tofloat32
. The content of theTypedArray
subclass is a copy of the tensor underlaying memory.Its setter fills the underlaying tensor memory by copying the binary data buffer from the
TypedArray
subclass. An exception will be thrown if the size or type of array does not match the tensor.Defined in: addon.ts:391
Methods#
getData
getData(): SupportedTypedArray;
It gets tensor data.
Returns: SupportedTypedArray
A subclass of
TypedArray
corresponding to the tensor element type, e.g.Float32Array
corresponds to float32.Defined in: addon.ts:401
getElementType
getElementType(): element
It gets the tensor element type.
Returns: element
Defined in: addon.ts:395
getShape
getShape(): number[]
It gets the tensor shape.
Returns: number[]
Defined in: addon.ts:405
getSize
getSize(): number[]
It gets the tensor size as a total number of elements.
Returns: number[]
Defined in: addon.ts:409