Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
20caf1db
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,发现更多精彩内容 >>
未验证
提交
20caf1db
编写于
12月 29, 2022
作者:
O
openharmony_ci
提交者:
Gitee
12月 29, 2022
浏览文件
操作
浏览文件
下载
差异文件
!7059 补充mslite xts用例1018
Merge pull request !7059 from wangtongyu6/merge-master-to-monthly1018
上级
f1a37737
00bd4753
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
53 addition
and
1 deletion
+53
-1
ai/mindspore/src/ohos_c_api_test_mslite.cpp
ai/mindspore/src/ohos_c_api_test_mslite.cpp
+53
-1
未找到文件。
ai/mindspore/src/ohos_c_api_test_mslite.cpp
浏览文件 @
20caf1db
...
...
@@ -554,6 +554,22 @@ HWTEST(MSLiteTest, OHOS_Context_CPU_0020, Function | MediumTest | Level1) {
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,调用指针方法
HWTEST
(
MSLiteTest
,
OHOS_Model_Build_0001
,
Function
|
MediumTest
|
Level1
)
{
printf
(
"==========Init Context==========
\n
"
);
...
...
@@ -692,6 +708,42 @@ HWTEST(MSLiteTest, OHOS_Model_Build_0008, Function | MediumTest | Level1) {
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与之前一致
HWTEST
(
MSLiteTest
,
OHOS_Model_Resize_0001
,
Function
|
MediumTest
|
Level1
)
{
printf
(
"==========Init Context==========
\n
"
);
...
...
@@ -1472,7 +1524,7 @@ HWTEST(MSLiteTest, OHOS_Multiple_0001, Function | MediumTest | Level1) {
}
}
//
异
常场景:Model创建一次,Build多次
//
正
常场景:Model创建一次,Build多次
HWTEST
(
MSLiteTest
,
OHOS_Multiple_0002
,
Function
|
MediumTest
|
Level1
)
{
printf
(
"==========Init Context==========
\n
"
);
OH_AI_ContextHandle
context
=
OH_AI_ContextCreate
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录