Correctly unpack tensor values (#11639)

This change fixes two issues:

* protobuf 3.20 incompatibility
* Potential incorrect results on big-endian machines
This commit is contained in:
Chih-Hsuan Yen 2022-06-01 15:03:11 +08:00 committed by GitHub
parent 2ac3649752
commit 03abcb0640
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -256,7 +256,7 @@ Status UnpackTensor(const ONNX_NAMESPACE::TensorProto& tensor, const void* raw_d
") does not match the data size(", tensor.field_size(), ") in proto"); \
auto& data = tensor.field_name(); \
for (auto data_iter = data.cbegin(); data_iter != data.cend(); ++data_iter) \
*p_data++ = *reinterpret_cast<const T*>(data_iter); \
*p_data++ = static_cast<T>(*data_iter); \
return Status::OK(); \
}