From d652b1fe48d1b9874575646a7680aab1e490ec0a Mon Sep 17 00:00:00 2001 From: BoarQing Date: Mon, 6 Nov 2023 23:16:17 +0800 Subject: [PATCH] [VitisAI] fix tensor has multi data type (#18188) ### Description When take a tensor's data as raw, clear data with other types within the tensor. ### Motivation and Context One model's graph transformation caused a node with multiple data types. This would make the model valid. --- onnxruntime/core/providers/vitisai/imp/tensor_proto.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/onnxruntime/core/providers/vitisai/imp/tensor_proto.cc b/onnxruntime/core/providers/vitisai/imp/tensor_proto.cc index 6ee148bc6a..db03354bf4 100644 --- a/onnxruntime/core/providers/vitisai/imp/tensor_proto.cc +++ b/onnxruntime/core/providers/vitisai/imp/tensor_proto.cc @@ -16,6 +16,12 @@ gsl::span tensor_proto_as_raw( std::vector unpacked_tensor; auto s = onnxruntime::utils::UnpackInitializerData(tensor, onnxruntime::Path(), unpacked_tensor); mut_tensor.mutable_raw_data()->resize(unpacked_tensor.size()); + mut_tensor.clear_float_data(); + mut_tensor.clear_int32_data(); + mut_tensor.clear_string_data(); + mut_tensor.clear_int64_data(); + mut_tensor.clear_double_data(); + mut_tensor.clear_uint64_data(); memcpy(mut_tensor.mutable_raw_data()->data(), unpacked_tensor.data(), unpacked_tensor.size()); } return gsl::span(tensor.raw_data().data(), tensor.raw_data().size());