Skip to content

Commit

Permalink
[Unity] Support float in vm executable (#15608)
Browse files Browse the repository at this point in the history
This PR adds the support for `float` in vm executable.

Co-authored-by: Ubuntu <ubuntu@ubuntu.com>
  • Loading branch information
cyx-6 and Ubuntu authored Aug 23, 2023
1 parent b365848 commit b99f34d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/runtime/relax_vm/executable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ enum ConstantType : int {
kShapeTuple = 2,
kString = 3,
kInt = 4,
kFloat = 5,
};

#define STREAM_CHECK(val, section) \
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.";
Expand Down

0 comments on commit b99f34d

Please sign in to comment.