Slice

class Slice(content: TensorContent, range: IntRange)

A handy class to easily read a range of the tensor's content.

Parameters

content

The tensor content.

range

Which range of tensor's content will be read.

Constructors

Link copied to clipboard
constructor(content: TensorContent, range: IntRange)

Functions

Link copied to clipboard
fun asByteArray(): ByteArray

Reads the selected range from the tensor as Bytes. The tensor must be of Tensor.DataType.INT8, otherwise you cannot read its content as ByteArray.

Link copied to clipboard
fun asDoubleArray(): DoubleArray

Reads the selected range from the tensor as doubles. The tensor must be of Tensor.DataType.FLOAT64, otherwise you cannot read its content as DoubleArray.

Link copied to clipboard
fun asFloatArray(): FloatArray

Reads the selected range from the tensor as floats. The tensor must be of Tensor.DataType.FLOAT32, otherwise you cannot read its content as FloatArray.

Link copied to clipboard
fun asIntArray(): IntArray

Reads the selected range from the tensor as integers. The tensor must be of Tensor.DataType.INT32, otherwise you cannot read its content as IntArray.

Link copied to clipboard
fun asShortArray(): ShortArray

Reads the selected range from the tensor as Shorts. The tensor must be of Tensor.DataType.INT16, otherwise you cannot read its content as ShortArray.