diff --git a/mindspore/ccsrc/plugin/device/gpu/hal/hardware/gpu_device_context.cc b/mindspore/ccsrc/plugin/device/gpu/hal/hardware/gpu_device_context.cc index 1c7c4a296cd..f48bb682be3 100644 --- a/mindspore/ccsrc/plugin/device/gpu/hal/hardware/gpu_device_context.cc +++ b/mindspore/ccsrc/plugin/device/gpu/hal/hardware/gpu_device_context.cc @@ -268,34 +268,35 @@ void GPUDeviceContext::OptimizeGraphWithDeviceInfo(const KernelGraphPtr &graph) void GPUDeviceContext::FuseOperators(const KernelGraphPtr &graph) const { MS_EXCEPTION_IF_NULL(graph); + auto optimizer = std::make_shared(); + auto pm = std::make_shared(); // In the dynamic shape scene, the infershape stage needs to call the primitive infer function. // When the fusion operator generates a new primitive, but there // is no corresponding primitive infer function, an error will occur. // Therefore, this kind of scene does not support dynamic shape. if (graph->is_dynamic_shape()) { - MS_LOG(INFO) << "Dynamic shape skip fusion"; - return; + MS_LOG(INFO) << "Dynamic shape skip some fusion pass"; + pm->AddPass(std::make_shared("print_reduce")); + } else { + pm->AddPass(std::make_shared()); + pm->AddPass(std::make_shared()); + pm->AddPass(std::make_shared()); + pm->AddPass(std::make_shared()); + pm->AddPass(std::make_shared()); + pm->AddPass(std::make_shared()); + pm->AddPass(std::make_shared()); + if (!graphkernel::GraphKernelFlags::GetInstance().IsEnableGraphKernel()) { + pm->AddPass(std::make_shared("cast_all")); + } + pm->AddPass(std::make_shared("combine_momentum")); + pm->AddPass(std::make_shared()); + pm->AddPass(std::make_shared()); + pm->AddPass(std::make_shared("print_reduce")); + pm->AddPass(std::make_shared()); + pm->AddPass(std::make_shared("insert_cast_gpu")); + pm->AddPass(std::make_shared()); + pm->AddPass(std::make_shared()); } - auto optimizer = std::make_shared(); - auto pm = std::make_shared(); - pm->AddPass(std::make_shared()); - pm->AddPass(std::make_shared()); - pm->AddPass(std::make_shared()); - pm->AddPass(std::make_shared()); - pm->AddPass(std::make_shared()); - pm->AddPass(std::make_shared()); - pm->AddPass(std::make_shared()); - if (!graphkernel::GraphKernelFlags::GetInstance().IsEnableGraphKernel()) { - pm->AddPass(std::make_shared("cast_all")); - } - pm->AddPass(std::make_shared("combine_momentum")); - pm->AddPass(std::make_shared()); - pm->AddPass(std::make_shared()); - pm->AddPass(std::make_shared("print_reduce")); - pm->AddPass(std::make_shared()); - pm->AddPass(std::make_shared("insert_cast_gpu")); - pm->AddPass(std::make_shared()); - pm->AddPass(std::make_shared()); optimizer->AddPassManager(pm); (void)optimizer->Optimize(graph); graph->SetExecOrderByDefault();