A tensor is a sequence of floating point numbers shaped into an n-dimensional matrix. It supports fast, scalable matrix operations such as matrix multiplication and transposition as well as a number of element-wise operations. Words for working with tensors are found in the tensors vocabulary.

Tensors can be created by calling one of four constructors: zeros ( shape -- tensor ) ones ( shape -- tensor ) naturals ( shape -- tensor ) arange ( a b step -- tensor )

They can be converted to the corresponding N-dimensional array with tensor>array ( tensor: tensor -- seq: array )

The number of dimensions can be extracted with: dims ( tensor -- n )

Additionally, tensors can be reshaped with: reshape ( tensor shape -- tensor ) flatten ( tensor -- tensor )

Tensors can be combined element-wise with other tensors as well as numbers with: t+ ( x y -- tensor ) t- ( x y -- tensor ) t* ( x y -- tensor ) t/ ( x y -- tensor ) t% ( x y -- tensor )

Finally, tensors support the following matrix operations: matmul ( tensor1: tensor tensor2: tensor -- tensor3: tensor ) transpose ( tensor: tensor -- tensor': tensor )