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.