struct TensorflowLite::Tensor

Overview

A tensor is a multi-dimensional array used as the basic data structure. This array can have any number of dimensions, and is used to represent data of various types, such as numeric, boolean, or string values.

The dimensions of a tensor are often referred to as "ranks". For instance:

Each tensor in TensorFlow is also associated with a data type (such as float32, int32, or string) and a shape. The shape of a tensor is the number of elements in each dimension.

For example, a 3x3 matrix has a shape of [3, 3].

Included Modules

Defined in:

tensorflow_lite/tensor.cr

Constructors

Instance Method Summary

Macro Summary

Constructor Detail

def self.new(tf_tensor_ptr : LibTensorflowLite::Tensor) #

[View source]

Instance Method Detail

def as_f #

provides a view into the tensor buffer as the requested type


[View source]
def as_f32 #

provides a view into the tensor buffer as the requested type


[View source]
def as_f64 #

provides a view into the tensor buffer as the requested type


[View source]
def as_i #

provides a view into the tensor buffer as the requested type


[View source]
def as_i16 #

provides a view into the tensor buffer as the requested type


[View source]
def as_i32 #

provides a view into the tensor buffer as the requested type


[View source]
def as_i64 #

provides a view into the tensor buffer as the requested type


[View source]
def as_i8 #

provides a view into the tensor buffer as the requested type


[View source]
def as_type #

returns a slice of the data in the correct type


[View source]
def as_u16 #

provides a view into the tensor buffer as the requested type


[View source]
def as_u32 #

provides a view into the tensor buffer as the requested type


[View source]
def as_u64 #

provides a view into the tensor buffer as the requested type


[View source]
def as_u8 #

provides a view into the tensor buffer as the requested type


[View source]
def bytesize : Int32 #

the size of the buffer backing this tensor


[View source]
def dimension_size(index : Int) : Int32 #

returns the number elements in this dimension or rank index


[View source]
def dimensions : Int32 #

Returns the number of dimensions (sometimes referred to as rank) of the Tensor. Will be 0 for a scalar, 1 for a vector, 2 for a matrix, 3 for a 3-dimensional tensor etc.


[View source]
def io_count #

attempts to calculate the number on inputs/outputs based on the type


[View source]
def name : String #

The friendly name of the tensor


[View source]
def rank #

Returns the number of dimensions (sometimes referred to as rank) of the Tensor. Will be 0 for a scalar, 1 for a vector, 2 for a matrix, 3 for a 3-dimensional tensor etc.


[View source]
def raw_data : Bytes #

buffer that makes up the tensor input


[View source]
def size #

Returns the number of dimensions (sometimes referred to as rank) of the Tensor. Will be 0 for a scalar, 1 for a vector, 2 for a matrix, 3 for a 3-dimensional tensor etc.


[View source]
def to_slice #

buffer that makes up the tensor input


[View source]
def type : Type #

The datatype this tensor holds

the type of data it expects as input or provides as output


[View source]

Macro Detail

macro to_type(klass) #

type casts the tensor buffer into the appropriate crystal lang type.

returns a Slice of the provided klass against the buffer for manipulation


[View source]