已合并
feat(graph): 补齐26个算子InferDataType交付件(op_graph/*_graph_infer.cpp) #5904
feat(graph): 补齐26个算子InferDataType交付件(op_graph/*_graph_infer.cpp) #5904
已合并
hahaha22创建于 9月21日
共 31 个文件变更+1031-202
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(ClipByValue).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -17,5 +17,12 @@
17 17 
18using namespace ge;18using namespace ge;
19namespace ops {19namespace ops {
20-IMPL_OP_INFERSHAPE(ClipByValue).InferShape(Ops::Base::InferShape4Broadcast);20+constexpr size_t INPUT_NUM_THREE = 3;
21-} // namespace ops21+ 
22+static ge::graphStatus InferShape4ClipByValue(gert::InferShapeContext* context)
23+{
24+ return Ops::Base::InferShape4Broadcast(context, INPUT_NUM_THREE);
25+}
26+ 
27+IMPL_OP_INFERSHAPE(ClipByValue).InferShape(InferShape4ClipByValue);
28+} // namespace ops
@@ -21,205 +21,187 @@ using namespace ge;
21 21 
22class ClipByValueTest : public testing::Test {22class ClipByValueTest : public testing::Test {
23protected:23protected:
24- static void SetUpTestCase()24+ static void SetUpTestCase() { std::cout << "ClipByValueTest SetUp" << std::endl; }
25- {
26- std::cout << "ClipByValueTest SetUp" << std::endl;
27- }
28 25 
29- static void TearDownTestCase()26+ static void TearDownTestCase() { std::cout << "ClipByValueTest TearDown" << std::endl; }
30- {
31- std::cout << "ClipByValueTest TearDown" << std::endl;
32- }
33};27};
34 28 
35TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_2)29TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_2)
36{30{
37- gert::InfershapeContextPara infershapeContextPara(31+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
38- "ClipByValue",32+ {
39- {33+ {{{1}, {1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
40- {{{1}, {1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},34+ {{{-1}, {-1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
41- {{{-1}, {-1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},35+ {{{-1}, {-1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
42- {{{-1}, {-1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},36+ },
43- },37+ {
44- {38+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
45- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},39+ });
46- });
47 std::vector<std::vector<int64_t>> expectOutputShape = {{-1}};40 std::vector<std::vector<int64_t>> expectOutputShape = {{-1}};
48 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);41 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
49}42}
50 43 
51TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_3)44TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_3)
52{45{
53- gert::InfershapeContextPara infershapeContextPara(46+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
54- "ClipByValue",47+ {
55- {48+ {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_NHWC},
56- {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_NHWC},49+ {{{-1}, {-1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
57- {{{-1}, {-1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},50+ {{{-1}, {-1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
58- {{{-1}, {-1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},51+ },
59- },52+ {
60- {53+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
61- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},54+ });
62- });
63 std::vector<std::vector<int64_t>> expectOutputShape = {};55 std::vector<std::vector<int64_t>> expectOutputShape = {};
64 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);56 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
65}57}
66 58 
67TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_4)59TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_4)
68{60{
69- gert::InfershapeContextPara infershapeContextPara(61+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
70- "ClipByValue",62+ {
71- {63+ {{{-2}, {-2}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
72- {{{-2}, {-2}}, ge::DT_FLOAT, ge::FORMAT_NHWC},64+ {{{-1}, {-1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
73- {{{-1}, {-1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},65+ {{{-1}, {-1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
74- {{{-1}, {-1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},66+ },
75- },67+ {
76- {68+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
77- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},69+ });
78- });
79 std::vector<std::vector<int64_t>> expectOutputShape = {};70 std::vector<std::vector<int64_t>> expectOutputShape = {};
80 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);71 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
81}72}
82 73 
83TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_5)74TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_5)
84{75{
85- gert::InfershapeContextPara infershapeContextPara(76+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
86- "ClipByValue",77+ {
87- {78+ {{{3, 1, 5}, {3, 1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
88- {{{3, 1, 5}, {3, 1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},79+ {{{1}, {1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
89- {{{1}, {1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},80+ {{{-1}, {-1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
90- {{{-1}, {-1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},81+ },
91- },82+ {
92- {83+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
93- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},84+ });
94- });
95 std::vector<std::vector<int64_t>> expectOutputShape = {{3, 1, 5}};85 std::vector<std::vector<int64_t>> expectOutputShape = {{3, 1, 5}};
96 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);86 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
97}87}
98 88 
99TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_6)89TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_6)
100{90{
101- gert::InfershapeContextPara infershapeContextPara(91+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
102- "ClipByValue",92+ {
103- {93+ {{{3, 1, 5}, {3, 1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
104- {{{3, 1, 5}, {3, 1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},94+ {{{1}, {1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
105- {{{1}, {1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},95+ {{{5}, {5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
106- {{{5}, {5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},96+ },
107- },97+ {
108- {98+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
109- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},99+ });
110- });
111 std::vector<std::vector<int64_t>> expectOutputShape = {{3, 1, 5}};100 std::vector<std::vector<int64_t>> expectOutputShape = {{3, 1, 5}};
112 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);101 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
113}102}
114 103 
115TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_7)104TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_7)
116{105{
117- gert::InfershapeContextPara infershapeContextPara(106+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
118- "ClipByValue",107+ {
119- {108+ {{{1, 5}, {1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
120- {{{1, 5}, {1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},109+ {{{3, 1, 5}, {3, 1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
121- {{{3, 1, 5}, {3, 1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},110+ {{{5}, {5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
122- {{{5}, {5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},111+ },
123- },112+ {
124- {113+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
125- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},114+ });
126- });
127 std::vector<std::vector<int64_t>> expectOutputShape = {{3, 1, 5}};115 std::vector<std::vector<int64_t>> expectOutputShape = {{3, 1, 5}};
128 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);116 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
129}117}
130 118 
131TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_8)119TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_8)
132{120{
133- gert::InfershapeContextPara infershapeContextPara(121+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
134- "ClipByValue",122+ {
135- {123+ {{{3, 1, 5}, {3, 1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
136- {{{3, 1, 5}, {3, 1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},124+ {{{1, 6}, {1, 6}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
137- {{{1, 6}, {1, 6}}, ge::DT_FLOAT, ge::FORMAT_NHWC},125+ {{{5}, {5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
138- {{{5}, {5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},126+ },
139- },127+ {
140- {128+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
141- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},129+ });
142- });
143 std::vector<std::vector<int64_t>> expectOutputShape = {};130 std::vector<std::vector<int64_t>> expectOutputShape = {};
144 ExecuteTestCase(infershapeContextPara, ge::GRAPH_FAILED, expectOutputShape);131 ExecuteTestCase(infershapeContextPara, ge::GRAPH_FAILED, expectOutputShape);
145}132}
146 133 
147TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_9)134TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_9)
148{135{
149- gert::InfershapeContextPara infershapeContextPara(136+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
150- "ClipByValue",137+ {
151- {138+ {{{3, 1, 5}, {3, 1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
152- {{{3, 1, 5}, {3, 1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},139+ {{{1, -1}, {1, -1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
153- {{{1, -1}, {1, -1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},140+ {{{-2}, {-2}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
154- {{{-2}, {-2}}, ge::DT_FLOAT, ge::FORMAT_NHWC},141+ },
155- },142+ {
156- {143+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
157- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},144+ });
158- });145+ std::vector<std::vector<int64_t>> expectOutputShape = {{-2}};
159- std::vector<std::vector<int64_t>> expectOutputShape = {{3, 1, 5}};
160 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);146 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
161}147}
162 148 
163TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_10)149TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_10)
164{150{
165- gert::InfershapeContextPara infershapeContextPara(151+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
166- "ClipByValue",152+ {
167- {153+ {{{3, 1, 5}, {3, 1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
168- {{{3, 1, 5}, {3, 1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},154+ {{{0, -1}, {0, -1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
169- {{{0, -1}, {0, -1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},155+ {{{-2}, {-2}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
170- {{{-2}, {-2}}, ge::DT_FLOAT, ge::FORMAT_NHWC},156+ },
171- },157+ {
172- {158+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
173- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},159+ });
174- });160+ std::vector<std::vector<int64_t>> expectOutputShape = {{-2}};
175- std::vector<std::vector<int64_t>> expectOutputShape = {{3, 0, 5}};
176 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);161 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
177}162}
178 163 
179TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_11)164TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_11)
180{165{
181- gert::InfershapeContextPara infershapeContextPara(166+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
182- "ClipByValue",167+ {
183- {168+ {{{3, 1, 5}, {3, 1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
184- {{{3, 1, 5}, {3, 1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},169+ {{{0, -1}, {0, -1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
185- {{{0, -1}, {0, -1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},170+ {{{-1}, {-1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
186- {{{-1}, {-1}}, ge::DT_FLOAT, ge::FORMAT_NHWC},171+ },
187- },172+ {
188- {173+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
189- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},174+ });
190- });
191 std::vector<std::vector<int64_t>> expectOutputShape = {{3, 0, 5}};175 std::vector<std::vector<int64_t>> expectOutputShape = {{3, 0, 5}};
192 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);176 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
193}177}
194 178 
195TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_12)179TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_12)
196{180{
197- gert::InfershapeContextPara infershapeContextPara(181+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
198- "ClipByValue",182+ {
199- {183+ {{{3, 1, 5}, {3, 1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
200- {{{3, 1, 5}, {3, 1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},184+ {{{1, 0}, {1, 0}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
201- {{{1, 0}, {1, 0}}, ge::DT_FLOAT, ge::FORMAT_NHWC},185+ {{{5}, {5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
202- {{{5}, {5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},186+ },
203- },187+ {
204- {188+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
205- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},189+ });
206- });
207 std::vector<std::vector<int64_t>> expectOutputShape = {{3, 0, 5}};190 std::vector<std::vector<int64_t>> expectOutputShape = {{3, 0, 5}};
208 ExecuteTestCase(infershapeContextPara, ge::GRAPH_FAILED, expectOutputShape);191 ExecuteTestCase(infershapeContextPara, ge::GRAPH_FAILED, expectOutputShape);
209}192}
210 193 
211TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_13)194TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_13)
212{195{
213- gert::InfershapeContextPara infershapeContextPara(196+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
214- "ClipByValue",197+ {
215- {198+ {{{3, 1, 0}, {3, 1, 0}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
216- {{{3, 1, 0}, {3, 1, 0}}, ge::DT_FLOAT, ge::FORMAT_NHWC},199+ {{{1, 5}, {1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
217- {{{1, 5}, {1, 5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},200+ {{{5}, {5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
218- {{{5}, {5}}, ge::DT_FLOAT, ge::FORMAT_NHWC},201+ },
219- },202+ {
220- {203+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
221- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},204+ });
222- });
223 std::vector<std::vector<int64_t>> expectOutputShape = {{3, 0, 5}};205 std::vector<std::vector<int64_t>> expectOutputShape = {{3, 0, 5}};
224 ExecuteTestCase(infershapeContextPara, ge::GRAPH_FAILED, expectOutputShape);206 ExecuteTestCase(infershapeContextPara, ge::GRAPH_FAILED, expectOutputShape);
225}207}
@@ -242,112 +224,105 @@ TEST_F(ClipByValueTest, clip_by_value_infershape_diff_test_14)
242 224 
243TEST_F(ClipByValueTest, infer_axis_type_with_input_is_scalar)225TEST_F(ClipByValueTest, infer_axis_type_with_input_is_scalar)
244{226{
245- gert::InfershapeContextPara infershapeContextPara(227+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
246- "ClipByValue",228+ {
247- {229+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
248- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},230+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
249- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},231+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
250- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},232+ },
251- },233+ {
252- {234+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
253- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},235+ });
254- });
255 std::vector<std::vector<int64_t>> expectOutputShape = {};236 std::vector<std::vector<int64_t>> expectOutputShape = {};
256 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);237 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
257}238}
258 239 
259TEST_F(ClipByValueTest, infer_axis_type_with_input_has_unknown_rank)240TEST_F(ClipByValueTest, infer_axis_type_with_input_has_unknown_rank)
260{241{
261- gert::InfershapeContextPara infershapeContextPara(242+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
262- "ClipByValue",243+ {
263- {244+ {{{-2}, {-2}}, ge::DT_FLOAT16, ge::FORMAT_ND},
264- {{{-2}, {-2}}, ge::DT_FLOAT16, ge::FORMAT_ND},245+ {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
265- {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND},246+ {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
266- {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND},247+ },
267- },248+ {
268- {249+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
269- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},250+ });
270- });
271 std::vector<std::vector<int64_t>> expectOutputShape = {};251 std::vector<std::vector<int64_t>> expectOutputShape = {};
272 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);252 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
273}253}
274 254 
275TEST_F(ClipByValueTest, infer_axis_type_with_clip_value_dim_num_equal)255TEST_F(ClipByValueTest, infer_axis_type_with_clip_value_dim_num_equal)
276{256{
277- gert::InfershapeContextPara infershapeContextPara(257+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
278- "ClipByValue",258+ {
279- {259+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
280- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},260+ {{{16}, {16}}, ge::DT_FLOAT16, ge::FORMAT_ND},
281- {{{16}, {16}}, ge::DT_FLOAT16, ge::FORMAT_ND},261+ {{{16}, {16}}, ge::DT_FLOAT16, ge::FORMAT_ND},
282- {{{16}, {16}}, ge::DT_FLOAT16, ge::FORMAT_ND},262+ },
283- },263+ {
284- {264+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
285- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},265+ });
286- });
287 std::vector<std::vector<int64_t>> expectOutputShape = {};266 std::vector<std::vector<int64_t>> expectOutputShape = {};
288 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);267 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
289}268}
290 269 
291TEST_F(ClipByValueTest, infer_axis_type_with_input_unknown_dim)270TEST_F(ClipByValueTest, infer_axis_type_with_input_unknown_dim)
292{271{
293- gert::InfershapeContextPara infershapeContextPara(272+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
294- "ClipByValue",273+ {
295- {274+ {{{16}, {16}}, ge::DT_FLOAT16, ge::FORMAT_ND},
296- {{{16}, {16}}, ge::DT_FLOAT16, ge::FORMAT_ND},275+ {{{16}, {16}}, ge::DT_FLOAT16, ge::FORMAT_ND},
297- {{{16}, {16}}, ge::DT_FLOAT16, ge::FORMAT_ND},276+ {{{-1}, {-1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
298- {{{-1}, {-1}}, ge::DT_FLOAT16, ge::FORMAT_ND},277+ },
299- },278+ {
300- {279+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
301- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},280+ });
302- });
303 std::vector<std::vector<int64_t>> expectOutputShape = {{16}};281 std::vector<std::vector<int64_t>> expectOutputShape = {{16}};
304 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);282 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
305}283}
306 284 
307TEST_F(ClipByValueTest, infer_axis_type_with_input_dim_num_great_than_1)285TEST_F(ClipByValueTest, infer_axis_type_with_input_dim_num_great_than_1)
308{286{
309- gert::InfershapeContextPara infershapeContextPara(287+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
310- "ClipByValue",288+ {
311- {289+ {{{16, 16}, {16, 16}}, ge::DT_FLOAT16, ge::FORMAT_ND},
312- {{{16, 16}, {16, 16}}, ge::DT_FLOAT16, ge::FORMAT_ND},290+ {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
313- {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND},291+ {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
314- {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND},292+ },
315- },293+ {
316- {294+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
317- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},295+ });
318- });
319 std::vector<std::vector<int64_t>> expectOutputShape = {{16, 16}};296 std::vector<std::vector<int64_t>> expectOutputShape = {{16, 16}};
320 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);297 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
321}298}
322 299 
323TEST_F(ClipByValueTest, infer_axis_type_with_input_dim_num_great_than_1_and_unknown_dim)300TEST_F(ClipByValueTest, infer_axis_type_with_input_dim_num_great_than_1_and_unknown_dim)
324{301{
325- gert::InfershapeContextPara infershapeContextPara(302+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
326- "ClipByValue",303+ {
327- {304+ {{{-1, 16}, {-1, 16}}, ge::DT_FLOAT16, ge::FORMAT_ND},
328- {{{-1, 16}, {-1, 16}}, ge::DT_FLOAT16, ge::FORMAT_ND},305+ {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
329- {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND},306+ {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
330- {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND},307+ },
331- },308+ {
332- {309+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
333- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},310+ });
334- });
335 std::vector<std::vector<int64_t>> expectOutputShape = {{-1, 16}};311 std::vector<std::vector<int64_t>> expectOutputShape = {{-1, 16}};
336 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);312 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
337}313}
338 314 
339TEST_F(ClipByValueTest, infer_axis_type_with_input_all_unknown_dim)315TEST_F(ClipByValueTest, infer_axis_type_with_input_all_unknown_dim)
340{316{
341- gert::InfershapeContextPara infershapeContextPara(317+ gert::InfershapeContextPara infershapeContextPara("ClipByValue",
342- "ClipByValue",318+ {
343- {319+ {{{-1, -1, -1}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
344- {{{-1, -1, -1}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},320+ {{{-1, -1, -1}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
345- {{{-1, -1, -1}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},321+ {{{-1, -1, -1}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},
346- {{{-1, -1, -1}, {-1, -1, -1}}, ge::DT_FLOAT16, ge::FORMAT_ND},322+ },
347- },323+ {
348- {324+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
349- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},325+ });
350- });
351 std::vector<std::vector<int64_t>> expectOutputShape = {{-1, -1, -1}};326 std::vector<std::vector<int64_t>> expectOutputShape = {{-1, -1, -1}};
352 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);327 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
353}328}
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(Addcdiv).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(Addcmul).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(Axpy).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(BiasAdd).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(BitwiseAnd).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,50 @@
1+/**
2+ * Copyright (c) 2026 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 "infershape_context_faker.h"
14+#include "infershape_case_executor.h"
15+ 
16+class BitwiseAndTest : public testing::Test {
17+protected:
18+ static void SetUpTestCase() { std::cout << "BitwiseAndTest SetUp" << std::endl; }
19+ 
20+ static void TearDownTestCase() { std::cout << "BitwiseAndTest TearDown" << std::endl; }
21+};
22+ 
23+TEST_F(BitwiseAndTest, bitwise_and_infer_shape_0)
24+{
25+ gert::StorageShape shape = {{2, 100}, {2, 100}};
26+ gert::StorageShape yShape = {{2, 100}, {2, 100}};
27+ gert::InfershapeContextPara::TensorDescription x1(shape, ge::DT_INT32, ge::FORMAT_ND);
28+ gert::InfershapeContextPara::TensorDescription x2(shape, ge::DT_INT32, ge::FORMAT_ND);
29+ gert::InfershapeContextPara::TensorDescription y(yShape, ge::DT_INT32, ge::FORMAT_ND);
30+ gert::InfershapeContextPara infershapeContextPara("BitwiseAnd", {x1, x2}, {y});
31+ std::vector<std::vector<int64_t>> expectOutputShape = {
32+ {2, 100},
33+ };
34+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
35+}
36+ 
37+TEST_F(BitwiseAndTest, bitwise_and_infer_shape_broadcast)
38+{
39+ gert::StorageShape x1Shape = {{2, 100}, {2, 100}};
40+ gert::StorageShape x2Shape = {{100}, {100}};
41+ gert::StorageShape yShape = {{2, 100}, {2, 100}};
42+ gert::InfershapeContextPara::TensorDescription x1(x1Shape, ge::DT_INT32, ge::FORMAT_ND);
43+ gert::InfershapeContextPara::TensorDescription x2(x2Shape, ge::DT_INT32, ge::FORMAT_ND);
44+ gert::InfershapeContextPara::TensorDescription y(yShape, ge::DT_INT32, ge::FORMAT_ND);
45+ gert::InfershapeContextPara infershapeContextPara("BitwiseAnd", {x1, x2}, {y});
46+ std::vector<std::vector<int64_t>> expectOutputShape = {
47+ {2, 100},
48+ };
49+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
50+}
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(BitwiseOr).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,50 @@
1+/**
2+ * Copyright (c) 2026 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 "infershape_context_faker.h"
14+#include "infershape_case_executor.h"
15+ 
16+class BitwiseOrTest : public testing::Test {
17+protected:
18+ static void SetUpTestCase() { std::cout << "BitwiseOrTest SetUp" << std::endl; }
19+ 
20+ static void TearDownTestCase() { std::cout << "BitwiseOrTest TearDown" << std::endl; }
21+};
22+ 
23+TEST_F(BitwiseOrTest, bitwise_or_infer_shape_0)
24+{
25+ gert::StorageShape shape = {{2, 100}, {2, 100}};
26+ gert::StorageShape yShape = {{2, 100}, {2, 100}};
27+ gert::InfershapeContextPara::TensorDescription x1(shape, ge::DT_INT32, ge::FORMAT_ND);
28+ gert::InfershapeContextPara::TensorDescription x2(shape, ge::DT_INT32, ge::FORMAT_ND);
29+ gert::InfershapeContextPara::TensorDescription y(yShape, ge::DT_INT32, ge::FORMAT_ND);
30+ gert::InfershapeContextPara infershapeContextPara("BitwiseOr", {x1, x2}, {y});
31+ std::vector<std::vector<int64_t>> expectOutputShape = {
32+ {2, 100},
33+ };
34+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
35+}
36+ 
37+TEST_F(BitwiseOrTest, bitwise_or_infer_shape_broadcast)
38+{
39+ gert::StorageShape x1Shape = {{2, 100}, {2, 100}};
40+ gert::StorageShape x2Shape = {{100}, {100}};
41+ gert::StorageShape yShape = {{2, 100}, {2, 100}};
42+ gert::InfershapeContextPara::TensorDescription x1(x1Shape, ge::DT_INT32, ge::FORMAT_ND);
43+ gert::InfershapeContextPara::TensorDescription x2(x2Shape, ge::DT_INT32, ge::FORMAT_ND);
44+ gert::InfershapeContextPara::TensorDescription y(yShape, ge::DT_INT32, ge::FORMAT_ND);
45+ gert::InfershapeContextPara infershapeContextPara("BitwiseOr", {x1, x2}, {y});
46+ std::vector<std::vector<int64_t>> expectOutputShape = {
47+ {2, 100},
48+ };
49+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
50+}
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(BitwiseXor).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,50 @@
1+/**
2+ * Copyright (c) 2026 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 "infershape_context_faker.h"
14+#include "infershape_case_executor.h"
15+ 
16+class BitwiseXorTest : public testing::Test {
17+protected:
18+ static void SetUpTestCase() { std::cout << "BitwiseXorTest SetUp" << std::endl; }
19+ 
20+ static void TearDownTestCase() { std::cout << "BitwiseXorTest TearDown" << std::endl; }
21+};
22+ 
23+TEST_F(BitwiseXorTest, bitwise_xor_infer_shape_0)
24+{
25+ gert::StorageShape shape = {{2, 100}, {2, 100}};
26+ gert::StorageShape yShape = {{2, 100}, {2, 100}};
27+ gert::InfershapeContextPara::TensorDescription x1(shape, ge::DT_INT32, ge::FORMAT_ND);
28+ gert::InfershapeContextPara::TensorDescription x2(shape, ge::DT_INT32, ge::FORMAT_ND);
29+ gert::InfershapeContextPara::TensorDescription y(yShape, ge::DT_INT32, ge::FORMAT_ND);
30+ gert::InfershapeContextPara infershapeContextPara("BitwiseXor", {x1, x2}, {y});
31+ std::vector<std::vector<int64_t>> expectOutputShape = {
32+ {2, 100},
33+ };
34+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
35+}
36+ 
37+TEST_F(BitwiseXorTest, bitwise_xor_infer_shape_broadcast)
38+{
39+ gert::StorageShape x1Shape = {{2, 100}, {2, 100}};
40+ gert::StorageShape x2Shape = {{100}, {100}};
41+ gert::StorageShape yShape = {{2, 100}, {2, 100}};
42+ gert::InfershapeContextPara::TensorDescription x1(x1Shape, ge::DT_INT32, ge::FORMAT_ND);
43+ gert::InfershapeContextPara::TensorDescription x2(x2Shape, ge::DT_INT32, ge::FORMAT_ND);
44+ gert::InfershapeContextPara::TensorDescription y(yShape, ge::DT_INT32, ge::FORMAT_ND);
45+ gert::InfershapeContextPara infershapeContextPara("BitwiseXor", {x1, x2}, {y});
46+ std::vector<std::vector<int64_t>> expectOutputShape = {
47+ {2, 100},
48+ };
49+ ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
50+}
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(Div).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(DivNoNan).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(FloorDiv).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(FloorMod).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,24 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "log/log.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+static ge::graphStatus InferDataType4GreaterEqual(gert::InferDataTypeContext* context)
17+{
18+ OP_LOGI("Begin InferDataType4GreaterEqual");
19+ context->SetOutputDataType(0, DT_BOOL);
20+ return ge::GRAPH_SUCCESS;
21+}
22+ 
23+IMPL_OP(GreaterEqual).InferDataType(InferDataType4GreaterEqual);
24+} // namespace ops
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(Lerp).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,24 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "log/log.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+static ge::graphStatus InferDataType4LessEqual(gert::InferDataTypeContext* context)
17+{
18+ OP_LOGI("Begin InferDataType4LessEqual");
19+ context->SetOutputDataType(0, DT_BOOL);
20+ return ge::GRAPH_SUCCESS;
21+}
22+ 
23+IMPL_OP(LessEqual).InferDataType(InferDataType4LessEqual);
24+} // namespace ops
@@ -0,0 +1,24 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "log/log.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+static ge::graphStatus InferDataType4LogicalAnd(gert::InferDataTypeContext* context)
17+{
18+ OP_LOGI("Begin InferDataType4LogicalAnd");
19+ context->SetOutputDataType(0, DT_BOOL);
20+ return ge::GRAPH_SUCCESS;
21+}
22+ 
23+IMPL_OP(LogicalAnd).InferDataType(InferDataType4LogicalAnd);
24+} // namespace ops
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(Maximum).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(Minimum).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(Mod).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,134 @@
1+/**
2+ * Copyright (c) 2026 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+/*!
12+ * \file mul_graph_infer.cpp
13+ * \brief InferDataType for Mul synced from rt1.0 (canndev) dtype strategy: y=PromoteType(x1,x2)
14+ */
15+ 
16+#include "register/op_impl_registry.h"
17+#include "log/log.h"
18+ 
19+using namespace ge;
20+namespace ops {
21+namespace promote_type_for_mul_detail {
22+constexpr auto u1 = ge::DataType::DT_UINT8;
23+constexpr auto i1 = ge::DataType::DT_INT8;
24+constexpr auto i2 = ge::DataType::DT_INT16;
25+constexpr auto i4 = ge::DataType::DT_INT32;
26+constexpr auto i8 = ge::DataType::DT_INT64;
27+constexpr auto f2 = ge::DataType::DT_FLOAT16;
28+constexpr auto f4 = ge::DataType::DT_FLOAT;
29+constexpr auto f8 = ge::DataType::DT_DOUBLE;
30+constexpr auto c2 = ge::DataType::DT_COMPLEX32;
31+constexpr auto c4 = ge::DataType::DT_COMPLEX64;
32+constexpr auto c8 = ge::DataType::DT_COMPLEX128;
33+constexpr auto b1 = ge::DataType::DT_BOOL;
34+constexpr auto bf = ge::DataType::DT_BF16;
35+constexpr auto ud = ge::DataType::DT_UNDEFINED;
36+// @formatter:off
37+static constexpr ge::DataType
38+ kPromoteTypesLookup[static_cast<int>(ge::DataType::DT_MAX)][static_cast<int>(ge::DataType::DT_MAX)] = {
39+ /* f4 f2 i1 i4 u1 xx i2 u2 u4 i8 u8 f8 b1 sv d1 D1 c4 c8 q1 q2 q4 Q1 Q2 rs sr
40+ du va bf, ud t4 T1 t2 T2 c2*/
41+ /* f4 0 */ {f4, f4, f4, f4, f4, ud, f4, ud, ud, f4, ud, f8, f4, ud, ud, ud, c4,
42+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, f4, ud, ud, ud, ud, ud, c4},
43+ /* f2 1 */ {f4, f2, f2, f2, f2, ud, f2, ud, ud, f2, ud, f8, f2, ud, ud, ud, c4,
44+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, f4, ud, ud, ud, ud, ud, c2},
45+ /* i1 2 */ {f4, f2, i1, i4, i2, ud, i2, ud, ud, i8, ud, f8, i1, ud, ud, ud, c4,
46+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, bf, ud, ud, ud, ud, ud, c2},
47+ /* i4 3 */ {f4, f2, i4, i4, i4, ud, i4, ud, ud, i8, ud, f8, i4, ud, ud, ud, c4,
48+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, bf, ud, ud, ud, ud, ud, c2},
49+ /* u1 4 */ {f4, f2, i2, i4, u1, ud, i2, ud, ud, i8, ud, f8, u1, ud, ud, ud, c4,
50+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, bf, ud, ud, ud, ud, ud, c2},
51+ /* xx 5 */ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
52+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
53+ /* i2 6 */ {f4, f2, i2, i4, i2, ud, i2, ud, ud, i8, ud, f8, i2, ud, ud, ud, c4,
54+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, bf, ud, ud, ud, ud, ud, c2},
55+ /* u2 7 */ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, c4,
56+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
57+ /* u4 8 */ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, c4,
58+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
59+ /* i8 9 */ {f4, f2, i8, i8, i8, ud, i8, ud, ud, i8, ud, f8, i8, ud, ud, ud, c4,
60+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, bf, ud, ud, ud, ud, ud, c2},
61+ /* u8 10*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, c8,
62+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
63+ /* f8 11*/ {f8, f8, f8, f8, f8, ud, f8, ud, ud, f8, ud, f8, f8, ud, ud, ud, c8,
64+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, f8, ud, ud, ud, ud, ud, c8},
65+ /* b1 12*/ {f4, f2, i1, i4, u1, ud, i2, ud, ud, i8, ud, f8, b1, ud, ud, ud, c4,
66+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, bf, ud, ud, ud, ud, ud, c2},
67+ /* sv 13*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
68+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
69+ /* d1 14*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
70+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
71+ /* D1 15*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
72+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
73+ /* c4 16*/ {c4, c4, c4, c4, c4, ud, c4, ud, ud, c4, ud, c8, c4, ud, ud, ud, c4,
74+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, c4, ud, ud, ud, ud, ud, c4},
75+ /* c8 17*/ {c8, c8, c8, c8, c8, ud, c8, ud, ud, c8, ud, c8, c8, ud, ud, ud, c8,
76+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, c8, ud, ud, ud, ud, ud, c8},
77+ /* q1 18*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
78+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
79+ /* q2 19*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
80+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
81+ /* q4 20*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
82+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
83+ /* Q1 21*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
84+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
85+ /* Q2 22*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
86+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
87+ /* rs 23*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
88+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
89+ /* sr 24*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
90+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
91+ /* du 25*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
92+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
93+ /* va 26*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
94+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
95+ /* bf 27*/ {f4, f4, bf, bf, bf, ud, bf, ud, ud, bf, ud, f8, bf, ud, ud, ud, c4,
96+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, bf, ud, ud, ud, ud, ud, c4},
97+ /* ud 28*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
98+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
99+ /* t4 29*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
100+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
101+ /* T1 30*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
102+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
103+ /* t2 31*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
104+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
105+ /* T2 32*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
106+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
107+ /* c2 33*/ {c4, c2, c2, c2, c2, ud, c2, ud, ud, c2, ud, c8, c2, ud, ud, ud, c4,
108+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, c4, ud, ud, ud, ud, ud, c2},
109+};
110+// @formatter:on
111+ 
112+inline ge::DataType PromoteType(ge::DataType type_a, ge::DataType type_b)
113+{
114+ if (type_a < 0 || type_b < 0 || type_a >= ge::DataType::DT_MAX || type_b >= ge::DataType::DT_MAX) {
115+ return ge::DataType::DT_UNDEFINED;
116+ }
117+ if (type_a == type_b) {
118+ return type_a;
119+ }
120+ return kPromoteTypesLookup[static_cast<int>(type_a)][static_cast<int>(type_b)];
121+}
122+ 
123+} // namespace promote_type_for_mul_detail
124+ 
125+static ge::graphStatus InferDataTypeForMul(gert::InferDataTypeContext* context)
126+{
127+ OP_LOGI("Begin InferDataTypeForMul");
128+ const ge::DataType x1DataType = context->GetInputDataType(0);
129+ const ge::DataType x2DataType = context->GetInputDataType(1);
130+ context->SetOutputDataType(0, promote_type_for_mul_detail::PromoteType(x1DataType, x2DataType));
131+ return ge::GRAPH_SUCCESS;
132+}
133+IMPL_OP(Mul).InferDataType(InferDataTypeForMul);
134+} // namespace ops
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(Muls).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(Select).InferDataType(InferDataTypeOutputSameAsInput<0, 1>);
17+} // namespace ops
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(SelectV2).InferDataType(InferDataTypeOutputSameAsInput<0, 1>);
17+} // namespace ops
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(SquaredDifference).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,17 @@
1+/**
2+ * Copyright (c) 2026 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 "register/op_impl_registry.h"
12+#include "op_graph/graph_infer_comm_funcs.h"
13+ 
14+using namespace ge;
15+namespace ops {
16+IMPL_OP(Sub).InferDataType(InferDataTypeOutputSameAsInput);
17+} // namespace ops
@@ -0,0 +1,134 @@
1+/**
2+ * Copyright (c) 2026 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+/*!
12+ * \file tanh_grad_graph_infer.cpp
13+ * \brief InferDataType for TanhGrad synced from rt1.0 (canndev) dtype strategy: z=PromoteType(y,dy)
14+ */
15+ 
16+#include "register/op_impl_registry.h"
17+#include "log/log.h"
18+ 
19+using namespace ge;
20+namespace ops {
21+namespace promote_type_for_tanh_grad_detail {
22+constexpr auto u1 = ge::DataType::DT_UINT8;
23+constexpr auto i1 = ge::DataType::DT_INT8;
24+constexpr auto i2 = ge::DataType::DT_INT16;
25+constexpr auto i4 = ge::DataType::DT_INT32;
26+constexpr auto i8 = ge::DataType::DT_INT64;
27+constexpr auto f2 = ge::DataType::DT_FLOAT16;
28+constexpr auto f4 = ge::DataType::DT_FLOAT;
29+constexpr auto f8 = ge::DataType::DT_DOUBLE;
30+constexpr auto c2 = ge::DataType::DT_COMPLEX32;
31+constexpr auto c4 = ge::DataType::DT_COMPLEX64;
32+constexpr auto c8 = ge::DataType::DT_COMPLEX128;
33+constexpr auto b1 = ge::DataType::DT_BOOL;
34+constexpr auto bf = ge::DataType::DT_BF16;
35+constexpr auto ud = ge::DataType::DT_UNDEFINED;
36+// @formatter:off
37+static constexpr ge::DataType
38+ kPromoteTypesLookup[static_cast<int>(ge::DataType::DT_MAX)][static_cast<int>(ge::DataType::DT_MAX)] = {
39+ /* f4 f2 i1 i4 u1 xx i2 u2 u4 i8 u8 f8 b1 sv d1 D1 c4 c8 q1 q2 q4 Q1 Q2 rs sr
40+ du va bf, ud t4 T1 t2 T2 c2*/
41+ /* f4 0 */ {f4, f4, f4, f4, f4, ud, f4, ud, ud, f4, ud, f8, f4, ud, ud, ud, c4,
42+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, f4, ud, ud, ud, ud, ud, c4},
43+ /* f2 1 */ {f4, f2, f2, f2, f2, ud, f2, ud, ud, f2, ud, f8, f2, ud, ud, ud, c4,
44+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, f4, ud, ud, ud, ud, ud, c2},
45+ /* i1 2 */ {f4, f2, i1, i4, i2, ud, i2, ud, ud, i8, ud, f8, i1, ud, ud, ud, c4,
46+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, bf, ud, ud, ud, ud, ud, c2},
47+ /* i4 3 */ {f4, f2, i4, i4, i4, ud, i4, ud, ud, i8, ud, f8, i4, ud, ud, ud, c4,
48+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, bf, ud, ud, ud, ud, ud, c2},
49+ /* u1 4 */ {f4, f2, i2, i4, u1, ud, i2, ud, ud, i8, ud, f8, u1, ud, ud, ud, c4,
50+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, bf, ud, ud, ud, ud, ud, c2},
51+ /* xx 5 */ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
52+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
53+ /* i2 6 */ {f4, f2, i2, i4, i2, ud, i2, ud, ud, i8, ud, f8, i2, ud, ud, ud, c4,
54+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, bf, ud, ud, ud, ud, ud, c2},
55+ /* u2 7 */ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, c4,
56+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
57+ /* u4 8 */ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, c4,
58+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
59+ /* i8 9 */ {f4, f2, i8, i8, i8, ud, i8, ud, ud, i8, ud, f8, i8, ud, ud, ud, c4,
60+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, bf, ud, ud, ud, ud, ud, c2},
61+ /* u8 10*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, c8,
62+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
63+ /* f8 11*/ {f8, f8, f8, f8, f8, ud, f8, ud, ud, f8, ud, f8, f8, ud, ud, ud, c8,
64+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, f8, ud, ud, ud, ud, ud, c8},
65+ /* b1 12*/ {f4, f2, i1, i4, u1, ud, i2, ud, ud, i8, ud, f8, b1, ud, ud, ud, c4,
66+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, bf, ud, ud, ud, ud, ud, c2},
67+ /* sv 13*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
68+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
69+ /* d1 14*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
70+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
71+ /* D1 15*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
72+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
73+ /* c4 16*/ {c4, c4, c4, c4, c4, ud, c4, ud, ud, c4, ud, c8, c4, ud, ud, ud, c4,
74+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, c4, ud, ud, ud, ud, ud, c4},
75+ /* c8 17*/ {c8, c8, c8, c8, c8, ud, c8, ud, ud, c8, ud, c8, c8, ud, ud, ud, c8,
76+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, c8, ud, ud, ud, ud, ud, c8},
77+ /* q1 18*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
78+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
79+ /* q2 19*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
80+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
81+ /* q4 20*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
82+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
83+ /* Q1 21*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
84+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
85+ /* Q2 22*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
86+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
87+ /* rs 23*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
88+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
89+ /* sr 24*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
90+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
91+ /* du 25*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
92+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
93+ /* va 26*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
94+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
95+ /* bf 27*/ {f4, f4, bf, bf, bf, ud, bf, ud, ud, bf, ud, f8, bf, ud, ud, ud, c4,
96+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, bf, ud, ud, ud, ud, ud, c4},
97+ /* ud 28*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
98+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
99+ /* t4 29*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
100+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
101+ /* T1 30*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
102+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
103+ /* t2 31*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
104+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
105+ /* T2 32*/ {ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud,
106+ ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud, ud},
107+ /* c2 33*/ {c4, c2, c2, c2, c2, ud, c2, ud, ud, c2, ud, c8, c2, ud, ud, ud, c4,
108+ c8, ud, ud, ud, ud, ud, ud, ud, ud, ud, c4, ud, ud, ud, ud, ud, c2},
109+};
110+// @formatter:on
111+ 
112+inline ge::DataType PromoteType(ge::DataType type_a, ge::DataType type_b)
113+{
114+ if (type_a < 0 || type_b < 0 || type_a >= ge::DataType::DT_MAX || type_b >= ge::DataType::DT_MAX) {
115+ return ge::DataType::DT_UNDEFINED;
116+ }
117+ if (type_a == type_b) {
118+ return type_a;
119+ }
120+ return kPromoteTypesLookup[static_cast<int>(type_a)][static_cast<int>(type_b)];
121+}
122+ 
123+} // namespace promote_type_for_tanh_grad_detail
124+ 
125+static ge::graphStatus InferDataTypeForTanhGrad(gert::InferDataTypeContext* context)
126+{
127+ OP_LOGI("Begin InferDataTypeForTanhGrad");
128+ const ge::DataType x1DataType = context->GetInputDataType(0);
129+ const ge::DataType x2DataType = context->GetInputDataType(1);
130+ context->SetOutputDataType(0, promote_type_for_tanh_grad_detail::PromoteType(x1DataType, x2DataType));
131+ return ge::GRAPH_SUCCESS;
132+}
133+IMPL_OP(TanhGrad).InferDataType(InferDataTypeForTanhGrad);
134+} // namespace ops