tvm
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
tvm::IRModule Class Reference

Managed reference class to IRModuleNode. More...

#include <module.h>

Inheritance diagram for tvm::IRModule:
Collaboration diagram for tvm::IRModule:

Public Types

using ContainerType = IRModuleNode
 Declare the container type. More...
 
- Public Types inherited from tvm::runtime::ObjectRef
using ContainerType = Object
 type indicate the container type. More...
 

Public Member Functions

 IRModule (Map< GlobalVar, BaseFunc > functions, Map< GlobalTypeVar, TypeData > type_definitions={}, std::unordered_set< String > import_set={}, SourceMap map={}, DictAttrs attrs=DictAttrs(), Map< String, Array< GlobalInfo >> global_infos={})
 constructor More...
 
 IRModule ()
 default constructor More...
 
 IRModule (ObjectPtr< Object > n)
 constructor More...
 
IRModuleNodeoperator-> () const
 
IRModule ShallowCopyIRModule (IRModule mod)
 Create a shallow copy of an IRModule. More...
 
 TVM_DEFINE_OBJECT_REF_COW_METHOD (IRModuleNode)
 
- Public Member Functions inherited from tvm::runtime::ObjectRef
 ObjectRef ()=default
 default constructor More...
 
 ObjectRef (ObjectPtr< Object > data)
 Constructor from existing object ptr. More...
 
bool same_as (const ObjectRef &other) const
 Comparator. More...
 
bool operator== (const ObjectRef &other) const
 Comparator. More...
 
bool operator!= (const ObjectRef &other) const
 Comparator. More...
 
bool operator< (const ObjectRef &other) const
 Comparator. More...
 
bool defined () const
 
const Objectget () const
 
const Objectoperator-> () const
 
bool unique () const
 
int use_count () const
 
template<typename ObjectType , typename = std::enable_if_t<std::is_base_of_v<Object, ObjectType>>>
const ObjectType * as () const
 Try to downcast the internal Object to a raw pointer of a corresponding type. More...
 
template<typename ObjectRefType , typename = std::enable_if_t<std::is_base_of_v<ObjectRef, ObjectRefType>>>
Optional< ObjectRefType > as () const
 Try to downcast the ObjectRef to a Optional<T> of the requested type. More...
 

Static Public Member Functions

static std::pair< IRModule, GlobalVarFromExprInContext (const RelayExpr &expr, const Map< GlobalVar, BaseFunc > &global_funcs={}, const Map< GlobalTypeVar, TypeData > &type_definitions={}, std::unordered_set< String > import_set={})
 Constructs a module from a standalone expression expr. More...
 
static IRModule FromExpr (const RelayExpr &expr, const Map< GlobalVar, BaseFunc > &global_funcs={}, const Map< GlobalTypeVar, TypeData > &type_definitions={})
 As for FromExprInContext, but assuming expr is bound to 'main' and no imports. More...
 
static IRModule FromText (const String &text, const String &source_path)
 Parse text format source file into an IRModule. More...
 

Static Public Attributes

static constexpr bool _type_is_nullable = false
 Declare whether Ref is nullable. More...
 
- Static Public Attributes inherited from tvm::runtime::ObjectRef
static constexpr bool _type_is_nullable = true
 

Additional Inherited Members

- Protected Member Functions inherited from tvm::runtime::ObjectRef
Objectget_mutable () const
 
- Static Protected Member Functions inherited from tvm::runtime::ObjectRef
template<typename T >
static T DowncastNoCheck (ObjectRef ref)
 Internal helper function downcast a ref without check. More...
 
static void FFIClearAfterMove (ObjectRef *ref)
 Clear the object ref data field without DecRef after we successfully moved the field. More...
 
template<typename ObjectType >
static ObjectPtr< ObjectType > GetDataPtr (const ObjectRef &ref)
 Internal helper function get data_ as ObjectPtr of ObjectType. More...
 
- Protected Attributes inherited from tvm::runtime::ObjectRef
ObjectPtr< Objectdata_
 Internal pointer that backs the reference. More...
 

Detailed Description

Managed reference class to IRModuleNode.

See also
IRModuleNode

Member Typedef Documentation

◆ ContainerType

Declare the container type.

Constructor & Destructor Documentation

◆ IRModule() [1/3]

tvm::IRModule::IRModule ( Map< GlobalVar, BaseFunc functions,
Map< GlobalTypeVar, TypeData type_definitions = {},
std::unordered_set< String import_set = {},
SourceMap  map = {},
DictAttrs  attrs = DictAttrs(),
Map< String, Array< GlobalInfo >>  global_infos = {} 
)
explicit

constructor

Parameters
functionsFunctions in the module.
type_definitionsType definitions in the module.
import_setSet of imported files in the module.
mapThe module source map.
attrsThe module meta-data attributes.
global_infosGlobal infos in the module.

◆ IRModule() [2/3]

tvm::IRModule::IRModule ( )
inline

default constructor

◆ IRModule() [3/3]

tvm::IRModule::IRModule ( ObjectPtr< Object n)
inlineexplicit

constructor

Parameters
nThe object pointer.

Member Function Documentation

◆ FromExpr()

static IRModule tvm::IRModule::FromExpr ( const RelayExpr expr,
const Map< GlobalVar, BaseFunc > &  global_funcs = {},
const Map< GlobalTypeVar, TypeData > &  type_definitions = {} 
)
static

As for FromExprInContext, but assuming expr is bound to 'main' and no imports.

◆ FromExprInContext()

static std::pair<IRModule, GlobalVar> tvm::IRModule::FromExprInContext ( const RelayExpr expr,
const Map< GlobalVar, BaseFunc > &  global_funcs = {},
const Map< GlobalTypeVar, TypeData > &  type_definitions = {},
std::unordered_set< String import_set = {} 
)
static

Constructs a module from a standalone expression expr.

If expr is a function it will be bound directly. Otherwise a function over the free variables of expr (possibly none) with expr as body is created and bound.

The function is bound to, in preference order:

  • The "global_symbol" attribute of expr, if it is a function with that attribute.
  • 'main'
  • A unique name derived from 'main' if 'main' is already bound in global_funcs.

Additional global functions and type definitions may be included in the result module.

See also FromExpr.

Parameters
exprThe expression to set as the main function to the module.
global_funcsThe global function map. Default empty.
type_definitionsThe global type definition map. Default empty.
import_setSet of external modules already imported. Default empty.
Returns
A module with expr set as the main function, and the global var to which expr was bound (typcially 'main').

TODO(mbs): Does import_set and the bound global var need to be exposed via ffi?

◆ FromText()

static IRModule tvm::IRModule::FromText ( const String text,
const String source_path 
)
static

Parse text format source file into an IRModule.

Parameters
textA string of Relay source code.
source_pathThe path to the source file.
Returns
A Relay module.

◆ operator->()

IRModuleNode* tvm::IRModule::operator-> ( ) const
inline
Returns
mutable pointers to the node.

◆ ShallowCopyIRModule()

IRModule tvm::IRModule::ShallowCopyIRModule ( IRModule  mod)

Create a shallow copy of an IRModule.

Parameters
modThe module to copy.
Returns
The copied module.

◆ TVM_DEFINE_OBJECT_REF_COW_METHOD()

tvm::IRModule::TVM_DEFINE_OBJECT_REF_COW_METHOD ( IRModuleNode  )

Member Data Documentation

◆ _type_is_nullable

constexpr bool tvm::IRModule::_type_is_nullable = false
staticconstexpr

Declare whether Ref is nullable.


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