Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
6b9e8f02
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
6b9e8f02
编写于
1月 03, 2023
作者:
O
openharmony_ci
提交者:
Gitee
1月 03, 2023
浏览文件
操作
浏览文件
下载
差异文件
!7058 补充了mindspore lite的xts用例
Merge pull request !7058 from wangtongyu6/add_ms_xts_real
上级
676d6b70
0a47fe2c
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
58 addition
and
2 deletion
+58
-2
ai/mindspore/BUILD.gn
ai/mindspore/BUILD.gn
+5
-1
ai/mindspore/src/ohos_c_api_test_mslite.cpp
ai/mindspore/src/ohos_c_api_test_mslite.cpp
+53
-1
未找到文件。
ai/mindspore/BUILD.gn
浏览文件 @
6b9e8f02
...
@@ -15,6 +15,10 @@ import("//test/xts/tools/build/suite.gni")
...
@@ -15,6 +15,10 @@ import("//test/xts/tools/build/suite.gni")
module_output_path = "acts/ActsMindSporeTest"
module_output_path = "acts/ActsMindSporeTest"
config("mindspore_config") {
include_dirs = [ "//third_party/mindspore/" ]
}
ohos_moduletest_suite("ActsMindSporeTest") {
ohos_moduletest_suite("ActsMindSporeTest") {
module_out_path = module_output_path
module_out_path = module_output_path
sources = [
sources = [
...
@@ -22,7 +26,7 @@ ohos_moduletest_suite("ActsMindSporeTest") {
...
@@ -22,7 +26,7 @@ ohos_moduletest_suite("ActsMindSporeTest") {
"src/ohos_common.cpp",
"src/ohos_common.cpp",
]
]
include_dirs = [ "//foundation/ai/mindspore/
" ]
configs = [ ":mindspore_config
" ]
deps = [
deps = [
"//third_party/googletest:gmock",
"//third_party/googletest:gmock",
...
...
ai/mindspore/src/ohos_c_api_test_mslite.cpp
浏览文件 @
6b9e8f02
...
@@ -554,6 +554,22 @@ HWTEST(MSLiteTest, OHOS_Context_CPU_0020, Function | MediumTest | Level1) {
...
@@ -554,6 +554,22 @@ HWTEST(MSLiteTest, OHOS_Context_CPU_0020, Function | MediumTest | Level1) {
OH_AI_ModelDestroy
(
&
model
);
OH_AI_ModelDestroy
(
&
model
);
}
}
// 正常场景:Context设置NPU,频率为1
HWTEST
(
MSLiteTest
,
OHOS_Context_NPU_0002
,
Function
|
MediumTest
|
Level1
)
{
printf
(
"==========Init Context==========
\n
"
);
OH_AI_ContextHandle
context
=
OH_AI_ContextCreate
();
ASSERT_NE
(
context
,
nullptr
);
OH_AI_DeviceInfoHandle
npu_device_info
=
OH_AI_DeviceInfoCreate
(
OH_AI_DEVICETYPE_KIRIN_NPU
);
ASSERT_NE
(
npu_device_info
,
nullptr
);
OH_AI_DeviceInfoSetFrequency
(
npu_device_info
,
1
);
int
frequency
=
OH_AI_DeviceInfoGetFrequency
(
npu_device_info
);
ASSERT_EQ
(
frequency
,
1
);
OH_AI_ContextAddDeviceInfo
(
context
,
npu_device_info
);
printf
(
"==========Create model==========
\n
"
);
OH_AI_ModelHandle
model
=
OH_AI_ModelCreate
();
ASSERT_NE
(
model
,
nullptr
);
}
// 正常场景:ModelBuild,调用指针方法
// 正常场景:ModelBuild,调用指针方法
HWTEST
(
MSLiteTest
,
OHOS_Model_Build_0001
,
Function
|
MediumTest
|
Level1
)
{
HWTEST
(
MSLiteTest
,
OHOS_Model_Build_0001
,
Function
|
MediumTest
|
Level1
)
{
printf
(
"==========Init Context==========
\n
"
);
printf
(
"==========Init Context==========
\n
"
);
...
@@ -692,6 +708,42 @@ HWTEST(MSLiteTest, OHOS_Model_Build_0008, Function | MediumTest | Level1) {
...
@@ -692,6 +708,42 @@ HWTEST(MSLiteTest, OHOS_Model_Build_0008, Function | MediumTest | Level1) {
OH_AI_ModelDestroy
(
&
model
);
OH_AI_ModelDestroy
(
&
model
);
}
}
// 正常场景:ModelBuild,调用GetOutputs获取输出
HWTEST
(
MSLiteTest
,
OHOS_Model_Build_0009
,
Function
|
MediumTest
|
Level1
)
{
printf
(
"==========Init Context==========
\n
"
);
OH_AI_ContextHandle
context
=
OH_AI_ContextCreate
();
ASSERT_NE
(
context
,
nullptr
);
AddContextDeviceCPU
(
context
);
printf
(
"==========Create model==========
\n
"
);
OH_AI_ModelHandle
model
=
OH_AI_ModelCreate
();
ASSERT_NE
(
model
,
nullptr
);
printf
(
"==========Model build==========
\n
"
);
OH_AI_ModelBuildFromFile
(
model
,
"/data/test/ml_face_isface.ms"
,
OH_AI_MODELTYPE_MINDIR
,
context
);
printf
(
"==========Model Predict==========
\n
"
);
OH_AI_TensorHandleArray
inputs
=
OH_AI_ModelGetInputs
(
model
);
OH_AI_TensorHandleArray
output
;
FillInputsData
(
inputs
,
"ml_face_isface"
,
false
);
OH_AI_Status
ret
=
OH_AI_ModelPredict
(
model
,
inputs
,
&
output
,
nullptr
,
nullptr
);
ASSERT_EQ
(
ret
,
OH_AI_STATUS_SUCCESS
);
printf
(
"==========GetOutput==========
\n
"
);
OH_AI_TensorHandleArray
outputs
=
OH_AI_ModelGetOutputs
(
model
);
for
(
size_t
i
=
0
;
i
<
outputs
.
handle_num
;
++
i
)
{
OH_AI_TensorHandle
tensor
=
outputs
.
handle_list
[
i
];
int64_t
element_num
=
OH_AI_TensorGetElementNum
(
tensor
);
printf
(
"Tensor name: %s, elements num: %"
PRId64
".
\n
"
,
OH_AI_TensorGetName
(
tensor
),
element_num
);
float
*
output_data
=
reinterpret_cast
<
float
*>
(
OH_AI_TensorGetMutableData
(
tensor
));
printf
(
"output data is:"
);
for
(
int
j
=
0
;
j
<
element_num
&&
j
<=
20
;
++
j
)
{
printf
(
"%f "
,
output_data
[
j
]);
}
printf
(
"
\n
"
);
printf
(
"==========compFp32WithTData==========
\n
"
);
string
expectedDataFile
=
"/data/test/ml_face_isface"
+
std
::
to_string
(
i
)
+
".output"
;
bool
result
=
compFp32WithTData
(
output_data
,
expectedDataFile
,
0.01
,
0.01
,
false
);
EXPECT_EQ
(
result
,
true
);
}
}
// 正常场景:ModelResize,shape与之前一致
// 正常场景:ModelResize,shape与之前一致
HWTEST
(
MSLiteTest
,
OHOS_Model_Resize_0001
,
Function
|
MediumTest
|
Level1
)
{
HWTEST
(
MSLiteTest
,
OHOS_Model_Resize_0001
,
Function
|
MediumTest
|
Level1
)
{
printf
(
"==========Init Context==========
\n
"
);
printf
(
"==========Init Context==========
\n
"
);
...
@@ -1472,7 +1524,7 @@ HWTEST(MSLiteTest, OHOS_Multiple_0001, Function | MediumTest | Level1) {
...
@@ -1472,7 +1524,7 @@ HWTEST(MSLiteTest, OHOS_Multiple_0001, Function | MediumTest | Level1) {
}
}
}
}
//
异
常场景:Model创建一次,Build多次
//
正
常场景:Model创建一次,Build多次
HWTEST
(
MSLiteTest
,
OHOS_Multiple_0002
,
Function
|
MediumTest
|
Level1
)
{
HWTEST
(
MSLiteTest
,
OHOS_Multiple_0002
,
Function
|
MediumTest
|
Level1
)
{
printf
(
"==========Init Context==========
\n
"
);
printf
(
"==========Init Context==========
\n
"
);
OH_AI_ContextHandle
context
=
OH_AI_ContextCreate
();
OH_AI_ContextHandle
context
=
OH_AI_ContextCreate
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录