tvm
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | 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< OpNode > n)
 Construct a handle from a defined node.
 
TVM_FFI_INLINE void Validate (const CallNode *call) const
 Validate a Call with this Op's callback, when one is registered.
 
 TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE (Op, Expr, OpNode)
 
- 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< ExprNode > node)
 
 TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE (Expr, ffi::ObjectRef, ExprNode)
 

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.
 
static TVM_TIRX_DLL bool HasAttrMap (const ffi::String &attr_name)
 Check whether an attribute column exists, even if some Ops lack a value.
 
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.
 

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.

TVM_FFI_STATIC_INIT_BLOCK() {
OpDef("example.identity", "Return the input expression.")
.signature(sig::arg("value", "The input expression."))
.set_attr<bool>("FPurity", true);
}
// Copies the handle; the canonical node is shared.
Op op = Op::Get("example.identity");
bool pure = Op::GetAttrMap<bool>("FPurity")[op];
Noncopyable temporary builder for a canonical Op; see Op for the example.
Definition op.h:440
OpDef & set_attr(const ffi::String &attr_name, const ValueType &value, bool override=false)
Register an extensible attribute, rejecting duplicates unless overridden.
Definition op.h:540
OpDef & signature(const Specs &... specs)
Register a complete typed Call signature and its validator.
Definition op.h:514
Reference-counted handle to a canonical named operator.
Definition op.h:147
static TVM_TIRX_DLL Op Get(const ffi::String &op_name)
Look up a registered operator by name.

Constructor & Destructor Documentation

◆ Op()

tvm::Op::Op ( ffi::ObjectPtr< OpNode >  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()

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.

◆ HasAttrMap()

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.

◆ 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  ,
OpNode   
)

◆ Validate()

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

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


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