Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
f4e06650
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看板
未验证
提交
f4e06650
编写于
11月 13, 2019
作者:
J
juncaipeng
提交者:
GitHub
11月 13, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix error for AxesTensorList in unsqueeze op, test=develop (#2411)
* fix error for AxesTensorList in unsqueeze op
上级
0ade1bc5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
5 addition
and
13 deletion
+5
-13
lite/operators/op_params.h
lite/operators/op_params.h
+1
-1
lite/operators/unsqueeze_op.cc
lite/operators/unsqueeze_op.cc
+2
-9
lite/tests/kernels/unsqueeze_compute_test.cc
lite/tests/kernels/unsqueeze_compute_test.cc
+2
-3
未找到文件。
lite/operators/op_params.h
浏览文件 @
f4e06650
...
@@ -856,7 +856,7 @@ struct UnsqueezeParam {
...
@@ -856,7 +856,7 @@ struct UnsqueezeParam {
lite
::
Tensor
*
XShape
{};
lite
::
Tensor
*
XShape
{};
std
::
vector
<
int
>
axes
{};
std
::
vector
<
int
>
axes
{};
const
lite
::
Tensor
*
axes_tensor
{};
const
lite
::
Tensor
*
axes_tensor
{};
std
::
vector
<
lite
::
Tensor
>*
axes_tensor_vct
{};
std
::
vector
<
const
lite
::
Tensor
*>
axes_tensor_vct
{};
};
};
/// ----------------------- expand operators ----------------------
/// ----------------------- expand operators ----------------------
...
...
lite/operators/unsqueeze_op.cc
浏览文件 @
f4e06650
...
@@ -66,10 +66,7 @@ bool UnsqueezeOp::InferShape() const {
...
@@ -66,10 +66,7 @@ bool UnsqueezeOp::InferShape() const {
std
::
vector
<
int
>
final_axes
;
std
::
vector
<
int
>
final_axes
;
auto
axes
=
param_
.
axes
;
auto
axes
=
param_
.
axes
;
auto
*
axes_tensor
=
param_
.
axes_tensor
;
auto
*
axes_tensor
=
param_
.
axes_tensor
;
std
::
vector
<
lite
::
Tensor
>
axes_tensor_vct
;
auto
axes_tensor_vct
=
param_
.
axes_tensor_vct
;
if
(
param_
.
axes_tensor_vct
)
{
axes_tensor_vct
=
*
(
param_
.
axes_tensor_vct
);
}
if
(
!
axes
.
empty
())
{
if
(
!
axes
.
empty
())
{
final_axes
=
axes
;
final_axes
=
axes
;
...
@@ -79,7 +76,7 @@ bool UnsqueezeOp::InferShape() const {
...
@@ -79,7 +76,7 @@ bool UnsqueezeOp::InferShape() const {
axes_tensor_data
+
axes_tensor
->
numel
());
axes_tensor_data
+
axes_tensor
->
numel
());
}
else
if
(
!
axes_tensor_vct
.
empty
())
{
}
else
if
(
!
axes_tensor_vct
.
empty
())
{
for
(
int
i
=
0
;
i
<
axes_tensor_vct
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
axes_tensor_vct
.
size
();
i
++
)
{
final_axes
.
push_back
(
axes_tensor_vct
[
i
]
.
data
<
int
>
()[
0
]);
final_axes
.
push_back
(
axes_tensor_vct
[
i
]
->
data
<
int
>
()[
0
]);
}
}
}
else
{
}
else
{
LOG
(
FATAL
)
<<
"Input axis error"
;
LOG
(
FATAL
)
<<
"Input axis error"
;
...
@@ -114,16 +111,12 @@ bool UnsqueezeOp::AttachImpl(const cpp::OpDesc &opdesc, lite::Scope *scope) {
...
@@ -114,16 +111,12 @@ bool UnsqueezeOp::AttachImpl(const cpp::OpDesc &opdesc, lite::Scope *scope) {
if
(
opdesc
.
HasInput
(
"AxesTensorList"
)
&&
if
(
opdesc
.
HasInput
(
"AxesTensorList"
)
&&
opdesc
.
Input
(
"AxesTensorList"
).
size
()
>
0
)
{
opdesc
.
Input
(
"AxesTensorList"
).
size
()
>
0
)
{
auto
args
=
opdesc
.
Input
(
"AxesTensorList"
);
auto
args
=
opdesc
.
Input
(
"AxesTensorList"
);
/*
for
(
auto
arg
:
args
)
{
for
(
auto
arg
:
args
)
{
auto
*
var
=
scope
->
FindVar
(
arg
);
auto
*
var
=
scope
->
FindVar
(
arg
);
if
(
var
!=
nullptr
)
{
if
(
var
!=
nullptr
)
{
param_
.
axes_tensor_vct
.
push_back
(
var
->
GetMutable
<
lite
::
Tensor
>
());
param_
.
axes_tensor_vct
.
push_back
(
var
->
GetMutable
<
lite
::
Tensor
>
());
}
}
}
}
*/
auto
*
var
=
scope
->
FindVar
(
args
.
front
());
param_
.
axes_tensor_vct
=
var
->
GetMutable
<
std
::
vector
<
lite
::
Tensor
>>
();
}
}
CHECK
(
param_
.
X
)
<<
"Input(X) of UnsqueezeOp should not be null."
;
CHECK
(
param_
.
X
)
<<
"Input(X) of UnsqueezeOp should not be null."
;
CHECK
(
param_
.
Out
)
<<
"Output(Out) of UnsqueezeOp should not be null."
;
CHECK
(
param_
.
Out
)
<<
"Output(Out) of UnsqueezeOp should not be null."
;
...
...
lite/tests/kernels/unsqueeze_compute_test.cc
浏览文件 @
f4e06650
...
@@ -125,8 +125,7 @@ class UnsqueezeComputeTester : public arena::TestCase {
...
@@ -125,8 +125,7 @@ class UnsqueezeComputeTester : public arena::TestCase {
for
(
size_t
i
=
0
;
i
<
axes_
.
size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
axes_
.
size
();
i
++
)
{
name
=
name
+
std
::
to_string
(
i
);
name
=
name
+
std
::
to_string
(
i
);
axes_tensor_list_
.
push_back
(
name
);
axes_tensor_list_
.
push_back
(
name
);
std
::
vector
<
int
>
in_data
=
{
axes_
[
i
]};
SetCommonTensor
(
name
,
DDim
({
1
}),
&
axes_
[
i
]);
SetCommonTensor
(
name
,
DDim
({
1
}),
in_data
.
data
());
}
}
}
}
}
}
...
@@ -230,7 +229,7 @@ void test_unsqueeze(Place place) {
...
@@ -230,7 +229,7 @@ void test_unsqueeze(Place place) {
for
(
int
C
:
{
3
})
{
for
(
int
C
:
{
3
})
{
for
(
int
H
:
{
1
})
{
for
(
int
H
:
{
1
})
{
for
(
int
W
:
{
5
})
{
for
(
int
W
:
{
5
})
{
for
(
int
input_axes_flag
:
{
1
,
2
})
{
for
(
int
input_axes_flag
:
{
1
,
2
,
3
})
{
LOG
(
INFO
)
<<
N
<<
" "
<<
C
<<
" "
<<
H
<<
" "
<<
W
<<
" "
LOG
(
INFO
)
<<
N
<<
" "
<<
C
<<
" "
<<
H
<<
" "
<<
W
<<
" "
<<
input_axes_flag
;
<<
input_axes_flag
;
std
::
unique_ptr
<
arena
::
TestCase
>
tester
(
std
::
unique_ptr
<
arena
::
TestCase
>
tester
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录