26#ifndef TVM_TIRX_INDEX_MAP_H_
27#define TVM_TIRX_INDEX_MAP_H_
29#include <tvm/ffi/container/array.h>
30#include <tvm/ffi/container/tuple.h>
176 const ffi::TypedFunction<ffi::Optional<ffi::String>(
const Var& var)>& f_name_map =
180 namespace refl = tvm::ffi::reflection;
181 refl::ObjectDef<IndexMapObj>()
183 refl::AttachFieldFlag::SEqHashDefPattern())
186 refl::AttachFieldFlag::SEqHashIgnore());
202 ffi::Optional<IndexMap> inverse_index_map = std::nullopt);
212 int ndim, ffi::TypedFunction<ffi::Array<PrimExpr>(ffi::Array<Var>)> func,
213 ffi::Optional<IndexMap> inverse_index_map = std::nullopt);
262 ffi::Array<Range> initial_ranges)
const;
276 ffi::Array<Range> initial_ranges,
const sym::Analyzer& analyzer)
const;
#define TVM_TIRX_DLL
Definition base.h:55
Device-independent tensor allocation, copies, views and serialization.
Managed reference to VarObj.
Definition expr.h:571
Managed reference to AnalyzerObj.
Definition analyzer.h:750
Defines a mapping between two representations of indices into a tensor.
Definition index_map.h:52
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.IndexMap", IndexMapObj, ffi::Object)
ffi::Array< PrimVar > initial_indices
Variables representing the indices prior to remapping.
Definition index_map.h:59
TVM_TIRX_DLL ffi::Tensor MapTensor(ffi::Tensor arr_src) const
ffi::Optional< ffi::ObjectRef > inverse_index_map
The inverse index map.
Definition index_map.h:83
TVM_TIRX_DLL ffi::String ToPythonString(const ffi::TypedFunction< ffi::Optional< ffi::String >(const Var &var)> &f_name_map=nullptr) const
Convert to string representation in Python.
IndexMapObj()
Default constructor.
Definition index_map.h:91
ffi::Array< PrimExpr > final_indices
Expressions defining the indices after remapping.
Definition index_map.h:71
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition index_map.h:189
TVM_TIRX_DLL 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.
TVM_TIRX_DLL 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.
static void RegisterReflection()
Definition index_map.h:179
TVM_TIRX_DLL ffi::Array< PrimExpr > MapIndices(const ffi::Array< PrimExpr > &indices) const
Map indices to the output space using a fresh analyzer.
TVM_TIRX_DLL ffi::Array< Range > MapRanges(const ffi::Array< Range > &ranges) const
Map a memory range to the output space using a fresh analyzer.
TVM_TIRX_DLL ffi::Array< PrimExpr > MapShape(const ffi::Array< PrimExpr > &shape) const
Map a tensor shape to the output space using a fresh analyzer.
TVM_TIRX_DLL ffi::Array< PrimExpr > MapIndices(const ffi::Array< PrimExpr > &indices, const sym::Analyzer &analyzer) const
Map indices to the output space using an existing analyzer.
Definition index_map.h:193
static TVM_TIRX_DLL 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.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(IndexMap, ffi::ObjectRef, IndexMapObj)
TVM_TIRX_DLL IndexMap(ffi::Array< PrimVar > initial_indices, ffi::Array< PrimExpr > final_indices, ffi::Optional< IndexMap > inverse_index_map=std::nullopt)
The constructor.
TVM_TIRX_DLL IndexMap Inverse(ffi::Array< Range > initial_ranges, const sym::Analyzer &analyzer) const
Generate the inverse mapping using an existing analyzer.
TVM_TIRX_DLL IndexMap RenameVariables(const ffi::TypedFunction< 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.
TVM_TIRX_DLL IndexMap Inverse(ffi::Array< Range > initial_ranges) const
Generate the inverse mapping using a fresh analyzer.
TVM_TIRX_DLL ffi::Tuple< IndexMap, PrimExpr > NonSurjectiveInverse(ffi::Array< Range > initial_ranges) const
Generate the inverse mapping using a fresh analyzer.
TVM_TIRX_DLL ffi::Tuple< IndexMap, PrimExpr > NonSurjectiveInverse(ffi::Array< Range > initial_ranges, const sym::Analyzer &analyzer) const
Generate the inverse mapping using an existing analyzer.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41