Construct a new string tensor object from the given type, data and dims.
Specify the element type.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new bool tensor object from the given type, data and dims.
Specify the element type.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new uint8 tensor object from a Uint8ClampedArray, data and dims.
Specify the element type.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new 64-bit integer typed tensor object from the given type, data and dims.
Specify the element type.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new numeric tensor object from the given type, data and dims.
Specify the element type.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new float32 tensor object from the given data and dims.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new int8 tensor object from the given data and dims.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new uint8 tensor object from the given data and dims.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new uint8 tensor object from the given data and dims.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new uint16 tensor object from the given data and dims.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new int16 tensor object from the given data and dims.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new int32 tensor object from the given data and dims.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new int64 tensor object from the given data and dims.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new string tensor object from the given data and dims.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new bool tensor object from the given data and dims.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new float64 tensor object from the given data and dims.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new uint32 tensor object from the given data and dims.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new uint64 tensor object from the given data and dims.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new tensor object from the given type, data and dims.
Specify the element type.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
Construct a new tensor object from the given data and dims.
Specify the CPU tensor data.
Optional
dims: readonly number[]Specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
create a tensor from a WebGPU buffer
the GPUBuffer object to create tensor from
An optional object representing options for creating tensor from WebGPU buffer.
The options include following properties:
dataType
: the data type of the tensor. If omitted, assume 'float32'.dims
: the dimension of the tensor. Required.download
: an optional function to download the tensor data from GPU to CPU. If omitted, the GPU data
will not be able to download. Usually, this is provided by a GPU backend for the inference outputs. Users don't
need to provide this function.dispose
: an optional function to dispose the tensor data on GPU. If omitted, the GPU data will not be disposed.
Usually, this is provided by a GPU backend for the inference outputs. Users don't need to provide this function.a tensor object
create a tensor from an ImageData object
the ImageData object to create tensor from
Optional
options: TensorFromImageDataOptionsAn optional object representing options for creating tensor from ImageData.
The following default settings will be applied:
tensorFormat
: 'RGB'
tensorLayout
: 'NCHW'
dataType
: 'float32'
A promise that resolves to a tensor object
create a tensor from a HTMLImageElement object
the HTMLImageElement object to create tensor from
Optional
options: TensorFromImageElementOptionsAn optional object representing options for creating tensor from HTMLImageElement.
The following default settings will be applied:
tensorFormat
: 'RGB'
tensorLayout
: 'NCHW'
dataType
: 'float32'
A promise that resolves to a tensor object
create a tensor from URL
a string as a URL to the image or a data URL containing the image data.
Optional
options: TensorFromUrlOptionsAn optional object representing options for creating tensor from URL.
The following default settings will be applied:
tensorFormat
: 'RGB'
tensorLayout
: 'NCHW'
dataType
: 'float32'
A promise that resolves to a tensor object
create a tensor from an ImageBitmap object
the ImageBitmap object to create tensor from
An optional object representing options for creating tensor from URL.
The following default settings will be applied:
tensorFormat
: 'RGB'
tensorLayout
: 'NCHW'
dataType
: 'float32'
A promise that resolves to a tensor object
create a tensor from a WebNN MLTensor
the MLTensor object to create tensor from
An optional object representing options for creating tensor from a WebNN MLTensor.
The options include following properties:
dataType
: the data type of the tensor. If omitted, assume 'float32'.dims
: the dimension of the tensor. Required.download
: an optional function to download the tensor data from the MLTensor to CPU. If omitted, the MLTensor
data will not be able to download. Usually, this is provided by the WebNN backend for the inference outputs.
Users don't need to provide this function.dispose
: an optional function to dispose the tensor data on the WebNN MLTensor. If omitted, the MLTensor will
not be disposed. Usually, this is provided by the WebNN backend for the inference outputs. Users don't need to
provide this function.a tensor object
create a tensor from a pre-allocated buffer. The buffer will be used as a pinned buffer.
the tensor element type.
a TypedArray corresponding to the type.
Optional
dims: readonly number[]specify the dimension of the tensor. If omitted, a 1-D tensor is assumed.
a tensor object
create a tensor from a WebGL texture
the WebGLTexture object to create tensor from
An optional object representing options for creating tensor from WebGL texture.
The options include following properties:
width
: the width of the texture. Required.height
: the height of the texture. Required.format
: the format of the texture. If omitted, assume 'RGBA'.download
: an optional function to download the tensor data from GPU to CPU. If omitted, the GPU data
will not be able to download. Usually, this is provided by a GPU backend for the inference outputs. Users don't
need to provide this function.dispose
: an optional function to dispose the tensor data on GPU. If omitted, the GPU data will not be disposed.
Usually, this is provided by a GPU backend for the inference outputs. Users don't need to provide this function.a tensor object
Generated using TypeDoc
type TensorConstructor defines the constructors of 'Tensor' to create CPU tensor instances.