Skip to content

Commit 83a6edb

Browse files
Merge pull request #434 from JingyuanZhang/master
feat(webgl): update fuse_op add exp
2 parents 6a1700a + 0a3f5d8 commit 83a6edb

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

packages/paddlejs-backend-webgl/src/ops/atom/common_func.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ float tanh_func(float x, float y, float z) {
6969
return tanh_calc(x);
7070
}`;
7171

72-
const exp = `
73-
float exp(float x, float y, float z) {
72+
const exp_func = `
73+
float exp_func(float x, float y, float z) {
7474
float result = exp(x);
7575
return result;
7676
}`;
7777

7878
export {
7979
prelu,
8080
relu6,
81-
exp,
81+
exp_func,
8282
leakyRelu,
8383
scale,
8484
sigmoid,

packages/paddlejs-backend-webgl/src/ops/atom/fuse_ops.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ export default function genFuseOpCode(params: OpParams) {
8989
act_name = 'tanh_func';
9090
break;
9191

92+
case 'exp':
93+
act_name = 'exp_func';
94+
break;
95+
9296
default:
9397
break;
9498
}

packages/paddlejs-backend-webgl/src/utils/dataProcess.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ function genGLSLArr(arr: Array<Number>, key: string, type: ArrTypeEnum) {
130130
}
131131

132132
function getValueFromArrByIndex(arr: Array<number>, arrKey: string, type: ArrTypeEnum) {
133+
if (arr.length === 0) {
134+
return '';
135+
}
136+
133137
const ifConditions = arr.reduce((acc, _, idx) => {
134138
const ifCondition = idx === 0
135139
? `

0 commit comments

Comments
 (0)