Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,15 @@ void FuseOperatorUnsqueeze2OneDNNPass::FuseUnsqueeze2(
GET_IR_NODE_FROM_SUBGRAPH(
unsqueeze2_out, unsqueeze2_out, op_unsqueeze2_pattern);

if (!operator_op->Op()->HasAttr("use_mkldnn") ||
bool use_mkldnn_not =
!operator_op->Op()->HasAttr("use_mkldnn") ||
(operator_op->Op()->HasAttr("use_mkldnn") &&
!(PADDLE_GET_CONST(bool, operator_op->Op()->GetAttr("use_mkldnn"))))) {
!(PADDLE_GET_CONST(bool, operator_op->Op()->GetAttr("use_mkldnn"))));
bool use_onednn_not =
!operator_op->Op()->HasAttr("use_onednn") ||
(operator_op->Op()->HasAttr("use_onednn") &&
!(PADDLE_GET_CONST(bool, operator_op->Op()->GetAttr("use_onednn"))));
if (use_mkldnn_not && use_onednn_not) {
VLOG(4) << "Only oneDNN version of " << op_type
<< "can be fused with unsqueeze2.";
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void ShuffleChannelMKLDNNDetectPass::ApplyImpl(ir::Graph* graph) const {
new_op_desc.SetOutput("Out", {output_name});

new_op_desc.SetAttr("group", group);
new_op_desc.SetAttr("use_mkldnn", true);
new_op_desc.SetAttr("use_onednn", true);
new_op_desc.Flush();

// Create a new node for the fused op.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ void MainTest() {
for (const auto* node : graph->Nodes()) {
if (node->IsOp() && node->Op()->Type() == "shuffle_channel") {
const auto* op = node->Op();
ASSERT_TRUE(op->HasAttr("use_mkldnn"));
EXPECT_TRUE(PADDLE_GET_CONST(bool, op->GetAttr("use_mkldnn")));
ASSERT_TRUE(op->HasAttr("use_mkldnn") || op->HasAttr("use_onednn"));
EXPECT_TRUE((op->HasAttr("use_mkldnn") &&
PADDLE_GET_CONST(bool, op->GetAttr("use_mkldnn"))) ||
(op->HasAttr("use_onednn") &&
PADDLE_GET_CONST(bool, op->GetAttr("use_onednn"))));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,15 @@ void FuseSqueeze2Transpose2OneDNNPass::ApplyImpl(Graph *graph) const {
GET_IR_NODE_FROM_SUBGRAPH(
transpose2_op, transpose2_op, squeeze2_transpose2_pattern);

if (!transpose2_op->Op()->HasAttr("use_mkldnn") ||
bool use_mkldnn_not =
!transpose2_op->Op()->HasAttr("use_mkldnn") ||
(transpose2_op->Op()->HasAttr("use_mkldnn") &&
!(PADDLE_GET_CONST(bool,
transpose2_op->Op()->GetAttr("use_mkldnn"))))) {
!(PADDLE_GET_CONST(bool, transpose2_op->Op()->GetAttr("use_mkldnn"))));
bool use_onednn_not =
!transpose2_op->Op()->HasAttr("use_onednn") ||
(transpose2_op->Op()->HasAttr("use_onednn") &&
!(PADDLE_GET_CONST(bool, transpose2_op->Op()->GetAttr("use_onednn"))));
if (use_mkldnn_not && use_onednn_not) {
VLOG(4) << "Only oneDNN version of transpose2 can be fused after with "
"squeeze2.";
return;
Expand Down