This is an automated email from the ASF dual-hosted git repository.

masahi pushed a commit to branch unity
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/unity by this push:
     new e67678066d [Unity][VM] Improved error message in 
CodeGenVM::EmitKillObject (#15822)
e67678066d is described below

commit e67678066d368df73358221aecdc18de9f0c0e07
Author: Eric Lunderberg <[email protected]>
AuthorDate: Thu Oct 12 23:49:28 2023 -0500

    [Unity][VM] Improved error message in CodeGenVM::EmitKillObject (#15822)
    
    * [Unity][VM] Improved error message in CodeGenVM::EmitKillObject
    
    This was implemented while debugging CI failures in
    https://github.com/apache/tvm/pull/15810, but is not otherwise related
    to the changes in that PR.
    
    * ci bump
---
 include/tvm/runtime/relax_vm/bytecode.h | 22 ++++++++++++++++++++++
 src/relax/backend/vm/codegen_vm.cc      |  5 ++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/include/tvm/runtime/relax_vm/bytecode.h 
b/include/tvm/runtime/relax_vm/bytecode.h
index fdafaac1e0..4526c6fffa 100644
--- a/include/tvm/runtime/relax_vm/bytecode.h
+++ b/include/tvm/runtime/relax_vm/bytecode.h
@@ -90,6 +90,28 @@ struct Instruction {
    * \brief The kind of instruction's argument.
    */
   enum class ArgKind : int { kRegister = 0, kImmediate = 1, kConstIdx = 2, 
kFuncIdx = 3 };
+
+  friend std::ostream& operator<<(std::ostream& os, const ArgKind& kind) {
+    switch (kind) {
+      case ArgKind::kRegister:
+        os << "kRegister";
+        break;
+      case ArgKind::kImmediate:
+        os << "kImmediate";
+        break;
+      case ArgKind::kConstIdx:
+        os << "kConstIdx";
+        break;
+      case ArgKind::kFuncIdx:
+        os << "kFuncIdx";
+        break;
+      default:
+        LOG(FATAL) << "Internal error: "
+                   << "Invalid ArgKind with integer value " << 
static_cast<int>(kind);
+    }
+    return os;
+  }
+
   /*!
    * \brief The auxiliary data structure for instruction argument.
    */
diff --git a/src/relax/backend/vm/codegen_vm.cc 
b/src/relax/backend/vm/codegen_vm.cc
index 711b2d4ba5..caee0a0c13 100644
--- a/src/relax/backend/vm/codegen_vm.cc
+++ b/src/relax/backend/vm/codegen_vm.cc
@@ -357,7 +357,10 @@ class CodeGenVM : public 
ExprFunctor<Instruction::Arg(const Expr&)> {
   RegName EmitKillObject(const Call& call_node) {
     ICHECK_EQ(call_node->args.size(), 1);
     Instruction::Arg arg = this->VisitExpr(call_node->args[0]);
-    ICHECK(arg.kind() == Instruction::ArgKind::kRegister);
+    ICHECK(arg.kind() == Instruction::ArgKind::kRegister)
+        << "Expected the object to be killed to be stored in a register, "
+        << "but argument " << call_node->args[0] << " produced VM instruction 
of type "
+        << arg.kind();
     RegName dst_reg = arg.value();
     builder_->EmitCall("vm.builtin.null_value", {}, dst_reg);
     return dst_reg;

Reply via email to