Skip to main content

Mojo struct

TensorSlice

@register_passable

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.

Implemented traits

AnyType, Copyable, Movable

Methods

__getitem__

__getitem__(self, *indices: Int) -> SIMD[type, 1]

Gets the value at the specified indices.

Args:

  • *indices (Int): The indices of the value to retrieve.

Returns:

The value at the specified indices.

__setitem__

__setitem__(self, *indices: Int, *, val: SIMD[type, 1])

Sets the value at the specified indices.

Args:

  • *indices (Int): The indices of the value to retrieve.
  • val (SIMD[type, 1]): The value to store at the specified indices.

runtime_spec

runtime_spec(self) -> RuntimeTensorSpec[type, rank]

Gets the static spec of the slice.

Returns:

Static tensor spec of slice.

spec

spec(self) -> TensorSpec

Gets the spec of the slice.

Returns:

Spec of slice as TensorSpec.