Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
47409b72
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 2 年 前同步成功
通知
2325
Star
20933
Fork
5424
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
47409b72
编写于
6月 13, 2019
作者:
Z
zhupengyang
提交者:
Tensor Tang
6月 13, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix split op and arm unit test
上级
519ef7f7
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
36 addition
and
31 deletion
+36
-31
paddle/fluid/lite/arm/math/split.cc
paddle/fluid/lite/arm/math/split.cc
+2
-2
paddle/fluid/lite/arm/math/split.h
paddle/fluid/lite/arm/math/split.h
+1
-1
paddle/fluid/lite/kernels/arm/split_compute.cc
paddle/fluid/lite/kernels/arm/split_compute.cc
+1
-1
paddle/fluid/lite/kernels/arm/split_compute_test.cc
paddle/fluid/lite/kernels/arm/split_compute_test.cc
+25
-20
paddle/fluid/lite/operators/op_params.h
paddle/fluid/lite/operators/op_params.h
+2
-2
paddle/fluid/lite/operators/split_op.cc
paddle/fluid/lite/operators/split_op.cc
+4
-4
paddle/fluid/lite/operators/split_op.h
paddle/fluid/lite/operators/split_op.h
+1
-1
未找到文件。
paddle/fluid/lite/arm/math/split.cc
浏览文件 @
47409b72
...
@@ -52,10 +52,10 @@ void split_cpy<float>(const float* din, float* dout, int num) {
...
@@ -52,10 +52,10 @@ void split_cpy<float>(const float* din, float* dout, int num) {
}
}
template
<
>
template
<
>
void
split
<
float
>
(
const
float
*
din
,
std
::
vector
<
lite
::
Tensor
*>*
dout
,
void
split
<
float
>
(
const
float
*
din
,
const
std
::
vector
<
lite
::
Tensor
*>&
dout
,
const
int
axis
,
const
std
::
vector
<
int
>&
in_strides
)
{
const
int
axis
,
const
std
::
vector
<
int
>&
in_strides
)
{
int
input_offset
=
0
;
int
input_offset
=
0
;
for
(
auto
out
:
*
dout
)
{
for
(
auto
out
:
dout
)
{
auto
out_dim
=
out
->
dims
();
auto
out_dim
=
out
->
dims
();
std
::
vector
<
int
>
out_strides
(
out_dim
.
size
());
std
::
vector
<
int
>
out_strides
(
out_dim
.
size
());
out_strides
[
out_dim
.
size
()
-
1
]
=
out_dim
[
out_dim
.
size
()
-
1
];
out_strides
[
out_dim
.
size
()
-
1
]
=
out_dim
[
out_dim
.
size
()
-
1
];
...
...
paddle/fluid/lite/arm/math/split.h
浏览文件 @
47409b72
...
@@ -26,7 +26,7 @@ template <typename T>
...
@@ -26,7 +26,7 @@ template <typename T>
void
split_cpy
(
const
T
*
din
,
T
*
dout
,
int
num
);
void
split_cpy
(
const
T
*
din
,
T
*
dout
,
int
num
);
template
<
typename
T
>
template
<
typename
T
>
void
split
(
const
T
*
din
,
std
::
vector
<
lite
::
Tensor
*>*
dout
,
const
int
axis
,
void
split
(
const
T
*
din
,
const
std
::
vector
<
lite
::
Tensor
*>&
dout
,
const
int
axis
,
const
std
::
vector
<
int
>&
in_strides
);
const
std
::
vector
<
int
>&
in_strides
);
}
// namespace math
}
// namespace math
...
...
paddle/fluid/lite/kernels/arm/split_compute.cc
浏览文件 @
47409b72
...
@@ -24,7 +24,7 @@ namespace arm {
...
@@ -24,7 +24,7 @@ namespace arm {
void
SplitCompute
::
Run
()
{
void
SplitCompute
::
Run
()
{
auto
&
param
=
Param
<
operators
::
SplitParam
>
();
auto
&
param
=
Param
<
operators
::
SplitParam
>
();
const
float
*
din
=
param
.
x
->
data
<
float
>
();
const
float
*
din
=
param
.
x
->
data
<
float
>
();
auto
*
dout
=
param
.
output
;
auto
&
dout
=
param
.
output
;
auto
in_dim
=
param
.
x
->
dims
();
auto
in_dim
=
param
.
x
->
dims
();
std
::
vector
<
int
>
in_strides
(
in_dim
.
size
());
std
::
vector
<
int
>
in_strides
(
in_dim
.
size
());
in_strides
[
in_dim
.
size
()
-
1
]
=
in_dim
[
in_dim
.
size
()
-
1
];
in_strides
[
in_dim
.
size
()
-
1
]
=
in_dim
[
in_dim
.
size
()
-
1
];
...
...
paddle/fluid/lite/kernels/arm/split_compute_test.cc
浏览文件 @
47409b72
...
@@ -24,20 +24,10 @@ namespace kernels {
...
@@ -24,20 +24,10 @@ namespace kernels {
namespace
arm
{
namespace
arm
{
void
splite_resize_out
(
const
lite
::
Tensor
*
din
,
void
splite_resize_out
(
const
lite
::
Tensor
*
din
,
std
::
vector
<
lite
::
Tensor
*>*
dout
,
int
axis
,
int
num
,
const
std
::
vector
<
lite
::
Tensor
*>&
dout
,
int
axis
,
const
std
::
vector
<
int
>&
sections
)
{
int
num
,
const
std
::
vector
<
int
>&
sections
)
{
for
(
auto
out
:
*
dout
)
delete
out
;
dout
->
clear
();
auto
in_dims
=
din
->
dims
();
auto
in_dims
=
din
->
dims
();
int
outs_number
;
int
outs_number
=
dout
.
size
();
if
(
num
>
0
)
{
outs_number
=
num
;
}
else
{
outs_number
=
sections
.
size
();
}
for
(
int
i
=
0
;
i
<
outs_number
;
i
++
)
{
dout
->
push_back
(
new
lite
::
Tensor
);
}
std
::
vector
<
lite
::
DDimLite
>
outs_dims
;
std
::
vector
<
lite
::
DDimLite
>
outs_dims
;
outs_dims
.
reserve
(
outs_number
);
outs_dims
.
reserve
(
outs_number
);
...
@@ -58,7 +48,7 @@ void splite_resize_out(const lite::Tensor* din,
...
@@ -58,7 +48,7 @@ void splite_resize_out(const lite::Tensor* din,
}
}
for
(
int
j
=
0
;
j
<
outs_dims
.
size
();
++
j
)
{
for
(
int
j
=
0
;
j
<
outs_dims
.
size
();
++
j
)
{
(
*
dout
)
[
j
]
->
Resize
(
outs_dims
[
j
]);
dout
[
j
]
->
Resize
(
outs_dims
[
j
]);
}
}
}
}
...
@@ -75,7 +65,7 @@ void split_compute_ref(const operators::SplitParam& param) {
...
@@ -75,7 +65,7 @@ void split_compute_ref(const operators::SplitParam& param) {
}
}
int
input_offset
=
0
;
int
input_offset
=
0
;
for
(
auto
out
:
*
dout
)
{
for
(
auto
out
:
dout
)
{
auto
out_dim
=
out
->
dims
();
auto
out_dim
=
out
->
dims
();
std
::
vector
<
int
>
out_strides
(
out_dim
.
size
());
std
::
vector
<
int
>
out_strides
(
out_dim
.
size
());
out_strides
[
out_dim
.
size
()
-
1
]
=
out_dim
[
out_dim
.
size
()
-
1
];
out_strides
[
out_dim
.
size
()
-
1
]
=
out_dim
[
out_dim
.
size
()
-
1
];
...
@@ -128,16 +118,31 @@ TEST(split_arm, compute) {
...
@@ -128,16 +118,31 @@ TEST(split_arm, compute) {
for
(
int
i
=
0
;
i
<
x
.
dims
().
production
();
i
++
)
{
for
(
int
i
=
0
;
i
<
x
.
dims
().
production
();
i
++
)
{
x_data
[
i
]
=
i
;
x_data
[
i
]
=
i
;
}
}
splite_resize_out
(
&
x
,
&
output
,
axis
,
num
,
sections
);
for
(
auto
out
:
output
)
delete
out
;
splite_resize_out
(
&
x
,
&
output_ref
,
axis
,
num
,
sections
);
for
(
auto
out
:
output_ref
)
delete
out
;
output
.
clear
();
output_ref
.
clear
();
int
outs_number
;
if
(
num
>
0
)
{
outs_number
=
num
;
}
else
{
outs_number
=
sections
.
size
();
}
for
(
int
i
=
0
;
i
<
outs_number
;
i
++
)
{
output
.
push_back
(
new
lite
::
Tensor
);
output_ref
.
push_back
(
new
lite
::
Tensor
);
}
splite_resize_out
(
&
x
,
output
,
axis
,
num
,
sections
);
splite_resize_out
(
&
x
,
output_ref
,
axis
,
num
,
sections
);
param
.
x
=
&
x
;
param
.
x
=
&
x
;
param
.
axis
=
axis
;
param
.
axis
=
axis
;
param
.
num
=
num
;
param
.
num
=
num
;
param
.
sections
=
&
sections
;
param
.
sections
=
sections
;
param
.
output
=
&
output
;
param
.
output
=
output
;
split
.
SetParam
(
param
);
split
.
SetParam
(
param
);
split
.
Run
();
split
.
Run
();
param
.
output
=
&
output_ref
;
param
.
output
=
output_ref
;
split_compute_ref
<
float
>
(
param
);
split_compute_ref
<
float
>
(
param
);
for
(
int
i
=
0
;
i
<
output
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
output
.
size
();
i
++
)
{
float
*
output_data
=
output
[
i
]
->
mutable_data
<
float
>
();
float
*
output_data
=
output
[
i
]
->
mutable_data
<
float
>
();
...
...
paddle/fluid/lite/operators/op_params.h
浏览文件 @
47409b72
...
@@ -178,10 +178,10 @@ struct DropoutParam {
...
@@ -178,10 +178,10 @@ struct DropoutParam {
// For Split op
// For Split op
struct
SplitParam
{
struct
SplitParam
{
lite
::
Tensor
*
x
{};
lite
::
Tensor
*
x
{};
std
::
vector
<
lite
::
Tensor
*>
*
output
{};
std
::
vector
<
lite
::
Tensor
*>
output
{};
int
axis
{
-
1
};
int
axis
{
-
1
};
int
num
{
0
};
int
num
{
0
};
std
::
vector
<
int
>
*
sections
;
std
::
vector
<
int
>
sections
;
};
};
/// ----------------------- element wise operators ----------------------
/// ----------------------- element wise operators ----------------------
...
...
paddle/fluid/lite/operators/split_op.cc
浏览文件 @
47409b72
...
@@ -21,7 +21,7 @@ namespace operators {
...
@@ -21,7 +21,7 @@ namespace operators {
bool
SplitOp
::
CheckShape
()
const
{
bool
SplitOp
::
CheckShape
()
const
{
CHECK_OR_FALSE
(
param_
.
x
);
CHECK_OR_FALSE
(
param_
.
x
);
CHECK_
OR_FALSE
(
param_
.
output
);
CHECK_
GT_OR_FALSE
(
param_
.
output
.
size
(),
1UL
);
auto
x_dims
=
param_
.
x
->
dims
();
auto
x_dims
=
param_
.
x
->
dims
();
auto
x_rank
=
x_dims
.
size
();
auto
x_rank
=
x_dims
.
size
();
CHECK_OR_FALSE
(
param_
.
axis
>=
-
static_cast
<
int
>
(
x_rank
)
&&
CHECK_OR_FALSE
(
param_
.
axis
>=
-
static_cast
<
int
>
(
x_rank
)
&&
...
@@ -31,7 +31,7 @@ bool SplitOp::CheckShape() const {
...
@@ -31,7 +31,7 @@ bool SplitOp::CheckShape() const {
bool
SplitOp
::
InferShape
()
const
{
bool
SplitOp
::
InferShape
()
const
{
const
auto
&
outs
=
param_
.
output
;
const
auto
&
outs
=
param_
.
output
;
auto
in_dims
=
param_
.
x
.
dims
();
auto
in_dims
=
param_
.
x
->
dims
();
int
axis
=
param_
.
axis
;
int
axis
=
param_
.
axis
;
int
num
=
param_
.
num
;
int
num
=
param_
.
num
;
const
auto
&
sections
=
param_
.
sections
;
const
auto
&
sections
=
param_
.
sections
;
...
@@ -68,7 +68,7 @@ bool SplitOp::AttachImpl(const cpp::OpDesc &opdesc, lite::Scope *scope) {
...
@@ -68,7 +68,7 @@ bool SplitOp::AttachImpl(const cpp::OpDesc &opdesc, lite::Scope *scope) {
param_
.
sections
=
opdesc
.
GetAttr
<
std
::
vector
<
int
>>
(
"sections"
);
param_
.
sections
=
opdesc
.
GetAttr
<
std
::
vector
<
int
>>
(
"sections"
);
param_
.
x
=
const_cast
<
lite
::
Tensor
*>
(
param_
.
x
=
const_cast
<
lite
::
Tensor
*>
(
&
scope
->
FindVar
(
opdesc
.
Input
(
"X"
).
front
())
->
Get
<
lite
::
Tensor
>
());
&
scope
->
FindVar
(
opdesc
.
Input
(
"X"
).
front
())
->
Get
<
lite
::
Tensor
>
());
auto
outs
=
op
_
desc
.
Output
(
"Out"
);
auto
outs
=
opdesc
.
Output
(
"Out"
);
for
(
auto
var
:
outs
)
{
for
(
auto
var
:
outs
)
{
param_
.
output
.
push_back
(
scope
->
FindVar
(
var
)
->
GetMutable
<
lite
::
Tensor
>
());
param_
.
output
.
push_back
(
scope
->
FindVar
(
var
)
->
GetMutable
<
lite
::
Tensor
>
());
}
}
...
@@ -79,4 +79,4 @@ bool SplitOp::AttachImpl(const cpp::OpDesc &opdesc, lite::Scope *scope) {
...
@@ -79,4 +79,4 @@ bool SplitOp::AttachImpl(const cpp::OpDesc &opdesc, lite::Scope *scope) {
}
// namespace lite
}
// namespace lite
}
// namespace paddle
}
// namespace paddle
REGISTER_LITE_OP
(
s
oftmax
,
paddle
::
lite
::
operators
::
Softmax
Op
);
REGISTER_LITE_OP
(
s
plit
,
paddle
::
lite
::
operators
::
Split
Op
);
paddle/fluid/lite/operators/split_op.h
浏览文件 @
47409b72
...
@@ -23,7 +23,7 @@ namespace paddle {
...
@@ -23,7 +23,7 @@ namespace paddle {
namespace
lite
{
namespace
lite
{
namespace
operators
{
namespace
operators
{
class
S
oftmax
Op
:
public
OpLite
{
class
S
plit
Op
:
public
OpLite
{
public:
public:
SplitOp
()
{}
SplitOp
()
{}
explicit
SplitOp
(
const
std
::
string
&
op_type
)
:
OpLite
(
op_type
)
{}
explicit
SplitOp
(
const
std
::
string
&
op_type
)
:
OpLite
(
op_type
)
{}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录