rlmesh.Tensor

classfrom rlmesh import Tensor[source]

Native tensor value used by RLMesh value encoding.

Tensor(buffer: object, shape: Sequence[int], dtype: str) -> Tensor

shape

property[source]
property shape: list[int]

dtype

property[source]
property dtype: str

ndim

property[source]
property ndim: int

size

property[source]
property size: int

nbytes

property[source]
property nbytes: int

strides

property[source]
property strides: list[int]

Strides in bytes per dimension, C-order.

device

property[source]
property device: str

Device holding the tensor data. Always "cpu".

buffer

property[source]
property buffer: memoryview

is_contiguous

function[source]
is_contiguous() -> bool

Whether the elements are laid out C-contiguously.

reshape

function[source]
reshape(shape: Sequence[int]) -> Tensor

A tensor with the same elements and a new shape. One dimension may be -1 to infer its size from the element count. Shares the underlying data when this tensor is contiguous.

copy

function[source]
copy() -> Tensor

A deep copy backed by fresh storage.

from_dlpack

function[source]
from_dlpack(obj: object) -> Tensor

Import a tensor from a DLPack capsule or any object implementing __dlpack__. Accepts both legacy and versioned capsules; the elements are always copied into fresh storage and the source capsule is consumed.

tobytes

function[source]
tobytes() -> bytes