Interface Tensor#

interface Tensor {
    data: SupportedTypedArray;
    getElementType(): element;
    getData(): SupportedTypedArray;
    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.

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 to float32. The content of the TypedArray 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.

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:413

getElementType

  • getElementType(): element
    

    It gets the tensor element type.

getShape

  • getShape(): number[]
    

    It gets the tensor shape.

getSize

  • getSize(): number[]
    

    It gets the tensor size as a total number of elements.