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