26 #ifndef TVM_TIR_INDEX_MAP_H_
27 #define TVM_TIR_INDEX_MAP_H_
29 #include <tvm/ffi/container/array.h>
101 ffi::Array<PrimExpr>
MapIndices(
const ffi::Array<PrimExpr>& indices)
const;
111 ffi::Array<PrimExpr>
MapIndices(
const ffi::Array<PrimExpr>& indices,
126 ffi::Array<Range>
MapRanges(
const ffi::Array<Range>& ranges)
const;
140 ffi::Array<Range>
MapRanges(
const ffi::Array<Range>& ranges,
176 const std::function<ffi::Optional<ffi::String>(
const Var&
var)>& f_name_map =
nullptr)
const;
179 namespace refl = tvm::ffi::reflection;
180 refl::ObjectDef<IndexMapNode>()
182 refl::AttachFieldFlag::SEqHashDefRecursive())
185 refl::AttachFieldFlag::SEqHashIgnore());
200 IndexMap(ffi::Array<PrimVar> initial_indices, ffi::Array<PrimExpr> final_indices,
201 ffi::Optional<IndexMap> inverse_index_map = std::nullopt);
210 static IndexMap FromFunc(
int ndim, ffi::TypedFunction<ffi::Array<PrimExpr>(ffi::Array<Var>)> func,
211 ffi::Optional<IndexMap> inverse_index_map = std::nullopt);
245 const std::function<ffi::Optional<ffi::String>(
const Var&
var)>& f_name_map =
nullptr)
const;
282 std::function<ffi::Optional<PrimExpr>(
const Var&
var)> f_subst);
Managed reference to AnalyzerObj.
Definition: analyzer.h:913
Managed Tensor. The array is backed by reference counted blocks.
Definition: tensor.h:49
Defines a mapping between two representations of indices into a buffer.
Definition: index_map.h:52
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: index_map.h:188
ffi::Array< Range > MapRanges(const ffi::Array< Range > &ranges, const arith::Analyzer &analyzer) const
Map a memory range to the output space using an existing analyzer.
ffi::Array< PrimExpr > MapShape(const ffi::Array< PrimExpr > &shape, const arith::Analyzer &analyzer) const
Map a buffer shape to the output space using an existing analyzer.
ffi::Array< PrimVar > initial_indices
Variables representing the indices prior to remapping.
Definition: index_map.h:59
ffi::Optional< ffi::ObjectRef > inverse_index_map
The inverse index map.
Definition: index_map.h:83
IndexMapNode()
Default constructor.
Definition: index_map.h:91
ffi::String ToPythonString(const std::function< ffi::Optional< ffi::String >(const Var &var)> &f_name_map=nullptr) const
Convert to string representation in Python.
runtime::Tensor MapTensor(runtime::Tensor arr_src) const
ffi::Array< Range > MapRanges(const ffi::Array< Range > &ranges) const
Map a memory range to the output space using a fresh analyzer.
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tirx.IndexMap", IndexMapNode, ffi::Object)
ffi::Array< PrimExpr > MapShape(const ffi::Array< PrimExpr > &shape) const
Map a buffer shape to the output space using a fresh analyzer.
ffi::Array< PrimExpr > MapIndices(const ffi::Array< PrimExpr > &indices) const
Map indices to the output space using a fresh analyzer.
static void RegisterReflection()
Definition: index_map.h:178
ffi::Array< PrimExpr > MapIndices(const ffi::Array< PrimExpr > &indices, const arith::Analyzer &analyzer) const
Map indices to the output space using an existing analyzer.
ffi::Array< PrimExpr > final_indices
Expressions defining the indices after remapping.
Definition: index_map.h:71
Definition: index_map.h:192
std::pair< IndexMap, PrimExpr > NonSurjectiveInverse(ffi::Array< Range > initial_ranges, const arith::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.
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(IndexMap, ffi::ObjectRef, IndexMapNode)
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.
IndexMap Inverse(ffi::Array< Range > initial_ranges, const arith::Analyzer &analyzer) const
Generate the inverse mapping using an existing 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.
std::pair< IndexMap, PrimExpr > NonSurjectiveInverse(ffi::Array< Range > initial_ranges) const
Generate the inverse mapping using a fresh analyzer.
a named variable in TIR
Definition: var.h:68
PrimVar var(std::string name_hint, PrimType t=PrimType::Int(32))
Construct a new Var expression.
IndexMap Substitute(const IndexMap &index_map, std::function< ffi::Optional< PrimExpr >(const Var &var)> f_subst)
Substitute variables in an index map.
Tensor shape(const Tensor &src, PrimType dtype, const std::string name="T_shape", const std::string tag=kInjective)
Get the shape of input tensor.
Definition: transform.h:2010
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition: analyzer.h:40
A device-independent managed Tensor abstraction.