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

Gathers the Targets and distinguished SEScopes in canonical form needed to compile a Relay module. All centralizes any setup and validation logic needed to transition from configuration options conveyed implicitly (eg in PassContexts) or explicitly (eg a a list of Targets) to the configuration. More...

#include <compilation_config.h>

Inheritance diagram for tvm::CompilationConfigNode:
Collaboration diagram for tvm::CompilationConfigNode:

Public Member Functions

void VisitAttrs (AttrVisitor *v)
 
SEScope CanonicalSEScope (const SEScope &se_scope) const
 Returns a SEScope agreeing with se_scope on all its constrained fields, however: More...
 
- Public Member Functions inherited from tvm::runtime::Object
uint32_t type_index () const
 
std::string GetTypeKey () const
 
size_t GetTypeKeyHash () const
 
template<typename TargetType >
bool IsInstance () const
 
bool unique () const
 
 Object ()
 
 Object (const Object &other)
 
 Object (Object &&other)
 
Objectoperator= (const Object &other)
 
Objectoperator= (Object &&other)
 

Public Attributes

TargetMap legacy_target_map
 The legacy targets map, mapping device type to Targets. Does not include any entry for the host target. Intended to give a unique Target for every DLDeviceType, though we want to get rid of that limitation. More...
 
Target host_target
 The host target. Used for 'scalar' data and code (such as shapes and shape functions) and residual Relay expressions and data (such as conditionals and ADTs). More...
 
Array< Targetprimitive_targets
 Vector of all available targets for primitive operators. May contain a Target for the same device type as for the host_target, however the host_target should be preferred for all host computations and data. More...
 
SEScope default_primitive_se_scope = SEScope::FullyUnconstrained()
 SEScope for primitive operators which are not otherwise constrained to a particular device. More...
 
SEScope host_se_scope = SEScope::FullyUnconstrained()
 SEScope for the host. More...
 
Target optional_homogeneous_target
 If defined then compile and/or run in 'homogenous execution mode'. In this mode all primitives are compiled for this target only. More...
 

Static Public Attributes

static constexpr const char * _type_key = "CompilationConfig"
 
- Static Public Attributes inherited from tvm::runtime::Object
static constexpr const char * _type_key = "runtime.Object"
 
static constexpr bool _type_final = false
 
static constexpr uint32_t _type_child_slots = 0
 
static constexpr bool _type_child_slots_can_overflow = true
 
static constexpr bool _type_has_method_visit_attrs = true
 
static constexpr bool _type_has_method_sequal_reduce = false
 
static constexpr bool _type_has_method_shash_reduce = false
 
static constexpr uint32_t _type_index = TypeIndex::kDynamic
 

Friends

class CompilationConfig
 

Additional Inherited Members

- Public Types inherited from tvm::runtime::Object
typedef void(* FDeleter) (Object *self)
 Object deleter. More...
 
using RefCounterType = std::atomic< int32_t >
 
- Static Public Member Functions inherited from tvm::runtime::Object
static std::string TypeIndex2Key (uint32_t tindex)
 Get the type key of the corresponding index from runtime. More...
 
static size_t TypeIndex2KeyHash (uint32_t tindex)
 Get the type key hash of the corresponding index from runtime. More...
 
static uint32_t TypeKey2Index (const std::string &key)
 Get the type index of the corresponding key from runtime. More...
 
static uint32_t _GetOrAllocRuntimeTypeIndex ()
 
static uint32_t RuntimeTypeIndex ()
 
- Protected Member Functions inherited from tvm::runtime::Object
void IncRef ()
 developer function, increases reference counter. More...
 
void DecRef ()
 developer function, decrease reference counter. More...
 
- Static Protected Member Functions inherited from tvm::runtime::Object
static uint32_t GetOrAllocRuntimeTypeIndex (const std::string &key, uint32_t static_tindex, uint32_t parent_tindex, uint32_t type_child_slots, bool type_child_slots_can_overflow)
 Get the type index using type key. More...
 
