Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
1bdad804
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看板
未验证
提交
1bdad804
编写于
2月 10, 2023
作者:
O
openharmony_ci
提交者:
Gitee
2月 10, 2023
浏览文件
操作
浏览文件
下载
差异文件
!7522 删除无用的测试用例_1018
Merge pull request !7522 from wangtongyu6/merge-master-to-monthly1018
上级
14ea31e1
51441476
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
1 addition
and
97 deletion
+1
-97
ai/mindspore/src/ohos_c_api_test_mslite.cpp
ai/mindspore/src/ohos_c_api_test_mslite.cpp
+1
-97
未找到文件。
ai/mindspore/src/ohos_c_api_test_mslite.cpp
浏览文件 @
1bdad804
...
...
@@ -60,16 +60,6 @@ void AddContextDeviceCPU(OH_AI_ContextHandle context) {
OH_AI_ContextAddDeviceInfo
(
context
,
cpu_device_info
);
}
// add gpu device info
void
AddContextDeviceGPU
(
OH_AI_ContextHandle
context
)
{
OH_AI_DeviceInfoHandle
gpu_device_info
=
OH_AI_DeviceInfoCreate
(
OH_AI_DEVICETYPE_GPU
);
ASSERT_NE
(
gpu_device_info
,
nullptr
);
OH_AI_DeviceType
device_type
=
OH_AI_DeviceInfoGetDeviceType
(
gpu_device_info
);
printf
(
"==========device_type:%d
\n
"
,
device_type
);
ASSERT_EQ
(
device_type
,
OH_AI_DEVICETYPE_GPU
);
OH_AI_ContextAddDeviceInfo
(
context
,
gpu_device_info
);
}
// fill data to inputs tensor
void
FillInputsData
(
OH_AI_TensorHandleArray
inputs
,
string
model_name
,
bool
is_transpose
)
{
for
(
size_t
i
=
0
;
i
<
inputs
.
handle_num
;
++
i
)
{
...
...
@@ -1077,7 +1067,7 @@ HWTEST(MSLiteTest, OHOS_Tensor_Create_0001, Function | MediumTest | Level1) {
constexpr
size_t
create_shape_num
=
4
;
int64_t
create_shape
[
create_shape_num
]
=
{
1
,
48
,
48
,
3
};
OH_AI_TensorHandle
tensor
=
OH_AI_TensorCreate
(
"data"
,
OH_AI_DATATYPE_NUMBERTYPE_FLOAT32
,
create_shape
,
create_shape_num
,
nullptr
,
static_cast
<
int
>
(
1
*
48
*
48
*
3
*
sizeof
(
float
))
);
create_shape_num
,
nullptr
,
0
);
ASSERT_NE
(
tensor
,
nullptr
);
OH_AI_TensorHandleArray
inputs
=
OH_AI_ModelGetInputs
(
model
);
inputs
.
handle_list
[
0
]
=
tensor
;
...
...
@@ -1439,72 +1429,6 @@ HWTEST(MSLiteTest, OHOS_Input_0001, Function | MediumTest | Level1) {
ModelPredict
(
model
,
context
,
"ml_face_isface"
,
{},
false
,
true
,
false
);
}
// 正常场景:多输入模型
HWTEST
(
MSLiteTest
,
OHOS_Input_0002
,
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
);
ModelPredict
(
model
,
context
,
"ml_headpose_pb2tflite"
,
{},
false
,
false
,
false
);
}
// 正常场景:输入为uint8模型
HWTEST
(
MSLiteTest
,
OHOS_Input_0003
,
Function
|
MediumTest
|
Level1
)
{
printf
(
"==========ReadFile==========
\n
"
);
size_t
size1
;
size_t
*
ptr_size1
=
&
size1
;
const
char
*
imagePath
=
"/data/test/aiy_vision_classifier_plants_V1_3.input"
;
char
*
imageBuf
=
ReadFile
(
imagePath
,
ptr_size1
);
ASSERT_NE
(
imageBuf
,
nullptr
);
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
(
"==========Build model==========
\n
"
);
OH_AI_Status
ret
=
OH_AI_ModelBuildFromFile
(
model
,
"/data/test/aiy_vision_classifier_plants_V1_3.ms"
,
OH_AI_MODELTYPE_MINDIR
,
context
);
printf
(
"==========build model return code:%d
\n
"
,
ret
);
ASSERT_EQ
(
ret
,
OH_AI_STATUS_SUCCESS
);
printf
(
"==========GetInputs==========
\n
"
);
OH_AI_TensorHandleArray
inputs
=
OH_AI_ModelGetInputs
(
model
);
ASSERT_NE
(
inputs
.
handle_list
,
nullptr
);
for
(
size_t
i
=
0
;
i
<
inputs
.
handle_num
;
++
i
)
{
OH_AI_TensorHandle
tensor
=
inputs
.
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
);
void
*
input_data
=
OH_AI_TensorGetMutableData
(
inputs
.
handle_list
[
i
]);
ASSERT_NE
(
input_data
,
nullptr
);
memcpy_s
(
input_data
,
size1
,
imageBuf
,
size1
);
}
printf
(
"==========Model Predict==========
\n
"
);
OH_AI_TensorHandleArray
outputs
;
ret
=
OH_AI_ModelPredict
(
model
,
inputs
,
&
outputs
,
nullptr
,
nullptr
);
ASSERT_EQ
(
ret
,
OH_AI_STATUS_SUCCESS
);
printf
(
"==========GetOutput==========
\n
"
);
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
);
uint8_t
*
output_data
=
reinterpret_cast
<
uint8_t
*>
(
OH_AI_TensorGetMutableData
(
tensor
));
printf
(
"output data is:"
);
for
(
int
j
=
0
;
j
<
element_num
&&
j
<=
20
;
++
j
)
{
printf
(
"%d "
,
output_data
[
j
]);
}
printf
(
"
\n
"
);
printf
(
"==========compFp32WithTData==========
\n
"
);
string
expectedDataFile
=
"/data/test/aiy_vision_classifier_plants_V1_3"
+
std
::
to_string
(
i
)
+
".output"
;
bool
result
=
compUint8WithTData
(
output_data
,
expectedDataFile
,
0.01
,
0.01
,
false
);
EXPECT_EQ
(
result
,
true
);
}
delete
[]
imageBuf
;
OH_AI_ModelDestroy
(
&
model
);
}
// 正常场景:量化模型
HWTEST
(
MSLiteTest
,
OHOS_Input_0004
,
Function
|
MediumTest
|
Level1
)
{
...
...
@@ -1525,26 +1449,6 @@ HWTEST(MSLiteTest, OHOS_Multiple_0001, Function | MediumTest | Level1) {
}
}
// 正常场景:Model创建一次,Build多次
HWTEST
(
MSLiteTest
,
OHOS_Multiple_0002
,
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
(
"==========Build model==========
\n
"
);
OH_AI_Status
ret
=
OH_AI_ModelBuildFromFile
(
model
,
"/data/test/ml_face_isface.ms"
,
OH_AI_MODELTYPE_MINDIR
,
context
);
printf
(
"==========build model return code:%d
\n
"
,
ret
);
ASSERT_EQ
(
ret
,
OH_AI_STATUS_SUCCESS
);
printf
(
"==========Build model==========
\n
"
);
OH_AI_Status
ret2
=
OH_AI_ModelBuildFromFile
(
model
,
"/data/test/ml_face_isface.ms"
,
OH_AI_MODELTYPE_MINDIR
,
context
);
printf
(
"==========build model return code:%d
\n
"
,
ret2
);
ASSERT_EQ
(
ret2
,
OH_AI_STATUS_SUCCESS
);
OH_AI_ModelDestroy
(
&
model
);
}
// 正常场景:Model创建一次,Build一次,Predict多次
HWTEST
(
MSLiteTest
,
OHOS_Multiple_0003
,
Function
|
MediumTest
|
Level1
)
{
printf
(
"==========Init Context==========
\n
"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录