Skip to main content

Mojo struct

VariadicTensors

struct VariadicTensors[mut: Bool, input: IO, dtype: DType, rank: Int, //, size: Int, io_spec: IOSpec[mut, input], *, static_specs: StaticTensorSpecList[static_specs.internals_list, static_specs.shapes_list, static_specs.strides_list]]

A tuple-like container of tensors representing variadic arguments from the graph compiler.

Implemented traits

AnyType, Copyable, ImplicitlyCopyable, ImplicitlyDestructible, Movable, RegisterPassable, Sized, TrivialRegisterPassable

Methods

__init__

__init__(ptrs: StaticTuple[UnsafePointer[Scalar[dtype], MutAnyOrigin], size], shapes: StaticTuple[IndexList[rank], size]) -> Self

Initialize the variadic tensor from tuples of pointers and shapes.

This is a bulk initialization of the VariadicTensors value from an array of pointers and an array of runtime shapes. This allows the graph compiler to avoid generating code to construct DynamicTensor values directly.

__len__

__len__(self) -> Int

Returns the number of variadic arguments in the pack.

Returns:

Int: The number of variadic arguments.

__getitem_param__

__getitem_param__[index: Int](self) -> ManagedTensorSlice[io_spec, static_spec=static_specs.__getitem_param__[index]()]

Returns the tensor at the given position in the variadic argument argument pack.

Parameters:

  • index (Int): The index into the variadic tensor arguments.

Returns:

ManagedTensorSlice: The tensor at the specified index.

Was this page helpful?