24 #ifndef TVM_TARGET_TARGET_H_ 25 #define TVM_TARGET_TARGET_H_ 34 #include <unordered_set> 66 TVM_DLL
const std::string&
str()
const;
84 v->Visit(
"kind", &kind);
85 v->Visit(
"tag", &tag);
86 v->Visit(
"keys", &keys);
87 v->Visit(
"attrs", &attrs);
88 v->Visit(
"features", &features);
89 v->Visit(
"host", &host);
99 template <
typename TObjectRef>
101 const std::string& attr_key,
103 static_assert(std::is_base_of<ObjectRef, TObjectRef>::value,
104 "Can only call GetAttr with ObjectRef types.");
105 auto it = attrs.
find(attr_key);
106 if (it != attrs.
end()) {
107 return Downcast<Optional<TObjectRef>>((*it).second);
109 return default_value;
119 template <
typename TObjectRef>
143 template <
typename TObjectRef>
145 const std::string& feature_key,
149 return default_value;
154 template <
typename TObjectRef>
160 TVM_DLL std::vector<std::string>
GetKeys()
const;
162 TVM_DLL std::unordered_set<std::string>
GetLibs()
const;
174 mutable std::string str_repr_;
186 TVM_DLL
explicit Target(std::nullptr_t) { data_ =
nullptr; }
191 TVM_DLL
explicit Target(
const String& tag_or_config_or_target_str);
205 TVM_DLL
static tvm::Target Current(
bool allow_not_defined =
true);
212 TVM_DLL
explicit Target(Target target, Target host);
220 static Target WithHost(
const Target& target,
const Target& host);
228 bool IsExternalCodegen()
const;
244 bool IsExternalCodegenFor(
const Target& that)
const;
258 TVM_DLL
void EnterWithScope();
263 TVM_DLL
void ExitWithScope();
285 #endif // TVM_TARGET_TARGET_H_ friend class TargetInternal
Definition: target.h:176
std::unordered_set< std::string > GetLibs() const
Get the keys for this target as an unordered_set of string.
TVM_DECLARE_FINAL_OBJECT_INFO(TargetNode, Object)
Definitions and helper macros for IR/AST nodes.
Compilation target.
Definition: target.h:46
A Reducer class to reduce the structural equality result of two objects.
Definition: structural_equal.h:124
Target(std::nullptr_t)
Construct a null Target.
Definition: target.h:186
IRModule that holds the functions and type definitions.
runtime implementation for LibTorch/TorchScript.
Definition: analyzer.h:36
A Reducer class to reduce the structural hash value.
Definition: structural_hash.h:110
PrimExpr equal(PrimExpr a, PrimExpr b, Span span=Span())
equal
Optional< Target > GetHost() const
void SHashReduce(SHashReducer hash_reduce) const
const std::string & str() const
The raw string representation of the target.
Optional< V > Get(const K &key) const
Definition: map.h:1385
bool SEqualReduce(const TargetNode *other, SEqualReducer equal) const
base class of all object containers.
Definition: object.h:167
TargetKind kind
The kind of the target device.
Definition: target.h:49
String tag
Tag of the target, can be empty.
Definition: target.h:53
Managed reference class to TargetKindNode.
Definition: target_kind.h:145
Visitor class to get the attributes of an AST/IR node. The content is going to be called for each fie...
Definition: reflection.h:52
Array, container representing a contiguous sequence of ObjectRefs.
Definition: array.h:289
Optional< TObjectRef > GetFeature(const std::string &attr_key, TObjectRef default_value) const
Definition: target.h:155
iterator find(const K &key) const
Definition: map.h:1383
String ToDebugString() const
Returns a human readable representation of Target which includes all fields, especially the host...
static constexpr const bool _type_has_method_sequal_reduce
Definition: target.h:168
Reference to string objects.
Definition: string.h:98
Optional< TObjectRef > GetAttr(const std::string &attr_key, TObjectRef default_value) const
Get an entry from attrs of the target.
Definition: target.h:120
#define TVM_DEFINE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:713
std::vector< std::string > GetKeys() const
Get the keys for this target as a vector of string.
RAII wrapper function to enter and exit a context object similar to python's with syntax...
Definition: with.h:58
Managed reference class to TargetNode.
Definition: target.h:183
Map< String, ObjectRef > attrs
Collection of attributes.
Definition: target.h:57
Array< String > keys
Keys for this target.
Definition: target.h:55
Map< String, ObjectRef > Export() const
Optional< TObjectRef > GetFeature(const std::string &feature_key, Optional< TObjectRef > default_value=Optional< TObjectRef >(nullptr)) const
Get a Target feature.
Definition: target.h:144
Base class of all object reference.
Definition: object.h:511
void VisitAttrs(AttrVisitor *v)
Definition: target.h:83
static constexpr const bool _type_has_method_shash_reduce
Definition: target.h:169
Optional< ObjectRef > host
Target host information, must be Target type.
Definition: target.h:51
iterator end() const
Definition: map.h:1381
static constexpr const char * _type_key
Definition: target.h:167
Map container of NodeRef->NodeRef in DSL graph. Map implements copy on write semantics, which means map is mutable but copy will happen when array is referenced in more than two places.
Definition: map.h:1271
Map< String, ObjectRef > features
Target features.
Definition: target.h:59
Optional container that to represent to a Nullable variant of T.
Definition: optional.h:51
int GetTargetDeviceType() const
Optional< TObjectRef > GetAttr(const std::string &attr_key, Optional< TObjectRef > default_value=Optional< TObjectRef >(nullptr)) const
Get an entry from attrs of the target.
Definition: target.h:100
RAII wrapper function to enter and exit a context object similar to python's with syntax...
void CheckAndUpdateHostConsistency(Target *target, Target *host)
Check and update host field of the given legacy target and target host pair. Note that this function ...