From 89317c63b2e57868597a09ed440102ea0bb39ad8 Mon Sep 17 00:00:00 2001 From: wejoncy Date: Mon, 16 Dec 2024 19:03:32 +0800 Subject: [PATCH] check cache-key --- .../core/providers/coreml/coreml_execution_provider.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/onnxruntime/core/providers/coreml/coreml_execution_provider.cc b/onnxruntime/core/providers/coreml/coreml_execution_provider.cc index ee1f39e5723d5..847e6f6fae87b 100644 --- a/onnxruntime/core/providers/coreml/coreml_execution_provider.cc +++ b/onnxruntime/core/providers/coreml/coreml_execution_provider.cc @@ -65,6 +65,11 @@ CoreMLExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph_vie } if (main_graph->GetModel().MetaData().count(kCOREML_CACHE_KEY) > 0) { user_provided_key = graph_viewer.GetGraph().GetModel().MetaData().at(kCOREML_CACHE_KEY); + if (user_provided_key.size() > 32 || + std::count_if(user_provided_key.begin(), user_provided_key.end(), + [](unsigned char c) { return std::isalnum(c); })) { + user_provided_key = std::to_string(std::hash{}(user_provided_key)); + } } else { // model_hash is a 64-bit hash value of model_path if model_path is not empty, // otherwise it hashes the graph input names and all the node output names.