Skip to content

Commit 41d9bc8

Browse files
[GPU] Add fusing false condition for fs_b_yx_fsv32_network at eltwise and quantize pattern
1 parent d17f91c commit 41d9bc8

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

src/plugins/intel_gpu/src/graph/graph_optimizer/fuse_primitives_with_layout.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@
1212

1313
using namespace cldnn;
1414

15-
static bool eltwise_supports_fusings(eltwise_node& node) {
16-
auto out_layout = node.get_output_layout();
17-
// This condition refers to optimizied kernel EltwiseKernel_fs_b_yx_fsv32
18-
if (out_layout.data_type == data_types::f16 && out_layout.batch() > 1 && out_layout.format == format::fs_b_yx_fsv32) {
19-
return false;
20-
}
15+
void fuse_primitives_with_layout::run(program& p) {
16+
auto eltwise_supports_fusings = [&](eltwise_node& node) -> bool {
17+
auto out_layout = node.get_output_layout();
18+
// This condition refers to optimizied kernel EltwiseKernel_fs_b_yx_fsv32
19+
if (out_layout.data_type == data_types::f16 && out_layout.batch() > 1 &&
20+
(_lo.get_optimization_attributes().fs_b_yx_fsv32_network || out_layout.format == format::fs_b_yx_fsv32)) {
21+
return false;
22+
}
2123

22-
return true;
23-
}
24+
return true;
25+
};
2426

25-
void fuse_primitives_with_layout::run(program& p) {
2627
bool need_recalc_processing_order = false;
2728
std::map<primitive_id, std::vector<std::pair<primitive_id, size_t>>> fusing_history;
2829

@@ -35,7 +36,7 @@ void fuse_primitives_with_layout::run(program& p) {
3536
continue;
3637

3738
// No optimized Eltwise kernel supports fused-operation for fs_b_yx_fsv32
38-
// Check fusing quantize to eltwsise for this case
39+
// Check fusing quantize to eltwise for this case
3940
auto func_fuse_quantize = [&](quantize_node& node) {
4041
bool should_fuse = false;
4142
auto out_layout = node.get_output_layout();
@@ -49,7 +50,6 @@ void fuse_primitives_with_layout::run(program& p) {
4950
return;
5051

5152
should_fuse |= input_node.is_type<eltwise>() && eltwise_supports_fusings(input_node.as<eltwise>());
52-
5353
if (!should_fuse)
5454
return;
5555

src/plugins/intel_gpu/src/graph/include/pass_manager.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,12 @@ class mark_runtime_skippable_nodes : public base_pass {
397397

398398
class fuse_primitives_with_layout : public base_pass {
399399
public:
400-
fuse_primitives_with_layout() : base_pass("fuse_primitives_with_layout") {}
400+
explicit fuse_primitives_with_layout(layout_optimizer& lo_ref) :
401+
base_pass("fuse_primitives_with_layout"), _lo(lo_ref) {}
401402

402403
private:
403404
void run(program& p) override;
405+
layout_optimizer& _lo;
404406
};
405407

406408
} // namespace cldnn

src/plugins/intel_gpu/src/graph/program.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ void program::pre_optimize_graph(bool is_internal) {
594594

595595
// Check fusing primitives based on preferred format or layout optimization
596596
if (optimize_data) {
597-
apply_opt_pass<fuse_primitives_with_layout>();
597+
apply_opt_pass<fuse_primitives_with_layout>(lo);
598598
}
599599

600600
// add optimization attributes for onednn primitives

0 commit comments

Comments
 (0)