Skip to content

Commit 7d613cb

Browse files
authored
Merge pull request #451 from JingyuanZhang/master
feat(webgl): update conv2d packing with hard_swish
2 parents e33999d + 0ff3ae8 commit 7d613cb

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

packages/paddlejs-backend-webgl/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/paddlejs-backend-webgl/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@paddlejs/paddlejs-backend-webgl",
3-
"version": "1.2.8",
3+
"version": "1.2.9",
44
"description": "",
55
"main": "lib/index",
66
"scripts": {

packages/paddlejs-backend-webgl/src/ops/shader/conv2d_packing.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ function mainFunc(
1010
paddings = [],
1111
dilations = [],
1212
fuse_relu,
13-
act_type
13+
act_type,
14+
hard_swish_offset = 3.0,
15+
hard_swish_scale = 6.0,
16+
hard_swish_threshold = 6.0
1417
}
1518
) {
1619
const [stride_v = 1, stride_h = 1] = strides;
@@ -84,6 +87,13 @@ function mainFunc(
8487
else if (${act_type === 'relu6'}) {
8588
res = min(max(vec4(0.0, 0.0, 0.0, 0.0), res), vec4(6.0, 6.0, 6.0, 6.0));
8689
}
90+
else if (${act_type === 'hard_swish'}) {
91+
res = res * min(
92+
max(vec4(0.0, 0.0, 0.0, 0.0), res + vec4(${hard_swish_offset})),
93+
vec4(${hard_swish_threshold})
94+
) / vec4(${hard_swish_scale});
95+
}
96+
8797
setPackedOutput(res);
8898
}
8999
`;

0 commit comments

Comments
 (0)