|
tvm
|
IRModule that holds functions and type definitions. More...
#include <module.h>
Public Member Functions | |
| template<typename TObjectRef > | |
| ffi::Optional< TObjectRef > | GetAttr (const std::string &attr_key, ffi::Optional< TObjectRef > default_value=ffi::Optional< TObjectRef >(std::nullopt)) const |
| Get a module attribute. | |
| template<typename T > | |
| 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. | |
| template<typename T > | |
| 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 > | |
| ffi::Optional< TObjectRef > | GetAttr (const std::string &attr_key, TObjectRef default_value) const |
| DictAttrs | GetAttrs () const |
| Get the metadata attributes. | |
| bool | HasNonzeroAttr (const std::string &attr_key) const |
| Check whether the module has an non-zero integer attr. | |
| IRModuleObj ()=default | |
| TVM_TIRX_DLL bool | SEqual (const IRModuleObj *other, ffi::TypedFunction< bool(AnyView, AnyView, bool, AnyView)> equal) const |
| TVM_TIRX_DLL int64_t | SHash (int64_t init_hash, ffi::TypedFunction< int64_t(AnyView, int64_t, bool)> hash) const |
| void | Add (const GlobalVar &var, const BaseFunc &func, bool update=false) |
| Add a function to the global environment. | |
| TVM_TIRX_DLL void | AddUnchecked (const GlobalVar &var, const BaseFunc &func) |
| Add a function to the global environment. | |
| void | Update (const GlobalVar &var, const BaseFunc &func) |
| Update a function in the global environment. | |
| void | UpdateGlobalInfo (const ffi::String &name, const ffi::Array< GlobalInfo > &info) |
| Update an array of global infos in the global environment. | |
| void | Remove (const GlobalVar &var) |
| Remove a function from the global environment. | |
| bool | ContainGlobalVar (const ffi::String &name) const |
| Check if the global_var_map_ contains a global variable. | |
| TVM_TIRX_DLL GlobalVar | GetGlobalVar (const ffi::String &str) const |
| Lookup a global function by its variable. | |
| TVM_TIRX_DLL ffi::Array< GlobalVar > | GetGlobalVars () const |
| Collect all global vars defined in this module, ordered by the global variable name. | |
| BaseFunc | Lookup (const GlobalVar &var) const |
| Look up a global function by its variable. | |
| BaseFunc | Lookup (const ffi::String &name) const |
| Look up a global function by its string name. | |
| void | Update (const IRModule &other) |
| Update the functions inside this environment by functions in another environment. | |
| IRModule | ShallowCopy () |
| Create a shallow copy of this IRModule. | |
| TVM_FFI_DECLARE_OBJECT_INFO_FINAL ("ir.IRModule", IRModuleObj, ffi::Object) | |
Static Public Member Functions | |
| static void | RegisterReflection () |
Public Attributes | |
| ffi::Map< GlobalVar, BaseFunc > | functions |
| A map from ids to all global functions. | |
| DictAttrs | attrs |
| ffi::Map< ffi::String, ffi::Array< GlobalInfo > > | global_infos |
| Globally static object that are referred by the IR itself. | |
| ffi::Map< ffi::String, GlobalVar > | global_var_map_ |
| A map from string names to global variables that ensures global uniqueness. | |
Static Public Attributes | |
| static constexpr TVMFFISEqHashKind | _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode |
| static constexpr bool | _type_mutable = true |
Friends | |
| class | IRModule |
| The IRModule declaration statement. | |
IRModule that holds functions and type definitions.
IRModule is the basic unit for all IR transformations across the stack.
Many operations require access to the global IRModule. We pass the IRModule by value in a functional style as an explicit argument, but we mutate the Module while optimizing programs.
|
default |
|
inline |
Add a function to the global environment.
| var | The var of the global function. |
| func | The function. |
| update | Controls whether you can replace a definition in the environment. |
| TVM_TIRX_DLL void tvm::IRModuleObj::AddUnchecked | ( | const GlobalVar & | var, |
| const BaseFunc & | func | ||
| ) |
Add a function to the global environment.
| var | The name of the global function. |
| func | The function. |
It does not do type inference as Add does.
|
inline |
Check if the global_var_map_ contains a global variable.
| name | The variable name. |
|
inline |
Get a module attribute.
| attr_key | The attribute key. |
| default_value | The default value if the key does not exist, defaults to nullptr. |
| TObjectRef | the expected object type. |
| Error | if the key exists but the value does not match TObjectRef |
|
inline |
|
inline |
Get an attribute with its value type deduced only from the key.
| key | The typed attribute key. |
| default_value | Value returned only when the key is absent. |
|
inline |
Accept a default convertible to the key's value type.
|
inline |
Get the metadata attributes.
| TVM_TIRX_DLL GlobalVar tvm::IRModuleObj::GetGlobalVar | ( | const ffi::String & | str | ) | const |
Lookup a global function by its variable.
| str | The unique string specifying the global variable. |
| TVM_TIRX_DLL ffi::Array< GlobalVar > tvm::IRModuleObj::GetGlobalVars | ( | ) | const |
Collect all global vars defined in this module, ordered by the global variable name.
|
inline |
Check whether the module has an non-zero integer attr.
This function can be used to check whether an optional attribute mark(e.g. inline) exists.
| attr_key | The key to the attribute. |
|
inline |
Look up a global function by its string name.
| name | The name of the function. |
Look up a global function by its variable.
| var | The global var to lookup. |
|
inlinestatic |
|
inline |
Remove a function from the global environment.
| var | The name of the global function to update. |
| TVM_TIRX_DLL bool tvm::IRModuleObj::SEqual | ( | const IRModuleObj * | other, |
| ffi::TypedFunction< bool(AnyView, AnyView, bool, AnyView)> | equal | ||
| ) | const |
|
inline |
| TVM_TIRX_DLL int64_t tvm::IRModuleObj::SHash | ( | int64_t | init_hash, |
| ffi::TypedFunction< int64_t(AnyView, int64_t, bool)> | hash | ||
| ) | const |
| tvm::IRModuleObj::TVM_FFI_DECLARE_OBJECT_INFO_FINAL | ( | "ir.IRModule" | , |
| IRModuleObj | , | ||
| ffi::Object | |||
| ) |
Update a function in the global environment.
| var | The name of the global function to update. |
| func | The new function. |
|
inline |
Update the functions inside this environment by functions in another environment.
| other | The other environment. |
|
inline |
Update an array of global infos in the global environment.
| name | The name of the global info. |
| info | The new array of global infos. |
|
staticconstexpr |
|
staticconstexpr |
| DictAttrs tvm::IRModuleObj::attrs |
| ffi::Map<ffi::String, ffi::Array<GlobalInfo> > tvm::IRModuleObj::global_infos |
Globally static object that are referred by the IR itself.
| ffi::Map<ffi::String, GlobalVar> tvm::IRModuleObj::global_var_map_ |
A map from string names to global variables that ensures global uniqueness.