Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
b4bac81b
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看板
提交
b4bac81b
编写于
3月 27, 2020
作者:
J
jackzhang235
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix some mlu kernel test
上级
8a9d026c
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
30 addition
and
57 deletion
+30
-57
lite/kernels/mlu/bridges/batch_norm_op_test.cc
lite/kernels/mlu/bridges/batch_norm_op_test.cc
+0
-2
lite/kernels/mlu/bridges/concat_op_test.cc
lite/kernels/mlu/bridges/concat_op_test.cc
+1
-13
lite/kernels/mlu/bridges/conv_op_test.cc
lite/kernels/mlu/bridges/conv_op_test.cc
+0
-4
lite/kernels/mlu/bridges/fc_op_test.cc
lite/kernels/mlu/bridges/fc_op_test.cc
+25
-6
lite/kernels/mlu/bridges/interpolate_op_test.cc
lite/kernels/mlu/bridges/interpolate_op_test.cc
+0
-2
lite/kernels/mlu/bridges/pool_op_test.cc
lite/kernels/mlu/bridges/pool_op_test.cc
+0
-5
lite/kernels/mlu/bridges/softmax_op_test.cc
lite/kernels/mlu/bridges/softmax_op_test.cc
+0
-2
lite/kernels/mlu/bridges/test_helper.cc
lite/kernels/mlu/bridges/test_helper.cc
+3
-1
lite/kernels/mlu/bridges/transpose_op.cc
lite/kernels/mlu/bridges/transpose_op.cc
+0
-22
lite/kernels/mlu/bridges/transpose_op_test.cc
lite/kernels/mlu/bridges/transpose_op_test.cc
+1
-0
未找到文件。
lite/kernels/mlu/bridges/batch_norm_op_test.cc
浏览文件 @
b4bac81b
...
@@ -137,9 +137,7 @@ void test_batch_norm(
...
@@ -137,9 +137,7 @@ void test_batch_norm(
{
bs
,
ic
,
ih
,
iw
},
{
bs
,
ic
,
ih
,
iw
},
{
0
,
2
,
3
,
1
});
{
0
,
2
,
3
,
1
});
out
->
Resize
({
bs
,
ih
,
iw
,
ic
});
x
->
CopyDataFrom
(
input_trans
);
x
->
CopyDataFrom
(
input_trans
);
x
->
Resize
({
bs
,
ih
,
iw
,
ic
});
LaunchOp
(
op
,
{
x_var_name
},
{
out_var_name
});
LaunchOp
(
op
,
{
x_var_name
},
{
out_var_name
});
...
...
lite/kernels/mlu/bridges/concat_op_test.cc
浏览文件 @
b4bac81b
...
@@ -113,21 +113,8 @@ void test_concat(std::vector<std::vector<int64_t>> input, int axis) {
...
@@ -113,21 +113,8 @@ void test_concat(std::vector<std::vector<int64_t>> input, int axis) {
static_cast
<
int
>
(
input
[
1
][
2
]),
static_cast
<
int
>
(
input
[
1
][
2
]),
static_cast
<
int
>
(
input
[
1
][
3
])},
static_cast
<
int
>
(
input
[
1
][
3
])},
{
0
,
2
,
3
,
1
});
{
0
,
2
,
3
,
1
});
auto
os
=
out
->
dims
();
out
->
Resize
({
static_cast
<
int
>
(
os
[
0
]),
static_cast
<
int
>
(
os
[
2
]),
static_cast
<
int
>
(
os
[
3
]),
static_cast
<
int
>
(
os
[
1
])});
x
->
CopyDataFrom
(
input_x
);
x
->
CopyDataFrom
(
input_x
);
y
->
CopyDataFrom
(
input_y
);
y
->
CopyDataFrom
(
input_y
);
x
->
Resize
({
static_cast
<
int
>
(
input
[
0
][
0
]),
static_cast
<
int
>
(
input
[
0
][
2
]),
static_cast
<
int
>
(
input
[
0
][
3
]),
static_cast
<
int
>
(
input
[
0
][
1
])});
y
->
Resize
({
static_cast
<
int
>
(
input
[
1
][
0
]),
static_cast
<
int
>
(
input
[
1
][
2
]),
static_cast
<
int
>
(
input
[
1
][
3
]),
static_cast
<
int
>
(
input
[
1
][
1
])});
LaunchOp
(
op
,
{
x_var_name
,
y_var_name
},
{
out_var_name
});
LaunchOp
(
op
,
{
x_var_name
,
y_var_name
},
{
out_var_name
});
...
@@ -136,6 +123,7 @@ void test_concat(std::vector<std::vector<int64_t>> input, int axis) {
...
@@ -136,6 +123,7 @@ void test_concat(std::vector<std::vector<int64_t>> input, int axis) {
Tensor
output_trans
;
Tensor
output_trans
;
output_trans
.
Resize
(
out
->
dims
());
output_trans
.
Resize
(
out
->
dims
());
auto
os
=
out
->
dims
();
transpose
(
out_data
,
transpose
(
out_data
,
output_trans
.
mutable_data
<
float
>
(),
output_trans
.
mutable_data
<
float
>
(),
{
static_cast
<
int
>
(
os
[
0
]),
{
static_cast
<
int
>
(
os
[
0
]),
...
...
lite/kernels/mlu/bridges/conv_op_test.cc
浏览文件 @
b4bac81b
...
@@ -244,10 +244,6 @@ void test_conv(int bs,
...
@@ -244,10 +244,6 @@ void test_conv(int bs,
}
}
}
}
input
->
Resize
({
bs
,
ih
,
iw
,
ic
});
output
->
Resize
(
{
output_shape
[
0
],
output_shape
[
2
],
output_shape
[
3
],
output_shape
[
1
]});
// create and convert op to MLU model, then run it on MLU
// create and convert op to MLU model, then run it on MLU
auto
op
=
CreateOp
<
operators
::
ConvOpLite
>
(
opdesc_mlu
,
&
scope
);
auto
op
=
CreateOp
<
operators
::
ConvOpLite
>
(
opdesc_mlu
,
&
scope
);
LaunchOp
(
op
,
{
input_var_name
},
{
output_var_name
});
LaunchOp
(
op
,
{
input_var_name
},
{
output_var_name
});
...
...
lite/kernels/mlu/bridges/fc_op_test.cc
浏览文件 @
b4bac81b
...
@@ -139,15 +139,34 @@ void test_fc(const std::vector<int64_t>& input_shape,
...
@@ -139,15 +139,34 @@ void test_fc(const std::vector<int64_t>& input_shape,
}
}
auto
fc_op_mlu
=
CreateOp
<
operators
::
FcOpLite
>
(
fc_op_desc_mlu
,
&
scope
);
auto
fc_op_mlu
=
CreateOp
<
operators
::
FcOpLite
>
(
fc_op_desc_mlu
,
&
scope
);
input
->
Resize
({
static_cast
<
int
>
(
input_shape
[
0
]),
static_cast
<
int
>
(
input_shape
[
2
]),
Tensor
input_tmp
,
out_tmp
;
static_cast
<
int
>
(
input_shape
[
3
]),
input_tmp
.
Resize
(
input_shape
);
static_cast
<
int
>
(
input_shape
[
1
])});
transpose
(
input
->
mutable_data
<
float
>
(),
out
->
Resize
({
static_cast
<
int
>
(
input_shape
[
0
]),
static_cast
<
int
>
(
w_shape
[
1
])});
input_tmp
.
mutable_data
<
float
>
(),
{
static_cast
<
int
>
(
input_shape
[
0
]),
static_cast
<
int
>
(
input_shape
[
1
]),
static_cast
<
int
>
(
input_shape
[
2
]),
static_cast
<
int
>
(
input_shape
[
3
])},
{
0
,
2
,
3
,
1
});
input
->
CopyDataFrom
(
input_tmp
);
LaunchOp
(
fc_op_mlu
,
{
input_var_name
},
{
out_var_name
});
LaunchOp
(
fc_op_mlu
,
{
input_var_name
},
{
out_var_name
});
// compare results
auto
os
=
out
->
dims
();
out_tmp
.
Resize
(
os
);
auto
*
out_data
=
out
->
mutable_data
<
float
>
();
auto
*
out_data
=
out
->
mutable_data
<
float
>
();
// transpose(out_data,
// out_tmp.mutable_data<float>(),
// {static_cast<int>(os[0]),
// static_cast<int>(os[2]),
// static_cast<int>(os[3]),
// static_cast<int>(os[1])},
// {0, 3, 1, 2});
//
// out_data = out_tmp.mutable_data<float>();
// compare results
auto
*
out_ref_data
=
out_ref
->
mutable_data
<
float
>
();
auto
*
out_ref_data
=
out_ref
->
mutable_data
<
float
>
();
for
(
int
i
=
0
;
i
<
out
->
dims
().
production
();
i
++
)
{
for
(
int
i
=
0
;
i
<
out
->
dims
().
production
();
i
++
)
{
EXPECT_NEAR
(
out_data
[
i
],
out_ref_data
[
i
],
1e-5
);
EXPECT_NEAR
(
out_data
[
i
],
out_ref_data
[
i
],
1e-5
);
...
...
lite/kernels/mlu/bridges/interpolate_op_test.cc
浏览文件 @
b4bac81b
...
@@ -237,7 +237,6 @@ class InterpComputeTester {
...
@@ -237,7 +237,6 @@ class InterpComputeTester {
/* printf("----output tensor dims: %ld, %d, %d, %ld\n", dims_[0], out_h,
/* printf("----output tensor dims: %ld, %d, %d, %ld\n", dims_[0], out_h,
* out_w, dims_[1]); */
* out_w, dims_[1]); */
std
::
vector
<
int64_t
>
out_shape_nchw
=
{
dims_
[
0
],
dims_
[
1
],
out_h
,
out_w
};
std
::
vector
<
int64_t
>
out_shape_nchw
=
{
dims_
[
0
],
dims_
[
1
],
out_h
,
out_w
};
out
->
Resize
(
DimNCHW2NHWC
(
out_shape_nchw
));
outref
->
Resize
(
out_shape_nchw
);
outref
->
Resize
(
out_shape_nchw
);
outsize
->
Resize
({
2
});
outsize
->
Resize
({
2
});
...
@@ -283,7 +282,6 @@ class InterpComputeTester {
...
@@ -283,7 +282,6 @@ class InterpComputeTester {
{
in
,
ic
,
ih
,
iw
},
{
in
,
ic
,
ih
,
iw
},
{
0
,
2
,
3
,
1
});
{
0
,
2
,
3
,
1
});
x
->
CopyDataFrom
(
input_trans
);
x
->
CopyDataFrom
(
input_trans
);
x
->
Resize
(
DimNCHW2NHWC
(
dims_
.
Vectorize
()));
if
(
use_outsize_
)
{
if
(
use_outsize_
)
{
LaunchOp
(
op
,
{
x_var_name
,
outsize_var_name
},
{
out_var_name
});
LaunchOp
(
op
,
{
x_var_name
,
outsize_var_name
},
{
out_var_name
});
}
else
{
}
else
{
...
...
lite/kernels/mlu/bridges/pool_op_test.cc
浏览文件 @
b4bac81b
...
@@ -180,12 +180,7 @@ void test_pool(int bs,
...
@@ -180,12 +180,7 @@ void test_pool(int bs,
{
0
,
2
,
3
,
1
});
{
0
,
2
,
3
,
1
});
auto
os
=
out
->
dims
();
auto
os
=
out
->
dims
();
out
->
Resize
({
static_cast
<
int
>
(
os
[
0
]),
static_cast
<
int
>
(
os
[
2
]),
static_cast
<
int
>
(
os
[
3
]),
static_cast
<
int
>
(
os
[
1
])});
x
->
CopyDataFrom
(
input_trans
);
x
->
CopyDataFrom
(
input_trans
);
x
->
Resize
({
bs
,
ih
,
iw
,
ic
});
LaunchOp
(
op
,
{
x_var_name
},
{
out_var_name
});
LaunchOp
(
op
,
{
x_var_name
},
{
out_var_name
});
...
...
lite/kernels/mlu/bridges/softmax_op_test.cc
浏览文件 @
b4bac81b
...
@@ -110,9 +110,7 @@ void test_softmax(const std::vector<int64_t>& input_shape, int axis) {
...
@@ -110,9 +110,7 @@ void test_softmax(const std::vector<int64_t>& input_shape, int axis) {
{
bs
,
ic
,
ih
,
iw
},
{
bs
,
ic
,
ih
,
iw
},
{
0
,
2
,
3
,
1
});
{
0
,
2
,
3
,
1
});
out
->
Resize
({
bs
,
ih
,
iw
,
ic
});
x
->
CopyDataFrom
(
input_trans
);
x
->
CopyDataFrom
(
input_trans
);
x
->
Resize
({
bs
,
ih
,
iw
,
ic
});
LaunchOp
(
op
,
{
x_var_name
},
{
out_var_name
});
LaunchOp
(
op
,
{
x_var_name
},
{
out_var_name
});
...
...
lite/kernels/mlu/bridges/test_helper.cc
浏览文件 @
b4bac81b
...
@@ -58,7 +58,7 @@ void LaunchOp(const std::shared_ptr<lite::OpLite> op,
...
@@ -58,7 +58,7 @@ void LaunchOp(const std::shared_ptr<lite::OpLite> op,
graph
.
AddNode
(
input_name
,
graph
.
AddNode
(
input_name
,
input_tensor
->
dims
().
Vectorize
(),
input_tensor
->
dims
().
Vectorize
(),
CNML_TENSOR
,
CNML_TENSOR
,
CNML_N
HWC
,
CNML_N
CHW
,
graph
.
FPType
(),
graph
.
FPType
(),
reinterpret_cast
<
void
*>
(
reinterpret_cast
<
void
*>
(
input_tensor
->
mutable_data
<
float
>
(
TARGET
(
kMLU
))));
input_tensor
->
mutable_data
<
float
>
(
TARGET
(
kMLU
))));
...
@@ -68,6 +68,8 @@ void LaunchOp(const std::shared_ptr<lite::OpLite> op,
...
@@ -68,6 +68,8 @@ void LaunchOp(const std::shared_ptr<lite::OpLite> op,
sizeof
(
float
)
*
input_tensor
->
dims
().
production
(),
sizeof
(
float
)
*
input_tensor
->
dims
().
production
(),
CNRT_MEM_TRANS_DIR_HOST2DEV
));
CNRT_MEM_TRANS_DIR_HOST2DEV
));
}
}
op
->
CheckShape
();
op
->
InferShape
();
bridges
.
Select
(
op_type
,
TARGET
(
kMLU
))(
bridges
.
Select
(
op_type
,
TARGET
(
kMLU
))(
reinterpret_cast
<
void
*>
(
&
graph
),
const_cast
<
OpLite
*>
(
op
.
get
()),
nullptr
);
reinterpret_cast
<
void
*>
(
&
graph
),
const_cast
<
OpLite
*>
(
op
.
get
()),
nullptr
);
...
...
lite/kernels/mlu/bridges/transpose_op.cc
浏览文件 @
b4bac81b
...
@@ -21,28 +21,6 @@ namespace lite {
...
@@ -21,28 +21,6 @@ namespace lite {
namespace
subgraph
{
namespace
subgraph
{
namespace
mlu
{
namespace
mlu
{
// std::vector<int> axis_to_nhwc4d(const std::vector<int>& axis) {
// CHECK_EQ(axis.size(), 4);
// std::vector<int> new_axis(4, 0);
// const std::vector<int> axis_map1 = {0, 2, 3, 1};
// const std::vector<int> axis_map2 = {0, 3, 1, 2};
// for (size_t i = 0; i < new_axis.size(); ++i) {
// new_axis[i] = axis_map2[axis[axis_map1[i]]];
// }
// return new_axis;
//}
//
// std::vector<int> axis_to_nhw3d(const std::vector<int>& axis) {
// CHECK_EQ(axis.size(), 3);
// std::vector<int> new_axis(3, 0);
// const std::vector<int> axis_map = {0, 2, 1};
// for (size_t i = 0; i < new_axis.size(); ++i) {
// new_axis[i] = axis_map[axis[axis_map[i]]];
// }
// new_axis.push_back(3);
// return new_axis;
//}
std
::
vector
<
int
>
axis_to_nhwc
(
const
std
::
vector
<
int
>&
axis
)
{
std
::
vector
<
int
>
axis_to_nhwc
(
const
std
::
vector
<
int
>&
axis
)
{
CHECK_EQ
(
axis
.
size
(),
4
)
<<
"Unsupport dim in mlu transpose"
;
CHECK_EQ
(
axis
.
size
(),
4
)
<<
"Unsupport dim in mlu transpose"
;
std
::
vector
<
int
>
new_axis
(
4
,
0
);
std
::
vector
<
int
>
new_axis
(
4
,
0
);
...
...
lite/kernels/mlu/bridges/transpose_op_test.cc
浏览文件 @
b4bac81b
...
@@ -115,6 +115,7 @@ void test_transpose(const std::vector<int64_t>& input_shape,
...
@@ -115,6 +115,7 @@ void test_transpose(const std::vector<int64_t>& input_shape,
}
}
}
}
// TODO(pmshst): fix the transpose test
TEST
(
MLUBridges
,
transpose
)
{
TEST
(
MLUBridges
,
transpose
)
{
std
::
vector
<
int64_t
>
input_shape
=
{
2
,
3
,
4
,
5
};
std
::
vector
<
int64_t
>
input_shape
=
{
2
,
3
,
4
,
5
};
test_transpose
(
input_shape
,
std
::
vector
<
int
>
{
0
,
1
,
3
,
2
});
test_transpose
(
input_shape
,
std
::
vector
<
int
>
{
0
,
1
,
3
,
2
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录