Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
d886718b
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看板
未验证
提交
d886718b
编写于
11月 01, 2019
作者:
L
liu zhengxi
提交者:
GitHub
11月 01, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "refactor: BindTargets and ExcludeTargets, test=release/v2.0.0 (#2329)" (#2330)
This reverts commit
19f2ede2
.
上级
19f2ede2
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
42 addition
and
81 deletion
+42
-81
lite/api/paddle_place.cc
lite/api/paddle_place.cc
+0
-32
lite/api/paddle_place.h
lite/api/paddle_place.h
+0
-12
lite/core/mir/fusion/conv_bn_fuse_pass.cc
lite/core/mir/fusion/conv_bn_fuse_pass.cc
+1
-2
lite/core/mir/pass.h
lite/core/mir/pass.h
+2
-27
lite/core/mir/pass_registry.h
lite/core/mir/pass_registry.h
+0
-4
lite/core/mir/pass_utils.cc
lite/core/mir/pass_utils.cc
+39
-4
未找到文件。
lite/api/paddle_place.cc
浏览文件 @
d886718b
...
@@ -113,37 +113,5 @@ const std::string& DataLayoutRepr(DataLayoutType layout) {
...
@@ -113,37 +113,5 @@ const std::string& DataLayoutRepr(DataLayoutType layout) {
return
datalayout2string
[
x
];
return
datalayout2string
[
x
];
}
}
std
::
set
<
TargetType
>
ExpandValidTargets
(
TargetType
target
)
{
static
const
std
::
set
<
TargetType
>
valid_set
({
TARGET
(
kX86
),
TARGET
(
kCUDA
),
TARGET
(
kARM
),
TARGET
(
kOpenCL
),
TARGET
(
kNPU
),
TARGET
(
kXPU
),
TARGET
(
kFPGA
)});
if
(
target
==
TARGET
(
kAny
))
{
return
valid_set
;
}
return
std
::
set
<
TargetType
>
({
target
});
}
std
::
set
<
PrecisionType
>
ExpandValidPrecisions
(
PrecisionType
precision
)
{
static
const
std
::
set
<
PrecisionType
>
valid_set
(
{
PRECISION
(
kFloat
),
PRECISION
(
kInt8
),
PRECISION
(
kFP16
),
PRECISION
(
kAny
)});
if
(
precision
==
PRECISION
(
kAny
))
{
return
valid_set
;
}
return
std
::
set
<
PrecisionType
>
({
precision
});
}
std
::
set
<
DataLayoutType
>
ExpandValidLayouts
(
DataLayoutType
layout
)
{
static
const
std
::
set
<
DataLayoutType
>
valid_set
(
{
DATALAYOUT
(
kNCHW
),
DATALAYOUT
(
kAny
),
DATALAYOUT
(
kNHWC
)});
if
(
layout
==
DATALAYOUT
(
kAny
))
{
return
valid_set
;
}
return
std
::
set
<
DataLayoutType
>
({
layout
});
}
}
// namespace lite_api
}
// namespace lite_api
}
// namespace paddle
}
// namespace paddle
lite/api/paddle_place.h
浏览文件 @
d886718b
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
// limitations under the License.
// limitations under the License.
#pragma once
#pragma once
#include <set>
#include <string>
#include <string>
// Generic helper definitions for shared library support
// Generic helper definitions for shared library support
...
@@ -125,17 +124,6 @@ const std::string& PrecisionRepr(PrecisionType precision);
...
@@ -125,17 +124,6 @@ const std::string& PrecisionRepr(PrecisionType precision);
const
std
::
string
&
DataLayoutRepr
(
DataLayoutType
layout
);
const
std
::
string
&
DataLayoutRepr
(
DataLayoutType
layout
);
// Get a set of all the elements represented by the target.
std
::
set
<
TargetType
>
ExpandValidTargets
(
TargetType
target
=
TARGET
(
kAny
));
// Get a set of all the elements represented by the precision.
std
::
set
<
PrecisionType
>
ExpandValidPrecisions
(
PrecisionType
precision
=
PRECISION
(
kAny
));
// Get a set of all the elements represented by the layout.
std
::
set
<
DataLayoutType
>
ExpandValidLayouts
(
DataLayoutType
layout
=
DATALAYOUT
(
kAny
));
/*
/*
* Place specifies the execution context of a Kernel or input/output for a
* Place specifies the execution context of a Kernel or input/output for a
* kernel. It is used to make the analysis of the MIR more clear and accurate.
* kernel. It is used to make the analysis of the MIR more clear and accurate.
...
...
lite/core/mir/fusion/conv_bn_fuse_pass.cc
浏览文件 @
d886718b
...
@@ -44,5 +44,4 @@ void ConvBNFusePass::Apply(const std::unique_ptr<SSAGraph>& graph) {
...
@@ -44,5 +44,4 @@ void ConvBNFusePass::Apply(const std::unique_ptr<SSAGraph>& graph) {
}
// namespace paddle
}
// namespace paddle
REGISTER_MIR_PASS
(
lite_conv_bn_fuse_pass
,
paddle
::
lite
::
mir
::
ConvBNFusePass
)
REGISTER_MIR_PASS
(
lite_conv_bn_fuse_pass
,
paddle
::
lite
::
mir
::
ConvBNFusePass
)
.
BindTargets
({
TARGET
(
kAny
)})
.
BindTargets
({
TARGET
(
kAny
)});
.
ExcludeTargets
({
TARGET
(
kX86
)});
lite/core/mir/pass.h
浏览文件 @
d886718b
...
@@ -49,35 +49,10 @@ class Pass {
...
@@ -49,35 +49,10 @@ class Pass {
// Some passes only apply to qualified targets, which need to be explicitly
// Some passes only apply to qualified targets, which need to be explicitly
// declared.
// declared.
// Bind the target. At runtime, there must be one device in the bound targets.
// Bind targets. At runtime, there must be one device in the bound targets.
void
BindTargets
(
const
std
::
set
<
TargetType
>&
targets
)
{
void
BindTargets
(
const
std
::
set
<
TargetType
>&
targets
)
{
std
::
set
<
TargetType
>
res
;
bound_targets_
=
targets
;
for
(
const
auto
&
target
:
targets
)
{
const
std
::
set
<
TargetType
>&
universe
=
ExpandValidTargets
(
target
);
std
::
set_union
(
bound_targets_
.
begin
(),
bound_targets_
.
end
(),
universe
.
begin
(),
universe
.
end
(),
std
::
inserter
(
res
,
res
.
begin
()));
}
bound_targets_
=
res
;
}
// Exclude targets. At runtime, there must be one device in the bound targets.
void
ExcludeTargets
(
const
std
::
set
<
TargetType
>&
targets
)
{
std
::
set
<
TargetType
>
res
;
for
(
const
auto
&
target
:
targets
)
{
const
std
::
set
<
TargetType
>&
universe
=
ExpandValidTargets
(
target
);
std
::
set_difference
(
bound_targets_
.
begin
(),
bound_targets_
.
end
(),
universe
.
begin
(),
universe
.
end
(),
std
::
inserter
(
res
,
res
.
begin
()));
}
bound_targets_
=
res
;
}
}
// Get all bound targets.
// Get all bound targets.
const
std
::
set
<
TargetType
>&
Targets
()
const
{
return
bound_targets_
;
}
const
std
::
set
<
TargetType
>&
Targets
()
const
{
return
bound_targets_
;
}
...
...
lite/core/mir/pass_registry.h
浏览文件 @
d886718b
...
@@ -34,10 +34,6 @@ class PassRegistry {
...
@@ -34,10 +34,6 @@ class PassRegistry {
pass_
->
BindTargets
(
targets
);
pass_
->
BindTargets
(
targets
);
return
*
this
;
return
*
this
;
}
}
PassRegistry
&
ExcludeTargets
(
const
std
::
set
<
TargetType
>&
targets
)
{
pass_
->
ExcludeTargets
(
targets
);
return
*
this
;
}
PassRegistry
&
BindKernel
(
const
std
::
string
&
name
,
PassRegistry
&
BindKernel
(
const
std
::
string
&
name
,
const
lite_api
::
Place
&
place
)
{
const
lite_api
::
Place
&
place
)
{
pass_
->
BindKernel
(
name
,
place
);
pass_
->
BindKernel
(
name
,
place
);
...
...
lite/core/mir/pass_utils.cc
浏览文件 @
d886718b
...
@@ -23,17 +23,52 @@ namespace lite {
...
@@ -23,17 +23,52 @@ namespace lite {
using
lite_api
::
Place
;
using
lite_api
::
Place
;
namespace
{
template
<
typename
T
>
class
Types
final
{
public:
explicit
Types
(
const
std
::
set
<
T
>&
types
)
:
types_
(
types
)
{}
~
Types
()
=
default
;
std
::
set
<
T
>
ValidSet
(
const
T
&
element
)
const
;
private:
const
std
::
set
<
T
>
types_
;
};
template
<
typename
T
>
std
::
set
<
T
>
Types
<
T
>::
ValidSet
(
const
T
&
element
)
const
{
if
(
element
==
T
::
kAny
)
{
return
types_
;
}
else
if
(
element
==
T
::
kUnk
)
{
LOG
(
FATAL
)
<<
"The type of the kernel's place is unknown."
;
}
return
std
::
set
<
T
>
({
element
});
}
void
ExpandPlaces
(
std
::
set
<
Place
>*
places
,
const
Place
&
place
)
{
void
ExpandPlaces
(
std
::
set
<
Place
>*
places
,
const
Place
&
place
)
{
for
(
const
auto
&
target
:
lite_api
::
ExpandValidTargets
(
place
.
target
))
{
static
const
Types
<
TargetType
>
target_set
({
TARGET
(
kHost
),
for
(
const
auto
&
precision
:
TARGET
(
kX86
),
lite_api
::
ExpandValidPrecisions
(
place
.
precision
))
{
TARGET
(
kCUDA
),
for
(
const
auto
&
layout
:
lite_api
::
ExpandValidLayouts
(
place
.
layout
))
{
TARGET
(
kARM
),
TARGET
(
kOpenCL
),
TARGET
(
kNPU
),
TARGET
(
kFPGA
)});
static
const
Types
<
PrecisionType
>
precision_set
(
{
PRECISION
(
kFloat
),
PRECISION
(
kInt8
),
PRECISION
(
kFP16
),
PRECISION
(
kAny
)});
static
const
Types
<
DataLayoutType
>
layout_set
(
{
DATALAYOUT
(
kNCHW
),
DATALAYOUT
(
kAny
),
DATALAYOUT
(
kNHWC
)});
for
(
const
auto
&
target
:
target_set
.
ValidSet
(
place
.
target
))
{
for
(
const
auto
&
precision
:
precision_set
.
ValidSet
(
place
.
precision
))
{
for
(
const
auto
&
layout
:
layout_set
.
ValidSet
(
place
.
layout
))
{
places
->
insert
(
Place
(
target
,
precision
,
layout
));
places
->
insert
(
Place
(
target
,
precision
,
layout
));
}
}
}
}
}
}
}
}
}
// anonymous namespace
bool
KernelRegistered
(
const
std
::
string
name
,
const
Place
&
place
)
{
bool
KernelRegistered
(
const
std
::
string
name
,
const
Place
&
place
)
{
std
::
set
<
Place
>
places
;
std
::
set
<
Place
>
places
;
ExpandPlaces
(
&
places
,
place
);
ExpandPlaces
(
&
places
,
place
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录