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 <gmock/gmock.h>
17 #include <gtest/gtest.h>
18
19 #include "common/utils.h"
20 #include "common/log.h"
21 #include "nn_tensor.h"
22 #include "inner_model.h"
23
24 #include <sys/mman.h>
25
26 #include "lite_graph_to_hdi_model_v2_0.h"
27 #include "device.h"
28 #include "interfaces/kits/c/neural_network_runtime/neural_network_runtime_type.h"
29 #include "nnbackend.h"
30 #include "ops_registry.h"
31 #include "transform.h"
32
33 using namespace testing;
34 using namespace testing::ext;
35 using namespace OHOS::NeuralNetworkRuntime;
36
37 namespace MSLITE = mindspore::lite;
38
39 namespace NNRT {
40 namespace UnitTest {
41 class InnerModelTest : public testing::Test {
42 public:
43 void SetLiteGraph(mindspore::lite::LiteGraph* liteGraph);
44 void SetTensors();
45 void SetIndices();
46
47 public:
48 InnerModel m_innerModelTest;
49
50 std::vector<int32_t> m_dimInput {3, 3};
51 std::vector<int32_t> m_dimOutput {3, 3};
52 std::vector<uint32_t> m_inputIndices {0};
53 std::vector<uint32_t> m_outputIndices {1};
54
55 OH_NN_OperationType m_opType {OH_NN_OPS_ADD};
56
57 OH_NN_UInt32Array m_inputs;
58 OH_NN_UInt32Array m_outputs;
59 OH_NN_UInt32Array m_params;
60
61 uint32_t m_paramIndexs[1] {3};
62 uint32_t m_inputIndexs[2] {0, 1};
63 uint32_t m_outputIndexs[1] {2};
64 };
65
SetLiteGraph(mindspore::lite::LiteGraph * liteGraph)66 void InnerModelTest::SetLiteGraph(mindspore::lite::LiteGraph* liteGraph)
67 {
68 liteGraph->name_ = "testGraph";
69 liteGraph->input_indices_ = m_inputIndices;
70 liteGraph->output_indices_ = m_outputIndices;
71
72 const std::vector<mindspore::lite::QuantParam> quant_params {};
73
74 for (size_t indexInput = 0; indexInput < liteGraph->input_indices_.size(); ++indexInput) {
75 const std::vector<uint8_t> data(36, 1);
76 liteGraph->all_tensors_.emplace_back(mindspore::lite::MindIR_Tensor_Create());
77 }
78
79 for (size_t indexOutput = 0; indexOutput < liteGraph->output_indices_.size(); ++indexOutput) {
80 const std::vector<uint8_t> dataOut(36, 1);
81 liteGraph->all_tensors_.emplace_back(mindspore::lite::MindIR_Tensor_Create());
82 }
83 }
84
SetTensors()85 void InnerModelTest::SetTensors()
86 {
87 const int dim[2] = {2, 2};
88 const OH_NN_Tensor& tensor = {OH_NN_FLOAT32, 2, dim, nullptr, OH_NN_TENSOR};
89
90 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensor));
91 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensor));
92 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensor));
93
94 const OH_NN_Tensor& tensorParam = {OH_NN_INT8, 0, nullptr, nullptr, OH_NN_ADD_ACTIVATIONTYPE};
95 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensorParam));
96 }
97
SetIndices()98 void InnerModelTest::SetIndices()
99 {
100 m_params.data = m_paramIndexs;
101 m_params.size = sizeof(m_paramIndexs) / sizeof(uint32_t);
102
103 m_inputs.data = m_inputIndexs;
104 m_inputs.size = sizeof(m_inputIndexs) / sizeof(uint32_t);
105
106 m_outputs.data = m_outputIndexs;
107 m_outputs.size = sizeof(m_outputIndexs) / sizeof(uint32_t);
108 }
109
110 /**
111 * @tc.name: inner_model_construct_nntensor_from_litegraph_001
112 * @tc.desc: Verify the input_indices is empty of the construct_nntensor_from_litegraph function
113 * @tc.type: FUNC
114 */
115 HWTEST_F(InnerModelTest, inner_model_construct_nntensor_from_litegraph_001, TestSize.Level1)
116 {
117 mindspore::lite::LiteGraph* liteGraph = new (std::nothrow) mindspore::lite::LiteGraph();
118 EXPECT_NE(nullptr, liteGraph);
119 m_inputIndices = {};
120
121 SetLiteGraph(liteGraph);
122
123 ExtensionConfig extensionConfig;
124
125 EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_innerModelTest
126 .BuildFromLiteGraph(liteGraph, extensionConfig));
127 }
128
129 /**
130 * @tc.name: inner_model_construct_nntensor_from_litegraph_002
131 * @tc.desc: Verify the input_indices is out of bounds of the construct_nntensor_from_litegraph function
132 * @tc.type: FUNC
133 */
134 HWTEST_F(InnerModelTest, inner_model_construct_nntensor_from_litegraph_002, TestSize.Level1)
135 {
136 mindspore::lite::LiteGraph* liteGraph = new (std::nothrow) mindspore::lite::LiteGraph();
137 EXPECT_NE(nullptr, liteGraph);
138 m_inputIndices = {6};
139
140 SetLiteGraph(liteGraph);
141
142 ExtensionConfig extensionConfig;
143
144 EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_innerModelTest
145 .BuildFromLiteGraph(liteGraph, extensionConfig));
146 }
147
148 /**
149 * @tc.name: inner_model_construct_nntensor_from_litegraph_003
150 * @tc.desc: Verify the success of the construct_nntensor_from_litegraph function
151 * @tc.type: FUNC
152 */
153 HWTEST_F(InnerModelTest, inner_model_construct_nntensor_from_litegraph_003, TestSize.Level1)
154 {
155 mindspore::lite::LiteGraph* liteGraph = new (std::nothrow) mindspore::lite::LiteGraph();
156 EXPECT_NE(nullptr, liteGraph);
157
158 SetLiteGraph(liteGraph);
159
160 ExtensionConfig extensionConfig;
161
162 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.BuildFromLiteGraph(liteGraph, extensionConfig));
163 }
164
165 /**
166 * @tc.name: inner_model_construct_nntensor_from_litegraph_004
167 * @tc.desc: Verify the nntensor build failed nullptr return of the construct_nntensor_from_litegraph function
168 * @tc.type: FUNC
169 */
170 HWTEST_F(InnerModelTest, inner_model_construct_nntensor_from_litegraph_004, TestSize.Level1)
171 {
172 mindspore::lite::LiteGraph* liteGraph = new (std::nothrow) mindspore::lite::LiteGraph();
173 EXPECT_NE(nullptr, liteGraph);
174 m_dimInput = {3, -3};
175
176 SetLiteGraph(liteGraph);
177
178 ExtensionConfig extensionConfig;
179
180 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.BuildFromLiteGraph(liteGraph, extensionConfig));
181 }
182
183 /**
184 * @tc.name: inner_model_construct_nntensor_from_litegraph_005
185 * @tc.desc: Verify the output indices out of bounds of the construct_nntensor_from_litegraph function
186 * @tc.type: FUNC
187 */
188 HWTEST_F(InnerModelTest, inner_model_construct_nntensor_from_litegraph_005, TestSize.Level1)
189 {
190 mindspore::lite::LiteGraph* liteGraph = new (std::nothrow) mindspore::lite::LiteGraph();
191 EXPECT_NE(nullptr, liteGraph);
192 m_outputIndices = {6};
193
194 SetLiteGraph(liteGraph);
195
196 ExtensionConfig extensionConfig;
197
198 EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_innerModelTest
199 .BuildFromLiteGraph(liteGraph, extensionConfig));
200 }
201
202 /**
203 * @tc.name: inner_model_build_from_lite_graph_001
204 * @tc.desc: Verify the litegraph is nullptr of the build_from_lite_graph function
205 * @tc.type: FUNC
206 */
207 HWTEST_F(InnerModelTest, inner_model_build_from_lite_graph_001, TestSize.Level1)
208 {
209 char d = 'a';
210 char * cr = &d;
211 struct OH_NN_Extension on_exit = {
212 "zhou", cr, 5
213 };
214 OH_NN_Extension *extensions = &on_exit;
215 size_t extensionSize = 1;
216 ExtensionConfig extensionConfig;
217 std::string opLayout;
218 for (size_t i = 0; i < extensionSize; ++i) {
219 std::string name = extensions[i].name;
220 if (name == "QuantBuffer") {
221 extensionConfig.quantBuffer.data = extensions[i].value;
222 extensionConfig.quantBuffer.length = extensions[i].valueSize;
223 } else if (name == "ModelName") {
224 extensionConfig.modelName.assign(extensions[i].value, extensions[i].value + extensions[i].valueSize);
225 } else if (name == "Profiling") {
226 extensionConfig.isProfiling.assign(extensions[i].value, extensions[i].value + extensions[i].valueSize);
227 LOGI("OH_NNModel_BuildFromLiteGraph isProfiling enable.");
228 } else if (name == "opLayout") {
229 opLayout.assign(extensions[i].value, extensions[i].value + extensions[i].valueSize);
230 extensionConfig.opLayout.insert({opLayout, "hiai::ExecuteDevice::CPU"});
231 LOGI("OH_NNModel_BuildFromLiteGraph opLayout:%{public}s.", opLayout.c_str());
232 }
233 }
234
235 EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_innerModelTest
236 .BuildFromLiteGraph(nullptr, extensionConfig));
237 }
238
239 /**
240 * @tc.name: inner_model_build_from_lite_graph_002
241 * @tc.desc: Verify the buildfromlitegraph twice forbidden of the build_from_lite_graph function
242 * @tc.type: FUNC
243 */
244 HWTEST_F(InnerModelTest, inner_model_build_from_lite_graph_002, TestSize.Level1)
245 {
246 mindspore::lite::LiteGraph* liteGraph = new (std::nothrow) mindspore::lite::LiteGraph();
247 EXPECT_NE(nullptr, liteGraph);
248
249 SetLiteGraph(liteGraph);
250 ExtensionConfig extensionConfig;
251
252 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.BuildFromLiteGraph(liteGraph, extensionConfig));
253 EXPECT_EQ(OH_NN_OPERATION_FORBIDDEN, m_innerModelTest
254 .BuildFromLiteGraph(liteGraph, extensionConfig));
255 }
256
257 /**
258 * @tc.name: inner_model_build_from_lite_graph_003
259 * @tc.desc: Verify the litegraph->alltensors is empty of the build_from_lite_graph function
260 * @tc.type: FUNC
261 */
262 HWTEST_F(InnerModelTest, inner_model_build_from_lite_graph_003, TestSize.Level1)
263 {
264 mindspore::lite::LiteGraph* liteGraph = new (std::nothrow) mindspore::lite::LiteGraph();
265 EXPECT_NE(nullptr, liteGraph);
266 liteGraph->name_ = "testGraph";
267 liteGraph->input_indices_ = {0};
268 liteGraph->output_indices_ = {1};
269
270 const int32_t dimInput[2] = {2, 2};
271 const OH_NN_Tensor& tensor = {OH_NN_INT8, 2, dimInput, nullptr, OH_NN_TENSOR};
272 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensor));
273 ExtensionConfig extensionConfig;
274
275 EXPECT_EQ(OH_NN_OPERATION_FORBIDDEN, m_innerModelTest
276 .BuildFromLiteGraph(liteGraph, extensionConfig));
277 }
278
279
280 /**
281 * @tc.name: inner_model_add_tensor_001
282 * @tc.desc: Verify the success of the addtensor function
283 * @tc.type: FUNC
284 */
285 HWTEST_F(InnerModelTest, inner_model_add_tensor_001, TestSize.Level1)
286 {
287 const int32_t dimInput[2] = {2, 2};
288 const OH_NN_Tensor& tensor = {OH_NN_INT8, 2, dimInput, nullptr, OH_NN_TENSOR};
289 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensor));
290 }
291
292 /**
293 * @tc.name: inner_model_add_tensor_002
294 * @tc.desc: Verify the addtensor after buildfromlitegraph of the addtensor function
295 * @tc.type: FUNC
296 */
297 HWTEST_F(InnerModelTest, inner_model_add_tensor_002, TestSize.Level1)
298 {
299 mindspore::lite::LiteGraph* liteGraph = new (std::nothrow) mindspore::lite::LiteGraph();
300 EXPECT_NE(nullptr, liteGraph);
301 SetLiteGraph(liteGraph);
302
303 ExtensionConfig extensionConfig;
304
305 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.BuildFromLiteGraph(liteGraph, extensionConfig));
306
307 const int32_t dimInput[2] = {2, 2};
308 const OH_NN_Tensor& tensor = {OH_NN_INT8, 2, dimInput, nullptr, OH_NN_TENSOR};
309 EXPECT_EQ(OH_NN_OPERATION_FORBIDDEN, m_innerModelTest.AddTensor(tensor));
310 }
311
312 /**
313 * @tc.name: inner_model_add_tensor_003
314 * @tc.desc: Verify the buildfromnntensor failed of the addtensor function
315 * @tc.type: FUNC
316 */
317 HWTEST_F(InnerModelTest, inner_model_add_tensor_003, TestSize.Level1)
318 {
319 const int32_t dimInput[2] = {2, -2};
320 const OH_NN_Tensor& tensor = {OH_NN_INT8, 2, dimInput, nullptr, OH_NN_TENSOR};
321 EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_innerModelTest.AddTensor(tensor));
322 }
323
324
325 /**
326 * @tc.name: inner_model_set_tensor_value_001
327 * @tc.desc: Verify the success of the set_tensor_value function
328 * @tc.type: FUNC
329 */
330 HWTEST_F(InnerModelTest, inner_model_set_tensor_value_001, TestSize.Level1)
331 {
332 SetTensors();
333
334 uint32_t index = 3;
335 const int8_t activation = 0;
336 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SetTensorValue(index,
337 static_cast<const void *>(&activation), sizeof(int8_t)));
338 }
339
340 /**
341 * @tc.name: inner_model_set_tensor_value_002
342 * @tc.desc: Verify the index out of bounds of the set_tensor_value function
343 * @tc.type: FUNC
344 */
345 HWTEST_F(InnerModelTest, inner_model_set_tensor_value_002, TestSize.Level1)
346 {
347 SetTensors();
348
349 uint32_t index = 6;
350 const int8_t activation = 0;
351 EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_innerModelTest.SetTensorValue(index,
352 static_cast<const void *>(&activation), sizeof(int8_t)));
353 }
354
355 /**
356 * @tc.name: inner_model_set_tensor_value_003
357 * @tc.desc: Verify the buffer value is nullptr of the set_tensor_value function
358 * @tc.type: FUNC
359 */
360 HWTEST_F(InnerModelTest, inner_model_set_tensor_value_003, TestSize.Level1)
361 {
362 SetTensors();
363
364 uint32_t index = 3;
365 const int8_t activation = 0;
366 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SetTensorValue(index,
367 nullptr, sizeof(activation)));
368 }
369
370 /**
371 * @tc.name: inner_model_set_tensor_value_004
372 * @tc.desc: Verify the length invalid of the set_tensor_value function
373 * @tc.type: FUNC
374 */
375 HWTEST_F(InnerModelTest, inner_model_set_tensor_value_004, TestSize.Level1)
376 {
377 SetTensors();
378
379 uint32_t index = 3;
380 const int8_t activation = 0;
381 EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_innerModelTest.SetTensorValue(index,
382 static_cast<const void *>(&activation), 0));
383 }
384
385 /**
386 * @tc.name: inner_model_set_tensor_value_005
387 * @tc.desc: Verify the after buildgraph of the set_tensor_value function
388 * @tc.type: FUNC
389 */
390 HWTEST_F(InnerModelTest, inner_model_set_tensor_value_005, TestSize.Level1)
391 {
392 uint32_t index = 3;
393 const int8_t activation = 0;
394
395 mindspore::lite::LiteGraph* liteGraph = new (std::nothrow) mindspore::lite::LiteGraph();
396 EXPECT_NE(nullptr, liteGraph);
397 SetLiteGraph(liteGraph);
398
399 ExtensionConfig extensionConfig;
400 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.BuildFromLiteGraph(liteGraph, extensionConfig));
401
402 EXPECT_EQ(OH_NN_OPERATION_FORBIDDEN, m_innerModelTest.SetTensorValue(index,
403 static_cast<const void *>(&activation), sizeof(int8_t)));
404 }
405
406 /**
407 * @tc.name: inner_model_set_tensor_value_006
408 * @tc.desc: Verify the set value twice of the set_tensor_value function
409 * @tc.type: FUNC
410 */
411 HWTEST_F(InnerModelTest, inner_model_set_tensor_value_006, TestSize.Level1)
412 {
413 SetTensors();
414
415 uint32_t index = 3;
416 const int8_t activation = 0;
417 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SetTensorValue(index,
418 static_cast<const void *>(&activation), sizeof(int8_t)));
419
420 EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_innerModelTest.SetTensorValue(index,
421 static_cast<const void *>(&activation), sizeof(int8_t)));
422 }
423
424 /**
425 * @tc.name: inner_model_set_tensor_value_007
426 * @tc.desc: Verify the tensor dynamicShape of the set_tensor_value function
427 * @tc.type: FUNC
428 */
429 HWTEST_F(InnerModelTest, inner_model_set_tensor_value_007, TestSize.Level1)
430 {
431 const int32_t dimInput[2] = {2, -1};
432 const OH_NN_Tensor& tensor = {OH_NN_FLOAT32, 2, dimInput, nullptr, OH_NN_TENSOR};
433
434 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensor));
435 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensor));
436 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensor));
437 const OH_NN_Tensor& tensorParam = {OH_NN_INT8, 0, nullptr, nullptr, OH_NN_ADD_ACTIVATIONTYPE};
438 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensorParam));
439
440 uint32_t index = 0;
441 float x[4] = {0, 1, 2, 3};
442 EXPECT_EQ(OH_NN_OPERATION_FORBIDDEN, m_innerModelTest.SetTensorValue(index,
443 x, sizeof(x)- 1));
444 }
445
446 /**
447 * @tc.name: inner_model_add_operation_001
448 * @tc.desc: Verify the success of the addoperation function
449 * @tc.type: FUNC
450 */
451 HWTEST_F(InnerModelTest, inner_model_add_operation_001, TestSize.Level1)
452 {
453 SetIndices();
454
455 SetTensors();
456
457 uint32_t index = 3;
458 const int8_t activation = 0;
459 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SetTensorValue(index,
460 static_cast<const void *>(&activation), sizeof(int8_t)));
461
462 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddOperation(m_opType, m_params, m_inputs, m_outputs));
463 }
464
465 /**
466 * @tc.name: inner_model_add_operation_002
467 * @tc.desc: Verify the after buildgraph of the addtensor function
468 * @tc.type: FUNC
469 */
470 HWTEST_F(InnerModelTest, inner_model_add_operation_002, TestSize.Level1)
471 {
472 OH_NN_OperationType m_opType = OH_NN_OPS_ADD;
473 OH_NN_UInt32Array m_inputs;
474 OH_NN_UInt32Array m_outputs;
475 OH_NN_UInt32Array m_params;
476
477 mindspore::lite::LiteGraph* liteGraph = new (std::nothrow) mindspore::lite::LiteGraph();
478 EXPECT_NE(nullptr, liteGraph);
479 SetLiteGraph(liteGraph);
480
481 ExtensionConfig extensionConfig;
482
483 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.BuildFromLiteGraph(liteGraph, extensionConfig));
484
485 EXPECT_EQ(OH_NN_OPERATION_FORBIDDEN, m_innerModelTest.AddOperation(m_opType, m_params, m_inputs,
486 m_outputs));
487 }
488
489 /**
490 * @tc.name: inner_model_add_operation_003
491 * @tc.desc: Verify the without set buffer of the addtensor function
492 * @tc.type: FUNC
493 */
494 HWTEST_F(InnerModelTest, inner_model_add_operation_003, TestSize.Level1)
495 {
496 SetIndices();
497 SetTensors();
498
499 EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_innerModelTest.AddOperation(m_opType, m_params, m_inputs, m_outputs));
500 }
501
502 /**
503 * @tc.name: inner_model_add_operation_004
504 * @tc.desc: Verify the output indices equal to input indices of the addtensor function
505 * @tc.type: FUNC
506 */
507 HWTEST_F(InnerModelTest, inner_model_add_operation_004, TestSize.Level1)
508 {
509 m_outputIndexs[0] = 0;
510
511 SetIndices();
512 SetTensors();
513
514 EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_innerModelTest.AddOperation(m_opType, m_params, m_inputs, m_outputs));
515 }
516
517 /**
518 * @tc.name: inner_model_add_operation_005
519 * @tc.desc: Verify the optype invalid of the addtensor function
520 * @tc.type: FUNC
521 */
522 HWTEST_F(InnerModelTest, inner_model_add_operation_005, TestSize.Level1)
523 {
524 m_opType = OH_NN_OperationType(99);
525
526 SetIndices();
527 SetTensors();
528
529 EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_innerModelTest.AddOperation(m_opType, m_params, m_inputs, m_outputs));
530 }
531
532 /**
533 * @tc.name: inner_model_add_operation_006
534 * @tc.desc: Verify the input indices out of bounds of the addoperation function
535 * @tc.type: FUNC
536 */
537 HWTEST_F(InnerModelTest, inner_model_add_operation_006, TestSize.Level1)
538 {
539 m_inputIndexs[1] = 6;
540
541 SetIndices();
542 SetTensors();
543
544 uint32_t index = 3;
545 const int8_t activation = 0;
546 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SetTensorValue(index,
547 static_cast<const void *>(&activation), sizeof(int8_t)));
548 EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_innerModelTest.AddOperation(m_opType, m_params, m_inputs, m_outputs));
549 }
550
551 /**
552 * @tc.name: inner_model_add_operation_007
553 * @tc.desc: Verify the param indices out of bounds of the addoperation function
554 * @tc.type: FUNC
555 */
556 HWTEST_F(InnerModelTest, inner_model_add_operation_007, TestSize.Level1)
557 {
558 m_paramIndexs[0] = 6;
559
560 SetIndices();
561 SetTensors();
562
563 uint32_t index = 3;
564 const int8_t activation = 0;
565 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SetTensorValue(index,
566 static_cast<const void *>(&activation), sizeof(int8_t)));
567 EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_innerModelTest.AddOperation(m_opType, m_params, m_inputs, m_outputs));
568 }
569
570 /**
571 * @tc.name: inner_model_add_operation_008
572 * @tc.desc: Verify the input indices size is 0 of the addoperation function
573 * @tc.type: FUNC
574 */
575 HWTEST_F(InnerModelTest, inner_model_add_operation_008, TestSize.Level1)
576 {
577 SetIndices();
578
579 m_inputs.size = 0;
580 m_inputs.data = nullptr;
581 SetTensors();
582
583 uint32_t index = 3;
584 const int8_t activation = 0;
585 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SetTensorValue(index,
586 static_cast<const void *>(&activation), sizeof(int8_t)));
587
588 EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_innerModelTest.AddOperation(m_opType, m_params, m_inputs, m_outputs));
589 }
590
591 /**
592 * @tc.name: inner_model_add_operation_009
593 * @tc.desc: Verify the output indices size is 0 of the addoperation function
594 * @tc.type: FUNC
595 */
596 HWTEST_F(InnerModelTest, inner_model_add_operation_009, TestSize.Level1)
597 {
598 SetIndices();
599
600 m_outputs.size = 0;
601 m_outputs.data = nullptr;
602 SetTensors();
603
604 uint32_t index = 3;
605 const int8_t activation = 0;
606 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SetTensorValue(index,
607 static_cast<const void *>(&activation), sizeof(int8_t)));
608
609 EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_innerModelTest.AddOperation(m_opType, m_params, m_inputs, m_outputs));
610 }
611
612 /**
613 * @tc.name: inner_model_add_operation_010
614 * @tc.desc: Verify the ops build failed of the addoperation function
615 * @tc.type: FUNC
616 */
617 HWTEST_F(InnerModelTest, inner_model_add_operation_010, TestSize.Level1)
618 {
619 SetIndices();
620
621 const int32_t dimInput1[2] = {2, 2};
622 const OH_NN_Tensor& tensor = {OH_NN_FLOAT32, 2, dimInput1, nullptr, OH_NN_TENSOR};
623 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensor));
624 const int32_t dimInput2[2] = {2, 2};
625 const OH_NN_Tensor& tensor1 = {OH_NN_FLOAT32, 2, dimInput2, nullptr, OH_NN_TENSOR};
626 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensor1));
627 const int32_t dimOutput[2] = {2, 2};
628 const OH_NN_Tensor& tensor2 = {OH_NN_FLOAT32, 2, dimOutput, nullptr, OH_NN_TENSOR};
629 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensor2));
630 const OH_NN_Tensor& tensor3 = {OH_NN_INT8, 0, nullptr, nullptr, OH_NN_DIV_ACTIVATIONTYPE};
631 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensor3));
632
633 uint32_t index = 3;
634 const int8_t activation = 0;
635 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SetTensorValue(index,
636 static_cast<const void *>(&activation), sizeof(int8_t)));
637
638 EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_innerModelTest.AddOperation(m_opType, m_params, m_inputs, m_outputs));
639 }
640
641 /**
642 * @tc.name: inner_model_specify_inputs_and_outputs_001
643 * @tc.desc: Verify the success of the specify_inputs_and_outputs function
644 * @tc.type: FUNC
645 */
646 HWTEST_F(InnerModelTest, inner_model_specify_inputs_and_outputs_001, TestSize.Level1)
647 {
648 SetIndices();
649 SetTensors();
650
651 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SpecifyInputsAndOutputs(m_inputs, m_outputs));
652
653 std::vector<std::shared_ptr<NNTensor>> inTensors = m_innerModelTest.GetInputTensors();
654 EXPECT_EQ(inTensors.size(), m_inputs.size);
655 std::vector<std::shared_ptr<NNTensor>> outTensors = m_innerModelTest.GetOutputTensors();
656 EXPECT_EQ(outTensors.size(), m_outputs.size);
657 }
658
659 /**
660 * @tc.name: inner_model_specify_inputs_and_outputs_002
661 * @tc.desc: Verify the after buildgraph of the specify_inputs_and_outputs function
662 * @tc.type: FUNC
663 */
664 HWTEST_F(InnerModelTest, inner_model_specify_inputs_and_outputs_002, TestSize.Level1)
665 {
666 OH_NN_UInt32Array inputs;
667 OH_NN_UInt32Array outputs;
668 inputs.data = m_inputIndexs;
669 inputs.size = sizeof(m_inputIndexs) / sizeof(uint32_t);
670 outputs.data = nullptr;
671 outputs.size = sizeof(m_outputIndexs) / sizeof(uint32_t);
672
673 mindspore::lite::LiteGraph* liteGraph = new (std::nothrow) mindspore::lite::LiteGraph();
674 EXPECT_NE(nullptr, liteGraph);
675 SetLiteGraph(liteGraph);
676
677 ExtensionConfig extensionConfig;
678
679 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.BuildFromLiteGraph(liteGraph, extensionConfig));
680
681 EXPECT_EQ(OH_NN_OPERATION_FORBIDDEN, m_innerModelTest.SpecifyInputsAndOutputs(inputs, outputs));
682 }
683
684 /**
685 * @tc.name: inner_model_specify_inputs_and_outputs_003
686 * @tc.desc: Verify the output indices is nullptr but length not 0 of the specify_inputs_and_outputs function
687 * @tc.type: FUNC
688 */
689 HWTEST_F(InnerModelTest, inner_model_specify_inputs_and_outputs_003, TestSize.Level1)
690 {
691 SetIndices();
692
693 m_outputs.data = nullptr;
694 SetTensors();
695
696 EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_innerModelTest.SpecifyInputsAndOutputs(m_inputs, m_outputs));
697 }
698
699 /**
700 * @tc.name: inner_model_specify_inputs_and_outputs_004
701 * @tc.desc: Verify the specift twice of the specify_inputs_and_outputs function
702 * @tc.type: FUNC
703 */
704 HWTEST_F(InnerModelTest, inner_model_specify_inputs_and_outputs_004, TestSize.Level1)
705 {
706 SetIndices();
707 SetTensors();
708
709 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SpecifyInputsAndOutputs(m_inputs, m_outputs));
710
711 EXPECT_EQ(OH_NN_OPERATION_FORBIDDEN, m_innerModelTest.SpecifyInputsAndOutputs(m_inputs, m_outputs));
712 }
713
714 /**
715 * @tc.name: inner_model_build_001
716 * @tc.desc: Verify the success of the build function
717 * @tc.type: FUNC
718 */
719 HWTEST_F(InnerModelTest, inner_model_build_001, TestSize.Level1)
720 {
721 SetIndices();
722 SetTensors();
723
724 uint32_t index = 3;
725 const int8_t activation = 0;
726 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SetTensorValue(index,
727 static_cast<const void *>(&activation), sizeof(int8_t)));
728
729 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddOperation(m_opType, m_params, m_inputs, m_outputs));
730 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SpecifyInputsAndOutputs(m_inputs, m_outputs));
731 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.Build());
732 EXPECT_EQ(true, m_innerModelTest.IsBuild());
733 }
734
735 /**
736 * @tc.name: inner_model_build_002
737 * @tc.desc: Verify the build twice forbidden of the build function
738 * @tc.type: FUNC
739 */
740 HWTEST_F(InnerModelTest, inner_model_build_002, TestSize.Level1)
741 {
742 SetIndices();
743 SetTensors();
744
745 uint32_t index = 3;
746 const int8_t activation = 0;
747 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SetTensorValue(index,
748 static_cast<const void *>(&activation), sizeof(int8_t)));
749
750 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddOperation(m_opType, m_params, m_inputs, m_outputs));
751 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SpecifyInputsAndOutputs(m_inputs, m_outputs));
752 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.Build());
753 EXPECT_EQ(OH_NN_OPERATION_FORBIDDEN, m_innerModelTest.Build());
754 }
755
756 /**
757 * @tc.name: inner_model_build_003
758 * @tc.desc: Verify the params not match optype of the build function
759 * @tc.type: FUNC
760 */
761 HWTEST_F(InnerModelTest, inner_model_build_003, TestSize.Level1)
762 {
763 OH_NN_OperationType m_opType = OH_NN_OPS_DIV;
764
765 SetIndices();
766
767 const int dim[2] = {2, 2};
768 const OH_NN_Tensor& tensor = {OH_NN_FLOAT32, 2, dim, nullptr, OH_NN_TENSOR};
769 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensor));
770 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensor));
771 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensor));
772 const OH_NN_Tensor& tensorParam = {OH_NN_INT8, 0, nullptr, nullptr, OH_NN_DIV_ACTIVATIONTYPE};
773 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddTensor(tensorParam));
774
775 uint32_t index = 3;
776 const int8_t activation = 0;
777 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SetTensorValue(index,
778 static_cast<const void *>(&activation), sizeof(int8_t)));
779 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SpecifyInputsAndOutputs(m_inputs, m_outputs));
780 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddOperation(m_opType, m_params, m_inputs, m_outputs));
781 EXPECT_EQ(OH_NN_FAILED, m_innerModelTest.Build());
782 }
783
784 /**
785 * @tc.name: inner_model_build_004
786 * @tc.desc: Verify the success of the build function
787 * @tc.type: FUNC
788 */
789 HWTEST_F(InnerModelTest, inner_model_build_004, TestSize.Level1)
790 {
791 SetIndices();
792 SetTensors();
793
794 uint32_t index = 3;
795 const int8_t activation = 0;
796 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SetTensorValue(index,
797 static_cast<const void *>(&activation), sizeof(int8_t)));
798
799 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddOperation(m_opType, m_params, m_inputs, m_outputs));
800 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SpecifyInputsAndOutputs(m_inputs, m_outputs));
801 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.Build());
802 }
803
804 /**
805 * @tc.name: inner_model_get_supported_operation_001
806 * @tc.desc: Verify the success of the get_supported_operation function
807 * @tc.type: FUNC
808 */
809 HWTEST_F(InnerModelTest, inner_model_get_supported_operation_001, TestSize.Level1)
810 {
811 const bool *isSupported = nullptr;
812 uint32_t opCount = 1;
813
814 SetIndices();
815 SetTensors();
816
817 uint32_t index = 3;
818 const int8_t activation = 0;
819 size_t deviceID = 10;
820 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SetTensorValue(index,
821 static_cast<const void *>(&activation), sizeof(int8_t)));
822
823 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddOperation(m_opType, m_params, m_inputs, m_outputs));
824 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SpecifyInputsAndOutputs(m_inputs, m_outputs));
825 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.Build());
826 EXPECT_EQ(OH_NN_FAILED, m_innerModelTest.GetSupportedOperations(deviceID, &isSupported, opCount));
827 }
828
829 /**
830 * @tc.name: inner_model_get_supported_operation_002
831 * @tc.desc: Verify the mock hdi device result of the get_supported_operation function
832 * @tc.type: FUNC
833 */
834 HWTEST_F(InnerModelTest, inner_model_get_supported_operation_002, TestSize.Level1)
835 {
836 size_t deviceID = 10;
837 const bool *isSupported = nullptr;
838 uint32_t opCount = 1;
839
840 mindspore::lite::LiteGraph* liteGraph = new (std::nothrow) mindspore::lite::LiteGraph();
841 EXPECT_NE(nullptr, liteGraph);
842 SetLiteGraph(liteGraph);
843
844 ExtensionConfig extensionConfig;
845
846 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.BuildFromLiteGraph(liteGraph, extensionConfig));
847 EXPECT_EQ(OH_NN_FAILED, m_innerModelTest.GetSupportedOperations(deviceID, &isSupported, opCount));
848 }
849
850 /**
851 * @tc.name: inner_model_get_supported_operation_003
852 * @tc.desc: Verify the mock device manager of the get_supported_operation function
853 * @tc.type: FUNC
854 */
855 HWTEST_F(InnerModelTest, inner_model_get_supported_operation_003, TestSize.Level1)
856 {
857 const bool *isSupported = nullptr;
858 uint32_t opCount = 1;
859
860 SetIndices();
861 SetTensors();
862
863 uint32_t index = 3;
864 const int8_t activation = 0;
865 size_t deviceID = 12345;
866 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SetTensorValue(index,
867 static_cast<const void *>(&activation), sizeof(int8_t)));
868
869 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.AddOperation(m_opType, m_params, m_inputs, m_outputs));
870 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.SpecifyInputsAndOutputs(m_inputs, m_outputs));
871 EXPECT_EQ(OH_NN_SUCCESS, m_innerModelTest.Build());
872 EXPECT_EQ(OH_NN_FAILED, m_innerModelTest.GetSupportedOperations(deviceID, &isSupported, opCount));
873
874 std::shared_ptr<mindspore::lite::LiteGraph> liteGraph = m_innerModelTest.GetLiteGraphs();
875 EXPECT_EQ(liteGraph->name_, "NNR_Model");
876 }
877
878 /**
879 * @tc.name: inner_model_get_supported_operation_004
880 * @tc.desc: Verify the before build of the get_supported_operation function
881 * @tc.type: FUNC
882 */
883 HWTEST_F(InnerModelTest, inner_model_get_supported_operation_004, TestSize.Level1)
884 {
885 size_t deviceID = 10;
886 const bool *isSupported = nullptr;
887 uint32_t opCount = 1;
888
889 EXPECT_EQ(OH_NN_OPERATION_FORBIDDEN, m_innerModelTest.GetSupportedOperations(deviceID, &isSupported, opCount));
890 }
891 } // namespace UnitTest
892 } // namespace NNRT
893
894 namespace OHOS {
895 namespace NeuralNetworkRuntime {
896 namespace V2 {
897 namespace UnitTest {
898 class LiteGraphToHDIModelV2Test : public testing::Test {
899 public:
900 LiteGraphToHDIModelV2Test() = default;
901 ~LiteGraphToHDIModelV2Test() = default;
902 public:
903 std::vector<uint32_t> m_inputs{0, 1};
904 std::vector<uint32_t> m_outputs{2};
905 std::vector<uint32_t> m_param{3};
906 std::vector<int32_t> m_input_dim{3, 3};
907 std::vector<int32_t> m_output_dim{3, 3};
908 std::vector<int32_t> m_param_dim{};
909 };
910
getNode(void * primitive)911 MSLITE::LiteGraph::Node* getNode(void* primitive)
912 {
913 MSLITE::LiteGraph::Node* node = new(std::nothrow) MSLITE::LiteGraph::Node();
914 node->name_ = "NNRt_SubGraph";
915 node->quant_type_ = 1;
916 node->primitive_ = primitive;
917 node->input_indices_ = {1, 1, 1, 1};
918 node->output_indices_ = {1, 1, 1, 1};
919 return node;
920 }
921
922 /**
923 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_001
924 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
925 * @tc.type: FUNC
926 */
927 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_001, TestSize.Level0)
928 {
929 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_001");
930 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
931 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(nullptr, tensorBuffer);
932 EXPECT_EQ(nullptr, model);
933 }
934
935 /**
936 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_002
937 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
938 * @tc.type: FUNC
939 */
940 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_002, TestSize.Level0)
941 {
942 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_002");
943 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
944 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {0, 0, 0, 0};
945 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
946 EXPECT_EQ(nullptr, model);
947
948 uint8_t *mmapPtr = static_cast<uint8_t *>(mmap(nullptr,
949 tensorBuffer.bufferSize, PROT_READ | PROT_WRITE, MAP_SHARED, tensorBuffer.fd, 0));
950 EXPECT_EQ(MAP_FAILED, mmapPtr);
951 }
952
953 /**
954 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_003
955 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
956 * @tc.type: FUNC
957 */
958 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_003, TestSize.Level0)
959 {
960 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_003");
961 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
962 MSLITE::LiteGraph::SubGraph* subGraph = new (std::nothrow) MSLITE::LiteGraph::SubGraph();
963 subGraph->name_ = "NNRt_SubGraph";
964 subGraph->input_indices_ = {1, 1, 1, 1};
965 subGraph->output_indices_ = {1, 1, 1, 1};
966 subGraph->node_indices_ = {1, 1, 1, 1};
967
968 void* tp = MSLITE::MindIR_Tensor_Create();
969
970 liteGraph.get()->all_tensors_.emplace_back(tp);
971 liteGraph.get()->sub_graphs_.emplace_back(subGraph);
972
973 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 1, 1, 1};
974
975 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
976 EXPECT_NE(nullptr, model);
977
978 uint8_t *mmapPtr = static_cast<uint8_t *>(mmap(nullptr,
979 tensorBuffer.bufferSize, PROT_READ | PROT_WRITE, MAP_SHARED, tensorBuffer.fd, 0));
980 EXPECT_EQ(MAP_FAILED, mmapPtr);
981 }
982
983 /**
984 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_004
985 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
986 * @tc.type: FUNC
987 */
988 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_004, TestSize.Level0)
989 {
990 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_004");
991 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
992 liteGraph.get()->all_nodes_.emplace_back(nullptr);
993 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
994 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
995 EXPECT_EQ(nullptr, model);
996 }
997
998 /**
999 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_005
1000 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1001 * @tc.type: FUNC
1002 */
1003 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_005, TestSize.Level0)
1004 {
1005 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_005");
1006 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1007 MSLITE::LiteGraph::Node* node = new(std::nothrow) MSLITE::LiteGraph::Node();
1008 liteGraph.get()->all_nodes_.emplace_back(node);
1009 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1010 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1011 EXPECT_EQ(nullptr, model);
1012 }
1013
1014 /**
1015 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_006
1016 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1017 * @tc.type: FUNC
1018 */
1019 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_006, TestSize.Level0)
1020 {
1021 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_006");
1022 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1023
1024 float alpha {0.0f};
1025 float minVal {0.0f};
1026 float maxVal {0.0f};
1027 bool approximate {false};
1028 mindspore::lite::ActivationType activationType {mindspore::lite::ACTIVATION_TYPE_ABS};
1029
1030 void* primitive = mindspore::lite::MindIR_Activation_CreatePrimitive(activationType, alpha,
1031 minVal, maxVal, approximate);
1032
1033 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1034 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1035 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1036 EXPECT_NE(nullptr, model);
1037 }
1038
1039 /**
1040 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_007
1041 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1042 * @tc.type: FUNC
1043 */
1044 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_007, TestSize.Level0)
1045 {
1046 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_007");
1047 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1048
1049 int8_t num = 1;
1050 int8_t* fuseData = #
1051 mindspore::lite::ActivationType type = NNToMS::TransfromFusionType(static_cast<OH_NN_FuseType>(*fuseData));
1052 void* primitive = mindspore::lite::MindIR_AddFusion_CreatePrimitive(type);
1053
1054 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1055 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1056 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1057 EXPECT_NE(nullptr, model);
1058 }
1059
1060 /**
1061 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_008
1062 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1063 * @tc.type: FUNC
1064 */
1065 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_008, TestSize.Level0)
1066 {
1067 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_008");
1068 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1069
1070 int64_t keepDims {0};
1071 void* primitive = mindspore::lite::MindIR_All_CreatePrimitive(keepDims);
1072
1073 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1074 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1075 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1076 EXPECT_NE(nullptr, model);
1077 }
1078
1079 /**
1080 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_009
1081 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1082 * @tc.type: FUNC
1083 */
1084 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_009, TestSize.Level0)
1085 {
1086 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_009");
1087 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1088
1089 int64_t axis {-1};
1090 int64_t topK {1};
1091 bool keepDims {false};
1092 bool outMaxValue {false};
1093 void* primitive = mindspore::lite::MindIR_ArgMaxFusion_CreatePrimitive(axis, topK, keepDims, outMaxValue);
1094
1095 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1096 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1097 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1098 EXPECT_NE(nullptr, model);
1099 }
1100
1101 /**
1102 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_010
1103 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1104 * @tc.type: FUNC
1105 */
1106 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_010, TestSize.Level0)
1107 {
1108 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_010");
1109 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1110
1111 int64_t summarize {0};
1112 void* primitive = mindspore::lite::MindIR_Assert_CreatePrimitive(summarize);
1113
1114 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1115 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1116 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1117 EXPECT_NE(nullptr, model);
1118 }
1119
1120 /**
1121 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_011
1122 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1123 * @tc.type: FUNC
1124 */
1125 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_011, TestSize.Level0)
1126 {
1127 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_011");
1128 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1129
1130 std::vector<int64_t> kernelSize;
1131 std::vector<int64_t> pad;
1132 std::vector<int64_t> strides;
1133 mindspore::lite::PadMode padMode {mindspore::lite::PAD_MODE_PAD};
1134 mindspore::lite::ActivationType activationType {mindspore::lite::ACTIVATION_TYPE_NO_ACTIVATION};
1135 mindspore::lite::RoundMode roundMode {mindspore::lite::ROUND_MODE_FLOOR};
1136 mindspore::lite::Format format {mindspore::lite::FORMAT_NCHW};
1137 bool global {false};
1138 void* primitive = mindspore::lite::MindIR_AvgPoolFusion_CreatePrimitive(kernelSize, strides, pad,
1139 padMode, roundMode, format, global, activationType);
1140
1141 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1142 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1143 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1144 EXPECT_NE(nullptr, model);
1145 }
1146
1147 /**
1148 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_012
1149 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1150 * @tc.type: FUNC
1151 */
1152 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_012, TestSize.Level0)
1153 {
1154 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_012");
1155 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1156
1157 std::vector<int64_t> blockSize;
1158 std::vector<std::vector<int64_t>> crops;
1159 void* primitive = mindspore::lite::MindIR_BatchToSpaceND_CreatePrimitive(blockSize, crops);
1160
1161 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1162 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1163 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1164 EXPECT_NE(nullptr, model);
1165 }
1166
1167 /**
1168 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_013
1169 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1170 * @tc.type: FUNC
1171 */
1172 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_013, TestSize.Level0)
1173 {
1174 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_013");
1175 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1176
1177 float epsilon {0.0001f};
1178 void* primitive = mindspore::lite::MindIR_FusedBatchNorm_CreatePrimitive(epsilon);
1179
1180 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1181 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1182 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1183 EXPECT_NE(nullptr, model);
1184 }
1185
1186 /**
1187 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_014
1188 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1189 * @tc.type: FUNC
1190 */
1191 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_014, TestSize.Level0)
1192 {
1193 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_014");
1194 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1195
1196 float epsilon {0.0001f};
1197 void* primitive = mindspore::lite::MindIR_FusedBatchNorm_CreatePrimitive(epsilon);
1198
1199 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1200 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1201 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1202 EXPECT_NE(nullptr, model);
1203 }
1204
1205 /**
1206 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_015
1207 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1208 * @tc.type: FUNC
1209 */
1210 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_015, TestSize.Level0)
1211 {
1212 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_015");
1213 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1214
1215 void* primitive = mindspore::lite::MindIR_BiasAdd_CreatePrimitive();
1216
1217 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1218 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1219 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1220 EXPECT_NE(nullptr, model);
1221 }
1222
1223 /**
1224 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_016
1225 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1226 * @tc.type: FUNC
1227 */
1228 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_016, TestSize.Level0)
1229 {
1230 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_016");
1231 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1232
1233 std::vector<int64_t> shape;
1234 void* primitive = mindspore::lite::MindIR_BroadcastTo_CreatePrimitive(shape);
1235
1236 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1237 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1238 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1239 EXPECT_NE(nullptr, model);
1240 }
1241
1242 /**
1243 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_017
1244 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1245 * @tc.type: FUNC
1246 */
1247 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_017, TestSize.Level0)
1248 {
1249 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_017");
1250 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1251
1252 void* primitive = mindspore::lite::MindIR_Cast_CreatePrimitive();
1253
1254 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1255 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1256 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1257 EXPECT_NE(nullptr, model);
1258 }
1259
1260 /**
1261 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_018
1262 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1263 * @tc.type: FUNC
1264 */
1265 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_018, TestSize.Level0)
1266 {
1267 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_018");
1268 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1269
1270 void* primitive = mindspore::lite::MindIR_Ceil_CreatePrimitive();
1271
1272 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1273 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1274 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1275 EXPECT_NE(nullptr, model);
1276 }
1277
1278 /**
1279 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_019
1280 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1281 * @tc.type: FUNC
1282 */
1283 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_019, TestSize.Level0)
1284 {
1285 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_019");
1286 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1287
1288 float max {0.0f};
1289 float min {0.0f};
1290 void* primitive = mindspore::lite::MindIR_Clip_CreatePrimitive(max, min);
1291
1292 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1293 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1294 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1295 EXPECT_NE(nullptr, model);
1296 }
1297
1298 /**
1299 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_020
1300 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1301 * @tc.type: FUNC
1302 */
1303 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_020, TestSize.Level0)
1304 {
1305 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_020");
1306 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1307
1308 int64_t axis{0};
1309 void* primitive = mindspore::lite::MindIR_Concat_CreatePrimitive(axis);
1310
1311 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1312 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1313 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1314 EXPECT_NE(nullptr, model);
1315 }
1316
1317 /**
1318 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_021
1319 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1320 * @tc.type: FUNC
1321 */
1322 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_021, TestSize.Level0)
1323 {
1324 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_021");
1325 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1326
1327 int64_t dataType {0};
1328 std::vector<float> value;
1329 void* primitive = mindspore::lite::MindIR_ConstantOfShape_CreatePrimitive(dataType, value);
1330
1331 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1332 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1333 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1334 EXPECT_NE(nullptr, model);
1335 }
1336
1337 /**
1338 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_022
1339 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1340 * @tc.type: FUNC
1341 */
1342 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_022, TestSize.Level0)
1343 {
1344 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_022");
1345 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1346
1347 int64_t group {1};
1348 int64_t inChannel {0};
1349 int64_t outChannel {0};
1350 std::vector<int64_t> kernelSize;
1351 std::vector<int64_t> strides;
1352 std::vector<int64_t> padList;
1353 std::vector<int64_t> dilation;
1354 std::vector<int64_t> outputPaddings;
1355 mindspore::lite::PadMode padMode{mindspore::lite::PAD_MODE_PAD};
1356 mindspore::lite::ActivationType activationType{mindspore::lite::ACTIVATION_TYPE_NO_ACTIVATION};
1357 void* primitive = MindIR_Conv2dTransposeFusion_CreatePrimitive(kernelSize,
1358 strides, dilation, padMode, padList, group, inChannel, outChannel,
1359 activationType, outputPaddings);
1360
1361 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1362 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1363 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1364 EXPECT_NE(nullptr, model);
1365 }
1366
1367 /**
1368 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_023
1369 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1370 * @tc.type: FUNC
1371 */
1372 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_023, TestSize.Level0)
1373 {
1374 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_023");
1375 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1376
1377 void* primitive = mindspore::lite::MindIR_Cos_CreatePrimitive();
1378
1379 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1380 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1381 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1382 EXPECT_NE(nullptr, model);
1383 }
1384
1385 /**
1386 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_024
1387 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1388 * @tc.type: FUNC
1389 */
1390 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_024, TestSize.Level0)
1391 {
1392 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_024");
1393 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1394
1395 int64_t axis {0};
1396 std::vector<int64_t> offset;
1397 void* primitive = mindspore::lite::MindIR_Crop_CreatePrimitive(axis, offset);
1398
1399 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1400 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1401 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1402 EXPECT_NE(nullptr, model);
1403 }
1404
1405 /**
1406 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_025
1407 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1408 * @tc.type: FUNC
1409 */
1410 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_025, TestSize.Level0)
1411 {
1412 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_025");
1413 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1414
1415 int64_t blockSize {0};
1416 std::string mode;
1417 mindspore::lite::Format format {mindspore::lite::FORMAT_NCHW};
1418 void* primitive = mindspore::lite::MindIR_DepthToSpace_CreatePrimitive(blockSize, format, mode);
1419
1420 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1421 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1422 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1423 EXPECT_NE(nullptr, model);
1424 }
1425
1426 /**
1427 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_026
1428 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1429 * @tc.type: FUNC
1430 */
1431 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_026, TestSize.Level0)
1432 {
1433 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_026");
1434 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1435
1436 int64_t inputSize {0};
1437 std::vector<float> scale;
1438 float nmsIoUThreshold {0.0f};
1439 float nmsScoreThreshold {0.0f};
1440 int64_t maxDetections {0};
1441 int64_t detectionsPerClass {0};
1442 int64_t maxClassesPerDetection {0};
1443 int64_t numClasses {0};
1444 bool useRegularNms {false};
1445 bool outQuantized {false};
1446 mindspore::lite::Format format {mindspore::lite::FORMAT_NCHW};
1447 void* primitive = mindspore::lite::MindIR_DetectionPostProcess_CreatePrimitive(format, inputSize, scale,
1448 nmsIoUThreshold, nmsScoreThreshold, maxDetections, detectionsPerClass, maxClassesPerDetection,
1449 numClasses, useRegularNms, outQuantized);
1450
1451 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1452 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1453 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1454 EXPECT_NE(nullptr, model);
1455 }
1456
1457 /**
1458 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_027
1459 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1460 * @tc.type: FUNC
1461 */
1462 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_027, TestSize.Level0)
1463 {
1464 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_027");
1465 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1466
1467 mindspore::lite::EltwiseMode mode {mindspore::lite::ELTWISE_MODE_PROD};
1468 void* primitive = mindspore::lite::MindIR_Eltwise_CreatePrimitive(mode);
1469
1470 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1471 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1472 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1473 EXPECT_NE(nullptr, model);
1474 }
1475
1476 /**
1477 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_028
1478 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1479 * @tc.type: FUNC
1480 */
1481 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_028, TestSize.Level0)
1482 {
1483 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_028");
1484 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1485
1486 void* primitive = mindspore::lite::MindIR_Equal_CreatePrimitive();
1487
1488 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1489 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1490 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1491 EXPECT_NE(nullptr, model);
1492 }
1493
1494 /**
1495 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_029
1496 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1497 * @tc.type: FUNC
1498 */
1499 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_029, TestSize.Level0)
1500 {
1501 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_029");
1502 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1503
1504 void* primitive = mindspore::lite::MindIR_Erf_CreatePrimitive();
1505
1506 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1507 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1508 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1509 EXPECT_NE(nullptr, model);
1510 }
1511
1512 /**
1513 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_030
1514 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1515 * @tc.type: FUNC
1516 */
1517 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_030, TestSize.Level0)
1518 {
1519 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_030");
1520 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1521
1522 float base {-1.0f};
1523 float scale {1.0f};
1524 float shift {0.0f};
1525 void* primitive = mindspore::lite::MindIR_ExpFusion_CreatePrimitive(base, scale, shift);
1526
1527 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1528 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1529 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1530 EXPECT_NE(nullptr, model);
1531 }
1532
1533 /**
1534 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_031
1535 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1536 * @tc.type: FUNC
1537 */
1538 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_031, TestSize.Level0)
1539 {
1540 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_031");
1541 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1542
1543 void* primitive = mindspore::lite::MindIR_ExpandDims_CreatePrimitive();
1544
1545 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1546 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1547 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1548 EXPECT_NE(nullptr, model);
1549 }
1550
1551 /**
1552 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_032
1553 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1554 * @tc.type: FUNC
1555 */
1556 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_032, TestSize.Level0)
1557 {
1558 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_032");
1559 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1560
1561 void* primitive = mindspore::lite::MindIR_Fill_CreatePrimitive();
1562
1563 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1564 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1565 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1566 EXPECT_NE(nullptr, model);
1567 }
1568
1569 /**
1570 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_033
1571 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1572 * @tc.type: FUNC
1573 */
1574 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_033, TestSize.Level0)
1575 {
1576 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_033");
1577 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1578
1579 int64_t axis {1};
1580 void* primitive = mindspore::lite::MindIR_Flatten_CreatePrimitive(axis);
1581
1582 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1583 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1584 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1585 EXPECT_NE(nullptr, model);
1586 }
1587
1588 /**
1589 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_034
1590 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1591 * @tc.type: FUNC
1592 */
1593 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_034, TestSize.Level0)
1594 {
1595 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_034");
1596 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1597
1598 void* primitive = mindspore::lite::MindIR_Floor_CreatePrimitive();
1599
1600 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1601 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1602 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1603 EXPECT_NE(nullptr, model);
1604 }
1605
1606 /**
1607 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_035
1608 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1609 * @tc.type: FUNC
1610 */
1611 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_035, TestSize.Level0)
1612 {
1613 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_035");
1614 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1615
1616 bool hasBias {false};
1617 bool useAxis {false};
1618 int64_t axis {0};
1619 mindspore::lite::ActivationType activationType {mindspore::lite::ACTIVATION_TYPE_NO_ACTIVATION};
1620 void* primitive = mindspore::lite::MindIR_FullConnection_CreatePrimitive(hasBias, useAxis,
1621 axis, activationType);
1622
1623 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1624 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1625 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1626 EXPECT_NE(nullptr, model);
1627 }
1628
1629 /**
1630 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_036
1631 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1632 * @tc.type: FUNC
1633 */
1634 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_036, TestSize.Level0)
1635 {
1636 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_036");
1637 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1638
1639 void* primitive = mindspore::lite::MindIR_Gather_CreatePrimitive();
1640
1641 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1642 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1643 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1644 EXPECT_NE(nullptr, model);
1645 }
1646
1647 /**
1648 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_037
1649 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1650 * @tc.type: FUNC
1651 */
1652 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_037, TestSize.Level0)
1653 {
1654 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_037");
1655 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1656
1657 void* primitive = mindspore::lite::MindIR_GatherNd_CreatePrimitive();
1658
1659 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1660 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1661 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1662 EXPECT_NE(nullptr, model);
1663 }
1664
1665 /**
1666 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_038
1667 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1668 * @tc.type: FUNC
1669 */
1670 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_038, TestSize.Level0)
1671 {
1672 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_038");
1673 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1674
1675 mindspore::lite::ActivationType activationType = mindspore::lite::ACTIVATION_TYPE_GELU;
1676 float alpha = 0.0f;
1677 float minVal = 0.0f;
1678 float maxVal = 0.0f;
1679 bool approximate = false;
1680 void* primitive = mindspore::lite::MindIR_Activation_CreatePrimitive(activationType,
1681 alpha, minVal, maxVal, approximate);
1682
1683 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1684 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1685 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1686 EXPECT_NE(nullptr, model);
1687 }
1688
1689 /**
1690 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_039
1691 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1692 * @tc.type: FUNC
1693 */
1694 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_039, TestSize.Level0)
1695 {
1696 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_039");
1697 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1698
1699 void* primitive = mindspore::lite::MindIR_Greater_CreatePrimitive();
1700
1701 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1702 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1703 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1704 EXPECT_NE(nullptr, model);
1705 }
1706
1707 /**
1708 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_040
1709 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1710 * @tc.type: FUNC
1711 */
1712 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_040, TestSize.Level0)
1713 {
1714 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_040");
1715 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1716
1717 void* primitive = mindspore::lite::MindIR_GreaterEqual_CreatePrimitive();
1718
1719 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1720 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1721 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1722 EXPECT_NE(nullptr, model);
1723 }
1724
1725 /**
1726 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_041
1727 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1728 * @tc.type: FUNC
1729 */
1730 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_041, TestSize.Level0)
1731 {
1732 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_041");
1733 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1734
1735 mindspore::lite::ActivationType activationType = mindspore::lite::ACTIVATION_TYPE_HSIGMOID;
1736 float alpha = 0.0f;
1737 float minVal = 0.0f;
1738 float maxVal = 0.0f;
1739 bool approximate = false;
1740 void* primitive = mindspore::lite::MindIR_Activation_CreatePrimitive(activationType,
1741 alpha, minVal, maxVal, approximate);
1742
1743 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1744 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1745 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1746 EXPECT_NE(nullptr, model);
1747 }
1748
1749 /**
1750 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_042
1751 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1752 * @tc.type: FUNC
1753 */
1754 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_042, TestSize.Level0)
1755 {
1756 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_042");
1757 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1758
1759 float epsilon {0.0f};
1760 void* primitive = mindspore::lite::MindIR_InstanceNorm_CreatePrimitive(epsilon);
1761
1762 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1763 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1764 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1765 EXPECT_NE(nullptr, model);
1766 }
1767
1768 /**
1769 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_043
1770 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1771 * @tc.type: FUNC
1772 */
1773 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_043, TestSize.Level0)
1774 {
1775 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_043");
1776 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1777
1778 float epsilon {0.0f};
1779 void* primitive = mindspore::lite::MindIR_InstanceNorm_CreatePrimitive(epsilon);
1780
1781 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1782 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1783 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1784 EXPECT_NE(nullptr, model);
1785 }
1786
1787 /**
1788 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_044
1789 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1790 * @tc.type: FUNC
1791 */
1792 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_044, TestSize.Level0)
1793 {
1794 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_044");
1795 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1796
1797 std::vector<int64_t> axis;
1798 float epsilon {1e-6};
1799 mindspore::lite::ActivationType activationType {mindspore::lite::ACTIVATION_TYPE_NO_ACTIVATION};
1800 void* primitive = mindspore::lite::MindIR_L2NormalizeFusion_CreatePrimitive(axis, epsilon, activationType);
1801
1802 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1803 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1804 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1805 EXPECT_NE(nullptr, model);
1806 }
1807
1808 /**
1809 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_045
1810 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1811 * @tc.type: FUNC
1812 */
1813 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_045, TestSize.Level0)
1814 {
1815 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_045");
1816 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1817
1818 int64_t beginNormAxis {1};
1819 float epsilon {1e-7};
1820 bool elementwiseAffine {true};
1821 int64_t beginParamsAxis {1};
1822 void* primitive = mindspore::lite::MindIR_LayerNormFusion_CreatePrimitive(beginNormAxis,
1823 epsilon, elementwiseAffine, beginParamsAxis);
1824
1825 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1826 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1827 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1828 EXPECT_NE(nullptr, model);
1829 }
1830
1831 /**
1832 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_046
1833 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1834 * @tc.type: FUNC
1835 */
1836 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_046, TestSize.Level0)
1837 {
1838 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_046");
1839 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1840
1841 float alpha {0.0f};
1842 float minVal {0.0f};
1843 float maxVal {0.0f};
1844 bool approximate {false};
1845 mindspore::lite::ActivationType activationType {mindspore::lite::ACTIVATION_TYPE_LEAKY_RELU};
1846 void* primitive = mindspore::lite::MindIR_Activation_CreatePrimitive(activationType, alpha,
1847 minVal, maxVal, approximate);
1848
1849 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1850 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1851 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1852 EXPECT_NE(nullptr, model);
1853 }
1854
1855 /**
1856 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_047
1857 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1858 * @tc.type: FUNC
1859 */
1860 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_047, TestSize.Level0)
1861 {
1862 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_047");
1863 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1864
1865 void* primitive = mindspore::lite::MindIR_Less_CreatePrimitive();
1866
1867 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1868 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1869 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1870 EXPECT_NE(nullptr, model);
1871 }
1872
1873 /**
1874 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_048
1875 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1876 * @tc.type: FUNC
1877 */
1878 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_048, TestSize.Level0)
1879 {
1880 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_048");
1881 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1882
1883 void* primitive = mindspore::lite::MindIR_LessEqual_CreatePrimitive();
1884
1885 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1886 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1887 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1888 EXPECT_NE(nullptr, model);
1889 }
1890
1891 /**
1892 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_049
1893 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1894 * @tc.type: FUNC
1895 */
1896 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_049, TestSize.Level0)
1897 {
1898 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_049");
1899 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1900
1901 void* primitive = mindspore::lite::MindIR_Log_CreatePrimitive();
1902
1903 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1904 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1905 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1906 EXPECT_NE(nullptr, model);
1907 }
1908
1909 /**
1910 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_050
1911 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1912 * @tc.type: FUNC
1913 */
1914 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_050, TestSize.Level0)
1915 {
1916 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_050");
1917 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1918
1919 int64_t axis {0};
1920 void* primitive = mindspore::lite::MindIR_LogSoftmax_CreatePrimitive(axis);
1921
1922 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1923 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1924 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1925 EXPECT_NE(nullptr, model);
1926 }
1927
1928 /**
1929 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_051
1930 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1931 * @tc.type: FUNC
1932 */
1933 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_051, TestSize.Level0)
1934 {
1935 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_051");
1936 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1937
1938 void* primitive = mindspore::lite::MindIR_LogicalAnd_CreatePrimitive();
1939
1940 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1941 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1942 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1943 EXPECT_NE(nullptr, model);
1944 }
1945
1946 /**
1947 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_052
1948 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1949 * @tc.type: FUNC
1950 */
1951 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_052, TestSize.Level0)
1952 {
1953 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_052");
1954 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1955
1956 void* primitive = mindspore::lite::MindIR_LogicalNot_CreatePrimitive();
1957
1958 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1959 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1960 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1961 EXPECT_NE(nullptr, model);
1962 }
1963
1964 /**
1965 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_053
1966 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1967 * @tc.type: FUNC
1968 */
1969 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_053, TestSize.Level0)
1970 {
1971 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_053");
1972 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1973
1974 void* primitive = mindspore::lite::MindIR_LogicalOr_CreatePrimitive();
1975
1976 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
1977 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
1978 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
1979 EXPECT_NE(nullptr, model);
1980 }
1981
1982 /**
1983 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_054
1984 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
1985 * @tc.type: FUNC
1986 */
1987 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_054, TestSize.Level0)
1988 {
1989 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_054");
1990 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
1991
1992 int64_t depthRadius {0};
1993 float bias {0.0f};
1994 float alpha {0.0f};
1995 float beta {0.0f};
1996 std::string normRegion {"ACROSS_CHANNELS"};
1997 void* primitive = mindspore::lite::MindIR_LRN_CreatePrimitive(depthRadius, bias, alpha,
1998 beta, normRegion);
1999
2000 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2001 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2002 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2003 EXPECT_NE(nullptr, model);
2004 }
2005
2006 /**
2007 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_055
2008 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2009 * @tc.type: FUNC
2010 */
2011 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_055, TestSize.Level0)
2012 {
2013 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_055");
2014 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2015
2016 bool bidirectional {false};
2017 bool hasBias {false};
2018 int64_t inputSize {0};
2019 int64_t hiddenSize {0};
2020 int64_t numLayers {0};
2021 int64_t numDirections {0};
2022 float dropout {0.0f};
2023 float zoneoutCell {0.0f};
2024 float zoneoutHidden {0.0f};
2025 int64_t projSize {0};
2026 void* primitive = mindspore::lite::MindIR_LSTM_CreatePrimitive(bidirectional, hasBias, inputSize,
2027 hiddenSize, numLayers, numDirections, dropout, zoneoutCell, zoneoutHidden, projSize);
2028
2029 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2030 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2031 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2032 EXPECT_NE(nullptr, model);
2033 }
2034
2035 /**
2036 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_056
2037 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2038 * @tc.type: FUNC
2039 */
2040 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_056, TestSize.Level0)
2041 {
2042 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_056");
2043 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2044
2045 void* primitive = mindspore::lite::MindIR_Maximum_CreatePrimitive();
2046
2047 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2048 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2049 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2050 EXPECT_NE(nullptr, model);
2051 }
2052
2053 /**
2054 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_057
2055 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2056 * @tc.type: FUNC
2057 */
2058 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_057, TestSize.Level0)
2059 {
2060 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_057");
2061 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2062
2063 std::vector<int64_t> kernelSize;
2064 std::vector<int64_t> pad;
2065 std::vector<int64_t> strides;
2066 mindspore::lite::PadMode padMode {mindspore::lite::PAD_MODE_PAD};
2067 mindspore::lite::ActivationType activationType {mindspore::lite::ACTIVATION_TYPE_NO_ACTIVATION};
2068 mindspore::lite::Format format {mindspore::lite::FORMAT_NCHW};
2069 bool global {false};
2070 void* primitive = MindIR_MaxPoolFusion_CreatePrimitive(kernelSize, strides, pad,
2071 padMode, format, global, activationType);
2072
2073 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2074 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2075 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2076 EXPECT_NE(nullptr, model);
2077 }
2078
2079 /**
2080 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_058
2081 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2082 * @tc.type: FUNC
2083 */
2084 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_058, TestSize.Level0)
2085 {
2086 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_058");
2087 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2088
2089 void* primitive = mindspore::lite::MindIR_Minimum_CreatePrimitive();
2090
2091 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2092 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2093 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2094 EXPECT_NE(nullptr, model);
2095 }
2096
2097 /**
2098 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_059
2099 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2100 * @tc.type: FUNC
2101 */
2102 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_059, TestSize.Level0)
2103 {
2104 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_059");
2105 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2106
2107 void* primitive = mindspore::lite::MindIR_Mod_CreatePrimitive();
2108
2109 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2110 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2111 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2112 EXPECT_NE(nullptr, model);
2113 }
2114
2115 /**
2116 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_060
2117 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2118 * @tc.type: FUNC
2119 */
2120 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_060, TestSize.Level0)
2121 {
2122 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_060");
2123 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2124
2125 mindspore::lite::ActivationType activationType {mindspore::lite::ACTIVATION_TYPE_NO_ACTIVATION};
2126 void* primitive = mindspore::lite::MindIR_MulFusion_CreatePrimitive(activationType);
2127
2128 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2129 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2130 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2131 EXPECT_NE(nullptr, model);
2132 }
2133
2134 /**
2135 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_061
2136 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2137 * @tc.type: FUNC
2138 */
2139 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_061, TestSize.Level0)
2140 {
2141 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_061");
2142 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2143
2144 void* primitive = mindspore::lite::MindIR_Neg_CreatePrimitive();
2145
2146 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2147 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2148 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2149 EXPECT_NE(nullptr, model);
2150 }
2151
2152 /**
2153 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_062
2154 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2155 * @tc.type: FUNC
2156 */
2157 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_062, TestSize.Level0)
2158 {
2159 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_062");
2160 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2161
2162 void* primitive = mindspore::lite::MindIR_NotEqual_CreatePrimitive();
2163
2164 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2165 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2166 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2167 EXPECT_NE(nullptr, model);
2168 }
2169
2170 /**
2171 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_063
2172 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2173 * @tc.type: FUNC
2174 */
2175 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_063, TestSize.Level0)
2176 {
2177 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_063");
2178 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2179
2180 int64_t axis {-1};
2181 void* primitive = mindspore::lite::MindIR_OneHot_CreatePrimitive(axis);
2182
2183 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2184 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2185 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2186 EXPECT_NE(nullptr, model);
2187 }
2188
2189 /**
2190 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_064
2191 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2192 * @tc.type: FUNC
2193 */
2194 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_064, TestSize.Level0)
2195 {
2196 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_064");
2197 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2198
2199 std::vector<std::vector<int64_t>> paddings;
2200 float constantValue {0.0f};
2201 mindspore::lite::PaddingMode paddingMode {mindspore::lite::PADDING_MODE_CONSTANT};
2202 void* primitive = MindIR_PadFusion_CreatePrimitive(paddings, paddingMode, constantValue);
2203
2204 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2205 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2206 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2207 EXPECT_NE(nullptr, model);
2208 }
2209
2210 /**
2211 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_065
2212 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2213 * @tc.type: FUNC
2214 */
2215 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_065, TestSize.Level0)
2216 {
2217 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_065");
2218 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2219
2220 float scale {1.0f};
2221 float shift {0.0f};
2222 void* primitive = mindspore::lite::MindIR_PowFusion_CreatePrimitive(scale, shift);
2223
2224 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2225 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2226 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2227 EXPECT_NE(nullptr, model);
2228 }
2229
2230 /**
2231 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_066
2232 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2233 * @tc.type: FUNC
2234 */
2235 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_066, TestSize.Level0)
2236 {
2237 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_066");
2238 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2239
2240 bool channelShared{false};
2241 void* primitive = mindspore::lite::MindIR_PReLUFusion_CreatePrimitive(channelShared);
2242
2243 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2244 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2245 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2246 EXPECT_NE(nullptr, model);
2247 }
2248
2249 /**
2250 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_067
2251 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2252 * @tc.type: FUNC
2253 */
2254 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_067, TestSize.Level0)
2255 {
2256 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_067");
2257 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2258
2259 const uint64_t* srcT{nullptr};
2260 const uint64_t* dstT{nullptr};
2261 int64_t axis {0};
2262 void* primitive = mindspore::lite::MindIR_QuantDTypeCast_CreatePrimitive(*srcT, *dstT, axis);
2263
2264 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2265 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2266 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2267 EXPECT_NE(nullptr, model);
2268 }
2269
2270 /**
2271 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_068
2272 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2273 * @tc.type: FUNC
2274 */
2275 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_068, TestSize.Level0)
2276 {
2277 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_068");
2278 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2279
2280 int64_t dType {0.0f};
2281 int64_t start {0};
2282 int64_t limit {0};
2283 int64_t delta {1};
2284 void* primitive = mindspore::lite::MindIR_Range_CreatePrimitive(dType, start, limit, delta);
2285
2286 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2287 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2288 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2289 EXPECT_NE(nullptr, model);
2290 }
2291
2292 /**
2293 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_069
2294 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2295 * @tc.type: FUNC
2296 */
2297 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_069, TestSize.Level0)
2298 {
2299 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_069");
2300 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2301
2302 void* primitive = mindspore::lite::MindIR_Rank_CreatePrimitive();
2303
2304 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2305 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2306 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2307 EXPECT_NE(nullptr, model);
2308 }
2309
2310 /**
2311 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_070
2312 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2313 * @tc.type: FUNC
2314 */
2315 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_070, TestSize.Level0)
2316 {
2317 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_070");
2318 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2319
2320 void* primitive = mindspore::lite::MindIR_Reciprocal_CreatePrimitive();
2321
2322 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2323 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2324 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2325 EXPECT_NE(nullptr, model);
2326 }
2327
2328 /**
2329 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_071
2330 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2331 * @tc.type: FUNC
2332 */
2333 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_071, TestSize.Level0)
2334 {
2335 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_071");
2336 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2337
2338 mindspore::lite::ReduceMode mode {mindspore::lite::REDUCE_MODE_ALL};
2339 float coeff {0.0f};
2340 bool reduceToEnd {false};
2341 bool keepDims {false};
2342 void* primitive = mindspore::lite::MindIR_ReduceFusion_CreatePrimitive(keepDims, mode, reduceToEnd, coeff);
2343
2344 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2345 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2346 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2347 EXPECT_NE(nullptr, model);
2348 }
2349
2350 /**
2351 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_072
2352 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2353 * @tc.type: FUNC
2354 */
2355 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_072, TestSize.Level0)
2356 {
2357 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_072");
2358 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2359
2360 float alpha{0.0f};
2361 float minVal{0.0f};
2362 float maxVal{0.0f};
2363 bool approximate{false};
2364 mindspore::lite::ActivationType activationType{mindspore::lite::ACTIVATION_TYPE_RELU6};
2365 void* primitive = mindspore::lite::MindIR_Activation_CreatePrimitive(activationType, alpha,
2366 minVal, maxVal, approximate);
2367
2368 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2369 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2370 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2371 EXPECT_NE(nullptr, model);
2372 }
2373
2374 /**
2375 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_073
2376 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2377 * @tc.type: FUNC
2378 */
2379 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_073, TestSize.Level0)
2380 {
2381 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_073");
2382 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2383
2384 void* primitive = mindspore::lite::MindIR_Reshape_CreatePrimitive();
2385
2386 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2387 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2388 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2389 EXPECT_NE(nullptr, model);
2390 }
2391
2392 /**
2393 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_074
2394 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2395 * @tc.type: FUNC
2396 */
2397 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_074, TestSize.Level0)
2398 {
2399 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_074");
2400 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2401
2402 float cubicCoeff{0.0f};
2403 float extrapolationValue{0.0f};
2404 mindspore::lite::NearestMode nearestMode{mindspore::lite::NEAREST_MODE_NORMAL};
2405 mindspore::lite::ResizeMethod method {mindspore::lite::RESIZE_METHOD_LINEAR};
2406 uint64_t newHeight{0};
2407 uint64_t newWidth{0};
2408 bool preserveAspectRatio{false};
2409 mindspore::lite::CoordinateTransformMode coordinateTransformMode {
2410 mindspore::lite::COORDINATE_TRANSFORM_MODE_ASYMMETRIC};
2411 uint64_t excludeOutside{0};
2412 void* primitive = mindspore::lite::MindIR_Resize_CreatePrimitive(method, newHeight, newWidth,
2413 preserveAspectRatio, coordinateTransformMode, cubicCoeff, excludeOutside,
2414 extrapolationValue, nearestMode);
2415
2416 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2417 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2418 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2419 EXPECT_NE(nullptr, model);
2420 }
2421
2422 /**
2423 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_075
2424 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2425 * @tc.type: FUNC
2426 */
2427 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_075, TestSize.Level0)
2428 {
2429 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_075");
2430 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2431
2432 void* primitive = mindspore::lite::MindIR_Round_CreatePrimitive();
2433
2434 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2435 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2436 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2437 EXPECT_NE(nullptr, model);
2438 }
2439
2440 /**
2441 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_076
2442 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2443 * @tc.type: FUNC
2444 */
2445 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_076, TestSize.Level0)
2446 {
2447 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_076");
2448 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2449
2450 void* primitive = mindspore::lite::MindIR_Rsqrt_CreatePrimitive();
2451
2452 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2453 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2454 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2455 EXPECT_NE(nullptr, model);
2456 }
2457
2458 /**
2459 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_077
2460 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2461 * @tc.type: FUNC
2462 */
2463 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_077, TestSize.Level0)
2464 {
2465 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_077");
2466 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2467
2468 mindspore::lite::ActivationType activationType{mindspore::lite::ACTIVATION_TYPE_NO_ACTIVATION};
2469 const uint64_t* axis{nullptr};
2470 void* primitive = mindspore::lite::MindIR_ScaleFusion_CreatePrimitive(*axis, activationType);
2471
2472 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2473 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2474 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2475 EXPECT_NE(nullptr, model);
2476 }
2477
2478 /**
2479 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_078
2480 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2481 * @tc.type: FUNC
2482 */
2483 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_078, TestSize.Level0)
2484 {
2485 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_078");
2486 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2487
2488 void* primitive = mindspore::lite::MindIR_ScatterNd_CreatePrimitive();
2489
2490 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2491 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2492 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2493 EXPECT_NE(nullptr, model);
2494 }
2495
2496 /**
2497 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_079
2498 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2499 * @tc.type: FUNC
2500 */
2501 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_079, TestSize.Level0)
2502 {
2503 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_079");
2504 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2505
2506 void* primitive = mindspore::lite::MindIR_Select_CreatePrimitive();
2507
2508 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2509 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2510 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2511 EXPECT_NE(nullptr, model);
2512 }
2513
2514 /**
2515 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_080
2516 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2517 * @tc.type: FUNC
2518 */
2519 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_080, TestSize.Level0)
2520 {
2521 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_080");
2522 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2523
2524 float alpha{0.0f};
2525 float minVal{0.0f};
2526 float maxVal{0.0f};
2527 bool approximate{false};
2528 mindspore::lite::ActivationType activationType{mindspore::lite::ACTIVATION_TYPE_SIGMOID};
2529 void* primitive = mindspore::lite::MindIR_Activation_CreatePrimitive(activationType, alpha, minVal,
2530 maxVal, approximate);
2531
2532 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2533 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2534 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2535 EXPECT_NE(nullptr, model);
2536 }
2537
2538 /**
2539 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_081
2540 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2541 * @tc.type: FUNC
2542 */
2543 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_081, TestSize.Level0)
2544 {
2545 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_081");
2546 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2547
2548 void* primitive = mindspore::lite::MindIR_Sin_CreatePrimitive();
2549
2550 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2551 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2552 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2553 EXPECT_NE(nullptr, model);
2554 }
2555
2556 /**
2557 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_082
2558 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2559 * @tc.type: FUNC
2560 */
2561 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_082, TestSize.Level0)
2562 {
2563 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_082");
2564 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2565
2566 mindspore::lite::Format format {mindspore::lite::FORMAT_NCHW};
2567 int64_t blockSize {0};
2568 void* primitive = mindspore::lite::MindIR_SpaceToDepth_CreatePrimitive(blockSize, format);
2569
2570 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2571 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2572 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2573 EXPECT_NE(nullptr, model);
2574 }
2575
2576 /**
2577 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_083
2578 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2579 * @tc.type: FUNC
2580 */
2581 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_083, TestSize.Level0)
2582 {
2583 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_083");
2584 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2585
2586 void* primitive = mindspore::lite::MindIR_SparseToDense_CreatePrimitive();
2587
2588 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2589 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2590 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2591 EXPECT_NE(nullptr, model);
2592 }
2593
2594 /**
2595 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_084
2596 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2597 * @tc.type: FUNC
2598 */
2599 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_084, TestSize.Level0)
2600 {
2601 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_084");
2602 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2603
2604 void* primitive = mindspore::lite::MindIR_Square_CreatePrimitive();
2605
2606 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2607 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2608 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2609 EXPECT_NE(nullptr, model);
2610 }
2611
2612 /**
2613 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_085
2614 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2615 * @tc.type: FUNC
2616 */
2617 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_085, TestSize.Level0)
2618 {
2619 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_085");
2620 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2621
2622 float alpha {0.0f};
2623 float minVal {0.0f};
2624 float maxVal {0.0f};
2625 bool approximate {false};
2626 mindspore::lite::ActivationType activationType {mindspore::lite::ACTIVATION_TYPE_SWISH};
2627 void* primitive = mindspore::lite::MindIR_Activation_CreatePrimitive(activationType, alpha,
2628 minVal, maxVal, approximate);
2629
2630 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2631 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2632 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2633 EXPECT_NE(nullptr, model);
2634 }
2635
2636 /**
2637 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_086
2638 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2639 * @tc.type: FUNC
2640 */
2641 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_086, TestSize.Level0)
2642 {
2643 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_086");
2644 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2645
2646 int64_t axis {0};
2647 void* primitive = mindspore::lite::MindIR_Unstack_CreatePrimitive(axis);
2648
2649 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2650 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2651 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2652 EXPECT_NE(nullptr, model);
2653 }
2654
2655 /**
2656 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_087
2657 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2658 * @tc.type: FUNC
2659 */
2660 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_087, TestSize.Level0)
2661 {
2662 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_087");
2663 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2664
2665 void* primitive = mindspore::lite::MindIR_Where_CreatePrimitive();
2666
2667 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2668 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2669 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2670 EXPECT_NE(nullptr, model);
2671 }
2672
2673 /**
2674 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_088
2675 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2676 * @tc.type: FUNC
2677 */
2678 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_088, TestSize.Level0)
2679 {
2680 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_088");
2681 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2682
2683 void* primitive = mindspore::lite::MindIR_Shape_CreatePrimitive();
2684
2685 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2686 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2687 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2688 EXPECT_NE(nullptr, model);
2689 }
2690
2691 /**
2692 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_089
2693 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2694 * @tc.type: FUNC
2695 */
2696 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_089, TestSize.Level0)
2697 {
2698 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_089");
2699 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2700
2701 std::vector<int64_t> axis;
2702 void* primitive = mindspore::lite::MindIR_Unsqueeze_CreatePrimitive(axis);
2703
2704 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2705 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2706 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2707 EXPECT_NE(nullptr, model);
2708 }
2709
2710 /**
2711 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_090
2712 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2713 * @tc.type: FUNC
2714 */
2715 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_090, TestSize.Level0)
2716 {
2717 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_090");
2718 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2719
2720 int64_t inChannel{0};
2721 int64_t outChannel{0};
2722 std::vector<int64_t> kernelSize;
2723 std::vector<int64_t> strides;
2724 std::vector<int64_t> pad;
2725 std::vector<int64_t> dilation;
2726 mindspore::lite::PadMode padMode{mindspore::lite::PAD_MODE_PAD};
2727 mindspore::lite::ActivationType activationType{mindspore::lite::ACTIVATION_TYPE_NO_ACTIVATION};
2728 void* primitive = mindspore::lite::MindIR_Conv2DFusion_CreatePrimitive(kernelSize, strides,
2729 dilation, padMode, pad, inChannel, inChannel, outChannel, activationType);
2730
2731 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2732 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2733 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2734 EXPECT_NE(nullptr, model);
2735 }
2736
2737 /**
2738 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_091
2739 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2740 * @tc.type: FUNC
2741 */
2742 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_091, TestSize.Level0)
2743 {
2744 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_091");
2745 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2746
2747 mindspore::lite::ActivationType activationType {mindspore::lite::ACTIVATION_TYPE_NO_ACTIVATION};
2748 void* primitive = mindspore::lite::MindIR_DivFusion_CreatePrimitive(activationType);
2749
2750 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2751 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2752 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2753 EXPECT_NE(nullptr, model);
2754 }
2755
2756 /**
2757 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_092
2758 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2759 * @tc.type: FUNC
2760 */
2761 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_092, TestSize.Level0)
2762 {
2763 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_092");
2764 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2765
2766 mindspore::lite::ActivationType activationType{mindspore::lite::ACTIVATION_TYPE_NO_ACTIVATION};
2767 bool transposeA{false};
2768 bool transposeB{false};
2769 void* primitive = mindspore::lite::MindIR_MatMulFusion_CreatePrimitive(transposeA, transposeB, activationType);
2770
2771 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2772 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2773 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2774 EXPECT_NE(nullptr, model);
2775 }
2776
2777 /**
2778 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_093
2779 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2780 * @tc.type: FUNC
2781 */
2782 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_093, TestSize.Level0)
2783 {
2784 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_093");
2785 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2786
2787 std::vector<int64_t> axes;
2788 void* primitive = mindspore::lite::MindIR_SliceFusion_CreatePrimitive(axes);
2789
2790 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2791 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2792 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2793 EXPECT_NE(nullptr, model);
2794 }
2795
2796 /**
2797 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_094
2798 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2799 * @tc.type: FUNC
2800 */
2801 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_094, TestSize.Level0)
2802 {
2803 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_094");
2804 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2805
2806 std::vector<int64_t> axis;
2807 void* primitive = mindspore::lite::MindIR_Softmax_CreatePrimitive(axis);
2808
2809 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2810 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2811 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2812 EXPECT_NE(nullptr, model);
2813 }
2814
2815 /**
2816 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_095
2817 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2818 * @tc.type: FUNC
2819 */
2820 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_095, TestSize.Level0)
2821 {
2822 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_095");
2823 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2824
2825 std::vector<std::vector<int64_t>> paddings;
2826 std::vector<int64_t> block_shape {};
2827 void* primitive = mindspore::lite::MindIR_SpaceToBatchND_CreatePrimitive(block_shape, paddings);
2828
2829 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2830 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2831 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2832 EXPECT_NE(nullptr, model);
2833 }
2834
2835 /**
2836 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_096
2837 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2838 * @tc.type: FUNC
2839 */
2840 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_096, TestSize.Level0)
2841 {
2842 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_096");
2843 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2844
2845 int64_t outputNum {0};
2846 std::vector<int64_t> sizeSplits;
2847 int64_t axis {0};
2848 void* primitive = mindspore::lite::MindIR_Split_CreatePrimitive(outputNum, sizeSplits, axis);
2849
2850 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2851 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2852 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2853 EXPECT_NE(nullptr, model);
2854 }
2855
2856 /**
2857 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_097
2858 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2859 * @tc.type: FUNC
2860 */
2861 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_097, TestSize.Level0)
2862 {
2863 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_097");
2864 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2865
2866 void* primitive = mindspore::lite::MindIR_Sqrt_CreatePrimitive();
2867
2868 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2869 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2870 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2871 EXPECT_NE(nullptr, model);
2872 }
2873
2874 /**
2875 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_098
2876 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2877 * @tc.type: FUNC
2878 */
2879 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_098, TestSize.Level0)
2880 {
2881 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_098");
2882 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2883
2884 void* primitive = mindspore::lite::MindIR_SquaredDifference_CreatePrimitive();
2885
2886 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2887 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2888 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2889 EXPECT_NE(nullptr, model);
2890 }
2891
2892 /**
2893 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_099
2894 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2895 * @tc.type: FUNC
2896 */
2897 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_099, TestSize.Level0)
2898 {
2899 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_099");
2900 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2901
2902 std::vector<int64_t> axis;
2903 void* primitive = mindspore::lite::MindIR_Squeeze_CreatePrimitive(axis);
2904
2905 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2906 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2907 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2908 EXPECT_NE(nullptr, model);
2909 }
2910
2911 /**
2912 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_100
2913 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2914 * @tc.type: FUNC
2915 */
2916 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_100, TestSize.Level0)
2917 {
2918 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_100");
2919 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2920
2921 int64_t axis = {0};
2922 void* primitive = mindspore::lite::MindIR_Stack_CreatePrimitive(axis);
2923
2924 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2925 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2926 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2927 EXPECT_NE(nullptr, model);
2928 }
2929
2930 /**
2931 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_101
2932 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2933 * @tc.type: FUNC
2934 */
2935 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_101, TestSize.Level0)
2936 {
2937 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_101");
2938 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2939
2940 int64_t beginMask = {0};
2941 int64_t endMask = {0};
2942 int64_t ellipsisMask = {0};
2943 int64_t newAxisMask = {0};
2944 int64_t shrinkAxisMask = {0};
2945 void* primitive = mindspore::lite::MindIR_StridedSlice_CreatePrimitive(beginMask, endMask, ellipsisMask,
2946 newAxisMask, shrinkAxisMask);
2947
2948 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2949 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2950 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2951 EXPECT_NE(nullptr, model);
2952 }
2953
2954 /**
2955 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_102
2956 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2957 * @tc.type: FUNC
2958 */
2959 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_102, TestSize.Level0)
2960 {
2961 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_102");
2962 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2963
2964 mindspore::lite::ActivationType activationType {mindspore::lite::ACTIVATION_TYPE_NO_ACTIVATION};
2965 void* primitive = mindspore::lite::MindIR_SubFusion_CreatePrimitive(activationType);
2966
2967 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2968 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2969 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2970 EXPECT_NE(nullptr, model);
2971 }
2972
2973 /**
2974 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_103
2975 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2976 * @tc.type: FUNC
2977 */
2978 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_103, TestSize.Level0)
2979 {
2980 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_103");
2981 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
2982
2983 std::vector<int64_t> dims {0};
2984 void* primitive = mindspore::lite::MindIR_TileFusion_CreatePrimitive(dims);
2985
2986 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
2987 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
2988 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
2989 EXPECT_NE(nullptr, model);
2990 }
2991
2992 /**
2993 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_104
2994 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
2995 * @tc.type: FUNC
2996 */
2997 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_104, TestSize.Level0)
2998 {
2999 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_104");
3000 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
3001
3002 int64_t axis {0};
3003 bool sorted {true};
3004 void* primitive = mindspore::lite::MindIR_TopKFusion_CreatePrimitive(sorted, axis);
3005
3006 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
3007 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
3008 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
3009 EXPECT_NE(nullptr, model);
3010 }
3011
3012 /**
3013 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_105
3014 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
3015 * @tc.type: FUNC
3016 */
3017 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_105, TestSize.Level0)
3018 {
3019 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_105");
3020 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
3021
3022 void* primitive = mindspore::lite::MindIR_Transpose_CreatePrimitive();
3023
3024 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
3025 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
3026 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
3027 EXPECT_NE(nullptr, model);
3028 }
3029
3030 /**
3031 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_106
3032 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
3033 * @tc.type: FUNC
3034 */
3035 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_106, TestSize.Level0)
3036 {
3037 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_106");
3038 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
3039
3040 std::vector<int64_t> axis;
3041 void* primitive = mindspore::lite::MindIR_Unsqueeze_CreatePrimitive(axis);
3042
3043 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
3044 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
3045 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
3046 EXPECT_NE(nullptr, model);
3047 }
3048
3049 /**
3050 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_107
3051 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
3052 * @tc.type: FUNC
3053 */
3054 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_107, TestSize.Level0)
3055 {
3056 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_107");
3057 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
3058
3059 std::vector<int64_t> axis;
3060 void* primitive = mindspore::lite::MindIR_Unsqueeze_CreatePrimitive(axis);
3061
3062 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
3063 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
3064 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
3065 EXPECT_NE(nullptr, model);
3066 }
3067
3068 /**
3069 * @tc.name: litegraphtohdimodeltest_litegraph_to_hdimodel_108
3070 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
3071 * @tc.type: FUNC
3072 */
3073 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_litegraph_to_hdimodel_108, TestSize.Level0)
3074 {
3075 LOGE("LiteGraph_To_HDIModel litegraphtohdimodeltest_litegraph_to_hdimodel_108");
3076 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
3077 MSLITE::LiteGraph::SubGraph* subGraph = new (std::nothrow) MSLITE::LiteGraph::SubGraph();
3078 subGraph->name_ = "NNRt_SubGraph";
3079 subGraph->input_indices_ = {1, 1, 1, 1};
3080 subGraph->output_indices_ = {1, 1, 1, 1};
3081 subGraph->node_indices_ = {1, 1, 1, 1};
3082
3083 void* tp = MSLITE::MindIR_Tensor_Create();
3084
3085 liteGraph.get()->all_tensors_.emplace_back(tp);
3086 liteGraph.get()->all_tensors_.emplace_back(nullptr);
3087 liteGraph.get()->sub_graphs_.emplace_back(subGraph);
3088
3089 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 1, 1, 1};
3090
3091 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
3092 EXPECT_NE(nullptr, model);
3093
3094 uint8_t *mmapPtr = static_cast<uint8_t *>(mmap(nullptr,
3095 tensorBuffer.bufferSize, PROT_READ | PROT_WRITE, MAP_SHARED, tensorBuffer.fd, 0));
3096 EXPECT_EQ(MAP_FAILED, mmapPtr);
3097 }
3098
3099 /**
3100 * @tc.name: litegraphtohdimodeltest_hdimodel_destroy_001
3101 * @tc.desc: Verify the QuantParams function return nullptr in case of fd -1.
3102 * @tc.type: FUNC
3103 */
3104 HWTEST_F(LiteGraphToHDIModelV2Test, litegraphtohdimodeltest_hdimodel_destroy_001, TestSize.Level0)
3105 {
3106 LOGE("HDIModel_Destroy litegraphtohdimodeltest_hdimodel_destroy_001");
3107 std::shared_ptr<MSLITE::LiteGraph> liteGraph = std::make_shared<MSLITE::LiteGraph>();
3108
3109 float alpha {0.0f};
3110 float minVal {0.0f};
3111 float maxVal {0.0f};
3112 bool approximate {false};
3113 mindspore::lite::ActivationType activationType {mindspore::lite::ACTIVATION_TYPE_ABS};
3114
3115 void* primitive = mindspore::lite::MindIR_Activation_CreatePrimitive(activationType, alpha,
3116 minVal, maxVal, approximate);
3117
3118 liteGraph.get()->all_nodes_.emplace_back(getNode(primitive));
3119 OHOS::HDI::Nnrt::V2_0::SharedBuffer tensorBuffer {-1, 0, 0, 0};
3120 OHOS::HDI::Nnrt::V2_0::Model * model = LiteGraph_To_HDIModel(liteGraph.get(), tensorBuffer);
3121 EXPECT_NE(nullptr, model);
3122 HDIModel_Destroy(&model);
3123 }
3124 } // namespace UnitTest
3125 } // namespace V1
3126 } // namespace NeuralNetworkRuntime
3127 } // namespace OHOS