diff --git a/lite/model_parser/naive_buffer/param_desc.cc b/lite/model_parser/naive_buffer/param_desc.cc index cc97b027160706b9c848a7b0dced22ab0fbed57a..99d6552d4689e102bbfd7d95f025a9ef0fc92fcf 100644 --- a/lite/model_parser/naive_buffer/param_desc.cc +++ b/lite/model_parser/naive_buffer/param_desc.cc @@ -152,10 +152,8 @@ void ParamDesc::SetDim(const std::vector& dim) { auto& data_builder = desc_->GetField>("data"); \ auto data = data_builder.data(); \ size_t size = data_builder.size() / sizeof(T); \ - auto* data_ptr = reinterpret_cast(data); \ - for (size_t i = 0; i < size; ++i) { \ - res.push_back(data_ptr[i]); \ - } \ + res.resize(size); \ + memcpy(&res[0], data, data_builder.size()); \ return res; \ }