Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
e5ef6e7e
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看板
提交
e5ef6e7e
编写于
7月 10, 2018
作者:
E
eclipsess
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gemm bn relu v1
上级
22646263
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
33 addition
and
31 deletion
+33
-31
src/operators/fusion_conv_add.h
src/operators/fusion_conv_add.h
+5
-5
src/operators/fusion_conv_add_bn_relu_op.h
src/operators/fusion_conv_add_bn_relu_op.h
+5
-5
src/operators/kernel/central-arm-func/conv_add_arm_func.h
src/operators/kernel/central-arm-func/conv_add_arm_func.h
+4
-4
src/operators/kernel/central-arm-func/conv_add_bn_relu_func.h
...operators/kernel/central-arm-func/conv_add_bn_relu_func.h
+15
-12
src/operators/math/depthwise_conv_3x3.cpp
src/operators/math/depthwise_conv_3x3.cpp
+1
-2
src/operators/math/math_function.h
src/operators/math/math_function.h
+1
-1
test/common/test_gemm.cpp
test/common/test_gemm.cpp
+2
-2
未找到文件。
src/operators/fusion_conv_add.h
浏览文件 @
e5ef6e7e
...
@@ -68,11 +68,11 @@ class FusionConvAddOp : public framework::OperatorWithKernel<
...
@@ -68,11 +68,11 @@ class FusionConvAddOp : public framework::OperatorWithKernel<
#ifdef PADDLE_MOBILE_CPU
#ifdef PADDLE_MOBILE_CPU
#ifndef CONV_ADD_REGISTER
//
#ifndef CONV_ADD_REGISTER
static
framework
::
FusionOpRegistrar
convadd_registrar
(
//
static framework::FusionOpRegistrar convadd_registrar(
new
FusionConvAddMatcher
());
//
new FusionConvAddMatcher());
#define CONV_ADD_REGISTER
//
#define CONV_ADD_REGISTER
#endif
//
#endif
#endif
#endif
...
...
src/operators/fusion_conv_add_bn_relu_op.h
浏览文件 @
e5ef6e7e
...
@@ -79,11 +79,11 @@ class FusionConvAddBNReluOp
...
@@ -79,11 +79,11 @@ class FusionConvAddBNReluOp
#ifdef PADDLE_MOBILE_CPU
#ifdef PADDLE_MOBILE_CPU
//
#ifndef FUSION_CONV_ADD_BN_RELU_REGISTER
#ifndef FUSION_CONV_ADD_BN_RELU_REGISTER
//
static framework::FusionOpRegistrar fusion_conv_add_bn_relu_registrar(
static
framework
::
FusionOpRegistrar
fusion_conv_add_bn_relu_registrar
(
//
new FusionConvAddBNReluMatcher());
new
FusionConvAddBNReluMatcher
());
//
#define FUSION_CONV_ADD_BN_RELU_REGISTER
#define FUSION_CONV_ADD_BN_RELU_REGISTER
//
#endif
#endif
#endif
#endif
...
...
src/operators/kernel/central-arm-func/conv_add_arm_func.h
浏览文件 @
e5ef6e7e
...
@@ -125,10 +125,10 @@ void ConvAddCompute(const FusionConvAddParam ¶m) {
...
@@ -125,10 +125,10 @@ void ConvAddCompute(const FusionConvAddParam ¶m) {
param
.
Input
()
->
dims
()[
1
]
==
param
.
Output
()
->
dims
()[
1
]
&&
param
.
Input
()
->
dims
()[
1
]
==
param
.
Output
()
->
dims
()[
1
]
&&
param
.
Filter
()
->
dims
()[
2
]
==
param
.
Filter
()
->
dims
()[
3
]
&&
param
.
Filter
()
->
dims
()[
2
]
==
param
.
Filter
()
->
dims
()[
3
]
&&
param
.
Filter
()
->
dims
()[
2
]
==
3
&&
param
.
Strides
()[
0
]
==
2
)
{
param
.
Filter
()
->
dims
()[
2
]
==
3
&&
param
.
Strides
()[
0
]
==
2
)
{
//
math::DepthwiseConv3x3(param.Input(), param.Strides(),
//
math::DepthwiseConv3x3(param.Input(), param.Strides(),
//
param.Paddings(),
//
param.Paddings(),
//
param.Filter(), param.Bias(), param.Output(),
//
param.Filter(), param.Bias(), param.Output(),
//
false);
//
false);
math
::
DepthwiseConv3x3s2p1v2
(
param
.
Input
(),
param
.
Filter
(),
param
.
Output
(),
math
::
DepthwiseConv3x3s2p1v2
(
param
.
Input
(),
param
.
Filter
(),
param
.
Output
(),
*
param
.
Bias
(),
true
);
*
param
.
Bias
(),
true
);
...
...
src/operators/kernel/central-arm-func/conv_add_bn_relu_func.h
浏览文件 @
e5ef6e7e
...
@@ -106,22 +106,25 @@ void ConvAddBNReluBasic(const FusionConvAddBNReluParam ¶m) {
...
@@ -106,22 +106,25 @@ void ConvAddBNReluBasic(const FusionConvAddBNReluParam ¶m) {
// gemm
// gemm
Tensor
out_slice
=
out_batch
.
Slice
(
g
*
out_step
,
(
g
+
1
)
*
out_step
);
Tensor
out_slice
=
out_batch
.
Slice
(
g
*
out_step
,
(
g
+
1
)
*
out_step
);
Tensor
filter_slice
=
filter
.
Slice
(
g
*
out_step
,
(
g
+
1
)
*
out_step
);
Tensor
filter_slice
=
filter
.
Slice
(
g
*
out_step
,
(
g
+
1
)
*
out_step
);
math
::
matmul
<
float
>
(
filter_slice
,
false
,
col_matrix
,
false
,
// math::matmul<float>(filter_slice, false, col_matrix, false,
// static_cast<float>(1), &out_slice,
// static_cast<float>(0));
math
::
matmulWithBn
<
float
>
(
filter_slice
,
false
,
col_matrix
,
false
,
static_cast
<
float
>
(
1
),
&
out_slice
,
static_cast
<
float
>
(
1
),
&
out_slice
,
static_cast
<
float
>
(
0
));
static_cast
<
float
>
(
0
)
,
true
,
&
new_scale
,
&
new_bias
);
}
}
}
}
/// todo : use neon in special case instead of 2for(300ms)
/// todo : use neon in special case instead of 2for(300ms)
auto
output_ptr
=
output
->
data
<
float
>
();
//
auto output_ptr = output->data<float>();
for
(
int
c
=
0
;
c
<
output_matrix_shape
[
0
];
c
++
)
{
//
for (int c = 0; c < output_matrix_shape[0]; c++) {
int
start
=
c
*
output_matrix_shape
[
1
];
//
int start = c * output_matrix_shape[1];
for
(
int
j
=
0
;
j
<
output_matrix_shape
[
1
];
j
++
)
{
//
for (int j = 0; j < output_matrix_shape[1]; j++) {
output_ptr
[
start
+
j
]
=
//
output_ptr[start + j] =
output_ptr
[
start
+
j
]
*
new_scale_ptr
[
c
]
+
new_bias_ptr
[
c
];
//
output_ptr[start + j] * new_scale_ptr[c] + new_bias_ptr[c];
output_ptr
[
start
+
j
]
=
//
output_ptr[start + j] =
output_ptr
[
start
+
j
]
<
0
?
0
:
output_ptr
[
start
+
j
];
//
output_ptr[start + j] < 0 ? 0 : output_ptr[start + j];
}
//
}
}
//
}
}
}
template
<
typename
P
>
template
<
typename
P
>
void
ConvAddBNReluCompute
(
const
FusionConvAddBNReluParam
&
param
)
{
void
ConvAddBNReluCompute
(
const
FusionConvAddBNReluParam
&
param
)
{
...
...
src/operators/math/depthwise_conv_3x3.cpp
浏览文件 @
e5ef6e7e
...
@@ -1036,8 +1036,7 @@ void DepthwiseConv3x3s2p1v2(const Tensor *input, const Tensor *filter,
...
@@ -1036,8 +1036,7 @@ void DepthwiseConv3x3s2p1v2(const Tensor *input, const Tensor *filter,
float32x4_t
vbias
=
vdupq_n_f32
(
0.0
);
float32x4_t
vbias
=
vdupq_n_f32
(
0.0
);
float32x4x2_t
input_buff_mid
{},
input_buff_bottom
[
w_times
+
1
],
float32x4x2_t
input_buff_mid
{},
input_buff_bottom
[
w_times
+
1
];
input_buff_top
[
w_times
+
1
];
float32x4_t
elewise_res0
,
elewise_res1
,
elewise_res2
,
res3
;
float32x4_t
elewise_res0
,
elewise_res1
,
elewise_res2
,
res3
;
int
out2in_mid
;
int
out2in_mid
;
float32x4_t
zero
=
vdupq_n_f32
(
0.0
);
float32x4_t
zero
=
vdupq_n_f32
(
0.0
);
...
...
src/operators/math/math_function.h
浏览文件 @
e5ef6e7e
...
@@ -30,7 +30,7 @@ void matmul(const framework::Tensor &matrix_a, bool trans_a,
...
@@ -30,7 +30,7 @@ void matmul(const framework::Tensor &matrix_a, bool trans_a,
template
<
typename
T
>
template
<
typename
T
>
void
matmulWithBn
(
const
framework
::
Tensor
&
matrix_a
,
bool
trans_a
,
void
matmulWithBn
(
const
framework
::
Tensor
&
matrix_a
,
bool
trans_a
,
const
framework
::
Tensor
&
matrix_b
,
bool
trans_b
,
T
alpha
,
const
framework
::
Tensor
&
matrix_b
,
bool
trans_b
,
T
alpha
,
framework
::
Tensor
*
matrix_out
,
T
beta
,
bool
relu
,
framework
::
Tensor
*
matrix_out
,
T
beta
,
bool
relu
=
true
,
framework
::
Tensor
*
new_scale
,
framework
::
Tensor
*
new_bias
);
framework
::
Tensor
*
new_scale
,
framework
::
Tensor
*
new_bias
);
}
// namespace math
}
// namespace math
}
// namespace operators
}
// namespace operators
...
...
test/common/test_gemm.cpp
浏览文件 @
e5ef6e7e
...
@@ -52,8 +52,8 @@ int main() {
...
@@ -52,8 +52,8 @@ int main() {
}
}
auto
time1
=
time
();
auto
time1
=
time
();
paddle_mobile
::
operators
::
math
::
s
gemm
(
m
,
n
,
k
,
0.9
,
a
,
lda
,
b
,
ldb
,
0.3
,
c
,
// paddle_mobile::operators::math::S
gemm(m, n, k, 0.9, a, lda, b, ldb, 0.3, c,
ldc
);
//
ldc);
auto
time2
=
time
();
auto
time2
=
time
();
DLOG
<<
"gemm cost :"
<<
time_diff
(
time1
,
time2
)
<<
"ms
\n
"
;
DLOG
<<
"gemm cost :"
<<
time_diff
(
time1
,
time2
)
<<
"ms
\n
"
;
for
(
int
i
=
0
;
i
<
m
*
n
;
++
i
)
{
for
(
int
i
=
0
;
i
<
m
*
n
;
++
i
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录