Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
360b4013
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
360b4013
编写于
2月 26, 2020
作者:
H
huzhiqiang
提交者:
GitHub
2月 26, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[opencl]add pre_process attribute into layoutop (#3001)
上级
857b7116
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
52 addition
and
2 deletion
+52
-2
lite/api/cxx_api_impl.cc
lite/api/cxx_api_impl.cc
+7
-1
lite/core/mir/type_layout_cast_pass.cc
lite/core/mir/type_layout_cast_pass.cc
+28
-0
lite/core/mir/type_layout_cast_pass.h
lite/core/mir/type_layout_cast_pass.h
+9
-0
lite/core/optimizer.h
lite/core/optimizer.h
+4
-1
lite/operators/layout_op.cc
lite/operators/layout_op.cc
+3
-0
lite/operators/op_params.h
lite/operators/op_params.h
+1
-0
未找到文件。
lite/api/cxx_api_impl.cc
浏览文件 @
360b4013
...
...
@@ -35,7 +35,13 @@ void CxxPaddleApiImpl::Init(const lite_api::CxxConfig &config) {
Env
<
TARGET
(
kCUDA
)
>::
Init
();
#endif
auto
places
=
config
.
valid_places
();
raw_predictor_
.
Build
(
config
,
places
);
std
::
vector
<
std
::
string
>
passes
{};
auto
use_layout_preprocess_pass
=
config
.
model_dir
().
find
(
"OPENCL_PRE_PRECESS"
);
if
(
use_layout_preprocess_pass
!=
std
::
string
::
npos
)
{
passes
=
{
"type_layout_cast_preprocess_pass"
};
}
raw_predictor_
.
Build
(
config
,
places
,
passes
);
mode_
=
config
.
power_mode
();
threads_
=
config
.
threads
();
...
...
lite/core/mir/type_layout_cast_pass.cc
浏览文件 @
360b4013
...
...
@@ -204,6 +204,28 @@ void TypeLayoutTransformPass::SetValidPlaces(
valid_places_
=
valid_places
;
}
void
OpenCLTypeLayoutTransformPass
::
Apply
(
const
std
::
unique_ptr
<
SSAGraph
>&
graph
)
{
// Start from inputs of the graph, those should have place set.
VLOG
(
4
)
<<
"
\n
"
<<
Visualize
(
graph
.
get
());
std
::
list
<
Node
*>
nodes
;
for
(
auto
&
node
:
graph
->
StmtTopologicalOrder
())
{
nodes
.
push_back
(
node
);
}
VLOG
(
4
)
<<
"nodes.size():"
<<
nodes
.
size
();
for
(
auto
&
node
:
nodes
)
{
VLOG
(
4
)
<<
"!node->IsStmt():"
<<
!
node
->
IsStmt
();
if
(
!
node
->
IsStmt
()
||
node
->
AsStmt
().
op_type
()
==
"while"
)
continue
;
if
(
node
->
AsStmt
().
op_type
()
==
"layout"
)
{
auto
new_op
=
node
->
AsStmt
().
mutable_op_info
();
int
process_type
=
1
;
new_op
->
SetAttr
(
"process_type"
,
process_type
);
}
}
VLOG
(
4
)
<<
"
\n
"
<<
Visualize
(
graph
.
get
());
}
}
// namespace mir
}
// namespace lite
}
// namespace paddle
...
...
@@ -213,3 +235,9 @@ REGISTER_MIR_PASS(type_layout_cast_pass,
.
BindTargets
({
TARGET
(
kAny
)})
.
BindKernel
(
"layout_once"
)
.
BindKernel
(
"layout"
);
REGISTER_MIR_PASS
(
type_layout_cast_preprocess_pass
,
paddle
::
lite
::
mir
::
OpenCLTypeLayoutTransformPass
)
.
BindTargets
({
TARGET
(
kAny
)})
.
BindKernel
(
"layout_once"
)
.
BindKernel
(
"layout"
);
lite/core/mir/type_layout_cast_pass.h
浏览文件 @
360b4013
...
...
@@ -57,6 +57,15 @@ class TypeLayoutTransformPass : public ProgramPass {
std
::
vector
<
Place
>
valid_places_
;
};
// add preprocess and postprocess attribute for layout op
class
OpenCLTypeLayoutTransformPass
:
public
ProgramPass
{
public:
void
Apply
(
const
std
::
unique_ptr
<
SSAGraph
>&
graph
)
override
;
private:
std
::
vector
<
Place
>
valid_places_
;
};
}
// namespace mir
}
// namespace lite
}
// namespace paddle
lite/core/optimizer.h
浏览文件 @
360b4013
...
...
@@ -53,7 +53,7 @@ class Optimizer {
SpecifyKernelPickTactic
(
kernel_pick_factor
);
InitTargetTypeTransformPass
();
if
(
passes
.
empty
())
{
if
(
passes
.
empty
()
||
passes
.
size
()
==
1
)
{
std
::
vector
<
std
::
string
>
passes_local
{
{
"lite_quant_dequant_fuse_pass"
,
//
"weight_quantization_preprocess_pass"
,
//
...
...
@@ -112,6 +112,9 @@ class Optimizer {
"runtime_context_assign_pass"
,
"argument_type_display_pass"
,
"memory_optimize_pass"
}};
if
(
passes
.
size
()
==
1
)
{
passes_local
.
push_back
(
passes
[
0
]);
}
RunPasses
(
passes_local
);
}
else
{
RunPasses
(
passes
);
...
...
lite/operators/layout_op.cc
浏览文件 @
360b4013
...
...
@@ -35,6 +35,9 @@ bool LayoutOp::AttachImpl(const cpp::OpDesc &opdesc,
auto
out
=
opdesc
.
Output
(
"Out"
).
front
();
param_
.
x
=
GetTensor
(
scope
,
x
);
param_
.
y
=
GetMutableTensor
(
scope
,
out
);
if
(
opdesc
.
HasAttr
(
"process_type"
))
{
param_
.
process_type
=
opdesc
.
GetAttr
<
int
>
(
"process_type"
);
}
return
true
;
}
std
::
string
LayoutOp
::
DebugString
()
const
{
return
"layout_op"
;
}
...
...
lite/operators/op_params.h
浏览文件 @
360b4013
...
...
@@ -62,6 +62,7 @@ struct IoCopyParam {
struct
LayoutParam
{
const
lite
::
Tensor
*
x
{};
lite
::
Tensor
*
y
{};
int
process_type
{
0
};
};
struct
CalibParam
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录