26 #ifndef TVM_TARGET_VIRTUAL_DEVICE_H_
27 #define TVM_TARGET_VIRTUAL_DEVICE_H_
33 #include <unordered_set>
188 DLDeviceType
device_type()
const {
return static_cast<DLDeviceType
>(device_type_int); }
248 refl::ObjectDef<VirtualDeviceNode>()
249 .def_ro(
"device_type_int", &VirtualDeviceNode::device_type_int,
252 "The device id of the virtual device.", refl::DefaultValue(-1))
254 "The target describing how to compile for the virtual device.",
255 refl::DefaultValue(
Target()))
257 "The area of memory w.r.t. the virtual device where data is stored.",
258 refl::DefaultValue(
""));
308 return VirtualDevice(device.device_type, device.device_id, std::move(target));
313 DLDeviceType
device_type =
static_cast<DLDeviceType
>(target->GetTargetDeviceType());
325 return VirtualDevice(device.device_type, device.device_id, std::move(target),
326 std::move(memory_scope));
368 std::unordered_set<VirtualDevice, StructuralHash, StructuralEqual> cache_;
Adapter for AttrsNode with the new reflection API.
Definition: attrs.h:385
Base class of all attribute class.
Definition: attrs.h:102
Container of constant int that adds more constructors.
Definition: expr.h:600
Managed reference class to TargetNode.
Definition: target.h:192
A cache of VirtualDevices. This can be used:
Definition: virtual_device.h:355
VirtualDevice Unique(const VirtualDevice &virtual_device)
Returns the unique VirtualDevice structurally equal to the given virtual_device.
VirtualDevice Make(int device_type=kInvalidDeviceType, int virtual_device_id=-1, Target target={}, MemoryScope memory_scope={})
Returns the unique VirtualDevice representing given fields.
Describes at compile time the constraints on where data is to be stored at runtime down to the (virtu...
Definition: virtual_device.h:172
static void RegisterReflection()
Definition: virtual_device.h:246
DLDeviceType device_type() const
Definition: virtual_device.h:188
Target target
The Target describing how to compile for the virtual device.
Definition: virtual_device.h:205
int virtual_device_id
The device identifier for the virtual device. This must be resolved to a physical device identifier e...
Definition: virtual_device.h:196
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("target.VirtualDevice", VirtualDeviceNode, BaseAttrsNode)
MemoryScope memory_scope
The scope of memory w.r.t. the virtual device which holds data.
Definition: virtual_device.h:212
Device ToDevice() const
Returns the (virtual) Device implied by this VirtualDevice. Both the device_type and virtual_device_m...
Definition: virtual_device.h:237
bool IsFullyUnconstrained() const
Returns true if virtual device is 'fully unconstrained', ie no target/device type,...
Definition: virtual_device.h:218
bool IsFullyConstrained() const
Returns true if virtual device is 'fully constrained', ie target, device id and memory scope are all ...
Definition: virtual_device.h:227
Managed reference class to VirtualDeviceNode.
Definition: virtual_device.h:268
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(VirtualDevice, ObjectRef, VirtualDeviceNode)
VirtualDevice(int device_type_int=kInvalidDeviceType, int virtual_device_id=-1, Target target={}, MemoryScope memory_scope={})
Construct a virtual device.
static VirtualDevice ForDeviceTargetAndMemoryScope(const Device &device, Target target, MemoryScope memory_scope)
Returns the VirtualDevice for device, target and memory_scope.
Definition: virtual_device.h:323
static ffi::Optional< VirtualDevice > Join(const VirtualDevice &lhs, const VirtualDevice &rhs)
Returns the 'join' of lhs and rhs. The result will agree pointwise with lhs and rhs on all their cons...
static VirtualDevice ForMemoryScope(MemoryScope memory_scope)
Returns the VirtualDevice for memory_scope alone.
Definition: virtual_device.h:318
static VirtualDevice Default(const VirtualDevice &lhs, const VirtualDevice &rhs)
Returns the 'default' of lhs and rhs. The result will be lhs, except any unconstrained fields in lhs ...
static VirtualDevice FullyUnconstrained()
Returns the unique fully unconstrained VirtualDevice.
static VirtualDevice ForDeviceAndTarget(const Device &device, Target target)
Returns the VirtualDevice for device and target.
Definition: virtual_device.h:307
static VirtualDevice ForDevice(const Device &device)
Returns the VirtualDevice for device.
Definition: virtual_device.h:302
static VirtualDevice ForDeviceType(const Integer &device_type, int virtual_device_id=-1)
Definition: virtual_device.h:297
static VirtualDevice ForDeviceType(DLDeviceType device_type, int virtual_device_id=-1)
Returns the VirtualDevice for device_type and (if not -1) virtual_device_id. The target and memory sc...
Definition: virtual_device.h:290
static VirtualDevice ForDeviceType(int device_type, int virtual_device_id=-1)
Definition: virtual_device.h:294
static VirtualDevice ForTarget(Target target)
Returns the VirtualDevice for target.
Definition: virtual_device.h:312
Definition: repr_printer.h:91
constexpr const char * device_type
The device type.
Definition: stmt.h:1063
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37
constexpr const char * kVirtualDevice
Definition: virtual_device.h:376
constexpr int kInvalidDeviceType
Definition: virtual_device.h:55
ffi::String MemoryScope
Abstract label for an area of memory.
Definition: global_info.h:37
DLDevice Device
Definition: device_api.h:42
constexpr int kNullDeviceType
Definition: virtual_device.h:52
Compilation target object.