• 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 ReduceL2Test : public testing::Test {};
24 
25 struct ReduceL2Model1 {
26     const std::vector<int32_t> input_shape = {2, 2};
27     const std::vector<int32_t> output_shape = {2, 2};
28 
29     bool keepDimsValue[1] = {false};
30     bool reduceToEndValue[1] = {false};
31     float coeffValue[1] = {1};
32     float inputValue[2][2] = {{1, 2}, {3, 4}};
33     float axisValue[1] = {0};
34     float outputValue[2][2] = {0};
35 
36     OHNNOperandTest input = {OH_NN_FLOAT32, OH_NN_TENSOR, input_shape, inputValue, 4*sizeof(float)};
37     OHNNOperandTest axis = {OH_NN_FLOAT32, OH_NN_TENSOR, {1}, axisValue, sizeof(float)};
38     OHNNOperandTest output = {OH_NN_FLOAT32, OH_NN_TENSOR, output_shape, outputValue, 4*sizeof(float)};
39     OHNNOperandTest keepDims = {OH_NN_BOOL, OH_NN_REDUCE_L2_KEEP_DIMS, {1}, keepDimsValue, sizeof(bool)};
40     OHNNOperandTest reduceToEnd = {OH_NN_BOOL, OH_NN_REDUCE_L2_REDUCE_TO_END, {1}, reduceToEndValue, sizeof(bool)};
41     OHNNOperandTest coeff = {OH_NN_FLOAT32, OH_NN_REDUCE_L2_COEFF, {1}, coeffValue, sizeof(float)};
42     OHNNGraphArgs graphArgs = {.operationType = OH_NN_OPS_REDUCE_L2,
43                                .operands = {input, axis, output, keepDims, reduceToEnd, coeff},
44                                .paramIndices = {3, 4, 5},
45                                .inputIndices = {0, 1},
46                                .outputIndices = {2}};
47 };
48 
49 struct ReduceL2Model2 {
50     const std::vector<int32_t> input_shape = {2, 2};
51     const std::vector<int32_t> output_shape = {1, 2};
52 
53     bool keepDimsValue[1] = {true};
54     bool reduceToEndValue[1] = {false};
55     float coeffValue[1] = {1};
56     float inputValue[2][2] = {{1, 2}, {3, 4}};
57     float axisValue[1] = {1};
58     float outputValue[1][2] = {0};
59 
60     OHNNOperandTest input = {OH_NN_FLOAT32, OH_NN_TENSOR, input_shape, inputValue, 4*sizeof(float)};
61     OHNNOperandTest axis = {OH_NN_FLOAT32, OH_NN_TENSOR, {1}, axisValue, sizeof(float)};
62     OHNNOperandTest output = {OH_NN_FLOAT32, OH_NN_TENSOR, output_shape, outputValue, 2*sizeof(float)};
63     OHNNOperandTest keepDims = {OH_NN_BOOL, OH_NN_REDUCE_L2_KEEP_DIMS, {1}, keepDimsValue, sizeof(bool)};
64     OHNNOperandTest reduceToEnd = {OH_NN_BOOL, OH_NN_REDUCE_L2_REDUCE_TO_END, {1}, reduceToEndValue, sizeof(bool)};
65     OHNNOperandTest coeff = {OH_NN_FLOAT32, OH_NN_REDUCE_L2_COEFF, {1}, coeffValue, sizeof(float)};
66     OHNNGraphArgs graphArgs = {.operationType = OH_NN_OPS_REDUCE_L2,
67                                .operands = {input, axis, output, keepDims, reduceToEnd, coeff},
68                                .paramIndices = {3, 4, 5},
69                                .inputIndices = {0, 1},
70                                .outputIndices = {2}};
71 };
72 
73 struct ReduceL2Model3 {
74     const std::vector<int32_t> input_shape = {2, 2, 2};
75     const std::vector<int32_t> output_shape = {2, 2};
76 
77     bool keepDimsValue[1] = {false};
78     bool reduceToEndValue[1] = {false};
79     float coeffValue[1] = {1};
80     float inputValue[2][2][2] = {{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}};
81     float axisValue[2] = {0, 1};
82     float outputValue[2][2] = {0};
83 
84     OHNNOperandTest input = {OH_NN_FLOAT32, OH_NN_TENSOR, input_shape, inputValue, 8*sizeof(float)};
85     OHNNOperandTest axis = {OH_NN_FLOAT32, OH_NN_TENSOR, {2}, axisValue, 2*sizeof(float)};
86     OHNNOperandTest output = {OH_NN_FLOAT32, OH_NN_TENSOR, output_shape, outputValue, 4*sizeof(float)};
87     OHNNOperandTest keepDims = {OH_NN_BOOL, OH_NN_REDUCE_L2_KEEP_DIMS, {1}, keepDimsValue, sizeof(bool)};
88     OHNNOperandTest reduceToEnd = {OH_NN_BOOL, OH_NN_REDUCE_L2_REDUCE_TO_END, {1}, reduceToEndValue, sizeof(bool)};
89     OHNNOperandTest coeff = {OH_NN_FLOAT32, OH_NN_REDUCE_L2_COEFF, {1}, coeffValue, sizeof(float)};
90     OHNNGraphArgs graphArgs = {.operationType = OH_NN_OPS_REDUCE_L2,
91                                .operands = {input, axis, output, keepDims, reduceToEnd, coeff},
92                                .paramIndices = {3, 4, 5},
93                                .inputIndices = {0, 1},
94                                .outputIndices = {2}};
95 };
96 
97 struct ReduceL2Model4 {
98     const std::vector<int32_t> input_shape = {2, 2, 2};
99     const std::vector<int32_t> output_shape = {2, 2};
100 
101     bool keepDimsValue[1] = {true};
102     bool reduceToEndValue[1] = {true};
103     float coeffValue[1] = {1};
104     float inputValue[2][2][2] = {{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}};
105     float axisValue[1] = {0};
106     float outputValue[1][2] = {0};
107 
108     OHNNOperandTest input = {OH_NN_FLOAT32, OH_NN_TENSOR, input_shape, inputValue, 8*sizeof(float)};
109     OHNNOperandTest axis = {OH_NN_FLOAT32, OH_NN_TENSOR, {1}, axisValue, sizeof(float)};
110     OHNNOperandTest output = {OH_NN_FLOAT32, OH_NN_TENSOR, output_shape, outputValue, 2*sizeof(float)};
111     OHNNOperandTest keepDims = {OH_NN_BOOL, OH_NN_REDUCE_L2_KEEP_DIMS, {1}, keepDimsValue, sizeof(bool)};
112     OHNNOperandTest reduceToEnd = {OH_NN_BOOL, OH_NN_REDUCE_L2_REDUCE_TO_END, {1}, reduceToEndValue, sizeof(bool)};
113     OHNNOperandTest coeff = {OH_NN_FLOAT32, OH_NN_REDUCE_L2_COEFF, {1}, coeffValue, sizeof(float)};
114     OHNNGraphArgs graphArgs = {.operationType = OH_NN_OPS_REDUCE_L2,
115                                .operands = {input, axis, output, keepDims, reduceToEnd, coeff},
116                                .paramIndices = {3, 4, 5},
117                                .inputIndices = {0, 1},
118                                .outputIndices = {2}};
119 };
120 
121 struct ReduceL2Model5 {
122     const std::vector<int32_t> input_shape = {2, 2, 2};
123     const std::vector<int32_t> output_shape = {2, 2};
124 
125     bool keepDimsValue[1] = {false};
126     bool reduceToEndValue[1] = {true};
127     float coeffValue[1] = {2};
128     float inputValue[2][2][2] = {{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}};
129     float axisValue[2] = {0, 1};
130     float outputValue[2] = {0};
131 
132     OHNNOperandTest input = {OH_NN_FLOAT32, OH_NN_TENSOR, input_shape, inputValue, 8*sizeof(float)};
133     OHNNOperandTest axis = {OH_NN_FLOAT32, OH_NN_TENSOR, {2}, axisValue, 2*sizeof(float)};
134     OHNNOperandTest output = {OH_NN_FLOAT32, OH_NN_TENSOR, output_shape, outputValue, 2*sizeof(float)};
135     OHNNOperandTest keepDims = {OH_NN_BOOL, OH_NN_REDUCE_L2_KEEP_DIMS, {1}, keepDimsValue, sizeof(bool)};
136     OHNNOperandTest reduceToEnd = {OH_NN_BOOL, OH_NN_REDUCE_L2_REDUCE_TO_END, {1}, reduceToEndValue, sizeof(bool)};
137     OHNNOperandTest coeff = {OH_NN_FLOAT32, OH_NN_REDUCE_L2_COEFF, {1}, coeffValue, sizeof(float)};
138     OHNNGraphArgs graphArgs = {.operationType = OH_NN_OPS_REDUCE_L2,
139                                .operands = {input, axis, output, keepDims, reduceToEnd, coeff},
140                                .paramIndices = {3, 4, 5},
141                                .inputIndices = {0, 1},
142                                .outputIndices = {2}};
143 };
144 
145 /**
146  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Build_01
147  * @tc.desc: ReduceL2Model1模型build测试
148  * @tc.type: FUNC
149  */
150 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Build_01, Function | MediumTest | Level1)
151 {
152     OH_NNModel *model = OH_NNModel_Construct();
153     EXPECT_NE(nullptr, model);
154 
155     ReduceL2Model1 reduceL2Model;
156     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
157     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
158 
159     OH_NNCompilation *compilation = OH_NNCompilation_Construct(model);
160     EXPECT_NE(nullptr, compilation);
161 
162     OHNNCompileParam compileParam{
163         .performanceMode = OH_NN_PERFORMANCE_HIGH,
164         .priority = OH_NN_PRIORITY_HIGH,
165     };
166     EXPECT_EQ(OH_NN_SUCCESS, CompileGraphMock(compilation, compileParam));
167 
168     OH_NNExecutor *executor = OH_NNExecutor_Construct(compilation);
169     EXPECT_NE(nullptr, executor);
170 
171     Free(model, compilation, executor);
172 }
173 
174 /**
175  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Build_02
176  * @tc.desc: ReduceL2Model2模型build测试
177  * @tc.type: FUNC
178  */
179 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Build_02, Function | MediumTest | Level1)
180 {
181     OH_NNModel *model = OH_NNModel_Construct();
182     EXPECT_NE(nullptr, model);
183 
184     ReduceL2Model2 reduceL2Model;
185     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
186     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
187 
188     OH_NNCompilation *compilation = OH_NNCompilation_Construct(model);
189     EXPECT_NE(nullptr, compilation);
190 
191     OHNNCompileParam compileParam{
192         .performanceMode = OH_NN_PERFORMANCE_HIGH,
193         .priority = OH_NN_PRIORITY_HIGH,
194     };
195     EXPECT_EQ(OH_NN_SUCCESS, CompileGraphMock(compilation, compileParam));
196 
197     OH_NNExecutor *executor = OH_NNExecutor_Construct(compilation);
198     EXPECT_NE(nullptr, executor);
199 
200     Free(model, compilation, executor);
201 }
202 
203 /**
204  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Build_03
205  * @tc.desc: ReduceL2Model3模型build测试
206  * @tc.type: FUNC
207  */
208 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Build_03, Function | MediumTest | Level1)
209 {
210     OH_NNModel *model = OH_NNModel_Construct();
211     EXPECT_NE(nullptr, model);
212 
213     ReduceL2Model3 reduceL2Model;
214     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
215     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
216 
217     OH_NNCompilation *compilation = OH_NNCompilation_Construct(model);
218     EXPECT_NE(nullptr, compilation);
219 
220     OHNNCompileParam compileParam{
221         .performanceMode = OH_NN_PERFORMANCE_HIGH,
222         .priority = OH_NN_PRIORITY_HIGH,
223     };
224     EXPECT_EQ(OH_NN_SUCCESS, CompileGraphMock(compilation, compileParam));
225 
226     OH_NNExecutor *executor = OH_NNExecutor_Construct(compilation);
227     EXPECT_NE(nullptr, executor);
228 
229     Free(model, compilation, executor);
230 }
231 
232 /**
233  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Build_04
234  * @tc.desc: ReduceL2Model4模型build测试
235  * @tc.type: FUNC
236  */
237 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Build_04, Function | MediumTest | Level1)
238 {
239     OH_NNModel *model = OH_NNModel_Construct();
240     EXPECT_NE(nullptr, model);
241 
242     ReduceL2Model4 reduceL2Model;
243     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
244     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
245 
246     OH_NNCompilation *compilation = OH_NNCompilation_Construct(model);
247     EXPECT_NE(nullptr, compilation);
248 
249     OHNNCompileParam compileParam{
250         .performanceMode = OH_NN_PERFORMANCE_HIGH,
251         .priority = OH_NN_PRIORITY_HIGH,
252     };
253     EXPECT_EQ(OH_NN_SUCCESS, CompileGraphMock(compilation, compileParam));
254 
255     OH_NNExecutor *executor = OH_NNExecutor_Construct(compilation);
256     EXPECT_NE(nullptr, executor);
257 
258     Free(model, compilation, executor);
259 }
260 
261 /**
262  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Build_05
263  * @tc.desc: ReduceL2Model5模型build测试
264  * @tc.type: FUNC
265  */
266 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Build_05, Function | MediumTest | Level1)
267 {
268     OH_NNModel *model = OH_NNModel_Construct();
269     EXPECT_NE(nullptr, model);
270 
271     ReduceL2Model5 reduceL2Model;
272     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
273     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
274 
275     OH_NNCompilation *compilation = OH_NNCompilation_Construct(model);
276     EXPECT_NE(nullptr, compilation);
277 
278     OHNNCompileParam compileParam{
279         .performanceMode = OH_NN_PERFORMANCE_HIGH,
280         .priority = OH_NN_PRIORITY_HIGH,
281     };
282     EXPECT_EQ(OH_NN_SUCCESS, CompileGraphMock(compilation, compileParam));
283 
284     OH_NNExecutor *executor = OH_NNExecutor_Construct(compilation);
285     EXPECT_NE(nullptr, executor);
286 
287     Free(model, compilation, executor);
288 }
289 
290 /**
291  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Build_06
292  * @tc.desc: ReduceL2Model1模型输入Tensor+1进行build测试
293  * @tc.type: FUNC
294  */
295 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Build_06, Function | MediumTest | Level2)
296 {
297     OH_NNModel *model = OH_NNModel_Construct();
298     EXPECT_NE(nullptr, model);
299 
300     ReduceL2Model1 reduceL2Model;
301     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
302     graphArgs.operands = {reduceL2Model.input, reduceL2Model.input, reduceL2Model.axis, reduceL2Model.output,
303                           reduceL2Model.keepDims, reduceL2Model.reduceToEnd, reduceL2Model.coeff};
304     graphArgs.inputIndices = {0, 1, 2};
305     graphArgs.outputIndices = {3};
306     graphArgs.paramIndices = {4, 5, 6};
307     EXPECT_EQ(OH_NN_INVALID_PARAMETER, BuildSingleOpGraph(model, graphArgs));
308 
309     Free(model, nullptr, nullptr);
310 }
311 
312 /**
313  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Build_07
314  * @tc.desc: ReduceL2Model1模型输出Tensor+1进行build测试
315  * @tc.type: FUNC
316  */
317 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Build_07, Function | MediumTest | Level2)
318 {
319     OH_NNModel *model = OH_NNModel_Construct();
320     EXPECT_NE(nullptr, model);
321 
322     ReduceL2Model1 reduceL2Model;
323     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
324     graphArgs.operands = {reduceL2Model.input, reduceL2Model.axis, reduceL2Model.output, reduceL2Model.output,
325                           reduceL2Model.keepDims, reduceL2Model.reduceToEnd, reduceL2Model.coeff};
326     graphArgs.inputIndices = {0, 1};
327     graphArgs.outputIndices = {2, 3};
328     graphArgs.paramIndices = {4, 5, 6};
329     EXPECT_EQ(OH_NN_INVALID_PARAMETER, BuildSingleOpGraph(model, graphArgs));
330 
331     Free(model, nullptr, nullptr);
332 }
333 
334 /**
335  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Build_08
336  * @tc.desc: ReduceL2Model1模型传入非法参数进行build测试
337  * @tc.type: FUNC
338  */
339 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Build_08, Function | MediumTest | Level2)
340 {
341     OH_NNModel *model = OH_NNModel_Construct();
342     EXPECT_NE(nullptr, model);
343 
344     ReduceL2Model1 reduceL2Model;
345     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
346 
347     int8_t activationValue = OH_NN_FUSED_NONE;
348     OHNNOperandTest activation = {OH_NN_INT8, OH_NN_ADD_ACTIVATIONTYPE, {}, &activationValue, sizeof(int8_t)};
349     graphArgs.operands = {reduceL2Model.input, reduceL2Model.axis, reduceL2Model.output, activation,
350                           reduceL2Model.keepDims, reduceL2Model.reduceToEnd, reduceL2Model.coeff};
351     graphArgs.paramIndices = {3, 4, 5, 6};
352     EXPECT_EQ(OH_NN_INVALID_PARAMETER, BuildSingleOpGraph(model, graphArgs));
353 
354     Free(model, nullptr, nullptr);
355 }
356 
357 /**
358  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_Finish_01
359  * @tc.desc: 模型构图,未添加操作数
360  * @tc.type: FUNC
361  */
362 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_Finish_01, Function | MediumTest | Level2)
363 {
364     OH_NNModel *model = OH_NNModel_Construct();
365     EXPECT_NE(nullptr, model);
366 
367     OHNNGraphArgs graphArgs;
368     EXPECT_EQ(OH_NN_INVALID_PARAMETER, SingleModelBuildEndStep(model, graphArgs));
369 
370     Free(model, nullptr, nullptr);
371 }
372 
373 /**
374  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_Finish_02
375  * @tc.desc: 模型构图,未设置输入输出
376  * @tc.type: FUNC
377  */
378 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_Finish_02, Function | MediumTest | Level2)
379 {
380     OH_NNModel *model = OH_NNModel_Construct();
381     EXPECT_NE(nullptr, model);
382 
383     ReduceL2Model1 reduceL2Model;
384     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
385     graphArgs.specifyIO = false;
386     EXPECT_EQ(OH_NN_OPERATION_FORBIDDEN, BuildSingleOpGraph(model, graphArgs));
387 
388     Free(model, nullptr, nullptr);
389 }
390 
391 /**
392  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_Finish_03
393  * @tc.desc: 模型构图,设置输入输出,构图成功
394  * @tc.type: FUNC
395  */
396 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_Finish_03, Function | MediumTest | Level1)
397 {
398     OH_NNModel *model = OH_NNModel_Construct();
399     EXPECT_NE(nullptr, model);
400 
401     ReduceL2Model1 reduceL2Model;
402     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
403     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
404 
405     Free(model, nullptr, nullptr);
406 }
407 
408 /**
409  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_SetOperandValue_01
410  * @tc.desc: 设置操作数值,操作数不存在
411  * @tc.type: FUNC
412  */
413 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_SetOperandValue_01, Function | MediumTest | Level2)
414 {
415     OH_NNModel *model = OH_NNModel_Construct();
416     EXPECT_NE(nullptr, model);
417 
418     ReduceL2Model1 reduceL2Model;
419     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
420 
421     NN_TensorDesc* tensorDesc = nullptr;
422     std::vector<NN_TensorDesc*> tensorDescVec;
423 
424     for (size_t i = 0; i < graphArgs.operands.size(); i++) {
425         const OHNNOperandTest &operandTem = graphArgs.operands[i];
426         tensorDesc = createTensorDesc(operandTem.shape.data(),
427                                       (uint32_t) operandTem.shape.size(),
428                                       operandTem.dataType, operandTem.format);
429         tensorDescVec.emplace_back(tensorDesc);
430         EXPECT_EQ(OH_NN_SUCCESS, OH_NNModel_AddTensorToModel(model, tensorDesc));
431         EXPECT_EQ(OH_NN_SUCCESS, OH_NNModel_SetTensorType(model, i, operandTem.type));
432 
433         if (std::find(graphArgs.paramIndices.begin(), graphArgs.paramIndices.end(), i) !=
434             graphArgs.paramIndices.end()) {
435             EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SetTensorData(
436                 model, 1000+i, operandTem.data, operandTem.length));
437         }
438     }
439 
440     FreeTensorDescVec(tensorDescVec);
441     Free(model, nullptr, nullptr);
442 }
443 
444 /**
445  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_SetOperandValue_02
446  * @tc.desc: 设置操作数值,buufer为nullptr
447  * @tc.type: FUNC
448  */
449 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_SetOperandValue_02, Function | MediumTest | Level2)
450 {
451     OH_NNModel *model = OH_NNModel_Construct();
452     EXPECT_NE(nullptr, model);
453 
454     ReduceL2Model1 reduceL2Model;
455     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
456 
457     NN_TensorDesc* tensorDesc = nullptr;
458     std::vector<NN_TensorDesc*> tensorDescVec;
459 
460     for (size_t i = 0; i < graphArgs.operands.size(); i++) {
461         const OHNNOperandTest &operandTem = graphArgs.operands[i];
462         tensorDesc = createTensorDesc(operandTem.shape.data(),
463                                       (uint32_t) operandTem.shape.size(),
464                                       operandTem.dataType, operandTem.format);
465         tensorDescVec.emplace_back(tensorDesc);
466         EXPECT_EQ(OH_NN_SUCCESS, OH_NNModel_AddTensorToModel(model, tensorDesc));
467         EXPECT_EQ(OH_NN_SUCCESS, OH_NNModel_SetTensorType(model, i, operandTem.type));
468 
469         if (std::find(graphArgs.paramIndices.begin(), graphArgs.paramIndices.end(), i) !=
470             graphArgs.paramIndices.end()) {
471             EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SetTensorData(model, i, nullptr, operandTem.length));
472         }
473     }
474 
475     FreeTensorDescVec(tensorDescVec);
476     Free(model, nullptr, nullptr);
477 }
478 
479 /**
480  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_SetOperandValue_03
481  * @tc.desc: 设置操作数值,length为0
482  * @tc.type: FUNC
483  */
484 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_SetOperandValue_03, Function | MediumTest | Level2)
485 {
486     OH_NNModel *model = OH_NNModel_Construct();
487     EXPECT_NE(nullptr, model);
488 
489     ReduceL2Model1 reduceL2Model;
490     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
491 
492     NN_TensorDesc* tensorDesc = nullptr;
493     std::vector<NN_TensorDesc*> tensorDescVec;
494 
495     for (size_t i = 0; i < graphArgs.operands.size(); i++) {
496         const OHNNOperandTest &operandTem = graphArgs.operands[i];
497         tensorDesc = createTensorDesc(operandTem.shape.data(),
498                                       (uint32_t) operandTem.shape.size(),
499                                       operandTem.dataType, operandTem.format);
500         tensorDescVec.emplace_back(tensorDesc);
501         EXPECT_EQ(OH_NN_SUCCESS, OH_NNModel_AddTensorToModel(model, tensorDesc));
502         EXPECT_EQ(OH_NN_SUCCESS, OH_NNModel_SetTensorType(model, i, operandTem.type));
503 
504         if (std::find(graphArgs.paramIndices.begin(), graphArgs.paramIndices.end(), i) !=
505             graphArgs.paramIndices.end()) {
506             EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SetTensorData(model, 1000+i, operandTem.data, 0));
507         }
508     }
509 
510     FreeTensorDescVec(tensorDescVec);
511     Free(model, nullptr, nullptr);
512 }
513 
514 /**
515  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_SpecifyInputsAndOutputs_01
516  * @tc.desc: 设置输入输出,inputIndices为nullptr
517  * @tc.type: FUNC
518  */
519 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_SpecifyInputsAndOutputs_01,
520          Function | MediumTest | Level2)
521 {
522     OH_NNModel *model = OH_NNModel_Construct();
523     EXPECT_NE(nullptr, model);
524 
525     ReduceL2Model1 reduceL2Model;
526     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
527     graphArgs.specifyIO = false;
528     graphArgs.build = false;
529     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
530 
531     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
532     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
533     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SpecifyInputsAndOutputs(model, nullptr, &outputIndices));
534 
535     Free(model, nullptr, nullptr);
536 }
537 
538 /**
539  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_SpecifyInputsAndOutputs_02
540  * @tc.desc: 设置输入输出,inputindices中data为nullptr
541  * @tc.type: FUNC
542  */
543 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_SpecifyInputsAndOutputs_02,
544          Function | MediumTest | Level2)
545 {
546     OH_NNModel *model = OH_NNModel_Construct();
547     EXPECT_NE(nullptr, model);
548 
549     ReduceL2Model1 reduceL2Model;
550     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
551     graphArgs.specifyIO = false;
552     graphArgs.build = false;
553     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
554 
555     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
556     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
557     inputIndices.data = nullptr;
558     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SpecifyInputsAndOutputs(model, &inputIndices, &outputIndices));
559 
560     Free(model, nullptr, nullptr);
561 }
562 
563 /**
564  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_SpecifyInputsAndOutputs_03
565  * @tc.desc: 设置输入输出,inputindices中data对应序号不存在
566  * @tc.type: FUNC
567  */
568 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_SpecifyInputsAndOutputs_03,
569          Function | MediumTest | Level2)
570 {
571     OH_NNModel *model = OH_NNModel_Construct();
572     EXPECT_NE(nullptr, model);
573 
574     ReduceL2Model1 reduceL2Model;
575     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
576     graphArgs.specifyIO = false;
577     graphArgs.build = false;
578     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
579 
580     graphArgs.inputIndices = {100000};
581     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
582     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
583     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SpecifyInputsAndOutputs(model, &inputIndices, &outputIndices));
584 
585     Free(model, nullptr, nullptr);
586 }
587 
588 /**
589  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_SpecifyInputsAndOutputs_04
590  * @tc.desc: 设置输入输出,inputindices中size为0
591  * @tc.type: FUNC
592  */
593 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_SpecifyInputsAndOutputs_04,
594          Function | MediumTest | Level2)
595 {
596     OH_NNModel *model = OH_NNModel_Construct();
597     EXPECT_NE(nullptr, model);
598 
599     ReduceL2Model1 reduceL2Model;
600     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
601     graphArgs.specifyIO = false;
602     graphArgs.build = false;
603     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
604 
605     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
606     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
607     inputIndices.size = 0;
608     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SpecifyInputsAndOutputs(model, &inputIndices, &outputIndices));
609 
610     Free(model, nullptr, nullptr);
611 }
612 
613 /**
614  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_SpecifyInputsAndOutputs_05
615  * @tc.desc: 设置输入输出,outputindices为nullptr
616  * @tc.type: FUNC
617  */
618 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_SpecifyInputsAndOutputs_05,
619          Function | MediumTest | Level2)
620 {
621     OH_NNModel *model = OH_NNModel_Construct();
622     EXPECT_NE(nullptr, model);
623 
624     ReduceL2Model1 reduceL2Model;
625     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
626     graphArgs.specifyIO = false;
627     graphArgs.build = false;
628     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
629 
630     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
631     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
632     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SpecifyInputsAndOutputs(model, &inputIndices, nullptr));
633 
634     Free(model, nullptr, nullptr);
635 }
636 
637 /**
638  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_SpecifyInputsAndOutputs_06
639  * @tc.desc: 设置输入输出,outputindices中data为nullptr
640  * @tc.type: FUNC
641  */
642 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_SpecifyInputsAndOutputs_06,
643          Function | MediumTest | Level2)
644 {
645     OH_NNModel *model = OH_NNModel_Construct();
646     EXPECT_NE(nullptr, model);
647 
648     ReduceL2Model1 reduceL2Model;
649     OHNNGraphArgs graphArgs = reduceL2Model.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 inputIndices = TransformUInt32Array(graphArgs.inputIndices);
656     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
657     outputIndices.data = nullptr;
658     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SpecifyInputsAndOutputs(model, &inputIndices, &outputIndices));
659 
660     Free(model, nullptr, nullptr);
661 }
662 
663 /**
664  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_SpecifyInputsAndOutputs_07
665  * @tc.desc: 设置输入输出,outputindices中data对应序号不存在
666  * @tc.type: FUNC
667  */
668 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_SpecifyInputsAndOutputs_07,
669          Function | MediumTest | Level2)
670 {
671     OH_NNModel *model = OH_NNModel_Construct();
672     EXPECT_NE(nullptr, model);
673 
674     ReduceL2Model1 reduceL2Model;
675     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
676     graphArgs.specifyIO = false;
677     graphArgs.build = false;
678     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
679 
680     graphArgs.outputIndices = {100000};
681     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
682     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
683     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SpecifyInputsAndOutputs(model, &inputIndices, &outputIndices));
684 
685     Free(model, nullptr, nullptr);
686 }
687 
688 /**
689  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_SpecifyInputsAndOutputs_08
690  * @tc.desc: 设置输入输出,outputindices中size为0
691  * @tc.type: FUNC
692  */
693 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_SpecifyInputsAndOutputs_08,
694          Function | MediumTest | Level2)
695 {
696     OH_NNModel *model = OH_NNModel_Construct();
697     EXPECT_NE(nullptr, model);
698 
699     ReduceL2Model1 reduceL2Model;
700     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
701     graphArgs.specifyIO = false;
702     graphArgs.build = false;
703     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
704 
705     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
706     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
707     outputIndices.size = 0;
708     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_SpecifyInputsAndOutputs(model, &inputIndices, &outputIndices));
709 
710     Free(model, nullptr, nullptr);
711 }
712 
713 /**
714  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_01
715  * @tc.desc: 添加算子,paramindices为nullptr
716  * @tc.type: FUNC
717  */
718 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_01, Function | MediumTest | Level2)
719 {
720     OH_NNModel *model = OH_NNModel_Construct();
721     EXPECT_NE(nullptr, model);
722 
723     ReduceL2Model1 reduceL2Model;
724     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
725     graphArgs.addOperation = false;
726     graphArgs.specifyIO = false;
727     graphArgs.build = false;
728     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
729 
730     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
731     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
732     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_AddOperation(model, graphArgs.operationType,
733                                                                nullptr, &inputIndices, &outputIndices));
734 
735     Free(model, nullptr, nullptr);
736 }
737 
738 /**
739  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_02
740  * @tc.desc: 添加算子,paramindices中data为nullptr
741  * @tc.type: FUNC
742  */
743 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_02, Function | MediumTest | Level1)
744 {
745     OH_NNModel *model = OH_NNModel_Construct();
746     EXPECT_NE(nullptr, model);
747 
748     ReduceL2Model1 reduceL2Model;
749     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
750     graphArgs.addOperation = false;
751     graphArgs.specifyIO = false;
752     graphArgs.build = false;
753     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
754 
755     auto paramIndices = TransformUInt32Array(graphArgs.paramIndices);
756     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
757     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
758     paramIndices.data = nullptr;
759     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_AddOperation(model, graphArgs.operationType,
760                                                                &paramIndices, &inputIndices, &outputIndices));
761 
762     Free(model, nullptr, nullptr);
763 }
764 
765 /**
766  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_03
767  * @tc.desc: 添加算子,paramindices中data对应序号不存在
768  * @tc.type: FUNC
769  */
770 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_03, Function | MediumTest | Level2)
771 {
772     OH_NNModel *model = OH_NNModel_Construct();
773     EXPECT_NE(nullptr, model);
774 
775     ReduceL2Model1 reduceL2Model;
776     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
777     graphArgs.addOperation = false;
778     graphArgs.specifyIO = false;
779     graphArgs.build = false;
780     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
781 
782     graphArgs.paramIndices = {100000};
783     auto paramIndices = TransformUInt32Array(graphArgs.paramIndices);
784     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
785     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
786     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_AddOperation(model, graphArgs.operationType,
787                                                                &paramIndices, &inputIndices, &outputIndices));
788 
789     Free(model, nullptr, nullptr);
790 }
791 
792 /**
793  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_04
794  * @tc.desc: 添加算子,paramindices中size为0
795  * @tc.type: FUNC
796  */
797 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_04, Function | MediumTest | Level1)
798 {
799     OH_NNModel *model = OH_NNModel_Construct();
800     EXPECT_NE(nullptr, model);
801 
802     ReduceL2Model1 reduceL2Model;
803     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
804     graphArgs.addOperation = false;
805     graphArgs.specifyIO = false;
806     graphArgs.build = false;
807     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
808 
809     auto paramIndices = TransformUInt32Array(graphArgs.paramIndices);
810     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
811     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
812     paramIndices.size = 0;
813     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_AddOperation(model, graphArgs.operationType,
814                                                                &paramIndices, &inputIndices, &outputIndices));
815 
816     Free(model, nullptr, nullptr);
817 }
818 
819 /**
820  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_05
821  * @tc.desc: 添加算子,inputindices为nullptr
822  * @tc.type: FUNC
823  */
824 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_05, Function | MediumTest | Level2)
825 {
826     OH_NNModel *model = OH_NNModel_Construct();
827     EXPECT_NE(nullptr, model);
828 
829     ReduceL2Model1 reduceL2Model;
830     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
831     graphArgs.addOperation = false;
832     graphArgs.specifyIO = false;
833     graphArgs.build = false;
834     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
835 
836     auto paramIndices = TransformUInt32Array(graphArgs.paramIndices);
837     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
838     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_AddOperation(model, graphArgs.operationType,
839                                                                &paramIndices, nullptr, &outputIndices));
840 
841     Free(model, nullptr, nullptr);
842 }
843 
844 /**
845  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_06
846  * @tc.desc: 添加算子,inputindices中data为nullptr
847  * @tc.type: FUNC
848  */
849 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_06, Function | MediumTest | Level2)
850 {
851     OH_NNModel *model = OH_NNModel_Construct();
852     EXPECT_NE(nullptr, model);
853 
854     ReduceL2Model1 reduceL2Model;
855     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
856     graphArgs.addOperation = false;
857     graphArgs.specifyIO = false;
858     graphArgs.build = false;
859     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
860 
861     auto paramIndices = TransformUInt32Array(graphArgs.paramIndices);
862     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
863     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
864     inputIndices.data = nullptr;
865     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_AddOperation(model, graphArgs.operationType,
866                                                                &paramIndices, &inputIndices, &outputIndices));
867 
868     Free(model, nullptr, nullptr);
869 }
870 
871 /**
872  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_07
873  * @tc.desc: 添加算子,inputindices中data对应序号不存在
874  * @tc.type: FUNC
875  */
876 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_07, Function | MediumTest | Level2)
877 {
878     OH_NNModel *model = OH_NNModel_Construct();
879     EXPECT_NE(nullptr, model);
880 
881     ReduceL2Model1 reduceL2Model;
882     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
883     graphArgs.addOperation = false;
884     graphArgs.specifyIO = false;
885     graphArgs.build = false;
886     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
887 
888     graphArgs.inputIndices = {100000};
889     auto paramIndices = TransformUInt32Array(graphArgs.paramIndices);
890     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
891     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
892     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_AddOperation(model, graphArgs.operationType,
893                                                                &paramIndices, &inputIndices, &outputIndices));
894 
895     Free(model, nullptr, nullptr);
896 }
897 
898 /**
899  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_08
900  * @tc.desc: 添加算子,inputindices中size为0
901  * @tc.type: FUNC
902  */
903 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_08, Function | MediumTest | Level2)
904 {
905     OH_NNModel *model = OH_NNModel_Construct();
906     EXPECT_NE(nullptr, model);
907 
908     ReduceL2Model1 reduceL2Model;
909     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
910     graphArgs.addOperation = false;
911     graphArgs.specifyIO = false;
912     graphArgs.build = false;
913     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
914 
915     auto paramIndices = TransformUInt32Array(graphArgs.paramIndices);
916     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
917     auto outputIndices = TransformUInt32Array(graphArgs.outputIndices);
918     inputIndices.size = 0;
919     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_AddOperation(model, graphArgs.operationType,
920                                                                &paramIndices, &inputIndices, &outputIndices));
921 
922     Free(model, nullptr, nullptr);
923 }
924 
925 /**
926  * @tc.number : SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_09
927  * @tc.desc: 添加算子,outputindices为nullptr
928  * @tc.type: FUNC
929  */
930 HWTEST_F(ReduceL2Test, SUB_AI_NNRt_Func_North_ReduceL2_Model_AddOperation_09, Function | MediumTest | Level2)
931 {
932     OH_NNModel *model = OH_NNModel_Construct();
933     EXPECT_NE(nullptr, model);
934 
935     ReduceL2Model1 reduceL2Model;
936     OHNNGraphArgs graphArgs = reduceL2Model.graphArgs;
937     graphArgs.addOperation = false;
938     graphArgs.specifyIO = false;
939     graphArgs.build = false;
940     EXPECT_EQ(OH_NN_SUCCESS, BuildSingleOpGraph(model, graphArgs));
941 
942     auto paramIndices = TransformUInt32Array(graphArgs.paramIndices);
943     auto inputIndices = TransformUInt32Array(graphArgs.inputIndices);
944     EXPECT_EQ(OH_NN_INVALID_PARAMETER, OH_NNModel_AddOperation(nullptr, graphArgs.operationType,
945                                                                &paramIndices, &inputIndices, nullptr));
946 
947     Free(model, nullptr, nullptr);
948 }