Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
0e77cd63
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看板
提交
0e77cd63
编写于
3月 09, 2020
作者:
Z
zhupengyang
提交者:
GitHub
3月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avoid reusing non-tensor in memery_optimize_pass (#3111)
上级
c79a0954
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
46 addition
and
28 deletion
+46
-28
lite/core/mir/memory_optimize_pass.cc
lite/core/mir/memory_optimize_pass.cc
+8
-0
lite/kernels/arm/elementwise_compute.cc
lite/kernels/arm/elementwise_compute.cc
+32
-22
lite/operators/op_params.h
lite/operators/op_params.h
+6
-6
未找到文件。
lite/core/mir/memory_optimize_pass.cc
浏览文件 @
0e77cd63
...
...
@@ -78,6 +78,7 @@ void MemoryOptimizePass::CollectLifeCycleByDevice(
// Collect the invalid input and output variables that will not be reused.
std
::
unordered_set
<
std
::
string
>
invalid_var_names
;
for
(
auto
&
op_node
:
graph
->
StmtTopologicalOrder
())
{
// variables of invalid_op_nodes wil not be reused
if
(
!
op_node
->
IsStmt
())
continue
;
auto
op_info
=
op_node
->
AsStmt
().
op_info
();
auto
op_type
=
op_info
->
Type
();
...
...
@@ -120,6 +121,13 @@ void MemoryOptimizePass::CollectLifeCycleByDevice(
}
}
// non-tensor(like tensor_array) variables will not be reused
for
(
auto
&
node
:
graph
->
nodes
())
{
if
(
node
.
IsArg
()
&&
!
node
.
arg
()
->
type
->
IsTensor
())
{
invalid_var_names
.
insert
(
node
.
arg
()
->
name
);
}
}
for
(
auto
&
op_node
:
graph
->
StmtTopologicalOrder
())
{
if
(
op_node
->
IsStmt
())
{
std
::
vector
<
Node
*>
var_nodes
(
op_node
->
inlinks
.
begin
(),
...
...
lite/kernels/arm/elementwise_compute.cc
浏览文件 @
0e77cd63
...
...
@@ -182,30 +182,30 @@ void ElementwiseSubActivationCompute::Run() {
template
<
typename
T
,
PrecisionType
PType
>
void
ElementwiseMulCompute
<
T
,
PType
>::
Run
()
{
auto
&
param
=
this
->
template
Param
<
operators
::
ElementwiseParam
>();
if
(
param
.
X
->
precision
()
==
PRECISION
(
kFloat
))
{
auto
*
x_data
=
param
.
X
->
template
data
<
float
>();
auto
*
y_data
=
param
.
Y
->
template
data
<
float
>();
auto
*
out_data
=
param
.
Out
->
template
mutable_data
<
float
>();
auto
*
x_data
=
param
.
X
->
template
data
<
T
>();
auto
*
y_data
=
param
.
Y
->
template
data
<
T
>();
auto
*
out_data
=
param
.
Out
->
template
mutable_data
<
T
>();
int
axis
=
param
.
axis
;
auto
x_dims
=
param
.
X
->
dims
();
auto
y_dims
=
param
.
Y
->
dims
();
int
pre
,
n
,
post
;
if
(
x_dims
.
size
()
<
y_dims
.
size
()
&&
is_broadcast
(
y_dims
,
x_dims
,
axis
,
&
pre
,
&
n
,
&
post
))
{
lite
::
arm
::
math
::
elementwise_mul_broadcast
<
float
>
(
lite
::
arm
::
math
::
elementwise_mul_broadcast
<
T
>
(
y_data
,
x_data
,
out_data
,
pre
,
n
,
post
);
}
else
if
(
is_broadcast
(
x_dims
,
y_dims
,
axis
,
&
pre
,
&
n
,
&
post
))
{
lite
::
arm
::
math
::
elementwise_mul_broadcast
<
float
>
(
lite
::
arm
::
math
::
elementwise_mul_broadcast
<
T
>
(
x_data
,
y_data
,
out_data
,
pre
,
n
,
post
);
}
else
{
lite
::
arm
::
math
::
elementwise_mul
<
float
>
(
lite
::
arm
::
math
::
elementwise_mul
<
T
>
(
x_data
,
y_data
,
out_data
,
x_dims
.
production
());
}
}
else
if
(
param
.
X
->
precision
()
==
PRECISION
(
kInt64
))
{
}
template
<
>
void
ElementwiseMulCompute
<
int64_t
,
PRECISION
(
kInt64
)
>::
Run
()
{
auto
&
param
=
this
->
template
Param
<
operators
::
ElementwiseParam
>();
lite
::
arm
::
math
::
elementwise_compute_basic
<
int64_t
>
(
param
,
"mul"
,
""
);
}
else
{
LOG
(
FATAL
)
<<
"unsupport input type"
;
}
}
void
ElementwiseMulActivationCompute
::
Run
()
{
...
...
@@ -420,6 +420,16 @@ REGISTER_LITE_KERNEL(
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt32
))})
.
Finalize
();
using
elementwise_mul_int64
=
paddle
::
lite
::
kernels
::
arm
::
ElementwiseMulCompute
<
int64_t
,
PRECISION
(
kInt64
)
>
;
REGISTER_LITE_KERNEL
(
elementwise_mul
,
kARM
,
kInt64
,
kNCHW
,
elementwise_mul_int64
,
def
)
.
BindInput
(
"X"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt64
))})
.
BindInput
(
"Y"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt64
))})
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
kARM
),
PRECISION
(
kInt64
))})
.
Finalize
();
REGISTER_LITE_KERNEL
(
fusion_elementwise_mul_activation
,
kARM
,
...
...
lite/operators/op_params.h
浏览文件 @
0e77cd63
...
...
@@ -730,15 +730,15 @@ struct IncrementParam {
};
struct
WriteToArrayParam
{
const
lite
::
Tensor
*
X
{};
const
lite
::
Tensor
*
I
{};
std
::
vector
<
lite
::
Tensor
>*
Out
{};
const
lite
::
Tensor
*
X
{
nullptr
};
const
lite
::
Tensor
*
I
{
nullptr
};
std
::
vector
<
lite
::
Tensor
>*
Out
{
nullptr
};
};
struct
ReadFromArrayParam
{
const
std
::
vector
<
lite
::
Tensor
>*
X
{};
const
lite
::
Tensor
*
I
{};
lite
::
Tensor
*
Out
{};
const
std
::
vector
<
lite
::
Tensor
>*
X
{
nullptr
};
const
lite
::
Tensor
*
I
{
nullptr
};
lite
::
Tensor
*
Out
{
nullptr
};
};
struct
BeamSearchParam
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录