From de750b93fc260230edf4af9795be119e2435b460 Mon Sep 17 00:00:00 2001 From: Kelvin Choi Date: Mon, 25 Oct 2021 17:47:42 +0900 Subject: [PATCH] [GPU] Revert input's output layout in case of does_possible_implementation_exist failure (#8108) Signed-off-by: Kelvin Choi --- .../src/graph_optimizer/remove_redundant_reorders.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/inference-engine/thirdparty/clDNN/src/graph_optimizer/remove_redundant_reorders.cpp b/inference-engine/thirdparty/clDNN/src/graph_optimizer/remove_redundant_reorders.cpp index 07a9f63a9a0..e9e94eff564 100644 --- a/inference-engine/thirdparty/clDNN/src/graph_optimizer/remove_redundant_reorders.cpp +++ b/inference-engine/thirdparty/clDNN/src/graph_optimizer/remove_redundant_reorders.cpp @@ -308,12 +308,15 @@ void remove_redundant_reorders::run(program& p) { if (!lo.can_fuse_reorder_to_prev(input, *node.get_users().front(), input.get_output_layout().format, output_layout.format)) continue; + auto old_output_layout_of_input = input.get_output_layout(); input.set_output_layout(output_layout, false); if (input.type()->does_possible_implementation_exist(input)) { p.replace_all_usages(node, input); p.add_optimized_primitive_info(node.id()); p.remove_all_connections(node); p.remove_if_dangling(node); + } else { + input.set_output_layout(old_output_layout_of_input, false); } } } @@ -414,6 +417,7 @@ void remove_redundant_reorders::run(program& p) { } } + auto old_output_layout_of_input = input.get_output_layout(); auto output_layout = node->get_output_layout(); input.set_output_layout(output_layout, false); if (input.type()->does_possible_implementation_exist(input)) { @@ -433,8 +437,11 @@ void remove_redundant_reorders::run(program& p) { node->can_be_optimized(true); p.add_optimized_primitive_info(node->id()); p.extract_and_remove(*node); + return true; + } else { + input.set_output_layout(old_output_layout_of_input, false); + return false; } - return true; }; if (enable_reorder_fusing) {