Class Op#

Inheritance Relationships#

Base Type#

Class Documentation#

class Op : public tvm::Expr#

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];

Public Types

using ContainerType = OpObj#

Public Functions

inline explicit Op(ffi::ObjectPtr<OpObj> n)#

Construct a handle from a defined node.

Parameters:

n – The operator node.

inline void Validate(const CallObj *call) const#

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

inline explicit Op(::tvm::ffi::UnsafeInit tag)#
inline __PtrType operator->() const#
inline __PtrType get() const#

Public Static Functions

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

Get a typed live view of a registered attribute column.

Template Parameters:

ValueType – The attribute value type.

Parameters:

attr_name – The column name.

Throws:

InternalError – if the column has never been registered.

Returns:

A shared view that observes registration, replacement, reset, and growth.

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 bool HasAttrMap(const ffi::String &attr_name)#

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

Parameters:

attr_name – The column name.

Returns:

Whether the column has been registered.

template<typename ValueType>
static inline bool HasAttrMap(ffi::reflection::AttrKey<ValueType> key)#

Check whether the column named by a typed key exists.

static Op Get(const ffi::String &op_name)#

Look up a registered operator by name.

Parameters:

op_name – The canonical name.

Throws:

AttributeError – if the operator is not registered.

Returns:

A copy of the reference-counted handle to the canonical node.

static ffi::Array<ffi::String> ListNames()#

List registered operator names.

Returns:

Names in unspecified order.