已合并
feat: 补充concat_d、pack ophost ut #609
zhanw_coding创建于 2025年12月31日
feat: 补充concat_d、pack ophost ut #609
已合并
zhanw_coding创建于 2025年12月31日
7 个文件变更+1209-28
@@ -884,7 +884,7 @@ parse_changed_files() {
884 echo "related ops "$COMPILED_OPS884 echo "related ops "$COMPILED_OPS
885 echo "related soc_info "$soc_info885 echo "related soc_info "$soc_info
886 886 
887- COMPUTE_UNIT=$soc_info887+ # COMPUTE_UNIT=$soc_info
888 888 
889 if [[ "$related_ut" == "set()" ]]; then889 if [[ "$related_ut" == "set()" ]]; then
890 ENABLE_TEST=FALSE890 ENABLE_TEST=FALSE
@@ -18,6 +18,7 @@
18#include "op_api_ut_common/op_api_ut.h"18#include "op_api_ut_common/op_api_ut.h"
19#include "op_api_ut_common/scalar_desc.h"19#include "op_api_ut_common/scalar_desc.h"
20#include "op_api_ut_common/tensor_desc.h"20#include "op_api_ut_common/tensor_desc.h"
21+#include "opdev/platform.h"
21 22 
22using namespace std;23using namespace std;
23 24 
@@ -32,6 +33,11 @@ protected:
32 {33 {
33 cout << "l2_cat_test TearDown" << endl;34 cout << "l2_cat_test TearDown" << endl;
34 }35 }
36+ 
37+ void TearDown() override
38+ {
39+ op::SetPlatformSocVersion(op::SocVersion::ASCEND910B);
40+ }
35};41};
36 42 
37TEST_F(l2_cat_test, cat_dtype_all_support)43TEST_F(l2_cat_test, cat_dtype_all_support)
@@ -298,19 +304,20 @@ TEST_F(l2_cat_test, cat_one_dim1_empty_tensor)
298 EXPECT_EQ(aclRet, ACL_SUCCESS);304 EXPECT_EQ(aclRet, ACL_SUCCESS);
299}305}
300 306 
301-// TEST_F(l2_cat_test, ascend310P_bfloat16)307+TEST_F(l2_cat_test, ascend310P_bfloat16)
302-// {308+{
303-// auto tensor_1_desc = TensorDesc({2, 3}, ACL_BF16, ACL_FORMAT_ND).ValueRange(0, 2);309+ op::SetPlatformSocVersion(op::SocVersion::ASCEND310P);
304-// auto tensor_2_desc = TensorDesc({1, 3}, ACL_BF16, ACL_FORMAT_ND).ValueRange(0, 2);310+ auto tensor_1_desc = TensorDesc({2, 3}, ACL_BF16, ACL_FORMAT_ND).ValueRange(0, 2);
305-// auto out_tensor_desc = TensorDesc({3, 3}, ACL_FLOAT, ACL_FORMAT_ND);311+ auto tensor_2_desc = TensorDesc({1, 3}, ACL_BF16, ACL_FORMAT_ND).ValueRange(0, 2);
306-// auto tensor_list_desc = TensorListDesc({tensor_1_desc, tensor_2_desc});312+ auto out_tensor_desc = TensorDesc({3, 3}, ACL_FLOAT, ACL_FORMAT_ND);
313+ auto tensor_list_desc = TensorListDesc({tensor_1_desc, tensor_2_desc});
307 314 
308-// int64_t dim = 0;315+ int64_t dim = 0;
309-// auto ut = OP_API_UT(aclnnCat, INPUT(tensor_list_desc, dim), OUTPUT(out_tensor_desc));316+ auto ut = OP_API_UT(aclnnCat, INPUT(tensor_list_desc, dim), OUTPUT(out_tensor_desc));
310-// uint64_t workspace_size = 0;317+ uint64_t workspace_size = 0;
311-// aclnnStatus aclRet = ut.TestGetWorkspaceSize(&workspace_size);318+ aclnnStatus aclRet = ut.TestGetWorkspaceSize(&workspace_size);
312-// EXPECT_EQ(aclRet, ACLNN_ERR_PARAM_INVALID);319+ EXPECT_EQ(aclRet, ACLNN_ERR_PARAM_INVALID);
313-// }320+}
314 321 
315TEST_F(l2_cat_test, dtype_promote_to_complex128)322TEST_F(l2_cat_test, dtype_promote_to_complex128)
316{323{
@@ -0,0 +1,504 @@
1+/**
2+ * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#include "../../../../op_host/arch35/concat_d_tiling_arch35.h"
12+#include <iostream>
13+#include <vector>
14+#include <gtest/gtest.h>
15+#include "tiling_context_faker.h"
16+#include "tiling_case_executor.h"
17+ 
18+class ConcatDTiling : public testing::Test {
19+protected:
20+ static void SetUpTestCase()
21+ {
22+ std::cout << "ConcatDTiling SetUp" << std::endl;
23+ }
24+ 
25+ static void TearDownTestCase()
26+ {
27+ std::cout << "ConcatDTiling TearDown" << std::endl;
28+ }
29+};
30+ 
31+TEST_F(ConcatDTiling, ConcatD_tiling_UT_one_axis_diff_shape_align)
32+{
33+ optiling::ConcatDCompileInfo compileInfo;
34+ compileInfo.totalCoreNum = 64;
35+ compileInfo.ubSize = 253952;
36+ gert::TilingContextPara tilingContextPara(
37+ "ConcatD",
38+ {
39+ {{{31, 3, 2560}, {31, 3, 2560}}, ge::DT_INT32, ge::FORMAT_ND},
40+ {{{31, 3, 1280}, {31, 3, 1280}}, ge::DT_INT32, ge::FORMAT_ND},
41+ {{{31, 3, 9980}, {31, 3, 9980}}, ge::DT_INT32, ge::FORMAT_ND},
42+ },
43+ {
44+ {{{31, 3, 13820}, {31, 3, 13820}}, ge::DT_INT32, ge::FORMAT_ND},
45+ },
46+ {
47+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(2)},
48+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
49+ },
50+ {3}, {1}, &compileInfo);
51+ uint64_t expectTilingKey = 2224;
52+ string expectTilingData =
53+ "1125912791875585 1030792151105 601295421468 15744 2 2 2 58 13820 1 0 281479271743488 562958543486978 "
54+ "562958543486978 562958543486978 562958543486978 562958543486978 2 281479271677952 562958543486977 "
55+ "562958543486978 562958543486978 562958543486978 562958543486978 562958543486978 562958543486977 0 0 480 960 "
56+ "1440 1920 2400 320 800 1280 480 960 1440 1920 2400 2880 3360 3840 4320 4800 5280 5760 6240 6720 7200 7680 "
57+ "8160 8640 9120 9600 9980 480 960 1440 1920 2400 320 800 1280 480 960 1440 1920 2400 2880 3360 3840 4320 4800 "
58+ "5280 5760 6240 6720 7200 7680 8160 8640 9120 9600 9980 6525 9980 895 3070 6525 9980 0 0 0 0 0 0 0 0 2560 "
59+ "1280 ";
60+ std::vector<size_t> expectWorkspaces = {16777216};
61+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectTilingData, expectWorkspaces);
62+}
63+ 
64+TEST_F(ConcatDTiling, ConcatD_tiling_UT_pure_copy)
65+{
66+ optiling::ConcatDCompileInfo compileInfo;
67+ compileInfo.totalCoreNum = 64;
68+ compileInfo.ubSize = 253952;
69+ gert::TilingContextPara tilingContextPara(
70+ "ConcatD",
71+ {
72+ {{{310, 3, 2560}, {310, 3, 2560}}, ge::DT_INT32, ge::FORMAT_ND},
73+ {{{310, 3, 1280}, {310, 3, 1280}}, ge::DT_INT32, ge::FORMAT_ND},
74+ {{{310, 3, 9980}, {310, 3, 9980}}, ge::DT_INT32, ge::FORMAT_ND},
75+ },
76+ {
77+ {{{310, 3, 13820}, {310, 3, 13820}}, ge::DT_INT32, ge::FORMAT_ND},
78+ },
79+ {
80+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(2)},
81+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
82+ },
83+ {3}, {1}, &compileInfo);
84+ uint64_t expectTilingKey = 20002;
85+ std::vector<size_t> expectWorkspaces = {16777216};
86+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
87+}
88+ 
89+TEST_F(ConcatDTiling, ConcatD_tiling_UT_one_axis_diff_shape_align_int64)
90+{
91+ optiling::ConcatDCompileInfo compileInfo;
92+ compileInfo.totalCoreNum = 64;
93+ compileInfo.ubSize = 253952;
94+ gert::TilingContextPara tilingContextPara(
95+ "ConcatD",
96+ {
97+ {{{16384, 512}, {16384, 512}}, ge::DT_INT64, ge::FORMAT_ND},
98+ {{{16384, 4}, {16384, 4}}, ge::DT_INT64, ge::FORMAT_ND},
99+ },
100+ {
101+ {{{16384, 516}, {16384, 516}}, ge::DT_INT64, ge::FORMAT_ND},
102+ },
103+ {
104+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
105+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(2)},
106+ },
107+ {2}, {1}, &compileInfo);
108+ uint64_t expectTilingKey = 12128;
109+ std::vector<size_t> expectWorkspaces = {16777216};
110+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
111+}
112+ 
113+TEST_F(ConcatDTiling, ConcatD_tiling_UT_zero_axis_same_shape_align_float)
114+{
115+ optiling::ConcatDCompileInfo compileInfo;
116+ compileInfo.totalCoreNum = 64;
117+ compileInfo.ubSize = 253952;
118+ gert::TilingContextPara tilingContextPara(
119+ "ConcatD",
120+ {
121+ {{{131080}, {131080}}, ge::DT_FLOAT, ge::FORMAT_ND},
122+ {{{131080}, {131080}}, ge::DT_FLOAT, ge::FORMAT_ND},
123+ {{{131080}, {131080}}, ge::DT_FLOAT, ge::FORMAT_ND},
124+ },
125+ {
126+ {{{393240}, {393240}}, ge::DT_FLOAT, ge::FORMAT_ND},
127+ },
128+ {
129+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(0)},
130+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
131+ },
132+ {3}, {1}, &compileInfo);
133+ uint64_t expectTilingKey = 2114;
134+ std::vector<size_t> expectWorkspaces = {16777216};
135+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
136+}
137+ 
138+TEST_F(ConcatDTiling, ConcatD_tiling_UT_zero_axis_diff_shape_align_float)
139+{
140+ optiling::ConcatDCompileInfo compileInfo;
141+ compileInfo.totalCoreNum = 64;
142+ compileInfo.ubSize = 253952;
143+ gert::TilingContextPara tilingContextPara(
144+ "ConcatD",
145+ {
146+ {{{8256}, {8256}}, ge::DT_FLOAT, ge::FORMAT_ND},
147+ {{{8224}, {8224}}, ge::DT_FLOAT, ge::FORMAT_ND},
148+ {{{4112}, {4112}}, ge::DT_FLOAT, ge::FORMAT_ND},
149+ },
150+ {
151+ {{{20602}, {20602}}, ge::DT_FLOAT, ge::FORMAT_ND},
152+ },
153+ {
154+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(0)},
155+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
156+ },
157+ {3}, {1}, &compileInfo);
158+ uint64_t expectTilingKey = 2124;
159+ std::vector<size_t> expectWorkspaces = {16777216};
160+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
161+}
162+ 
163+TEST_F(ConcatDTiling, ConcatD_tiling_UT_one_axis_concat_simt_same_shape_no_align_float)
164+{
165+ optiling::ConcatDCompileInfo compileInfo;
166+ compileInfo.totalCoreNum = 64;
167+ compileInfo.ubSize = 253952;
168+ gert::TilingContextPara tilingContextPara(
169+ "ConcatD",
170+ {
171+ {{{12289}, {12289}}, ge::DT_FLOAT, ge::FORMAT_ND},
172+ {{{12289}, {12289}}, ge::DT_FLOAT, ge::FORMAT_ND},
173+ {{{12289}, {12289}}, ge::DT_FLOAT, ge::FORMAT_ND},
174+ },
175+ {
176+ {{{36867}, {36867}}, ge::DT_FLOAT, ge::FORMAT_ND},
177+ },
178+ {
179+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(0)},
180+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
181+ },
182+ {3}, {1}, &compileInfo);
183+ uint64_t expectTilingKey = 2214;
184+ std::vector<size_t> expectWorkspaces = {16777216};
185+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
186+}
187+ 
188+TEST_F(ConcatDTiling, ConcatD_tiling_UT_zero_axis_diff_shape_no_align_float)
189+{
190+ optiling::ConcatDCompileInfo compileInfo;
191+ compileInfo.totalCoreNum = 64;
192+ compileInfo.ubSize = 253952;
193+ gert::TilingContextPara tilingContextPara(
194+ "ConcatD",
195+ {
196+ {{{8224}, {8224}}, ge::DT_FLOAT, ge::FORMAT_ND},
197+ {{{8223}, {8223}}, ge::DT_FLOAT, ge::FORMAT_ND},
198+ {{{3223}, {3223}}, ge::DT_FLOAT, ge::FORMAT_ND},
199+ },
200+ {
201+ {{{19670}, {19670}}, ge::DT_FLOAT, ge::FORMAT_ND},
202+ },
203+ {
204+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(0)},
205+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
206+ },
207+ {3}, {1}, &compileInfo);
208+ uint64_t expectTilingKey = 2224;
209+ std::vector<size_t> expectWorkspaces = {16777216};
210+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
211+}
212+ 
213+TEST_F(ConcatDTiling, ConcatD_tiling_UT_one_axis_diff_shape_no_align_float)
214+{
215+ optiling::ConcatDCompileInfo compileInfo;
216+ compileInfo.totalCoreNum = 64;
217+ compileInfo.ubSize = 253952;
218+ gert::TilingContextPara tilingContextPara(
219+ "ConcatD",
220+ {
221+ {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},
222+ {{{8223, 33}, {8223, 33}}, ge::DT_FLOAT, ge::FORMAT_ND},
223+ {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},
224+ },
225+ {
226+ {{{24669, 95}, {24669, 95}}, ge::DT_FLOAT, ge::FORMAT_ND},
227+ },
228+ {
229+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
230+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
231+ },
232+ {3}, {1}, &compileInfo);
233+ uint64_t expectTilingKey = 12224;
234+ std::vector<size_t> expectWorkspaces = {16777216};
235+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
236+}
237+ 
238+TEST_F(ConcatDTiling, ConcatD_tiling_UT_one_axis_diff_shape_no_align_int8)
239+{
240+ optiling::ConcatDCompileInfo compileInfo;
241+ compileInfo.totalCoreNum = 64;
242+ compileInfo.ubSize = 253952;
243+ gert::TilingContextPara tilingContextPara(
244+ "ConcatD",
245+ {
246+ {{{8223, 31}, {8223, 31}}, ge::DT_INT8, ge::FORMAT_ND},
247+ {{{8223, 32}, {8223, 32}}, ge::DT_INT8, ge::FORMAT_ND},
248+ {{{8223, 31}, {8223, 31}}, ge::DT_INT8, ge::FORMAT_ND},
249+ },
250+ {
251+ {{{24669, 94}, {24669, 94}}, ge::DT_INT8, ge::FORMAT_ND},
252+ },
253+ {
254+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
255+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
256+ },
257+ {3}, {1}, &compileInfo);
258+ uint64_t expectTilingKey = 12221;
259+ std::vector<size_t> expectWorkspaces = {16777216};
260+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
261+}
262+ 
263+TEST_F(ConcatDTiling, ConcatD_tiling_UT_one_axis_diff_shape_no_align_int64)
264+{
265+ optiling::ConcatDCompileInfo compileInfo;
266+ compileInfo.totalCoreNum = 64;
267+ compileInfo.ubSize = 253952;
268+ gert::TilingContextPara tilingContextPara(
269+ "ConcatD",
270+ {
271+ {{{8223, 31}, {8223, 31}}, ge::DT_INT64, ge::FORMAT_ND},
272+ {{{8223, 32}, {8223, 32}}, ge::DT_INT64, ge::FORMAT_ND},
273+ {{{8223, 31}, {8223, 31}}, ge::DT_INT64, ge::FORMAT_ND},
274+ },
275+ {
276+ {{{24669, 94}, {24669, 94}}, ge::DT_INT64, ge::FORMAT_ND},
277+ },
278+ {
279+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
280+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
281+ },
282+ {3}, {1}, &compileInfo);
283+ uint64_t expectTilingKey = 12228;
284+ std::vector<size_t> expectWorkspaces = {16777216};
285+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
286+}
287+ 
288+TEST_F(ConcatDTiling, ConcatD_tiling_UT_one_axis_same_shape_no_align_float)
289+{
290+ optiling::ConcatDCompileInfo compileInfo;
291+ compileInfo.totalCoreNum = 64;
292+ compileInfo.ubSize = 253952;
293+ gert::TilingContextPara tilingContextPara(
294+ "ConcatD",
295+ {
296+ {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},
297+ {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},
298+ {{{8223, 31}, {8223, 31}}, ge::DT_FLOAT, ge::FORMAT_ND},
299+ },
300+ {
301+ {{{24669, 93}, {24669, 93}}, ge::DT_FLOAT, ge::FORMAT_ND},
302+ },
303+ {
304+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
305+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
306+ },
307+ {3}, {1}, &compileInfo);
308+ uint64_t expectTilingKey = 12314;
309+ std::vector<size_t> expectWorkspaces = {16777216};
310+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
311+}
312+ 
313+TEST_F(ConcatDTiling, ConcatD_tiling_UT_one_axis_same_shape_no_align_int8)
314+{
315+ optiling::ConcatDCompileInfo compileInfo;
316+ compileInfo.totalCoreNum = 64;
317+ compileInfo.ubSize = 253952;
318+ gert::TilingContextPara tilingContextPara(
319+ "ConcatD",
320+ {
321+ {{{8223, 31}, {8223, 31}}, ge::DT_INT8, ge::FORMAT_ND},
322+ {{{8223, 31}, {8223, 31}}, ge::DT_INT8, ge::FORMAT_ND},
323+ {{{8223, 31}, {8223, 31}}, ge::DT_INT8, ge::FORMAT_ND},
324+ },
325+ {
326+ {{{24669, 93}, {24669, 93}}, ge::DT_INT8, ge::FORMAT_ND},
327+ },
328+ {
329+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
330+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
331+ },
332+ {3}, {1}, &compileInfo);
333+ uint64_t expectTilingKey = 12311;
334+ std::vector<size_t> expectWorkspaces = {16777216};
335+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
336+}
337+ 
338+TEST_F(ConcatDTiling, ConcatD_tiling_UT_one_axis_same_shape_no_align_int64)
339+{
340+ optiling::ConcatDCompileInfo compileInfo;
341+ compileInfo.totalCoreNum = 64;
342+ compileInfo.ubSize = 253952;
343+ gert::TilingContextPara tilingContextPara(
344+ "ConcatD",
345+ {
346+ {{{8223, 31}, {8223, 31}}, ge::DT_INT64, ge::FORMAT_ND},
347+ {{{8223, 31}, {8223, 31}}, ge::DT_INT64, ge::FORMAT_ND},
348+ {{{8223, 31}, {8223, 31}}, ge::DT_INT64, ge::FORMAT_ND},
349+ },
350+ {
351+ {{{24669, 93}, {24669, 93}}, ge::DT_INT64, ge::FORMAT_ND},
352+ },
353+ {
354+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
355+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
356+ },
357+ {3}, {1}, &compileInfo);
358+ uint64_t expectTilingKey = 12214;
359+ std::vector<size_t> expectWorkspaces = {16777216};
360+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
361+}
362+ 
363+TEST_F(ConcatDTiling, ConcatD_tiling_UT_error_dtype)
364+{
365+ optiling::ConcatDCompileInfo compileInfo;
366+ compileInfo.totalCoreNum = 64;
367+ compileInfo.ubSize = 253952;
368+ gert::TilingContextPara tilingContextPara(
369+ "ConcatD",
370+ {
371+ {{{8223, 31}, {8223, 31}}, ge::DT_COMPLEX128, ge::FORMAT_ND},
372+ {{{8223, 32}, {8223, 32}}, ge::DT_COMPLEX128, ge::FORMAT_ND},
373+ {{{8223, 31}, {8223, 31}}, ge::DT_COMPLEX128, ge::FORMAT_ND},
374+ },
375+ {
376+ {{{24669, 94}, {24669, 94}}, ge::DT_COMPLEX128, ge::FORMAT_ND},
377+ },
378+ {
379+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
380+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
381+ },
382+ {3}, {1}, &compileInfo);
383+ ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED);
384+}
385+ 
386+TEST_F(ConcatDTiling, ConcatD_tiling_UT_error_dim)
387+{
388+ optiling::ConcatDCompileInfo compileInfo;
389+ compileInfo.totalCoreNum = 64;
390+ compileInfo.ubSize = 253952;
391+ gert::TilingContextPara tilingContextPara(
392+ "ConcatD",
393+ {
394+ {{{8223, 31}, {8223, 31}}, ge::DT_COMPLEX64, ge::FORMAT_ND},
395+ {{{8223, 32}, {8223, 32}}, ge::DT_COMPLEX64, ge::FORMAT_ND},
396+ {{{8223, 31}, {8223, 31}}, ge::DT_COMPLEX64, ge::FORMAT_ND},
397+ },
398+ {
399+ {{{24669, 94}, {24669, 94}}, ge::DT_COMPLEX64, ge::FORMAT_ND},
400+ },
401+ {
402+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(5)},
403+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
404+ },
405+ {3}, {1}, &compileInfo);
406+ ExecuteTestCase(tilingContextPara, ge::GRAPH_FAILED);
407+}
408+ 
409+TEST_F(ConcatDTiling, ConcatD_tiling_UT_for_more_core)
410+{
411+ optiling::ConcatDCompileInfo compileInfo;
412+ compileInfo.totalCoreNum = 73;
413+ compileInfo.ubSize = 253952;
414+ gert::TilingContextPara tilingContextPara(
415+ "ConcatD",
416+ {
417+ {{{8223, 31}, {8223, 31}}, ge::DT_INT8, ge::FORMAT_ND},
418+ {{{8223, 32}, {8223, 32}}, ge::DT_INT8, ge::FORMAT_ND},
419+ {{{8223, 31}, {8223, 31}}, ge::DT_INT8, ge::FORMAT_ND},
420+ },
421+ {
422+ {{{24669, 94}, {24669, 94}}, ge::DT_INT8, ge::FORMAT_ND},
423+ },
424+ {
425+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
426+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
427+ },
428+ {3}, {1}, &compileInfo);
429+ uint64_t expectTilingKey = 12221;
430+ std::vector<size_t> expectWorkspaces = {16777216};
431+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
432+}
433+ 
434+TEST_F(ConcatDTiling, ConcatD_tiling_UT_one_axis_concat_simt_no_align_float)
435+{
436+ optiling::ConcatDCompileInfo compileInfo;
437+ compileInfo.totalCoreNum = 64;
438+ compileInfo.ubSize = 253952;
439+ gert::TilingContextPara::TensorDescription tensorInput1 = {{{8224}, {8224}}, ge::DT_FLOAT, ge::FORMAT_ND};
440+ gert::TilingContextPara::TensorDescription tensorInput2 = {{{8225}, {8225}}, ge::DT_FLOAT, ge::FORMAT_ND};
441+ std::vector<gert::TilingContextPara::TensorDescription> tensorDesc = {tensorInput1, tensorInput2};
442+ tensorDesc.insert(tensorDesc.end(), 32, tensorInput1);
443+ gert::TilingContextPara tilingContextPara(
444+ "ConcatD", tensorDesc,
445+ {
446+ {{{271393}, {271393}}, ge::DT_FLOAT, ge::FORMAT_ND},
447+ },
448+ {
449+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(0)},
450+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(34)},
451+ },
452+ {tensorDesc.size()}, {1}, &compileInfo);
453+ uint64_t expectTilingKey = 30004;
454+ std::vector<size_t> expectWorkspaces = {16777216};
455+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
456+}
457+ 
458+TEST_F(ConcatDTiling, ConcatD_tiling_UT_one_axis_concat_simt_diff_shape_no_align_int64)
459+{
460+ optiling::ConcatDCompileInfo compileInfo;
461+ compileInfo.totalCoreNum = 64;
462+ compileInfo.ubSize = 253952;
463+ gert::TilingContextPara::TensorDescription tensorInput1 = {{{8, 31}, {8, 31}}, ge::DT_INT64, ge::FORMAT_ND};
464+ gert::TilingContextPara::TensorDescription tensorInput2 = {{{8, 32}, {8, 32}}, ge::DT_INT64, ge::FORMAT_ND};
465+ std::vector<gert::TilingContextPara::TensorDescription> tensorDesc = {tensorInput1, tensorInput2};
466+ tensorDesc.insert(tensorDesc.end(), 32, tensorInput1);
467+ gert::TilingContextPara tilingContextPara(
468+ "ConcatD", tensorDesc,
469+ {
470+ {{{8, 1022}, {8, 1022}}, ge::DT_INT64, ge::FORMAT_ND},
471+ },
472+ {
473+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
474+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(34)},
475+ },
476+ {tensorDesc.size()}, {1}, &compileInfo);
477+ uint64_t expectTilingKey = 30008;
478+ std::vector<size_t> expectWorkspaces = {16777216};
479+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
480+}
481+ 
482+TEST_F(ConcatDTiling, ConcatD_tiling_UT_one_axis_concat_simt_diff_shape_no_align_int8)
483+{
484+ optiling::ConcatDCompileInfo compileInfo;
485+ compileInfo.totalCoreNum = 64;
486+ compileInfo.ubSize = 253952;
487+ gert::TilingContextPara::TensorDescription tensorInput1 = {{{8, 31}, {8, 31}}, ge::DT_INT32, ge::FORMAT_ND};
488+ gert::TilingContextPara::TensorDescription tensorInput2 = {{{8, 30}, {8, 30}}, ge::DT_INT32, ge::FORMAT_ND};
489+ std::vector<gert::TilingContextPara::TensorDescription> tensorDesc = {tensorInput1, tensorInput2};
490+ tensorDesc.insert(tensorDesc.end(), 32, tensorInput1);
491+ gert::TilingContextPara tilingContextPara(
492+ "ConcatD", tensorDesc,
493+ {
494+ {{{8, 1022}, {8, 1022}}, ge::DT_INT32, ge::FORMAT_ND},
495+ },
496+ {
497+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
498+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(34)},
499+ },
500+ {tensorDesc.size()}, {1}, &compileInfo);
501+ uint64_t expectTilingKey = 30004;
502+ std::vector<size_t> expectWorkspaces = {16777216};
503+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
504+}
@@ -0,0 +1,268 @@
1+/**
2+ * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#include <gtest/gtest.h>
12+#include <iostream>
13+#include <vector>
14+#include "infershape_context_faker.h"
15+#include "infershape_case_executor.h"
16+ 
17+class ConcatDInfershapeTest : public testing::Test {
18+protected:
19+ static void SetUpTestCase()
20+ {
21+ std::cout << "ConcatDInfershapeTest SetUp" << std::endl;
22+ }
23+ 
24+ static void TearDownTestCase()
25+ {
26+ std::cout << "ConcatDInfershapeTest TearDown" << std::endl;
27+ }
28+};
29+ 
30+TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16)
31+{
32+ gert::InfershapeContextPara infershapeContextPara(
33+ "ConcatD",
34+ {
35+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
36+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
37+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
38+ },
39+ {
40+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
41+ },
42+ {
43+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},
44+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
45+ },
46+ {3}, {1});
47+ std::vector<std::vector<int64_t>> expectOutputShape = {
48+ {2, 100, 12},
49+ };
50+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
51+}
52+ 
53+TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_n1)
54+{
55+ gert::InfershapeContextPara infershapeContextPara(
56+ "ConcatD",
57+ {
58+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
59+ },
60+ {
61+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
62+ },
63+ {
64+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},
65+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
66+ },
67+ {1}, {1});
68+ std::vector<std::vector<int64_t>> expectOutputShape = {
69+ {2, 100, 4},
70+ };
71+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
72+}
73+ 
74+TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_shape)
75+{
76+ gert::InfershapeContextPara infershapeContextPara(
77+ "ConcatD",
78+ {
79+ {{{2, 100, 1}, {2, 100, 1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
80+ {{{2, 100, 24}, {2, 100, 24}}, ge::DT_FLOAT16, ge::FORMAT_ND},
81+ {{{2, 100, 34}, {2, 100, 34}}, ge::DT_FLOAT16, ge::FORMAT_ND},
82+ },
83+ {
84+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
85+ },
86+ {
87+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},
88+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
89+ },
90+ {3}, {1});
91+ std::vector<std::vector<int64_t>> expectOutputShape = {
92+ {2, 100, 59},
93+ };
94+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
95+}
96+ 
97+TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_errorshape)
98+{
99+ gert::InfershapeContextPara infershapeContextPara(
100+ "ConcatD",
101+ {
102+ {{{2, 100, 1}, {2, 100, 1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
103+ {{{2, 100, 24}, {2, 100, 24}}, ge::DT_FLOAT16, ge::FORMAT_ND},
104+ {{{2, 100, 34}, {2, 100, 34}}, ge::DT_FLOAT16, ge::FORMAT_ND},
105+ },
106+ {
107+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
108+ },
109+ {
110+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
111+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
112+ },
113+ {3}, {1});
114+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_FAILED);
115+}
116+ 
117+TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_errordim)
118+{
119+ gert::InfershapeContextPara infershapeContextPara(
120+ "ConcatD",
121+ {
122+ {{{2, 100, 1}, {2, 100, 1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
123+ {{{2, 100, 24}, {2, 100, 24}}, ge::DT_FLOAT16, ge::FORMAT_ND},
124+ {{{2, 100, 34}, {2, 100, 34}}, ge::DT_FLOAT16, ge::FORMAT_ND},
125+ },
126+ {
127+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
128+ },
129+ {
130+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(5)},
131+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
132+ },
133+ {3}, {1});
134+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_FAILED);
135+}
136+ 
137+TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_errorshapdim)
138+{
139+ gert::InfershapeContextPara infershapeContextPara(
140+ "ConcatD",
141+ {
142+ {{{2, 100, 1}, {2, 100, 1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
143+ {{{2, 100, 2, 4}, {2, 100, 2, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
144+ {{{2, 100, 34}, {2, 100, 34}}, ge::DT_FLOAT16, ge::FORMAT_ND},
145+ },
146+ {
147+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
148+ },
149+ {
150+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},
151+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
152+ },
153+ {3}, {1});
154+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_FAILED);
155+}
156+ 
157+TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_fp16_scalar)
158+{
159+ gert::InfershapeContextPara infershapeContextPara(
160+ "ConcatD",
161+ {
162+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
163+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
164+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
165+ },
166+ {
167+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
168+ },
169+ {
170+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},
171+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
172+ },
173+ {3}, {1});
174+ std::vector<std::vector<int64_t>> expectOutputShape = {};
175+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
176+}
177+ 
178+TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_no_shape_range_fp16)
179+{
180+ gert::InfershapeContextPara infershapeContextPara(
181+ "ConcatD",
182+ {
183+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
184+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
185+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
186+ },
187+ {
188+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
189+ },
190+ {
191+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},
192+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
193+ },
194+ {3}, {1});
195+ std::vector<std::vector<int64_t>> expectOutputShape = {
196+ {2, 100, 12},
197+ };
198+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
199+}
200+ 
201+TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_no_shape_range_mix_fp16)
202+{
203+ gert::InfershapeContextPara infershapeContextPara(
204+ "ConcatD",
205+ {
206+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
207+ {{{2, 100, 4}, {2, 100, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
208+ {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
209+ },
210+ {
211+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
212+ },
213+ {
214+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},
215+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
216+ },
217+ {3}, {1});
218+ std::vector<std::vector<int64_t>> expectOutputShape = {
219+ {2, 100, 12},
220+ };
221+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
222+}
223+ 
224+TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_dynamic_fp16)
225+{
226+ gert::InfershapeContextPara infershapeContextPara(
227+ "ConcatD",
228+ {
229+ {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
230+ {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
231+ {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
232+ },
233+ {
234+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
235+ },
236+ {
237+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},
238+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
239+ },
240+ {3}, {1});
241+ std::vector<std::vector<int64_t>> expectOutputShape = {
242+ {2, 100, 12},
243+ };
244+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
245+}
246+ 
247+TEST_F(ConcatDInfershapeTest, concat_d_infer_shape_dynamic2_fp16)
248+{
249+ gert::InfershapeContextPara infershapeContextPara(
250+ "ConcatD",
251+ {
252+ {{{2, 100, 4}, {-1, -1, 5}}, ge::DT_FLOAT16, ge::FORMAT_ND},
253+ {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
254+ {{{2, 100, 4}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
255+ },
256+ {
257+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
258+ },
259+ {
260+ {"concat_dim", Ops::Math::AnyValue::CreateFrom<int64_t>(-1)},
261+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
262+ },
263+ {3}, {1});
264+ std::vector<std::vector<int64_t>> expectOutputShape = {
265+ {2, 100, 12},
266+ };
267+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
268+}
@@ -17,6 +17,7 @@
17#include "op_api_ut_common/op_api_ut.h"17#include "op_api_ut_common/op_api_ut.h"
18#include "op_api_ut_common/scalar_desc.h"18#include "op_api_ut_common/scalar_desc.h"
19#include "op_api_ut_common/tensor_desc.h"19#include "op_api_ut_common/tensor_desc.h"
20+#include "opdev/platform.h"
20 21 
21using namespace std;22using namespace std;
22 23 
@@ -31,6 +32,11 @@ protected:
31 {32 {
32 cout << "l2_stack_test TearDown" << endl;33 cout << "l2_stack_test TearDown" << endl;
33 }34 }
35+ 
36+ void TearDown() override
37+ {
38+ op::SetPlatformSocVersion(op::SocVersion::ASCEND910B);
39+ }
34};40};
35 41 
36// 输入为空指针42// 输入为空指针
@@ -475,20 +481,21 @@ TEST_F(l2_stack_test, l2_stack_test_one_empty_tensor)
475 EXPECT_EQ(aclRet, ACL_SUCCESS);481 EXPECT_EQ(aclRet, ACL_SUCCESS);
476}482}
477 483 
478-// // 正常路径,bfloat16484+// 正常路径,bfloat16
479-// TEST_F(l2_stack_test, ascend310P_l2_stack_test_dtype_bfloat16)485+TEST_F(l2_stack_test, ascend310P_l2_stack_test_dtype_bfloat16)
480-// {486+{
481-// auto tensor_1_desc =487+ op::SetPlatformSocVersion(op::SocVersion::ASCEND310P);
482-// TensorDesc({2, 5}, ACL_BF16, ACL_FORMAT_ND).Value(vector<float>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10});488+ auto tensor_1_desc =
483-// auto tensor_2_desc =489+ TensorDesc({2, 5}, ACL_BF16, ACL_FORMAT_ND).Value(vector<float>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
484-// TensorDesc({2, 5}, ACL_BF16, ACL_FORMAT_ND).Value(vector<float>{11, 12, 13, 14, 15, 16, 17, 18, 19, 20});490+ auto tensor_2_desc =
485-// auto out_tensor_desc = TensorDesc({2, 2, 5}, ACL_BF16, ACL_FORMAT_ND);491+ TensorDesc({2, 5}, ACL_BF16, ACL_FORMAT_ND).Value(vector<float>{11, 12, 13, 14, 15, 16, 17, 18, 19, 20});
486-// auto tensor_list_desc = TensorListDesc({tensor_1_desc, tensor_2_desc});492+ auto out_tensor_desc = TensorDesc({2, 2, 5}, ACL_BF16, ACL_FORMAT_ND);
487-// int64_t dim = 0;493+ auto tensor_list_desc = TensorListDesc({tensor_1_desc, tensor_2_desc});
494+ int64_t dim = 0;
488 495 
489-// auto ut = OP_API_UT(aclnnStack, INPUT(tensor_list_desc, dim), OUTPUT(out_tensor_desc));496+ auto ut = OP_API_UT(aclnnStack, INPUT(tensor_list_desc, dim), OUTPUT(out_tensor_desc));
490 497 
491-// uint64_t workspace_size = 0;498+ uint64_t workspace_size = 0;
492-// aclnnStatus aclRet = ut.TestGetWorkspaceSize(&workspace_size);499+ aclnnStatus aclRet = ut.TestGetWorkspaceSize(&workspace_size);
493-// EXPECT_EQ(aclRet, ACLNN_ERR_PARAM_INVALID);500+ EXPECT_EQ(aclRet, ACLNN_ERR_PARAM_INVALID);
494-// }501+}
@@ -0,0 +1,217 @@
1+/**
2+ * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#include "../../../../op_host/arch35/pack_tiling_arch35.h"
12+#include <iostream>
13+#include <vector>
14+#include <gtest/gtest.h>
15+#include "tiling_context_faker.h"
16+#include "tiling_case_executor.h"
17+ 
18+class PackTilingTest : public testing::Test {
19+protected:
20+ static void SetUpTestCase()
21+ {
22+ std::cout << "PackTilingTest SetUp" << std::endl;
23+ }
24+ 
25+ static void TearDownTestCase()
26+ {
27+ std::cout << "PackTilingTest TearDown" << std::endl;
28+ }
29+};
30+ 
31+TEST_F(PackTilingTest, Pack_asc_tiling_UT_notfirst_axis_align_bitwidth4_01)
32+{
33+ optiling::ConcatDCompileInfo compileInfo;
34+ compileInfo.totalCoreNum = 64;
35+ compileInfo.ubSize = 253952;
36+ gert::TilingContextPara tilingContextPara(
37+ "Pack",
38+ {
39+ {{{2, 4, 4}, {2, 4, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},
40+ {{{2, 4, 4}, {2, 4, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},
41+ {{{2, 4, 4}, {2, 4, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},
42+ },
43+ {
44+ {{{2, 12, 4}, {2, 12, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},
45+ },
46+ {
47+ {"axis", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
48+ },
49+ {3}, {1}, &compileInfo);
50+ uint64_t expectTilingKey = 12114;
51+ std::vector<size_t> expectWorkspaces = {16777216};
52+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
53+}
54+ 
55+TEST_F(PackTilingTest, Pack_asc_tiling_UT_first_axis_align_bitwidth2_02)
56+{
57+ optiling::ConcatDCompileInfo compileInfo;
58+ compileInfo.totalCoreNum = 64;
59+ compileInfo.ubSize = 253952;
60+ gert::TilingContextPara tilingContextPara(
61+ "Pack",
62+ {
63+ {{{8192}, {8192}}, ge::DT_FLOAT16, ge::FORMAT_ND},
64+ {{{8192}, {8192}}, ge::DT_FLOAT16, ge::FORMAT_ND},
65+ {{{8192}, {8192}}, ge::DT_FLOAT16, ge::FORMAT_ND},
66+ },
67+ {
68+ {{{24576}, {24576}}, ge::DT_FLOAT16, ge::FORMAT_ND},
69+ },
70+ {
71+ {"axis", Ops::Math::AnyValue::CreateFrom<int64_t>(0)},
72+ },
73+ {3}, {1}, &compileInfo);
74+ uint64_t expectTilingKey = 2112;
75+ std::vector<size_t> expectWorkspaces = {16777216};
76+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
77+}
78+ 
79+TEST_F(PackTilingTest, Pack_asc_tiling_UT_notfirst_align_same_bitwidth2_03)
80+{
81+ optiling::ConcatDCompileInfo compileInfo;
82+ compileInfo.totalCoreNum = 64;
83+ compileInfo.ubSize = 253952;
84+ gert::TilingContextPara tilingContextPara(
85+ "Pack",
86+ {
87+ {{{31, 3, 2560}, {31, 3, 2560}}, ge::DT_FLOAT16, ge::FORMAT_ND},
88+ {{{31, 3, 2560}, {31, 3, 2560}}, ge::DT_FLOAT16, ge::FORMAT_ND},
89+ {{{31, 3, 2560}, {31, 3, 2560}}, ge::DT_FLOAT16, ge::FORMAT_ND},
90+ },
91+ {
92+ {{{31, 3, 7680}, {31, 3, 7680}}, ge::DT_FLOAT16, ge::FORMAT_ND},
93+ },
94+ {
95+ {"axis", Ops::Math::AnyValue::CreateFrom<int64_t>(2)},
96+ },
97+ {3}, {1}, &compileInfo);
98+ uint64_t expectTilingKey = 2112;
99+ std::vector<size_t> expectWorkspaces = {16777216};
100+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
101+}
102+ 
103+TEST_F(PackTilingTest, Pack_asc_tiling_UT_notfirst_axis_align_same_bitwidth8_04)
104+{
105+ optiling::ConcatDCompileInfo compileInfo;
106+ compileInfo.totalCoreNum = 64;
107+ compileInfo.ubSize = 253952;
108+ gert::TilingContextPara tilingContextPara(
109+ "Pack",
110+ {
111+ {{{16384, 2, 512}, {16384, 2, 512}}, ge::DT_INT64, ge::FORMAT_ND},
112+ {{{16384, 2, 512}, {16384, 2, 512}}, ge::DT_INT64, ge::FORMAT_ND},
113+ },
114+ {
115+ {{{16384, 4, 512}, {16384, 4, 512}}, ge::DT_INT64, ge::FORMAT_ND},
116+ },
117+ {
118+ {"axis", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
119+ },
120+ {2}, {1}, &compileInfo);
121+ uint64_t expectTilingKey = 20002;
122+ std::vector<size_t> expectWorkspaces = {16777216};
123+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
124+}
125+ 
126+TEST_F(PackTilingTest, Pack_asc_tiling_UT_notfirst_axis_align_same_bitwidth1_05)
127+{
128+ optiling::ConcatDCompileInfo compileInfo;
129+ compileInfo.totalCoreNum = 64;
130+ compileInfo.ubSize = 253952;
131+ gert::TilingContextPara tilingContextPara(
132+ "Pack",
133+ {
134+ {{{12, 1, 8, 128}, {12, 1, 8, 128}}, ge::DT_INT8, ge::FORMAT_ND},
135+ {{{12, 1, 8, 128}, {12, 1, 8, 128}}, ge::DT_INT8, ge::FORMAT_ND},
136+ },
137+ {
138+ {{{12, 1, 16, 128}, {12, 1, 16, 128}}, ge::DT_INT8, ge::FORMAT_ND},
139+ },
140+ {
141+ {"axis", Ops::Math::AnyValue::CreateFrom<int64_t>(2)},
142+ },
143+ {2}, {1}, &compileInfo);
144+ uint64_t expectTilingKey = 2111;
145+ std::vector<size_t> expectWorkspaces = {16777216};
146+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
147+}
148+ 
149+TEST_F(PackTilingTest, Pack_asc_tiling_UT_first_axis_align_same_bitwidth4_06)
150+{
151+ optiling::ConcatDCompileInfo compileInfo;
152+ compileInfo.totalCoreNum = 64;
153+ compileInfo.ubSize = 253952;
154+ gert::TilingContextPara tilingContextPara(
155+ "Pack",
156+ {
157+ {{{8192}, {8192}}, ge::DT_FLOAT, ge::FORMAT_ND},
158+ {{{8192}, {8192}}, ge::DT_FLOAT, ge::FORMAT_ND},
159+ {{{8192}, {8192}}, ge::DT_FLOAT, ge::FORMAT_ND},
160+ },
161+ {
162+ {{{24576}, {24576}}, ge::DT_FLOAT, ge::FORMAT_ND},
163+ },
164+ {
165+ {"axis", Ops::Math::AnyValue::CreateFrom<int64_t>(0)},
166+ },
167+ {3}, {1}, &compileInfo);
168+ uint64_t expectTilingKey = 2114;
169+ std::vector<size_t> expectWorkspaces = {16777216};
170+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
171+}
172+ 
173+TEST_F(PackTilingTest, Pack_asc_tiling_UT_first_axis_align_same_bitwidth1_07)
174+{
175+ optiling::ConcatDCompileInfo compileInfo;
176+ compileInfo.totalCoreNum = 64;
177+ compileInfo.ubSize = 253952;
178+ gert::TilingContextPara tilingContextPara(
179+ "Pack",
180+ {
181+ {{{12, 1, 8, 128}, {12, 1, 8, 128}}, ge::DT_INT8, ge::FORMAT_ND},
182+ {{{12, 1, 8, 128}, {12, 1, 8, 128}}, ge::DT_INT8, ge::FORMAT_ND},
183+ },
184+ {
185+ {{{24, 1, 8, 128}, {24, 1, 8, 128}}, ge::DT_INT8, ge::FORMAT_ND},
186+ },
187+ {
188+ {"axis", Ops::Math::AnyValue::CreateFrom<int64_t>(0)},
189+ },
190+ {2}, {1}, &compileInfo);
191+ uint64_t expectTilingKey = 2111;
192+ std::vector<size_t> expectWorkspaces = {16777216};
193+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
194+}
195+ 
196+TEST_F(PackTilingTest, Pack_asc_tiling_UT_first_axis_align_same_bitwidth8_08)
197+{
198+ optiling::ConcatDCompileInfo compileInfo;
199+ compileInfo.totalCoreNum = 64;
200+ compileInfo.ubSize = 253952;
201+ gert::TilingContextPara tilingContextPara(
202+ "Pack",
203+ {
204+ {{{16384, 512, 2}, {16384, 512, 2}}, ge::DT_INT64, ge::FORMAT_ND},
205+ {{{16384, 512, 2}, {16384, 512, 2}}, ge::DT_INT64, ge::FORMAT_ND},
206+ },
207+ {
208+ {{{32768, 512, 2}, {32768, 512, 2}}, ge::DT_INT64, ge::FORMAT_ND},
209+ },
210+ {
211+ {"axis", Ops::Math::AnyValue::CreateFrom<int64_t>(0)},
212+ },
213+ {2}, {1}, &compileInfo);
214+ uint64_t expectTilingKey = 20002;
215+ std::vector<size_t> expectWorkspaces = {16777216};
216+ ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectWorkspaces);
217+}
@@ -0,0 +1,178 @@
1+/**
2+ * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4+ * CANN Open Software License Agreement Version 2.0 (the "License").
5+ * Please refer to the License for details. You may not use this file except in compliance with the License.
6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8+ * See LICENSE in the root of the software repository for the full text of the License.
9+ */
10+ 
11+#include <gtest/gtest.h>
12+#include <iostream>
13+#include <vector>
14+#include "infershape_context_faker.h"
15+#include "infershape_case_executor.h"
16+ 
17+class PackInferTest : public testing::Test {
18+protected:
19+ static void SetUpTestCase()
20+ {
21+ std::cout << "PackInferTest SetUp" << std::endl;
22+ }
23+ 
24+ static void TearDownTestCase()
25+ {
26+ std::cout << "PackInferTest TearDown" << std::endl;
27+ }
28+};
29+ 
30+TEST_F(PackInferTest, pack_infer_test_1)
31+{
32+ gert::InfershapeContextPara infershapeContextPara(
33+ "Pack",
34+ {
35+ {{{-1, -1}, {-1, -1}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},
36+ {{{-1, -1}, {-1, -1}}, ge::DT_FLOAT16, ge::FORMAT_NCHW},
37+ },
38+ {
39+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
40+ },
41+ {
42+ {"axis", Ops::Math::AnyValue::CreateFrom<int64_t>(0)},
43+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(2)},
44+ },
45+ {2}, {1});
46+ std::vector<std::vector<int64_t>> expectOutputShape = {
47+ {2, -1, -1},
48+ };
49+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
50+}
51+ 
52+TEST_F(PackInferTest, pack_infer_test_2)
53+{
54+ gert::InfershapeContextPara infershapeContextPara(
55+ "Pack",
56+ {
57+ {{{-1, -1}, {-1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
58+ {{{-1, -1}, {-1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
59+ },
60+ {
61+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
62+ },
63+ {
64+ {"axis", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
65+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(2)},
66+ },
67+ {2}, {1});
68+ std::vector<std::vector<int64_t>> expectOutputShape = {
69+ {-1, 2, -1},
70+ };
71+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
72+}
73+ 
74+TEST_F(PackInferTest, pack_infer_test_3rt)
75+{
76+ gert::InfershapeContextPara infershapeContextPara(
77+ "Pack",
78+ {
79+ {{{3, -1, -1, 5}, {3, -1, -1, 5}}, ge::DT_FLOAT16, ge::FORMAT_ND},
80+ {{{3, -1, -1, 5}, {3, -1, -1, 5}}, ge::DT_FLOAT16, ge::FORMAT_ND},
81+ {{{3, -1, -1, 5}, {3, -1, -1, 5}}, ge::DT_FLOAT16, ge::FORMAT_ND},
82+ },
83+ {
84+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
85+ },
86+ {
87+ {"axis", Ops::Math::AnyValue::CreateFrom<int64_t>(0)},
88+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
89+ },
90+ {3}, {1});
91+ std::vector<std::vector<int64_t>> expectOutputShape = {
92+ {3, 3, -1, -1, 5},
93+ };
94+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
95+}
96+ 
97+TEST_F(PackInferTest, pack_infer_test_4rt)
98+{
99+ gert::InfershapeContextPara infershapeContextPara(
100+ "Pack",
101+ {
102+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
103+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
104+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
105+ },
106+ {
107+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
108+ },
109+ {
110+ {"axis", Ops::Math::AnyValue::CreateFrom<int64_t>(2)},
111+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
112+ },
113+ {3}, {1});
114+ std::vector<std::vector<int64_t>> expectOutputShape = {
115+ {3},
116+ };
117+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
118+}
119+ 
120+TEST_F(PackInferTest, pack_infer_test_6)
121+{
122+ gert::InfershapeContextPara infershapeContextPara(
123+ "Pack",
124+ {
125+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
126+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
127+ },
128+ {
129+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
130+ },
131+ {
132+ {"axis", Ops::Math::AnyValue::CreateFrom<int64_t>(0)},
133+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(2)},
134+ },
135+ {2}, {1});
136+ std::vector<std::vector<int64_t>> expectOutputShape = {
137+ {2},
138+ };
139+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
140+}
141+ 
142+TEST_F(PackInferTest, pack_infer_test_7)
143+{
144+ gert::InfershapeContextPara infershapeContextPara(
145+ "Pack",
146+ {
147+ {{{3, -1, -1, 5}, {3, -1, -1, 5}}, ge::DT_FLOAT16, ge::FORMAT_ND},
148+ {{{3, -1, -1, 5}, {3, -1, -1, 5}}, ge::DT_FLOAT16, ge::FORMAT_ND},
149+ {{}, ge::DT_FLOAT16, ge::FORMAT_ND},
150+ },
151+ {
152+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
153+ },
154+ {
155+ {"axis", Ops::Math::AnyValue::CreateFrom<int64_t>(2)},
156+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(3)},
157+ },
158+ {3}, {1});
159+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_FAILED);
160+}
161+ 
162+TEST_F(PackInferTest, pack_infer_test_8)
163+{
164+ gert::InfershapeContextPara infershapeContextPara(
165+ "Pack",
166+ {
167+ {{{3, 2, 2, 5}, {3, 2, 2, 5}}, ge::DT_FLOAT16, ge::FORMAT_ND},
168+ },
169+ {
170+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
171+ },
172+ {
173+ {"axis", Ops::Math::AnyValue::CreateFrom<int64_t>(10)},
174+ {"N", Ops::Math::AnyValue::CreateFrom<int64_t>(1)},
175+ },
176+ {1}, {1});
177+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_FAILED);
178+}