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

Managed reference to LayoutNode. More...

#include <data_layout.h>

Inheritance diagram for tvm::tir::Layout:
Collaboration diagram for tvm::tir::Layout:

Public Member Functions

 Layout (const Array< tir::IterVar > &axes)
 
 Layout (const tvm::String &name)
 construct from a string More...
 
 Layout (const char *name)
 construct from a string More...
 
 Layout (const std::string &name, DataType dtype=DataType::Int(32))
 construct from a string. More...
 
LayoutNodeoperator-> ()
 access the internal node container More...
 
Layout SubLayout (size_t pos, size_t len) const
 Returns a sub-layout which is the portion of the object that starts at dimension pos and spans len dimensions (or until the end of the layout, whichever comes first). More...
 
Layout Split (const LayoutAxis &axis, size_t target_pos, int32_t factor) const
 Split axis by size and put the sub-axis to position target_pos. More...
 
size_t ndim () const
 
size_t ndim_primal () const
 
Layout ExpandPrimal (const Layout &dst_layout)
 Returns a new layout where the dims have been expanded to match the primal dimensions. More...
 
int32_t IndexOf (const LayoutAxis &axis) const
 return the index of the input axis. If it is not found in the layout or the layout is undefined, return -1. More...
 
int32_t FactorOf (const LayoutAxis &axis) const
 Get the factor size of the subordinate axis. More...
 
bool Contains (const LayoutAxis &axis) const
 Whether the layout contains an axis. More...
 
const LayoutAxisoperator[] (int32_t i) const
 
std::string name () const
 
bool Equals (const Layout &rhs) const
 Whether the two layouts are equal. More...
 
 TVM_DEFINE_OBJECT_REF_METHODS (Layout, ObjectRef, LayoutNode)
 
- 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 const LayoutUndef ()
 Return an undefined layout. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Layout &l)
 allow output string of layout to ostream 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...
 

Detailed Description

Managed reference to LayoutNode.

See also
LayoutNode

Constructor & Destructor Documentation

◆ Layout() [1/4]

tvm::tir::Layout::Layout ( const Array< tir::IterVar > &  axes)
explicit

◆ Layout() [2/4]

tvm::tir::Layout::Layout ( const tvm::String name)
inline

construct from a string

◆ Layout() [3/4]

tvm::tir::Layout::Layout ( const char *  name)
inline

construct from a string

◆ Layout() [4/4]

tvm::tir::Layout::Layout ( const std::string &  name,
DataType  dtype = DataType::Int(32) 
)

construct from a string.

Parameters
nameinput in layout convention: upper case indicates a dimension and the corresponding lower case with factor size indicates the split dimension. return undefined layout if "__undef__" is passed.
dtypeThe dtype of generated axes vars in the returned layout. It is required to be integer type.

Member Function Documentation

◆ Contains()

bool tvm::tir::Layout::Contains ( const LayoutAxis axis) const
inline

Whether the layout contains an axis.

Parameters
axisaxis to be checked.
Returns
Whether the layout contains the axis.

◆ Equals()

bool tvm::tir::Layout::Equals ( const Layout rhs) const
inline

Whether the two layouts are equal.

Parameters
rhsAnother layout.
Returns
whether the two layouts are equal.

◆ ExpandPrimal()

Layout tvm::tir::Layout::ExpandPrimal ( const Layout dst_layout)
inline

Returns a new layout where the dims have been expanded to match the primal dimensions.

Parameters
dst_layoutThe dst layout to which current layout has to be expanded.
Returns
The expanded Layout.

◆ FactorOf()

int32_t tvm::tir::Layout::FactorOf ( const LayoutAxis axis) const

Get the factor size of the subordinate axis.

Parameters
axisthe input primal-axis or subordinate-axis.
Returns
the size of the subordinate-axis of axis (if axis is a primal-axis), or the size of axis itself (if axis is a subordinate-axis). Return -1 if axis is not in the layout the layout is undefined.

◆ IndexOf()

int32_t tvm::tir::Layout::IndexOf ( const LayoutAxis axis) const
inline

return the index of the input axis. If it is not found in the layout or the layout is undefined, return -1.

Parameters
axisthe input axis.
Returns
the index or -1 if not found.

◆ name()

std::string tvm::tir::Layout::name ( ) const
inline
Returns
the string description of the layout

◆ ndim()

size_t tvm::tir::Layout::ndim ( ) const
inline
Returns
number of dimensions

◆ ndim_primal()

size_t tvm::tir::Layout::ndim_primal ( ) const
inline
Returns
number of super dimensions

◆ operator->()

LayoutNode* tvm::tir::Layout::operator-> ( )
inline

access the internal node container

Returns
the pointer to the internal node container

◆ operator[]()

const LayoutAxis& tvm::tir::Layout::operator[] ( int32_t  i) const
inline

◆ Split()

Layout tvm::tir::Layout::Split ( const LayoutAxis axis,
size_t  target_pos,
int32_t  factor 
) const

Split axis by size and put the sub-axis to position target_pos.

Parameters
axisThe source axis to be split. It must be a primal-axis;
target_posThe target position of the newly split subordinate-axis.
factorsize of the sub-dimension.
Returns
A newly constructed Layout object.

◆ SubLayout()

Layout tvm::tir::Layout::SubLayout ( size_t  pos,
size_t  len 
) const

Returns a sub-layout which is the portion of the object that starts at dimension pos and spans len dimensions (or until the end of the layout, whichever comes first).

Parameters
posThe start position.
lenThe length of the sub-layout. if 0, return layout of scalar
Returns
A newly constructed Layout object.

◆ TVM_DEFINE_OBJECT_REF_METHODS()

tvm::tir::Layout::TVM_DEFINE_OBJECT_REF_METHODS ( Layout  ,
ObjectRef  ,
LayoutNode   
)

◆ Undef()

static const Layout& tvm::tir::Layout::Undef ( )
inlinestatic

Return an undefined layout.

Returns
a (global) undefined layout.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Layout l 
)
friend

allow output string of layout to ostream

Parameters
osthe output stream
lthe layout
Returns
the ostream

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