Skip to main content

Mojo module

tensor_slice

Represents a sliced view of a tensor. The slice has origin same as that of the tensor from which it is created.

For example, you can create a TensorSlice and use it like this:

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

def main():
tensor = Tensor[DType.float32, rank=3](TensorShape(1, 2, 3))
slice_one = tensor[:]
from max.driver import Tensor
from max.tensor import TensorShape

def main():
tensor = Tensor[DType.float32, rank=3](TensorShape(1, 2, 3))
slice_one = tensor[:]

Structs

  • TensorSlice: Sliced view of a tensor. This is safe to use even after the last use of tensor from which it is created. For creating a slice use the getitem method defined in tensor.