Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
7213d3ba
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看板
提交
7213d3ba
编写于
1月 16, 2019
作者:
H
hjchen2
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove duplicate macro definition, and fix some code style
上级
8d8dbf47
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
48 addition
and
72 deletion
+48
-72
src/framework/operator.h
src/framework/operator.h
+33
-24
src/operators/kernel/activation_kernel.h
src/operators/kernel/activation_kernel.h
+0
-9
src/operators/kernel/arm/sequence_pool_kernel.cpp
src/operators/kernel/arm/sequence_pool_kernel.cpp
+4
-2
src/operators/kernel/dequant_bn_kernel.h
src/operators/kernel/dequant_bn_kernel.h
+6
-15
src/operators/kernel/kernels.h
src/operators/kernel/kernels.h
+0
-9
src/operators/kernel/sequence_kernels.h
src/operators/kernel/sequence_kernels.h
+3
-12
test/net/test_benchmark.cpp
test/net/test_benchmark.cpp
+2
-1
未找到文件。
src/framework/operator.h
浏览文件 @
7213d3ba
...
...
@@ -150,30 +150,6 @@ class OpKernelBase {
#endif
};
#define DECLARE_OPERATOR(OpName, OpParam, OpKernel) \
template <typename DeviceType, typename T> \
class OpName##Op : public framework::OperatorWithKernel< \
DeviceType, OpParam<DeviceType>, \
operators::OpKernel<DeviceType, T>> { \
public: \
OpName##Op(const std::string &type, const VariableNameMap &inputs, \
const VariableNameMap &outputs, \
const framework::AttributeMap &attrs, \
std::shared_ptr<framework::Scope> scope) \
: framework::OperatorWithKernel<DeviceType, OpParam<DeviceType>, \
operators::OpKernel<DeviceType, T>>( \
type, inputs, outputs, attrs, scope) {} \
\
void InferShape() const override; \
};
#define DEFINE_OP_CONSTRUCTOR(cls, parent_cls) \
cls(const std::string &type, const ::paddle_mobile::VariableNameMap &inputs, \
const ::paddle_mobile::VariableNameMap &outputs, \
const ::paddle_mobile::framework::AttributeMap &attrs, \
std::shared_ptr<::paddle_mobile::framework::Scope> scope) \
: parent_cls<Dtype, T>(type, inputs, outputs, attrs, scope) {}
class
FusionOpMatcher
{
public:
FusionOpMatcher
()
{}
...
...
@@ -198,5 +174,38 @@ class FusionOpMatcher {
std
::
shared_ptr
<
OpDesc
>
new_opdesc_
;
};
#define DECLARE_OPERATOR(OpName, OpParam, OpKernel) \
template <typename DeviceType, typename T> \
class OpName##Op : public framework::OperatorWithKernel< \
DeviceType, OpParam<DeviceType>, \
operators::OpKernel<DeviceType, T>> { \
public: \
OpName##Op(const std::string &type, const VariableNameMap &inputs, \
const VariableNameMap &outputs, \
const framework::AttributeMap &attrs, \
std::shared_ptr<framework::Scope> scope) \
: framework::OperatorWithKernel<DeviceType, OpParam<DeviceType>, \
operators::OpKernel<DeviceType, T>>( \
type, inputs, outputs, attrs, scope) {} \
\
void InferShape() const override; \
};
#define DECLARE_KERNEL(OpName, OpParam) \
template <typename DeviceType, typename T> \
class OpName##Kernel \
: public framework::OpKernelBase<DeviceType, OpParam<DeviceType>> { \
public: \
bool Init(OpParam<DeviceType> *param); \
void Compute(const OpParam<DeviceType> ¶m); \
};
#define DEFINE_OP_CONSTRUCTOR(cls, parent_cls) \
cls(const std::string &type, const ::paddle_mobile::VariableNameMap &inputs, \
const ::paddle_mobile::VariableNameMap &outputs, \
const ::paddle_mobile::framework::AttributeMap &attrs, \
std::shared_ptr<::paddle_mobile::framework::Scope> scope) \
: parent_cls<Dtype, T>(type, inputs, outputs, attrs, scope) {}
}
// namespace framework
}
// namespace paddle_mobile
src/operators/kernel/activation_kernel.h
浏览文件 @
7213d3ba
...
...
@@ -20,15 +20,6 @@ limitations under the License. */
namespace
paddle_mobile
{
namespace
operators
{
#define DECLARE_KERNEL(OpName, Param) \
template <typename DeviceType, typename T> \
class OpName##Kernel \
: public framework::OpKernelBase<DeviceType, Param<DeviceType>> { \
public: \
bool Init(Param<DeviceType> *param); \
void Compute(const Param<DeviceType> ¶m); \
};
#ifdef RELU_OP
DECLARE_KERNEL
(
Relu
,
ReluParam
);
DECLARE_KERNEL
(
Relu6
,
ReluParam
);
...
...
src/operators/kernel/arm/sequence_pool_kernel.cpp
浏览文件 @
7213d3ba
...
...
@@ -66,8 +66,9 @@ void SequencePoolImpl(const framework::LoDTensor &input,
memcpy
(
out_ptr
,
in_ptr
,
width
*
sizeof
(
float
));
in_ptr
+=
width
;
int
remain_h
=
height
-
1
;
int
remain_w_start
=
0
;
#ifdef __ARM_NEON__
int
remain_w_start
=
width
&
0xfffc
;
remain_w_start
=
width
&
0xfffc
;
#endif // __ARM_NEON__
for
(
int
h
=
0
;
h
<
remain_h
;
++
h
)
{
#ifdef __ARM_NEON__
...
...
@@ -124,9 +125,10 @@ void SequencePoolImpl<SUM, float>(const framework::LoDTensor &input,
memcpy
(
out_ptr
,
in_ptr
,
width
*
sizeof
(
float
));
in_ptr
+=
width
;
int
remain_h
=
height
-
1
;
int
remain_w_start
=
0
;
#ifdef __ARM_NEON__
int
loop_w
=
width
>>
2
;
int
remain_w_start
=
width
&
0xfffc
;
remain_w_start
=
width
&
0xfffc
;
#endif // __ARM_NEON__
for
(
int
h
=
0
;
h
<
remain_h
;
++
h
)
{
#ifdef __ARM_NEON__
...
...
src/operators/kernel/dequant_bn_kernel.h
浏览文件 @
7213d3ba
...
...
@@ -20,37 +20,28 @@ limitations under the License. */
namespace
paddle_mobile
{
namespace
operators
{
#define DECLARE_KERNEL(KernelClass, KernelParam) \
template <typename DeviceType, typename T> \
class KernelClass \
: public framework::OpKernelBase<DeviceType, KernelParam<DeviceType>> { \
public: \
bool Init(KernelParam<DeviceType> *param); \
void Compute(const KernelParam<DeviceType> ¶m); \
};
#ifdef FUSION_DEQUANT_BN_OP
DECLARE_KERNEL
(
FusionDequantBN
Kernel
,
FusionDequantBNParam
);
DECLARE_KERNEL
(
FusionDequantBN
,
FusionDequantBNParam
);
#endif
#ifdef FUSION_DEQUANT_BN_RELU_OP
DECLARE_KERNEL
(
FusionDequantBNRelu
Kernel
,
FusionDequantBNParam
);
DECLARE_KERNEL
(
FusionDequantBNRelu
,
FusionDequantBNParam
);
#endif
#ifdef FUSION_DEQUANT_ADD_BN_OP
DECLARE_KERNEL
(
FusionDequantAddBN
Kernel
,
FusionDequantAddBNParam
);
DECLARE_KERNEL
(
FusionDequantAddBN
,
FusionDequantAddBNParam
);
#endif
#ifdef FUSION_DEQUANT_ADD_BN_RELU_OP
DECLARE_KERNEL
(
FusionDequantAddBNRelu
Kernel
,
FusionDequantAddBNParam
);
DECLARE_KERNEL
(
FusionDequantAddBNRelu
,
FusionDequantAddBNParam
);
#endif
#ifdef FUSION_DEQUANT_ADD_BN_QUANT_OP
DECLARE_KERNEL
(
FusionDequantAddBNQuant
Kernel
,
FusionDequantAddBNQuantParam
);
DECLARE_KERNEL
(
FusionDequantAddBNQuant
,
FusionDequantAddBNQuantParam
);
#endif
#ifdef FUSION_DEQUANT_ADD_BN_RELU_QUANT_OP
DECLARE_KERNEL
(
FusionDequantAddBNReluQuant
Kernel
,
FusionDequantAddBNQuantParam
);
DECLARE_KERNEL
(
FusionDequantAddBNReluQuant
,
FusionDequantAddBNQuantParam
);
#endif
}
// namespace operators
...
...
src/operators/kernel/kernels.h
浏览文件 @
7213d3ba
...
...
@@ -20,15 +20,6 @@ limitations under the License. */
namespace
paddle_mobile
{
namespace
operators
{
#define DECLARE_KERNEL(KernelClass, KernelParam) \
template <typename DeviceType, typename T> \
class KernelClass##Kernel \
: public framework::OpKernelBase<DeviceType, KernelParam<DeviceType>> { \
public: \
bool Init(KernelParam<DeviceType> *param); \
void Compute(const KernelParam<DeviceType> ¶m); \
};
#ifdef TOP_K_OP
DECLARE_KERNEL
(
TopK
,
TopKParam
)
#endif // TOP_K_OP
...
...
src/operators/kernel/sequence_kernels.h
浏览文件 @
7213d3ba
...
...
@@ -20,25 +20,16 @@ limitations under the License. */
namespace
paddle_mobile
{
namespace
operators
{
#define DECLARE_KERNEL(KernelClass, KernelParam) \
template <typename DeviceType, typename T> \
class KernelClass \
: public framework::OpKernelBase<DeviceType, KernelParam<DeviceType>> { \
public: \
bool Init(KernelParam<DeviceType> *param); \
void Compute(const KernelParam<DeviceType> ¶m); \
};
#ifdef SEQUENCE_EXPAND_OP
DECLARE_KERNEL
(
SequenceExpand
Kernel
,
SequenceExpandParam
);
DECLARE_KERNEL
(
SequenceExpand
,
SequenceExpandParam
);
#endif // SEQUENCE_EXPAND_OP
#ifdef SEQUENCE_POOL_OP
DECLARE_KERNEL
(
SequencePool
Kernel
,
SequencePoolParam
);
DECLARE_KERNEL
(
SequencePool
,
SequencePoolParam
);
#endif // SEQUENCE_POOL_OP
#ifdef SEQUENCE_SOFTMAX_OP
DECLARE_KERNEL
(
SequenceSoftmax
Kernel
,
SoftmaxParam
);
DECLARE_KERNEL
(
SequenceSoftmax
,
SoftmaxParam
);
#endif // SEQUENCE_SOFTMAX_OP
}
// namespace operators
...
...
test/net/test_benchmark.cpp
浏览文件 @
7213d3ba
...
...
@@ -43,7 +43,8 @@ int main(int argc, char* argv[]) {
std
::
shared_ptr
<
paddle_mobile
::
framework
::
Tensor
>
output
;
std
::
vector
<
int64_t
>
dims
{
1
,
3
,
224
,
224
};
if
(
feed_shape
)
{
sscanf
(
feed_shape
,
"%d,%d,%d,%d"
,
&
dims
[
0
],
&
dims
[
1
],
&
dims
[
2
],
&
dims
[
3
]);
sscanf
(
feed_shape
,
"%ld,%ld,%ld,%ld"
,
&
dims
[
0
],
&
dims
[
1
],
&
dims
[
2
],
&
dims
[
3
]);
}
std
::
cout
<<
"feed shape: ["
<<
dims
[
0
]
<<
", "
<<
dims
[
1
]
<<
", "
<<
dims
[
2
]
<<
", "
<<
dims
[
3
]
<<
"]
\n
"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录