From 03abcb06406f1014ab902833ccb91b402589e25d Mon Sep 17 00:00:00 2001 From: Chih-Hsuan Yen Date: Wed, 1 Jun 2022 15:03:11 +0800 Subject: [PATCH] Correctly unpack tensor values (#11639) This change fixes two issues: * protobuf 3.20 incompatibility * Potential incorrect results on big-endian machines --- onnxruntime/core/framework/tensorprotoutils.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxruntime/core/framework/tensorprotoutils.cc b/onnxruntime/core/framework/tensorprotoutils.cc index 085c1ffbe2..3de3f84b23 100644 --- a/onnxruntime/core/framework/tensorprotoutils.cc +++ b/onnxruntime/core/framework/tensorprotoutils.cc @@ -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(data_iter); \ + *p_data++ = static_cast(*data_iter); \ return Status::OK(); \ }