1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "ops/conv2d_transpose_builder.h"
17 
18 #include "ops_test.h"
19 
20 using namespace testing;
21 using namespace testing::ext;
22 using namespace OHOS::NeuralNetworkRuntime::Ops;
23 
24 namespace OHOS {
25 namespace NeuralNetworkRuntime {
26 namespace UnitTest {
27 class Conv2DTransposePadmodeBuilderTest : public OpsTest {
28 public:
29     void SetUp() override;
30     void TearDown() override;
31 
32     void SetConv2dTransposeInput();
33     void SetPadMode(OH_NN_DataType dataType,
34         const std::vector<int32_t> &dim,  const OH_NN_QuantParam* quantParam, OH_NN_TensorType type);
35     void SetOutPaddings(OH_NN_DataType dataType,
36         const std::vector<int32_t> &dim,  const OH_NN_QuantParam* quantParam, OH_NN_TensorType type);
37     void SetParam();
38 
39 public:
40     Conv2DTransposeBuilder m_builder;
41     std::vector<uint32_t> m_inputs{0, 1, 2};
42     std::vector<uint32_t> m_outputs{3};
43     std::vector<uint32_t> m_params{4, 5, 6, 7, 8, 9};
44     std::vector<int32_t> m_output_dim{1, 3, 3, 1};
45     std::vector<int32_t> m_stride_dim{2};
46     std::vector<int32_t> m_dilation_dim{2};
47     std::vector<int32_t> outPaddingsDim{2};
48     std::vector<int32_t> m_param_dim{};
49 };
50 
SetUp()51 void Conv2DTransposePadmodeBuilderTest::SetUp() {}
52 
TearDown()53 void Conv2DTransposePadmodeBuilderTest::TearDown() {}
54 
SetPadMode(OH_NN_DataType dataType,const std::vector<int32_t> & dim,const OH_NN_QuantParam * quantParam,OH_NN_TensorType type)55 void Conv2DTransposePadmodeBuilderTest::SetPadMode(OH_NN_DataType dataType,
56     const std::vector<int32_t> &dim,  const OH_NN_QuantParam* quantParam, OH_NN_TensorType type)
57 {
58     std::shared_ptr<NNTensor> tensor = TransToNNTensor(dataType, dim, quantParam, type);
59     int8_t* padModeValue = new (std::nothrow) int8_t(0);
60     EXPECT_NE(nullptr, padModeValue);
61     tensor->SetBuffer(padModeValue, sizeof(int8_t));
62     m_allTensors.emplace_back(tensor);
63 }
64 
SetOutPaddings(OH_NN_DataType dataType,const std::vector<int32_t> & dim,const OH_NN_QuantParam * quantParam,OH_NN_TensorType type)65 void Conv2DTransposePadmodeBuilderTest::SetOutPaddings(OH_NN_DataType dataType,
66     const std::vector<int32_t> &dim,  const OH_NN_QuantParam* quantParam, OH_NN_TensorType type)
67 {
68     int32_t outPaddingsNum = 2;
69     std::shared_ptr<NNTensor> tensor = TransToNNTensor(dataType, dim, quantParam, type);
70     int64_t* outPaddingsValue = new (std::nothrow) int64_t[2]{0, 0};
71     EXPECT_NE(nullptr, outPaddingsValue);
72     tensor->SetBuffer(outPaddingsValue, outPaddingsNum * sizeof(int64_t));
73     m_allTensors.emplace_back(tensor);
74 }
75 
SetParam()76 void Conv2DTransposePadmodeBuilderTest::SetParam()
77 {
78     SetStride(OH_NN_INT64, m_stride_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_STRIDES);
79     SetDilation(OH_NN_INT64, m_dilation_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_DILATION);
80     SetPadMode(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
81     SetOutPaddings(OH_NN_INT64, outPaddingsDim, nullptr, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
82     SetGroup(OH_NN_INT64, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_GROUP);
83     SetActivation(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
84 }
85 
SetConv2dTransposeInput()86 void Conv2DTransposePadmodeBuilderTest::SetConv2dTransposeInput()
87 {
88     int32_t weightNum = 4;
89     std::vector<int32_t> m_input_dim{1, 4, 4, 1};
90     std::vector<int32_t> weightDim = {1, 2, 2, 1};
91     std::vector<int32_t> biasDim = {1};
92     std::shared_ptr<NNTensor> inTensor;
93     inTensor = TransToNNTensor(OH_NN_FLOAT32, m_input_dim, nullptr, OH_NN_TENSOR);
94     m_allTensors.emplace_back(inTensor);
95     inTensor = TransToNNTensor(OH_NN_FLOAT32, weightDim, nullptr, OH_NN_TENSOR);
96     float* weightValue = new (std::nothrow) float[4]{1, 1, 1, 1};
97     EXPECT_NE(nullptr, weightValue);
98     inTensor->SetBuffer(weightValue, weightNum * sizeof(weightValue));
99     m_allTensors.emplace_back(inTensor);
100     inTensor = TransToNNTensor(OH_NN_FLOAT32, biasDim, nullptr, OH_NN_TENSOR);
101     float* biasValue = new (std::nothrow) float[1]{0};
102     EXPECT_NE(nullptr, biasValue);
103     inTensor->SetBuffer(biasValue, sizeof(float));
104     m_allTensors.emplace_back(inTensor);
105 }
106 
107 /**
108  * @tc.name: conv2dtranpose_build_padmode_001
109  * @tc.desc: Verify the success of the build function
110  * @tc.type: FUNC
111  */
112 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_001, TestSize.Level1)
113 {
114     m_paramsIndex = m_params;
115     m_inputsIndex = m_inputs;
116 
117     SetConv2dTransposeInput();
118     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
119     SetParam();
120     EXPECT_EQ(OH_NN_SUCCESS, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
121 }
122 
123 /**
124  * @tc.name: conv2dtranpose_build_padmode_002
125  * @tc.desc: Verify the forbidden of the build function
126  * @tc.type: FUNC
127  */
128 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_002, TestSize.Level1)
129 {
130     m_paramsIndex = m_params;
131     m_inputsIndex = m_inputs;
132 
133     SetConv2dTransposeInput();
134     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
135     SetParam();
136     EXPECT_EQ(OH_NN_SUCCESS, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
137     EXPECT_EQ(OH_NN_OPERATION_FORBIDDEN, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
138 }
139 
140 /**
141  * @tc.name: conv2dtranpose_build_padmode_003
142  * @tc.desc: Verify the missing input of the build function
143  * @tc.type: FUNC
144  */
145 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_003, TestSize.Level1)
146 {
147     m_inputs = {0};
148     m_outputs = {1};
149     m_params = {2, 3, 4, 5, 6, 7};
150     m_paramsIndex = m_params;
151     m_inputsIndex = m_inputs;
152 
153     SetConv2dTransposeInput();
154     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
155     SetParam();
156     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
157 }
158 
159 /**
160  * @tc.name: conv2dtranpose_build_padmode_004
161  * @tc.desc: Verify the missing output of the build function
162  * @tc.type: FUNC
163  */
164 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_004, TestSize.Level1)
165 {
166     m_inputs = {0, 1, 2};
167     m_outputs = {};
168     m_params = {3, 4, 5, 6, 7, 8};
169     m_paramsIndex = m_params;
170     m_inputsIndex = m_inputs;
171 
172     SetConv2dTransposeInput();
173     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
174     SetParam();
175     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
176 }
177 
178 /**
179  * @tc.name: conv2dtranpose_build_padmode_005
180  * @tc.desc: Verify the inputIndex out of bounds of the build function
181  * @tc.type: FUNC
182  */
183 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_005, TestSize.Level1)
184 {
185     m_inputs = {0, 1, 10};
186     m_outputs = {3};
187     m_params = {4, 5, 6, 7, 8, 9};
188     m_paramsIndex = m_params;
189     m_inputsIndex = m_inputs;
190 
191     SetConv2dTransposeInput();
192     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
193     SetParam();
194     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
195 }
196 
197 /**
198  * @tc.name: conv2dtranpose_build_padmode_006
199  * @tc.desc: Verify the outputIndex out of bounds of the build function
200  * @tc.type: FUNC
201  */
202 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_006, TestSize.Level1)
203 {
204     m_inputs = {0, 1, 2};
205     m_outputs = {10};
206     m_params = {4, 5, 6, 7, 8, 9};
207     m_paramsIndex = m_params;
208     m_inputsIndex = m_inputs;
209 
210     SetConv2dTransposeInput();
211     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
212     SetParam();
213     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
214 }
215 
216 /**
217  * @tc.name: conv2dtranpose_build_padmode_007
218  * @tc.desc: Verify the invalid stride of the build function
219  * @tc.type: FUNC
220  */
221 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_007, TestSize.Level1)
222 {
223     m_paramsIndex = m_params;
224     m_inputsIndex = m_inputs;
225 
226     SetConv2dTransposeInput();
227     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
228 
229     std::shared_ptr<NNTensor> tensor = TransToNNTensor(OH_NN_INT32, m_stride_dim, nullptr,
230         OH_NN_CONV2D_TRANSPOSE_STRIDES);
231     int32_t* strideValue = new (std::nothrow) int32_t[2]{1, 1};
232     EXPECT_NE(nullptr, strideValue);
233 
234     tensor->SetBuffer(strideValue, 2 * sizeof(int32_t));
235     m_allTensors.emplace_back(tensor);
236 
237     SetDilation(OH_NN_INT64, m_dilation_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_DILATION);
238     SetPadMode(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
239     SetOutPaddings(OH_NN_INT64, outPaddingsDim, nullptr, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
240     SetGroup(OH_NN_INT64, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_GROUP);
241     SetActivation(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
242     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
243 }
244 
245 /**
246  * @tc.name: conv2dtranpose_build_padmode_008
247  * @tc.desc: Verify the invalid dilation of the build function
248  * @tc.type: FUNC
249  */
250 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_008, TestSize.Level1)
251 {
252     m_paramsIndex = m_params;
253     m_inputsIndex = m_inputs;
254 
255     SetConv2dTransposeInput();
256     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
257 
258     SetStride(OH_NN_INT64, m_stride_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_STRIDES);
259     std::shared_ptr<NNTensor> tensor = TransToNNTensor(OH_NN_INT32, m_dilation_dim, nullptr,
260         OH_NN_CONV2D_TRANSPOSE_DILATION);
261     int32_t* dilationValue = new (std::nothrow) int32_t[2]{1, 1};
262     EXPECT_NE(nullptr, dilationValue);
263 
264     tensor->SetBuffer(dilationValue, 2 * sizeof(int32_t));
265     m_allTensors.emplace_back(tensor);
266 
267     SetPadMode(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
268     SetOutPaddings(OH_NN_INT64, outPaddingsDim, nullptr, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
269     SetGroup(OH_NN_INT64, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_GROUP);
270     SetActivation(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
271     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
272 }
273 
274 /**
275  * @tc.name: conv2dtranpose_build_padmode_009
276  * @tc.desc: Verify the invalid padmode of the build function
277  * @tc.type: FUNC
278  */
279 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_009, TestSize.Level1)
280 {
281     m_paramsIndex = m_params;
282     m_inputsIndex = m_inputs;
283 
284     SetConv2dTransposeInput();
285     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
286     SetStride(OH_NN_INT64, m_stride_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_STRIDES);
287     SetDilation(OH_NN_INT64, m_dilation_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_DILATION);
288     std::shared_ptr<NNTensor> tensor = TransToNNTensor(OH_NN_INT32, m_param_dim, nullptr,
289         OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
290     int32_t* padModeValue = new (std::nothrow) int32_t(0);
291     EXPECT_NE(nullptr, padModeValue);
292 
293     tensor->SetBuffer(padModeValue, sizeof(int32_t));
294     m_allTensors.emplace_back(tensor);
295     SetOutPaddings(OH_NN_INT64, outPaddingsDim, nullptr, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
296     SetGroup(OH_NN_INT64, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_GROUP);
297     SetActivation(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
298     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
299 }
300 
301 /**
302  * @tc.name: conv2dtranpose_build_padmode_010
303  * @tc.desc: Verify the invalid outpaddings of the build function
304  * @tc.type: FUNC
305  */
306 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_010, TestSize.Level1)
307 {
308     m_paramsIndex = m_params;
309     m_inputsIndex = m_inputs;
310 
311     SetConv2dTransposeInput();
312     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
313     SetStride(OH_NN_INT64, m_stride_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_STRIDES);
314     SetDilation(OH_NN_INT64, m_dilation_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_DILATION);
315     SetPadMode(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
316 
317     std::shared_ptr<NNTensor> outPadtensor = TransToNNTensor(OH_NN_INT32, outPaddingsDim, nullptr,
318         OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
319     int32_t* outPaddingsTypeInvalid = new (std::nothrow) int32_t(0);
320     EXPECT_NE(nullptr, outPaddingsTypeInvalid);
321 
322     outPadtensor->SetBuffer(outPaddingsTypeInvalid, sizeof(int32_t));
323     m_allTensors.emplace_back(outPadtensor);
324 
325     SetGroup(OH_NN_INT64, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_GROUP);
326     SetActivation(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
327     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
328 }
329 
330 /**
331  * @tc.name: conv2dtranpose_build_padmode_011
332  * @tc.desc: Verify the invalid group of the build function
333  * @tc.type: FUNC
334  */
335 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_011, TestSize.Level1)
336 {
337     m_paramsIndex = m_params;
338     m_inputsIndex = m_inputs;
339 
340     SetConv2dTransposeInput();
341     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
342     SetStride(OH_NN_INT64, m_stride_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_STRIDES);
343     SetDilation(OH_NN_INT64, m_dilation_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_DILATION);
344     SetPadMode(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
345     SetOutPaddings(OH_NN_INT64, outPaddingsDim, nullptr, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
346 
347     std::shared_ptr<NNTensor> tensor = TransToNNTensor(OH_NN_INT32, m_param_dim, nullptr,
348         OH_NN_CONV2D_TRANSPOSE_GROUP);
349     int32_t* groupValue = new (std::nothrow) int32_t(0);
350     EXPECT_NE(nullptr, groupValue);
351 
352     tensor->SetBuffer(groupValue, sizeof(int32_t));
353     m_allTensors.emplace_back(tensor);
354     SetActivation(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
355     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
356 }
357 
358 /**
359  * @tc.name: conv2dtranpose_build_padmode_012
360  * @tc.desc: Verify the invalid activation of the build function
361  * @tc.type: FUNC
362  */
363 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_012, TestSize.Level1)
364 {
365     m_paramsIndex = m_params;
366     m_inputsIndex = m_inputs;
367 
368     SetConv2dTransposeInput();
369     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
370     SetStride(OH_NN_INT64, m_stride_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_STRIDES);
371     SetDilation(OH_NN_INT64, m_dilation_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_DILATION);
372     SetPadMode(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
373     SetOutPaddings(OH_NN_INT64, outPaddingsDim, nullptr, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
374     SetGroup(OH_NN_INT64, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_GROUP);
375 
376     std::shared_ptr<NNTensor> tensor = TransToNNTensor(OH_NN_INT32, m_param_dim, nullptr,
377         OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
378     int32_t* activationTest = new (std::nothrow) int32_t(1);
379     EXPECT_NE(nullptr, activationTest);
380 
381     tensor->SetBuffer(activationTest, sizeof(int32_t));
382     m_allTensors.emplace_back(tensor);
383     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
384 }
385 
386 /**
387  * @tc.name: conv2dtranpose_build_padmode_013
388  * @tc.desc: Verify the group scalar length of the build function
389  * @tc.type: FUNC
390  */
391 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_013, TestSize.Level1)
392 {
393     std::vector<int32_t> groupDim = {2};
394     m_paramsIndex = m_params;
395     m_inputsIndex = m_inputs;
396 
397     SetConv2dTransposeInput();
398     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
399     SetStride(OH_NN_INT64, m_stride_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_STRIDES);
400     SetDilation(OH_NN_INT64, m_dilation_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_DILATION);
401     SetPadMode(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
402     SetOutPaddings(OH_NN_INT64, outPaddingsDim, nullptr, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
403 
404     std::shared_ptr<NNTensor> tensor = TransToNNTensor(OH_NN_INT64, outPaddingsDim, nullptr,
405         OH_NN_CONV2D_TRANSPOSE_GROUP);
406     int64_t* groupTest = new (std::nothrow) int64_t[2]{0, 0};
407     EXPECT_NE(nullptr, groupTest);
408 
409     tensor->SetBuffer(groupTest, 2 * sizeof(int64_t));
410     m_allTensors.emplace_back(tensor);
411     SetActivation(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
412     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
413 }
414 
415 /**
416  * @tc.name: conv2dtranpose_build_padmode_014
417  * @tc.desc: Verify the activation scalar length of the build function
418  * @tc.type: FUNC
419  */
420 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_014, TestSize.Level1)
421 {
422     m_inputsIndex = m_inputs;
423     m_paramsIndex = m_params;
424 
425     SetConv2dTransposeInput();
426     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
427     SetStride(OH_NN_INT64, m_stride_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_STRIDES);
428     SetDilation(OH_NN_INT64, m_dilation_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_DILATION);
429     SetPadMode(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
430     SetOutPaddings(OH_NN_INT64, outPaddingsDim, nullptr, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
431     SetGroup(OH_NN_INT64, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_GROUP);
432     std::shared_ptr<NNTensor> tensor = TransToNNTensor(OH_NN_INT8, outPaddingsDim, nullptr,
433         OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
434     int8_t* activationTest = new (std::nothrow) int8_t[2]{0, 0};
435     EXPECT_NE(nullptr, activationTest);
436 
437     tensor->SetBuffer(activationTest, 2 * sizeof(int8_t));
438     m_allTensors.emplace_back(tensor);
439     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
440 }
441 
442 /**
443  * @tc.name: conv2dtranpose_build_padmode_015
444  * @tc.desc: Verify the invalid weight dims of the build function
445  * @tc.type: FUNC
446  */
447 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_015, TestSize.Level1)
448 {
449     m_paramsIndex = m_params;
450     m_inputsIndex = m_inputs;
451     int32_t weightNum = 3;
452     std::vector<int32_t> m_input_dim{1, 4, 4, 1};
453     std::vector<int32_t> weightDim = {1, 3, 1};
454     std::vector<int32_t> biasDim = {1};
455 
456     std::shared_ptr<NNTensor> inTensor;
457     inTensor = TransToNNTensor(OH_NN_FLOAT32, m_input_dim, nullptr, OH_NN_TENSOR);
458     m_allTensors.emplace_back(inTensor);
459     inTensor = TransToNNTensor(OH_NN_FLOAT32, weightDim, nullptr, OH_NN_TENSOR);
__anon5a8f7e210302null460     float* weightValue = new (std::nothrow) float[3]{1, 1, 1};
461     EXPECT_NE(nullptr, weightValue);
462 
463     inTensor->SetBuffer(weightValue, weightNum * sizeof(weightValue));
464     m_allTensors.emplace_back(inTensor);
465     inTensor = TransToNNTensor(OH_NN_FLOAT32, biasDim, nullptr, OH_NN_TENSOR);
__anon5a8f7e210402null466     float* biasValue = new (std::nothrow) float[1]{0};
467     EXPECT_NE(nullptr, biasValue);
468 
469     inTensor->SetBuffer(biasValue, sizeof(float));
470     m_allTensors.emplace_back(inTensor);
471     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
472 }
473 
474 /**
475  * @tc.name: conv2dtranpose_build_padmode_016
476  * @tc.desc: Verify the invalid param to conv2d transpose length of the build function
477  * @tc.type: FUNC
478  */
479 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_016, TestSize.Level1)
480 {
481     SetConv2dTransposeInput();
482     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
483     SetStride(OH_NN_INT64, m_stride_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_STRIDES);
484     SetDilation(OH_NN_INT64, m_dilation_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_DILATION);
485     SetPadMode(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
486     SetOutPaddings(OH_NN_INT64, outPaddingsDim, nullptr, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
487     SetGroup(OH_NN_INT64, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_GROUP);
488 
489     std::shared_ptr<NNTensor> tensor = TransToNNTensor(OH_NN_INT8, m_param_dim, nullptr,
490         OH_NN_CONV2D_ACTIVATION_TYPE);
491     int8_t* activationValue = new (std::nothrow) int8_t(0);
492     EXPECT_NE(nullptr, activationValue);
493 
494     tensor->SetBuffer(activationValue, sizeof(int8_t));
495     m_allTensors.emplace_back(tensor);
496     m_paramsIndex = m_params;
497     m_inputsIndex = m_inputs;
498     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
499 }
500 
501 /**
502  * @tc.name: conv2dtranpose_build_padmode_017
503  * @tc.desc: Verify the activation value of the build function
504  * @tc.type: FUNC
505  */
506 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_017, TestSize.Level1)
507 {
508     SetConv2dTransposeInput();
509     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
510     m_paramsIndex = m_params;
511     m_inputsIndex = m_inputs;
512 
513     SetStride(OH_NN_INT64, m_stride_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_STRIDES);
514     SetDilation(OH_NN_INT64, m_dilation_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_DILATION);
515     SetPadMode(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
516     SetOutPaddings(OH_NN_INT64, outPaddingsDim, nullptr, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
517     SetGroup(OH_NN_INT64, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_GROUP);
518     std::shared_ptr<NNTensor> tensor = TransToNNTensor(OH_NN_INT8, m_param_dim, nullptr,
519         OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
520     int8_t* activationValue = new (std::nothrow) int8_t(10);
521     EXPECT_NE(nullptr, activationValue);
522 
523     tensor->SetBuffer(activationValue, sizeof(int8_t));
524     m_allTensors.emplace_back(tensor);
525     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
526 }
527 
528 /**
529  * @tc.name: conv2dtranpose_build_padmode_018
530  * @tc.desc: Verify the padmode value of the build function
531  * @tc.type: FUNC
532  */
533 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_018, TestSize.Level1)
534 {
535     m_paramsIndex = m_params;
536     m_inputsIndex = m_inputs;
537 
538     SetConv2dTransposeInput();
539     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
540     SetStride(OH_NN_INT64, m_stride_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_STRIDES);
541     SetDilation(OH_NN_INT64, m_dilation_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_DILATION);
542 
543     std::shared_ptr<NNTensor> tensor = TransToNNTensor(OH_NN_INT8, m_param_dim, nullptr,
544         OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
545     int8_t* padModeValue = new (std::nothrow) int8_t(10);
546     EXPECT_NE(nullptr, padModeValue);
547 
548     tensor->SetBuffer(padModeValue, sizeof(int8_t));
549     m_allTensors.emplace_back(tensor);
550     SetOutPaddings(OH_NN_INT64, outPaddingsDim, nullptr, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
551     SetGroup(OH_NN_INT64, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_GROUP);
552     SetActivation(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
553     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
554 }
555 
556 /**
557  * @tc.name: conv2dtranpose_build_padmode_019
558  * @tc.desc: Verify the pad dim invalid of the build function
559  * @tc.type: FUNC
560  */
561 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_019, TestSize.Level1)
562 {
563     std::vector<int32_t> m_pad_dim = {3};
564     m_paramsIndex = m_params;
565     m_inputsIndex = m_inputs;
566 
567     SetConv2dTransposeInput();
568     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
569     SetStride(OH_NN_INT64, m_stride_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_STRIDES);
570     SetDilation(OH_NN_INT64, m_dilation_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_DILATION);
571     SetPadMode(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
572 
573     std::shared_ptr<NNTensor> tensor = TransToNNTensor(OH_NN_INT64, m_pad_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_PAD);
574     int64_t* padValue = new (std::nothrow) int64_t[3]{1, 1, 1};
575     EXPECT_NE(nullptr, padValue);
576 
577     tensor->SetBuffer(padValue, 3 * sizeof(int64_t));
578     m_allTensors.emplace_back(tensor);
579     SetGroup(OH_NN_INT64, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_GROUP);
580     SetActivation(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
581     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
582 }
583 
584 /**
585  * @tc.name: conv2dtranpose_build_padmode_020
586  * @tc.desc: Verify the conv2dtranspose without set stride of the build function
587  * @tc.type: FUNC
588  */
589 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_020, TestSize.Level1)
590 {
591     m_paramsIndex = m_params;
592     m_inputsIndex = m_inputs;
593 
594     SetConv2dTransposeInput();
595     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
596     std::shared_ptr<NNTensor> tensor = TransToNNTensor(OH_NN_INT64, m_stride_dim, nullptr,
597         OH_NN_CONV2D_TRANSPOSE_STRIDES);
598     m_allTensors.emplace_back(tensor);
599 
600     SetDilation(OH_NN_INT64, m_dilation_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_DILATION);
601     SetPadMode(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
602     SetOutPaddings(OH_NN_INT64, outPaddingsDim, nullptr, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
603     SetGroup(OH_NN_INT64, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_GROUP);
604     SetActivation(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
605     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
606 }
607 
608 /**
609  * @tc.name: conv2dtranpose_build_padmode_021
610  * @tc.desc: Verify the conv2dtranspose without set dilation of the build function
611  * @tc.type: FUNC
612  */
613 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_021, TestSize.Level1)
614 {
615     m_paramsIndex = m_params;
616     m_inputsIndex = m_inputs;
617 
618     SetConv2dTransposeInput();
619     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
620     SetStride(OH_NN_INT64, m_stride_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_STRIDES);
621 
622     std::shared_ptr<NNTensor> tensor = TransToNNTensor(OH_NN_INT64, m_dilation_dim, nullptr,
623         OH_NN_CONV2D_TRANSPOSE_DILATION);
624     m_allTensors.emplace_back(tensor);
625 
626     SetPadMode(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
627     SetOutPaddings(OH_NN_INT64, outPaddingsDim, nullptr, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
628     SetGroup(OH_NN_INT64, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_GROUP);
629     SetActivation(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
630     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
631 }
632 
633 /**
634  * @tc.name: conv2dtranpose_build_padmode_022
635  * @tc.desc: Verify the conv2dtranspose without set pad of the build function
636  * @tc.type: FUNC
637  */
638 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_022, TestSize.Level1)
639 {
640     m_paramsIndex = m_params;
641     m_inputsIndex = m_inputs;
642 
643     SetConv2dTransposeInput();
644     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
645     SetStride(OH_NN_INT64, m_stride_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_STRIDES);
646     SetDilation(OH_NN_INT64, m_dilation_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_DILATION);
647 
648     std::shared_ptr<NNTensor> tensor = TransToNNTensor(OH_NN_INT8, m_param_dim, nullptr,
649         OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
650     m_allTensors.emplace_back(tensor);
651 
652     SetOutPaddings(OH_NN_INT64, outPaddingsDim, nullptr, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
653     SetGroup(OH_NN_INT64, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_GROUP);
654     SetActivation(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
655     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
656 }
657 
658 /**
659  * @tc.name: conv2dtranpose_build_padmode_023
660  * @tc.desc: Verify the conv2dtranspose without set outpaddings of the build function
661  * @tc.type: FUNC
662  */
663 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_023, TestSize.Level1)
664 {
665     m_paramsIndex = m_params;
666     m_inputsIndex = m_inputs;
667 
668     SetConv2dTransposeInput();
669     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
670     SetStride(OH_NN_INT64, m_stride_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_STRIDES);
671     SetDilation(OH_NN_INT64, m_dilation_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_DILATION);
672     SetPadMode(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
673 
674     std::shared_ptr<NNTensor> tensor = TransToNNTensor(OH_NN_INT64, outPaddingsDim, nullptr,
675         OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
676     m_allTensors.emplace_back(tensor);
677 
678     SetGroup(OH_NN_INT64, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_GROUP);
679     SetActivation(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
680     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
681 }
682 
683 /**
684  * @tc.name: conv2dtranpose_build_padmode_024
685  * @tc.desc: Verify the conv2dtranspose without set group of the build function
686  * @tc.type: FUNC
687  */
688 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_024, TestSize.Level1)
689 {
690     m_paramsIndex = m_params;
691     m_inputsIndex = m_inputs;
692 
693     SetConv2dTransposeInput();
694     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
695     SetStride(OH_NN_INT64, m_stride_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_STRIDES);
696     SetDilation(OH_NN_INT64, m_dilation_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_DILATION);
697     SetPadMode(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
698     SetOutPaddings(OH_NN_INT64, outPaddingsDim, nullptr, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
699 
700     std::shared_ptr<NNTensor> tensor = TransToNNTensor(OH_NN_INT64, m_param_dim, nullptr,
701         OH_NN_CONV2D_TRANSPOSE_GROUP);
702     m_allTensors.emplace_back(tensor);
703 
704     SetActivation(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
705     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
706 }
707 
708 /**
709  * @tc.name: conv2dtranpose_build_padmode_025
710  * @tc.desc: Verify the conv2dtranspose without set activation of the build function
711  * @tc.type: FUNC
712  */
713 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_build_padmode_025, TestSize.Level1)
714 {
715     m_paramsIndex = m_params;
716     SetConv2dTransposeInput();
717 
718     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
719     SetStride(OH_NN_INT64, m_stride_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_STRIDES);
720     SetDilation(OH_NN_INT64, m_dilation_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_DILATION);
721     SetPadMode(OH_NN_INT8, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_PAD_MODE);
722     SetOutPaddings(OH_NN_INT64, outPaddingsDim, nullptr, OH_NN_CONV2D_TRANSPOSE_OUTPUT_PADDINGS);
723     SetGroup(OH_NN_INT64, m_param_dim, nullptr, OH_NN_CONV2D_TRANSPOSE_GROUP);
724 
725     std::shared_ptr<NNTensor> tensor = TransToNNTensor(OH_NN_INT8, m_param_dim, nullptr,
726         OH_NN_CONV2D_TRANSPOSE_ACTIVATION_TYPE);
727     m_allTensors.emplace_back(tensor);
728     m_inputsIndex = m_inputs;
729     EXPECT_EQ(OH_NN_INVALID_PARAMETER, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
730 }
731 
732 /**
733  * @tc.name: conv2dtranpose_getprimitive_padmode_001
734  * @tc.desc: Verify the behavior of the GetPrimitive function
735  * @tc.type: FUNC
736  */
737 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_getprimitive_padmode_001, TestSize.Level1)
738 {
739     m_paramsIndex = m_params;
740     m_inputsIndex = m_inputs;
741 
742     SetConv2dTransposeInput();
743     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
744     SetParam();
745     EXPECT_EQ(OH_NN_SUCCESS, m_builder.Build(m_paramsIndex, m_inputsIndex, m_outputsIndex, m_allTensors));
746 
747     LiteGraphTensorPtr primitive = m_builder.GetPrimitive();
748     LiteGraphTensorPtr expectPrimitive(nullptr, DestroyLiteGraphPrimitive);
749     EXPECT_NE(expectPrimitive, primitive);
750 
751     std::vector<int64_t> returnStrides = mindspore::lite::MindIR_Conv2dTransposeFusion_GetStride(primitive.get());
752     std::vector<int64_t> strideValueTest{1, 1};
753     std::vector<int64_t> expectDliation = mindspore::lite::MindIR_Conv2dTransposeFusion_GetDilation(primitive.get());
754     std::vector<int64_t> dilationValueTest{1, 1};
755     int expectpadMode = mindspore::lite::MindIR_Conv2dTransposeFusion_GetPadMode(primitive.get());
756     EXPECT_EQ(1, expectpadMode);
757 
758     int expectGroup = mindspore::lite::MindIR_Conv2dTransposeFusion_GetGroup(primitive.get());
759     EXPECT_EQ(0, expectGroup);
760 
761     std::vector<int64_t> expectoutPadding =
762         mindspore::lite::MindIR_Conv2dTransposeFusion_GetOutputPaddings(primitive.get());
763     std::vector<int64_t> outPaddingTest{0, 0};
764     EXPECT_EQ(outPaddingTest, expectoutPadding);
765 
766     int expectActivation = mindspore::lite::MindIR_Conv2dTransposeFusion_GetActivationType(primitive.get());
767     EXPECT_EQ(0, expectActivation);
768 }
769 
770 /**
771  * @tc.name: conv2dtranpose_getprimitive_padmode_002
772  * @tc.desc: Verify the behavior of the GetPrimitive function
773  * @tc.type: FUNC
774  */
775 HWTEST_F(Conv2DTransposePadmodeBuilderTest, conv2dtranpose_getprimitive_padmode_002, TestSize.Level1)
776 {
777     m_paramsIndex = m_params;
778     m_inputsIndex = m_inputs;
779 
780     SetConv2dTransposeInput();
781     SaveOutputTensor(m_outputs, OH_NN_FLOAT32, m_output_dim, nullptr);
782     SetParam();
783 
784     LiteGraphTensorPtr primitive = m_builder.GetPrimitive();
785     LiteGraphTensorPtr expectPrimitive(nullptr, DestroyLiteGraphPrimitive);
786     EXPECT_EQ(expectPrimitive, primitive);
787 }
788 } // namespace UnitTest
789 } // namespace NeuralNetworkRuntime
790 } // namespace OHOS
791