26 #ifndef TVM_TIR_INDEX_MAP_H_
27 #define TVM_TIR_INDEX_MAP_H_
29 #include <tvm/ffi/container/array.h>
152 const std::function<Optional<String>(
const Var&
var)>& f_name_map =
nullptr)
const;
156 refl::ObjectDef<IndexMapNode>()
158 refl::AttachFieldFlag::SEqHashDef())
161 refl::AttachFieldFlag::SEqHashIgnore());
165 static constexpr
const char*
_type_key =
"tir.IndexMap";
177 IndexMap(Array<Var> initial_indices, Array<PrimExpr> final_indices,
178 Optional<IndexMap> inverse_index_map = std::nullopt);
188 Optional<IndexMap> inverse_index_map = std::nullopt);
209 const std::function<Optional<String>(
const Var&
var)>& f_name_map =
nullptr)
const;
232 std::function<Optional<PrimExpr>(
const Var&
var)> f_subst);
Analyzer that contains bunch of sub-analyzers.
Definition: analyzer.h:636
Managed NDArray. The array is backed by reference counted blocks.
Definition: ndarray.h:53
Defines a mapping between two representations of indices into a buffer.
Definition: index_map.h:52
Array< PrimExpr > MapIndices(const Array< PrimExpr > &indices, arith::Analyzer *analyzer) const
Map indices to the output space.
static constexpr const char * _type_key
Definition: index_map.h:165
Array< PrimExpr > final_indices
Expressions defining the indices after remapping.
Definition: index_map.h:71
Optional< ObjectRef > inverse_index_map
The inverse index map.
Definition: index_map.h:83
Array< PrimExpr > MapShape(const Array< PrimExpr > &shape, arith::Analyzer *analyzer) const
Map a buffer shape to the output space.
Array< Var > initial_indices
Variables representing the indices prior to remapping.
Definition: index_map.h:59
static void RegisterReflection()
Definition: index_map.h:154
IndexMapNode()
Default constructor.
Definition: index_map.h:91
Array< Range > MapRanges(const Array< Range > &ranges, arith::Analyzer *analyzer) const
Map a memory range to the output space.
TVM_DECLARE_FINAL_OBJECT_INFO(IndexMapNode, Object)
String ToPythonString(const std::function< Optional< String >(const Var &var)> &f_name_map=nullptr) const
Convert to string representation in Python.
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition: index_map.h:164
runtime::NDArray MapNDArray(runtime::NDArray arr_src) const
Definition: index_map.h:169
TVM_DEFINE_OBJECT_REF_METHODS(IndexMap, ObjectRef, IndexMapNode)
IndexMap Inverse(Array< Range > initial_ranges, arith::Analyzer *analyzer) const
Generate the inverse mapping.
IndexMap RenameVariables(const std::function< Optional< String >(const Var &var)> &f_name_map=nullptr) const
Rename the variables in the index map and ensure the names are unique.
std::pair< IndexMap, PrimExpr > NonSurjectiveInverse(Array< Range > initial_ranges, arith::Analyzer *analyzer) const
Generate the inverse mapping.
IndexMap(Array< Var > initial_indices, Array< PrimExpr > final_indices, Optional< IndexMap > inverse_index_map=std::nullopt)
The constructor.
static IndexMap FromFunc(int ndim, ffi::TypedFunction< Array< PrimExpr >(Array< Var >)> func, Optional< IndexMap > inverse_index_map=std::nullopt)
Create an index map from a packed function.
a named variable in TIR
Definition: var.h:78
Definition: repr_printer.h:91
Var var(std::string name_hint, DataType t=DataType::Int(32))
Construct a new Var expression.
IndexMap Substitute(const IndexMap &index_map, std::function< Optional< PrimExpr >(const Var &var)> f_subst)
Substitute variables in an index map.
Tensor shape(const Tensor &src, DataType dtype, const std::string name="T_shape", const std::string tag=kInjective)
Get the shape of input tensor.
Definition: transform.h:1945
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37
A managed object in the TVM runtime.