1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "neural_network_runtime_test.h"
17 
18 #include "mindir.h"
19 
20 #include "common/utils.h"
21 #include "compilation.h"
22 #include "hdi_device_v2_0.h"
23 #include "test/unittest/common/v2_0/mock_idevice.h"
24 
25 namespace OHOS {
26 namespace NeuralNetworkRuntime {
PrepareModel(std::shared_ptr<const mindspore::lite::LiteGraph> model,const ModelConfig & config,std::shared_ptr<PreparedModel> & preparedModel)27 OH_NN_ReturnCode HDIDeviceV2_0::PrepareModel(std::shared_ptr<const mindspore::lite::LiteGraph> model,
28     const ModelConfig& config, std::shared_ptr<PreparedModel>& preparedModel)
29 {
30     if (model == nullptr) {
31         return OH_NN_INVALID_PARAMETER;
32     }
33 
34     if (config.enableFloat16 == false) {
35         return OH_NN_FAILED;
36     }
37 
38     sptr<OHOS::HDI::Nnrt::V2_0::IPreparedModel> iPreparedModel = sptr<OHOS::HDI::Nnrt::V2_0
39         ::MockIPreparedModel>(new OHOS::HDI::Nnrt::V2_0::MockIPreparedModel());
40     if (iPreparedModel == nullptr) {
41         LOGE("HDIDeviceV2_0 mock PrepareModel failed, error happened when new sptr");
42         return OH_NN_NULL_PTR;
43     }
44 
45     preparedModel = CreateSharedPtr<HDIPreparedModelV2_0>(iPreparedModel);
46     return OH_NN_SUCCESS;
47 }
48 
GetDeviceType(OH_NN_DeviceType & deviceType)49 OH_NN_ReturnCode HDIDeviceV2_0::GetDeviceType(OH_NN_DeviceType& deviceType)
50 {
51     if (deviceType == OH_NN_OTHERS) {
52         return OH_NN_UNAVAILABLE_DEVICE;
53     }
54 
55     return OH_NN_SUCCESS;
56 }
57 
IsModelCacheSupported(bool & isSupported)58 OH_NN_ReturnCode HDIDeviceV2_0::IsModelCacheSupported(bool& isSupported)
59 {
60     isSupported = true;
61     return OH_NN_SUCCESS;
62 }
63 
IsPerformanceModeSupported(bool & isSupported)64 OH_NN_ReturnCode HDIDeviceV2_0::IsPerformanceModeSupported(bool& isSupported)
65 {
66     isSupported = true;
67     return OH_NN_SUCCESS;
68 }
69 
IsPrioritySupported(bool & isSupported)70 OH_NN_ReturnCode HDIDeviceV2_0::IsPrioritySupported(bool& isSupported)
71 {
72     isSupported = true;
73     return OH_NN_SUCCESS;
74 }
75 
IsFloat16PrecisionSupported(bool & isSupported)76 OH_NN_ReturnCode HDIDeviceV2_0::IsFloat16PrecisionSupported(bool& isSupported)
77 {
78     isSupported = true;
79     return OH_NN_SUCCESS;
80 }
81 
GetSupportedOperation(std::shared_ptr<const mindspore::lite::LiteGraph> model,std::vector<bool> & ops)82 OH_NN_ReturnCode HDIDeviceV2_0::GetSupportedOperation(std::shared_ptr<const mindspore::lite::LiteGraph> model,
83     std::vector<bool>& ops)
84 {
85     if (model == nullptr) {
86         LOGE("HDIDeviceV2_0 mock GetSupportedOperation failed, Model is nullptr, cannot query supported operation.");
87         return OH_NN_NULL_PTR;
88     }
89 
90     ops.emplace_back(true);
91     return OH_NN_SUCCESS;
92 }
93 
IsDynamicInputSupported(bool & isSupported)94 OH_NN_ReturnCode HDIDeviceV2_0::IsDynamicInputSupported(bool& isSupported)
95 {
96     isSupported = true;
97     return OH_NN_SUCCESS;
98 }
99 } // namespace NeuralNetworkRuntime
100 } // namespace OHOS
101 
102 namespace OHOS {
103 namespace NeuralNetworkRuntime {
104 namespace Unittest {
BuildModel(InnerModel & model)105 OH_NN_ReturnCode NeuralNetworkRuntimeTest::BuildModel(InnerModel& model)
106 {
107     int32_t inputDims[2] = {3, 4};
108     OH_NN_Tensor input1 = {OH_NN_FLOAT32, 2, inputDims, nullptr, OH_NN_TENSOR};
109     OH_NN_ReturnCode ret = model.AddTensor(input1);
110     if (ret != OH_NN_SUCCESS) {
111         return ret;
112     }
113 
114     // 添加Add算子的第二个输入Tensor,类型为float32,张量形状为[3, 4]
115     OH_NN_Tensor input2 = {OH_NN_FLOAT32, 2, inputDims, nullptr, OH_NN_TENSOR};
116     ret = model.AddTensor(input2);
117     if (ret != OH_NN_SUCCESS) {
118         return ret;
119     }
120 
121     // 添加Add算子的参数Tensor,该参数Tensor用于指定激活函数的类型,Tensor的数据类型为int8。
122     int32_t activationDims = 1;
123     int8_t activationValue = OH_NN_FUSED_NONE;
124     OH_NN_Tensor activation = {OH_NN_INT8, 1, &activationDims, nullptr, OH_NN_ADD_ACTIVATIONTYPE};
125     ret = model.AddTensor(activation);
126     if (ret != OH_NN_SUCCESS) {
127         return ret;
128     }
129 
130     // 将激活函数类型设置为OH_NN_FUSED_NONE,表示该算子不添加激活函数。
131     uint32_t index = 2;
132     ret = model.SetTensorValue(index, &activationValue, sizeof(int8_t));
133     if (ret != OH_NN_SUCCESS) {
134         return ret;
135     }
136 
137     // 设置Add算子的输出,类型为float32,张量形状为[3, 4]
138     OH_NN_Tensor output = {OH_NN_FLOAT32, 2, inputDims, nullptr, OH_NN_TENSOR};
139     ret = model.AddTensor(output);
140     if (ret != OH_NN_SUCCESS) {
141         return ret;
142     }
143 
144     // 指定Add算子的输入、参数和输出索引
145     uint32_t inputIndicesValues[2] = {0, 1};
146     uint32_t paramIndicesValues = 2;
147     uint32_t outputIndicesValues = 3;
148     OH_NN_UInt32Array paramIndices = {&paramIndicesValues, 1};
149     OH_NN_UInt32Array inputIndices = {inputIndicesValues, 2};
150     OH_NN_UInt32Array outputIndices = {&outputIndicesValues, 1};
151 
152     // 向模型实例添加Add算子
153     ret = model.AddOperation(OH_NN_OPS_ADD, paramIndices, inputIndices, outputIndices);
154     if (ret != OH_NN_SUCCESS) {
155         return ret;
156     }
157 
158     // 设置模型实例的输入、输出索引
159     ret = model.SpecifyInputsAndOutputs(inputIndices, outputIndices);
160     if (ret != OH_NN_SUCCESS) {
161         return ret;
162     }
163 
164     // 完成模型实例的构建
165     ret = model.Build();
166     if (ret != OH_NN_SUCCESS) {
167         return ret;
168     }
169 
170     return ret;
171 }
172 
InitIndices()173 void NeuralNetworkRuntimeTest::InitIndices()
174 {
175     m_inputIndices.data = m_inputIndexs;
176     m_inputIndices.size = sizeof(m_inputIndexs) / sizeof(uint32_t);
177 
178     m_outputIndices.data = m_outputIndexs;
179     m_outputIndices.size = sizeof(m_outputIndexs) / sizeof(uint32_t);
180 
181     m_paramIndices.data = m_paramIndexs;
182     m_paramIndices.size = sizeof(m_paramIndexs) / sizeof(uint32_t);
183 }
184 
AddModelTensor(InnerModel & innerModel)185 void NeuralNetworkRuntimeTest::AddModelTensor(InnerModel& innerModel)
186 {
187     const int dim[2] = {2, 2};
188     const OH_NN_Tensor& tensor = {OH_NN_FLOAT32, 2, dim, nullptr, OH_NN_TENSOR};
189 
190     EXPECT_EQ(OH_NN_SUCCESS, innerModel.AddTensor(tensor));
191     EXPECT_EQ(OH_NN_SUCCESS, innerModel.AddTensor(tensor));
192     EXPECT_EQ(OH_NN_SUCCESS, innerModel.AddTensor(tensor));
193 
194     const OH_NN_Tensor& tensorParam = {OH_NN_INT8, 0, nullptr, nullptr, OH_NN_ADD_ACTIVATIONTYPE};
195     EXPECT_EQ(OH_NN_SUCCESS, innerModel.AddTensor(tensorParam));
196 }
197 
SetTensor()198 void NeuralNetworkRuntimeTest::SetTensor()
199 {
200     m_tensor.dataType = OH_NN_INT32;
201     m_tensor.dimensionCount = 0;
202     m_tensor.dimensions = nullptr;
203     m_tensor.quantParam = nullptr;
204     m_tensor.type = OH_NN_TENSOR;
205 }
206 
SetInnerBuild(InnerModel & innerModel)207 void NeuralNetworkRuntimeTest::SetInnerBuild(InnerModel& innerModel)
208 {
209     uint32_t index = 3;
210     const int8_t activation = 0;
211     EXPECT_EQ(OH_NN_SUCCESS, innerModel.SetTensorValue(index,
212         static_cast<const void *>(&activation), sizeof(int8_t)));
213 
214     OH_NN_OperationType opType {OH_NN_OPS_ADD};
215     EXPECT_EQ(OH_NN_SUCCESS, innerModel.AddOperation(opType, m_paramIndices, m_inputIndices, m_outputIndices));
216     EXPECT_EQ(OH_NN_SUCCESS, innerModel.SpecifyInputsAndOutputs(m_inputIndices, m_outputIndices));
217     EXPECT_EQ(OH_NN_SUCCESS, innerModel.Build());
218 }
219 
SetInputAndOutput(Executor & executor)220 void NeuralNetworkRuntimeTest::SetInputAndOutput(Executor& executor)
221 {
222     size_t input1Index = 0;
223     int32_t inputDims[2] = {3, 4};
224     size_t lengthSize = 12 * sizeof(float);
225     size_t *length = &lengthSize;
226 
227     size_t minInputDims = 1;
228     size_t maxInputDims = 12;
229 
230     size_t *minInputDimsAdress = &minInputDims;
231     size_t **minInputDimsAdressA = &minInputDimsAdress;
232 
233     size_t *maxInputDimsAdress = &maxInputDims;
234     size_t **maxInputDimsAdressA = &maxInputDimsAdress;
235 
236     m_tensor = {OH_NN_FLOAT32, 2, inputDims, nullptr, OH_NN_TENSOR};
237     EXPECT_EQ(OH_NN_SUCCESS, executor.GetInputDimRange(input1Index, minInputDimsAdressA, maxInputDimsAdressA, length));
238     uint32_t outputIndex = 0;
239 
240     int32_t shape = 3;
241     int32_t* shapeA = &shape;
242     int32_t** shapeAA = &shapeA;
243     uint32_t* shapeNum = &outputIndex;
244     EXPECT_EQ(OH_NN_SUCCESS, executor.GetOutputShape(outputIndex, shapeAA, shapeNum));
245 }
246 
247 /*
248  * @tc.name: model_construct_001
249  * @tc.desc: Verify the return model of the OH_NNModel_Construct function.
250  * @tc.type: FUNC
251  */
252 HWTEST_F(NeuralNetworkRuntimeTest, model_construct_001, testing::ext::TestSize.Level0)
253 {
254     OH_NNModel* ret = OH_NNModel_Construct();
255     EXPECT_NE(nullptr, ret);
256 }
257 
258 /*
259  * @tc.name: model_add_tensor_001
260  * @tc.desc: Verify the OH_NNModel is nullptr of the OH_NNModel_Tensor function.
261  * @tc.type: FUNC
262  */
263 HWTEST_F(NeuralNetworkRuntimeTest, model_add_tensor_001, testing::ext::TestSize.Level0)
264 {
265     OH_NNModel* model = nullptr;
266     const int32_t dimInput[2] = {2, 2};
267     const OH_NN_Tensor tensor = {OH_NN_INT8, 2, dimInput, nullptr, OH_NN_TENSOR};
268     OH_NN_ReturnCode ret = OH_NNModel_AddTensor(model, &tensor);
269     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
270 }
271 
272 /*
273  * @tc.name: model_add_tensor_002
274  * @tc.desc: Verify the OH_NN_Tensor is nullptr of the OH_NNModel_AddTensor function.
275  * @tc.type: FUNC
276  */
277 HWTEST_F(NeuralNetworkRuntimeTest, model_add_tensor_002, testing::ext::TestSize.Level0)
278 {
279     InnerModel innerModel;
280 
281     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
282     OH_NN_Tensor* tensor = nullptr;
283     OH_NN_ReturnCode ret = OH_NNModel_AddTensor(model, tensor);
284     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
285 }
286 
287 /*
288  * @tc.name: model_add_tensor_003
289  * @tc.desc: Verify the success of the OH_NNModel_AddTensor function.
290  * @tc.type: FUNC
291  */
292 HWTEST_F(NeuralNetworkRuntimeTest, model_add_tensor_003, testing::ext::TestSize.Level0)
293 {
294     InnerModel innerModel;
295     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
296 
297     const int32_t dimInput[2] = {2, 2};
298     const OH_NN_Tensor tensor = {OH_NN_INT8, 2, dimInput, nullptr, OH_NN_TENSOR};
299     OH_NN_ReturnCode ret = OH_NNModel_AddTensor(model, &tensor);
300     EXPECT_EQ(OH_NN_SUCCESS, ret);
301 }
302 
303 /*
304  * @tc.name: model_add_operation_001
305  * @tc.desc: Verify the OH_NNModel is nullptr of the OH_NNModel_AddOperation function.
306  * @tc.type: FUNC
307  */
308 HWTEST_F(NeuralNetworkRuntimeTest, model_add_operation_001, testing::ext::TestSize.Level0)
309 {
310     InnerModel innerModel;
311     OH_NNModel* model = nullptr;
312     OH_NN_OperationType opType {OH_NN_OPS_ADD};
313 
314     InitIndices();
315     AddModelTensor(innerModel);
316 
317     uint32_t index = 3;
318     const int8_t activation = 0;
319     EXPECT_EQ(OH_NN_SUCCESS, innerModel.SetTensorValue(index,
320         static_cast<const void *>(&activation), sizeof(int8_t)));
321 
322     OH_NN_ReturnCode ret = OH_NNModel_AddOperation(model, opType, &m_paramIndices, &m_inputIndices, &m_outputIndices);
323     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
324 }
325 
326 /*
327  * @tc.name: model_add_operation_002
328  * @tc.desc: Verify the paramIndices is nullptr of the OH_NNModel_AddOperation function.
329  * @tc.type: FUNC
330  */
331 HWTEST_F(NeuralNetworkRuntimeTest, model_add_operation_002, testing::ext::TestSize.Level0)
332 {
333     InnerModel innerModel;
334     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
335     OH_NN_OperationType opType {OH_NN_OPS_ADD};
336 
337     m_inputIndices.data = m_inputIndexs;
338     m_inputIndices.size = sizeof(m_inputIndexs) / sizeof(uint32_t);
339 
340     m_outputIndices.data = m_outputIndexs;
341     m_outputIndices.size = sizeof(m_outputIndexs) / sizeof(uint32_t);
342 
343     AddModelTensor(innerModel);
344     uint32_t index = 3;
345     const int8_t activation = 0;
346     EXPECT_EQ(OH_NN_SUCCESS, innerModel.SetTensorValue(index,
347         static_cast<const void *>(&activation), sizeof(int8_t)));
348 
349     OH_NN_ReturnCode ret = OH_NNModel_AddOperation(model, opType, nullptr, &m_inputIndices, &m_outputIndices);
350     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
351 }
352 
353 /*
354  * @tc.name: model_add_operation_003
355  * @tc.desc: Verify the inputIndices is nullptr of the OH_NNModel_AddOperation function.
356  * @tc.type: FUNC
357  */
358 HWTEST_F(NeuralNetworkRuntimeTest, model_add_operation_003, testing::ext::TestSize.Level0)
359 {
360     InnerModel innerModel;
361     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
362     OH_NN_OperationType opType {OH_NN_OPS_ADD};
363 
364     m_paramIndices.data = m_paramIndexs;
365     m_paramIndices.size = sizeof(m_paramIndexs) / sizeof(uint32_t);
366 
367     m_outputIndices.data = m_outputIndexs;
368     m_outputIndices.size = sizeof(m_outputIndexs) / sizeof(uint32_t);
369 
370     AddModelTensor(innerModel);
371     uint32_t index = 3;
372     const int8_t activation = 0;
373     EXPECT_EQ(OH_NN_SUCCESS, innerModel.SetTensorValue(index,
374         static_cast<const void *>(&activation), sizeof(int8_t)));
375 
376     OH_NN_ReturnCode ret = OH_NNModel_AddOperation(model, opType, &m_paramIndices, nullptr, &m_outputIndices);
377     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
378 }
379 
380 /*
381  * @tc.name: model_add_operation_004
382  * @tc.desc: Verify the outputIndices is nullptr of the OH_NNModel_AddOperation function.
383  * @tc.type: FUNC
384  */
385 HWTEST_F(NeuralNetworkRuntimeTest, model_add_operation_004, testing::ext::TestSize.Level0)
386 {
387     InnerModel innerModel;
388     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
389     OH_NN_OperationType opType {OH_NN_OPS_ADD};
390 
391     m_paramIndices.data = m_paramIndexs;
392     m_paramIndices.size = sizeof(m_paramIndexs) / sizeof(uint32_t);
393 
394     m_inputIndices.data = m_inputIndexs;
395     m_inputIndices.size = sizeof(m_inputIndexs) / sizeof(uint32_t);
396 
397     AddModelTensor(innerModel);
398     uint32_t index = 3;
399     const int8_t activation = 0;
400     EXPECT_EQ(OH_NN_SUCCESS, innerModel.SetTensorValue(index,
401         static_cast<const void *>(&activation), sizeof(int8_t)));
402 
403     OH_NN_ReturnCode ret = OH_NNModel_AddOperation(model, opType, &m_paramIndices, &m_inputIndices, nullptr);
404     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
405 }
406 
407 /*
408  * @tc.name: model_add_operation_005
409  * @tc.desc: Verify the success of the OH_NNModel_AddOperation function.
410  * @tc.type: FUNC
411  */
412 HWTEST_F(NeuralNetworkRuntimeTest, model_add_operation_005, testing::ext::TestSize.Level0)
413 {
414     InnerModel innerModel;
415     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
416     OH_NN_OperationType opType {OH_NN_OPS_ADD};
417 
418     InitIndices();
419     AddModelTensor(innerModel);
420 
421     uint32_t index = 3;
422     const int8_t activation = 0;
423     EXPECT_EQ(OH_NN_SUCCESS, innerModel.SetTensorValue(index,
424         static_cast<const void *>(&activation), sizeof(int8_t)));
425 
426     OH_NN_ReturnCode ret = OH_NNModel_AddOperation(model, opType, &m_paramIndices, &m_inputIndices, &m_outputIndices);
427     EXPECT_EQ(OH_NN_SUCCESS, ret);
428 }
429 
430 /*
431  * @tc.name: model_set_tensor_data_001
432  * @tc.desc: Verify the OH_NNModel is nullptr of the OH_NNModel_SetTensorData function.
433  * @tc.type: FUNC
434  */
435 HWTEST_F(NeuralNetworkRuntimeTest, model_set_tensor_data_001, testing::ext::TestSize.Level0)
436 {
437     InnerModel innerModel;
438     OH_NNModel* model = nullptr;
439     AddModelTensor(innerModel);
440 
441     uint32_t index = 3;
442     const int8_t activation = 0;
443 
444     OH_NN_ReturnCode ret = OH_NNModel_SetTensorData(model, index, static_cast<const void *>(&activation),
445         sizeof(int8_t));
446     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
447 }
448 
449 /*
450  * @tc.name: model_set_tensor_data_002
451  * @tc.desc: Verify the data is nullptr of the OH_NNModel_SetTensorData function.
452  * @tc.type: FUNC
453  */
454 HWTEST_F(NeuralNetworkRuntimeTest, model_set_tensor_data_002, testing::ext::TestSize.Level0)
455 {
456     InnerModel innerModel;
457     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
458     AddModelTensor(innerModel);
459 
460     uint32_t index = 3;
461 
462     OH_NN_ReturnCode ret = OH_NNModel_SetTensorData(model, index, nullptr, sizeof(int8_t));
463     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
464 }
465 
466 /*
467  * @tc.name: model_set_tensor_data_003
468  * @tc.desc: Verify the length is 0 of the OH_NNModel_SetTensorData function.
469  * @tc.type: FUNC
470  */
471 HWTEST_F(NeuralNetworkRuntimeTest, model_set_tensor_data_003, testing::ext::TestSize.Level0)
472 {
473     InnerModel innerModel;
474     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
475     AddModelTensor(innerModel);
476 
477     uint32_t index = 3;
478     const int8_t activation = 0;
479 
480     OH_NN_ReturnCode ret = OH_NNModel_SetTensorData(model, index, static_cast<const void *>(&activation), 0);
481     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
482 }
483 
484 /*
485  * @tc.name: model_set_tensor_data_004
486  * @tc.desc: Verify the successs of the OH_NNModel_SetTensorData function.
487  * @tc.type: FUNC
488  */
489 HWTEST_F(NeuralNetworkRuntimeTest, model_set_tensor_data_004, testing::ext::TestSize.Level0)
490 {
491     InnerModel innerModel;
492     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
493     AddModelTensor(innerModel);
494 
495     uint32_t index = 3;
496     const int8_t activation = 0;
497 
498     OH_NN_ReturnCode ret = OH_NNModel_SetTensorData(model, index, static_cast<const void *>(&activation),
499         sizeof(int8_t));
500     EXPECT_EQ(OH_NN_SUCCESS, ret);
501 }
502 
503 /*
504  * @tc.name: model_specify_inputs_and_outputs_001
505  * @tc.desc: Verify the OH_NNModel is nullptr of the OH_NNModel_SpecifyInputsAndOutputs function.
506  * @tc.type: FUNC
507  */
508 HWTEST_F(NeuralNetworkRuntimeTest, model_specify_inputs_and_outputs_001, testing::ext::TestSize.Level0)
509 {
510     InnerModel innerModel;
511     OH_NNModel* model = nullptr;
512 
513     InitIndices();
514     AddModelTensor(innerModel);
515 
516     OH_NN_ReturnCode ret = OH_NNModel_SpecifyInputsAndOutputs(model, &m_inputIndices, &m_outputIndices);
517     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
518 }
519 
520 /*
521  * @tc.name: model_specify_inputs_and_outputs_002
522  * @tc.desc: Verify the inputIndices is nullptr of the OH_NNModel_SpecifyInputsAndOutputs function.
523  * @tc.type: FUNC
524  */
525 HWTEST_F(NeuralNetworkRuntimeTest, model_specify_inputs_and_outputs_002, testing::ext::TestSize.Level0)
526 {
527     InnerModel innerModel;
528     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
529 
530     InitIndices();
531     AddModelTensor(innerModel);
532 
533     OH_NN_ReturnCode ret = OH_NNModel_SpecifyInputsAndOutputs(model, nullptr, &m_outputIndices);
534     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
535 }
536 
537 /*
538  * @tc.name: model_specify_inputs_and_outputs_003
539  * @tc.desc: Verify the outputIndices is nullptr of the OH_NNModel_SpecifyInputsAndOutputs function.
540  * @tc.type: FUNC
541  */
542 HWTEST_F(NeuralNetworkRuntimeTest, model_specify_inputs_and_outputs_003, testing::ext::TestSize.Level0)
543 {
544     InnerModel innerModel;
545     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
546 
547     InitIndices();
548     AddModelTensor(innerModel);
549 
550     OH_NN_ReturnCode ret = OH_NNModel_SpecifyInputsAndOutputs(model, &m_inputIndices, nullptr);
551     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
552 }
553 
554 /*
555  * @tc.name: model_specify_inputs_and_outputs_004
556  * @tc.desc: Verify the success of the OH_NNModel_SpecifyInputsAndOutputs function.
557  * @tc.type: FUNC
558  */
559 HWTEST_F(NeuralNetworkRuntimeTest, model_specify_inputs_and_outputs_004, testing::ext::TestSize.Level0)
560 {
561     InnerModel innerModel;
562     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
563 
564     InitIndices();
565     AddModelTensor(innerModel);
566 
567     OH_NN_ReturnCode ret = OH_NNModel_SpecifyInputsAndOutputs(model, &m_inputIndices, &m_outputIndices);
568     EXPECT_EQ(OH_NN_SUCCESS, ret);
569 }
570 
571 /*
572  * @tc.name: model_finish_001
573  * @tc.desc: Verify the OH_NNModel is nullptr of the OH_NNModel_Finish function.
574  * @tc.type: FUNC
575  */
576 HWTEST_F(NeuralNetworkRuntimeTest, model_finish_001, testing::ext::TestSize.Level0)
577 {
578     InnerModel innerModel;
579     OH_NNModel* model = nullptr;
580 
581     OH_NN_OperationType opType {OH_NN_OPS_ADD};
582 
583     InitIndices();
584     AddModelTensor(innerModel);
585 
586     uint32_t index = 3;
587     const int8_t activation = 0;
588     EXPECT_EQ(OH_NN_SUCCESS, innerModel.SetTensorValue(index, static_cast<const void *>(&activation),
589         sizeof(int8_t)));
590 
591     EXPECT_EQ(OH_NN_SUCCESS, innerModel.AddOperation(opType, m_paramIndices, m_inputIndices, m_outputIndices));
592     EXPECT_EQ(OH_NN_SUCCESS, innerModel.SpecifyInputsAndOutputs(m_inputIndices, m_outputIndices));
593 
594     OH_NN_ReturnCode ret = OH_NNModel_Finish(model);
595     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
596 }
597 
598 /*
599  * @tc.name: model_finish_002
600  * @tc.desc: Verify the success of the OH_NNModel_Finish function.
601  * @tc.type: FUNC
602  */
603 HWTEST_F(NeuralNetworkRuntimeTest, model_finish_002, testing::ext::TestSize.Level0)
604 {
605     InnerModel innerModel;
606     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
607 
608     OH_NN_OperationType opType {OH_NN_OPS_ADD};
609 
610     InitIndices();
611     AddModelTensor(innerModel);
612 
613     const int8_t activation = 0;
614     uint32_t index = 3;
615     EXPECT_EQ(OH_NN_SUCCESS, innerModel.SetTensorValue(index,
616         static_cast<const void *>(&activation), sizeof(int8_t)));
617 
618     EXPECT_EQ(OH_NN_SUCCESS, innerModel.AddOperation(opType, m_paramIndices, m_inputIndices, m_outputIndices));
619     EXPECT_EQ(OH_NN_SUCCESS, innerModel.SpecifyInputsAndOutputs(m_inputIndices, m_outputIndices));
620 
621     OH_NN_ReturnCode ret = OH_NNModel_Finish(model);
622     EXPECT_EQ(OH_NN_SUCCESS, ret);
623 }
624 
625 /*
626  * @tc.name: model_destroy_001
627  * @tc.desc: Verify the OH_NNModel is nullptr of the OH_NNModel_Destroy function.
628  * @tc.type: FUNC
629  */
630 HWTEST_F(NeuralNetworkRuntimeTest, model_destroy_001, testing::ext::TestSize.Level0)
631 {
632     InnerModel innerModel;
633     OH_NNModel** pModel = nullptr;
634     OH_NNModel_Destroy(pModel);
635     EXPECT_EQ(nullptr, pModel);
636 }
637 
638 /*
639  * @tc.name: model_destroy_002
640  * @tc.desc: Verify the *OH_NNModel is nullptr of the OH_NNModel_Destroy function.
641  * @tc.type: FUNC
642  */
643 HWTEST_F(NeuralNetworkRuntimeTest, model_destroy_002, testing::ext::TestSize.Level0)
644 {
645     InnerModel innerModel;
646     OH_NNModel* model = nullptr;
647     OH_NNModel** pModel = &model;
648     OH_NNModel_Destroy(pModel);
649     EXPECT_EQ(nullptr, model);
650 }
651 
652 /*
653  * @tc.name: model_destroy_003
654  * @tc.desc: Verify the normal model of the OH_NNModel_Destroy function.
655  * @tc.type: FUNC
656  */
657 HWTEST_F(NeuralNetworkRuntimeTest, model_destroy_003, testing::ext::TestSize.Level0)
658 {
659     InnerModel* innerModel = new InnerModel();
660     EXPECT_NE(nullptr, innerModel);
661     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(innerModel);
662     OH_NNModel_Destroy(&model);
663     EXPECT_EQ(nullptr, model);
664 }
665 
666 /*
667  * @tc.name: model_get_available_operation_001
668  * @tc.desc: Verify the OH_NNModel is nullptr of the OH_NNModel_GetAvailableOperations function.
669  * @tc.type: FUNC
670  */
671 HWTEST_F(NeuralNetworkRuntimeTest, model_get_available_operation_001, testing::ext::TestSize.Level0)
672 {
673     InnerModel innerModel;
674     OH_NNModel* model = nullptr;
675 
676     uint32_t opCount = 1;
677     const bool *pIsAvailable = nullptr;
678 
679     InitIndices();
680     AddModelTensor(innerModel);
681     SetInnerBuild(innerModel);
682 
683     size_t deviceID = 10;
684     OH_NN_ReturnCode ret = OH_NNModel_GetAvailableOperations(model, deviceID, &pIsAvailable, &opCount);
685     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
686 }
687 
688 /*
689  * @tc.name: model_get_available_operation_002
690  * @tc.desc: Verify the isAvailable is nullptr of the OH_NNModel_GetAvailableOperations function.
691  * @tc.type: FUNC
692  */
693 HWTEST_F(NeuralNetworkRuntimeTest, model_get_available_operation_002, testing::ext::TestSize.Level0)
694 {
695     InnerModel innerModel;
696     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
697 
698     uint32_t opCount = 1;
699     InitIndices();
700     AddModelTensor(innerModel);
701     SetInnerBuild(innerModel);
702 
703     size_t deviceID = 10;
704     OH_NN_ReturnCode ret = OH_NNModel_GetAvailableOperations(model, deviceID, nullptr, &opCount);
705     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
706 }
707 
708 /*
709  * @tc.name: model_get_available_operation_003
710  * @tc.desc: Verify the *isAvailable is no nullptr of the OH_NNModel_GetAvailableOperations function.
711  * @tc.type: FUNC
712  */
713 HWTEST_F(NeuralNetworkRuntimeTest, model_get_available_operation_003, testing::ext::TestSize.Level0)
714 {
715     InnerModel innerModel;
716     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
717 
718     const bool isAvailable = true;
719     const bool *pIsAvailable = &isAvailable;
720     uint32_t opCount = 1;
721 
722     InitIndices();
723     AddModelTensor(innerModel);
724     SetInnerBuild(innerModel);
725 
726     size_t deviceID = 10;
727     OH_NN_ReturnCode ret = OH_NNModel_GetAvailableOperations(model, deviceID, &pIsAvailable, &opCount);
728     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
729 }
730 
731 /*
732  * @tc.name: model_get_available_operation_004
733  * @tc.desc: Verify the opCount is nullptr of the OH_NNModel_GetAvailableOperations function.
734  * @tc.type: FUNC
735  */
736 HWTEST_F(NeuralNetworkRuntimeTest, model_get_available_operation_004, testing::ext::TestSize.Level0)
737 {
738     InnerModel innerModel;
739     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
740 
741     const bool *pIsAvailable = nullptr;
742     uint32_t* opCount = nullptr;
743 
744     InitIndices();
745     AddModelTensor(innerModel);
746     SetInnerBuild(innerModel);
747 
748     size_t deviceID = 10;
749     OH_NN_ReturnCode ret = OH_NNModel_GetAvailableOperations(model, deviceID, &pIsAvailable, opCount);
750     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
751 }
752 
753 /*
754  * @tc.name: model_get_available_operation_005
755  * @tc.desc: Verify the success of the OH_NNModel_GetAvailableOperations function.
756  * @tc.type: FUNC
757  */
758 HWTEST_F(NeuralNetworkRuntimeTest, model_get_available_operation_005, testing::ext::TestSize.Level0)
759 {
760     InnerModel innerModel;
761     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
762 
763     const bool *pIsAvailable = nullptr;
764     uint32_t opCount = 1;
765 
766     InitIndices();
767     AddModelTensor(innerModel);
768     SetInnerBuild(innerModel);
769 
770     size_t deviceID = 10;
771     OH_NN_ReturnCode ret = OH_NNModel_GetAvailableOperations(model, deviceID, &pIsAvailable, &opCount);
772     EXPECT_EQ(OH_NN_FAILED, ret);
773 }
774 
775 /*
776  * @tc.name: compilation_construct_001
777  * @tc.desc: Verify the OH_NNModel is nullptr of the OH_NNCompilation_Construct function.
778  * @tc.type: FUNC
779  */
780 HWTEST_F(NeuralNetworkRuntimeTest, compilation_construct_001, testing::ext::TestSize.Level0)
781 {
782     InnerModel innerModel;
783     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
784     const OH_NNModel* model = nullptr;
785     OH_NNCompilation* ret = OH_NNCompilation_Construct(model);
786     EXPECT_EQ(nullptr, ret);
787 }
788 
789 /*
790  * @tc.name: compilation_construct_002
791  * @tc.desc: Verify the not OH_NNModel_Build before creating compilation of the OH_NNCompilation_Construct function.
792  * @tc.type: FUNC
793  */
794 HWTEST_F(NeuralNetworkRuntimeTest, compilation_construct_002, testing::ext::TestSize.Level0)
795 {
796     InnerModel innerModel;
797     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
798     OH_NNCompilation* ret = OH_NNCompilation_Construct(model);
799     EXPECT_NE(nullptr, ret);
800 }
801 
802 /*
803  * @tc.name: compilation_construct_003
804  * @tc.desc: Verify the normal model of the OH_NNCompilation_Construct function.
805  * @tc.type: FUNC
806  */
807 HWTEST_F(NeuralNetworkRuntimeTest, compilation_construct_003, testing::ext::TestSize.Level0)
808 {
809     InnerModel innerModel;
810     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
811     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
812     OH_NNCompilation* ret = OH_NNCompilation_Construct(model);
813     EXPECT_NE(nullptr, ret);
814 }
815 
816 /*
817  * @tc.name: compilation_set_device_001
818  * @tc.desc: Verify the OH_NNCompilation is nullptr of the OH_NNCompilation_SetDevice function.
819  * @tc.type: FUNC
820  */
821 HWTEST_F(NeuralNetworkRuntimeTest, compilation_set_device_001, testing::ext::TestSize.Level0)
822 {
823     OH_NNCompilation* compilation = nullptr;
824     size_t deviceId = 1;
825     OH_NN_ReturnCode ret = OH_NNCompilation_SetDevice(compilation, deviceId);
826     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
827 }
828 
829 /*
830  * @tc.name: compilation_set_device_002
831  * @tc.desc: Verify the success of the OH_NNCompilation_SetDevice function.
832  * @tc.type: FUNC
833  */
834 HWTEST_F(NeuralNetworkRuntimeTest, compilation_set_device_002, testing::ext::TestSize.Level0)
835 {
836     InnerModel innerModel;
837     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
838 
839     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
840     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
841     size_t deviceId = 1;
842     OH_NN_ReturnCode ret = OH_NNCompilation_SetDevice(nnCompilation, deviceId);
843     EXPECT_EQ(OH_NN_SUCCESS, ret);
844 }
845 
846 /*
847  * @tc.name: compilation_set_cache_001
848  * @tc.desc: Verify the OH_NNCompilation is nullptr of the OH_NNCompilation_SetCache function.
849  * @tc.type: FUNC
850  */
851 HWTEST_F(NeuralNetworkRuntimeTest, compilation_set_cache_001, testing::ext::TestSize.Level0)
852 {
853     InnerModel innerModel;
854     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
855     OH_NNCompilation* nnCompilation = nullptr;
856     const char* cacheDir = "../";
857     uint32_t version = 1;
858     OH_NN_ReturnCode ret = OH_NNCompilation_SetCache(nnCompilation, cacheDir, version);
859     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
860 }
861 
862 /*
863  * @tc.name: compilation_set_cache_002
864  * @tc.desc: Verify the cachePath is nullptr of the OH_NNCompilation_SetCache function.
865  * @tc.type: FUNC
866  */
867 HWTEST_F(NeuralNetworkRuntimeTest, compilation_set_cache_002, testing::ext::TestSize.Level0)
868 {
869     InnerModel innerModel;
870     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
871 
872     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
873     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
874     const char* cacheDir = nullptr;
875     uint32_t version = 1;
876     OH_NN_ReturnCode ret = OH_NNCompilation_SetCache(nnCompilation, cacheDir, version);
877     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
878 }
879 
880 /*
881  * @tc.name: compilation_set_cache_003
882  * @tc.desc: Verify the success of the OH_NNCompilation_SetCache function.
883  * @tc.type: FUNC
884  */
885 HWTEST_F(NeuralNetworkRuntimeTest, compilation_set_cache_003, testing::ext::TestSize.Level0)
886 {
887     InnerModel innerModel;
888     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
889 
890     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
891     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
892     const char* cacheDir = "../";
893     uint32_t version = 1;
894     OH_NN_ReturnCode ret = OH_NNCompilation_SetCache(nnCompilation, cacheDir, version);
895     EXPECT_EQ(OH_NN_SUCCESS, ret);
896 }
897 
898 /*
899  * @tc.name: compilation_set_performance_mode_001
900  * @tc.desc: Verify the OH_NNCompilation is nullptr of the OH_NNCompilation_SetPerformanceMode function.
901  * @tc.type: FUNC
902  */
903 HWTEST_F(NeuralNetworkRuntimeTest, compilation_set_performance_mode_001, testing::ext::TestSize.Level0)
904 {
905     InnerModel innerModel;
906     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
907     OH_NNCompilation* nnCompilation = nullptr;
908     OH_NN_PerformanceMode performanceMode = OH_NN_PERFORMANCE_NONE;
909 
910     OH_NN_ReturnCode ret = OH_NNCompilation_SetPerformanceMode(nnCompilation, performanceMode);
911     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
912 }
913 
914 /*
915  * @tc.name: compilation_set_performance_mode_002
916  * @tc.desc: Verify the success of the OH_NNCompilation_SetPerformanceMode function.
917  * @tc.type: FUNC
918  */
919 HWTEST_F(NeuralNetworkRuntimeTest, compilation_set_performance_mode_002, testing::ext::TestSize.Level0)
920 {
921     InnerModel innerModel;
922     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
923 
924     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
925     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
926     OH_NN_PerformanceMode performanceMode = OH_NN_PERFORMANCE_NONE;
927 
928     OH_NN_ReturnCode ret = OH_NNCompilation_SetPerformanceMode(nnCompilation, performanceMode);
929     EXPECT_EQ(OH_NN_SUCCESS, ret);
930 }
931 
932 /*
933  * @tc.name: compilation_set_priority_001
934  * @tc.desc: Verify the OH_NNCompilation is nullptr of the OH_NNCompilation_SetPriority function.
935  * @tc.type: FUNC
936  */
937 HWTEST_F(NeuralNetworkRuntimeTest, compilation_set_priority_001, testing::ext::TestSize.Level0)
938 {
939     InnerModel innerModel;
940     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
941     OH_NNCompilation* nnCompilation = nullptr;
942     OH_NN_Priority priority = OH_NN_PRIORITY_LOW;
943 
944     OH_NN_ReturnCode ret = OH_NNCompilation_SetPriority(nnCompilation, priority);
945     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
946 }
947 
948 /*
949  * @tc.name: compilation_set_priority_002
950  * @tc.desc: Verify the success of the OH_NNCompilation_SetPriority function.
951  * @tc.type: FUNC
952  */
953 HWTEST_F(NeuralNetworkRuntimeTest, compilation_set_priority_002, testing::ext::TestSize.Level0)
954 {
955     InnerModel innerModel;
956     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
957 
958     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
959     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
960     OH_NN_Priority priority = OH_NN_PRIORITY_LOW;
961 
962     OH_NN_ReturnCode ret = OH_NNCompilation_SetPriority(nnCompilation, priority);
963     EXPECT_EQ(OH_NN_SUCCESS, ret);
964 }
965 
966 /*
967  * @tc.name: compilation_set_enable_float16_001
968  * @tc.desc: Verify the OH_NNCompilation is nullptr of the OH_NNCompilation_EnableFloat16 function.
969  * @tc.type: FUNC
970  */
971 HWTEST_F(NeuralNetworkRuntimeTest, compilation_set_enable_float16_001, testing::ext::TestSize.Level0)
972 {
973     InnerModel innerModel;
974     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
975     OH_NNCompilation* nnCompilation = nullptr;
976     bool enableFloat16 = true;
977 
978     OH_NN_ReturnCode ret = OH_NNCompilation_EnableFloat16(nnCompilation, enableFloat16);
979     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
980 }
981 
982 /*
983  * @tc.name: compilation_set_enable_float16_002
984  * @tc.desc: Verify the success of the OH_NNCompilation_EnableFloat16 function.
985  * @tc.type: FUNC
986  */
987 HWTEST_F(NeuralNetworkRuntimeTest, compilation_set_enable_float16_002, testing::ext::TestSize.Level0)
988 {
989     InnerModel innerModel;
990     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
991 
992     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
993     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
994     bool enableFloat16 = true;
995 
996     OH_NN_ReturnCode ret = OH_NNCompilation_EnableFloat16(nnCompilation, enableFloat16);
997     EXPECT_EQ(OH_NN_SUCCESS, ret);
998 }
999 
1000 /*
1001  * @tc.name: compilation_build_001
1002  * @tc.desc: Verify the OH_NNCompilation is nullptr of the OH_NNCompilation_Build function.
1003  * @tc.type: FUNC
1004  */
1005 HWTEST_F(NeuralNetworkRuntimeTest, compilation_build_001, testing::ext::TestSize.Level0)
1006 {
1007     InnerModel innerModel;
1008     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1009     OH_NNCompilation* nnCompilation = nullptr;
1010 
1011     OH_NN_ReturnCode ret = OH_NNCompilation_Build(nnCompilation);
1012     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
1013 }
1014 
1015 /*
1016  * @tc.name: compilation_build_002
1017  * @tc.desc: Verify the success of the OH_NNCompilation_Build function.
1018  * @tc.type: FUNC
1019  */
1020 HWTEST_F(NeuralNetworkRuntimeTest, compilation_build_002, testing::ext::TestSize.Level0)
1021 {
1022     InnerModel innerModel;
1023     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1024 
1025     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1026     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1027 
1028     OH_NN_ReturnCode ret = OH_NNCompilation_Build(nnCompilation);
1029     EXPECT_EQ(OH_NN_FAILED, ret);
1030 }
1031 
1032 /*
1033  * @tc.name: compilation_destroy_001
1034  * @tc.desc: Verify the OH_NNCompilation is nullptr of the OH_NNCompilation_Destroy function.
1035  * @tc.type: FUNC
1036  */
1037 HWTEST_F(NeuralNetworkRuntimeTest, compilation_destroy_001, testing::ext::TestSize.Level0)
1038 {
1039     OH_NNCompilation** pCompilation = nullptr;
1040     OH_NNCompilation_Destroy(pCompilation);
1041     EXPECT_EQ(nullptr, pCompilation);
1042 }
1043 
1044 /*
1045  * @tc.name: compilation_destroy_002
1046  * @tc.desc: Verify the *OH_NNCompilation is nullptr of the OH_NNCompilation_Destroy function.
1047  * @tc.type: FUNC
1048  */
1049 HWTEST_F(NeuralNetworkRuntimeTest, compilation_destroy_002, testing::ext::TestSize.Level0)
1050 {
1051     OH_NNCompilation* compilation = nullptr;
1052     OH_NNCompilation** pCompilation = &compilation;
1053     OH_NNCompilation_Destroy(pCompilation);
1054     EXPECT_EQ(nullptr, compilation);
1055 }
1056 
1057 /*
1058  * @tc.name: compilation_destroy_003
1059  * @tc.desc: Verify the normal model of the OH_NNCompilation_Destroy function.
1060  * @tc.type: FUNC
1061  */
1062 HWTEST_F(NeuralNetworkRuntimeTest, compilation_destroy_003, testing::ext::TestSize.Level0)
1063 {
1064     InnerModel* innerModel = new InnerModel();
1065     EXPECT_NE(nullptr, innerModel);
1066 
1067     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1068     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1069     OH_NNCompilation_Destroy(&nnCompilation);
1070     EXPECT_EQ(nullptr, nnCompilation);
1071 }
1072 
1073 /**
1074  * @tc.name: excutor_construct_001
1075  * @tc.desc: Verify the OH_NNCompilation is nullptr of the OH_NNExecutor_Construct function
1076  * @tc.type: FUNC
1077  */
1078 HWTEST_F(NeuralNetworkRuntimeTest, excutor_construct_001, testing::ext::TestSize.Level0)
1079 {
1080     InnerModel innerModel;
1081     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1082 
1083     OH_NNCompilation* nnCompilation = nullptr;
1084     OH_NNExecutor* executor = OH_NNExecutor_Construct(nnCompilation);
1085     EXPECT_EQ(nullptr, executor);
1086 }
1087 
1088 /**
1089  * @tc.name: excutor_construct_002
1090  * @tc.desc: Verify the not OH_NNCompilation_Build before creating executor of the OH_NNExecutor_Construct function
1091  * @tc.type: FUNC
1092  */
1093 HWTEST_F(NeuralNetworkRuntimeTest, excutor_construct_002, testing::ext::TestSize.Level0)
1094 {
1095     InnerModel innerModel;
1096     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1097 
1098     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1099     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1100     OH_NNExecutor * executor = OH_NNExecutor_Construct(nnCompilation);
1101     EXPECT_EQ(nullptr, executor);
1102 }
1103 
1104 /**
1105  * @tc.name: excutor_construct_003
1106  * @tc.desc: Verify the success of the OH_NNExecutor_Construct function
1107  * @tc.type: FUNC
1108  */
1109 HWTEST_F(NeuralNetworkRuntimeTest, excutor_construct_003, testing::ext::TestSize.Level0)
1110 {
1111     InnerModel innerModel;
1112     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1113 
1114     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1115     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1116     OH_NNExecutor * executor = OH_NNExecutor_Construct(nnCompilation);
1117     EXPECT_EQ(nullptr, executor);
1118 }
1119 
1120 /**
1121  * @tc.name: excutor_setinput_001
1122  * @tc.desc: Verify the OH_NNExecutor is nullptr of the OH_NNExecutor_SetInput function
1123  * @tc.type: FUNC
1124  */
1125 HWTEST_F(NeuralNetworkRuntimeTest, excutor_setinput_001, testing::ext::TestSize.Level0)
1126 {
1127     SetTensor();
1128 
1129     float input[9] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
1130     const void *buffer = input;
1131     size_t length = 2 * sizeof(float);
1132     uint32_t inputIndex = 0;
1133     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_SetInput(nullptr, inputIndex, &m_tensor, buffer, length));
1134 }
1135 
1136 /**
1137  * @tc.name: excutor_setinput_002
1138  * @tc.desc: Verify the OH_NN_Tensor is nullptr of the OH_NNExecutor_SetInput function
1139  * @tc.type: FUNC
1140  */
1141 HWTEST_F(NeuralNetworkRuntimeTest, excutor_setinput_002, testing::ext::TestSize.Level0)
1142 {
1143     InnerModel innerModel;
1144     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1145 
1146     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1147     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1148     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1149 
1150     uint32_t inputIndex = 0;
1151     float input[9] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
1152     const void *buffer = input;
1153     size_t length = 2 * sizeof(float);
1154     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_SetInput(nnExecutor, inputIndex, nullptr, buffer, length));
1155 }
1156 
1157 /**
1158  * @tc.name: excutor_setinput_003
1159  * @tc.desc: Verify the data is nullptr of the OH_NNExecutor_SetInput function
1160  * @tc.type: FUNC
1161  */
1162 HWTEST_F(NeuralNetworkRuntimeTest, excutor_setinput_003, testing::ext::TestSize.Level0)
1163 {
1164     InnerModel innerModel;
1165     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1166 
1167     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1168     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1169     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1170 
1171     SetTensor();
1172 
1173     uint32_t inputIndex = 0;
1174     const void *buffer = nullptr;
1175     size_t length = 2 * sizeof(float);
1176     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_SetInput(nnExecutor, inputIndex, &m_tensor, buffer, length));
1177 }
1178 
1179 /**
1180  * @tc.name: excutor_setinput_004
1181  * @tc.desc: Verify the length is 0 of the OH_NNExecutor_SetInput function
1182  * @tc.type: FUNC
1183  */
1184 HWTEST_F(NeuralNetworkRuntimeTest, excutor_setinput_004, testing::ext::TestSize.Level0)
1185 {
1186     InnerModel innerModel;
1187     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1188 
1189     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1190     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1191     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1192 
1193     uint32_t inputIndex = 0;
1194     SetTensor();
1195 
1196     size_t length = 0;
1197     float input[9] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
1198     const void *buffer = input;
1199     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_SetInput(nnExecutor, inputIndex, &m_tensor, buffer, length));
1200 }
1201 
1202 /**
1203  * @tc.name: excutor_setinput_005
1204  * @tc.desc: Verify the success of the OH_NNExecutor_SetInput function
1205  * @tc.type: FUNC
1206  */
1207 HWTEST_F(NeuralNetworkRuntimeTest, excutor_setinput_005, testing::ext::TestSize.Level0)
1208 {
1209     InnerModel innerModel;
1210     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1211 
1212     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1213     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1214     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1215 
1216     uint32_t inputIndex = 0;
1217     int32_t dims[2] = {3, 4};
1218     m_tensor = {OH_NN_FLOAT32, 2, dims, nullptr, OH_NN_TENSOR};
1219 
1220     float input[12] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
1221     const void *buffer = input;
1222     size_t length = 12 * sizeof(float);
1223     OH_NN_ReturnCode ret = OH_NNExecutor_SetInput(nnExecutor, inputIndex, &m_tensor, buffer, length);
1224     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
1225 }
1226 
1227 /**
1228  * @tc.name: excutor_setoutput_001
1229  * @tc.desc: Verify the OH_NNExecutor is nullptr of the OH_NNExecutor_SetOutput function
1230  * @tc.type: FUNC
1231  */
1232 HWTEST_F(NeuralNetworkRuntimeTest, excutor_setoutput_001, testing::ext::TestSize.Level0)
1233 {
1234     uint32_t outputIndex = 0;
1235     float input[9] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
1236     void *buffer = input;
1237     size_t length = 9 * sizeof(int32_t);
1238     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_SetOutput(nullptr, outputIndex, buffer, length));
1239 }
1240 
1241 /**
1242  * @tc.name: excutor_setoutput_002
1243  * @tc.desc: Verify the data is nullptr of the OH_NNExecutor_SetOutput function
1244  * @tc.type: FUNC
1245  */
1246 HWTEST_F(NeuralNetworkRuntimeTest, excutor_setoutput_002, testing::ext::TestSize.Level0)
1247 {
1248     InnerModel innerModel;
1249     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1250 
1251     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1252     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1253     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1254 
1255     uint32_t outputIndex = 0;
1256     void *buffer = nullptr;
1257     size_t length = 9 * sizeof(int32_t);
1258     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_SetOutput(nnExecutor, outputIndex, buffer, length));
1259 }
1260 
1261 /**
1262  * @tc.name: excutor_setoutput_003
1263  * @tc.desc: Verify the length is 0 of the OH_NNExecutor_SetOutput function
1264  * @tc.type: FUNC
1265  */
1266 HWTEST_F(NeuralNetworkRuntimeTest, excutor_setoutput_003, testing::ext::TestSize.Level0)
1267 {
1268     InnerModel innerModel;
1269     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1270 
1271     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1272     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1273     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1274 
1275     uint32_t outputIndex = 0;
1276     float input[9] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
1277     void *buffer = input;
1278     size_t length = 0;
1279     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_SetOutput(nnExecutor, outputIndex, buffer, length));
1280 }
1281 
1282 /**
1283  * @tc.name: excutor_setoutput_004
1284  * @tc.desc: Verify the success of the OH_NNExecutor_SetOutput function
1285  * @tc.type: FUNC
1286  */
1287 HWTEST_F(NeuralNetworkRuntimeTest, excutor_setoutput_004, testing::ext::TestSize.Level0)
1288 {
1289     InnerModel innerModel;
1290     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1291 
1292     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1293     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1294     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1295 
1296     uint32_t outputIndex = 0;
1297     float output[12];
1298     size_t length = 12 * sizeof(float);
1299     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_SetOutput(nnExecutor, outputIndex, output, length));
1300 }
1301 
1302 /**
1303  * @tc.name: excutor_getoutputshape_001
1304  * @tc.desc: Verify the OH_NNExecutor is nullptr of the OH_NNExecutor_GetOutputShape function
1305  * @tc.type: FUNC
1306  */
1307 HWTEST_F(NeuralNetworkRuntimeTest, excutor_getoutputshape_001, testing::ext::TestSize.Level0)
1308 {
1309     InnerModel innerModel;
1310     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1311 
1312     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1313     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1314     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1315 
1316     int32_t* ptr = nullptr;
1317     int32_t** shape = &ptr;
1318     uint32_t length = 2;
1319     uint32_t outputIndex = 0;
1320     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_GetOutputShape(nnExecutor, outputIndex,
1321         shape, &length));
1322 }
1323 
1324 /**
1325  * @tc.name: excutor_getoutputshape_002
1326  * @tc.desc: Verify the shape is nullptr of the OH_NNExecutor_GetOutputShape function
1327  * @tc.type: FUNC
1328  */
1329 HWTEST_F(NeuralNetworkRuntimeTest, excutor_getoutputshape_002, testing::ext::TestSize.Level0)
1330 {
1331     InnerModel innerModel;
1332     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1333 
1334     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1335     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1336     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1337 
1338     uint32_t outputIndex = 0;
1339     int32_t** shape = nullptr;
1340     uint32_t length = 2;
1341     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_GetOutputShape(nnExecutor, outputIndex,
1342         shape, &length));
1343 }
1344 
1345 /**
1346  * @tc.name: excutor_getoutputshape_003
1347  * @tc.desc: Verify the *shape is not nullptr of the OH_NNExecutor_GetOutputShape function
1348  * @tc.type: FUNC
1349  */
1350 HWTEST_F(NeuralNetworkRuntimeTest, excutor_getoutputshape_003, testing::ext::TestSize.Level0)
1351 {
1352     InnerModel innerModel;
1353     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1354 
1355     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1356     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1357     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1358 
1359     int32_t expectDim[2] = {3, 3};
1360     int32_t* ptr = expectDim;
1361     int32_t** shape = &ptr;
1362     uint32_t length = 2;
1363     uint32_t outputIndex = 0;
1364     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_GetOutputShape(nnExecutor, outputIndex,
1365         shape, &length));
1366 }
1367 
1368 /**
1369  * @tc.name: excutor_getoutputshape_004
1370  * @tc.desc: Verify the length is nullptr of the OH_NNExecutor_GetOutputShape function
1371  * @tc.type: FUNC
1372  */
1373 HWTEST_F(NeuralNetworkRuntimeTest, excutor_getoutputshape_004, testing::ext::TestSize.Level0)
1374 {
1375     InnerModel innerModel;
1376     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1377 
1378     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1379     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1380     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1381 
1382     int32_t* ptr = nullptr;
1383     int32_t** shape = &ptr;
1384     uint32_t outputIndex = 0;
1385     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_GetOutputShape(nnExecutor, outputIndex, shape, nullptr));
1386 }
1387 
1388 /**
1389  * @tc.name: excutor_getoutputshape_005
1390  * @tc.desc: Verify the success of the OH_NNExecutor_GetOutputShape function
1391  * @tc.type: FUNC
1392  */
1393 HWTEST_F(NeuralNetworkRuntimeTest, excutor_getoutputshape_005, testing::ext::TestSize.Level0)
1394 {
1395     InnerModel innerModel;
1396     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1397 
1398     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1399     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1400     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1401 
1402     int32_t* ptr = nullptr;
1403     int32_t** shape = &ptr;
1404     uint32_t length = 2;
1405     uint32_t outputIndex = 0;
1406     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_GetOutputShape(nnExecutor, outputIndex, shape, &length));
1407 }
1408 
1409 /**
1410  * @tc.name: excutor_run_001
1411  * @tc.desc: Verify the OH_NNExecutor is nullptr of the OH_NNExecutor_Run function
1412  * @tc.type: FUNC
1413  */
1414 HWTEST_F(NeuralNetworkRuntimeTest, excutor_run_001, testing::ext::TestSize.Level0)
1415 {
1416     OH_NNExecutor* nnExecutor = nullptr;
1417     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_Run(nnExecutor));
1418 }
1419 
1420 /**
1421  * @tc.name: excutor_run_002
1422  * @tc.desc: Verify the success of the OH_NNExecutor_Run function
1423  * @tc.type: FUNC
1424  */
1425 HWTEST_F(NeuralNetworkRuntimeTest, excutor_run_002, testing::ext::TestSize.Level0)
1426 {
1427     InnerModel innerModel;
1428     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1429 
1430     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1431     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1432     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1433 
1434     int32_t inputDims[2] = {3, 4};
1435     m_tensor = {OH_NN_FLOAT32, 2, inputDims, nullptr, OH_NN_TENSOR};
1436 
1437     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_Run(nnExecutor));
1438 }
1439 
1440 /*
1441  * @tc.name: executor_allocate_input_memory_001
1442  * @tc.desc: Verify the OH_NNExecutor is nullptr of the OH_NNExecutor_AllocateInputMemory function.
1443  * @tc.type: FUNC
1444  */
1445 HWTEST_F(NeuralNetworkRuntimeTest, executor_allocate_input_memory_001, testing::ext::TestSize.Level0)
1446 {
1447     OH_NNExecutor* nnExecutor = nullptr;
1448     uint32_t outputIndex = 0;
1449     size_t length = 9 * sizeof(float);
1450 
1451     OH_NN_Memory* ret = OH_NNExecutor_AllocateInputMemory(nnExecutor, outputIndex, length);
1452     EXPECT_EQ(nullptr, ret);
1453 }
1454 
1455 /*
1456  * @tc.name: executor_allocate_input_memory_002
1457  * @tc.desc: Verify the passed length equals 0 of the OH_NNExecutor_AllocateInputMemory function.
1458  * @tc.type: FUNC
1459  */
1460 HWTEST_F(NeuralNetworkRuntimeTest, executor_allocate_input_memory_002, testing::ext::TestSize.Level0)
1461 {
1462     InnerModel innerModel;
1463     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1464 
1465     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1466     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1467     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1468 
1469     uint32_t outputIndex = 0;
1470     size_t length = 0;
1471 
1472     OH_NN_Memory* ret = OH_NNExecutor_AllocateInputMemory(nnExecutor, outputIndex, length);
1473     EXPECT_EQ(nullptr, ret);
1474 }
1475 
1476 /*
1477  * @tc.name: executor_allocate_input_memory_003
1478  * @tc.desc: Verify the error when creating input memory in executor of the OH_NNExecutor_AllocateInputMemory function.
1479  * @tc.type: FUNC
1480  */
1481 HWTEST_F(NeuralNetworkRuntimeTest, executor_allocate_input_memory_003, testing::ext::TestSize.Level0)
1482 {
1483     InnerModel innerModel;
1484     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1485 
1486     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1487     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1488     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1489 
1490     uint32_t outputIndex = 6;
1491     size_t length = 9 * sizeof(float);
1492 
1493     OH_NN_Memory* ret = OH_NNExecutor_AllocateInputMemory(nnExecutor, outputIndex, length);
1494     EXPECT_EQ(nullptr, ret);
1495 }
1496 
1497 /*
1498  * @tc.name: executor_allocate_input_memory_004
1499  * @tc.desc: Verify the success of the OH_NNExecutor_AllocateInputMemory function.
1500  * @tc.type: FUNC
1501  */
1502 HWTEST_F(NeuralNetworkRuntimeTest, executor_allocate_input_memory_004, testing::ext::TestSize.Level0)
1503 {
1504     InnerModel innerModel;
1505     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1506 
1507     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1508     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1509     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1510 
1511     uint32_t outputIndex = 0;
1512     size_t length = 9 * sizeof(float);
1513 
1514     OH_NN_Memory* ret = OH_NNExecutor_AllocateInputMemory(nnExecutor, outputIndex, length);
1515     EXPECT_EQ(nullptr, ret);
1516 }
1517 
1518 /*
1519  * @tc.name: executor_allocate_output_memory_001
1520  * @tc.desc: Verify the OH_NNExecutor is nullptr of the OH_NNExecutor_AllocateOutputMemory function.
1521  * @tc.type: FUNC
1522  */
1523 HWTEST_F(NeuralNetworkRuntimeTest, executor_allocate_output_memory_001, testing::ext::TestSize.Level0)
1524 {
1525     OH_NNExecutor* nnExecutor = nullptr;
1526     uint32_t outputIndex = 0;
1527     size_t length = 9 * sizeof(float);
1528 
1529     OH_NN_Memory* ret = OH_NNExecutor_AllocateOutputMemory(nnExecutor, outputIndex, length);
1530     EXPECT_EQ(nullptr, ret);
1531 }
1532 
1533 /*
1534  * @tc.name: executor_allocate_output_memory_002
1535  * @tc.desc: Verify the passed length equals 0 of the OH_NNExecutor_AllocateOutputMemory function.
1536  * @tc.type: FUNC
1537  */
1538 HWTEST_F(NeuralNetworkRuntimeTest, executor_allocate_output_memory_002, testing::ext::TestSize.Level0)
1539 {
1540     InnerModel innerModel;
1541     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1542 
1543     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1544     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1545     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1546 
1547     uint32_t outputIndex = 0;
1548     size_t length = 0;
1549 
1550     OH_NN_Memory* ret = OH_NNExecutor_AllocateOutputMemory(nnExecutor, outputIndex, length);
1551     EXPECT_EQ(nullptr, ret);
1552 }
1553 
1554 /*
1555  * @tc.name: executor_allocate_output_memory_003
1556  * @tc.desc: Verify the error when create output memory in executor of the OH_NNExecutor_AllocateOutputMemory function.
1557  * @tc.type: FUNC
1558  */
1559 HWTEST_F(NeuralNetworkRuntimeTest, executor_allocate_output_memory_003, testing::ext::TestSize.Level0)
1560 {
1561     InnerModel innerModel;
1562     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1563 
1564     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1565     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1566     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1567 
1568     uint32_t outputIndex = 6;
1569     size_t length = 9 * sizeof(float);
1570 
1571     OH_NN_Memory* ret = OH_NNExecutor_AllocateOutputMemory(nnExecutor, outputIndex, length);
1572     EXPECT_EQ(nullptr, ret);
1573 }
1574 
1575 /*
1576  * @tc.name: executor_allocate_output_memory_004
1577  * @tc.desc: Verify the success of the OH_NNExecutor_AllocateOutputMemory function.
1578  * @tc.type: FUNC
1579  */
1580 HWTEST_F(NeuralNetworkRuntimeTest, executor_allocate_output_memory_004, testing::ext::TestSize.Level0)
1581 {
1582     InnerModel innerModel;
1583     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1584 
1585     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1586     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1587     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1588 
1589     uint32_t outputIndex = 0;
1590     size_t length = 9 * sizeof(float);
1591 
1592     OH_NN_Memory* ret = OH_NNExecutor_AllocateOutputMemory(nnExecutor, outputIndex, length);
1593     EXPECT_EQ(nullptr, ret);
1594 }
1595 
1596 
1597 /*
1598  * @tc.name: executor_destroy_input_memory_001
1599  * @tc.desc: Verify the OH_NNExecutor is nullptr of the OH_NNExecutor_DestroyInputMemory function.
1600  * @tc.type: FUNC
1601  */
1602 HWTEST_F(NeuralNetworkRuntimeTest, executor_destroy_input_memory_001, testing::ext::TestSize.Level0)
1603 {
1604     InnerModel innerModel;
1605     BuildModel(innerModel);
1606     OH_NNExecutor* nnExecutor = nullptr;
1607 
1608     uint32_t inputIndex = 0;
1609     float dataArry[9] {0, 1, 2, 3, 4, 5, 6, 7, 8};
1610     void* const data = dataArry;
1611     OH_NN_Memory memory = {data, 9 * sizeof(float)};
1612     OH_NN_Memory* pMemory = &memory;
1613     OH_NNExecutor_DestroyInputMemory(nnExecutor, inputIndex, &pMemory);
1614     EXPECT_EQ(nullptr, nnExecutor);
1615 }
1616 
1617 /*
1618  * @tc.name: executor_destroy_input_memory_002
1619  * @tc.desc: Verify the memory is nullptr of the OH_NNExecutor_DestroyInputMemory function.
1620  * @tc.type: FUNC
1621  */
1622 HWTEST_F(NeuralNetworkRuntimeTest, executor_destroy_input_memory_002, testing::ext::TestSize.Level0)
1623 {
1624     InnerModel innerModel;
1625     BuildModel(innerModel);
1626 
1627     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1628     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1629     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1630 
1631     uint32_t inputIndex = 0;
1632     OH_NN_Memory** memory = nullptr;
1633     OH_NNExecutor_DestroyInputMemory(nnExecutor, inputIndex, memory);
1634     EXPECT_EQ(nullptr, memory);
1635 }
1636 
1637 /*
1638  * @tc.name: executor_destroy_input_memory_003
1639  * @tc.desc: Verify the *memory is nullptr of the OH_NNExecutor_DestroyInputMemory function.
1640  * @tc.type: FUNC
1641  */
1642 HWTEST_F(NeuralNetworkRuntimeTest, executor_destroy_input_memory_003, testing::ext::TestSize.Level0)
1643 {
1644     InnerModel innerModel;
1645     BuildModel(innerModel);
1646 
1647     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1648     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1649     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1650 
1651     uint32_t inputIndex = 0;
1652     OH_NN_Memory* memory = nullptr;
1653     OH_NN_Memory** pMemory = &memory;
1654     OH_NNExecutor_DestroyInputMemory(nnExecutor, inputIndex, pMemory);
1655     EXPECT_EQ(nullptr, memory);
1656 }
1657 
1658 /*
1659  * @tc.name: executor_destroy_input_memory_004
1660  * @tc.desc: Verify the error happened when destroying input memory of the OH_NNExecutor_DestroyInputMemory function.
1661  * @tc.type: FUNC
1662  */
1663 HWTEST_F(NeuralNetworkRuntimeTest, executor_destroy_input_memory_004, testing::ext::TestSize.Level0)
1664 {
1665     InnerModel innerModel;
1666     BuildModel(innerModel);
1667 
1668     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1669     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1670     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1671 
1672     uint32_t inputIndex = 6;
1673     float dataArry[9] {0, 1, 2, 3, 4, 5, 6, 7, 8};
1674     void* const data = dataArry;
1675     OH_NN_Memory memory = {data, 9 * sizeof(float)};
1676     OH_NN_Memory* pMemory = &memory;
1677     OH_NNExecutor_DestroyInputMemory(nnExecutor, inputIndex, &pMemory);
1678     EXPECT_NE(nullptr, pMemory);
1679 }
1680 
1681 /*
1682  * @tc.name: executor_destroy_input_memory_005
1683  * @tc.desc: Verify the success of the OH_NNExecutor_DestroyInputMemory function.
1684  * @tc.type: FUNC
1685  */
1686 HWTEST_F(NeuralNetworkRuntimeTest, executor_destroy_input_memory_005, testing::ext::TestSize.Level0)
1687 {
1688     InnerModel innerModel;
1689     BuildModel(innerModel);
1690 
1691     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1692     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1693     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1694 
1695     uint32_t inputIndex = 0;
1696     float dataArry[9] {0, 1, 2, 3, 4, 5, 6, 7, 8};
1697     void* const data = dataArry;
1698     OH_NN_Memory memory = {data, 9 * sizeof(float)};
1699     OH_NN_Memory* pMemory = &memory;
1700     OH_NNExecutor_DestroyInputMemory(nnExecutor, inputIndex, &pMemory);
1701     EXPECT_NE(nullptr, pMemory);
1702 }
1703 
1704 /*
1705  * @tc.name: executor_destroy_output_memory_001
1706  * @tc.desc: Verify the OH_NNExecutor is nullptr of the OH_NNExecutor_DestroyOutputMemory function.
1707  * @tc.type: FUNC
1708  */
1709 HWTEST_F(NeuralNetworkRuntimeTest, executor_destroy_output_memory_001, testing::ext::TestSize.Level0)
1710 {
1711     OH_NNExecutor* nnExecutor = nullptr;
1712     uint32_t outputIndex = 0;
1713     float dataArry[9] {0, 1, 2, 3, 4, 5, 6, 7, 8};
1714     void* const data = dataArry;
1715     OH_NN_Memory memory = {data, 9 * sizeof(float)};
1716     OH_NN_Memory* pMemory = &memory;
1717     OH_NNExecutor_DestroyOutputMemory(nnExecutor, outputIndex, &pMemory);
1718     EXPECT_EQ(nullptr, nnExecutor);
1719 }
1720 
1721 /*
1722  * @tc.name: executor_destroy_output_memory_002
1723  * @tc.desc: Verify the memory is nullptr of the OH_NNExecutor_DestroyOutputMemory function.
1724  * @tc.type: FUNC
1725  */
1726 HWTEST_F(NeuralNetworkRuntimeTest, executor_destroy_output_memory_002, testing::ext::TestSize.Level0)
1727 {
1728     InnerModel innerModel;
1729     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1730 
1731     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1732     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1733     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1734 
1735     uint32_t outputIndex = 0;
1736     OH_NN_Memory** memory = nullptr;
1737     OH_NNExecutor_DestroyOutputMemory(nnExecutor, outputIndex, memory);
1738     EXPECT_EQ(nullptr, memory);
1739 }
1740 
1741 /*
1742  * @tc.name: executor_destroy_output_memory_003
1743  * @tc.desc: Verify the *memory is nullptr of the OH_NNExecutor_DestroyOutputMemory function.
1744  * @tc.type: FUNC
1745  */
1746 HWTEST_F(NeuralNetworkRuntimeTest, executor_destroy_output_memory_003, testing::ext::TestSize.Level0)
1747 {
1748     InnerModel innerModel;
1749     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1750 
1751     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1752     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1753     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1754 
1755     uint32_t outputIndex = 0;
1756     OH_NN_Memory* memory = nullptr;
1757     OH_NN_Memory** pMemory = &memory;
1758     OH_NNExecutor_DestroyOutputMemory(nnExecutor, outputIndex, pMemory);
1759     EXPECT_EQ(nullptr, memory);
1760 }
1761 
1762 /*
1763  * @tc.name: executor_destroy_output_memory_004
1764  * @tc.desc: Verify the error happened when destroying output memory of the OH_NNExecutor_DestroyOutputMemory function.
1765  * @tc.type: FUNC
1766  */
1767 HWTEST_F(NeuralNetworkRuntimeTest, executor_destroy_output_memory_004, testing::ext::TestSize.Level0)
1768 {
1769     InnerModel innerModel;
1770     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1771 
1772     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1773     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1774     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1775 
1776     uint32_t outputIndex = 6;
1777     float dataArry[9] {0, 1, 2, 3, 4, 5, 6, 7, 8};
1778     void* const data = dataArry;
1779     OH_NN_Memory memory = {data, 9 * sizeof(float)};
1780     OH_NN_Memory* pMemory = &memory;
1781     OH_NNExecutor_DestroyOutputMemory(nnExecutor, outputIndex, &pMemory);
1782     EXPECT_NE(nullptr, pMemory);
1783 }
1784 
1785 /*
1786  * @tc.name: executor_destroy_output_memory_005
1787  * @tc.desc: Verify the success of the OH_NNExecutor_DestroyOutputMemory function.
1788  * @tc.type: FUNC
1789  */
1790 HWTEST_F(NeuralNetworkRuntimeTest, executor_destroy_output_memory_005, testing::ext::TestSize.Level0)
1791 {
1792     InnerModel innerModel;
1793     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1794 
1795     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1796     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1797     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1798 
1799     float dataArry[9] {0, 1, 2, 3, 4, 5, 6, 7, 8};
1800     void* const data = dataArry;
1801     OH_NN_Memory memory = {data, 9 * sizeof(float)};
1802     OH_NN_Memory* pMemory = &memory;
1803     uint32_t outputIndex = 0;
1804     OH_NNExecutor_DestroyOutputMemory(nnExecutor, outputIndex, &pMemory);
1805     EXPECT_NE(nullptr, pMemory);
1806 }
1807 
1808 /*
1809  * @tc.name: executor_set_input_with_memory_001
1810  * @tc.desc: Verify the OH_NNExecutor is nullptr of the OH_NNExecutor_SetInputWithMemory function.
1811  * @tc.type: FUNC
1812  */
1813 HWTEST_F(NeuralNetworkRuntimeTest, executor_set_input_with_memory_001, testing::ext::TestSize.Level0)
1814 {
1815     OH_NNExecutor* nnExecutor = nullptr;
1816 
1817     SetTensor();
1818 
1819     uint32_t inputIndex = 0;
1820     float dataArry[9] {0, 1, 2, 3, 4, 5, 6, 7, 8};
1821     void* const data = dataArry;
1822     OH_NN_Memory memory = {data, 9 * sizeof(float)};
1823 
1824     OH_NN_ReturnCode ret = OH_NNExecutor_SetInputWithMemory(nnExecutor, inputIndex, &m_tensor, &memory);
1825     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
1826 }
1827 
1828 /*
1829  * @tc.name: executor_set_input_with_memory_002
1830  * @tc.desc: Verify the operand is nullptr of the OH_NNExecutor_SetInputWithMemory function.
1831  * @tc.type: FUNC
1832  */
1833 HWTEST_F(NeuralNetworkRuntimeTest, executor_set_input_with_memory_002, testing::ext::TestSize.Level0)
1834 {
1835     InnerModel innerModel;
1836     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1837 
1838     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1839     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1840     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1841 
1842     OH_NN_Tensor* operand = nullptr;
1843 
1844     uint32_t inputIndex = 0;
1845     float dataArry[9] {0, 1, 2, 3, 4, 5, 6, 7, 8};
1846     void* const data = dataArry;
1847     OH_NN_Memory memory = {data, 9 * sizeof(float)};
1848 
1849     OH_NN_ReturnCode ret = OH_NNExecutor_SetInputWithMemory(nnExecutor, inputIndex, operand, &memory);
1850     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
1851 }
1852 
1853 /*
1854  * @tc.name: executor_set_input_with_memory_003
1855  * @tc.desc: Verify the memory is nullptr of the OH_NNExecutor_SetInputWithMemory function.
1856  * @tc.type: FUNC
1857  */
1858 HWTEST_F(NeuralNetworkRuntimeTest, executor_set_input_with_memory_003, testing::ext::TestSize.Level0)
1859 {
1860     InnerModel innerModel;
1861     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1862 
1863     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1864     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1865     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1866 
1867     SetTensor();
1868 
1869     uint32_t inputIndex = 0;
1870     OH_NN_Memory* memory = nullptr;
1871     OH_NN_ReturnCode ret = OH_NNExecutor_SetInputWithMemory(nnExecutor, inputIndex, &m_tensor, memory);
1872     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
1873 }
1874 
1875 /*
1876  * @tc.name: executor_set_input_with_memory_004
1877  * @tc.desc: Verify the success of the OH_NNExecutor_SetInputWithMemory function.
1878  * @tc.type: FUNC
1879  */
1880 HWTEST_F(NeuralNetworkRuntimeTest, executor_set_input_with_memory_004, testing::ext::TestSize.Level0)
1881 {
1882     InnerModel innerModel;
1883     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1884 
1885     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1886     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1887     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1888 
1889     uint32_t inputIndex = 0;
1890     int32_t dims[2] = {3, 4};
1891     m_tensor = {OH_NN_FLOAT32, 2, dims, nullptr, OH_NN_TENSOR};
1892 
1893     float dataArry[12] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
1894     void* const data = dataArry;
1895     OH_NN_Memory memory = {data, 12 * sizeof(float)};
1896 
1897     OH_NN_ReturnCode ret = OH_NNExecutor_SetInputWithMemory(nnExecutor, inputIndex, &m_tensor, &memory);
1898     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
1899 }
1900 
1901 
1902 /*
1903  * @tc.name: executor_set_output_with_memory_001
1904  * @tc.desc: Verify the OH_NNExecutor is nullptr of the OH_NNExecutor_SetOutputWithMemory function.
1905  * @tc.type: FUNC
1906  */
1907 HWTEST_F(NeuralNetworkRuntimeTest, executor_set_output_with_memory_001, testing::ext::TestSize.Level0)
1908 {
1909     OH_NNExecutor* nnExecutor = nullptr;
1910     uint32_t outputIndex = 0;
1911     float dataArry[9] {0, 1, 2, 3, 4, 5, 6, 7, 8};
1912     void* const data = dataArry;
1913     OH_NN_Memory memory = {data, 9 * sizeof(float)};
1914     OH_NN_ReturnCode ret = OH_NNExecutor_SetOutputWithMemory(nnExecutor, outputIndex, &memory);
1915     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
1916 }
1917 
1918 /*
1919  * @tc.name: executor_set_output_with_memory_002
1920  * @tc.desc: Verify the memory is nullptr of the OH_NNExecutor_SetOutputWithMemory function.
1921  * @tc.type: FUNC
1922  */
1923 HWTEST_F(NeuralNetworkRuntimeTest, executor_set_output_with_memory_002, testing::ext::TestSize.Level0)
1924 {
1925     InnerModel innerModel;
1926     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1927 
1928     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1929     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1930     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1931 
1932     uint32_t outputIndex = 0;
1933     OH_NN_Memory* memory = nullptr;
1934     OH_NN_ReturnCode ret = OH_NNExecutor_SetOutputWithMemory(nnExecutor, outputIndex, memory);
1935     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
1936 }
1937 
1938 /*
1939  * @tc.name: executor_set_output_with_memory_003
1940  * @tc.desc: Verify the success of the OH_NNExecutor_SetOutputWithMemory function.
1941  * @tc.type: FUNC
1942  */
1943 HWTEST_F(NeuralNetworkRuntimeTest, executor_set_output_with_memory_003, testing::ext::TestSize.Level0)
1944 {
1945     InnerModel innerModel;
1946     EXPECT_EQ(OH_NN_SUCCESS, BuildModel(innerModel));
1947 
1948     OH_NNModel* model = reinterpret_cast<OH_NNModel*>(&innerModel);
1949     OH_NNCompilation* nnCompilation = OH_NNCompilation_Construct(model);
1950     OH_NNExecutor* nnExecutor = OH_NNExecutor_Construct(nnCompilation);
1951 
1952     uint32_t outputIndex = 0;
1953     float dataArry[12] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
1954     void* const data = dataArry;
1955     OH_NN_Memory memory = {data, 12 * sizeof(float)};
1956     OH_NN_ReturnCode ret = OH_NNExecutor_SetOutputWithMemory(nnExecutor, outputIndex, &memory);
1957     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
1958 }
1959 
1960 /*
1961  * @tc.name: executor_destroy_001
1962  * @tc.desc: Verify the OH_NNExecutor is nullptr of the OH_NNExecutor_Destroy function.
1963  * @tc.type: FUNC
1964  */
1965 HWTEST_F(NeuralNetworkRuntimeTest, executor_destroy_001, testing::ext::TestSize.Level0)
1966 {
1967     OH_NNExecutor** pExecutor = nullptr;
1968     OH_NNExecutor_Destroy(pExecutor);
1969     EXPECT_EQ(nullptr, pExecutor);
1970 }
1971 
1972 /*
1973  * @tc.name: executor_destroy_002
1974  * @tc.desc: Verify the *OH_NNExecutor is nullptr of the OH_NNExecutor_Destroy function.
1975  * @tc.type: FUNC
1976  */
1977 HWTEST_F(NeuralNetworkRuntimeTest, executor_destroy_002, testing::ext::TestSize.Level0)
1978 {
1979     OH_NNExecutor* nnExecutor = nullptr;
1980     OH_NNExecutor** pExecutor = &nnExecutor;
1981     OH_NNExecutor_Destroy(pExecutor);
1982     EXPECT_EQ(nullptr, nnExecutor);
1983 }
1984 
1985 /*
1986  * @tc.name: device_get_all_devices_id_001
1987  * @tc.desc: Verify the allDevicesID is nullptr of the OH_NNDevice_GetAllDevicesID function.
1988  * @tc.type: FUNC
1989  */
1990 HWTEST_F(NeuralNetworkRuntimeTest, device_get_all_devices_id_001, testing::ext::TestSize.Level0)
1991 {
1992     const size_t** allDevicesId = nullptr;
1993     uint32_t deviceCount = 1;
1994     uint32_t* pDeviceCount = &deviceCount;
1995     OH_NN_ReturnCode ret = OH_NNDevice_GetAllDevicesID(allDevicesId, pDeviceCount);
1996     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
1997 }
1998 
1999 /*
2000  * @tc.name: device_get_all_devices_id_002
2001  * @tc.desc: Verify the *allDevicesID is not nullptr of the OH_NNDevice_GetAllDevicesID function.
2002  * @tc.type: FUNC
2003  */
2004 HWTEST_F(NeuralNetworkRuntimeTest, device_get_all_devices_id_002, testing::ext::TestSize.Level0)
2005 {
2006     const size_t devicesId = 1;
2007     const size_t* allDevicesId = &devicesId;
2008     const size_t** pAllDevicesId = &allDevicesId;
2009     uint32_t deviceCount = 1;
2010     uint32_t* pDeviceCount = &deviceCount;
2011     OH_NN_ReturnCode ret = OH_NNDevice_GetAllDevicesID(pAllDevicesId, pDeviceCount);
2012     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
2013 }
2014 
2015 /*
2016  * @tc.name: device_get_all_devices_id_003
2017  * @tc.desc: Verify the deviceCount is nullptr of the OH_NNDevice_GetAllDevicesID function.
2018  * @tc.type: FUNC
2019  */
2020 HWTEST_F(NeuralNetworkRuntimeTest, device_get_all_devices_id_003, testing::ext::TestSize.Level0)
2021 {
2022     const size_t* allDevicesId = nullptr;
2023     const size_t** pAllDevicesId = &allDevicesId;
2024     uint32_t* pDeviceCount = nullptr;
2025     OH_NN_ReturnCode ret = OH_NNDevice_GetAllDevicesID(pAllDevicesId, pDeviceCount);
2026     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
2027 }
2028 
2029 /*
2030  * @tc.name: device_get_all_devices_id_004
2031  * @tc.desc: Verify the get no device of the OH_NNDevice_GetAllDevicesID function.
2032  * @tc.type: FUNC
2033  */
2034 HWTEST_F(NeuralNetworkRuntimeTest, device_get_all_devices_id_004, testing::ext::TestSize.Level0)
2035 {
2036     const size_t* allDevicesId = nullptr;
2037     const size_t** pAllDevicesId = &allDevicesId;
2038     uint32_t deviceCount = 1;
2039     uint32_t* pDeviceCount = &deviceCount;
2040     OHOS::HDI::Nnrt::V2_0::MockIPreparedModel::m_ExpectRetCode = OH_NN_FAILED;
2041     OH_NN_ReturnCode ret = OH_NNDevice_GetAllDevicesID(pAllDevicesId, pDeviceCount);
2042     EXPECT_EQ(OH_NN_SUCCESS, ret);
2043 }
2044 
2045 /*
2046  * @tc.name: device_get_all_devices_id_005
2047  * @tc.desc: Verify the success of the OH_NNDevice_GetAllDevicesID function.
2048  * @tc.type: FUNC
2049  */
2050 HWTEST_F(NeuralNetworkRuntimeTest, device_get_all_devices_id_005, testing::ext::TestSize.Level0)
2051 {
2052     const size_t* allDevicesId = nullptr;
2053     const size_t** pAllDevicesId = &allDevicesId;
2054     uint32_t deviceCount = 1;
2055     uint32_t* pDeviceCount = &deviceCount;
2056     OH_NN_ReturnCode ret = OH_NNDevice_GetAllDevicesID(pAllDevicesId, pDeviceCount);
2057     EXPECT_EQ(OH_NN_SUCCESS, ret);
2058 }
2059 
2060 /*
2061  * @tc.name: device_get_name_001
2062  * @tc.desc: Verify the name is nullptr of the OH_NNDevice_GetName function.
2063  * @tc.type: FUNC
2064  */
2065 HWTEST_F(NeuralNetworkRuntimeTest, device_get_name_001, testing::ext::TestSize.Level0)
2066 {
2067     size_t deviceID = 1;
2068     const char **name = nullptr;
2069     OH_NN_ReturnCode ret = OH_NNDevice_GetName(deviceID, name);
2070     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
2071 }
2072 
2073 /*
2074  * @tc.name: device_get_name_002
2075  * @tc.desc: Verify the *name is not nullptr of the OH_NNDevice_GetName function.
2076  * @tc.type: FUNC
2077  */
2078 HWTEST_F(NeuralNetworkRuntimeTest, device_get_name_002, testing::ext::TestSize.Level0)
2079 {
2080     size_t deviceID = 1;
2081     const char* name = "diviceId";
2082     const char** pName = &name;
2083     OH_NN_ReturnCode ret = OH_NNDevice_GetName(deviceID, pName);
2084     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
2085 }
2086 
2087 /*
2088  * @tc.name: device_get_name_003
2089  * @tc.desc: Verify the error happened when getting name of deviceID of the OH_NNDevice_GetName function.
2090  * @tc.type: FUNC
2091  */
2092 HWTEST_F(NeuralNetworkRuntimeTest, device_get_name_003, testing::ext::TestSize.Level0)
2093 {
2094     size_t deviceID = 12345;
2095     const char* name = nullptr;
2096     const char** pName = &name;
2097     OH_NN_ReturnCode ret = OH_NNDevice_GetName(deviceID, pName);
2098     EXPECT_EQ(OH_NN_FAILED, ret);
2099 }
2100 
2101 /*
2102  * @tc.name: device_get_name_004
2103  * @tc.desc: Verify the success of the OH_NNDevice_GetName function.
2104  * @tc.type: FUNC
2105  */
2106 HWTEST_F(NeuralNetworkRuntimeTest, device_get_name_004, testing::ext::TestSize.Level0)
2107 {
2108     size_t deviceID = 1;
2109     const char* name = nullptr;
2110     const char** pName = &name;
2111     OH_NN_ReturnCode ret = OH_NNDevice_GetName(deviceID, pName);
2112     EXPECT_EQ(OH_NN_FAILED, ret);
2113 }
2114 
2115 /*
2116  * @tc.name: device_get_type_001
2117  * @tc.desc: Verify the device is nullptr of the OH_NNDevice_GetType function.
2118  * @tc.type: FUNC
2119  */
2120 HWTEST_F(NeuralNetworkRuntimeTest, device_get_type_001, testing::ext::TestSize.Level0)
2121 {
2122     size_t deviceID = 12345;
2123     OH_NN_DeviceType deviceType = OH_NN_CPU;
2124     OH_NN_DeviceType* pDeviceType = &deviceType;
2125     OH_NN_ReturnCode ret = OH_NNDevice_GetType(deviceID, pDeviceType);
2126     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
2127 }
2128 
2129 /*
2130  * @tc.name: device_get_type_002
2131  * @tc.desc: Verify the OH_NN_DeviceType is nullptr of the OH_NNDevice_GetType function.
2132  * @tc.type: FUNC
2133  */
2134 HWTEST_F(NeuralNetworkRuntimeTest, device_get_type_002, testing::ext::TestSize.Level0)
2135 {
2136     size_t deviceID = 1;
2137     OH_NN_DeviceType* pDeviceType = nullptr;
2138     OH_NN_ReturnCode ret = OH_NNDevice_GetType(deviceID, pDeviceType);
2139     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
2140 }
2141 
2142 /*
2143  * @tc.name: device_get_type_003
2144  * @tc.desc: Verify the error happened when getting name of deviceID of the OH_NNDevice_GetType function.
2145  * @tc.type: FUNC
2146  */
2147 HWTEST_F(NeuralNetworkRuntimeTest, device_get_type_003, testing::ext::TestSize.Level0)
2148 {
2149     size_t deviceID = 1;
2150     OH_NN_DeviceType deviceType = OH_NN_OTHERS;
2151     OH_NN_DeviceType* pDeviceType = &deviceType;
2152     OH_NN_ReturnCode ret = OH_NNDevice_GetType(deviceID, pDeviceType);
2153     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
2154 }
2155 
2156 /*
2157  * @tc.name: device_get_type_004
2158  * @tc.desc: Verify the success of the OH_NNDevice_GetType function.
2159  * @tc.type: FUNC
2160  */
2161 HWTEST_F(NeuralNetworkRuntimeTest, device_get_type_004, testing::ext::TestSize.Level0)
2162 {
2163     size_t deviceID =  1;
2164     OH_NN_DeviceType deviceType = OH_NN_CPU;
2165     OH_NN_DeviceType* pDeviceType = &deviceType;
2166     OH_NN_ReturnCode ret = OH_NNDevice_GetType(deviceID, pDeviceType);
2167     EXPECT_EQ(OH_NN_INVALID_PARAMETER, ret);
2168 }
2169 } // namespace Unittest
2170 } // namespace NeuralNetworkRuntime
2171 } // namespace OHOS
2172