From 30ec4401d5ef1d3486e891993390f547eb251fb6 Mon Sep 17 00:00:00 2001 From: xufang Date: Thu, 19 Oct 2023 08:38:42 +0800 Subject: [PATCH] CreateInferRequest uses the first graph for CPU Plugin --- src/plugins/intel_cpu/src/exec_network.cpp | 10 ++++++++++ src/plugins/intel_cpu/src/exec_network.h | 1 + src/plugins/intel_cpu/src/infer_request.cpp | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/plugins/intel_cpu/src/exec_network.cpp b/src/plugins/intel_cpu/src/exec_network.cpp index d694ab523788fd..e8a8874ee10e70 100644 --- a/src/plugins/intel_cpu/src/exec_network.cpp +++ b/src/plugins/intel_cpu/src/exec_network.cpp @@ -201,6 +201,16 @@ ExecNetwork::GraphGuard::Lock ExecNetwork::GetGraph() const { return graphLock; } +ExecNetwork::GraphGuard::Lock ExecNetwork::GetFirstGraph() const { + int streamId = 0; + auto streamsExecutor = dynamic_cast(_taskExecutor.get()); + auto graphLock = GraphGuard::Lock(_graphs[streamId % _graphs.size()]); + if (!graphLock._graph.IsReady()) { + IE_THROW() << "graph is not ready"; + } + return graphLock; +} + InferenceEngine::IInferRequestInternal::Ptr ExecNetwork::CreateInferRequest() { return CreateAsyncInferRequestFromSync(); } diff --git a/src/plugins/intel_cpu/src/exec_network.h b/src/plugins/intel_cpu/src/exec_network.h index 711654f5df7087..6ce33f2b3ff0fc 100644 --- a/src/plugins/intel_cpu/src/exec_network.h +++ b/src/plugins/intel_cpu/src/exec_network.h @@ -75,6 +75,7 @@ class ExecNetwork: public InferenceEngine::ExecutableNetworkThreadSafeDefault { * even from main thread */ GraphGuard::Lock GetGraph() const; + GraphGuard::Lock GetFirstGraph() const; InferenceEngine::Parameter GetConfigLegacy(const std::string &name) const; diff --git a/src/plugins/intel_cpu/src/infer_request.cpp b/src/plugins/intel_cpu/src/infer_request.cpp index 749342edae152c..c67184db47fdbd 100644 --- a/src/plugins/intel_cpu/src/infer_request.cpp +++ b/src/plugins/intel_cpu/src/infer_request.cpp @@ -38,7 +38,7 @@ void InferRequestBase::CreateInferRequest() { if (execNetwork->_graphs.size() == 0) IE_THROW() << "No graph was found"; - graph = &(execNetwork->GetGraph()._graph); + graph = &(execNetwork->GetFirstGraph()._graph); initBlobs();