Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add attr: fuse_gelu fuse_elu fuse_sigmoid fuse_clamp fuse_swish #46

Open
wants to merge 1 commit into
base: pytorch_dnnl
Choose a base branch
from
Open
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
44 changes: 44 additions & 0 deletions include/ideep/attributes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,50 @@ struct attr_t : public dnnl::primitive_attr {
return attr;
}

static attr_t fuse_gelu(float scale = 1.0, float alpha = 0.f,
float beta = 0.f) {
attr_t attr;
post_ops po;
po.append_eltwise(scale, algorithm::eltwise_gelu_erf, alpha, beta);
attr.set_post_ops(po);
return attr;
}

static attr_t fuse_elu(float scale = 1.0, float alpha = 0.f,
float beta = 1.0) {
attr_t attr;
post_ops po;
po.append_eltwise(scale, algorithm::eltwise_elu, alpha, beta);
attr.set_post_ops(po);
return attr;
}

static attr_t fuse_sigmoid(float scale = 1.0, float alpha = 1.0,
float beta = 0.f) {
attr_t attr;
post_ops po;
po.append_eltwise(scale, algorithm::eltwise_logistic, alpha, beta);
attr.set_post_ops(po);
return attr;
}

static attr_t fuse_clamp(float lower_bound = -1.0, float upper_bound = 1.0) {
attr_t attr;
post_ops po;
po.append_eltwise(1.0, algorithm::eltwise_clip, lower_bound, upper_bound);
attr.set_post_ops(po);
return attr;
}

static attr_t fuse_swish(float scale = 1.0, float alpha = 1.0,
float beta = 0.f) {
attr_t attr;
post_ops po;
po.append_eltwise(scale, algorithm::eltwise_swish, alpha, beta);
attr.set_post_ops(po);
return attr;
}

static attr_t residual(float sum_scale = 1.0, float relu_scale = 1.0,
float alpha = 0.f, float beta = 0.f) {
attr_t attr;
Expand Down