Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
86fd3b32
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
86fd3b32
编写于
11月 07, 2018
作者:
T
Tomasz Patejko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MKLDNN residual connections fuse pass: counting statistics added to the pass
上级
ee6f778b
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
44 addition
and
5 deletion
+44
-5
paddle/fluid/framework/ir/conv_elementwise_add_mkldnn_fuse_pass.h
...luid/framework/ir/conv_elementwise_add_mkldnn_fuse_pass.h
+44
-5
未找到文件。
paddle/fluid/framework/ir/conv_elementwise_add_mkldnn_fuse_pass.h
浏览文件 @
86fd3b32
...
...
@@ -21,11 +21,45 @@
#include "paddle/fluid/framework/ir/graph.h"
#include "paddle/fluid/framework/ir/graph_pattern_detector.h"
#include <boost/optional.hpp>
namespace
paddle
{
namespace
framework
{
namespace
ir
{
// poor replacement for C++17 std::optional and Boost.Optional
struct
InPlace
{};
InPlace
in_place
;
template
<
typename
T
>
class
Maybe
{
private:
typename
std
::
aligned_storage
<
sizeof
(
T
),
alignof
(
T
)
>::
type
data
;
bool
is_initialized
{
false
};
public:
template
<
typename
...
Args
>
explicit
Maybe
(
InPlace
,
Args
&&
...
args
)
{
new
(
&
data
)
T
(
std
::
forward
<
Args
>
(
args
)...);
is_initialized
=
true
;
}
Maybe
()
{}
operator
bool
()
{
return
is_initialized
;
}
T
&
value
()
{
return
*
reinterpret_cast
<
T
*>
(
&
data
);
}
~
Maybe
()
{
reinterpret_cast
<
T
*>
(
&
data
)
->~
T
();
}
};
template
<
typename
T
,
typename
...
Args
>
Maybe
<
T
>
MakeMaybe
(
Args
&&
...
args
)
{
return
Maybe
<
T
>
(
in_place
,
std
::
forward
<
Args
>
(
args
)...);
}
using
graph_ptr
=
std
::
unique_ptr
<
ir
::
Graph
>
;
using
GraphWithStats
=
std
::
pair
<
ir
::
Graph
*
,
Maybe
<
int
>>
;
void
CorrectGraphEdges
(
Graph
*
graph
,
Node
*
from
,
Node
*
to
);
bool
IsReachable
(
ir
::
Graph
*
graph
,
Node
*
from
,
Node
*
to
);
...
...
@@ -33,8 +67,10 @@ std::pair<bool, Node*> HasBias(const Node& op, const std::string& bias_name);
class
ResidualConnectionMKLDNNFusePass
:
public
FusePassBase
{
private:
graph_ptr
FuseConvAsX
(
const
std
::
string
&
name_scope_
,
graph_ptr
graph
)
const
;
graph_ptr
FuseConvAsY
(
const
std
::
string
&
name_scope_
,
graph_ptr
graph
)
const
;
GraphWithStats
FuseConvAsX
(
const
std
::
string
&
name_scope
,
const
GraphWithStats
&
graph_with_stats
)
const
;
GraphWithStats
FuseConvAsY
(
const
std
::
string
&
name_scope
,
const
GraphWithStats
&
graph_with_stats
)
const
;
template
<
typename
RetType
>
using
GetNodeFunc
=
...
...
@@ -48,12 +84,15 @@ class ResidualConnectionMKLDNNFusePass : public FusePassBase {
const
ElementwiseAddFunc
&
get_node_from_elementwise_add_op
,
const
CanFuseFunc
&
can_fuse_func
);
void
operator
()(
const
GraphPatternDetector
::
subgraph_t
&
subgraph
,
Graph
*
graph
);
int
get_stats
()
const
{
return
*
fusion_stats
;
}
private:
std
::
shared_ptr
<
int
>
fusion_stats
;
ConvFunc
get_node_from_conv_op
;
ElementwiseAddFunc
get_node_from_elementwise_add_op
;
CanFuseFunc
can_fuse_func
;
void
operator
()(
const
GraphPatternDetector
::
subgraph_t
&
subgraph
,
Graph
*
graph
);
};
public:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录