Package 'tengen'

Title: Tensor Generics
Description: Generic functions and common objects for working with tensors.
Authors: Sebastian Fischer [aut, cre] (ORCID: <https://orcid.org/0000-0002-9609-3197>), Daniel Falbel [aut] (ORCID: <https://orcid.org/0009-0006-0143-2392>)
Maintainer: Sebastian Fischer <[email protected]>
License: MIT + file LICENSE
Version: 0.2.0
Built: 2026-06-07 06:55:00 UTC
Source: https://github.com/r-xla/tengen

Help Index


As Array

Description

Convert a value (usually a tensor from some framework) to an R array.

Usage

as_array(x, ...)

Arguments

x

(any)
Object.

...

(any)
Additional arguments.

Value

(any)


Convert to DataType

Description

Convert to DataType.

Usage

as_dtype(x)

Arguments

x

(any)
Object to convert. Can currently be a string (e.g. "i1", "i32", "f32", ...) or a DataType object.

Value

DataType


As Ray

Description

Convert a value (usually a tensor from some framework) to a raw() vector.

Usage

as_raw(x, ...)

Arguments

x

(any)
Object.

...

(any)
Additional arguments.

Value

(any)


Assert DataType

Description

Assert that an object is a DataType.

Usage

assert_dtype(x, arg = rlang::caller_arg(x))

Arguments

x

(any)
Object to check.

arg

(character(1))
Argument name for error messages.

Value

NULL (invisibly). Called for side effects.


BooleanType

Description

Represents the boolean type.

Usage

BooleanType()

Value

BooleanType


DataType Base Class

Description

DataType is the parent S3 class for all tensor data types. All data type classes inherit from DataType, enabling cross-type comparisons with == and != operators.

The specific data type classes are:

Details

This is a virtual base class - you cannot create instances directly. Use the specific type constructors instead.

See Also

BooleanType(), IntegerType(), UIntegerType(), FloatType()


Device

Description

Get the device of a tensor.

Usage

device(x, ...)

Arguments

x

(any)
Object.

...

(any)
Additional arguments.

Value

(any)


Data Type

Description

Get the data type of a tensor. The return type depends on the specific tensor implementation.

Usage

dtype(x, ...)

Arguments

x

(any)
Object.

...

(any)
Additional arguments.

Value

(any)


FloatType

Description

Represents a floating point type with a given bit width.

Usage

FloatType(value)

Arguments

value

(integer(1))

Value

FloatType


IntegerType (signed)

Description

Represents a signed integer type with a given bit width.

Usage

IntegerType(value)

Arguments

value

(integer(1))

Value

IntegerType


Is DataType

Description

Check if an object is a DataType.

Usage

is_dtype(x)

Arguments

x

(any)
Object to check.

Value

logical(1)


Number of Dimensions

Description

Get the number of dimensions of a tensor.

Usage

ndims(x)

Arguments

x

(any)
Object.

Value

(integer)


Number of Elements

Description

Get the number of elements of a tensor.

Usage

nelts(x)

Arguments

x

(any)
Object.

Value

(integer)


Shape

Description

Get the shape of a tensor.

Usage

shape(x, ...)

Arguments

x

(any)
Object.

...

(any)
Additional arguments.

Value

(integer())
The shape of the tensor.


UIntegerType

Description

Represents an unsigned integer type with a given bit width.

Usage

UIntegerType(value)

Arguments

value

(integer(1))

Value

UIntegerType