tvm
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | List of all members
tvm::tirx::BufferVar Class Reference

Checked zero-state view over an ordinary VarNode with BufferType. More...

#include <buffer.h>

Inheritance diagram for tvm::tirx::BufferVar:
Collaboration diagram for tvm::tirx::BufferVar:

Public Types

using ContainerType = VarNode
 

Public Member Functions

 BufferVar (ffi::String name, BufferType type, Span span=Span())
 Construct a fresh buffer variable from an explicit BufferType.
 
 BufferVar (Var var)
 Create a checked buffer view over an existing ordinary Var.
 
Var var () const
 Return the ordinary variable view over the same identity.
 
BufferType type () const
 Return the buffer type carried by the ordinary variable.
 
const ffi::String & name () const
 Return the buffer's diagnostic name.
 
const Spanspan () const
 Return the source span carried by the ordinary Var.
 
Expr data () const
 Project the physical pointer established by the definition site.
 
BufferVar MakeStrideView () const
 Return a new buffer that is equivalent with current one but always add stride field.
 
BufferVar MakeSlice (ffi::Array< PrimExpr > begins, ffi::Array< PrimExpr > extents) const
 Make a new symbolic buffer representing a slice of the buffer.
 
Expr access_ptr (int access_mask, PointerType ptr_type=PointerType::VoidPointerTy(), int content_lanes=1, PrimExpr offset=IntImm::Int32(0), ffi::Optional< PrimExpr > input_extent=std::nullopt) const
 Get access ptr to the entire buffer.
 
PrimExpr vload (ffi::Array< PrimExpr > begin, PrimType dtype) const
 Create an Expr that does a vector load at begin index.
 
Stmt vstore (ffi::Array< PrimExpr > begin, PrimExpr value) const
 Create a Stmt that does a vector store at begin index.
 
BufferVar GetFlattenedBuffer () const
 Get a flattened version of the buffer.
 
ffi::Array< PrimExprOffsetOf (ffi::Array< PrimExpr > index) const
 Determine the offset in the buffer of the given index.
 
PrimExpr OffsetOf_p (const ffi::Array< PrimExpr > &indices) const
 Get the buffer_offset op for the given index.
 
ffi::String scope () const
 Return the storage scope associated with this buffer.
 
BufferVar with_allocated_addr (ffi::Array< PrimExpr > allocated_addr) const
 Return a new buffer with the allocated address.
 
bool IsScalar (bool alloc_or_decl=true) const
 Return true if the buffer is a scalar.
 
BufferVar with_dtype (PrimType dtype) const
 Return a new buffer with the dtype.
 
PrimType ElementType () const
 
PointerType DataPointerType () const
 
 BufferVar ()=default
 
 BufferVar (ffi::ObjectPtr< VarNode > n)
 
 BufferVar (ffi::UnsafeInit tag)
 
 TVM_FFI_DEFINE_DEFAULT_COPY_MOVE_AND_ASSIGN (BufferVar)
 
const BufferTypeNodeoperator-> () const
 
const VarNodeget () const
 
- Public Member Functions inherited from tvm::Var
 Var (ffi::String name, ffi::Optional< Type > ty_annotation, Span span=Span())
 
Var CopyWithName (const ffi::String &name) const
 Return a fresh ordinary Var with the same type and a new name.
 
Var CopyWithSuffix (const ffi::String &suffix) const
 Return a fresh ordinary Var with a suffix appended to its name.
 
Var CopyWithDType (PrimType dtype) const
 Return a fresh ordinary Var with a new primitive type.
 
 TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE (Var, Expr, VarNode)
 
- Public Member Functions inherited from tvm::Expr
bool operator== (const Expr &other) const =delete
 
bool operator!= (const Expr &other) const =delete
 
bool operator< (const Expr &other) const =delete
 
 TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE (Expr, ffi::ObjectRef, ExprNode)
 

Static Public Attributes

static constexpr bool _type_is_nullable = false
 
static constexpr bool _type_container_is_exact = false
 

Detailed Description

Checked zero-state view over an ordinary VarNode with BufferType.

BufferVar does not introduce a runtime object or a second identity. It safely widens to Var, and get() returns the underlying VarNode used by identity-sensitive maps. operator-> exposes the immutable BufferType access contract for concise compiler-side metadata access.

Member Typedef Documentation

◆ ContainerType

Constructor & Destructor Documentation

◆ BufferVar() [1/5]

tvm::tirx::BufferVar::BufferVar ( ffi::String  name,
BufferType  type,
Span  span = Span() 
)
explicit

Construct a fresh buffer variable from an explicit BufferType.

