Class BaseFuncObj#
Defined in File function.h
Inheritance Relationships#
Base Type#
public tvm::ExprObj(Class ExprObj)
Derived Type#
public tvm::tirx::FunctionObj(Class FunctionObj)
Class Documentation#
-
class BaseFuncObj : public tvm::ExprObj#
Base node of all functions.
We support several variants of functions throughout the stack. All of the functions share the same type system to support cross variant calls.
See also
Subclassed by tvm::tirx::FunctionObj
Public Functions
-
template<typename TObjectRef>
inline ffi::Optional<TObjectRef> GetAttr(const std::string &attr_key, ffi::Optional<TObjectRef> default_value = std::nullopt) const# Get a function attribute.
void GetAttrExample(const BaseFunc& f) { auto value = f->GetAttr<int64_t>("AttrKey", 0); }
- Parameters:
attr_key – The attribute key.
default_value – The default value if the key does not exist, defaults to nullptr.
- Template Parameters:
TOBjectRef – the expected object type.
- Throws:
Error – if the key exists but the value does not match TObjectRef
- Returns:
The result
-
template<typename T>
inline 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.
- Parameters:
key – The typed attribute key.
default_value – Value returned only when the key is absent.
- Returns:
The attribute or default, with the same conversions as the name-based getter.
-
template<typename T>
inline 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.
-
template<typename TObjectRef>
inline ffi::Optional<TObjectRef> GetAttr(const std::string &attr_key, TObjectRef default_value) const#
-
inline bool HasNonzeroAttr(const std::string &attr_key) const#
Check whether the function has an non-zero integer attr.
This function can be used to check whether an optional attribute mark(e.g. inline) exists.
void HasNonzeroAttrExample(const BaseFunc& f) { if (f->HasNonzeroAttr(attr::kInline)) { // inline the function. } }
- Parameters:
attr_key – The key to the attribute.
- Returns:
The check result.
-
inline LinkageType GetLinkageType() const#
Get the type of the linkage.
Currently, we only consider external/internal linkage. This can be extended in the future when necessary.
void Example(const BaseFunc& f) { if (f->GetLinkageType() == tvm::LinkageType::kExternal) { // Do not remove a function with external linkage } }
- Returns:
Linkage type.
-
template<typename TObjectRef>