tvm
Public Member Functions | Static Public Member Functions | List of all members
tvm::tir::IndexMap Class Reference

#include <index_map.h>

Inheritance diagram for tvm::tir::IndexMap:
Collaboration diagram for tvm::tir::IndexMap:

Public Member Functions

 IndexMap (Array< Var > initial_indices, Array< PrimExpr > final_indices, Optional< IndexMap > inverse_index_map=NullOpt)
 The constructor. More...
 
IndexMap Inverse (Array< Range > initial_ranges, arith::Analyzer *analyzer) const
 Generate the inverse mapping. More...
 
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. More...
 
std::pair< IndexMap, PrimExprNonSurjectiveInverse (Array< Range > initial_ranges, arith::Analyzer *analyzer) const
 Generate the inverse mapping. More...
 
 TVM_DEFINE_OBJECT_REF_METHODS (IndexMap, ObjectRef, IndexMapNode)
 
- Public Member Functions inherited from tvm::runtime::ObjectRef
 ObjectRef ()=default
 default constructor More...
 
 ObjectRef (ObjectPtr< Object > data)
 Constructor from existing object ptr. More...
 
bool same_as (const ObjectRef &other) const
 Comparator. More...
 
bool operator== (const ObjectRef &other) const
 Comparator. More...
 
bool operator!= (const ObjectRef &other) const
 Comparator. More...
 
bool operator< (const ObjectRef &other) const
 Comparator. More...
 
bool defined () const
 
const Objectget () const
 
const Objectoperator-> () const
 
bool unique () const
 
int use_count () const
 
template<typename ObjectType , typename = std::enable_if_t<std::is_base_of_v<Object, ObjectType>>>
const ObjectType * as () const
 Try to downcast the internal Object to a raw pointer of a corresponding type. More...
 
template<typename ObjectRefType , typename = std::enable_if_t<std::is_base_of_v<ObjectRef, ObjectRefType>>>
Optional< ObjectRefType > as () const
 Try to downcast the ObjectRef to a Optional<T> of the requested type. More...
 

Static Public Member Functions

static IndexMap FromFunc (int ndim, runtime::TypedPackedFunc< Array< PrimExpr >(Array< Var >)> func, Optional< IndexMap > inverse_index_map=NullOpt)
 Create an index map from a packed function. More...
 

Additional Inherited Members

- Public Types inherited from tvm::runtime::ObjectRef
using ContainerType = Object
 type indicate the container type. More...
 
- Static Public Attributes inherited from tvm::runtime::ObjectRef
static constexpr bool _type_is_nullable = true
 
- Protected Member Functions inherited from tvm::runtime::ObjectRef
Objectget_mutable () const
 
- Static Protected Member Functions inherited from tvm::runtime::ObjectRef
template<typename T >
static T DowncastNoCheck (ObjectRef ref)
 Internal helper function downcast a ref without check. More...
 
static void FFIClearAfterMove (ObjectRef *ref)
 Clear the object ref data field without DecRef after we successfully moved the field. More...
 
template<typename ObjectType >
static ObjectPtr< ObjectType > GetDataPtr (const ObjectRef &ref)
 Internal helper function get data_ as ObjectPtr of ObjectType. More...
 
- Protected Attributes inherited from tvm::runtime::ObjectRef
ObjectPtr< Objectdata_
 Internal pointer that backs the reference. More...
 

Constructor & Destructor Documentation

◆ IndexMap()

tvm::tir::IndexMap::IndexMap ( Array< Var initial_indices,
Array< PrimExpr final_indices,
Optional< IndexMap inverse_index_map = NullOpt 
)

The constructor.

Parameters
initial_indicesVariables representing the indices prior to remapping
final_indicesExpressions defining the indices after remapping.
inverse_index_mapThe optional pre-defined inverse index map

Member Function Documentation

◆ FromFunc()

static IndexMap tvm::tir::IndexMap::FromFunc ( int  ndim,
runtime::TypedPackedFunc< Array< PrimExpr >(Array< Var >)>  func,
Optional< IndexMap inverse_index_map = NullOpt 
)
static

Create an index map from a packed function.

Parameters
ndimThe number of dimensions
funcThe function to be applied
inverse_index_mapThe optional pre-defined inverse index map
Returns
The created index map

◆ Inverse()

IndexMap tvm::tir::IndexMap::Inverse ( Array< Range initial_ranges,
arith::Analyzer analyzer 
) const

Generate the inverse mapping.

The range of the input indices is required in order to ensure that the transformation is bijective over the input domain.

If the user has supplied an inverse_index_map, that map is assumed to be correct and bijective, and is returned.

◆ NonSurjectiveInverse()

std::pair<IndexMap, PrimExpr> tvm::tir::IndexMap::NonSurjectiveInverse ( Array< Range initial_ranges,
arith::Analyzer analyzer 
) const

Generate the inverse mapping.

Determine the inverse, where the output range may contain addresses that do not correspond to an address in the input range.

Returns
The inverted index map, along with the predicate for which the inverse maps to a valid range.

◆ RenameVariables()

IndexMap tvm::tir::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.

Construct a new index map with the same transformation, but with name_hint of variables to be guaranteed unique. The optional f_name_map can be provided to rename the variables.

Parameters
f_name_mapThe optional name map to rename the variables.
Returns
The renamed index map.

◆ TVM_DEFINE_OBJECT_REF_METHODS()

tvm::tir::IndexMap::TVM_DEFINE_OBJECT_REF_METHODS ( IndexMap  ,
ObjectRef  ,
IndexMapNode   
)

The documentation for this class was generated from the following file: