26#ifndef TVM_TIR_INDEX_MAP_H_
27#define TVM_TIR_INDEX_MAP_H_
29#include <tvm/ffi/container/array.h>
100 ffi::Array<PrimExpr>
MapIndices(
const ffi::Array<PrimExpr>& indices)
const;
110 ffi::Array<PrimExpr>
MapIndices(
const ffi::Array<PrimExpr>& indices,
125 ffi::Array<Range>
MapRanges(
const ffi::Array<Range>& ranges)
const;
148 ffi::Array<PrimExpr>
MapShape(
const ffi::Array<PrimExpr>& shape)
const;
157 ffi::Array<PrimExpr>
MapShape(
const ffi::Array<PrimExpr>& shape,
174 const std::function<ffi::Optional<ffi::String>(
const Var& var)>& f_name_map =
nullptr)
const;
177 namespace refl = tvm::ffi::reflection;
178 refl::ObjectDef<IndexMapNode>()
180 refl::AttachFieldFlag::SEqHashDefPattern())
183 refl::AttachFieldFlag::SEqHashIgnore());
198 IndexMap(ffi::Array<PrimVar> initial_indices, ffi::Array<PrimExpr> final_indices,
199 ffi::Optional<IndexMap> inverse_index_map = std::nullopt);
208 static IndexMap FromFunc(
int ndim, ffi::TypedFunction<ffi::Array<PrimExpr>(ffi::Array<Var>)> func,
209 ffi::Optional<IndexMap> inverse_index_map = std::nullopt);
243 const std::function<ffi::Optional<ffi::String>(
const Var& var)>& f_name_map =
nullptr)
const;
Managed reference to VarNode.
Definition expr.h:714
Managed reference to AnalyzerObj.
Definition analyzer.h:916
Defines a mapping between two representations of indices into a tensor.
Definition index_map.h:51
ffi::Array< PrimExpr > MapIndices(const ffi::Array< PrimExpr > &indices, const sym::Analyzer &analyzer) const
Map indices to the output space using an existing analyzer.
ffi::Array< PrimExpr > MapIndices(const ffi::Array< PrimExpr > &indices) const
Map indices to the output space using a fresh analyzer.
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition index_map.h:186
ffi::Tensor MapTensor(ffi::Tensor arr_src) const
ffi::Array< PrimVar > initial_indices
Variables representing the indices prior to remapping.
Definition index_map.h:58
ffi::Optional< ffi::ObjectRef > inverse_index_map
The inverse index map.
Definition index_map.h:82
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.
IndexMapNode()
Default constructor.
Definition index_map.h:90
ffi::String ToPythonString(const std::function< ffi::Optional< ffi::String >(const Var &var)> &f_name_map=nullptr) const
Convert to string representation in Python.
ffi::Array< Range > MapRanges(const ffi::Array< Range > &ranges) const
Map a memory range to the output space using a fresh analyzer.
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.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.IndexMap", IndexMapNode, ffi::Object)
ffi::Array< PrimExpr > MapShape(const ffi::Array< PrimExpr > &shape) const
Map a tensor shape to the output space using a fresh analyzer.
static void RegisterReflection()
Definition index_map.h:176
ffi::Array< PrimExpr > final_indices
Expressions defining the indices after remapping.
Definition index_map.h:70
Definition index_map.h:190
IndexMap Inverse(ffi::Array< Range > initial_ranges, const sym::Analyzer &analyzer) const
Generate the inverse mapping using an existing analyzer.
std::pair< IndexMap, PrimExpr > NonSurjectiveInverse(ffi::Array< Range > initial_ranges, const sym::Analyzer &analyzer) const
Generate the inverse mapping using an existing analyzer.
IndexMap(ffi::Array< PrimVar > initial_indices, ffi::Array< PrimExpr > final_indices, ffi::Optional< IndexMap > inverse_index_map=std::nullopt)
The constructor.
static IndexMap FromFunc(int ndim, ffi::TypedFunction< ffi::Array< PrimExpr >(ffi::Array< Var >)> func, ffi::Optional< IndexMap > inverse_index_map=std::nullopt)
Create an index map from a packed function.
std::pair< IndexMap, PrimExpr > NonSurjectiveInverse(ffi::Array< Range > initial_ranges) const
Generate the inverse mapping using a fresh analyzer.
IndexMap RenameVariables(const std::function< ffi::Optional< ffi::String >(const Var &var)> &f_name_map=nullptr) const
Rename the variables in the index map and ensure the names are unique.
IndexMap Inverse(ffi::Array< Range > initial_ranges) const
Generate the inverse mapping using a fresh analyzer.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(IndexMap, ffi::ObjectRef, IndexMapNode)
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23
Device-independent tensor allocation, copies, views and serialization.