Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
3b436c62
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看板
提交
3b436c62
编写于
5月 20, 2020
作者:
D
dingminghui
提交者:
jackzhang235
5月 21, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(cast): use mlu cast as default
上级
1ebad864
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
9 deletion
+10
-9
lite/core/mir/mlu_postprocess_pass.cc
lite/core/mir/mlu_postprocess_pass.cc
+5
-5
lite/kernels/mlu/subgraph_compute.h
lite/kernels/mlu/subgraph_compute.h
+5
-4
未找到文件。
lite/core/mir/mlu_postprocess_pass.cc
浏览文件 @
3b436c62
...
...
@@ -888,14 +888,14 @@ void MLUPostprocessPass::Apply(const std::unique_ptr<SSAGraph>& graph) {
#endif
g_stream_id
=
static_cast
<
int
>
(
reinterpret_cast
<
int64_t
>
(
graph
.
get
()));
bool
use_mlu_cast
=
GetBoolFromEnv
(
"LIT
E_MLU_CAST"
);
ModifyValidPlaces
(
graph
.
get
(),
us
e_mlu_cast
);
bool
disable_mlu_cast
=
GetBoolFromEnv
(
"LITE_DISABL
E_MLU_CAST"
);
ModifyValidPlaces
(
graph
.
get
(),
!
disabl
e_mlu_cast
);
// insert io_copy, layout and precision cast of subgraph's inputs and outputs
for
(
auto
&
node
:
graph
->
mutable_nodes
())
{
if
(
node
.
IsStmt
()
&&
node
.
AsStmt
().
op_type
()
==
"subgraph"
)
{
const
Type
*
subgraph_arg_type
=
nullptr
;
GetSubgraphOpArgType
(
&
node
,
&
subgraph_arg_type
,
graph
.
get
());
if
(
us
e_mlu_cast
)
{
if
(
!
disabl
e_mlu_cast
)
{
AdjustSubgraph
(
&
node
,
subgraph_arg_type
);
}
...
...
@@ -903,14 +903,14 @@ void MLUPostprocessPass::Apply(const std::unique_ptr<SSAGraph>& graph) {
for
(
auto
p_in
:
links_tmp
)
{
if
(
NeedInsert
(
p_in
,
subgraph_arg_type
))
{
InsertBefore
(
graph
.
get
(),
p_in
,
&
node
,
subgraph_arg_type
,
us
e_mlu_cast
);
graph
.
get
(),
p_in
,
&
node
,
subgraph_arg_type
,
!
disabl
e_mlu_cast
);
}
}
links_tmp
.
assign
(
node
.
outlinks
.
begin
(),
node
.
outlinks
.
end
());
for
(
auto
p_out
:
links_tmp
)
{
if
(
NeedInsert
(
p_out
,
subgraph_arg_type
))
{
InsertAfter
(
graph
.
get
(),
p_out
,
&
node
,
subgraph_arg_type
,
us
e_mlu_cast
);
graph
.
get
(),
p_out
,
&
node
,
subgraph_arg_type
,
!
disabl
e_mlu_cast
);
}
}
}
...
...
lite/kernels/mlu/subgraph_compute.h
浏览文件 @
3b436c62
...
...
@@ -343,7 +343,7 @@ class SubgraphEngine : public subgraph::Engine {
CHECK_EQ
(
graph_input
->
size
(),
origin_itensors_
.
size
());
CHECK_EQ
(
graph_output
->
size
(),
origin_otensors_
.
size
());
bool
use_mlu_cast
=
GetBoolFromEnv
(
"LIT
E_MLU_CAST"
);
bool
disable_mlu_cast
=
GetBoolFromEnv
(
"LITE_DISABL
E_MLU_CAST"
);
if
(
!
disable_batch_size_changeable_
)
{
std
::
vector
<
std
::
shared_ptr
<
paddle
::
lite
::
subgraph
::
mlu
::
MLUTensor
>>
...
...
@@ -386,7 +386,7 @@ class SubgraphEngine : public subgraph::Engine {
for
(
size_t
i
=
0
;
i
<
origin_otensors_
.
size
();
++
i
)
{
// origin_otensors_[i]->Resize(new_output_size.at(i));
graph_out
[
i
]
->
set_mlu_ptr
(
GetOutputDataPtr
(
origin_otensors_
[
i
],
us
e_mlu_cast
));
GetOutputDataPtr
(
origin_otensors_
[
i
],
!
disabl
e_mlu_cast
));
}
}
else
{
graph_out
.
reserve
(
origin_otensors_
.
size
());
...
...
@@ -395,7 +395,8 @@ class SubgraphEngine : public subgraph::Engine {
paddle
::
lite
::
subgraph
::
mlu
::
MLUTensor
tmp
(
origin_otensors_
[
i
]
->
dims
().
Vectorize
());
tmp
.
set_mlu_dtype
(
graph_output
->
at
(
i
)
->
dtype
());
tmp
.
set_mlu_ptr
(
GetOutputDataPtr
(
origin_otensors_
[
i
],
use_mlu_cast
));
tmp
.
set_mlu_ptr
(
GetOutputDataPtr
(
origin_otensors_
[
i
],
!
disable_mlu_cast
));
graph_out
.
push_back
(
std
::
make_shared
<
paddle
::
lite
::
subgraph
::
mlu
::
MLUTensor
>
(
tmp
));
}
...
...
@@ -410,7 +411,7 @@ class SubgraphEngine : public subgraph::Engine {
for
(
size_t
i
=
0
;
i
<
origin_otensors_
.
size
();
++
i
)
{
origin_otensors_
[
i
]
->
Resize
(
graph_output
->
at
(
i
)
->
get_origin_shape
());
graph_output
->
at
(
i
)
->
set_mlu_ptr
(
GetOutputDataPtr
(
origin_otensors_
[
i
],
us
e_mlu_cast
));
GetOutputDataPtr
(
origin_otensors_
[
i
],
!
disabl
e_mlu_cast
));
}
graph
->
Compute
(
forward_param
,
exec_queue
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录