@@ -1080,6 +1080,16 @@ class Parser {
10801080 }
10811081 }
10821082
1083+ /* ! brief The attribute key for the virtual device. This key will be promoted to first class on
1084+ * functions and variable bindings.
1085+ *
1086+ * Type: VirtualDevice
1087+ */
1088+ // why can't this be constexpr?
1089+ // also where to put me?
1090+ // also change to just virtual_device, no result
1091+ const char * kVirtualDevice = " result_virtual_device" ;
1092+
10831093 /* ! Parse a function definition without a leading keyword or identifier.
10841094 *
10851095 * Handles things of the form [T1, ..., TN](arg1: U1, ..., argN : UN) -> Ret { body }.
@@ -1137,11 +1147,14 @@ class Parser {
11371147
11381148 // TODO(@jroesch): attributes should never be null, they should always be empty.
11391149 if (raw_attrs.size ()) {
1140- // Promote "result_virtual_device" to first-class
1141- if (raw_attrs.count (" result_virtual_device" )) {
1142- ObjectRef vid = raw_attrs.at (" result_virtual_device" );
1143- // TODO(@electriclilies): check that this is a virtaul device
1144- raw_attrs.erase (" result_virtual_device" );
1150+ // Promote kVirtualDevice to first-class
1151+ String vid_key = kVirtualDevice ;
1152+ if (raw_attrs.count (vid_key)) {
1153+ ObjectRef vid = raw_attrs.at (kVirtualDevice );
1154+ ICHECK (vid.as <VirtualDeviceNode>())
1155+ << " Expected the " << kVirtualDevice << " to have type VirtualDeviceNode, but got "
1156+ << vid->GetTypeKey ();
1157+ raw_attrs.erase (kVirtualDevice );
11451158 Function func = relay::Function (params, body, ret_type, generics, DictAttrs (raw_attrs));
11461159 func->virtual_device_ = vid;
11471160 return func;
0 commit comments