tvm
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
tvm::Op Class Reference

Reference-counted handle to a canonical named operator. More...

#include <op.h>

Inheritance diagram for tvm::Op:
Collaboration diagram for tvm::Op:

Public Member Functions

 Op (ffi::ObjectPtr< OpObj > n)
 Construct a handle from a defined node.
 
TVM_FFI_INLINE void Validate (const CallObj *call) const
 Validate a Call with this Op's callback, when one is registered.
 
 TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE (Op, Expr, OpObj)
 
- 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
 
 Expr (ffi::ObjectPtr< ExprObj > node)
 
 TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE (Expr, ffi::ObjectRef, ExprObj)
 

Static Public Member Functions

template<typename ValueType >
static OpAttrMap< ValueType > GetAttrMap (const ffi::String &attr_name)
 Get a typed live view of a registered attribute column.
 
template<typename ValueType >
static OpAttrMap< ValueType > GetAttrMap (ffi::reflection::AttrKey< ValueType > key)
 Get a live attribute view with its value type deduced from the key.
 
static TVM_TIRX_DLL bool HasAttrMap (const ffi::String &attr_name)
 Check whether an attribute column exists, even if some Ops lack a value.
 
template<typename ValueType >
static bool HasAttrMap (ffi::reflection::AttrKey< ValueType > key)
 Check whether the column named by a typed key exists.
 
static TVM_TIRX_DLL Op Get (const ffi::String &op_name)
 Look up a registered operator by name.
 
static TVM_TIRX_DLL ffi::Array< ffi::String > ListNames ()
 List registered operator names.
 

Friends

class OpDef
 

Detailed Description

Reference-counted handle to a canonical named operator.

OpDef temporarily builds metadata on the same Op returned by Get. Independent registrations may attach different attributes; replacing an existing attribute requires explicit override. Cached attribute maps observe subsequent changes. args_info describes required value operands; var_args_info permits a suffix. ty_args_info describes type arguments; a typed signature installs a validator that checks their count and classes.

constexpr ffi::reflection::AttrKey<bool> kPure{"FPurity"};
TVM_FFI_STATIC_INIT_BLOCK() {
OpDef("example.identity", "Return the input expression.")
.signature(sig::arg("value", "The input expression."))
.set_attr(kPure, true)
.expose();
}
// Copies the handle; the canonical node is shared.
Op op = Op::Get("example.identity");
bool pure = Op::GetAttrMap(kPure)[op];
friend class OpDef
Definition op.h:197
static TVM_TIRX_DLL Op Get(const ffi::String &op_name)
Look up a registered operator by name.
static OpAttrMap< ValueType > GetAttrMap(const ffi::String &attr_name)
Get a typed live view of a registered attribute column.
Definition op.h:767
@ kPure
Pure function that do not interacts with any external state.

Constructor & Destructor Documentation

◆ Op()

tvm::Op::Op ( ffi::ObjectPtr< OpObj >  n)
inlineexplicit

Construct a handle from a defined node.

Parameters
nThe operator node.

Member Function Documentation

◆ Get()

static TVM_TIRX_DLL Op tvm::Op::Get ( const ffi::String &  op_name)
static

Look up a registered operator by name.

Parameters
op_nameThe canonical name.
Returns
A copy of the reference-counted handle to the canonical node.
Exceptions
AttributeErrorif the operator is not registered.

◆ GetAttrMap() [1/2]

template<typename ValueType >
OpAttrMap< ValueType > tvm::Op::GetAttrMap ( const ffi::String &  attr_name)
static

Get a typed live view of a registered attribute column.

Template Parameters
ValueTypeThe attribute value type.
Parameters
attr_nameThe column name.
Returns
A shared view that observes registration, replacement, reset, and growth.
Exceptions
InternalErrorif the column has never been registered.

◆ GetAttrMap() [2/2]

template<typename ValueType >
OpAttrMap< ValueType > tvm::Op::GetAttrMap ( ffi::reflection::AttrKey< ValueType >  key)
static

Get a live attribute view with its value type deduced from the key.

◆ HasAttrMap() [1/2]

static TVM_TIRX_DLL bool tvm::Op::HasAttrMap ( const ffi::String &  attr_name)
static

Check whether an attribute column exists, even if some Ops lack a value.

Parameters
attr_nameThe column name.
Returns
Whether the column has been registered.

◆ HasAttrMap() [2/2]

template<typename ValueType >
static bool tvm::Op::HasAttrMap ( ffi::reflection::AttrKey< ValueType >  key)
inlinestatic

Check whether the column named by a typed key exists.

◆ ListNames()

static TVM_TIRX_DLL ffi::Array< ffi::String > tvm::Op::ListNames ( )
static

List registered operator names.

Returns
Names in unspecified order.

◆ TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE()

tvm::Op::TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE ( Op  ,
Expr  ,
OpObj   
)

◆ Validate()

TVM_FFI_INLINE void tvm::Op::Validate ( const CallObj *  call) const
inline

Validate a Call with this Op's callback, when one is registered.

Friends And Related Symbol Documentation

◆ OpDef

friend class OpDef
friend

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