[GPU] Add black list to avoid fusing crop before experimental_detectron_roi_feature_extractor (#15036)
* Add black list to avoid fusing crop before experimental_detectron_roi_feature_extractor * propagate crop when crop is cascaded
This commit is contained in:
1 parent
d18f518582
commit
9e54ac6518
2 files changed
+66
-2
No files matched your search
@@ -13,6 +13,8 @@
|
||||
#include "resample_inst.h"
|
||||
#include "loop_inst.h"
|
||||
#include "non_max_suppression_inst.h"
|
||||
#include "experimental_detectron_roi_feature_extractor_inst.hpp"
|
||||
#include "border_inst.h"
|
||||
|
||||
#include "pass_manager.h"
|
||||
#include "program_helpers.h"
|
||||
@@ -361,6 +363,8 @@ void prepare_buffer_fusing::run(program& p) {
|
||||
if (can_reshape_be_optimized(reshape_node))
|
||||
return;
|
||||
}
|
||||
if (user->is_type<experimental_detectron_roi_feature_extractor>() && user->get_dependency_index(node) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.get_dependencies().size() == 1 && node.get_users().size() > 0) {
|
||||
@@ -376,8 +380,8 @@ void prepare_buffer_fusing::run(program& p) {
|
||||
auto input_layout = node.get_dependency(0).get_output_layout();
|
||||
const auto& crop_size = crop_layout.get_tensor();
|
||||
const auto& out_padd = crop_layout.data_padding;
|
||||
const auto opt_lower_pad = crop_prim->offsets.feature[0];
|
||||
const auto opt_upper_pad = input_layout.feature() - crop_prim->offsets.feature[0] - crop_size.feature[0];
|
||||
auto opt_lower_pad = crop_prim->offsets.feature[0];
|
||||
auto opt_upper_pad = input_layout.feature() - crop_prim->offsets.feature[0] - crop_size.feature[0];
|
||||
|
||||
// do not optimize crop if paddings are not properly aligned
|
||||
for (auto& usr : node.get_users()) {
|
||||
@@ -415,6 +419,20 @@ void prepare_buffer_fusing::run(program& p) {
|
||||
// crop output buffer
|
||||
// |_low_pad_|__data_size__|___|<-upper pad
|
||||
|
||||
// feature num of pad should be accumulated if dep has been optimized out.
|
||||
auto& dep = node.get_dependency(0);
|
||||
if (dep.is_type<crop>() && dep.can_be_optimized()) {
|
||||
auto dep_pad = dep.get_output_layout().data_padding;
|
||||
OPENVINO_ASSERT(
|
||||
dep_pad.lower_size().batch[0] == 0 && dep_pad.upper_size().batch[0] == 0 &&
|
||||
dep_pad.lower_size().spatial[0] == 0 && dep_pad.upper_size().spatial[0] == 0 &&
|
||||
dep_pad.lower_size().spatial[1] == 0 && dep_pad.upper_size().spatial[1] == 0,
|
||||
"batch, y, x of pad should be aligned to 0.");
|
||||
|
||||
opt_lower_pad += dep_pad.lower_size().feature[0];
|
||||
opt_upper_pad += dep_pad.upper_size().feature[0];
|
||||
}
|
||||
|
||||
node.set_output_padding(
|
||||
padding({out_padd.lower_size().batch[0],
|
||||
opt_lower_pad,
|
||||
|
||||
@@ -1497,3 +1497,49 @@ TEST(crop_gpu, static_split_batch) {
|
||||
for (size_t i = 0; i < out3.size(); i++)
|
||||
ASSERT_EQ(output_ptr_3[i], out3[i]);
|
||||
}
|
||||
|
||||
TEST(crop_gpu, optimized_out_crop) {
|
||||
auto& engine = get_test_engine();
|
||||
|
||||
auto input_actual_layout = layout{ ov::PartialShape{5, 6, 1, 1}, data_types::f32, format::bfyx };
|
||||
auto input_mem = engine.allocate_memory(input_actual_layout);
|
||||
std::vector<int32_t> input_vec = {
|
||||
0, 1, 2, 3, 4, 5,
|
||||
0, 1, 2, 3, 4, 5,
|
||||
0, 1, 2, 3, 4, 5,
|
||||
0, 1, 2, 3, 4, 5,
|
||||
0, 1, 2, 3, 4, 5,
|
||||
};
|
||||
set_values(input_mem, input_vec);
|
||||
|
||||
std::vector<int32_t> out_vec = {
|
||||
0, 1, 2, 3,
|
||||
0, 1, 2, 3,
|
||||
0, 1, 2, 3,
|
||||
0, 1, 2, 3,
|
||||
0, 1, 2, 3,
|
||||
};
|
||||
|
||||
topology topology;
|
||||
topology.add(input_layout("input", input_actual_layout));
|
||||
topology.add(crop("crop1", { input_info("input") }, tensor(5, 5, 1, 1), { tensor(0, 0, 0, 0) }, padding({0, 0, 0, 0}, {0, 0, 0, 0})));
|
||||
topology.add(crop("crop2", { input_info("crop1") }, tensor(5, 4, 1, 1), { tensor(0, 0, 0, 0) }, padding({0, 0, 0, 0}, {0, 0, 0, 0})));
|
||||
topology.add(reorder("reorder_out", input_info("crop2"), layout{ ov::PartialShape{5, 4, 1, 1}, data_types::f32, format::bfyx }));
|
||||
|
||||
ExecutionConfig config;
|
||||
config.set_property(ov::intel_gpu::optimize_data(true));
|
||||
|
||||
network network(engine, topology, config);
|
||||
network.set_input_data("input", input_mem);
|
||||
auto outputs = network.execute();
|
||||
|
||||
auto output = outputs.at("reorder_out").get_memory();
|
||||
cldnn::mem_lock<int32_t> output_ptr(output, get_test_stream());
|
||||
|
||||
for (size_t i = 0; i < out_vec.size(); i++)
|
||||
ASSERT_EQ(output_ptr[i], out_vec[i]);
|
||||
|
||||
auto all_primitives = network.get_all_primitives();
|
||||
ASSERT_TRUE(all_primitives["crop1"] == "_optimized_");
|
||||
ASSERT_TRUE(all_primitives["crop2"] == "_optimized_");
|
||||
}
|
||||
Reference in new issue
Block a user