@@ -44,6 +44,16 @@ namespace tvm {
4444 */
4545using MemoryScope = String;
4646
47+ // NOTE: cannot use enum as they are out of bound of the original enum
48+ // and results in an undefined behavior
49+ // A 'null' device type, does not correspond to any DLDeviceType enum.
50+ // TODO(mbs): This is to help us as we transition away from representing the 'homogenous' case
51+ // as a singleton target map indexed by the invalid DLDeviceType '0'.
52+ constexpr int kNullDeviceType = 0 ;
53+
54+ // An 'invalid' device type, does not correspond to any DLDeviceType enum.
55+ constexpr int kInvalidDeviceType = -1 ;
56+
4757/* !
4858 * \brief Describes at compile time the constraints on where data is to be stored at runtime
4959 * down to the (virtual) device and memory scope level, and how to compile code to compute that
@@ -229,7 +239,7 @@ class VirtualDeviceNode : public AttrsNode<VirtualDeviceNode> {
229239 * Physical Devices" above.
230240 */
231241 Device ToDevice () const {
232- ICHECK (device_type () != kInvalidDeviceType );
242+ ICHECK (device_type_int != kInvalidDeviceType );
233243 ICHECK (virtual_device_id != -1 );
234244 Device device;
235245 device.device_type = device_type ();
@@ -262,7 +272,7 @@ class VirtualDevice : public ObjectRef {
262272 public:
263273 /* !
264274 * \brief Construct a virtual device.
265- * \param device_type The device type for the virtual device, or \p kInvalidDeviceType if
275+ * \param device_type_int The device type for the virtual device, or \p kInvalidDeviceType if
266276 * unconstrained. If \p target is defined then must match its \p target->GetTargetDeviceType().
267277 * \param virtual_device_id The device id for the virtual device, or -1 if unconstrained.
268278 * \param target The target describing how to compile for the virtual device, or null if
@@ -271,7 +281,7 @@ class VirtualDevice : public ObjectRef {
271281 * unconstrained.
272282 * \return The virtual device.
273283 */
274- explicit VirtualDevice (DLDeviceType device_type = kInvalidDeviceType , int virtual_device_id = -1 ,
284+ explicit VirtualDevice (int device_type_int = kInvalidDeviceType , int virtual_device_id = -1 ,
275285 Target target = {}, MemoryScope memory_scope = {});
276286
277287 /* ! \brief Returns the unique fully unconstrained \p VirtualDevice. */
@@ -349,7 +359,7 @@ class VirtualDevice : public ObjectRef {
349359class VirtualDeviceCache {
350360 public:
351361 /* ! \brief Returns the unique \p VirtualDevice representing given fields. */
352- VirtualDevice Make (DLDeviceType device_type = kInvalidDeviceType , int virtual_device_id = -1 ,
362+ VirtualDevice Make (int device_type = kInvalidDeviceType , int virtual_device_id = -1 ,
353363 Target target = {}, MemoryScope memory_scope = {});
354364
355365 /* !
0 commit comments