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

expye 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 b99f34d56a [Unity] Support float in vm executable (#15608)
b99f34d56a is described below

commit b99f34d56a46e17b9ef902a54332174debaed694
Author: Yaxing Cai <[email protected]>
AuthorDate: Wed Aug 23 02:45:55 2023 -0700

    [Unity] Support float in vm executable (#15608)
    
    This PR adds the support for `float` in vm executable.
    
    Co-authored-by: Ubuntu <[email protected]>
---
 src/runtime/relax_vm/executable.cc | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/runtime/relax_vm/executable.cc 
b/src/runtime/relax_vm/executable.cc
index 6ac5b56f37..0a77140469 100644
--- a/src/runtime/relax_vm/executable.cc
+++ b/src/runtime/relax_vm/executable.cc
@@ -45,6 +45,7 @@ enum ConstantType : int {
   kShapeTuple = 2,
   kString = 3,
   kInt = 4,
+  kFloat = 5,
 };
 
 #define STREAM_CHECK(val, section)                                          \
@@ -312,6 +313,9 @@ void Executable::SaveConstantSection(dmlc::Stream* strm) {
     } else if (it.type_code() == kDLInt) {
       strm->Write(ConstantType::kInt);
       strm->Write(it.value());
+    } else if (it.type_code() == kDLFloat) {
+      strm->Write(ConstantType::kFloat);
+      strm->Write(it.value());
     } else {
       try {
         strm->Write(ConstantType::kDLDataType);
@@ -385,6 +389,12 @@ void Executable::LoadConstantSection(dmlc::Stream* strm) {
       TVMRetValue cell;
       cell = value;
       this->constants.push_back(cell);
+    } else if (constant_type == ConstantType::kFloat) {
+      double value;
+      strm->Read(&value);
+      TVMRetValue cell;
+      cell = value;
+      this->constants.push_back(cell);
     } else {
       LOG(FATAL) << "Constant pool can only contain NDArray and DLDataType, 
but got "
                  << ArgTypeCode2Str(constant_type) << " when loading the VM 
constant pool.";

Reply via email to