• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 <vector>
17 #include <string>
18 #include <iostream>
19 #include "nncore_utils.h"
20 
21 using namespace testing::ext;
22 using namespace OHOS::NeuralNetworkRuntime::Test;
23 class LogicalOrTest : public testing::Test {};
24 
25 struct LogicalOrModel1 {
26     const std::vector<int32_t> tensor_shape = {3};
27     bool input0Value[3] = {true, false, true};
28     bool input1Value[3] = {false, false, true};
29     bool outputValue[3] = {false};
30 
31     OHNNOperandTest input0 = {OH_NN_BOOL, OH_NN_TENSOR, tensor_shape, input0Value, 3*sizeof(bool)};
32     OHNNOperandTest input1 = {OH_NN_BOOL, OH_NN_TENSOR, tensor_shape, input1Value, 3*sizeof(bool)};
33     OHNNOperandTest output = {OH_NN_BOOL, OH_NN_TENSOR, tensor_shape, outputValue, 3*sizeof(bool)};
34     OHNNGraphArgs graphArgs = {.operationType = OH_NN_OPS_LOGICAL_OR,
35                                .operands = {input0, input1, output},
36                                .paramIndices = {},
37                                .inputIndices = {0, 1},
38                                .outputIndices = {2}};
39 };
40 
41 struct LogicalOrModel2 {
42     const std::vector<int32_t> tensor_shape = {3};
43     int64_t input0Value[3] = {0, 1, 0};
44     int64_t input1Value[3] = {1, 0, 1};
45     bool outputValue[3] = {false};
46 
47     OHNNOperandTest input0 = {OH_NN_INT64, OH_NN_TENSOR, tensor_shape, input0Value, 3*sizeof(int64_t)};
48     OHNNOperandTest input1 = {OH_NN_INT64, OH_NN_TENSOR, tensor_shape, input1Value, 3*sizeof(int64_t)};
49     OHNNOperandTest output = {OH_NN_BOOL, OH_NN_TENSOR, tensor_shape, outputValue, 3*sizeof(bool)};
50     OHNNGraphArgs graphArgs = {.operationType = OH_NN_OPS_LOGICAL_OR,
51                                .operands = {input0, input1, output},
52                                .paramIndices = {},
53                                .inputIndices = {0, 1},
54                                .outputIndices = {2}};
55 };
56 
57 /**
58  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Build_01
59  * @tc.desc: LogicalOrModel1模型build测试
60  * @tc.type: FUNC
61  */
62 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Build_01, Function | MediumTest | Level1)
63 {
64     OH_NNModel *model = OH_NNModel_Construct();
65     EXPECT_NE(nullptr, model);
66 
67     LogicalOrModel1 logicalOrModel;
68     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
69     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
70 
71     OH_NNCompilation *compilation = OH_NNCompilation_Construct(model);
72     EXPECT_NE(nullptr, compilation);
73 
74     OHNNCompileParam compileParam{
75         .performanceMode = OH_NN_PERFORMANCE_HIGH,
76         .priority = OH_NN_PRIORITY_HIGH,
77     };
78     EXPECT_EQ(OH_NN_SUCCESS, CompileGraphMock(compilation, compileParam));
79 
80     OH_NNExecutor *executor = OH_NNExecutor_Construct(compilation);
81     EXPECT_NE(nullptr, executor);
82 
83     Free(model, compilation, executor);
84 }
85 
86 /**
87  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Build_02
88  * @tc.desc: LogicalOrModel2模型build测试
89  * @tc.type: FUNC
90  */
91 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Build_02, Function | MediumTest | Level1)
92 {
93     OH_NNModel *model = OH_NNModel_Construct();
94     EXPECT_NE(nullptr, model);
95 
96     LogicalOrModel2 logicalOrModel;
97     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
98     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
99 
100     OH_NNCompilation *compilation = OH_NNCompilation_Construct(model);
101     EXPECT_NE(nullptr, compilation);
102 
103     OHNNCompileParam compileParam{
104         .performanceMode = OH_NN_PERFORMANCE_HIGH,
105         .priority = OH_NN_PRIORITY_HIGH,
106     };
107     EXPECT_EQ(OH_NN_SUCCESS, CompileGraphMock(compilation, compileParam));
108 
109     OH_NNExecutor *executor = OH_NNExecutor_Construct(compilation);
110     EXPECT_NE(nullptr, executor);
111 
112     Free(model, compilation, executor);
113 }
114 
115 /**
116  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Build_03
117  * @tc.desc: LogicalOrModel1模型输入Tensor+1进行build测试
118  * @tc.type: FUNC
119  */
120 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Build_03, Function | MediumTest | Level2)
121 {
122     OH_NNModel *model = OH_NNModel_Construct();
123     EXPECT_NE(nullptr, model);
124 
125     LogicalOrModel2 logicalOrModel;
126     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
127     graphArgs.operands = {logicalOrModel.input0, logicalOrModel.input1, logicalOrModel.input1, logicalOrModel.output};
128     graphArgs.inputIndices = {0, 1, 2};
129     graphArgs.outputIndices = {3};
130     EXPECT_EQ(OH_NN_INVALID_PARAMETER, BuildSingleOpGraph(model, graphArgs));
131 
132     Free(model, nullptr, nullptr);
133 }
134 
135 /**
136  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Build_04
137  * @tc.desc: LogicalOrModel1模型输出Tensor+1进行build测试
138  * @tc.type: FUNC
139  */
140 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Build_04, Function | MediumTest | Level2)
141 {
142     OH_NNModel *model = OH_NNModel_Construct();
143     EXPECT_NE(nullptr, model);
144 
145     LogicalOrModel2 logicalOrModel;
146     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
147     graphArgs.operands = {logicalOrModel.input0, logicalOrModel.input1, logicalOrModel.output, logicalOrModel.output};
148     graphArgs.inputIndices = {0, 1};
149     graphArgs.outputIndices = {2, 3};
150     EXPECT_EQ(OH_NN_INVALID_PARAMETER, BuildSingleOpGraph(model, graphArgs));
151 
152     Free(model, nullptr, nullptr);
153 }
154 
155 /**
156  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Build_05
157  * @tc.desc: LogicalOrModel1模型传入非法参数进行build测试
158  * @tc.type: FUNC
159  */
160 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Build_05, Function | MediumTest | Level2)
161 {
162     OH_NNModel *model = OH_NNModel_Construct();
163     EXPECT_NE(nullptr, model);
164 
165     LogicalOrModel2 logicalOrModel;
166     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
167 
168     int8_t activationValue = OH_NN_FUSED_NONE;
169     OHNNOperandTest activation = {OH_NN_INT8, OH_NN_ADD_ACTIVATIONTYPE, {}, &activationValue, sizeof(int8_t)};
170     graphArgs.operands = {logicalOrModel.input0, logicalOrModel.input1, logicalOrModel.output, activation};
171     graphArgs.paramIndices = {3};
172     EXPECT_EQ(OH_NN_INVALID_PARAMETER, BuildSingleOpGraph(model, graphArgs));
173 
174     Free(model, nullptr, nullptr);
175 }
176 
177 /**
178  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_Finish_01
179  * @tc.desc: 模型构图,未添加操作数
180  * @tc.type: FUNC
181  */
182 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_Finish_01, Function | MediumTest | Level2)
183 {
184     OH_NNModel *model = OH_NNModel_Construct();
185     EXPECT_NE(nullptr, model);
186 
187     OHNNGraphArgs graphArgs;
188     EXPECT_EQ(OH_NN_INVALID_PARAMETER, SingleModelBuildEndStep(model, graphArgs));
189 
190     Free(model, nullptr, nullptr);
191 }
192 
193 /**
194  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_Finish_02
195  * @tc.desc: 模型构图,未设置输入输出
196  * @tc.type: FUNC
197  */
198 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_Finish_02, Function | MediumTest | Level2)
199 {
200     OH_NNModel *model = OH_NNModel_Construct();
201     EXPECT_NE(nullptr, model);
202 
203     LogicalOrModel1 logicalOrModel;
204     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
205     graphArgs.specifyIO = false;
206     EXPECT_EQ(OH_NN_OPERATION_FORBIDDEN, BuildSingleOpGraph(model, graphArgs));
207 
208     Free(model, nullptr, nullptr);
209 }
210 
211 /**
212  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_Finish_03
213  * @tc.desc: 模型构图,设置输入输出,构图成功
214  * @tc.type: FUNC
215  */
216 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_Finish_03, Function | MediumTest | Level1)
217 {
218     OH_NNModel *model = OH_NNModel_Construct();
219     EXPECT_NE(nullptr, model);
220 
221     LogicalOrModel1 logicalOrModel;
222     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
223     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
224 
225     Free(model, nullptr, nullptr);
226 }
227 
228 /**
229  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_SetOperandValue_01
230  * @tc.desc: 设置操作数值,操作数不存在
231  * @tc.type: FUNC
232  */
233 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_SetOperandValue_01, Function | MediumTest | Level2)
234 {
235     OH_NNModel *model = OH_NNModel_Construct();
236     EXPECT_NE(nullptr, model);
237 
238     LogicalOrModel1 logicalOrModel;
239     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
240 
241     NN_TensorDesc* tensorDesc = nullptr;
242     std::vector<NN_TensorDesc*> tensorDescVec;
243 
244     for (size_t i = 0; i < graphArgs.operands.size(); i++) {
245         const OHNNOperandTest &operandTem = graphArgs.operands[i];
246         tensorDesc = createTensorDesc(operandTem.shape.data(),
247                                       (uint32_t) operandTem.shape.size(),
248                                       operandTem.dataType, operandTem.format);
249         tensorDescVec.emplace_back(tensorDesc);
250         EXPECT_EQ(OH_NN_SUCCESS, OH_NNModel_AddTensorToModel(model, tensorDesc));
251         EXPECT_EQ(OH_NN_SUCCESS, OH_NNModel_SetTensorType(model, i, operandTem.type));
252 
253         if (std::find(graphArgs.paramIndices.begin(), graphArgs.paramIndices.end(), i) !=
254             graphArgs.paramIndices.end()) {
255             EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SetTensorData(
256                 model, 1000+i, operandTem.data, operandTem.length));
257         }
258     }
259 
260     FreeTensorDescVec(tensorDescVec);
261     Free(model, nullptr, nullptr);
262 }
263 
264 /**
265  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_SetOperandValue_02
266  * @tc.desc: 设置操作数值,buufer为nullptr
267  * @tc.type: FUNC
268  */
269 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_SetOperandValue_02, Function | MediumTest | Level2)
270 {
271     OH_NNModel *model = OH_NNModel_Construct();
272     EXPECT_NE(nullptr, model);
273 
274     LogicalOrModel1 logicalOrModel;
275     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
276 
277     NN_TensorDesc* tensorDesc = nullptr;
278     std::vector<NN_TensorDesc*> tensorDescVec;
279 
280     for (size_t i = 0; i < graphArgs.operands.size(); i++) {
281         const OHNNOperandTest &operandTem = graphArgs.operands[i];
282         tensorDesc = createTensorDesc(operandTem.shape.data(),
283                                       (uint32_t) operandTem.shape.size(),
284                                       operandTem.dataType, operandTem.format);
285         tensorDescVec.emplace_back(tensorDesc);
286         EXPECT_EQ(OH_NN_SUCCESS, OH_NNModel_AddTensorToModel(model, tensorDesc));
287         EXPECT_EQ(OH_NN_SUCCESS, OH_NNModel_SetTensorType(model, i, operandTem.type));
288 
289         if (std::find(graphArgs.paramIndices.begin(), graphArgs.paramIndices.end(), i) !=
290             graphArgs.paramIndices.end()) {
291             EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SetTensorData(model, i, nullptr, operandTem.length));
292         }
293     }
294 
295     FreeTensorDescVec(tensorDescVec);
296     Free(model, nullptr, nullptr);
297 }
298 
299 /**
300  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_SetOperandValue_03
301  * @tc.desc: 设置操作数值,length为0
302  * @tc.type: FUNC
303  */
304 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_SetOperandValue_03, Function | MediumTest | Level2)
305 {
306     OH_NNModel *model = OH_NNModel_Construct();
307     EXPECT_NE(nullptr, model);
308 
309     LogicalOrModel1 logicalOrModel;
310     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
311 
312     NN_TensorDesc* tensorDesc = nullptr;
313     std::vector<NN_TensorDesc*> tensorDescVec;
314 
315     for (size_t i = 0; i < graphArgs.operands.size(); i++) {
316         const OHNNOperandTest &operandTem = graphArgs.operands[i];
317         tensorDesc = createTensorDesc(operandTem.shape.data(),
318                                       (uint32_t) operandTem.shape.size(),
319                                       operandTem.dataType, operandTem.format);
320         tensorDescVec.emplace_back(tensorDesc);
321         EXPECT_EQ(OH_NN_SUCCESS, OH_NNModel_AddTensorToModel(model, tensorDesc));
322         EXPECT_EQ(OH_NN_SUCCESS, OH_NNModel_SetTensorType(model, i, operandTem.type));
323 
324         if (std::find(graphArgs.paramIndices.begin(), graphArgs.paramIndices.end(), i) !=
325             graphArgs.paramIndices.end()) {
326             EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SetTensorData(model, 1000+i, operandTem.data, 0));
327         }
328     }
329 
330     FreeTensorDescVec(tensorDescVec);
331     Free(model, nullptr, nullptr);
332 }
333 
334 /**
335  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_SpecifyInputsAndOutputs_01
336  * @tc.desc: 设置输入输出,inputIndices为nullptr
337  * @tc.type: FUNC
338  */
339 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_SpecifyInputsAndOutputs_01,
340          Function | MediumTest | Level2)
341 {
342     OH_NNModel *model = OH_NNModel_Construct();
343     EXPECT_NE(nullptr, model);
344 
345     LogicalOrModel1 logicalOrModel;
346     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
347     graphArgs.specifyIO = false;
348     graphArgs.build = false;
349     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
350 
351     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
352     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
353     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SpecifyInputsAndOutputs(model, nullptr, &outputIndices));
354 
355     Free(model, nullptr, nullptr);
356 }
357 
358 /**
359  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_SpecifyInputsAndOutputs_02
360  * @tc.desc: 设置输入输出,inputindices中data为nullptr
361  * @tc.type: FUNC
362  */
363 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_SpecifyInputsAndOutputs_02,
364          Function | MediumTest | Level2)
365 {
366     OH_NNModel *model = OH_NNModel_Construct();
367     EXPECT_NE(nullptr, model);
368 
369     LogicalOrModel1 logicalOrModel;
370     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
371     graphArgs.specifyIO = false;
372     graphArgs.build = false;
373     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
374 
375     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
376     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
377     inputIndices.data = nullptr;
378     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SpecifyInputsAndOutputs(model, &inputIndices, &outputIndices));
379 
380     Free(model, nullptr, nullptr);
381 }
382 
383 /**
384  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_SpecifyInputsAndOutputs_03
385  * @tc.desc: 设置输入输出,inputindices中data对应序号不存在
386  * @tc.type: FUNC
387  */
388 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_SpecifyInputsAndOutputs_03,
389          Function | MediumTest | Level2)
390 {
391     OH_NNModel *model = OH_NNModel_Construct();
392     EXPECT_NE(nullptr, model);
393 
394     LogicalOrModel1 logicalOrModel;
395     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
396     graphArgs.specifyIO = false;
397     graphArgs.build = false;
398     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
399 
400     graphArgs.inputIndices = {100000};
401     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
402     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
403     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SpecifyInputsAndOutputs(model, &inputIndices, &outputIndices));
404 
405     Free(model, nullptr, nullptr);
406 }
407 
408 /**
409  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_SpecifyInputsAndOutputs_04
410  * @tc.desc: 设置输入输出,inputindices中size为0
411  * @tc.type: FUNC
412  */
413 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_SpecifyInputsAndOutputs_04,
414          Function | MediumTest | Level2)
415 {
416     OH_NNModel *model = OH_NNModel_Construct();
417     EXPECT_NE(nullptr, model);
418 
419     LogicalOrModel1 logicalOrModel;
420     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
421     graphArgs.specifyIO = false;
422     graphArgs.build = false;
423     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
424 
425     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
426     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
427     inputIndices.size = 0;
428     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SpecifyInputsAndOutputs(model, &inputIndices, &outputIndices));
429 
430     Free(model, nullptr, nullptr);
431 }
432 
433 /**
434  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_SpecifyInputsAndOutputs_05
435  * @tc.desc: 设置输入输出,outputindices为nullptr
436  * @tc.type: FUNC
437  */
438 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_SpecifyInputsAndOutputs_05,
439          Function | MediumTest | Level2)
440 {
441     OH_NNModel *model = OH_NNModel_Construct();
442     EXPECT_NE(nullptr, model);
443 
444     LogicalOrModel1 logicalOrModel;
445     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
446     graphArgs.specifyIO = false;
447     graphArgs.build = false;
448     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
449 
450     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
451     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
452     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SpecifyInputsAndOutputs(model, &inputIndices, nullptr));
453 
454     Free(model, nullptr, nullptr);
455 }
456 
457 /**
458  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_SpecifyInputsAndOutputs_06
459  * @tc.desc: 设置输入输出,outputindices中data为nullptr
460  * @tc.type: FUNC
461  */
462 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_SpecifyInputsAndOutputs_06,
463          Function | MediumTest | Level2)
464 {
465     OH_NNModel *model = OH_NNModel_Construct();
466     EXPECT_NE(nullptr, model);
467 
468     LogicalOrModel1 logicalOrModel;
469     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
470     graphArgs.specifyIO = false;
471     graphArgs.build = false;
472     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
473 
474     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
475     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
476     outputIndices.data = nullptr;
477     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SpecifyInputsAndOutputs(model, &inputIndices, &outputIndices));
478 
479     Free(model, nullptr, nullptr);
480 }
481 
482 /**
483  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_SpecifyInputsAndOutputs_07
484  * @tc.desc: 设置输入输出,outputindices中data对应序号不存在
485  * @tc.type: FUNC
486  */
487 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_SpecifyInputsAndOutputs_07,
488          Function | MediumTest | Level2)
489 {
490     OH_NNModel *model = OH_NNModel_Construct();
491     EXPECT_NE(nullptr, model);
492 
493     LogicalOrModel1 logicalOrModel;
494     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
495     graphArgs.specifyIO = false;
496     graphArgs.build = false;
497     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
498 
499     graphArgs.outputIndices = {100000};
500     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
501     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
502     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SpecifyInputsAndOutputs(model, &inputIndices, &outputIndices));
503 
504     Free(model, nullptr, nullptr);
505 }
506 
507 /**
508  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_SpecifyInputsAndOutputs_08
509  * @tc.desc: 设置输入输出,outputindices中size为0
510  * @tc.type: FUNC
511  */
512 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_SpecifyInputsAndOutputs_08,
513          Function | MediumTest | Level2)
514 {
515     OH_NNModel *model = OH_NNModel_Construct();
516     EXPECT_NE(nullptr, model);
517 
518     LogicalOrModel1 logicalOrModel;
519     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
520     graphArgs.specifyIO = false;
521     graphArgs.build = false;
522     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
523 
524     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
525     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
526     outputIndices.size = 0;
527     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SpecifyInputsAndOutputs(model, &inputIndices, &outputIndices));
528 
529     Free(model, nullptr, nullptr);
530 }
531 
532 /**
533  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_01
534  * @tc.desc: 添加算子,paramindices为nullptr
535  * @tc.type: FUNC
536  */
537 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_01, Function | MediumTest | Level2)
538 {
539     OH_NNModel *model = OH_NNModel_Construct();
540     EXPECT_NE(nullptr, model);
541 
542     LogicalOrModel1 logicalOrModel;
543     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
544     graphArgs.addOperation = false;
545     graphArgs.specifyIO = false;
546     graphArgs.build = false;
547     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
548 
549     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
550     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
551     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_AddOperation(model, graphArgs.operationType,
552                                                                nullptr, &inputIndices, &outputIndices));
553 
554     Free(model, nullptr, nullptr);
555 }
556 
557 /**
558  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_02
559  * @tc.desc: 添加算子,paramindices中data为nullptr
560  * @tc.type: FUNC
561  */
562 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_02, Function | MediumTest | Level2)
563 {
564     OH_NNModel *model = OH_NNModel_Construct();
565     EXPECT_NE(nullptr, model);
566 
567     LogicalOrModel1 logicalOrModel;
568     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
569     graphArgs.addOperation = false;
570     graphArgs.specifyIO = false;
571     graphArgs.build = false;
572     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
573 
574     auto paramIndices = TransformUInt32Array(graphArgs.paramIndices);
575     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
576     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
577     paramIndices.data = nullptr;
578     EXPECT_EQ(OH_NN_SUCCESS, OH_NNModel_AddOperation(model, graphArgs.operationType,
579                                                      &paramIndices, &inputIndices, &outputIndices));
580 
581     Free(model, nullptr, nullptr);
582 }
583 
584 /**
585  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_03
586  * @tc.desc: 添加算子,paramindices中data对应序号不存在
587  * @tc.type: FUNC
588  */
589 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_03, Function | MediumTest | Level2)
590 {
591     OH_NNModel *model = OH_NNModel_Construct();
592     EXPECT_NE(nullptr, model);
593 
594     LogicalOrModel1 logicalOrModel;
595     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
596     graphArgs.addOperation = false;
597     graphArgs.specifyIO = false;
598     graphArgs.build = false;
599     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
600 
601     graphArgs.paramIndices = {100000};
602     auto paramIndices = TransformUInt32Array(graphArgs.paramIndices);
603     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
604     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
605     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_AddOperation(model, graphArgs.operationType,
606                                                                &paramIndices, &inputIndices, &outputIndices));
607 
608     Free(model, nullptr, nullptr);
609 }
610 
611 /**
612  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_04
613  * @tc.desc: 添加算子,paramindices中size为0
614  * @tc.type: FUNC
615  */
616 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_04, Function | MediumTest | Level2)
617 {
618     OH_NNModel *model = OH_NNModel_Construct();
619     EXPECT_NE(nullptr, model);
620 
621     LogicalOrModel1 logicalOrModel;
622     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
623     graphArgs.addOperation = false;
624     graphArgs.specifyIO = false;
625     graphArgs.build = false;
626     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
627 
628     auto paramIndices = TransformUInt32Array(graphArgs.paramIndices);
629     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
630     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
631     paramIndices.size = 0;
632     EXPECT_EQ(OH_NN_SUCCESS, OH_NNModel_AddOperation(model, graphArgs.operationType,
633                                                      &paramIndices, &inputIndices, &outputIndices));
634 
635     Free(model, nullptr, nullptr);
636 }
637 
638 /**
639  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_05
640  * @tc.desc: 添加算子,inputindices为nullptr
641  * @tc.type: FUNC
642  */
643 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_05, Function | MediumTest | Level2)
644 {
645     OH_NNModel *model = OH_NNModel_Construct();
646     EXPECT_NE(nullptr, model);
647 
648     LogicalOrModel1 logicalOrModel;
649     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
650     graphArgs.addOperation = false;
651     graphArgs.specifyIO = false;
652     graphArgs.build = false;
653     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
654 
655     auto paramIndices = TransformUInt32Array(graphArgs.paramIndices);
656     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
657     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_AddOperation(model, graphArgs.operationType,
658                                                                &paramIndices, nullptr, &outputIndices));
659 
660     Free(model, nullptr, nullptr);
661 }
662 
663 /**
664  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_06
665  * @tc.desc: 添加算子,inputindices中data为nullptr
666  * @tc.type: FUNC
667  */
668 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_06, Function | MediumTest | Level2)
669 {
670     OH_NNModel *model = OH_NNModel_Construct();
671     EXPECT_NE(nullptr, model);
672 
673     LogicalOrModel1 logicalOrModel;
674     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
675     graphArgs.addOperation = false;
676     graphArgs.specifyIO = false;
677     graphArgs.build = false;
678     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
679 
680     auto paramIndices = TransformUInt32Array(graphArgs.paramIndices);
681     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
682     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
683     inputIndices.data = nullptr;
684     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_AddOperation(model, graphArgs.operationType,
685                                                                &paramIndices, &inputIndices, &outputIndices));
686 
687     Free(model, nullptr, nullptr);
688 }
689 
690 /**
691  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_07
692  * @tc.desc: 添加算子,inputindices中data对应序号不存在
693  * @tc.type: FUNC
694  */
695 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_07, Function | MediumTest | Level2)
696 {
697     OH_NNModel *model = OH_NNModel_Construct();
698     EXPECT_NE(nullptr, model);
699 
700     LogicalOrModel1 logicalOrModel;
701     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
702     graphArgs.addOperation = false;
703     graphArgs.specifyIO = false;
704     graphArgs.build = false;
705     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
706 
707     graphArgs.inputIndices = {100000};
708     auto paramIndices = TransformUInt32Array(graphArgs.paramIndices);
709     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
710     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
711     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_AddOperation(model, graphArgs.operationType,
712                                                                &paramIndices, &inputIndices, &outputIndices));
713 
714     Free(model, nullptr, nullptr);
715 }
716 
717 /**
718  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_08
719  * @tc.desc: 添加算子,inputindices中size为0
720  * @tc.type: FUNC
721  */
722 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_08, Function | MediumTest | Level2)
723 {
724     OH_NNModel *model = OH_NNModel_Construct();
725     EXPECT_NE(nullptr, model);
726 
727     LogicalOrModel1 logicalOrModel;
728     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
729     graphArgs.addOperation = false;
730     graphArgs.specifyIO = false;
731     graphArgs.build = false;
732     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
733 
734     auto paramIndices = TransformUInt32Array(graphArgs.paramIndices);
735     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
736     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
737     inputIndices.size = 0;
738     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_AddOperation(model, graphArgs.operationType,
739                                                                &paramIndices, &inputIndices, &outputIndices));
740 
741     Free(model, nullptr, nullptr);
742 }
743 
744 /**
745  * @tc.number : SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_09
746  * @tc.desc: 添加算子,outputindices为nullptr
747  * @tc.type: FUNC
748  */
749 HWTEST_F(LogicalOrTest, SUB_AI_NNRt_Func_North_LogicalOr_Model_AddOperation_09, Function | MediumTest | Level2)
750 {
751     OH_NNModel *model = OH_NNModel_Construct();
752     EXPECT_NE(nullptr, model);
753 
754     LogicalOrModel1 logicalOrModel;
755     OHNNGraphArgs graphArgs = logicalOrModel.graphArgs;
756     graphArgs.addOperation = false;
757     graphArgs.specifyIO = false;
758     graphArgs.build = false;
759     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
760 
761     auto paramIndices = TransformUInt32Array(graphArgs.paramIndices);
762     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
763     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_AddOperation(nullptr, graphArgs.operationType,
764                                                                &paramIndices, &inputIndices, nullptr));
765 
766     Free(model, nullptr, nullptr);
767 }