Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
c68dd38e
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看板
提交
c68dd38e
编写于
6月 29, 2018
作者:
E
eclipsess
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
conv add bn relu
上级
8f97ff2f
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
45 addition
and
13 deletion
+45
-13
src/framework/operator.h
src/framework/operator.h
+12
-0
src/framework/program/program-optimize/node.cpp
src/framework/program/program-optimize/node.cpp
+10
-5
src/framework/program/program-optimize/node.h
src/framework/program/program-optimize/node.h
+5
-2
src/operators/feed_op.h
src/operators/feed_op.h
+2
-0
src/operators/fetch_op.h
src/operators/fetch_op.h
+2
-0
src/operators/fusion_conv_add.cpp
src/operators/fusion_conv_add.cpp
+2
-0
src/operators/fusion_conv_add.h
src/operators/fusion_conv_add.h
+3
-1
src/operators/fusion_conv_add_relu_op.h
src/operators/fusion_conv_add_relu_op.h
+4
-4
src/operators/fusion_fc_op.h
src/operators/fusion_fc_op.h
+5
-1
未找到文件。
src/framework/operator.h
浏览文件 @
c68dd38e
...
...
@@ -138,9 +138,21 @@ class OpKernelBase {
* @p para 这个参数为 kernel 运算时所需要用到参数组成的一个结构体,
* 所有结构体存在与: paddle-mobile/src/operators/op_param.h
* */
#ifdef PADDLE_MOBILE_MALI_GPU
OpKernelBase
()
{
acl_op_
=
nullptr
;
}
void
*
GetAclOp
()
const
{
return
acl_op_
;
}
void
SetAclOp
(
void
*
op
,
void
*
ob
)
const
{
reinterpret_cast
<
OpKernelBase
<
Dtype
,
P
>
*>
(
ob
)
->
acl_op_
=
op
;
}
#endif
virtual
void
Compute
(
const
P
&
para
)
const
=
0
;
virtual
bool
Init
(
const
P
&
para
)
const
{
return
true
;
};
virtual
~
OpKernelBase
()
=
default
;
private:
#ifdef PADDLE_MOBILE_MALI_GPU
void
*
acl_op_
;
#endif
};
#define DEFINE_OP_CONSTRUCTOR(cls, parent_cls) \
...
...
src/framework/program/program-optimize/node.cpp
浏览文件 @
c68dd38e
...
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */
#include "framework/program/program-optimize/node.h"
#include <algorithm>
#include "framework/operator.h"
namespace
paddle_mobile
{
...
...
@@ -92,7 +93,8 @@ int Node::Depth(int begin) {
Node
&
Node
::
Folder
(
int
size
,
std
::
string
type
,
std
::
map
<
std
::
string
,
std
::
pair
<
std
::
string
,
std
::
string
>>
change
,
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>>
change
,
std
::
vector
<
std
::
shared_ptr
<
Node
>>
*
removed_nodes
)
{
std
::
shared_ptr
<
framework
::
OpDesc
>
op_desc
=
std
::
make_shared
<
framework
::
OpDesc
>
();
...
...
@@ -109,12 +111,15 @@ Node &Node::Folder(
void
Node
::
Folder
(
std
::
shared_ptr
<
framework
::
OpDesc
>
op_desc
,
std
::
vector
<
std
::
shared_ptr
<
Node
>>
*
outputs
,
int
index
,
std
::
map
<
std
::
string
,
std
::
pair
<
std
::
string
,
std
::
string
>>
*
change
,
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>>
*
change
,
Node
*
begin_node
,
std
::
vector
<
std
::
shared_ptr
<
Node
>>
*
removed_nodes
)
{
if
(
change
->
find
(
this
->
type_
)
!=
change
->
end
())
{
auto
change_pair
=
(
*
change
)[
this
->
type_
];
op_desc
->
GetInputs
()[
change_pair
.
second
]
=
this
->
op_desc_
->
GetInputs
()[
change_pair
.
first
];
auto
change_pairs
=
(
*
change
)[
this
->
type_
];
for
(
const
auto
&
change_pair
:
change_pairs
)
{
op_desc
->
GetInputs
()[
change_pair
.
second
]
=
this
->
op_desc_
->
GetInputs
()[
change_pair
.
first
];
}
}
for
(
auto
&
attr_pair
:
this
->
op_desc_
->
attrs_
)
{
...
...
src/framework/program/program-optimize/node.h
浏览文件 @
c68dd38e
...
...
@@ -17,6 +17,7 @@ limitations under the License. */
#include <cinttypes>
#include <map>
#include <string>
#include <utility>
#include <vector>
#include "common/log.h"
#include "framework/program/op_desc.h"
...
...
@@ -43,7 +44,8 @@ class Node {
int
Depth
(
int
begin
=
0
);
Node
&
Folder
(
int
size
,
std
::
string
type
,
std
::
map
<
std
::
string
,
std
::
pair
<
std
::
string
,
std
::
string
>>
change_map
,
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>>
change
,
std
::
vector
<
std
::
shared_ptr
<
Node
>>
*
removed_nodes
);
std
::
vector
<
std
::
shared_ptr
<
framework
::
OpDesc
>>
OpDescs
(
int
size
);
std
::
shared_ptr
<
framework
::
OpDesc
>
OpDescOfNode
()
{
return
op_desc_
;
}
...
...
@@ -56,7 +58,8 @@ class Node {
void
Folder
(
std
::
shared_ptr
<
framework
::
OpDesc
>
op_desc
,
std
::
vector
<
std
::
shared_ptr
<
Node
>>
*
outputs
,
int
index
,
std
::
map
<
std
::
string
,
std
::
pair
<
std
::
string
,
std
::
string
>>
*
change
,
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>>
*
change
,
Node
*
begin_node
,
std
::
vector
<
std
::
shared_ptr
<
Node
>>
*
removed_nodes
);
std
::
shared_ptr
<
framework
::
OpDesc
>
op_desc_
;
#ifdef PADDLE_MOBILE_DEBUG
...
...
src/operators/feed_op.h
浏览文件 @
c68dd38e
...
...
@@ -50,6 +50,8 @@ USE_OP_CPU(feed);
REGISTER_OPERATOR_CPU
(
feed
,
ops
::
FeedOp
);
#endif
#ifdef PADDLE_MOBILE_MALI_GPU
USE_OP_MALI_GPU
(
feed
);
REGISTER_OPERATOR_MALI_GPU
(
feed
,
ops
::
FeedOp
);
#endif
#ifdef PADDLE_MOBILE_FPGA
#endif
...
...
src/operators/fetch_op.h
浏览文件 @
c68dd38e
...
...
@@ -50,6 +50,8 @@ USE_OP_CPU(fetch);
REGISTER_OPERATOR_CPU
(
fetch
,
ops
::
FetchOp
);
#endif
#ifdef PADDLE_MOBILE_MALI_GPU
USE_OP_MALI_GPU
(
fetch
);
REGISTER_OPERATOR_MALI_GPU
(
fetch
,
ops
::
FetchOp
);
#endif
#ifdef PADDLE_MOBILE_FPGA
#endif
...
...
src/operators/fusion_conv_add.cpp
浏览文件 @
c68dd38e
...
...
@@ -54,6 +54,8 @@ USE_OP_CPU(conv_add);
REGISTER_OPERATOR_CPU
(
conv_add
,
ops
::
FusionConvAddOp
);
#endif
#ifdef PADDLE_MOBILE_MALI_GPU
USE_OP_MALI_GPU
(
conv_add
);
REGISTER_OPERATOR_MALI_GPU
(
conv_add
,
ops
::
FusionConvAddOp
);
#endif
#ifdef PADDLE_MOBILE_FPGA
#endif
...
...
src/operators/fusion_conv_add.h
浏览文件 @
c68dd38e
...
...
@@ -40,7 +40,7 @@ class FusionConvAddMatcher : public framework::FusionOpMatcher {
vector
<
std
::
shared_ptr
<
framework
::
OpDesc
>>
origin_descs
=
node
->
OpDescs
(
node_
.
Depth
());
node
->
Folder
(
node_
.
Depth
(),
Type
(),
{{
G_OP_TYPE_ELEMENTWISE_ADD
,
{
"Y"
,
"Y"
}}},
removed_nodes
);
{{
G_OP_TYPE_ELEMENTWISE_ADD
,
{
{
"Y"
,
"Y"
}
}}},
removed_nodes
);
}
std
::
string
Type
()
{
return
G_OP_TYPE_CONV_ADD
;
}
...
...
@@ -68,11 +68,13 @@ class FusionConvAddOp : public framework::OperatorWithKernel<
};
#ifdef PADDLE_MOBILE_CPU
#ifndef CONV_ADD_REGISTER
static
framework
::
FusionOpRegistrar
convadd_registrar
(
new
FusionConvAddMatcher
());
#define CONV_ADD_REGISTER
#endif
#endif
#ifdef PADDLE_MOBILE_MALI_GPU
...
...
src/operators/fusion_conv_add_relu_op.h
浏览文件 @
c68dd38e
...
...
@@ -36,7 +36,7 @@ class FusionConvAddReluOpMatcher : public framework::FusionOpMatcher {
framework
::
Node
*
node
,
std
::
vector
<
std
::
shared_ptr
<
framework
::
Node
>>
*
removed_nodes
)
{
node
->
Folder
(
node_
.
Depth
(),
Type
(),
{{
G_OP_TYPE_ELEMENTWISE_ADD
,
{
"Y"
,
"Y"
}}},
removed_nodes
);
{{
G_OP_TYPE_ELEMENTWISE_ADD
,
{
{
"Y"
,
"Y"
}
}}},
removed_nodes
);
}
std
::
string
Type
()
{
return
G_OP_TYPE_FUSION_CONV_ADD_RELU
;
}
};
...
...
@@ -65,11 +65,11 @@ class FusionConvAddReluOp : public framework::OperatorWithKernel<
#ifdef PADDLE_MOBILE_CPU
#ifndef CONV_ADD_RELU_REGISTER
#define CONV_ADD_RELU_REGISTER
//
#ifndef CONV_ADD_RELU_REGISTER
//
#define CONV_ADD_RELU_REGISTER
// static framework::FusionOpRegistrar fusion_conv_add_relu_registrar(new
// FusionConvAddReluOpMatcher());
#endif
//
#endif
#endif
#ifdef PADDLE_MOBILE_MALI_GPU
...
...
src/operators/fusion_fc_op.h
浏览文件 @
c68dd38e
...
...
@@ -38,7 +38,7 @@ class FusionFcMatcher : public framework::FusionOpMatcher {
framework
::
Node
*
node
,
std
::
vector
<
std
::
shared_ptr
<
framework
::
Node
>>
*
removed_nodes
)
{
node
->
Folder
(
node_
.
Depth
(),
Type
(),
{{
G_OP_TYPE_ELEMENTWISE_ADD
,
{
"Y"
,
"Z"
}}},
removed_nodes
);
{{
G_OP_TYPE_ELEMENTWISE_ADD
,
{
{
"Y"
,
"Z"
}
}}},
removed_nodes
);
}
std
::
string
Type
()
{
return
G_OP_TYPE_FC
;
}
...
...
@@ -66,17 +66,21 @@ class FusionFcOp
};
#ifdef PADDLE_MOBILE_CPU
#ifndef CONV_CPU_REGISTER
#define CONV_CPU_REGISTER
static
framework
::
FusionOpRegistrar
fc_registrar
(
new
FusionFcMatcher
());
#endif
#endif
#ifdef PADDLE_MOBILE_MALI_GPU
#ifndef CONV_CPU_REGISTER
#define CONV_CPU_REGISTER
static
framework
::
FusionOpRegistrar
fc_registrar
(
new
FusionFcMatcher
());
#endif
#endif
#ifdef PADDLE_MOBILE_FPGA
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录