- Protected Attributes inherited from tvm::runtime::Object
uint32_t type_index_ {0}
 Type index(tag) that indicates the type of the object. More...
 
RefCounterType ref_counter_ {0}
 The internal reference counter. More...
 
FDeleter deleter_ = nullptr
 deleter of this object to enable customized allocation. If the deleter is nullptr, no deletion will be performed. The creator of the object must always set the deleter field properly. More...
 

Detailed Description

Gathers the Targets and distinguished SEScopes in canonical form needed to compile a Relay module. All centralizes any setup and validation logic needed to transition from configuration options conveyed implicitly (eg in PassContexts) or explicitly (eg a a list of Targets) to the configuration.

CAUTION: This is subject to change as we rework compilation options in general. See https://github.com/apache/tvm-rfcs/blob/main/rfcs/0028-command-line-registry-composition.md. So far this class is only focussed on carrying just the configuration needed by PlanDevices, and removing target-munging code duplication and inconsistencies between the three major build flows for the VM (relay/backend/vm/compile.cc), Graph/AOT (relay/backend/build_module.cc) and Interpreter (relay/backend/interpreter.cc). Over time we expect more global compiler configuration (eg for executor and runtime config, for system memory pool configuration, etc) to migrate into this class, and instances thereof to be attached to IRModules using a well-known attribute.

Member Function Documentation

◆ CanonicalSEScope()

SEScope tvm::CompilationConfigNode::CanonicalSEScope ( const SEScope se_scope) const

Returns a SEScope agreeing with se_scope on all its constrained fields, however:

  • If the target is null then it is filled in from the known available primitive targets by matching on device type. Fails if no such target is known.
  • The returned object is unique for the field values w.r.t. all other SEScopes returned by this method.

We call the result the 'canonical' SEScope. Two canonical SEScopes are structurally equal if and only if they are pointer equal.

◆ VisitAttrs()

void tvm::CompilationConfigNode::VisitAttrs ( AttrVisitor v)

Friends And Related Function Documentation

◆ CompilationConfig

friend class CompilationConfig
friend

Member Data Documentation

◆ _type_key

constexpr const char* tvm::CompilationConfigNode::_type_key = "CompilationConfig"
static

◆ default_primitive_se_scope

SEScope tvm::CompilationConfigNode::default_primitive_se_scope = SEScope::FullyUnconstrained()

SEScope for primitive operators which are not otherwise constrained to a particular device.

◆ host_se_scope

SEScope tvm::CompilationConfigNode::host_se_scope = SEScope::FullyUnconstrained()

SEScope for the host.

◆ host_target

Target tvm::CompilationConfigNode::host_target

The host target. Used for 'scalar' data and code (such as shapes and shape functions) and residual Relay expressions and data (such as conditionals and ADTs).

◆ legacy_target_map

TargetMap tvm::CompilationConfigNode::legacy_target_map

The legacy targets map, mapping device type to Targets. Does not include any entry for the host target. Intended to give a unique Target for every DLDeviceType, though we want to get rid of that limitation.

CAUTION: Since keys are Integers they are compared by object equality not integer value.

TODO(mbs): Remove once codegen updated for new target conventions.

◆ optional_homogeneous_target

Target tvm::CompilationConfigNode::optional_homogeneous_target

If defined then compile and/or run in 'homogenous execution mode'. In this mode all primitives are compiled for this target only.

This is to support legacy passes which have not been adapted to hetrogeneous execution and rely on an implicit global Target to be in scope.

TODO(mbs): Remove once all passes are 'hetrogeneous aware'.

◆ primitive_targets

Array<Target> tvm::CompilationConfigNode::primitive_targets

Vector of all available targets for primitive operators. May contain a Target for the same device type as for the host_target, however the host_target should be preferred for all host computations and data.


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