Skip to main content

Mojo trait

CopyPolicy

The CopyPolicy trait defines requirements needed for a tensor to be copied.

These requirements check the compatibility of the source and destination tensors.

Implemented traits

AnyType, UnknownDestructibility

Aliases

__del__is_trivial

alias __del__is_trivial

A flag (often compiler generated) to indicate whether the implementation of __del__ is trivial.

The implementation of __del__ is considered to be trivial if:

  • The struct has a compiler-generated trivial destructor and all its fields have a trivial __del__ method.

In practice, it means that the __del__ can be considered as no-op.

Required methods

verify_source_tensor

static verify_source_tensor(src: LayoutTensor[dtype, layout, origin, address_space=address_space, element_layout=element_layout, layout_int_type=layout_int_type, linear_idx_type=linear_idx_type, masked=masked, alignment=alignment])

A static function that verifies the source tensor is compatible with the copy operation. If the tensor is not valid compilation will fail.

Args:

  • src (LayoutTensor): The source tensor that will be copied from.

verify_destination_tensor

static verify_destination_tensor(dst: LayoutTensor[dtype, layout, origin, address_space=address_space, element_layout=element_layout, layout_int_type=layout_int_type, linear_idx_type=linear_idx_type, masked=masked, alignment=alignment])

A static function that verifies the destination tensor is compatible with the copy operation. If the tensor is not valid compilation will fail.

Args:

  • dst (LayoutTensor): The destination tensor that will be copied to.

Was this page helpful?