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

Buffer is a symbolic n-darray structure. It is a composition of primitive symbolic types, used to specify the memory layout of the Tensor used in program input. More...

#include <buffer.h>

Inheritance diagram for tvm::tir::Buffer:
Collaboration diagram for tvm::tir::Buffer:

Public Member Functions

 Buffer (Var data, DataType dtype, Array< PrimExpr > shape, Array< PrimExpr > strides, PrimExpr elem_offset, String name, int data_alignment, int offset_factor, BufferType buffer_type, Array< IntImm > axis_separators={}, Span span=Span())
 
Buffer MakeStrideView () const
 Return a new buffer that is equivalent with current one but always add stride field. More...
 
Buffer MakeSlice (Array< PrimExpr > begins, Array< PrimExpr > extents) const
 Make a new symbolic buffer representing a slice of the buffer. More...
 
PrimExpr access_ptr (int access_mask, DataType ptr_type=DataType::Handle(), int content_lanes=1, PrimExpr offset=IntImm(DataType::Int(32), 0), Optional< PrimExpr > input_extent=NullOpt) const
 Get access ptr to the entire buffer. More...
 
PrimExpr vload (Array< PrimExpr > begin, DataType dtype) const
 Create an Expr that does a vector load at begin index. More...
 
Stmt vstore (Array< PrimExpr > begin, PrimExpr value) const
 Create a Stmt that does a vector store at begin index. More...
 
Buffer GetFlattenedBuffer () const
 Get a flattened version of the buffer. More...
 
Array< PrimExprOffsetOf (Array< PrimExpr > index) const
 Determine the offset in the buffer of the given index. More...
 
String scope () const
 Return the storage scope associated with this buffer. More...
 
 TVM_DEFINE_OBJECT_REF_METHODS (Buffer, ObjectRef, BufferNode)
 
 TVM_DEFINE_OBJECT_REF_COW_METHOD (BufferNode)
 
- 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...
 

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

Buffer is a symbolic n-darray structure. It is a composition of primitive symbolic types, used to specify the memory layout of the Tensor used in program input.

Constructor & Destructor Documentation

◆ Buffer()

tvm::tir::Buffer::Buffer ( Var  data,
DataType  dtype,
Array< PrimExpr shape,
Array< PrimExpr strides,
PrimExpr  elem_offset,
String  name,
int  data_alignment,
int  offset_factor,
BufferType  buffer_type,
Array< IntImm axis_separators = {},
Span  span = Span() 
)

Member Function Documentation

◆ access_ptr()

PrimExpr tvm::tir::Buffer::access_ptr ( int  access_mask,
DataType  ptr_type = DataType::Handle(),
int  content_lanes = 1,
PrimExpr  offset = IntImm(DataType::Int(32), 0),
Optional< PrimExpr input_extent = NullOpt 
) const

Get access ptr to the entire buffer.

Parameters
access_maskThe access mask
ptr_typeThe type of the pointer.
content_lanesThe number of lanes for the (data) type.
offsetThe offset of ptr.
input_extentThe extent of ptr.

◆ GetFlattenedBuffer()

Buffer tvm::tir::Buffer::GetFlattenedBuffer ( ) const

Get a flattened version of the buffer.

◆ MakeSlice()

Buffer tvm::tir::Buffer::MakeSlice ( Array< PrimExpr begins,
Array< PrimExpr extents 
) const

Make a new symbolic buffer representing a slice of the buffer.

Parameters
beginsThe beginning position of each dimension.
extentsThe extent of each dimension.
Note
This function will make target buffer as compact as possible. If stride is not needed in the slice, it won't be presented
Returns
the result buffer.

◆ MakeStrideView()

Buffer tvm::tir::Buffer::MakeStrideView ( ) const

Return a new buffer that is equivalent with current one but always add stride field.

Returns
The strided version of the buffer.

◆ OffsetOf()

Array<PrimExpr> tvm::tir::Buffer::OffsetOf ( Array< PrimExpr index) const

Determine the offset in the buffer of the given index.

Returns the buffer offset, in number of elements of type dtype, without adjusting for number of lanes. (e.g. The number of float16x4 elements in a buffer of type float16x4.)

◆ scope()

String tvm::tir::Buffer::scope ( ) const

Return the storage scope associated with this buffer.

◆ TVM_DEFINE_OBJECT_REF_COW_METHOD()

tvm::tir::Buffer::TVM_DEFINE_OBJECT_REF_COW_METHOD ( BufferNode  )

◆ TVM_DEFINE_OBJECT_REF_METHODS()

tvm::tir::Buffer::TVM_DEFINE_OBJECT_REF_METHODS ( Buffer  ,
ObjectRef  ,
BufferNode   
)

◆ vload()

PrimExpr tvm::tir::Buffer::vload ( Array< PrimExpr begin,
DataType  dtype 
) const

Create an Expr that does a vector load at begin index.

Parameters
beginThe beginning index
dtypeThe data type to be loaded.

◆ vstore()

Stmt tvm::tir::Buffer::vstore ( Array< PrimExpr begin,
PrimExpr  value 
) const

Create a Stmt that does a vector store at begin index.

Parameters
beginThe beginning index
valueThe value to be stored.

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