tvm
Public Member Functions | Static Public Member Functions | Friends | List of all members
tvm::Target Class Reference

Managed reference class to TargetNode. More...

#include <target.h>

Inheritance diagram for tvm::Target:
Collaboration diagram for tvm::Target:

Public Member Functions

 Target (std::nullptr_t)
 Construct a null Target. More...
 
 Target (const String &tag_or_config_or_target_str)
 Construct a Target given a string. More...
 
 Target (const Map< String, ObjectRef > &config)
 Construct a Target using a JSON-like configuration. More...
 
 Target (Target target, Target host)
 Construct a Target given target and host. More...
 
 TVM_DEFINE_OBJECT_REF_METHODS (Target, ObjectRef, TargetNode)
 
Target WithoutHost () const
 
bool IsExternalCodegen () const
 Returns true if this target represents an external codegen. If so, this->kind->name can be used as the "Compiler" attribute on partitioned functions, and can be used to retrieve a partitioning pattern table using get_pattern_table. More...
 
bool IsExternalCodegenFor (const Target &that) const
 Returns true if this target represents an external codegen which is compatible with that target. In particular: More...
 
- 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 tvm::Target Current (bool allow_not_defined=true)
 Get the current target context from thread local storage. More...
 
static Target WithHost (const Target &target, const Target &host)
 Create a new Target object with given target (w.o host) and target host. More...
 

Friends

class TargetInternal
 
class With< Target >
 

Additional Inherited Members

- Public Types inherited from tvm::runtime::ObjectRef
using ContainerType = Object
 type indicate the container type. More...
 
- Static Public Attributes inherited from tvm::runtime::ObjectRef
static constexpr bool _type_is_nullable = true
 
- 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 TargetNode.

See also
TargetNode

Constructor & Destructor Documentation

◆ Target() [1/4]

tvm::Target::Target ( std::nullptr_t  )
inlineexplicit

Construct a null Target.

◆ Target() [2/4]

tvm::Target::Target ( const String tag_or_config_or_target_str)
explicit

Construct a Target given a string.

Parameters
tag_or_config_or_target_strthe string to parse for target

◆ Target() [3/4]

tvm::Target::Target ( const Map< String, ObjectRef > &  config)
explicit

Construct a Target using a JSON-like configuration.

Parameters
configThe JSON-like configuration for target

◆ Target() [4/4]

tvm::Target::Target ( Target  target,
Target  host 
)
explicit

Construct a Target given target and host.

Parameters
targetThe Target typed object with host field undefined for target
hostThe Target typed object for target host

Member Function Documentation

◆ Current()

static tvm::Target tvm::Target::Current ( bool  allow_not_defined = true)
static

Get the current target context from thread local storage.

Parameters
allow_not_definedIf the context stack is empty and this is set to true, an undefined Target will be returned. Otherwise, an empty context stack will cause a runtime error.
Returns
The target that is the current context. The target may not be defined if allow_not_defined is true.

◆ IsExternalCodegen()

bool tvm::Target::IsExternalCodegen ( ) const

Returns true if this target represents an external codegen. If so, this->kind->name can be used as the "Compiler" attribute on partitioned functions, and can be used to retrieve a partitioning pattern table using get_pattern_table.

◆ IsExternalCodegenFor()

bool tvm::Target::IsExternalCodegenFor ( const Target that) const

Returns true if this target represents an external codegen which is compatible with that target. In particular:

After partitioning, the external codegen compilation path may use that to guide it's compilation to a runtime::Module. Given this, an appropriate that can be found using CompilationConfig::FindPrimitiveTargetOrFail(this->GetTargetDeviceType()).

The CollagePartition pass uses this method to guide it's search over candidate partitions using external codegen.

◆ TVM_DEFINE_OBJECT_REF_METHODS()

tvm::Target::TVM_DEFINE_OBJECT_REF_METHODS ( Target  ,
ObjectRef  ,
TargetNode   
)

◆ WithHost()

static Target tvm::Target::WithHost ( const Target target,
const Target host 
)
static

Create a new Target object with given target (w.o host) and target host.

Parameters
targetThe current Target typed object target, with or without host field.
hostThe given Target typed object target host
Returns
The new Target object with the given target and host field of given host.

◆ WithoutHost()

Target tvm::Target::WithoutHost ( ) const
Returns
The target with the host stripped out

Friends And Related Function Documentation

◆ TargetInternal

friend class TargetInternal
friend

◆ With< Target >

friend class With< Target >
friend

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