Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
aae3f926
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看板
提交
aae3f926
编写于
8月 28, 2019
作者:
Z
zp7
提交者:
Yanzhan Yang
8月 28, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix infershape when cmakelist option CPU&GPU_CL is ON, test=develop (#1880)
上级
a270d326
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
137 addition
and
133 deletion
+137
-133
mobile/src/operators/increment_op.cpp
mobile/src/operators/increment_op.cpp
+3
-3
mobile/src/operators/kernel/cl/elementwise_add_kernel.cpp
mobile/src/operators/kernel/cl/elementwise_add_kernel.cpp
+2
-3
mobile/src/operators/lod_reset_op.cpp
mobile/src/operators/lod_reset_op.cpp
+4
-4
mobile/src/operators/one_hot_op.cpp
mobile/src/operators/one_hot_op.cpp
+3
-3
mobile/src/operators/op_param.h
mobile/src/operators/op_param.h
+1
-1
mobile/src/operators/reduce_prod_op.cpp
mobile/src/operators/reduce_prod_op.cpp
+6
-5
mobile/src/operators/reshape2_op.cpp
mobile/src/operators/reshape2_op.cpp
+37
-37
mobile/src/operators/slice_op.cpp
mobile/src/operators/slice_op.cpp
+32
-28
mobile/src/operators/top_k_op.cpp
mobile/src/operators/top_k_op.cpp
+6
-6
mobile/src/operators/transpose2_op.cpp
mobile/src/operators/transpose2_op.cpp
+43
-43
未找到文件。
mobile/src/operators/increment_op.cpp
浏览文件 @
aae3f926
...
...
@@ -27,9 +27,9 @@ void IncrementOp<Dtype, T>::InferShape() const {
auto
out
=
this
->
param_
.
Out
();
PADDLE_MOBILE_ENFORCE
(
input
->
numel
()
==
1
,
"input's numel should be 1"
);
out
->
Resize
(
input
->
dims
());
#ifdef PADDLE_MOBILE_CPU
if
(
std
::
is_same
<
DeviceType
<
kCPU
>
,
Dtype
>::
value
)
{
out
->
set_lod
(
input
->
lod
());
#endif
}
}
}
// namespace operators
...
...
mobile/src/operators/kernel/cl/elementwise_add_kernel.cpp
浏览文件 @
aae3f926
...
...
@@ -23,13 +23,12 @@ template <>
bool
ElementwiseAddKernel
<
GPU_CL
,
float
>::
Init
(
ElementwiseAddParam
<
GPU_CL
>
*
param
)
{
DLOG
<<
"-----init add-----"
;
CLImage
*
bias
=
reinterpret_cast
<
CLImage
*>
(
const_cast
<
CLImage
*>
(
param
->
InputY
()));
CLImage
*
bias
=
reinterpret_cast
<
CLImage
*>
(
const_cast
<
CLImage
*>
(
param
->
InputY
()));
if
(
!
bias
->
isInit
())
{
bias
->
InitNormalCLImage
(
cl_helper_
.
CLContext
(),
this
->
cl_helper_
.
CLCommandQueue
());
}
DLOG
<<
" bias: "
<<
*
bias
;
if
(
bias
->
dims
().
size
()
==
4
)
{
this
->
cl_helper_
.
AddKernel
(
"elementwise_add"
,
"elementwise_add_kernel.cl"
);
...
...
mobile/src/operators/lod_reset_op.cpp
浏览文件 @
aae3f926
...
...
@@ -23,11 +23,11 @@ template <typename Dtype, typename T>
void
LodResetOp
<
Dtype
,
T
>::
InferShape
()
const
{
const
auto
&
input_dims
=
this
->
param_
.
input_x_
->
dims
();
this
->
param_
.
output_
->
Resize
(
input_dims
);
#ifdef PADDLE_MOBILE_CPU
if
(
std
::
is_same
<
DeviceType
<
kCPU
>
,
Dtype
>::
value
)
{
if
(
this
->
param_
.
append
)
{
this
->
param_
.
output_
->
set_lod
(
this
->
param_
.
input_x_
->
lod
());
}
#endif
}
}
}
// namespace operators
...
...
mobile/src/operators/one_hot_op.cpp
浏览文件 @
aae3f926
...
...
@@ -26,9 +26,9 @@ void OnehotOp<Dtype, T>::InferShape() const {
framework
::
DDim
out_dims
(
x_dims
);
out_dims
[
out_dims
.
size
()
-
1
]
=
depth
;
this
->
param_
.
output_
->
Resize
(
out_dims
);
#ifdef PADDLE_MOBILE_CPU
if
(
std
::
is_same
<
DeviceType
<
kCPU
>
,
Dtype
>::
value
)
{
this
->
param_
.
output_
->
set_lod
(
this
->
param_
.
input_
->
lod
());
#endif
}
}
}
// namespace operators
...
...
mobile/src/operators/op_param.h
浏览文件 @
aae3f926
...
...
@@ -14,9 +14,9 @@ limitations under the License. */
#pragma once
#include <memory>
#include <string>
#include <vector>
#include <memory>
#include "common/log.h"
#include "common/type_define.h"
#include "common/types.h"
...
...
mobile/src/operators/reduce_prod_op.cpp
浏览文件 @
aae3f926
...
...
@@ -16,6 +16,7 @@ limitations under the License. */
#include "operators/reduce_prod_op.h"
#include <algorithm>
#include <vector>
namespace
paddle_mobile
{
namespace
operators
{
...
...
@@ -64,12 +65,12 @@ void ReduceProdOp<Dtype, T>::InferShape() const {
}
auto
out_dims
=
framework
::
make_ddim
(
dims_vector
);
this
->
param_
.
Output
()
->
Resize
(
out_dims
);
#ifdef PADDLE_MOBILE_CPU
if
(
std
::
is_same
<
DeviceType
<
kCPU
>
,
Dtype
>::
value
)
{
if
(
dims
[
0
]
!=
0
)
{
// Only pass LoD when not reducing on the first dim.
this
->
param_
.
Output
()
->
set_lod
(
this
->
param_
.
Input
()
->
lod
());
}
#endif
}
}
}
...
...
mobile/src/operators/reshape2_op.cpp
浏览文件 @
aae3f926
...
...
@@ -27,9 +27,9 @@ void Reshape2Op<Dtype, T>::InferShape() const {
}
auto
&
shape
=
this
->
param_
.
Shape
();
auto
input_x_dims
=
this
->
param_
.
InputX
()
->
dims
();
#ifdef PADDLE_MOBILE_CL
auto
input_dim_size
=
input_x_dims
.
size
();
bool
shouldResize
=
true
;
if
(
std
::
is_same
<
DeviceType
<
kGPU_CL
>
,
Dtype
>::
value
)
{
auto
input_dim_size
=
input_x_dims
.
size
();
if
(
input_dim_size
>
4
)
{
for
(
int
i
=
0
;
i
<
input_dim_size
-
4
;
++
i
)
{
if
(
input_x_dims
[
i
]
!=
0
&&
input_x_dims
[
i
]
!=
1
)
{
...
...
@@ -48,11 +48,11 @@ void Reshape2Op<Dtype, T>::InferShape() const {
input_x_dims
=
this
->
param_
.
InputX
()
->
dims
();
}
}
#endif
}
auto
out_dims
=
ValidateShape
(
shape
,
input_x_dims
);
this
->
param_
.
Out
()
->
Resize
(
out_dims
);
#ifdef PADDLE_MOBILE_CL
if
(
std
::
is_same
<
DeviceType
<
kGPU_CL
>
,
Dtype
>::
value
)
{
input_x_dims
=
this
->
param_
.
InputX
()
->
dims
();
shouldResize
=
true
;
if
(
out_dims
.
size
()
>
4
)
{
...
...
@@ -72,15 +72,15 @@ void Reshape2Op<Dtype, T>::InferShape() const {
this
->
param_
.
Out
()
->
Resize
(
temp_ddim
);
}
}
#endif
}
std
::
vector
<
int64_t
>
xshape_dims
(
input_x_dims
.
size
()
+
1
,
0
);
for
(
int
i
=
0
;
i
<
input_x_dims
.
size
();
++
i
)
{
xshape_dims
[
i
+
1
]
=
input_x_dims
[
i
];
}
this
->
param_
.
OutputXShape
()
->
Resize
(
framework
::
make_ddim
(
xshape_dims
));
#ifdef PADDLE_MOBILE_CL
if
(
std
::
is_same
<
DeviceType
<
kGPU_CL
>
,
Dtype
>::
value
)
{
this
->
param_
.
OutputXShape
()
->
Resize
(
input_x_dims
);
#endif
}
}
}
// namespace operators
...
...
mobile/src/operators/slice_op.cpp
浏览文件 @
aae3f926
...
...
@@ -26,7 +26,7 @@ void SliceOp<Dtype, T>::InferShape() const {
auto
axes
=
this
->
param_
.
axes_
;
auto
input
=
this
->
param_
.
input_
;
auto
output
=
this
->
param_
.
output_
;
#ifdef PADDLE_MOBILE_CL
if
(
std
::
is_same
<
DeviceType
<
kGPU_CL
>
,
Dtype
>::
value
)
{
auto
output_dims
=
output
->
dims
();
auto
output_dims_size
=
output_dims
.
size
();
bool
should_resize
=
true
;
...
...
@@ -47,16 +47,18 @@ void SliceOp<Dtype, T>::InferShape() const {
this
->
param_
.
output_
->
Resize
(
temp_ddim
);
}
}
#endif
}
PADDLE_MOBILE_ENFORCE
(
axes
.
size
()
==
1
,
"axes size should equals 1"
);
PADDLE_MOBILE_ENFORCE
(
input
->
dims
().
size
()
==
output
->
dims
().
size
(),
"input dim size should equals output dim size"
);
if
(
std
::
is_same
<
DeviceType
<
kGPU_CL
>
,
Dtype
>::
value
)
{
PADDLE_MOBILE_ENFORCE
(
output
->
dims
().
size
()
-
(
axes
[
0
]
-
(
this
->
param_
.
original_output_dims_size_
-
this
->
param_
.
output_
->
dims
().
size
()))
==
3
,
"op only support slice channel now"
);
}
auto
starts
=
this
->
param_
.
starts_
;
auto
ends
=
this
->
param_
.
ends_
;
framework
::
DDim
out_dims
(
input
->
dims
());
...
...
@@ -82,11 +84,13 @@ void SliceOp<Dtype, T>::InferShape() const {
}
}
output
->
Resize
(
out_dims
);
#if !defined(PADDLE_MOBILE_CL) && defined(PADDLE_MOBILE_CPU)
if
(
std
::
is_same
<
DeviceType
<
kCPU
>
,
Dtype
>::
value
)
{
LoDTensor
*
output_lod
=
reinterpret_cast
<
LoDTensor
*>
(
output
);
LoDTensor
*
input_lod
=
reinterpret_cast
<
LoDTensor
*>
(
input
);
if
(
axes
[
0
]
!=
0
)
{
output
->
set_lod
(
input
->
lod
());
output_lod
->
set_lod
(
input_lod
->
lod
());
}
}
#endif
}
}
// namespace operators
...
...
mobile/src/operators/top_k_op.cpp
浏览文件 @
aae3f926
...
...
@@ -19,18 +19,18 @@ limitations under the License. */
namespace
paddle_mobile
{
namespace
operators
{
template
<
typename
D
eviceT
ype
,
typename
T
>
void
TopKOp
<
D
eviceT
ype
,
T
>::
InferShape
()
const
{
template
<
typename
D
t
ype
,
typename
T
>
void
TopKOp
<
D
t
ype
,
T
>::
InferShape
()
const
{
const
int
k
=
this
->
param_
.
k_
;
auto
dims
=
this
->
param_
.
input_
->
dims
();
// should check k <= dims[-1] && k >= 1
dims
[
dims
.
size
()
-
1
]
=
k
;
this
->
param_
.
output_
->
Resize
(
dims
);
this
->
param_
.
indices_
->
Resize
(
dims
);
#ifdef PADDLE_MOBILE_CPU
if
(
std
::
is_same
<
DeviceType
<
kCPU
>
,
Dtype
>::
value
)
{
this
->
param_
.
output_
->
set_lod
(
this
->
param_
.
input_
->
lod
());
this
->
param_
.
indices_
->
set_lod
(
this
->
param_
.
input_
->
lod
());
#endif
}
}
}
// namespace operators
...
...
mobile/src/operators/transpose2_op.cpp
浏览文件 @
aae3f926
...
...
@@ -29,7 +29,7 @@ void Transpose2Op<Dtype, T>::InferShape() const {
size_t
x_dims_size
=
input_x_dims
.
size
();
size_t
axis_size
=
axis
.
size
();
#ifdef PADDLE_MOBILE_CL
if
(
std
::
is_same
<
DeviceType
<
kGPU_CL
>
,
Dtype
>::
value
)
{
bool
shouldResize
=
true
;
int
diff_dim
=
0
;
if
(
axis_size
>
4
)
{
...
...
@@ -76,7 +76,7 @@ void Transpose2Op<Dtype, T>::InferShape() const {
axis_size
=
axis
.
size
();
input_x_dims
=
this
->
param_
.
InputX
()
->
dims
();
x_dims_size
=
input_x_dims
.
size
();
#endif
}
PADDLE_MOBILE_ENFORCE
((
x_dims_size
==
axis_size
),
"input_dims must "
...
...
@@ -100,9 +100,9 @@ void Transpose2Op<Dtype, T>::InferShape() const {
xshape_dims
[
i
+
1
]
=
input_x_dims
[
i
];
}
this
->
param_
.
OutputXShape
()
->
Resize
(
framework
::
make_ddim
(
xshape_dims
));
#ifdef PADDLE_MOBILE_CL
if
(
std
::
is_same
<
DeviceType
<
kGPU_CL
>
,
Dtype
>::
value
)
{
this
->
param_
.
OutputXShape
()
->
Resize
(
input_x_dims
);
#endif
}
}
}
// namespace operators
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录