Commit 2a26558a authored by Amy Zhuang's avatar Amy Zhuang Committed by Robert Kimball

Do not fuse nodes if one node is predecessor of another node in horiz… (#1928)

* Do not fuse nodes if one node is predecessor of another node in horizontal fusion.

* Add dead node check and remove predecessor check in horizontal fusion.
parent 45fba7b1
......@@ -1040,7 +1040,7 @@ void runtime::cpu::CPU_ExternalFunction::register_common_passes(ngraph::pass::Ma
pass_manager.register_pass<ngraph::pass::CoreFusion>();
pass_manager.register_pass<runtime::cpu::pass::CPUFusion>();
// pass_manager.register_pass<runtime::cpu::pass::CPUHorizontalFusion>();
pass_manager.register_pass<runtime::cpu::pass::CPUHorizontalFusion>();
pass_manager.register_pass<runtime::cpu::pass::CPUCollapseDims>();
#if defined(NGRAPH_HALIDE)
pass_manager.register_pass<ngraph::runtime::cpu::pass::HalideSubgraphExtraction>();
......
......@@ -61,6 +61,7 @@ void ngraph::runtime::cpu::pass::CPUHorizontalFusion::cpu_conv_horizontal_fusion
//check if the node has been replaced
if (conv_bias_root->get_users().empty())
{
NGRAPH_DEBUG << "conv_horizontal_fusion: root node has been replaced\n";
return false;
}
......@@ -75,8 +76,14 @@ void ngraph::runtime::cpu::pass::CPUHorizontalFusion::cpu_conv_horizontal_fusion
for (auto u : m.get_pattern_map()[data_conv]->get_users())
{
if (!is_used(u.get()))
{
NGRAPH_DEBUG << "conv_horizontal_fusion: dead node\n";
continue;
}
if (!pattern::has_class<ngraph::op::ConvolutionBias>()(u))
{
NGRAPH_DEBUG << "conv_horizontal_fusion: not conv_bias node\n";
continue;
}
if (u->get_argument(0) != m.get_pattern_map()[data_conv])
......@@ -96,6 +103,7 @@ void ngraph::runtime::cpu::pass::CPUHorizontalFusion::cpu_conv_horizontal_fusion
bias_nodes.push_back(u->get_argument(2));
conv_bias_nodes.push_back(u);
}
if (conv_bias_nodes.size() <= 1)
{
NGRAPH_DEBUG << "conv_horizontal_fusion: need more than one nodes to do fusion\n";
......
......@@ -891,7 +891,6 @@ TEST(cpu_fusion, conv_bias_relu_n2c1h2w2_2)
EXPECT_TRUE(test::all_close(cpu_results.at(0), int_results.at(0)));
}
#if 0
TEST(cpu_fusion, conv_horizontal_fusion)
{
Shape shape_a{2, 1, 6, 6};
......@@ -942,7 +941,6 @@ TEST(cpu_fusion, conv_horizontal_fusion)
size_t cpu_cb = count_ops_of_type<op::ConvolutionBias>(cpu_f);
ASSERT_EQ(cpu_cb, 1);
}
#endif
// ConvolutionBiasAdd relies on an in-place fused MKLDNN kernel.
// Need to ensure that it is fused only when in-place buffer allocation is feasible
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment