Skip to main content
Log in

Mojo module

anytensor

Implements type erased generic tensor and memory types.

For example you can use AnyTensor if you don't know the dtype of tensor in advance or if you don't know the tensor is DeviceTensor or Tensor:

from max.driver import Tensor, AnyTensor
from max.tensor import TensorShape

@value
struct Container:
var _tensor: AnyTensor

def main():
tensor = Tensor[DType.float32, rank=1](TensorShape(1,))
container = Container(tensor^)
from max.driver import Tensor, AnyTensor
from max.tensor import TensorShape

@value
struct Container:
var _tensor: AnyTensor

def main():
tensor = Tensor[DType.float32, rank=1](TensorShape(1,))
container = Container(tensor^)

Structs

  • AnyMemory: A generic representation which can either be a Driver Tensor or Mojo object.
  • AnyMojoValue: Type erased representation of a mojo object. This is useful for passing opaque type as input for graph executution.
  • AnyTensor: A type erased tensor representation that is useful for situations where we need variadics of tensors.

Was this page helpful?