24#ifndef TVM_TARGET_TARGET_H_
25#define TVM_TARGET_TARGET_H_
27#include <tvm/ffi/reflection/registry.h>
52 ffi::Optional<ffi::ObjectRef>
host;
56 ffi::Array<ffi::String>
keys;
58 ffi::Map<ffi::String, Any>
attrs;
83 namespace refl = tvm::ffi::reflection;
84 refl::ObjectDef<TargetObj>()
99 template <
typename TObjectRef>
102 ffi::Optional<TObjectRef> default_value = ffi::Optional<TObjectRef>(std::nullopt))
const {
105 return (*it).second.as_or_throw<ffi::Optional<TObjectRef>>();
107 return default_value;
117 template <
typename TObjectRef>
127 mutable std::string str_repr_;
163 explicit Target(ffi::UnsafeInit tag, ffi::ObjectPtr<TargetObj> n) : ffi::ObjectRef(tag) {
164 data_ = std::move(n);
175 Target(
TargetKind kind, ffi::Optional<ffi::ObjectRef> host, ffi::String tag,
176 ffi::Array<ffi::String> keys, ffi::Map<ffi::String, ffi::Any> attrs);
Managed reference class to TargetKindObj.
Definition target_kind.h:88
Compilation target.
Definition target.h:45
ffi::Optional< ffi::ObjectRef > host
Target host information, must be Target type.
Definition target.h:52
static void RegisterReflection()
Definition target.h:82
TargetObj(TargetKind kind)
Definition target.h:47
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("target.Target", TargetObj, ffi::Object)
ffi::Optional< TObjectRef > GetAttr(const std::string &attr_key, TObjectRef default_value) const
Get an entry from attrs of the target.
Definition target.h:118
TargetObj(ffi::UnsafeInit tag)
Definition target.h:48
friend class TargetInternal
Definition target.h:129
TVM_TIRX_DLL int GetTargetDeviceType() const
TVM_TIRX_DLL const std::string & str() const
The JSON string representation of the target.
ffi::Array< ffi::String > keys
Keys for this target.
Definition target.h:56
ffi::String tag
Tag of the target, can be empty.
Definition target.h:54
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind
Definition target.h:122
TVM_TIRX_DLL ffi::Optional< Target > GetHost() const
TargetKind kind
The kind of the target device.
Definition target.h:50
ffi::Optional< TObjectRef > GetAttr(const std::string &attr_key, ffi::Optional< TObjectRef > default_value=ffi::Optional< TObjectRef >(std::nullopt)) const
Get an entry from attrs of the target.
Definition target.h:100
TVM_TIRX_DLL ffi::Map< ffi::String, ffi::Any > ToConfig() const
ffi::Map< ffi::String, Any > attrs
Collection of attributes (includes feature.* keys set by canonicalizer)
Definition target.h:58
TVM_TIRX_DLL bool HasKey(const std::string &query_key) const
Check if the target contains a key.
Managed reference class to TargetObj.
Definition target.h:136
TVM_TIRX_DLL Target(const ffi::Map< ffi::String, ffi::Any > &config)
Construct a Target using a JSON-like configuration.
static TVM_TIRX_DLL ffi::Optional< Target > Current(bool allow_not_defined=true)
Get the current target context from thread local storage.
static Target WithHost(const Target &target, const ffi::Optional< Target > &host)
Target(ffi::UnsafeInit tag, ffi::ObjectPtr< TargetObj > n)
Definition target.h:163
Target WithoutHost() const
TVM_TIRX_DLL Target(const ffi::String &tag_or_config_or_target_str)
Construct a Target given a string.
friend class TargetInternal
Definition target.h:179
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(Target, ffi::ObjectRef, TargetObj)
TVM_TIRX_DLL Target(Target target, ffi::Optional< Target > host)
Construct a Target given target and host.
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
Abstract device memory management API.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition attr.h:23
#define TVM_TIRX_DLL
Definition base.h:83
RAII wrapper function to enter and exit a context object similar to python's with syntax.