Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
128cdc5c
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
338
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看板
“af64f39bfd2ba99c2bba36926c5b45c4f2015609”上不存在“paddle/phi/kernels/affine_grid_grad_kernel.h”
提交
128cdc5c
编写于
5月 12, 2020
作者:
J
jackzhang235
提交者:
jackzhang235
5月 13, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add batch size unchangeable op's black list
上级
4af82042
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
50 addition
and
9 deletion
+50
-9
lite/kernels/mlu/bridges/graph.h
lite/kernels/mlu/bridges/graph.h
+3
-2
lite/kernels/mlu/subgraph_compute.h
lite/kernels/mlu/subgraph_compute.h
+47
-7
未找到文件。
lite/kernels/mlu/bridges/graph.h
浏览文件 @
128cdc5c
...
...
@@ -103,10 +103,11 @@ class Graph {
// return outputs_shape;
// }
void
AddInput
(
std
::
shared_ptr
<
MLUTensor
>
tensor
)
{
void
AddInput
(
std
::
shared_ptr
<
MLUTensor
>
tensor
,
bool
disable_batch_size_changeable
=
true
)
{
inputs_
.
push_back
(
tensor
->
mlu_tensor
());
input_tensors_
.
push_back
(
tensor
);
if
(
GetBoolFromEnv
(
"BATCH_SIZE_CHANGEABLE"
)
)
{
if
(
!
disable_batch_size_changeable
)
{
constexpr
int
input_dimNb
=
4
;
bool
input_dim_mutable
[
4
]
=
{
true
,
false
,
false
,
false
};
cnmlSetTensorDimMutable
(
...
...
lite/kernels/mlu/subgraph_compute.h
浏览文件 @
128cdc5c
...
...
@@ -50,7 +50,15 @@ class SubgraphEngine : public subgraph::Engine {
paddle
::
lite_api
::
PrecisionType
type
)
:
subgraph
::
Engine
(
ctx
,
block_idx
,
block_desc
,
input_names
,
output_names
,
scope
),
fp_type_
(
type
)
{}
fp_type_
(
type
)
{
VLOG
(
4
)
<<
"[MLU] PADDLE_LITE_MLU_SAVE_OFFLINE_MODEL is "
<<
GetBoolFromEnv
(
"PADDLE_LITE_MLU_SAVE_OFFLINE_MODEL"
);
VLOG
(
4
)
<<
"[MLU] PADDLE_LITE_MLU_DISABLE_BATCH_SIZE_CHANGEABLE is "
<<
GetBoolFromEnv
(
"PADDLE_LITE_MLU_DISABLE_BATCH_SIZE_CHANGEABLE"
);
if
(
GetBoolFromEnv
(
"PADDLE_LITE_MLU_DISABLE_BATCH_SIZE_CHANGEABLE"
))
{
disable_batch_size_changeable_
=
true
;
}
}
int
Build
()
{
// In order to attach all of the ops of the block desc, we need to build
...
...
@@ -83,7 +91,7 @@ class SubgraphEngine : public subgraph::Engine {
// used in batch changable situation
std
::
vector
<
std
::
vector
<
int64_t
>>
all_shape
;
for
(
auto
origin_itensor
:
origin_itensors_
)
{
if
(
GetBoolFromEnv
(
"BATCH_SIZE_CHANGEABLE"
)
)
{
if
(
!
disable_batch_size_changeable_
)
{
auto
iv
=
origin_itensor
->
dims
().
Vectorize
();
all_shape
.
push_back
(
iv
);
iv
.
erase
(
iv
.
begin
());
...
...
@@ -117,6 +125,21 @@ class SubgraphEngine : public subgraph::Engine {
protected:
int
BuildDeviceProgram
()
override
{
if
(
!
error_compile_batch_size_changeable_
&&
!
disable_batch_size_changeable_
)
{
int
status
=
BuildDeviceProgramImpl
();
if
(
subgraph
::
CHECK_SUCCESS
(
status
))
{
return
status
;
}
VLOG
(
4
)
<<
"[MLU] build batch_size changeable subgraph op failed, "
"changed to input_shape changeable"
;
}
error_compile_batch_size_changeable_
=
true
;
disable_batch_size_changeable_
=
true
;
return
BuildDeviceProgramImpl
();
}
int
BuildDeviceProgramImpl
()
{
int
status
=
0
;
auto
graph
=
std
::
make_shared
<
paddle
::
lite
::
subgraph
::
mlu
::
Graph
>
();
graph
->
SetFPType
(
fp_type_
);
...
...
@@ -131,7 +154,7 @@ class SubgraphEngine : public subgraph::Engine {
auto
data_type
=
input_tensor
->
precision
();
cnmlDataType_t
fp_type
=
PrecisionToDatatype
(
data_type
);
origin_itensors_
.
push_back
(
input_tensor
);
if
(
GetBoolFromEnv
(
"BATCH_SIZE_CHANGEABLE"
)
)
{
if
(
!
disable_batch_size_changeable_
)
{
auto
iv
=
input_tensor
->
dims
().
Vectorize
();
iv
.
erase
(
iv
.
begin
());
new_shape
.
push_back
(
iv
);
...
...
@@ -156,6 +179,16 @@ class SubgraphEngine : public subgraph::Engine {
auto
op
=
inst
.
op
();
CHECK
(
op
);
std
::
string
op_type
=
op
->
op_info
()
->
Type
();
if
(
!
disable_batch_size_changeable_
&&
std
::
find
(
unsupport_batch_size_changeable_op_type_
.
begin
(),
unsupport_batch_size_changeable_op_type_
.
end
(),
op_type
)
!=
unsupport_batch_size_changeable_op_type_
.
end
())
{
status
|=
subgraph
::
FAILED
;
VLOG
(
4
)
<<
"[MLU] found unsupported batch_size changeable op type: "
<<
op_type
;
return
status
;
}
op
->
CheckShape
();
const_cast
<
OpLite
*>
(
op
)
->
InferShape
();
if
(
!
bridges
.
Exists
(
op_type
,
TARGET
(
kMLU
)))
{
...
...
@@ -185,7 +218,8 @@ class SubgraphEngine : public subgraph::Engine {
}
}
for
(
auto
&
input_name
:
input_names_
)
{
graph
->
AddInput
(
graph
->
GetNode
(
input_name
));
graph
->
AddInput
(
graph
->
GetNode
(
input_name
),
disable_batch_size_changeable_
);
}
CHECK
(
!
origin_otensors_
.
empty
())
<<
"[MLU] no valid output names"
;
...
...
@@ -194,7 +228,7 @@ class SubgraphEngine : public subgraph::Engine {
auto
core_number
=
mlu_context
.
MLUCoreNumber
();
graph
->
Compile
(
core_version
,
core_number
);
shape_graph_map_
[
new_shape
]
=
graph
;
if
(
GetBoolFromEnv
(
"
SAVE_MLU
_OFFLINE_MODEL"
))
{
if
(
GetBoolFromEnv
(
"
PADDLE_LITE_MLU_SAVE
_OFFLINE_MODEL"
))
{
graph
->
GenOfflineModel
(
GetOfflineModName
());
}
return
status
;
...
...
@@ -289,7 +323,7 @@ class SubgraphEngine : public subgraph::Engine {
CHECK_EQ
(
graph_input
->
size
(),
origin_itensors_
.
size
());
CHECK_EQ
(
graph_output
->
size
(),
origin_otensors_
.
size
());
if
(
GetBoolFromEnv
(
"BATCH_SIZE_CHANGEABLE"
)
)
{
if
(
!
disable_batch_size_changeable_
)
{
std
::
vector
<
std
::
shared_ptr
<
paddle
::
lite
::
subgraph
::
mlu
::
MLUTensor
>>
graph_in
;
if
(
shape_tensor_map_in_
.
find
(
all_inputs_shape_
)
!=
...
...
@@ -405,6 +439,12 @@ class SubgraphEngine : public subgraph::Engine {
std
::
map
<
std
::
vector
<
std
::
vector
<
int64_t
>>
,
std
::
shared_ptr
<
paddle
::
lite
::
subgraph
::
mlu
::
Graph
>>
shape_graph_map_
{};
// enable batch size changeable by default, this cound be changed by
// environment variable PADDLE_LITE_MLU_DISABLE_BATCH_SIZE_CHANGEABLE and
// whether the op can be compiled with batch size changeable way
bool
disable_batch_size_changeable_
{
false
};
bool
error_compile_batch_size_changeable_
{
false
};
std
::
vector
<
std
::
string
>
unsupport_batch_size_changeable_op_type_
{
"concat"
};
// search output runtime MLUTensor for certain output shape when enable
// BATCH_SIZE_CHANGEABLE
std
::
map
<
std
::
vector
<
std
::
vector
<
int64_t
>>
,
...
...
@@ -419,7 +459,7 @@ class SubgraphEngine : public subgraph::Engine {
// BATCH_SIZE_CHANGEABLE
std
::
map
<
std
::
vector
<
std
::
vector
<
int64_t
>>
,
std
::
vector
<
std
::
vector
<
int64_t
>>>
in_out_shape_map_
{};
};
// namespace mlu
};
template
<
PrecisionType
Precision
>
class
SubgraphCompute
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录