24#ifndef TVM_IR_FUNCTION_H_
25#define TVM_IR_FUNCTION_H_
27#include <tvm/ffi/container/array.h>
28#include <tvm/ffi/container/map.h>
29#include <tvm/ffi/string.h>
118 template <
typename TObjectRef>
119 ffi::Optional<TObjectRef>
GetAttr(
const std::string& attr_key,
120 ffi::Optional<TObjectRef> default_value = std::nullopt)
const {
129 template <
typename T>
130 ffi::Optional<T>
GetAttr(ffi::reflection::AttrKey<T> key,
131 ffi::Optional<
typename ffi::reflection::AttrKey<T>::ValueType>
132 default_value = std::nullopt)
const {
136 template <
typename T>
137 ffi::Optional<T>
GetAttr(ffi::reflection::AttrKey<T> key,
138 typename ffi::reflection::AttrKey<T>::ValueType default_value)
const {
139 return GetAttr(key, ffi::Optional<T>(std::move(default_value)));
143 template <
typename TObjectRef>
144 ffi::Optional<TObjectRef>
GetAttr(
const std::string& attr_key, TObjectRef default_value)
const {
145 return GetAttr<TObjectRef>(attr_key, ffi::Optional<TObjectRef>(default_value));
190 namespace refl = tvm::ffi::reflection;
204 explicit BaseFunc(ffi::ObjectPtr<BaseFuncObj> node) :
Expr(std::move(node)) {}
220inline constexpr ffi::reflection::AttrKey<bool>
kDeclaration{
"declaration"};
229inline constexpr ffi::reflection::AttrKey<CallingConv>
kCallingConv{
"calling_conv"};
238inline constexpr ffi::reflection::AttrKey<Target>
kTarget{
"target"};
259inline constexpr ffi::reflection::AttrKey<ffi::String>
kGlobalSymbol{
"global_symbol"};
267inline constexpr ffi::reflection::AttrKey<ffi::String>
kScriptNamespace{
"script.namespace"};
Helpers for attribute objects.
Base node of all functions.
Definition function.h:94
LinkageType GetLinkageType() const
Get the type of the linkage.
Definition function.h:271
ffi::Optional< T > GetAttr(ffi::reflection::AttrKey< T > key, ffi::Optional< typename ffi::reflection::AttrKey< T >::ValueType > default_value=std::nullopt) const
Get an attribute with its value type deduced only from the key.
Definition function.h:130
DictAttrs attrs
Additional attributes storing the meta-data.
Definition function.h:97
ffi::Optional< TObjectRef > GetAttr(const std::string &attr_key, TObjectRef default_value) const
Definition function.h:144
static constexpr const uint32_t _type_child_slots
Definition function.h:194
TVM_FFI_DECLARE_OBJECT_INFO("ir.BaseFunc", BaseFuncObj, ExprObj)
ffi::Optional< T > GetAttr(ffi::reflection::AttrKey< T > key, typename ffi::reflection::AttrKey< T >::ValueType default_value) const
Accept a default convertible to the key's value type.
Definition function.h:137
static void RegisterReflection()
Definition function.h:189
ffi::Optional< TObjectRef > GetAttr(const std::string &attr_key, ffi::Optional< TObjectRef > default_value=std::nullopt) const
Get a function attribute.
Definition function.h:119
bool HasNonzeroAttr(const std::string &attr_key) const
Check whether the function has an non-zero integer attr.
Definition function.h:167
Managed reference to BaseFuncObj.
Definition function.h:202
BaseFunc(ffi::ObjectPtr< BaseFuncObj > node)
Definition function.h:204
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(BaseFunc, Expr, BaseFuncObj)
Managed reference to DictAttrsObj.
Definition attrs.h:108
ffi::Optional< TObjectRef > GetAttr(const std::string &attr_key, ffi::Optional< TObjectRef > default_value=ffi::Optional< TObjectRef >(std::nullopt)) const
Get a function attribute.
Definition attrs.h:171
bool HasNonzeroAttr(const std::string &attr_key) const
Check whether the function has an non-zero integer attr.
Definition attrs.h:225
Base type of all the expressions.
Definition expr.h:66
Managed reference to ExprObj.
Definition expr.h:101
constexpr ffi::reflection::AttrKey< bool > kDeclaration
Whether this function is a declaration.
Definition function.h:220
constexpr ffi::reflection::AttrKey< CallingConv > kCallingConv
Indicates the special calling convention.
Definition function.h:229
constexpr ffi::reflection::AttrKey< ffi::String > kScriptNamespace
Script namespace used to select construction, printing, and dialect lowering. Absent metadata selects...
Definition function.h:267
constexpr ffi::reflection::AttrKey< ffi::String > kGlobalSymbol
Global linker symbol of the function in generated code.
Definition function.h:259
constexpr ffi::reflection::AttrKey< Target > kTarget
Compilation target of the function.
Definition function.h:238
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41
CallingConv
Possible Calling conventions.
Definition function.h:46
@ kDefault
Default calling convention.
@ kCPackedFunc
ffi::Function that exposes a Cffi::Function signature.
@ kDeviceKernelLaunch
Device kernel launch.
LinkageType
Supported linkage types.
Definition function.h:73
@ kExternal
External linkage.
@ kInternal
Internal linkage.