Skip to contents

Provides S3 generics for common tensor operations.

Installation

pak::pak("r-xla/tengen")

Available Generics

  • shape(): Different from dim() by also supporting 0-dimensional tensors.
  • dtype(): Returns the data type of the tensor.
  • as_array(): Converts the tensor to an R array.
  • as_raw(): Converts the tensor to a raw() vector.
  • device(): Returns the device of the tensor.

Other functions:

  • ndims(): Returns the number of dimensions of the tensor. Is implemented as length(shape(x)).