◆ BufferVar() [2/5]

tvm::tirx::BufferVar::BufferVar ( Var  var)
inlineexplicit

Create a checked buffer view over an existing ordinary Var.

◆ BufferVar() [3/5]

tvm::tirx::BufferVar::BufferVar ( )
default

◆ BufferVar() [4/5]

tvm::tirx::BufferVar::BufferVar ( ffi::ObjectPtr< VarNode n)
inlineexplicit

◆ BufferVar() [5/5]

tvm::tirx::BufferVar::BufferVar ( ffi::UnsafeInit  tag)
inlineexplicit

Member Function Documentation

◆ access_ptr()

Expr tvm::tirx::BufferVar::access_ptr ( int  access_mask,
PointerType  ptr_type = PointerType::VoidPointerTy(),
int  content_lanes = 1,
PrimExpr  offset = IntImm::Int32(0),
ffi::Optional< PrimExpr input_extent = std::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.

◆ data()

Expr tvm::tirx::BufferVar::data ( ) const

Project the physical pointer established by the definition site.

◆ DataPointerType()

PointerType tvm::tirx::BufferVar::DataPointerType ( ) const
inline
Returns
type of the physical pointer projected by buffer_data.

◆ ElementType()

PrimType tvm::tirx::BufferVar::ElementType ( ) const
inline
Returns
primitive element type for compiler-side uses.

◆ get()

const VarNode * tvm::tirx::BufferVar::get ( ) const
inline

◆ GetFlattenedBuffer()

BufferVar tvm::tirx::BufferVar::GetFlattenedBuffer ( ) const

Get a flattened version of the buffer.

If flattening changes the type, the result is a fresh BufferVar. Callers that use it as a view over this buffer must bind the returned variable with DeclBuffer(flattened, this->data()).

◆ IsScalar()

bool tvm::tirx::BufferVar::IsScalar ( bool  alloc_or_decl = true) const

Return true if the buffer is a scalar.

Parameters
alloc_or_declWhether to consider alloc_scalar and decl_scalar as scalar. True for alloc_scalar, False for decl_scalar.

◆ MakeSlice()

BufferVar tvm::tirx::BufferVar::MakeSlice ( ffi::Array< PrimExpr begins,
ffi::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()

BufferVar tvm::tirx::BufferVar::MakeStrideView ( ) const

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

Returns
The strided version of the buffer.

◆ name()

const ffi::String & tvm::tirx::BufferVar::name ( ) const
inline

Return the buffer's diagnostic name.

◆ OffsetOf()

ffi::Array< PrimExpr > tvm::tirx::BufferVar::OffsetOf ( ffi::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.)

◆ OffsetOf_p()

PrimExpr tvm::tirx::BufferVar::OffsetOf_p ( const ffi::Array< PrimExpr > &  indices) const

Get the buffer_offset op for the given index.

Parameters
indexThe index to be accessed.
Returns
The buffer_offset op.

◆ operator->()

const BufferTypeNode * tvm::tirx::BufferVar::operator-> ( ) const
inline

◆ scope()

ffi::String tvm::tirx::BufferVar::scope ( ) const

Return the storage scope associated with this buffer.

◆ span()

const Span & tvm::tirx::BufferVar::span ( ) const
inline

Return the source span carried by the ordinary Var.

◆ TVM_FFI_DEFINE_DEFAULT_COPY_MOVE_AND_ASSIGN()

tvm::tirx::BufferVar::TVM_FFI_DEFINE_DEFAULT_COPY_MOVE_AND_ASSIGN ( BufferVar  )

◆ type()

BufferType tvm::tirx::BufferVar::type ( ) const
inline

Return the buffer type carried by the ordinary variable.

◆ var()

Var tvm::tirx::BufferVar::var ( ) const
inline

Return the ordinary variable view over the same identity.

◆ vload()

PrimExpr tvm::tirx::BufferVar::vload ( ffi::Array< PrimExpr begin,
PrimType  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::tirx::BufferVar::vstore ( ffi::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.

◆ with_allocated_addr()

BufferVar tvm::tirx::BufferVar::with_allocated_addr ( ffi::Array< PrimExpr allocated_addr) const

Return a new buffer with the allocated address.

◆ with_dtype()

BufferVar tvm::tirx::BufferVar::with_dtype ( PrimType  dtype) const

Return a new buffer with the dtype.

Member Data Documentation

◆ _type_container_is_exact

constexpr bool tvm::tirx::BufferVar::_type_container_is_exact = false
staticconstexpr

◆ _type_is_nullable

constexpr bool tvm::tirx::BufferVar::_type_is_nullable = false
staticconstexpr

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