[GPU] Check if padding is supported for static shape when buffer fusing (#18861)

* [GPU] Check if padding is supported even for static shape when buffer fusing

* Add unit test

* Remove unnecessary logic
This commit is contained in:
David Nam 2023-08-09 14:15:56 +09:00 committed by GitHub
parent 58bd8e7f0b
commit a8f4e114f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 1 deletions

View File

@ -117,7 +117,7 @@ bool concat_in_place_optimization::match(const program_node& concat_node,
// if an input is marked as network output, prevent optimizations
// which would affect a form of its output (unless debug flag is set),
// we also need to restrict input types to those which support padding on all axis
if (pred.first->is_dynamic() && is_runtime) {
if (!pred.first->is_dynamic() || is_runtime) {
if (!pred.first->is_padding_supported(concat_axis, lower_padd_in_axis))
return false;
}

View File

@ -3,6 +3,7 @@
//
#include "test_utils.h"
#include "random_generator.hpp"
#include "intel_gpu/runtime/engine.hpp"
@ -22,6 +23,8 @@
#include "intel_gpu/graph/network.hpp"
#include "pass_manager.h"
#include "to_string_utils.h"
#include "resample_inst.h"
#include "openvino/op/interpolate.hpp"
#include "program_wrapper.h"
@ -852,6 +855,37 @@ TEST(prepare_buffer_fusing, test_implicit_crop_and_outerpadding_deconv) {
ASSERT_EQ(crop_prim->can_be_optimized(), true);
}
TEST(prepare_buffer_fusing, test_checking_padding_supported) {
auto& engine = get_test_engine();
auto in_layout1 = layout{ ov::PartialShape{2, 36, 57, 57}, data_types::f16, format::fs_b_yx_fsv32};
auto in_layout2 = layout{ ov::PartialShape{2, 72, 57, 57}, data_types::f16, format::fs_b_yx_fsv32};
auto in_layout3 = layout{ ov::PartialShape{2, 144, 57, 57}, data_types::f16, format::fs_b_yx_fsv32};
auto padding1 = padding({0,18,1,1}, {0,0,0,0});
auto padding2 = padding({0,0,0,0}, {0,0,0,0});
auto padding3 = padding({0,0,0,0}, {0,0,0,0});
topology topology(
input_layout("input1", in_layout1),
input_layout("input2", in_layout2),
input_layout("input3", in_layout3),
resample("interp1", input_info("input1"), in_layout1.get_tensor(), 1, ov::op::v4::Interpolate::InterpolateMode::NEAREST, padding1),
resample("interp2", input_info("input2"), in_layout2.get_tensor(), 1, ov::op::v4::Interpolate::InterpolateMode::NEAREST, padding2),
resample("interp3", input_info("input3"), in_layout3.get_tensor(), 1, ov::op::v4::Interpolate::InterpolateMode::NEAREST, padding3),
concatenation("concat", {input_info("interp1"), input_info("interp2"), input_info("interp3")}, 1),
reorder("reorder", input_info("concat"), format::fs_b_yx_fsv32, data_types::f16));
ExecutionConfig config = get_test_default_config(engine);
config.set_property(ov::intel_gpu::optimize_data(true));
auto program = program::build_program(engine, topology, config, false, true);
program_wrapper::apply_opt_pass<prepare_buffer_fusing>(*program);
ASSERT_NE(program, nullptr);
auto& concat = program->get_node("concat");
ASSERT_EQ(concat.can_be_optimized(), false);
}
#ifdef ENABLE_ONEDNN_FOR_GPU
TEST(prepare_buffer_fusing, in_place_onednn_concat_static) {
auto& engine = get_test_engine();