Skip to content

Commit

Permalink
validate attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Silv3S committed Jul 6, 2022
1 parent ba17cd4 commit 991431d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 1 addition & 5 deletions paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -583,11 +583,7 @@ class ConvMKLDNNHandlerT
post_operations.append_sum(sum_scale);
}

bool has_activation = !ctx.Attr<std::string>("fuse_activation").empty();
if (has_activation) {
paddle::platform::AppendActivation(
ctx, post_operations, activation_scale);
}
paddle::platform::AppendActivation(ctx, post_operations, activation_scale);

conv_attr.set_post_ops(post_operations);
return conv_attr;
Expand Down
7 changes: 6 additions & 1 deletion paddle/fluid/platform/mkldnn_reuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,12 @@ class ActivationMKLDNNHandler
static void AppendActivation(const framework::ExecutionContext& ctx,
dnnl::post_ops& post_ops,
float activation_scale = 1.0f) {
if (!ctx.HasAttr("fuse_activation")) return;
const auto invalid_attribute =
ctx.HasAttr("fuse_activation")
? ctx.Attr<std::string>("fuse_activation").empty()
: true;
if (invalid_attribute) return;

const auto fuse_activation = ctx.Attr<std::string>("fuse_activation");
const auto fuse_alpha =
ctx.HasAttr("fuse_alpha") ? ctx.Attr<float>("fuse_alpha") : 0.0f;
Expand Down

1 comment on commit 991431d

@paddle-bot-old
Copy link

@paddle-bot-old paddle-bot-old bot commented on 991431d Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵️ CI failures summary

🔍 PR: #43519 Commit ID: 991431d contains failed CI.

🔹 Failed: PR-CI-APPROVAL

Unknown Failed
Unknown Failed

Please sign in to comment.