Class IndexMapObj#

Inheritance Relationships#

Base Type#

  • public ffi::Object

Class Documentation#

class IndexMapObj : public ffi::Object#

Defines a mapping between two representations of indices into a tensor.

This is primarily used for layout transformations of tensors objects.

Public Functions

inline IndexMapObj()#

Default constructor.

Defines the mapping as an identity function, with initial_indices equal to the final indices.

ffi::Array<PrimExpr> MapIndices(const ffi::Array<PrimExpr> &indices) const#

Map indices to the output space using a fresh analyzer.

Parameters:

indices – The indices in the input space. Should contain one value for each variable in initial_indices.

Returns:

The indices in the output space. Contains one value for each expression in final_indices.

ffi::Array<PrimExpr> MapIndices(const ffi::Array<PrimExpr> &indices, const sym::Analyzer &analyzer) const#

Map indices to the output space using an existing analyzer.

Parameters:
  • indices – The indices in the input space. Should contain one value for each variable in initial_indices.

  • analyzer – An analyzer to be used to simplify the resulting expressions.

Returns:

The indices in the output space. Contains one value for each expression in final_indices.

ffi::Array<Range> MapRanges(const ffi::Array<Range> &ranges) const#

Map a memory range to the output space using a fresh analyzer.

If contiguous memory locations in the input space are not necessarily contiguous in the output space (e.g. lambda i: [8*(i%8) + (i//8)]), then this will return the smallest range such that all valid indices are contained within the given range.

Parameters:

ranges – The ranges in the input space. Should contain one value for each variable in initial_indices.

Returns:

The ranges in the output space. Contains one value for each expression in final_indices.

ffi::Array<Range> MapRanges(const ffi::Array<Range> &ranges, const sym::Analyzer &analyzer) const#

Map a memory range to the output space using an existing analyzer.

If contiguous memory locations in the input space are not necessarily contiguous in the output space (e.g. lambda i: [8*(i%8) + (i//8)]), then this will return the smallest range such that all valid indices are contained within the given range.

Parameters:
  • ranges – The ranges in the input space. Should contain one value for each variable in initial_indices.

  • analyzer – An analyzer to be used to simplify the resulting expressions.

Returns:

The ranges in the output space. Contains one value for each expression in final_indices.

ffi::Array<PrimExpr> MapShape(const ffi::Array<PrimExpr> &shape) const#

Map a tensor shape to the output space using a fresh analyzer.

Parameters:

shape – The tensor shape in the input space. Should contain one value for each variable in initial_indices.

Returns:

The tensor shape in the output space. Contains one value for each expression in final_indices.

ffi::Array<PrimExpr> MapShape(const ffi::Array<PrimExpr> &shape, const sym::Analyzer &analyzer) const#

Map a tensor shape to the output space using an existing analyzer.

Parameters:
  • shape – The tensor shape in the input space. Should contain one value for each variable in initial_indices.

  • analyzer – An analyzer to be used to simplify the resulting expressions.

Returns:

The tensor shape in the output space. Contains one value for each expression in final_indices.

ffi::Tensor MapTensor(ffi::Tensor arr_src) const#
ffi::String ToPythonString(const ffi::TypedFunction<ffi::Optional<ffi::String>(const Var &var)> &f_name_map = nullptr) const#

Convert to string representation in Python.

Parameters:

f_name_map – Optional function to specify the stringified name of the variables.

Returns:

The stringified lambda expression in Python.

Public Members

ffi::Array<PrimVar> initial_indices#

Variables representing the indices prior to remapping.

If initial_indices is empty, then final_indices should also be empty, and no mapping is applied.

ffi::Array<PrimExpr> final_indices#

Expressions defining the indices after remapping.

These expressions should only be in terms of the initial_indices, and must be expressible as an IterSumExpr. The mapping from initial_indices to final_indices must be injective.

If final_indices is empty, then initial_indices should also be empty, and the map is an identity function.

ffi::Optional<ffi::ObjectRef> inverse_index_map#

The inverse index map.

When this is defined, IndexMap::Inverse will return the pre-defined inverse index map. Otherwise, the inverse index map will be computed on the fly. It is the user’s responsibility to ensure the correctness of the pre-defined inverse index map.

Note

ffi::ObjectRef is used here instead of IndexMap to avoid circular reference.

Public Static Functions

static inline void RegisterReflection()#
static inline int32_t _GetOrAllocRuntimeTypeIndex()#
static inline int32_t RuntimeTypeIndex() noexcept#