You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/10/30 02:14:05 UTC

[GitHub] [incubator-tvm] wweic commented on a change in pull request #6798: [Relay][VM] Add support for references.

wweic commented on a change in pull request #6798:
URL: https://github.com/apache/incubator-tvm/pull/6798#discussion_r514708170



##########
File path: src/runtime/vm/vm.cc
##########
@@ -595,6 +601,29 @@ void VirtualMachine::RunLoop() {
         pc_++;
         goto main_loop;
       }
+      case Opcode::RefRead: {
+        ADT ref = Downcast<ADT>(ReadRegister(instr.ref_read.ref));
+        WriteRegister(instr.dst, ref[0]);
+        pc_++;
+        goto main_loop;
+      }
+      case Opcode::RefWrite: {
+        ADT ref = Downcast<ADT>(ReadRegister(instr.ref_write.ref));
+        ObjectRef value = ReadRegister(instr.ref_write.value);
+        // Not sure about this being best way to implement mutable thing.
+        ADTObj* mut_array = const_cast<ADTObj*>(ref.as<ADTObj>());
+        ObjectRef& inner_value = (*mut_array)[0];
+        inner_value = value;
+        pc_++;
+        goto main_loop;
+      }
+      case Opcode::RefCreate: {
+        auto value = ReadRegister(instr.ref_create.initial_value);
+        auto ref = ADT(111, {value});

Review comment:
       How we do ensure this tag does not collide with other ADT's tag number?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org