OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[GPU] Check static impl cache before compiling new one (#33820)
Sungeun Kim8747638b3059
diff --git a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp b/src/plugins/intel_gpu/src/graph/primitive_inst.cppindex ee2be199376..6bf9dabd161 100644--- a/src/plugins/intel_gpu/src/graph/primitive_inst.cpp+++ b/src/plugins/intel_gpu/src/graph/primitive_inst.cpp@@ -3065,13 +3065,13 @@ std::shared_ptr<primitive_impl> ImplementationsFactory::get_primitive_impl_for_p}// 1. If we have static impl in the cache - use it- if (use_async_compilation && ((inst.get_impl() && inst.get_impl()->is_dynamic()) || inst.get_flag(ExecutionFlags::SHAPE_CHANGED))) {- auto cached_impl = m_static_impls_cache.get(updated_params);- if (cached_impl) {- return cached_impl->clone();- }+ auto cached_impl = m_static_impls_cache.get(updated_params);+ if (cached_impl) {+ return cached_impl->clone();+ }- // 1.1. Static impl not found - run async compilation+ // 2. If async compilation is enabled and dynamic impl exists or shape changed - try to compile asynchronously+ if (use_async_compilation && ((inst.get_impl() && inst.get_impl()->is_dynamic()) || inst.get_flag(ExecutionFlags::SHAPE_CHANGED))) {auto& compilation_context = prog.get_compilation_context();compilation_context.push_task(updated_params, [&inst, &compilation_context, updated_params, find_impl]() {if (compilation_context.is_stopped())@@ -3096,7 +3096,7 @@ std::shared_ptr<primitive_impl> ImplementationsFactory::get_primitive_impl_for_p}std::shared_ptr<primitive_impl> dynamic_impl = nullptr;- // 2. Try to find existing dynamic impl which supports given shapes+ // 3. Try to find existing dynamic impl which supports given shapesfor (auto& impl : m_dynamic_impls_cache) {if (impl->m_manager->support_shapes(params)) {dynamic_impl = impl;@@ -3104,7 +3104,7 @@ std::shared_ptr<primitive_impl> ImplementationsFactory::get_primitive_impl_for_p}}- // 3. Try to create new shape agnostic impl & cache it+ // 4. Try to create new shape agnostic impl & cache itif (!dynamic_impl) {dynamic_impl = find_impl(node, params, shape_types::dynamic_shape);if (dynamic_impl && !inst.can_be_optimized()) {@@ -3115,13 +3115,13 @@ std::shared_ptr<primitive_impl> ImplementationsFactory::get_primitive_impl_for_p}}- // 4. If we have any dynamic impl, do adjustment for new shape before returning in back+ // 5. If we have any dynamic impl, do adjustment for new shape before returning in backif (dynamic_impl) {dynamic_impl->update(inst, params);return dynamic_impl;}- // 5. Finally, if no impl found so far, we just enforce static impl compilation+ // 6. Finally, if no impl found so far, we just enforce static impl compilationauto static_impl = find_impl(node, updated_params, shape_types::static_shape);OPENVINO_ASSERT(static_impl != nullptr, "No static impl " + node->id());static_impl->set_node_params(*node);