Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
866ab5fc
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
866ab5fc
编写于
7月 10, 2018
作者:
E
eclipsycn
提交者:
GitHub
7月 10, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #540 from smilejames/develop
update gemm with batchnrom fusion
上级
cd30eb8a
d90955be
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
55 addition
and
56 deletion
+55
-56
src/operators/math/gemm.cpp
src/operators/math/gemm.cpp
+55
-56
未找到文件。
src/operators/math/gemm.cpp
浏览文件 @
866ab5fc
...
...
@@ -458,8 +458,7 @@ void SgemmWithBn(int m, int n, int k, float alpha, const float *A, int lda,
mc
=
s_min
(
m
-
i
,
MC
);
PackMatrixA_
(
mc
,
KC
,
mc
%
MR
,
&
A
(
i
,
0
),
lda
,
packedA
);
InnerKernelWithBn
(
mc
,
nc
,
alpha
,
packedA
,
packedB
,
beta
,
packedC
,
&
C
(
i
,
j
),
ldc
,
relu
,
new_scale
+
ldc
*
i
+
j
,
new_bias
+
ldc
*
i
+
j
);
&
C
(
i
,
j
),
ldc
,
relu
,
new_scale
+
i
,
new_bias
+
i
);
}
}
...
...
@@ -1224,23 +1223,27 @@ void WriteWithBn(int mc, int nc, float *c, float *C, int ldc, float *scale,
"mov r5, %[nc1]
\n\t
"
"mov r6, %[nc2]
\n\t
"
"vld1.32 {d0}, [%[scale]]
\n\t
"
"vld1.32 {d1}, [%[bias]]
\n\t
"
"vdup.32 q1, d0[0]
\n\t
"
"vdup.32 q2, d1[0]
\n\t
"
"subs r5, r5, #1
\n\t
"
"blt end_nc1_%=
\n\t
"
"loop_nc1_%=:
\n\t
"
"vld1.32 {q
0, q1
}, [%[c]]!
\n\t
"
"v
ld1.32 {q2, q3}, [%[scale]]!
\n\t
"
"v
ld1.32 {q10, q11}, [%[bias]]!
\n\t
"
"v
mla.f32 q10, q0,
q2
\n\t
"
"v
mla.f32 q11, q1, q3
\n\t
"
"vld1.32 {q
3, q4
}, [%[c]]!
\n\t
"
"v
mul.f32 q10, q3, q1
\n\t
"
"v
mul.f32 q11, q4, q1
\n\t
"
"v
add.f32 q10, q10,
q2
\n\t
"
"v
add.f32 q11, q11, q2
\n\t
"
"vst1.32 {q10, q11}, [%[C]]!
\n\t
"
"vld1.32 {q
4, q5
}, [%[c]]!
\n\t
"
"v
ld1.32 {q6, q7}, [%[scale]]!
\n\t
"
"v
ld1.32 {q12, q13}, [%[bias]]!
\n\t
"
"v
mla.f32 q12, q4, q6
\n\t
"
"v
mla.f32 q13, q5, q7
\n\t
"
"vld1.32 {q
5, q6
}, [%[c]]!
\n\t
"
"v
mul.f32 q12, q5, q1
\n\t
"
"v
mul.f32 q13, q6, q1
\n\t
"
"v
add.f32 q12, q12, q2
\n\t
"
"v
add.f32 q13, q13, q2
\n\t
"
"vst1.32 {q12, q13}, [%[C]]!
\n\t
"
"subs r5, r5, #1
\n\t
"
...
...
@@ -1251,11 +1254,10 @@ void WriteWithBn(int mc, int nc, float *c, float *C, int ldc, float *scale,
"blt end_nc2_%=
\n\t
"
"loop_nc2_%=:
\n\t
"
"vld1.32 {q0}, [%[c]]!
\n\t
"
"vld1.32 {q1}, [%[scale]]!
\n\t
"
"vld1.32 {q10}, [%[bias]]!
\n\t
"
"vmla.f32 q10, q0, q1
\n\t
"
"vst1.32 {q10}, [%[C]]!
\n\t
"
"vld1.32 {q7}, [%[c]]!
\n\t
"
"vmul.f32 q10, q7, q1
\n\t
"
"vadd.f32 q10, q10, q2
\n\t
"
"vst1.32 {q10}, [%[C]]!
\n\t
"
"subs r6, r6, #1
\n\t
"
"bge loop_nc2_%=
\n\t
"
...
...
@@ -1265,20 +1267,17 @@ void WriteWithBn(int mc, int nc, float *c, float *C, int ldc, float *scale,
"beq end_nc3_%=
\n\t
"
"sub %[c], %[c], %[nc3]
\n\t
"
"sub %[scale], %[scale], %[nc3]
\n\t
"
"sub %[bias], %[bias], %[nc3]
\n\t
"
"sub %[C], %[C], %[nc3]
\n\t
"
"vld1.32 {q0}, [%[c]]!
\n\t
"
"vld1.32 {q1}, [%[scale]]!
\n\t
"
"vld1.32 {q10}, [%[bias]]!
\n\t
"
"vmla.f32 q10, q0, q1
\n\t
"
"vst1.32 {q10}, [%[C]]!
\n\t
"
"vld1.32 {q8}, [%[c]]!
\n\t
"
"vmul.f32 q11, q8, q1
\n\t
"
"vadd.f32 q11, q11, q2
\n\t
"
"vst1.32 {q11}, [%[C]]!
\n\t
"
"end_nc3_%=:
\n\t
"
"add %[scale], %[scale], #4
\n\t
"
"add %[bias], %[bias], #4
\n\t
"
"add %[c], %[c], %[step1]
\n\t
"
"add %[scale], %[scale], %[step]
\n\t
"
"add %[bias], %[bias], %[step]
\n\t
"
"add %[C], %[C], %[step]
\n\t
"
"subs %[mc], %[mc], #1
\n\t
"
...
...
@@ -1289,8 +1288,8 @@ void WriteWithBn(int mc, int nc, float *c, float *C, int ldc, float *scale,
:
[
C
]
"r"
(
C
),
[
c
]
"r"
(
c
),
[
mc
]
"r"
(
mc
),
[
nc1
]
"r"
(
nc1
),
[
nc2
]
"r"
(
nc2
),
[
nc3
]
"r"
(
nc3
),
[
step
]
"r"
(
step
),
[
step1
]
"r"
(
step1
),
[
scale
]
"r"
(
scale
),
[
bias
]
"r"
(
bias
)
:
"memory"
,
"
cc"
,
"r5"
,
"r6"
,
"r7"
,
"r8"
,
"q0"
,
"q1"
,
"q2"
,
"q3"
,
"q4
"
,
"q
5"
,
"q6"
,
"q7
"
,
"q10"
,
"q11"
,
"q12"
,
"q13"
);
:
"memory"
,
"
r5"
,
"r6"
,
"q0"
,
"q1"
,
"q2"
,
"q3"
,
"q4"
,
"q5"
,
"q6"
,
"q7
"
,
"q
8
"
,
"q10"
,
"q11"
,
"q12"
,
"q13"
);
}
// C = A * B, batchnorm(C), relu(C)
...
...
@@ -1311,25 +1310,29 @@ void WriteWithBnRelu(int mc, int nc, float *c, float *C, int ldc, float *scale,
"mov r5, %[nc1]
\n\t
"
"mov r6, %[nc2]
\n\t
"
"vld1.32 {d0}, [%[scale]]
\n\t
"
"vld1.32 {d1}, [%[bias]]
\n\t
"
"vdup.32 q1, d0[0]
\n\t
"
"vdup.32 q2, d1[0]
\n\t
"
"subs r5, r5, #1
\n\t
"
"blt end_nc1_%=
\n\t
"
"loop_nc1_%=:
\n\t
"
"vld1.32 {q
0, q1
}, [%[c]]!
\n\t
"
"v
ld1.32 {q2, q3}, [%[scale]]!
\n\t
"
"v
ld1.32 {q10, q11}, [%[bias]]!
\n\t
"
"v
mla.f32 q10, q0,
q2
\n\t
"
"v
mla.f32 q11, q1, q3
\n\t
"
"vld1.32 {q
3, q4
}, [%[c]]!
\n\t
"
"v
mul.f32 q10, q3, q1
\n\t
"
"v
mul.f32 q11, q4, q1
\n\t
"
"v
add.f32 q10, q10,
q2
\n\t
"
"v
add.f32 q11, q11, q2
\n\t
"
"vmax.f32 q10, q10, q14
\n\t
"
"vmax.f32 q11, q11, q14
\n\t
"
"vst1.32 {q10, q11}, [%[C]]!
\n\t
"
"vld1.32 {q
4, q5
}, [%[c]]!
\n\t
"
"v
ld1.32 {q6, q7}, [%[scale]]!
\n\t
"
"v
ld1.32 {q12, q13}, [%[bias]]!
\n\t
"
"v
mla.f32 q12, q4, q6
\n\t
"
"v
mla.f32 q13, q5, q7
\n\t
"
"vld1.32 {q
5, q6
}, [%[c]]!
\n\t
"
"v
mul.f32 q12, q5, q1
\n\t
"
"v
mul.f32 q13, q6, q1
\n\t
"
"v
add.f32 q12, q12, q2
\n\t
"
"v
add.f32 q13, q13, q2
\n\t
"
"vmax.f32 q12, q12, q14
\n\t
"
"vmax.f32 q13, q13, q14
\n\t
"
"vst1.32 {q12, q13}, [%[C]]!
\n\t
"
...
...
@@ -1342,12 +1345,11 @@ void WriteWithBnRelu(int mc, int nc, float *c, float *C, int ldc, float *scale,
"blt end_nc2_%=
\n\t
"
"loop_nc2_%=:
\n\t
"
"vld1.32 {q0}, [%[c]]!
\n\t
"
"vld1.32 {q1}, [%[scale]]!
\n\t
"
"vld1.32 {q10}, [%[bias]]!
\n\t
"
"vmla.f32 q10, q0, q1
\n\t
"
"vmax.f32 q10, q10, q14
\n\t
"
"vst1.32 {q10}, [%[C]]!
\n\t
"
"vld1.32 {q7}, [%[c]]!
\n\t
"
"vmul.f32 q10, q7, q1
\n\t
"
"vadd.f32 q10, q10, q2
\n\t
"
"vmax.f32 q10, q10, q14
\n\t
"
"vst1.32 {q10}, [%[C]]!
\n\t
"
"subs r6, r6, #1
\n\t
"
"bge loop_nc2_%=
\n\t
"
...
...
@@ -1357,21 +1359,18 @@ void WriteWithBnRelu(int mc, int nc, float *c, float *C, int ldc, float *scale,
"beq end_nc3_%=
\n\t
"
"sub %[c], %[c], %[nc3]
\n\t
"
"sub %[scale], %[scale], %[nc3]
\n\t
"
"sub %[bias], %[bias], %[nc3]
\n\t
"
"sub %[C], %[C], %[nc3]
\n\t
"
"vld1.32 {q0}, [%[c]]!
\n\t
"
"vld1.32 {q1}, [%[scale]]!
\n\t
"
"vld1.32 {q10}, [%[bias]]!
\n\t
"
"vmla.f32 q10, q0, q1
\n\t
"
"vmax.f32 q10, q10, q14
\n\t
"
"vst1.32 {q10}, [%[C]]!
\n\t
"
"vld1.32 {q8}, [%[c]]!
\n\t
"
"vmul.f32 q11, q8, q1
\n\t
"
"vadd.f32 q11, q11, q2
\n\t
"
"vmax.f32 q11, q11, q14
\n\t
"
"vst1.32 {q11}, [%[C]]!
\n\t
"
"end_nc3_%=:
\n\t
"
"add %[scale], %[scale], #4
\n\t
"
"add %[bias], %[bias], #4
\n\t
"
"add %[c], %[c], %[step1]
\n\t
"
"add %[scale], %[scale], %[step]
\n\t
"
"add %[bias], %[bias], %[step]
\n\t
"
"add %[C], %[C], %[step]
\n\t
"
"subs %[mc], %[mc], #1
\n\t
"
...
...
@@ -1382,8 +1381,8 @@ void WriteWithBnRelu(int mc, int nc, float *c, float *C, int ldc, float *scale,
:
[
C
]
"r"
(
C
),
[
c
]
"r"
(
c
),
[
mc
]
"r"
(
mc
),
[
nc1
]
"r"
(
nc1
),
[
nc2
]
"r"
(
nc2
),
[
nc3
]
"r"
(
nc3
),
[
step
]
"r"
(
step
),
[
step1
]
"r"
(
step1
),
[
scale
]
"r"
(
scale
),
[
bias
]
"r"
(
bias
)
:
"memory"
,
"r5"
,
"r6"
,
"
r7"
,
"r8"
,
"q0"
,
"q1"
,
"q2"
,
"q3"
,
"q4"
,
"q5
"
,
"q
6"
,
"q7
"
,
"q10"
,
"q11"
,
"q12"
,
"q13"
,
"q14"
);
:
"memory"
,
"r5"
,
"r6"
,
"
q0"
,
"q1"
,
"q2"
,
"q3"
,
"q4"
,
"q5"
,
"q6"
,
"q7
"
,
"q
8
"
,
"q10"
,
"q11"
,
"q12"
,
"q13"
,
"q14"
);
}
// C = A * B
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录