!33996 [MS][LITE] fix copy fp64 tensordata from tensorinfo

Merge pull request !33996 from luoyuan/fix-copy-fp64-tensor
This commit is contained in:
i-robot 2022-05-07 08:16:26 +00:00 committed by Gitee
commit 43eff2b0a7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 2 additions and 2 deletions

View File

@ -221,9 +221,9 @@ int CopyTensorDataFromTensorInfo(const tensor::TensorPtr &tensor_info,
}
auto *origin_data = reinterpret_cast<double_t *>(tensor_info->data_c());
for (size_t i = 0; i < data_count; ++i) {
if (origin_data[i] > static_cast<double_t>(FLT_MAX) || origin_data[i] < static_cast<double_t>(FLT_MIN)) {
if (origin_data[i] > static_cast<double_t>(FLT_MAX) || origin_data[i] < static_cast<double_t>(-FLT_MAX)) {
MS_LOG(WARNING) << "float64 data " << origin_data[i] << " cannot fit into float32";
tensor_data[i] = origin_data[i] > 0 ? FLT_MAX : FLT_MIN;
tensor_data[i] = origin_data[i] > 0 ? FLT_MAX : -FLT_MAX;
} else {
tensor_data[i] = static_cast<float>(origin_data[i]);
}