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 @@ -122,7 +122,8 @@ void ConvActivationOnednnFusePass::FuseConvConcatAct(
}

bool is_not_conv_onednn =
!(prev_op_nodes[0]->Op()->GetAttrIfExists<bool>("use_mkldnn"));
!(prev_op_nodes[0]->Op()->GetAttrIfExists<bool>("use_mkldnn") ||
prev_op_nodes[0]->Op()->GetAttrIfExists<bool>("use_onednn"));
if ((prev_op_nodes[0]->Op()->Type() != "conv2d" &&
prev_op_nodes[0]->Op()->Type() != "fused_conv2d") ||
is_not_conv_onednn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ void ConvAffineChannelFusePass::FuseConvAffineChannel(
desc.SetOutput("Out", std::vector<std::string>({ac_out->Name()}));
desc.SetType("elementwise_add");
desc.SetAttr("axis", 1);
desc.SetAttr("use_mkldnn", conv->Op()->GetAttrIfExists<bool>("use_mkldnn"));
desc.SetAttr("use_onednn",
conv->Op()->GetAttrIfExists<bool>("use_mkldnn") ||
conv->Op()->GetAttrIfExists<bool>("use_onednn"));

auto eltwise_op = g->CreateOpNode(&desc); // OpDesc will be copied.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ void SetOp(ProgramDesc* prog,
const std::vector<std::string>& inputs,
const std::vector<std::string>& outputs,
const std::string& mkldnn_data_type = "float32",
const bool use_mkldnn = true) {
const bool use_onednn = true) {
auto* op = prog->MutableBlock(0)->AppendOp();

op->SetType(type);
if (type != "reshape2") op->SetAttr("use_mkldnn", use_mkldnn);
if (type != "reshape2") op->SetAttr("use_onednn", use_onednn);
op->SetAttr("mkldnn_data_type", mkldnn_data_type);

if (type == "conv2d") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void SetOp(ProgramDesc* prog,
auto* op = prog->MutableBlock(0)->AppendOp();

op->SetType(type);
op->SetAttr("use_mkldnn", true);
op->SetAttr("use_onednn", true);
op->SetAttr("mkldnn_data_type", mkldnn_data_type);

if (type == "conv2d") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void SetOp(ProgramDesc* prog,
bool is_negative_input = true) {
auto* op = prog->MutableBlock(0)->AppendOp();
op->SetType(type);
op->SetAttr("use_mkldnn", use_onednn);
op->SetAttr("use_onednn", use_onednn);
op->SetAttr("name", name);
if (type != "dropout" && type != "quantize" && type != "dequantize") {
op->SetAttr("mkldnn_data_type", onednn_data_type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void DepthwiseConvMKLDNNPass::ApplyImpl(ir::Graph* graph) const {
auto* pattern = gpd.mutable_pattern();
pattern->NewNode("depthwise_conv")
->assert_is_op("depthwise_conv2d")
->assert_op_attr("use_mkldnn", true);
->assert_op_attr_or("use_mkldnn", "use_onednn", true);

int found_depthwise_conv_onednn_count = 0;
auto handler = [&](const GraphPatternDetector::subgraph_t& subgraph,
Expand Down
9 changes: 5 additions & 4 deletions paddle/fluid/framework/ir/onednn/fc_onednn_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ void FCONEDNNPass::ApplyImpl(ir::Graph* graph) const {
int found_fc_count = 0;
auto handler = [&](const GraphPatternDetector::subgraph_t& subgraph,
Graph* g) {
VLOG(4) << "Handle FC MKL-DNN pass";
if (!(graph->Has("use_mkldnn") && graph->Get<bool>("use_mkldnn"))) {
VLOG(3) << "do not enable FC MKL-DNN because it doesn't have use_mkldnn "
VLOG(4) << "Handle FC ONE-DNN pass";
if (!(graph->Has("use_mkldnn") && graph->Get<bool>("use_mkldnn")) &&
!(graph->Has("use_onednn") && graph->Get<bool>("use_onednn"))) {
VLOG(3) << "do not enable FC ONE-DNN because it doesn't have use_onednn "
"attribute.";
return;
}
Expand All @@ -68,7 +69,7 @@ void FCONEDNNPass::ApplyImpl(ir::Graph* graph) const {
"2, 3 & 4, or when width or height is different than one.";
return;
}
desc->SetAttr("use_mkldnn", true);
desc->SetAttr("use_onednn", true);

found_fc_count++;
};
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/framework/operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ class TEST_API OperatorBase {
VariableNameMap outputs_;
AttributeMap attrs_;
// NOTE: runtime_attrs_ contains the attributes which used for dispatching
// kernel (use_mkldnn, use_cudnn, ...) or passing additional configuration
// kernel (use_onednn, use_cudnn, ...) or passing additional configuration
// for special heterogeneous kernel (workspace_size_MB, ...).
// The attributes in runtime_attrs_ are set by framework (such as PASS),
// and not in the python api.
Expand Down