Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
1716db63
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看板
未验证
提交
1716db63
编写于
9月 09, 2020
作者:
Z
zhupengyang
提交者:
GitHub
9月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[xpu] fix xpu unittests: cast, transpose, pool, layer_norm, elementwise, multiclass_nms (#4259)
上级
ad097764
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
52 addition
and
22 deletion
+52
-22
lite/kernels/xpu/bridges/cast_op.cc
lite/kernels/xpu/bridges/cast_op.cc
+2
-1
lite/kernels/xpu/subgraph_compute.cc
lite/kernels/xpu/subgraph_compute.cc
+9
-4
lite/tests/kernels/cast_compute_test.cc
lite/tests/kernels/cast_compute_test.cc
+2
-2
lite/tests/kernels/elementwise_compute_test.cc
lite/tests/kernels/elementwise_compute_test.cc
+8
-2
lite/tests/kernels/layer_norm_compute_test.cc
lite/tests/kernels/layer_norm_compute_test.cc
+2
-2
lite/tests/kernels/multiclass_nms_compute_test.cc
lite/tests/kernels/multiclass_nms_compute_test.cc
+0
-2
lite/tests/kernels/pool_compute_test.cc
lite/tests/kernels/pool_compute_test.cc
+9
-2
lite/tests/kernels/transpose_compute_test.cc
lite/tests/kernels/transpose_compute_test.cc
+20
-7
未找到文件。
lite/kernels/xpu/bridges/cast_op.cc
浏览文件 @
1716db63
...
...
@@ -88,7 +88,8 @@ int CastConverter(void* ctx, OpLite* op, KernelBase* kernel) {
// Cast node
graph
->
Add
(
out_name
,
graph
->
builder_
.
CreateCast
(
*
x_node
->
data
(),
CvtPrecisionType
(
out_ptype
)));
graph
->
builder_
.
CreateCast
(
*
x_node
->
data
(),
CvtPrecisionType
(
out_ptype
)),
PrecisionType
(
out_ptype
));
return
SUCCESS
;
}
...
...
lite/kernels/xpu/subgraph_compute.cc
浏览文件 @
1716db63
...
...
@@ -54,6 +54,7 @@ bool SubgraphEngine::BuildDeviceProgram() {
return
false
;
}
}
// Collect the input and output nodes of the XPU IR graph
std
::
vector
<
xtcl
::
xExpr
*>
device_inodes
;
std
::
vector
<
xtcl
::
xExpr
*>
device_onodes
;
...
...
@@ -62,16 +63,20 @@ bool SubgraphEngine::BuildDeviceProgram() {
CHECK
(
graph
.
Get
(
input_names_
[
i
])
->
is_data
());
device_inodes
.
push_back
(
graph
.
Get
(
input_names_
[
i
])
->
data
().
get
());
}
std
::
vector
<
std
::
string
>
valid_output_names
;
for
(
size_t
i
=
0
;
i
<
output_names_
.
size
();
i
++
)
{
if
(
graph
.
Has
(
output_names_
[
i
]))
{
device_onodes
.
push_back
(
graph
.
Get
(
output_names_
[
i
])
->
data
().
get
());
valid_output_names
.
push_back
(
output_names_
[
i
]);
}
else
{
// update output_names_ and origin_otensors because some outputs may be
// useless
output_names_
.
erase
(
output_names_
.
begin
()
+
i
);
origin_otensors_
.
erase
(
origin_otensors_
.
begin
()
+
i
);
i
--
;
}
}
// update output_names_ because some outputs may be useless
output_names_
=
valid_output_names
;
CHECK_GT
(
output_names_
.
size
(),
0
);
CHECK_EQ
(
output_names_
.
size
(),
origin_otensors_
.
size
());
// Build the XPU IR graph to the XPU runtime for inference
device_program_
=
lite
::
xpu
::
Device
::
Global
().
Build
(
&
graph
.
builder_
,
&
graph
.
params_
,
&
device_onodes
);
...
...
lite/tests/kernels/cast_compute_test.cc
浏览文件 @
1716db63
...
...
@@ -135,8 +135,8 @@ TEST(Cast, precision) {
float
abs_error
=
2e-5
;
#if defined(LITE_WITH_ARM)
place
=
TARGET
(
kARM
);
//
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
//
place = TARGET(kXPU);
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place
=
TARGET
(
kXPU
);
#elif defined(LITE_WITH_HUAWEI_ASCEND_NPU)
place
=
TARGET
(
kHuaweiAscendNPU
);
abs_error
=
1e-2
;
// precision_mode default is force_fp16
...
...
lite/tests/kernels/elementwise_compute_test.cc
浏览文件 @
1716db63
...
...
@@ -182,6 +182,12 @@ void TestElt(Place place,
std
::
vector
<
int64_t
>
y_shape
,
int
axis
,
std
::
string
act_type
=
""
)
{
#if defined(LITE_WITH_XPU)
if
((
y_shape
.
size
()
!=
1
&&
x_shape
.
size
()
!=
y_shape
.
size
())
||
elt_type
!=
std
::
string
(
"add"
)
||
!
act_type
.
empty
())
{
return
;
}
#endif
std
::
unique_ptr
<
arena
::
TestCase
>
tester
(
new
ElementwiseComputeTester
(
place
,
"def"
,
elt_type
,
x_shape
,
y_shape
,
axis
,
act_type
));
arena
::
Arena
arena
(
std
::
move
(
tester
),
place
,
abs_error
);
...
...
@@ -231,8 +237,8 @@ TEST(Elementwise, precision) {
abs_error
=
1e-2
;
// precision_mode default is force_fp16
#elif defined(LITE_WITH_ARM)
place
=
TARGET
(
kARM
);
//
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
//
place = TARGET(kXPU);
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place
=
TARGET
(
kXPU
);
#else
return
;
#endif
...
...
lite/tests/kernels/layer_norm_compute_test.cc
浏览文件 @
1716db63
...
...
@@ -156,8 +156,8 @@ TEST(LayerNorm, precision) {
#elif defined(LITE_WITH_ARM)
place
=
TARGET
(
kARM
);
abs_error
=
6e-5
;
//
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
//
place = TARGET(kXPU);
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place
=
TARGET
(
kXPU
);
#else
return
;
#endif
...
...
lite/tests/kernels/multiclass_nms_compute_test.cc
浏览文件 @
1716db63
...
...
@@ -478,8 +478,6 @@ TEST(multiclass_nms, precision) {
Place
place
;
#if defined(LITE_WITH_ARM)
place
=
TARGET
(
kHost
);
// #elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
// place = TARGET(kXPU);
#else
return
;
#endif
...
...
lite/tests/kernels/pool_compute_test.cc
浏览文件 @
1716db63
...
...
@@ -313,6 +313,7 @@ void TestPoolPaddings(Place place, float abs_error = 2e-5) {
for
(
auto
pooling_type
:
{
"max"
,
"avg"
})
{
TestPoolHelper
(
place
,
abs_error
,
{
2
,
3
,
6
,
7
},
pooling_type
,
{
1
,
1
},
{
0
,
0
},
{
2
,
2
});
#if !defined(LITE_WITH_XPU)
TestPoolHelper
(
place
,
abs_error
,
{
2
,
3
,
6
,
7
},
pooling_type
,
{
1
,
1
},
{
1
,
1
},
{
2
,
2
});
TestPoolHelper
(
place
,
...
...
@@ -336,6 +337,7 @@ void TestPoolPaddings(Place place, float abs_error = 2e-5) {
{
1
,
1
},
{
1
,
0
,
0
,
1
},
{
2
,
2
});
#endif
}
}
...
...
@@ -349,6 +351,7 @@ void TestPoolKsize(Place place, float abs_error = 2e-5) {
{
1
,
1
},
{
0
,
0
},
{
ksize
,
ksize
});
#if !defined(LITE_WITH_XPU)
TestPoolHelper
(
place
,
abs_error
,
{
2
,
3
,
6
,
7
},
...
...
@@ -356,12 +359,16 @@ void TestPoolKsize(Place place, float abs_error = 2e-5) {
{
2
,
2
},
{
1
,
1
},
{
ksize
,
ksize
});
#endif
}
}
}
void
TestPoolCeilMode
(
Place
place
,
float
abs_error
=
2e-5
)
{
for
(
auto
pooling_type
:
{
"max"
,
"avg"
})
{
#if defined(LITE_WITH_XPU)
if
(
pooling_type
==
std
::
string
(
"max"
))
continue
;
#endif
TestPoolHelper
(
place
,
abs_error
,
{
2
,
3
,
6
,
6
},
...
...
@@ -384,8 +391,8 @@ TEST(Pool, precision) {
#elif defined(LITE_WITH_HUAWEI_ASCEND_NPU)
place
=
TARGET
(
kHuaweiAscendNPU
);
abs_error
=
1e-2
;
// precision_mode default is force_fp16
//
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL) // NOLINT
//
place = TARGET(kXPU);
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL) // NOLINT
place
=
TARGET
(
kXPU
);
#else
return
;
#endif
...
...
lite/tests/kernels/transpose_compute_test.cc
浏览文件 @
1716db63
...
...
@@ -127,7 +127,12 @@ class TransposeComputeTester : public arena::TestCase {
void
TestTranspose2D
(
Place
place
,
float
abs_error
)
{
DDim
x_dims
{{
4
,
5
}};
std
::
vector
<
std
::
vector
<
int
>>
axes
{{
0
,
1
},
{
1
,
0
}};
std
::
vector
<
std
::
vector
<
int
>>
axes
{
#if !defined(LITE_WITH_XPU)
{
0
,
1
},
#endif
{
1
,
0
},
};
for
(
auto
axis
:
axes
)
{
std
::
unique_ptr
<
arena
::
TestCase
>
tester
(
new
TransposeComputeTester
(
place
,
"def"
,
x_dims
,
axis
));
...
...
@@ -138,8 +143,12 @@ void TestTranspose2D(Place place, float abs_error) {
void
TestTranspose3D
(
Place
place
,
float
abs_error
)
{
DDim
x_dims
{{
3
,
4
,
5
}};
std
::
vector
<
std
::
vector
<
int
>>
axes
{
{
0
,
1
,
2
},
{
0
,
2
,
1
},
{
1
,
0
,
2
},
{
2
,
1
,
0
}};
std
::
vector
<
std
::
vector
<
int
>>
axes
{
#if !defined(LITE_WITH_XPU)
{
0
,
1
,
2
},
#endif
{
0
,
2
,
1
},
{
1
,
0
,
2
},
{
2
,
1
,
0
},
};
for
(
auto
axis
:
axes
)
{
std
::
unique_ptr
<
arena
::
TestCase
>
tester
(
new
TransposeComputeTester
(
place
,
"def"
,
x_dims
,
axis
));
...
...
@@ -150,8 +159,12 @@ void TestTranspose3D(Place place, float abs_error) {
void
TestTranspose4D
(
Place
place
,
float
abs_error
)
{
DDim
x_dims
{{
2
,
3
,
4
,
5
}};
std
::
vector
<
std
::
vector
<
int
>>
axes
{
{
0
,
1
,
2
,
3
},
{
0
,
1
,
3
,
2
},
{
0
,
2
,
1
,
3
},
{
3
,
1
,
2
,
0
},
{
3
,
1
,
0
,
2
}};
std
::
vector
<
std
::
vector
<
int
>>
axes
{
#if !defined(LITE_WITH_XPU)
{
0
,
1
,
2
,
3
},
{
0
,
1
,
3
,
2
},
{
0
,
2
,
1
,
3
},
{
3
,
1
,
2
,
0
},
{
3
,
1
,
0
,
2
},
#endif
{
0
,
2
,
3
,
1
},
{
0
,
3
,
1
,
2
},
};
for
(
auto
axis
:
axes
)
{
std
::
unique_ptr
<
arena
::
TestCase
>
tester
(
new
TransposeComputeTester
(
place
,
"def"
,
x_dims
,
axis
));
...
...
@@ -170,8 +183,8 @@ TEST(Transpose, precision) {
#elif defined(LITE_WITH_HUAWEI_ASCEND_NPU)
place
=
TARGET
(
kHuaweiAscendNPU
);
abs_error
=
1e-2
;
// precision_mode default is force_fp16
// #elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL) // NOLINT
//
place = TARGET(kXPU);
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place
=
TARGET
(
kXPU
);
#else
return
;
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录