Fix CPU memory leak due to external weights not getting memory unmapped when using non-CPU EP. (#15040)

This commit is contained in:
Pranav Sharma 2023-03-16 08:01:46 -07:00 committed by GitHub
parent 1e7849c2c8
commit 6600fd792a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -161,9 +161,11 @@ static common::Status DeserializeTensorProto(const Env& env, const std::basic_st
}
OrtCallback ext_data_deleter;
std::optional<ScopedOrtCallbackInvoker> scoped_ort_callback_invoker;
if (utils::HasExternalData(tensor_proto)) {
ORT_RETURN_IF_ERROR(ExtDataTensorProtoToTensor(env, proto_path, tensor_proto, *p_deserialize_tensor,
ext_data_deleter));
scoped_ort_callback_invoker = ScopedOrtCallbackInvoker(ext_data_deleter);
} else {
ORT_RETURN_IF_ERROR(utils::TensorProtoToTensor(env, proto_path.c_str(), tensor_proto, *p_deserialize_tensor));
}