已合并
refactor: reduce duplicated code #9451
refactor: reduce duplicated code #9451
已合并
reven创建于 7 天前
31 个文件变更+507-511
@@ -93,64 +93,64 @@ public:
93 this->AICore().AddConfig("ascend910b");93 this->AICore().AddConfig("ascend910b");
94 this->AICore().AddConfig("ascend910_93");94 this->AICore().AddConfig("ascend910_93");
95 95 
96- OpAICoreConfig config_310p;96+ OpAICoreConfig addLayerConfig310p;
97- config_310p.Input("x1")97+ addLayerConfig310p.Input("x1")
98 .ParamType(REQUIRED)98 .ParamType(REQUIRED)
99 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})99 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
100 .Format(ALL_FORMAT_ND_310)100 .Format(ALL_FORMAT_ND_310)
101 .UnknownShapeFormat(ALL_FORMAT_ND_310)101 .UnknownShapeFormat(ALL_FORMAT_ND_310)
102 .AutoContiguous();102 .AutoContiguous();
103- config_310p.Input("x2")103+ addLayerConfig310p.Input("x2")
104 .ParamType(REQUIRED)104 .ParamType(REQUIRED)
105 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})105 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
106 .Format(ALL_FORMAT_ND_310)106 .Format(ALL_FORMAT_ND_310)
107 .UnknownShapeFormat(ALL_FORMAT_ND_310)107 .UnknownShapeFormat(ALL_FORMAT_ND_310)
108 .AutoContiguous();108 .AutoContiguous();
109- config_310p.Input("gamma")109+ addLayerConfig310p.Input("gamma")
110 .ParamType(REQUIRED)110 .ParamType(REQUIRED)
111 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})111 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
112 .Format(ALL_FORMAT_ND_310)112 .Format(ALL_FORMAT_ND_310)
113 .UnknownShapeFormat(ALL_FORMAT_ND_310)113 .UnknownShapeFormat(ALL_FORMAT_ND_310)
114 .AutoContiguous();114 .AutoContiguous();
115- config_310p.Input("beta")115+ addLayerConfig310p.Input("beta")
116 .ParamType(REQUIRED)116 .ParamType(REQUIRED)
117 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})117 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
118 .Format(ALL_FORMAT_ND_310)118 .Format(ALL_FORMAT_ND_310)
119 .UnknownShapeFormat(ALL_FORMAT_ND_310)119 .UnknownShapeFormat(ALL_FORMAT_ND_310)
120 .AutoContiguous();120 .AutoContiguous();
121- config_310p.Input("bias")121+ addLayerConfig310p.Input("bias")
122 .ParamType(OPTIONAL)122 .ParamType(OPTIONAL)
123 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})123 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
124 .Format(ALL_FORMAT_ND_310)124 .Format(ALL_FORMAT_ND_310)
125 .UnknownShapeFormat(ALL_FORMAT_ND_310)125 .UnknownShapeFormat(ALL_FORMAT_ND_310)
126 .AutoContiguous();126 .AutoContiguous();
127- config_310p.Output("y")127+ addLayerConfig310p.Output("y")
128 .ParamType(REQUIRED)128 .ParamType(REQUIRED)
129 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})129 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
130 .Format(ALL_FORMAT_ND_310)130 .Format(ALL_FORMAT_ND_310)
131 .UnknownShapeFormat(ALL_FORMAT_ND_310);131 .UnknownShapeFormat(ALL_FORMAT_ND_310);
132- config_310p.Output("mean")132+ addLayerConfig310p.Output("mean")
133 .ParamType(REQUIRED)133 .ParamType(REQUIRED)
134 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})134 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})
135 .Format(ALL_FORMAT_ND_310)135 .Format(ALL_FORMAT_ND_310)
136 .UnknownShapeFormat(ALL_FORMAT_ND_310);136 .UnknownShapeFormat(ALL_FORMAT_ND_310);
137- config_310p.Output("rstd")137+ addLayerConfig310p.Output("rstd")
138 .ParamType(REQUIRED)138 .ParamType(REQUIRED)
139 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})139 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})
140 .Format(ALL_FORMAT_ND_310)140 .Format(ALL_FORMAT_ND_310)
141 .UnknownShapeFormat(ALL_FORMAT_ND_310);141 .UnknownShapeFormat(ALL_FORMAT_ND_310);
142- config_310p.Output("x")142+ addLayerConfig310p.Output("x")
143 .ParamType(REQUIRED)143 .ParamType(REQUIRED)
144 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})144 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
145 .Format(ALL_FORMAT_ND_310)145 .Format(ALL_FORMAT_ND_310)
146 .UnknownShapeFormat(ALL_FORMAT_ND_310);146 .UnknownShapeFormat(ALL_FORMAT_ND_310);
147- config_310p.DynamicCompileStaticFlag(true)147+ addLayerConfig310p.DynamicCompileStaticFlag(true)
148 .DynamicRankSupportFlag(true)148 .DynamicRankSupportFlag(true)
149 .DynamicShapeSupportFlag(true)149 .DynamicShapeSupportFlag(true)
150 .NeedCheckSupportFlag(false);150 .NeedCheckSupportFlag(false);
151- this->AICore().AddConfig("ascend310p", config_310p);151+ this->AICore().AddConfig("ascend310p", addLayerConfig310p);
152- this->AICore().AddConfig("kirinx90", config_310p);152+ this->AICore().AddConfig("kirinx90", addLayerConfig310p);
153- this->AICore().AddConfig("kirin9030", config_310p);153+ this->AICore().AddConfig("kirin9030", addLayerConfig310p);
154 154 
155 OpAICoreConfig config_950;155 OpAICoreConfig config_950;
156 config_950.Input("x1")156 config_950.Input("x1")
@@ -87,45 +87,45 @@ public:
87 config_950.DynamicCompileStaticFlag(true).DynamicRankSupportFlag(true).DynamicShapeSupportFlag(true);87 config_950.DynamicCompileStaticFlag(true).DynamicRankSupportFlag(true).DynamicShapeSupportFlag(true);
88 this->AICore().AddConfig("ascend950", config_950);88 this->AICore().AddConfig("ascend950", config_950);
89 89 
90- OpAICoreConfig config_310p;90+ OpAICoreConfig addLayerGradConfig310p;
91 // input91 // input
92- config_310p.Input("dy")92+ addLayerGradConfig310p.Input("dy")
93 .ParamType(REQUIRED)93 .ParamType(REQUIRED)
94 .DataType({ge::DT_FLOAT, ge::DT_FLOAT16})94 .DataType({ge::DT_FLOAT, ge::DT_FLOAT16})
95 .Format({ge::FORMAT_ND, ge::FORMAT_ND})95 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
96 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})96 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
97 .AutoContiguous();97 .AutoContiguous();
98- config_310p.Input("x1")98+ addLayerGradConfig310p.Input("x1")
99 .ParamType(REQUIRED)99 .ParamType(REQUIRED)
100 .DataType({ge::DT_FLOAT, ge::DT_FLOAT16})100 .DataType({ge::DT_FLOAT, ge::DT_FLOAT16})
101 .Format({ge::FORMAT_ND, ge::FORMAT_ND})101 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
102 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})102 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
103 .AutoContiguous();103 .AutoContiguous();
104- config_310p.Input("x2")104+ addLayerGradConfig310p.Input("x2")
105 .ParamType(REQUIRED)105 .ParamType(REQUIRED)
106 .DataType({ge::DT_FLOAT, ge::DT_FLOAT16})106 .DataType({ge::DT_FLOAT, ge::DT_FLOAT16})
107 .Format({ge::FORMAT_ND, ge::FORMAT_ND})107 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
108 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})108 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
109 .AutoContiguous();109 .AutoContiguous();
110- config_310p.Input("rstd")110+ addLayerGradConfig310p.Input("rstd")
111 .ParamType(REQUIRED)111 .ParamType(REQUIRED)
112 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})112 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})
113 .Format({ge::FORMAT_ND, ge::FORMAT_ND})113 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
114 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})114 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
115 .AutoContiguous();115 .AutoContiguous();
116- config_310p.Input("mean")116+ addLayerGradConfig310p.Input("mean")
117 .ParamType(REQUIRED)117 .ParamType(REQUIRED)
118 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})118 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})
119 .Format({ge::FORMAT_ND, ge::FORMAT_ND})119 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
120 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})120 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
121 .AutoContiguous();121 .AutoContiguous();
122- config_310p.Input("gamma")122+ addLayerGradConfig310p.Input("gamma")
123 .ParamType(REQUIRED)123 .ParamType(REQUIRED)
124 .DataType({ge::DT_FLOAT, ge::DT_FLOAT16})124 .DataType({ge::DT_FLOAT, ge::DT_FLOAT16})
125 .Format({ge::FORMAT_ND, ge::FORMAT_ND})125 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
126 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})126 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
127 .AutoContiguous();127 .AutoContiguous();
128- config_310p.Input("dsum")128+ addLayerGradConfig310p.Input("dsum")
129 .ParamType(OPTIONAL)129 .ParamType(OPTIONAL)
130 .DataType({ge::DT_FLOAT, ge::DT_FLOAT16})130 .DataType({ge::DT_FLOAT, ge::DT_FLOAT16})
131 .Format({ge::FORMAT_ND, ge::FORMAT_ND})131 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
@@ -133,26 +133,26 @@ public:
133 .AutoContiguous();133 .AutoContiguous();
134 134 
135 // output135 // output
136- config_310p.Output("dx")136+ addLayerGradConfig310p.Output("dx")
137 .ParamType(REQUIRED)137 .ParamType(REQUIRED)
138 .DataType({ge::DT_FLOAT, ge::DT_FLOAT16})138 .DataType({ge::DT_FLOAT, ge::DT_FLOAT16})
139 .Format({ge::FORMAT_ND, ge::FORMAT_ND})139 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
140 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});140 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});
141- config_310p.Output("dgamma")141+ addLayerGradConfig310p.Output("dgamma")
142 .ParamType(REQUIRED)142 .ParamType(REQUIRED)
143 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})143 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})
144 .Format({ge::FORMAT_ND, ge::FORMAT_ND})144 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
145 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});145 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});
146- config_310p.Output("dbeta")146+ addLayerGradConfig310p.Output("dbeta")
147 .ParamType(REQUIRED)147 .ParamType(REQUIRED)
148 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})148 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})
149 .Format({ge::FORMAT_ND, ge::FORMAT_ND})149 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
150 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});150 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});
151- config_310p.DynamicCompileStaticFlag(true)151+ addLayerGradConfig310p.DynamicCompileStaticFlag(true)
152 .DynamicRankSupportFlag(true)152 .DynamicRankSupportFlag(true)
153 .DynamicShapeSupportFlag(true)153 .DynamicShapeSupportFlag(true)
154 .NeedCheckSupportFlag(false);154 .NeedCheckSupportFlag(false);
155- this->AICore().AddConfig("ascend310p", config_310p);155+ this->AICore().AddConfig("ascend310p", addLayerGradConfig310p);
156 }156 }
157};157};
158 158 
@@ -246,17 +246,17 @@ static bool CheckAllNotNull(std::initializer_list<T> ptrList)
246}246}
247 247 
248template <typename T>248template <typename T>
249-static inline bool CheckEqualsAll(std::initializer_list<T> eleList)249+static inline bool CheckEqualsAll(std::initializer_list<T> gradElements)
250{250{
251- bool ret = true;251+ bool gradEqual = true;
252- if (eleList.size() > 0) {252+ if (gradElements.size() > 0) {
253- const T* fontPtr = eleList.begin();253+ const T* gradFirstPtr = gradElements.begin();
254- for (const T* curtPtr = eleList.begin(); curtPtr != eleList.end(); curtPtr++) {254+ for (const T* gradCurrentPtr = gradElements.begin(); gradCurrentPtr != gradElements.end(); gradCurrentPtr++) {
255- ret = ret && (*(curtPtr) == *(fontPtr));255+ gradEqual = gradEqual && (*(gradCurrentPtr) == *(gradFirstPtr));
256- fontPtr = curtPtr;256+ gradFirstPtr = gradCurrentPtr;
257 }257 }
258 }258 }
259- return ret;259+ return gradEqual;
260}260}
261 261 
262static inline bool HasNoZero(const gert::StorageShape* shapePtr, size_t shapeDim)262static inline bool HasNoZero(const gert::StorageShape* shapePtr, size_t shapeDim)
@@ -1,12 +1,11 @@
1/**1/**
2- * This program is free software, you can redistribute it and/or modify.
3 * Copyright (c) 2025 Huawei Technologies Co., Ltd.2 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
4- * This file is a part of the CANN Open Software.3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
5- * Licensed under CANN Open Software License Agreement Version 2.0 (the "License").4+ * CANN Open Software License Agreement Version 2.0 (the "License").
6 * Please refer to the License for details. You may not use this file except in compliance with the License.5 * Please refer to the License for details. You may not use this file except in compliance with the License.
7- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
8- * BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. See LICENSE in the root of7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
9- * the software repository for the full text of the License.8+ * See LICENSE in the root of the software repository for the full text of the License.
10 */9 */
11 10 
12/*!11/*!
@@ -197,100 +196,100 @@ public:
197private:196private:
198 OpAICoreConfig GetKirinCoreConfig() const197 OpAICoreConfig GetKirinCoreConfig() const
199 {198 {
200- OpAICoreConfig config_kirin;199+ OpAICoreConfig addLayerQuantKirinConfig;
201- config_kirin.DynamicCompileStaticFlag(true)200+ addLayerQuantKirinConfig.DynamicCompileStaticFlag(true)
202 .DynamicFormatFlag(true)201 .DynamicFormatFlag(true)
203 .DynamicRankSupportFlag(true)202 .DynamicRankSupportFlag(true)
204 .DynamicShapeSupportFlag(true)203 .DynamicShapeSupportFlag(true)
205 .NeedCheckSupportFlag(false)204 .NeedCheckSupportFlag(false)
206 .PrecisionReduceFlag(true);205 .PrecisionReduceFlag(true);
207- config_kirin.Input("x1")206+ addLayerQuantKirinConfig.Input("x1")
208 .ParamType(REQUIRED)207 .ParamType(REQUIRED)
209 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})208 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
210 .Format({ge::FORMAT_ND, ge::FORMAT_ND})209 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
211 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})210 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
212 .AutoContiguous();211 .AutoContiguous();
213- config_kirin.Input("x2")212+ addLayerQuantKirinConfig.Input("x2")
214 .ParamType(REQUIRED)213 .ParamType(REQUIRED)
215 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})214 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
216 .Format({ge::FORMAT_ND, ge::FORMAT_ND})215 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
217 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})216 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
218 .AutoContiguous();217 .AutoContiguous();
219- config_kirin.Input("gamma")218+ addLayerQuantKirinConfig.Input("gamma")
220 .ParamType(REQUIRED)219 .ParamType(REQUIRED)
221 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})220 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
222 .Format({ge::FORMAT_ND, ge::FORMAT_ND})221 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
223 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})222 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
224 .AutoContiguous();223 .AutoContiguous();
225- config_kirin.Input("beta")224+ addLayerQuantKirinConfig.Input("beta")
226 .ParamType(REQUIRED)225 .ParamType(REQUIRED)
227 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})226 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
228 .Format({ge::FORMAT_ND, ge::FORMAT_ND})227 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
229 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})228 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
230 .AutoContiguous();229 .AutoContiguous();
231- config_kirin.Input("bias")230+ addLayerQuantKirinConfig.Input("bias")
232 .ParamType(OPTIONAL)231 .ParamType(OPTIONAL)
233 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})232 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
234 .Format({ge::FORMAT_ND, ge::FORMAT_ND})233 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
235 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})234 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
236 .AutoContiguous();235 .AutoContiguous();
237- config_kirin.Input("scales1")236+ addLayerQuantKirinConfig.Input("scales1")
238 .ParamType(OPTIONAL)237 .ParamType(OPTIONAL)
239 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})238 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
240 .Format({ge::FORMAT_ND, ge::FORMAT_ND})239 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
241 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})240 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
242 .AutoContiguous();241 .AutoContiguous();
243- config_kirin.Input("scales2")242+ addLayerQuantKirinConfig.Input("scales2")
244 .ParamType(OPTIONAL)243 .ParamType(OPTIONAL)
245 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})244 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
246 .Format({ge::FORMAT_ND, ge::FORMAT_ND})245 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
247 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})246 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
248 .AutoContiguous();247 .AutoContiguous();
249- config_kirin.Input("zero_points1")248+ addLayerQuantKirinConfig.Input("zero_points1")
250 .ParamType(OPTIONAL)249 .ParamType(OPTIONAL)
251 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})250 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
252 .Format({ge::FORMAT_ND, ge::FORMAT_ND})251 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
253 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})252 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
254 .AutoContiguous();253 .AutoContiguous();
255- config_kirin.Input("zero_points2")254+ addLayerQuantKirinConfig.Input("zero_points2")
256 .ParamType(OPTIONAL)255 .ParamType(OPTIONAL)
257 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})256 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
258 .Format({ge::FORMAT_ND, ge::FORMAT_ND})257 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
259 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})258 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
260 .AutoContiguous();259 .AutoContiguous();
261- config_kirin.Output("y1")260+ addLayerQuantKirinConfig.Output("y1")
262 .ParamType(REQUIRED)261 .ParamType(REQUIRED)
263 .DataType({ge::DT_INT8, ge::DT_INT8})262 .DataType({ge::DT_INT8, ge::DT_INT8})
264 .Format({ge::FORMAT_ND, ge::FORMAT_ND})263 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
265 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})264 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
266 .AutoContiguous();265 .AutoContiguous();
267- config_kirin.Output("y2")266+ addLayerQuantKirinConfig.Output("y2")
268 .ParamType(REQUIRED)267 .ParamType(REQUIRED)
269 .DataType({ge::DT_INT8, ge::DT_INT8})268 .DataType({ge::DT_INT8, ge::DT_INT8})
270 .Format({ge::FORMAT_ND, ge::FORMAT_ND})269 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
271 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})270 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
272 .AutoContiguous();271 .AutoContiguous();
273- config_kirin.Output("x")272+ addLayerQuantKirinConfig.Output("x")
274 .ParamType(REQUIRED)273 .ParamType(REQUIRED)
275 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})274 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
276 .Format({ge::FORMAT_ND, ge::FORMAT_ND})275 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
277 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})276 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
278 .AutoContiguous();277 .AutoContiguous();
279- config_kirin.Output("out_scales1")278+ addLayerQuantKirinConfig.Output("out_scales1")
280 .ParamType(REQUIRED)279 .ParamType(REQUIRED)
281 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})280 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})
282 .Format({ge::FORMAT_ND, ge::FORMAT_ND})281 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
283 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})282 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
284 .AutoContiguous();283 .AutoContiguous();
285- config_kirin.Output("out_scales2")284+ addLayerQuantKirinConfig.Output("out_scales2")
286 .ParamType(REQUIRED)285 .ParamType(REQUIRED)
287 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})286 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})
288 .Format({ge::FORMAT_ND, ge::FORMAT_ND})287 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
289 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})288 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
290 .AutoContiguous();289 .AutoContiguous();
291- return config_kirin;290+ return addLayerQuantKirinConfig;
292 }291 }
293};292};
294 293 
295OP_ADD(AddLayerNormQuant);294OP_ADD(AddLayerNormQuant);
296-} // namespace ops295+} // namespace ops
@@ -52,12 +52,12 @@ static inline bool CheckPlatform()
52 return true;52 return true;
53}53}
54 54 
55-static inline bool CheckOptInputDtype(const aclTensor* tensorPtr, op::DataType dtype)55+static inline bool CheckOptInputDtype(const aclTensor* quantTensor, op::DataType quantDtype)
56{56{
57- if (tensorPtr == nullptr) {57+ if (quantTensor == nullptr) {
58 return true;58 return true;
59 }59 }
60- OP_CHECK_DTYPE_NOT_MATCH(tensorPtr, dtype, return false);60+ OP_CHECK_DTYPE_NOT_MATCH(quantTensor, quantDtype, return false);
61 return true;61 return true;
62}62}
63 63 
@@ -1,12 +1,11 @@
1/**1/**
2- * This program is free software, you can redistribute it and/or modify.
3 * Copyright (c) 2025 Huawei Technologies Co., Ltd.2 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
4- * This file is a part of the CANN Open Software.3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
5- * Licensed under CANN Open Software License Agreement Version 2.0 (the "License").4+ * CANN Open Software License Agreement Version 2.0 (the "License").
6 * Please refer to the License for details. You may not use this file except in compliance with the License.5 * Please refer to the License for details. You may not use this file except in compliance with the License.
7- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
8- * BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. See LICENSE in the root of7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
9- * the software repository for the full text of the License.8+ * See LICENSE in the root of the software repository for the full text of the License.
10 */9 */
11 10 
12/*!11/*!
@@ -61,47 +60,47 @@ public:
61 this->AICore().AddConfig("ascend910b");60 this->AICore().AddConfig("ascend910b");
62 this->AICore().AddConfig("ascend910_93");61 this->AICore().AddConfig("ascend910_93");
63 62 
64- OpAICoreConfig config310P;63+ OpAICoreConfig addRmsConfig310p;
65- config310P.Input("x1")64+ addRmsConfig310p.Input("x1")
66 .ParamType(REQUIRED)65 .ParamType(REQUIRED)
67 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})66 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
68 .Format({ge::FORMAT_ND, ge::FORMAT_ND})67 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
69 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})68 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
70 .AutoContiguous();69 .AutoContiguous();
71- config310P.Input("x2")70+ addRmsConfig310p.Input("x2")
72 .ParamType(REQUIRED)71 .ParamType(REQUIRED)
73 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})72 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
74 .Format({ge::FORMAT_ND, ge::FORMAT_ND})73 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
75 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})74 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
76 .AutoContiguous();75 .AutoContiguous();
77- config310P.Input("gamma")76+ addRmsConfig310p.Input("gamma")
78 .ParamType(REQUIRED)77 .ParamType(REQUIRED)
79 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})78 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
80 .Format({ge::FORMAT_ND, ge::FORMAT_ND})79 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
81 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})80 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
82 .AutoContiguous();81 .AutoContiguous();
83- config310P.Output("y")82+ addRmsConfig310p.Output("y")
84 .ParamType(REQUIRED)83 .ParamType(REQUIRED)
85 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})84 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
86 .Format({ge::FORMAT_ND, ge::FORMAT_ND})85 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
87 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})86 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
88 .AutoContiguous();87 .AutoContiguous();
89- config310P.Output("rstd")88+ addRmsConfig310p.Output("rstd")
90 .ParamType(REQUIRED)89 .ParamType(REQUIRED)
91 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})90 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})
92 .Format({ge::FORMAT_ND, ge::FORMAT_ND})91 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
93 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})92 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
94 .AutoContiguous();93 .AutoContiguous();
95- config310P.Output("x")94+ addRmsConfig310p.Output("x")
96 .ParamType(REQUIRED)95 .ParamType(REQUIRED)
97 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})96 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
98 .Format({ge::FORMAT_ND, ge::FORMAT_ND})97 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
99 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})98 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
100 .AutoContiguous();99 .AutoContiguous();
101- config310P.DynamicCompileStaticFlag(true).DynamicRankSupportFlag(true).DynamicShapeSupportFlag(true);100+ addRmsConfig310p.DynamicCompileStaticFlag(true).DynamicRankSupportFlag(true).DynamicShapeSupportFlag(true);
102- this->AICore().AddConfig("ascend310p", config310P);101+ this->AICore().AddConfig("ascend310p", addRmsConfig310p);
103- this->AICore().AddConfig("kirinx90", config310P);102+ this->AICore().AddConfig("kirinx90", addRmsConfig310p);
104- this->AICore().AddConfig("kirin9030", config310P);103+ this->AICore().AddConfig("kirin9030", addRmsConfig310p);
105 104 
106 OpAICoreConfig config_950;105 OpAICoreConfig config_950;
107 config_950.Input("x1")106 config_950.Input("x1")
@@ -148,4 +147,4 @@ public:
148 }147 }
149};148};
150OP_ADD(AddRmsNorm);149OP_ADD(AddRmsNorm);
151-} // namespace ops150+} // namespace ops
@@ -1,12 +1,11 @@
1/**1/**
2- * This program is free software, you can redistribute it and/or modify.
3 * Copyright (c) 2025 Huawei Technologies Co., Ltd.2 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
4- * This file is a part of the CANN Open Software.3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
5- * Licensed under CANN Open Software License Agreement Version 2.0 (the "License").4+ * CANN Open Software License Agreement Version 2.0 (the "License").
6 * Please refer to the License for details. You may not use this file except in compliance with the License.5 * Please refer to the License for details. You may not use this file except in compliance with the License.
7- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
8- * BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. See LICENSE in the root of7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
9- * the software repository for the full text of the License.8+ * See LICENSE in the root of the software repository for the full text of the License.
10 */9 */
11 10 
12/*!11/*!
@@ -82,57 +81,57 @@ public:
82private:81private:
83 OpAICoreConfig GetKirinCoreConfig() const82 OpAICoreConfig GetKirinCoreConfig() const
84 {83 {
85- OpAICoreConfig config_kirin;84+ OpAICoreConfig castKirinConfig;
86- config_kirin.DynamicCompileStaticFlag(true)85+ castKirinConfig.DynamicCompileStaticFlag(true)
87 .DynamicFormatFlag(true)86 .DynamicFormatFlag(true)
88 .DynamicRankSupportFlag(true)87 .DynamicRankSupportFlag(true)
89 .DynamicShapeSupportFlag(true)88 .DynamicShapeSupportFlag(true)
90 .NeedCheckSupportFlag(false)89 .NeedCheckSupportFlag(false)
91 .PrecisionReduceFlag(true);90 .PrecisionReduceFlag(true);
92- config_kirin.Input("x1")91+ castKirinConfig.Input("x1")
93 .ParamType(REQUIRED)92 .ParamType(REQUIRED)
94 .DataType({ge::DT_FLOAT16})93 .DataType({ge::DT_FLOAT16})
95 .Format({ge::FORMAT_ND})94 .Format({ge::FORMAT_ND})
96 .UnknownShapeFormat({ge::FORMAT_ND})95 .UnknownShapeFormat({ge::FORMAT_ND})
97 .AutoContiguous();96 .AutoContiguous();
98- config_kirin.Input("x2")97+ castKirinConfig.Input("x2")
99 .ParamType(REQUIRED)98 .ParamType(REQUIRED)
100 .DataType({ge::DT_FLOAT16})99 .DataType({ge::DT_FLOAT16})
101 .Format({ge::FORMAT_ND})100 .Format({ge::FORMAT_ND})
102 .UnknownShapeFormat({ge::FORMAT_ND})101 .UnknownShapeFormat({ge::FORMAT_ND})
103 .AutoContiguous();102 .AutoContiguous();
104- config_kirin.Input("gamma")103+ castKirinConfig.Input("gamma")
105 .ParamType(REQUIRED)104 .ParamType(REQUIRED)
106 .DataType({ge::DT_FLOAT16})105 .DataType({ge::DT_FLOAT16})
107 .Format({ge::FORMAT_ND})106 .Format({ge::FORMAT_ND})
108 .UnknownShapeFormat({ge::FORMAT_ND})107 .UnknownShapeFormat({ge::FORMAT_ND})
109 .AutoContiguous();108 .AutoContiguous();
110- config_kirin.Output("y1")109+ castKirinConfig.Output("y1")
111 .ParamType(REQUIRED)110 .ParamType(REQUIRED)
112 .DataType({ge::DT_FLOAT})111 .DataType({ge::DT_FLOAT})
113 .Format({ge::FORMAT_ND})112 .Format({ge::FORMAT_ND})
114 .UnknownShapeFormat({ge::FORMAT_ND})113 .UnknownShapeFormat({ge::FORMAT_ND})
115 .AutoContiguous();114 .AutoContiguous();
116- config_kirin.Output("y2")115+ castKirinConfig.Output("y2")
117 .ParamType(REQUIRED)116 .ParamType(REQUIRED)
118 .DataType({ge::DT_FLOAT16})117 .DataType({ge::DT_FLOAT16})
119 .Format({ge::FORMAT_ND})118 .Format({ge::FORMAT_ND})
120 .UnknownShapeFormat({ge::FORMAT_ND})119 .UnknownShapeFormat({ge::FORMAT_ND})
121 .AutoContiguous();120 .AutoContiguous();
122- config_kirin.Output("rstd")121+ castKirinConfig.Output("rstd")
123 .ParamType(REQUIRED)122 .ParamType(REQUIRED)
124 .DataType({ge::DT_FLOAT})123 .DataType({ge::DT_FLOAT})
125 .Format({ge::FORMAT_ND})124 .Format({ge::FORMAT_ND})
126 .UnknownShapeFormat({ge::FORMAT_ND})125 .UnknownShapeFormat({ge::FORMAT_ND})
127 .AutoContiguous();126 .AutoContiguous();
128- config_kirin.Output("x")127+ castKirinConfig.Output("x")
129 .ParamType(REQUIRED)128 .ParamType(REQUIRED)
130 .DataType({ge::DT_FLOAT16})129 .DataType({ge::DT_FLOAT16})
131 .Format({ge::FORMAT_ND})130 .Format({ge::FORMAT_ND})
132 .UnknownShapeFormat({ge::FORMAT_ND})131 .UnknownShapeFormat({ge::FORMAT_ND})
133 .AutoContiguous();132 .AutoContiguous();
134- return config_kirin;133+ return castKirinConfig;
135 }134 }
136};135};
137OP_ADD(AddRmsNormCast);136OP_ADD(AddRmsNormCast);
138-} // namespace ops137+} // namespace ops
@@ -150,38 +150,39 @@ private:
150 150 
151 __aicore__ inline void ComputeRstd(LocalTensor<T> xLocal, LocalTensor<float> rstdLocal, uint32_t calc_row_num)151 __aicore__ inline void ComputeRstd(LocalTensor<T> xLocal, LocalTensor<float> rstdLocal, uint32_t calc_row_num)
152 {152 {
153- LocalTensor<float> x_fp32 = xFp32Buf.Get<float>();153+ LocalTensor<float> castXFp32 = xFp32Buf.Get<float>();
154- LocalTensor<float> sqx = sqxBuf.Get<float>();154+ LocalTensor<float> castSquareX = sqxBuf.Get<float>();
155- LocalTensor<float> reduce_buf_local = reduceFp32Buf.Get<float>();155+ LocalTensor<float> castReduceBuffer = reduceFp32Buf.Get<float>();
156- Cast(x_fp32, xLocal, RoundMode::CAST_NONE, calc_row_num * numColAlign);156+ Cast(castXFp32, xLocal, RoundMode::CAST_NONE, calc_row_num * numColAlign);
157 PipeBarrier<PIPE_V>();157 PipeBarrier<PIPE_V>();
158 158 
159- Mul(sqx, x_fp32, x_fp32, calc_row_num * numColAlign);159+ Mul(castSquareX, castXFp32, castXFp32, calc_row_num * numColAlign);
160 PipeBarrier<PIPE_V>();160 PipeBarrier<PIPE_V>();
161 161 
162- Muls(sqx, sqx, avgFactor, calc_row_num * numColAlign);162+ Muls(castSquareX, castSquareX, avgFactor, calc_row_num * numColAlign);
163 PipeBarrier<PIPE_V>();163 PipeBarrier<PIPE_V>();
164 164 
165- for (uint32_t i_i = 0; i_i < calc_row_num; i_i++) {165+ for (uint32_t castRowIndex = 0; castRowIndex < calc_row_num; castRowIndex++) {
166- ReduceSumCustom(rstdLocal[i_i * NUM_PER_BLK_FP32], sqx[i_i * numColAlign], reduce_buf_local, numCol);166+ ReduceSumCustom(rstdLocal[castRowIndex * NUM_PER_BLK_FP32], castSquareX[castRowIndex * numColAlign],
167+ castReduceBuffer, numCol);
167 }168 }
168 Adds(rstdLocal, rstdLocal, epsilon, calc_row_num * NUM_PER_BLK_FP32);169 Adds(rstdLocal, rstdLocal, epsilon, calc_row_num * NUM_PER_BLK_FP32);
169 PipeBarrier<PIPE_V>();170 PipeBarrier<PIPE_V>();
170 171 
171 Sqrt(rstdLocal, rstdLocal, calc_row_num * NUM_PER_BLK_FP32);172 Sqrt(rstdLocal, rstdLocal, calc_row_num * NUM_PER_BLK_FP32);
172- Duplicate(reduce_buf_local, ONE, NUM_PER_BLK_FP32);173+ Duplicate(castReduceBuffer, ONE, NUM_PER_BLK_FP32);
173 PipeBarrier<PIPE_V>();174 PipeBarrier<PIPE_V>();
174 175 
175- int32_t repeatTimes = calc_row_num * NUM_PER_BLK_FP32 / NUM_PER_REP_FP32;176+ int32_t castRepeatTimes = calc_row_num * NUM_PER_BLK_FP32 / NUM_PER_REP_FP32;
176- int32_t tailCount = calc_row_num * NUM_PER_BLK_FP32 % NUM_PER_REP_FP32;177+ int32_t castTailCount = calc_row_num * NUM_PER_BLK_FP32 % NUM_PER_REP_FP32;
177- int32_t bodyCount = repeatTimes * NUM_PER_REP_FP32;178+ int32_t castBodyCount = castRepeatTimes * NUM_PER_REP_FP32;
178 179 
179- if (likely(repeatTimes > 0)) {180+ if (likely(castRepeatTimes > 0)) {
180- Div(rstdLocal, reduce_buf_local, rstdLocal, NUM_PER_REP_FP32, repeatTimes,181+ Div(rstdLocal, castReduceBuffer, rstdLocal, NUM_PER_REP_FP32, castRepeatTimes,
181 {1, 0, 1, DEFAULT_REPEAT_STRIDE, 0, DEFAULT_REPEAT_STRIDE});182 {1, 0, 1, DEFAULT_REPEAT_STRIDE, 0, DEFAULT_REPEAT_STRIDE});
182 }183 }
183- if (unlikely(tailCount != 0)) {184+ if (unlikely(castTailCount != 0)) {
184- Div(rstdLocal[bodyCount], reduce_buf_local, rstdLocal[bodyCount], tailCount, 1,185+ Div(rstdLocal[castBodyCount], castReduceBuffer, rstdLocal[castBodyCount], castTailCount, 1,
185 {1, 0, 1, DEFAULT_REPEAT_STRIDE, 0, DEFAULT_REPEAT_STRIDE});186 {1, 0, 1, DEFAULT_REPEAT_STRIDE, 0, DEFAULT_REPEAT_STRIDE});
186 }187 }
187 PipeBarrier<PIPE_V>();188 PipeBarrier<PIPE_V>();
@@ -284,4 +285,4 @@ private:
284 int32_t blockIdx_;285 int32_t blockIdx_;
285 uint32_t rowWork = 1;286 uint32_t rowWork = 1;
286};287};
287-#endif // _ADD_RMS_NORM_CAST_MULTI_N_H_288+#endif // _ADD_RMS_NORM_CAST_MULTI_N_H_
@@ -181,80 +181,80 @@ public:
181private:181private:
182 OpAICoreConfig GetKirinCoreConfig() const182 OpAICoreConfig GetKirinCoreConfig() const
183 {183 {
184- OpAICoreConfig config_kirin;184+ OpAICoreConfig dynamicQuantKirinConfig;
185- config_kirin.DynamicCompileStaticFlag(true)185+ dynamicQuantKirinConfig.DynamicCompileStaticFlag(true)
186 .DynamicFormatFlag(true)186 .DynamicFormatFlag(true)
187 .DynamicRankSupportFlag(true)187 .DynamicRankSupportFlag(true)
188 .DynamicShapeSupportFlag(true)188 .DynamicShapeSupportFlag(true)
189 .NeedCheckSupportFlag(false)189 .NeedCheckSupportFlag(false)
190 .PrecisionReduceFlag(true);190 .PrecisionReduceFlag(true);
191- config_kirin.Input("x1")191+ dynamicQuantKirinConfig.Input("x1")
192 .ParamType(REQUIRED)192 .ParamType(REQUIRED)
193 .DataType({ge::DT_FLOAT16})193 .DataType({ge::DT_FLOAT16})
194 .Format({ge::FORMAT_ND})194 .Format({ge::FORMAT_ND})
195 .UnknownShapeFormat({ge::FORMAT_ND})195 .UnknownShapeFormat({ge::FORMAT_ND})
196 .AutoContiguous();196 .AutoContiguous();
197- config_kirin.Input("x2")197+ dynamicQuantKirinConfig.Input("x2")
198 .ParamType(REQUIRED)198 .ParamType(REQUIRED)
199 .DataType({ge::DT_FLOAT16})199 .DataType({ge::DT_FLOAT16})
200 .Format({ge::FORMAT_ND})200 .Format({ge::FORMAT_ND})
201 .UnknownShapeFormat({ge::FORMAT_ND})201 .UnknownShapeFormat({ge::FORMAT_ND})
202 .AutoContiguous();202 .AutoContiguous();
203- config_kirin.Input("gamma")203+ dynamicQuantKirinConfig.Input("gamma")
204 .ParamType(REQUIRED)204 .ParamType(REQUIRED)
205 .DataType({ge::DT_FLOAT16})205 .DataType({ge::DT_FLOAT16})
206 .Format({ge::FORMAT_ND})206 .Format({ge::FORMAT_ND})
207 .UnknownShapeFormat({ge::FORMAT_ND})207 .UnknownShapeFormat({ge::FORMAT_ND})
208 .AutoContiguous();208 .AutoContiguous();
209- config_kirin.Input("smooth_scale1")209+ dynamicQuantKirinConfig.Input("smooth_scale1")
210 .ParamType(OPTIONAL)210 .ParamType(OPTIONAL)
211 .DataType({ge::DT_FLOAT16})211 .DataType({ge::DT_FLOAT16})
212 .Format({ge::FORMAT_ND})212 .Format({ge::FORMAT_ND})
213 .UnknownShapeFormat({ge::FORMAT_ND})213 .UnknownShapeFormat({ge::FORMAT_ND})
214 .AutoContiguous();214 .AutoContiguous();
215- config_kirin.Input("smooth_scale2")215+ dynamicQuantKirinConfig.Input("smooth_scale2")
216 .ParamType(OPTIONAL)216 .ParamType(OPTIONAL)
217 .DataType({ge::DT_FLOAT16})217 .DataType({ge::DT_FLOAT16})
218 .Format({ge::FORMAT_ND})218 .Format({ge::FORMAT_ND})
219 .UnknownShapeFormat({ge::FORMAT_ND})219 .UnknownShapeFormat({ge::FORMAT_ND})
220 .AutoContiguous();220 .AutoContiguous();
221- config_kirin.Input("beta")221+ dynamicQuantKirinConfig.Input("beta")
222 .ParamType(OPTIONAL)222 .ParamType(OPTIONAL)
223 .DataType({ge::DT_FLOAT16})223 .DataType({ge::DT_FLOAT16})
224 .Format({ge::FORMAT_ND})224 .Format({ge::FORMAT_ND})
225 .UnknownShapeFormat({ge::FORMAT_ND})225 .UnknownShapeFormat({ge::FORMAT_ND})
226 .AutoContiguous();226 .AutoContiguous();
227- config_kirin.Output("y1")227+ dynamicQuantKirinConfig.Output("y1")
228 .ParamType(REQUIRED)228 .ParamType(REQUIRED)
229 .DataType({ge::DT_INT8})229 .DataType({ge::DT_INT8})
230 .Format({ge::FORMAT_ND})230 .Format({ge::FORMAT_ND})
231 .UnknownShapeFormat({ge::FORMAT_ND})231 .UnknownShapeFormat({ge::FORMAT_ND})
232 .AutoContiguous();232 .AutoContiguous();
233- config_kirin.Output("y2")233+ dynamicQuantKirinConfig.Output("y2")
234 .ParamType(REQUIRED)234 .ParamType(REQUIRED)
235 .DataType({ge::DT_INT8})235 .DataType({ge::DT_INT8})
236 .Format({ge::FORMAT_ND})236 .Format({ge::FORMAT_ND})
237 .UnknownShapeFormat({ge::FORMAT_ND})237 .UnknownShapeFormat({ge::FORMAT_ND})
238 .AutoContiguous();238 .AutoContiguous();
239- config_kirin.Output("x")239+ dynamicQuantKirinConfig.Output("x")
240 .ParamType(REQUIRED)240 .ParamType(REQUIRED)
241 .DataType({ge::DT_FLOAT16})241 .DataType({ge::DT_FLOAT16})
242 .Format({ge::FORMAT_ND})242 .Format({ge::FORMAT_ND})
243 .UnknownShapeFormat({ge::FORMAT_ND})243 .UnknownShapeFormat({ge::FORMAT_ND})
244 .AutoContiguous();244 .AutoContiguous();
245- config_kirin.Output("scale1")245+ dynamicQuantKirinConfig.Output("scale1")
246 .ParamType(REQUIRED)246 .ParamType(REQUIRED)
247 .DataType({ge::DT_FLOAT})247 .DataType({ge::DT_FLOAT})
248 .Format({ge::FORMAT_ND})248 .Format({ge::FORMAT_ND})
249 .UnknownShapeFormat({ge::FORMAT_ND})249 .UnknownShapeFormat({ge::FORMAT_ND})
250 .AutoContiguous();250 .AutoContiguous();
251- config_kirin.Output("scale2")251+ dynamicQuantKirinConfig.Output("scale2")
252 .ParamType(REQUIRED)252 .ParamType(REQUIRED)
253 .DataType({ge::DT_FLOAT})253 .DataType({ge::DT_FLOAT})
254 .Format({ge::FORMAT_ND})254 .Format({ge::FORMAT_ND})
255 .UnknownShapeFormat({ge::FORMAT_ND})255 .UnknownShapeFormat({ge::FORMAT_ND})
256 .AutoContiguous();256 .AutoContiguous();
257- return config_kirin;257+ return dynamicQuantKirinConfig;
258 }258 }
259};259};
260OP_ADD(AddRmsNormDynamicQuant);260OP_ADD(AddRmsNormDynamicQuant);
@@ -219,92 +219,92 @@ private:
219 219 
220 OpAICoreConfig GetKirinCoreConfig() const220 OpAICoreConfig GetKirinCoreConfig() const
221 {221 {
222- OpAICoreConfig config_kirin;222+ OpAICoreConfig v2KirinConfig;
223- config_kirin.DynamicCompileStaticFlag(true)223+ v2KirinConfig.DynamicCompileStaticFlag(true)
224 .DynamicFormatFlag(true)224 .DynamicFormatFlag(true)
225 .DynamicRankSupportFlag(true)225 .DynamicRankSupportFlag(true)
226 .DynamicShapeSupportFlag(true)226 .DynamicShapeSupportFlag(true)
227 .NeedCheckSupportFlag(false)227 .NeedCheckSupportFlag(false)
228 .PrecisionReduceFlag(true);228 .PrecisionReduceFlag(true);
229- config_kirin.Input("x1")229+ v2KirinConfig.Input("x1")
230 .ParamType(REQUIRED)230 .ParamType(REQUIRED)
231 .DataType({ge::DT_FLOAT16})231 .DataType({ge::DT_FLOAT16})
232 .Format({ge::FORMAT_ND})232 .Format({ge::FORMAT_ND})
233 .UnknownShapeFormat({ge::FORMAT_ND})233 .UnknownShapeFormat({ge::FORMAT_ND})
234 .AutoContiguous();234 .AutoContiguous();
235- config_kirin.Input("x2")235+ v2KirinConfig.Input("x2")
236 .ParamType(REQUIRED)236 .ParamType(REQUIRED)
237 .DataType({ge::DT_FLOAT16})237 .DataType({ge::DT_FLOAT16})
238 .Format({ge::FORMAT_ND})238 .Format({ge::FORMAT_ND})
239 .UnknownShapeFormat({ge::FORMAT_ND})239 .UnknownShapeFormat({ge::FORMAT_ND})
240 .AutoContiguous();240 .AutoContiguous();
241- config_kirin.Input("gamma")241+ v2KirinConfig.Input("gamma")
242 .ParamType(REQUIRED)242 .ParamType(REQUIRED)
243 .DataType({ge::DT_FLOAT16})243 .DataType({ge::DT_FLOAT16})
244 .Format({ge::FORMAT_ND})244 .Format({ge::FORMAT_ND})
245 .UnknownShapeFormat({ge::FORMAT_ND})245 .UnknownShapeFormat({ge::FORMAT_ND})
246 .AutoContiguous();246 .AutoContiguous();
247- config_kirin.Input("smooth_scale1")247+ v2KirinConfig.Input("smooth_scale1")
248 .ParamType(OPTIONAL)248 .ParamType(OPTIONAL)
249 .DataType({ge::DT_FLOAT16})249 .DataType({ge::DT_FLOAT16})
250 .Format({ge::FORMAT_ND})250 .Format({ge::FORMAT_ND})
251 .UnknownShapeFormat({ge::FORMAT_ND})251 .UnknownShapeFormat({ge::FORMAT_ND})
252 .AutoContiguous();252 .AutoContiguous();
253- config_kirin.Input("smooth_scale2")253+ v2KirinConfig.Input("smooth_scale2")
254 .ParamType(OPTIONAL)254 .ParamType(OPTIONAL)
255 .DataType({ge::DT_FLOAT16})255 .DataType({ge::DT_FLOAT16})
256 .Format({ge::FORMAT_ND})256 .Format({ge::FORMAT_ND})
257 .UnknownShapeFormat({ge::FORMAT_ND})257 .UnknownShapeFormat({ge::FORMAT_ND})
258 .AutoContiguous();258 .AutoContiguous();
259- config_kirin.Input("beta")259+ v2KirinConfig.Input("beta")
260 .ParamType(OPTIONAL)260 .ParamType(OPTIONAL)
261 .DataType({ge::DT_FLOAT16})261 .DataType({ge::DT_FLOAT16})
262 .Format({ge::FORMAT_ND})262 .Format({ge::FORMAT_ND})
263 .UnknownShapeFormat({ge::FORMAT_ND})263 .UnknownShapeFormat({ge::FORMAT_ND})
264 .AutoContiguous();264 .AutoContiguous();
265- config_kirin.Output("y1")265+ v2KirinConfig.Output("y1")
266 .ParamType(REQUIRED)266 .ParamType(REQUIRED)
267 .DataType({ge::DT_INT8})267 .DataType({ge::DT_INT8})
268 .Format({ge::FORMAT_ND})268 .Format({ge::FORMAT_ND})
269 .UnknownShapeFormat({ge::FORMAT_ND})269 .UnknownShapeFormat({ge::FORMAT_ND})
270 .AutoContiguous();270 .AutoContiguous();
271- config_kirin.Output("y2")271+ v2KirinConfig.Output("y2")
272 .ParamType(REQUIRED)272 .ParamType(REQUIRED)
273 .DataType({ge::DT_INT8})273 .DataType({ge::DT_INT8})
274 .Format({ge::FORMAT_ND})274 .Format({ge::FORMAT_ND})
275 .UnknownShapeFormat({ge::FORMAT_ND})275 .UnknownShapeFormat({ge::FORMAT_ND})
276 .AutoContiguous();276 .AutoContiguous();
277- config_kirin.Output("y3")277+ v2KirinConfig.Output("y3")
278 .ParamType(REQUIRED)278 .ParamType(REQUIRED)
279 .DataType({ge::DT_FLOAT})279 .DataType({ge::DT_FLOAT})
280 .Format({ge::FORMAT_ND})280 .Format({ge::FORMAT_ND})
281 .UnknownShapeFormat({ge::FORMAT_ND})281 .UnknownShapeFormat({ge::FORMAT_ND})
282 .AutoContiguous();282 .AutoContiguous();
283- config_kirin.Output("y4")283+ v2KirinConfig.Output("y4")
284 .ParamType(REQUIRED)284 .ParamType(REQUIRED)
285 .DataType({ge::DT_FLOAT16})285 .DataType({ge::DT_FLOAT16})
286 .Format({ge::FORMAT_ND})286 .Format({ge::FORMAT_ND})
287 .UnknownShapeFormat({ge::FORMAT_ND})287 .UnknownShapeFormat({ge::FORMAT_ND})
288 .AutoContiguous();288 .AutoContiguous();
289- config_kirin.Output("x")289+ v2KirinConfig.Output("x")
290 .ParamType(REQUIRED)290 .ParamType(REQUIRED)
291 .DataType({ge::DT_FLOAT16})291 .DataType({ge::DT_FLOAT16})
292 .Format({ge::FORMAT_ND})292 .Format({ge::FORMAT_ND})
293 .UnknownShapeFormat({ge::FORMAT_ND})293 .UnknownShapeFormat({ge::FORMAT_ND})
294 .AutoContiguous();294 .AutoContiguous();
295- config_kirin.Output("scale1")295+ v2KirinConfig.Output("scale1")
296 .ParamType(REQUIRED)296 .ParamType(REQUIRED)
297 .DataType({ge::DT_FLOAT})297 .DataType({ge::DT_FLOAT})
298 .Format({ge::FORMAT_ND})298 .Format({ge::FORMAT_ND})
299 .UnknownShapeFormat({ge::FORMAT_ND})299 .UnknownShapeFormat({ge::FORMAT_ND})
300 .AutoContiguous();300 .AutoContiguous();
301- config_kirin.Output("scale2")301+ v2KirinConfig.Output("scale2")
302 .ParamType(REQUIRED)302 .ParamType(REQUIRED)
303 .DataType({ge::DT_FLOAT})303 .DataType({ge::DT_FLOAT})
304 .Format({ge::FORMAT_ND})304 .Format({ge::FORMAT_ND})
305 .UnknownShapeFormat({ge::FORMAT_ND})305 .UnknownShapeFormat({ge::FORMAT_ND})
306 .AutoContiguous();306 .AutoContiguous();
307- return config_kirin;307+ return v2KirinConfig;
308 }308 }
309};309};
310OP_ADD(AddRmsNormDynamicQuantV2);310OP_ADD(AddRmsNormDynamicQuantV2);
@@ -120,26 +120,26 @@ static ge::graphStatus InferShape4AddRmsNormDynamicQuantV2(gert::InferShapeConte
120 auto ret = InferReduceShape(x1Shape, gammaShape, &outScaleShape);120 auto ret = InferReduceShape(x1Shape, gammaShape, &outScaleShape);
121 OP_CHECK_IF(!ret, OP_LOGE(context, "Dynamic AddRmsNormDynamicQuantV2 Not support gammaDimNum > xDimNum."),121 OP_CHECK_IF(!ret, OP_LOGE(context, "Dynamic AddRmsNormDynamicQuantV2 Not support gammaDimNum > xDimNum."),
122 return GRAPH_FAILED);122 return GRAPH_FAILED);
123- size_t outputMaskLen = outputMaskAttr == nullptr ? 0 : outputMaskAttr->GetSize();123+ size_t v2OutputMaskLen = outputMaskAttr == nullptr ? 0 : outputMaskAttr->GetSize();
124 124 
125 // unknown rank125 // unknown rank
126 if (IsUnknownRank(*x1Shape) || IsUnknownRank(*gammaShape)) {126 if (IsUnknownRank(*x1Shape) || IsUnknownRank(*gammaShape)) {
127- if (outputMaskLen != OUTPUT_MASK_NULLPTR_LEN) {127+ if (v2OutputMaskLen != OUTPUT_MASK_NULLPTR_LEN) {
128- const bool* outputMask = static_cast<const bool*>(outputMaskAttr->GetData());128+ const bool* v2OutputMask = static_cast<const bool*>(outputMaskAttr->GetData());
129- if (outputMask[0]) {129+ if (v2OutputMask[0]) {
130 SetUnknownRank(*outScale1Shape);130 SetUnknownRank(*outScale1Shape);
131 *y1Shape = *x1Shape;131 *y1Shape = *x1Shape;
132 } else {132 } else {
133 *outScale1Shape = gert::Shape({1});133 *outScale1Shape = gert::Shape({1});
134 }134 }
135- if (outputMask[1]) {135+ if (v2OutputMask[1]) {
136 SetUnknownRank(*outScale2Shape);136 SetUnknownRank(*outScale2Shape);
137 *y2Shape = *x1Shape;137 *y2Shape = *x1Shape;
138 } else {138 } else {
139 *outScale2Shape = gert::Shape({1});139 *outScale2Shape = gert::Shape({1});
140 }140 }
141- *y3Shape = outputMask[2] ? *x1Shape : gert::Shape({1});141+ *y3Shape = v2OutputMask[2] ? *x1Shape : gert::Shape({1});
142- *y4Shape = outputMask[3] ? *x1Shape : gert::Shape({1});142+ *y4Shape = v2OutputMask[3] ? *x1Shape : gert::Shape({1});
143 } else {143 } else {
144 *y1Shape = *x1Shape;144 *y1Shape = *x1Shape;
145 SetUnknownRank(*outScale1Shape);145 SetUnknownRank(*outScale1Shape);
@@ -159,21 +159,21 @@ static ge::graphStatus InferShape4AddRmsNormDynamicQuantV2(gert::InferShapeConte
159 *outScale1Shape = gert::Shape({1});159 *outScale1Shape = gert::Shape({1});
160 *outScale2Shape = gert::Shape({1});160 *outScale2Shape = gert::Shape({1});
161 161 
162- if (outputMaskLen != OUTPUT_MASK_NULLPTR_LEN) {162+ if (v2OutputMaskLen != OUTPUT_MASK_NULLPTR_LEN) {
163- OP_CHECK_IF(outputMaskLen != NUM_FOUR,163+ OP_CHECK_IF(v2OutputMaskLen != NUM_FOUR,
164 OP_LOGE(context, "When output_mask is not NULL, the array size must be 4."), return GRAPH_FAILED);164 OP_LOGE(context, "When output_mask is not NULL, the array size must be 4."), return GRAPH_FAILED);
165 165 
166- const bool* outputMask = static_cast<const bool*>(outputMaskAttr->GetData());166+ const bool* v2OutputMask = static_cast<const bool*>(outputMaskAttr->GetData());
167- if (outputMask[0]) {167+ if (v2OutputMask[0]) {
168 *y1Shape = *x1Shape;168 *y1Shape = *x1Shape;
169 *outScale1Shape = outScaleShape;169 *outScale1Shape = outScaleShape;
170 }170 }
171- if (outputMask[1]) {171+ if (v2OutputMask[1]) {
172 *y2Shape = *x1Shape;172 *y2Shape = *x1Shape;
173 *outScale2Shape = outScaleShape;173 *outScale2Shape = outScaleShape;
174 }174 }
175- *y3Shape = outputMask[2] ? *x1Shape : gert::Shape({1});175+ *y3Shape = v2OutputMask[2] ? *x1Shape : gert::Shape({1});
176- *y4Shape = outputMask[3] ? *x1Shape : gert::Shape({1});176+ *y4Shape = v2OutputMask[3] ? *x1Shape : gert::Shape({1});
177 } else {177 } else {
178 *y1Shape = *x1Shape;178 *y1Shape = *x1Shape;
179 *y3Shape = *x1Shape;179 *y3Shape = *x1Shape;
@@ -1,12 +1,11 @@
1/**1/**
2- * This program is free software, you can redistribute it and/or modify.
3 * Copyright (c) 2025 Huawei Technologies Co., Ltd.2 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
4- * This file is a part of the CANN Open Software.3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
5- * Licensed under CANN Open Software License Agreement Version 2.0 (the "License").4+ * CANN Open Software License Agreement Version 2.0 (the "License").
6 * Please refer to the License for details. You may not use this file except in compliance with the License.5 * Please refer to the License for details. You may not use this file except in compliance with the License.
7- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
8- * BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. See LICENSE in the root of7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
9- * the software repository for the full text of the License.8+ * See LICENSE in the root of the software repository for the full text of the License.
10 */9 */
11 10 
12/*!11/*!
@@ -123,77 +122,77 @@ public:
123 this->AICore().AddConfig("ascend910b");122 this->AICore().AddConfig("ascend910b");
124 this->AICore().AddConfig("ascend910_93");123 this->AICore().AddConfig("ascend910_93");
125 124 
126- OpAICoreConfig config310P;125+ OpAICoreConfig addRmsQuantConfig310p;
127- config310P.Input("x1")126+ addRmsQuantConfig310p.Input("x1")
128 .ParamType(REQUIRED)127 .ParamType(REQUIRED)
129 .DataType({ge::DT_FLOAT16})128 .DataType({ge::DT_FLOAT16})
130 .Format({ge::FORMAT_ND})129 .Format({ge::FORMAT_ND})
131 .UnknownShapeFormat({ge::FORMAT_ND})130 .UnknownShapeFormat({ge::FORMAT_ND})
132 .AutoContiguous();131 .AutoContiguous();
133- config310P.Input("x2")132+ addRmsQuantConfig310p.Input("x2")
134 .ParamType(REQUIRED)133 .ParamType(REQUIRED)
135 .DataType({ge::DT_FLOAT16})134 .DataType({ge::DT_FLOAT16})
136 .Format({ge::FORMAT_ND})135 .Format({ge::FORMAT_ND})
137 .UnknownShapeFormat({ge::FORMAT_ND})136 .UnknownShapeFormat({ge::FORMAT_ND})
138 .AutoContiguous();137 .AutoContiguous();
139- config310P.Input("gamma")138+ addRmsQuantConfig310p.Input("gamma")
140 .ParamType(REQUIRED)139 .ParamType(REQUIRED)
141 .DataType({ge::DT_FLOAT16})140 .DataType({ge::DT_FLOAT16})
142 .Format({ge::FORMAT_ND})141 .Format({ge::FORMAT_ND})
143 .UnknownShapeFormat({ge::FORMAT_ND})142 .UnknownShapeFormat({ge::FORMAT_ND})
144 .AutoContiguous();143 .AutoContiguous();
145- config310P.Input("scales1")144+ addRmsQuantConfig310p.Input("scales1")
146 .ParamType(REQUIRED)145 .ParamType(REQUIRED)
147 .DataType({ge::DT_FLOAT})146 .DataType({ge::DT_FLOAT})
148 .Format({ge::FORMAT_ND})147 .Format({ge::FORMAT_ND})
149 .UnknownShapeFormat({ge::FORMAT_ND})148 .UnknownShapeFormat({ge::FORMAT_ND})
150 .AutoContiguous();149 .AutoContiguous();
151- config310P.Input("scales2")150+ addRmsQuantConfig310p.Input("scales2")
152 .ParamType(OPTIONAL)151 .ParamType(OPTIONAL)
153 .DataType({ge::DT_FLOAT})152 .DataType({ge::DT_FLOAT})
154 .Format({ge::FORMAT_ND})153 .Format({ge::FORMAT_ND})
155 .UnknownShapeFormat({ge::FORMAT_ND})154 .UnknownShapeFormat({ge::FORMAT_ND})
156 .AutoContiguous();155 .AutoContiguous();
157- config310P.Input("zero_points1")156+ addRmsQuantConfig310p.Input("zero_points1")
158 .ParamType(OPTIONAL)157 .ParamType(OPTIONAL)
159 .DataType({ge::DT_INT32})158 .DataType({ge::DT_INT32})
160 .Format({ge::FORMAT_ND})159 .Format({ge::FORMAT_ND})
161 .UnknownShapeFormat({ge::FORMAT_ND})160 .UnknownShapeFormat({ge::FORMAT_ND})
162 .AutoContiguous();161 .AutoContiguous();
163- config310P.Input("zero_points2")162+ addRmsQuantConfig310p.Input("zero_points2")
164 .ParamType(OPTIONAL)163 .ParamType(OPTIONAL)
165 .DataType({ge::DT_INT32})164 .DataType({ge::DT_INT32})
166 .Format({ge::FORMAT_ND})165 .Format({ge::FORMAT_ND})
167 .UnknownShapeFormat({ge::FORMAT_ND})166 .UnknownShapeFormat({ge::FORMAT_ND})
168 .AutoContiguous();167 .AutoContiguous();
169- config310P.Input("beta")168+ addRmsQuantConfig310p.Input("beta")
170 .ParamType(OPTIONAL)169 .ParamType(OPTIONAL)
171 .DataType({ge::DT_FLOAT16})170 .DataType({ge::DT_FLOAT16})
172 .Format({ge::FORMAT_ND})171 .Format({ge::FORMAT_ND})
173 .UnknownShapeFormat({ge::FORMAT_ND})172 .UnknownShapeFormat({ge::FORMAT_ND})
174 .AutoContiguous();173 .AutoContiguous();
175- config310P.Output("y1")174+ addRmsQuantConfig310p.Output("y1")
176 .ParamType(REQUIRED)175 .ParamType(REQUIRED)
177 .DataType({ge::DT_INT8})176 .DataType({ge::DT_INT8})
178 .Format({ge::FORMAT_ND})177 .Format({ge::FORMAT_ND})
179 .UnknownShapeFormat({ge::FORMAT_ND})178 .UnknownShapeFormat({ge::FORMAT_ND})
180 .AutoContiguous();179 .AutoContiguous();
181- config310P.Output("y2")180+ addRmsQuantConfig310p.Output("y2")
182 .ParamType(REQUIRED)181 .ParamType(REQUIRED)
183 .DataType({ge::DT_INT8})182 .DataType({ge::DT_INT8})
184 .Format({ge::FORMAT_ND})183 .Format({ge::FORMAT_ND})
185 .UnknownShapeFormat({ge::FORMAT_ND})184 .UnknownShapeFormat({ge::FORMAT_ND})
186 .AutoContiguous();185 .AutoContiguous();
187- config310P.Output("x")186+ addRmsQuantConfig310p.Output("x")
188 .ParamType(REQUIRED)187 .ParamType(REQUIRED)
189 .DataType({ge::DT_FLOAT16})188 .DataType({ge::DT_FLOAT16})
190 .Format({ge::FORMAT_ND})189 .Format({ge::FORMAT_ND})
191 .UnknownShapeFormat({ge::FORMAT_ND})190 .UnknownShapeFormat({ge::FORMAT_ND})
192 .AutoContiguous();191 .AutoContiguous();
193- config310P.DynamicCompileStaticFlag(true).DynamicRankSupportFlag(true).DynamicShapeSupportFlag(true);192+ addRmsQuantConfig310p.DynamicCompileStaticFlag(true).DynamicRankSupportFlag(true).DynamicShapeSupportFlag(true);
194- this->AICore().AddConfig("ascend310p", config310P);193+ this->AICore().AddConfig("ascend310p", addRmsQuantConfig310p);
195- this->AICore().AddConfig("kirinx90", config310P);194+ this->AICore().AddConfig("kirinx90", addRmsQuantConfig310p);
196- this->AICore().AddConfig("kirin9030", config310P);195+ this->AICore().AddConfig("kirin9030", addRmsQuantConfig310p);
197 196 
198 OpAICoreConfig configRegbase;197 OpAICoreConfig configRegbase;
199 configRegbase.Input("x1")198 configRegbase.Input("x1")
@@ -260,4 +259,4 @@ public:
260 }259 }
261};260};
262OP_ADD(AddRmsNormQuant);261OP_ADD(AddRmsNormQuant);
263-} // namespace ops262+} // namespace ops
@@ -60,21 +60,21 @@ static ge::graphStatus InferShape4AddRmsNormQuant(gert::InferShapeContext* conte
60static graphStatus InferDataType4AddRmsNormQuant(gert::InferDataTypeContext* context)60static graphStatus InferDataType4AddRmsNormQuant(gert::InferDataTypeContext* context)
61{61{
62 OP_LOGD(context, "Begin to do InferDataType4AddRmsNormQuant");62 OP_LOGD(context, "Begin to do InferDataType4AddRmsNormQuant");
63- ge::DataType yDtype = ge::DT_INT8;63+ ge::DataType v2YDtype = ge::DT_INT8;
64- auto* attrs = context->GetAttrs();64+ auto* v2Attrs = context->GetAttrs();
65- if (attrs != nullptr) {65+ if (v2Attrs != nullptr) {
66- const int32_t* pDstDtype = attrs->GetAttrPointer<int32_t>(ATTR_INDEX_OF_DST_TYPE);66+ const int32_t* v2DstTypePtr = v2Attrs->GetAttrPointer<int32_t>(ATTR_INDEX_OF_DST_TYPE);
67- if (pDstDtype != nullptr) {67+ if (v2DstTypePtr != nullptr) {
68- int32_t dstDtype = *pDstDtype;68+ int32_t v2DstDtype = *v2DstTypePtr;
69- yDtype = static_cast<ge::DataType>(dstDtype);69+ v2YDtype = static_cast<ge::DataType>(v2DstDtype);
70- OP_CHECK_IF(std::find(OUT_TYPE_LIST.begin(), OUT_TYPE_LIST.end(), yDtype) == OUT_TYPE_LIST.end(),70+ OP_CHECK_IF(std::find(OUT_TYPE_LIST.begin(), OUT_TYPE_LIST.end(), v2YDtype) == OUT_TYPE_LIST.end(),
71 OP_LOGE(context,71 OP_LOGE(context,
72 "attr dst_type only support 2(int8), 34(hifloat8), 35(float8_e5m2), 36(float8_e4m3fn)"),72 "attr dst_type only support 2(int8), 34(hifloat8), 35(float8_e5m2), 36(float8_e4m3fn)"),
73 return ge::GRAPH_FAILED);73 return ge::GRAPH_FAILED);
74 }74 }
75 }75 }
76- context->SetOutputDataType(OUTPUT_Y1_IDX, yDtype);76+ context->SetOutputDataType(OUTPUT_Y1_IDX, v2YDtype);
77- context->SetOutputDataType(OUTPUT_Y2_IDX, yDtype);77+ context->SetOutputDataType(OUTPUT_Y2_IDX, v2YDtype);
78 context->SetOutputDataType(OUTPUT_X_IDX, context->GetInputDataType(INPUT_X1_IDX));78 context->SetOutputDataType(OUTPUT_X_IDX, context->GetInputDataType(INPUT_X1_IDX));
79 OP_LOGD(context, "End to do InferDataType4AddRmsNormQuant");79 OP_LOGD(context, "End to do InferDataType4AddRmsNormQuant");
80 return GRAPH_SUCCESS;80 return GRAPH_SUCCESS;
@@ -122,81 +122,81 @@ public:
122 this->AICore().AddConfig("ascend910b");122 this->AICore().AddConfig("ascend910b");
123 this->AICore().AddConfig("ascend910_93");123 this->AICore().AddConfig("ascend910_93");
124 124 
125- OpAICoreConfig config310P;125+ OpAICoreConfig v2Config310p;
126- config310P.Input("x1")126+ v2Config310p.Input("x1")
127 .ParamType(REQUIRED)127 .ParamType(REQUIRED)
128 .DataType({ge::DT_FLOAT16})128 .DataType({ge::DT_FLOAT16})
129 .Format({ge::FORMAT_ND})129 .Format({ge::FORMAT_ND})
130 .UnknownShapeFormat({ge::FORMAT_ND})130 .UnknownShapeFormat({ge::FORMAT_ND})
131 .AutoContiguous();131 .AutoContiguous();
132- config310P.Input("x2")132+ v2Config310p.Input("x2")
133 .ParamType(REQUIRED)133 .ParamType(REQUIRED)
134 .DataType({ge::DT_FLOAT16})134 .DataType({ge::DT_FLOAT16})
135 .Format({ge::FORMAT_ND})135 .Format({ge::FORMAT_ND})
136 .UnknownShapeFormat({ge::FORMAT_ND})136 .UnknownShapeFormat({ge::FORMAT_ND})
137 .AutoContiguous();137 .AutoContiguous();
138- config310P.Input("gamma")138+ v2Config310p.Input("gamma")
139 .ParamType(REQUIRED)139 .ParamType(REQUIRED)
140 .DataType({ge::DT_FLOAT16})140 .DataType({ge::DT_FLOAT16})
141 .Format({ge::FORMAT_ND})141 .Format({ge::FORMAT_ND})
142 .UnknownShapeFormat({ge::FORMAT_ND})142 .UnknownShapeFormat({ge::FORMAT_ND})
143 .AutoContiguous();143 .AutoContiguous();
144- config310P.Input("scales1")144+ v2Config310p.Input("scales1")
145 .ParamType(REQUIRED)145 .ParamType(REQUIRED)
146 .DataType({ge::DT_FLOAT})146 .DataType({ge::DT_FLOAT})
147 .Format({ge::FORMAT_ND})147 .Format({ge::FORMAT_ND})
148 .UnknownShapeFormat({ge::FORMAT_ND})148 .UnknownShapeFormat({ge::FORMAT_ND})
149 .AutoContiguous();149 .AutoContiguous();
150- config310P.Input("scales2")150+ v2Config310p.Input("scales2")
151 .ParamType(OPTIONAL)151 .ParamType(OPTIONAL)
152 .DataType({ge::DT_FLOAT})152 .DataType({ge::DT_FLOAT})
153 .Format({ge::FORMAT_ND})153 .Format({ge::FORMAT_ND})
154 .UnknownShapeFormat({ge::FORMAT_ND})154 .UnknownShapeFormat({ge::FORMAT_ND})
155 .AutoContiguous();155 .AutoContiguous();
156- config310P.Input("zero_points1")156+ v2Config310p.Input("zero_points1")
157 .ParamType(OPTIONAL)157 .ParamType(OPTIONAL)
158 .DataType({ge::DT_INT32})158 .DataType({ge::DT_INT32})
159 .Format({ge::FORMAT_ND})159 .Format({ge::FORMAT_ND})
160 .UnknownShapeFormat({ge::FORMAT_ND})160 .UnknownShapeFormat({ge::FORMAT_ND})
161 .AutoContiguous();161 .AutoContiguous();
162- config310P.Input("zero_points2")162+ v2Config310p.Input("zero_points2")
163 .ParamType(OPTIONAL)163 .ParamType(OPTIONAL)
164 .DataType({ge::DT_INT32})164 .DataType({ge::DT_INT32})
165 .Format({ge::FORMAT_ND})165 .Format({ge::FORMAT_ND})
166 .UnknownShapeFormat({ge::FORMAT_ND})166 .UnknownShapeFormat({ge::FORMAT_ND})
167 .AutoContiguous();167 .AutoContiguous();
168- config310P.Input("bias")168+ v2Config310p.Input("bias")
169 .ParamType(OPTIONAL)169 .ParamType(OPTIONAL)
170 .DataType({ge::DT_FLOAT16})170 .DataType({ge::DT_FLOAT16})
171 .Format({ge::FORMAT_ND})171 .Format({ge::FORMAT_ND})
172 .UnknownShapeFormat({ge::FORMAT_ND})172 .UnknownShapeFormat({ge::FORMAT_ND})
173 .AutoContiguous();173 .AutoContiguous();
174- config310P.Output("y1")174+ v2Config310p.Output("y1")
175 .ParamType(REQUIRED)175 .ParamType(REQUIRED)
176 .DataType({ge::DT_INT8})176 .DataType({ge::DT_INT8})
177 .Format({ge::FORMAT_ND})177 .Format({ge::FORMAT_ND})
178 .UnknownShapeFormat({ge::FORMAT_ND})178 .UnknownShapeFormat({ge::FORMAT_ND})
179 .AutoContiguous();179 .AutoContiguous();
180- config310P.Output("y2")180+ v2Config310p.Output("y2")
181 .ParamType(REQUIRED)181 .ParamType(REQUIRED)
182 .DataType({ge::DT_INT8})182 .DataType({ge::DT_INT8})
183 .Format({ge::FORMAT_ND})183 .Format({ge::FORMAT_ND})
184 .UnknownShapeFormat({ge::FORMAT_ND})184 .UnknownShapeFormat({ge::FORMAT_ND})
185 .AutoContiguous();185 .AutoContiguous();
186- config310P.Output("x")186+ v2Config310p.Output("x")
187 .ParamType(OPTIONAL)187 .ParamType(OPTIONAL)
188 .DataType({ge::DT_FLOAT16})188 .DataType({ge::DT_FLOAT16})
189 .Format({ge::FORMAT_ND})189 .Format({ge::FORMAT_ND})
190 .UnknownShapeFormat({ge::FORMAT_ND})190 .UnknownShapeFormat({ge::FORMAT_ND})
191 .AutoContiguous();191 .AutoContiguous();
192- config310P.Output("resOut")192+ v2Config310p.Output("resOut")
193 .ParamType(OPTIONAL)193 .ParamType(OPTIONAL)
194 .DataType({ge::DT_FLOAT16})194 .DataType({ge::DT_FLOAT16})
195 .Format({ge::FORMAT_ND})195 .Format({ge::FORMAT_ND})
196 .UnknownShapeFormat({ge::FORMAT_ND})196 .UnknownShapeFormat({ge::FORMAT_ND})
197 .AutoContiguous();197 .AutoContiguous();
198- config310P.DynamicCompileStaticFlag(true).DynamicRankSupportFlag(true).DynamicShapeSupportFlag(true);198+ v2Config310p.DynamicCompileStaticFlag(true).DynamicRankSupportFlag(true).DynamicShapeSupportFlag(true);
199- this->AICore().AddConfig("ascend310p", config310P);199+ this->AICore().AddConfig("ascend310p", v2Config310p);
200 200 
201 static const std::vector<ge::DataType> xDtypeRegbase = {201 static const std::vector<ge::DataType> xDtypeRegbase = {
202 ge::DT_FLOAT16, ge::DT_BF16, ge::DT_FLOAT, ge::DT_FLOAT16, ge::DT_BF16, ge::DT_FLOAT16, ge::DT_BF16,202 ge::DT_FLOAT16, ge::DT_BF16, ge::DT_FLOAT, ge::DT_FLOAT16, ge::DT_BF16, ge::DT_FLOAT16, ge::DT_BF16,
@@ -292,4 +292,4 @@ public:
292 }292 }
293};293};
294OP_ADD(AddRmsNormQuantV2);294OP_ADD(AddRmsNormQuantV2);
295-} // namespace ops295+} // namespace ops
@@ -209,12 +209,12 @@ aclnnStatus aclnnBatchNormElemtGetWorkspaceSize(const aclTensor* input, const ac
209 }209 }
210 aclIntArray* originShapeArray = uniqueExecutor.get()->AllocIntArray(originShapes, inputDims);210 aclIntArray* originShapeArray = uniqueExecutor.get()->AllocIntArray(originShapes, inputDims);
211 auto bnOutputReshape = l0op::Reshape(bnOutput, originShapeArray, uniqueExecutor.get());211 auto bnOutputReshape = l0op::Reshape(bnOutput, originShapeArray, uniqueExecutor.get());
212- auto bnOutputReformat = l0op::ReFormat(bnOutputReshape, Format::FORMAT_ND);212+ auto elemtOutputReformat = l0op::ReFormat(bnOutputReshape, Format::FORMAT_ND);
213- auto viewCopyResult = l0op::ViewCopy(bnOutputReformat, output, uniqueExecutor.get());213+ auto elemtViewCopyResult = l0op::ViewCopy(elemtOutputReformat, output, uniqueExecutor.get());
214- CHECK_RET(viewCopyResult != nullptr, ACLNN_ERR_INNER_NULLPTR);214+ CHECK_RET(elemtViewCopyResult != nullptr, ACLNN_ERR_INNER_NULLPTR);
215 } else {215 } else {
216- auto viewCopyResult = l0op::ViewCopy(bnOutput, output, uniqueExecutor.get());216+ auto elemtViewCopyResult = l0op::ViewCopy(bnOutput, output, uniqueExecutor.get());
217- CHECK_RET(viewCopyResult != nullptr, ACLNN_ERR_INNER_NULLPTR);217+ CHECK_RET(elemtViewCopyResult != nullptr, ACLNN_ERR_INNER_NULLPTR);
218 }218 }
219 219 
220 *workspaceSize = uniqueExecutor->GetWorkspaceSize();220 *workspaceSize = uniqueExecutor->GetWorkspaceSize();
@@ -85,23 +85,23 @@ static inline bool isBatchNormSupportAscendC(void)
85 return socVersionSupport;85 return socVersionSupport;
86}86}
87 87 
88-static bool CheckMaskNotNull(const aclTensor* gradInput, const aclTensor* gradWeight, const aclTensor* gradBias,88+static bool CheckMaskNotNull(const aclTensor* fastGradInput, const aclTensor* fastGradWeight,
89- const aclBoolArray* outputMask)89+ const aclTensor* fastGradBias, const aclBoolArray* fastOutputMask)
90{90{
91 // fast batch norm backward: check output mask validity91 // fast batch norm backward: check output mask validity
92- OP_CHECK_NULL(outputMask, return false);92+ OP_CHECK_NULL(fastOutputMask, return false);
93- if (outputMask->Size() < GRAD_WEIGHT_INDEX) {93+ if (fastOutputMask->Size() < GRAD_WEIGHT_INDEX) {
94 OP_LOGE(ACLNN_ERR_PARAM_INVALID, "outputMask size should not be less than 1.");94 OP_LOGE(ACLNN_ERR_PARAM_INVALID, "outputMask size should not be less than 1.");
95 return false;95 return false;
96 }96 }
97- if ((*outputMask)[0]) {97+ if ((*fastOutputMask)[0]) {
98- OP_CHECK_NULL(gradInput, return false);98+ OP_CHECK_NULL(fastGradInput, return false);
99 }99 }
100- if ((*outputMask)[GRAD_WEIGHT_INDEX]) {100+ if ((*fastOutputMask)[GRAD_WEIGHT_INDEX]) {
101- OP_CHECK_NULL(gradWeight, return false);101+ OP_CHECK_NULL(fastGradWeight, return false);
102 }102 }
103- if ((*outputMask)[GRAD_BIAS_INDEX]) {103+ if ((*fastOutputMask)[GRAD_BIAS_INDEX]) {
104- OP_CHECK_NULL(gradBias, return false);104+ OP_CHECK_NULL(fastGradBias, return false);
105 }105 }
106 return true;106 return true;
107}107}
@@ -118,9 +118,9 @@ static const std::initializer_list<DataType>& GetDtypeSupportList()
118 118 
119static bool CheckDtypeValid(const aclTensor* gradOut, const aclTensor* input)119static bool CheckDtypeValid(const aclTensor* gradOut, const aclTensor* input)
120{120{
121- const auto& supportList = GetDtypeSupportList();121+ const auto& fastSupportList = GetDtypeSupportList();
122- OP_CHECK_DTYPE_NOT_SUPPORT(gradOut, supportList, return false);122+ OP_CHECK_DTYPE_NOT_SUPPORT(gradOut, fastSupportList, return false);
123- OP_CHECK_DTYPE_NOT_SUPPORT(input, supportList, return false);123+ OP_CHECK_DTYPE_NOT_SUPPORT(input, fastSupportList, return false);
124 OP_CHECK_DTYPE_NOT_SAME(input, gradOut, return false);124 OP_CHECK_DTYPE_NOT_SAME(input, gradOut, return false);
125 125 
126 return true;126 return true;
@@ -129,15 +129,15 @@ static bool CheckDtypeValid(const aclTensor* gradOut, const aclTensor* input)
129static bool CheckGradDtypeValid(const aclTensor* gradInput, const aclTensor* gradWeight, const aclTensor* gradBias,129static bool CheckGradDtypeValid(const aclTensor* gradInput, const aclTensor* gradWeight, const aclTensor* gradBias,
130 const aclBoolArray* outputMask)130 const aclBoolArray* outputMask)
131{131{
132- const auto& supportList = GetDtypeSupportList();132+ const auto& fastSupportList = GetDtypeSupportList();
133 if ((*outputMask)[0]) {133 if ((*outputMask)[0]) {
134- OP_CHECK_DTYPE_NOT_SUPPORT(gradInput, supportList, return false);134+ OP_CHECK_DTYPE_NOT_SUPPORT(gradInput, fastSupportList, return false);
135 }135 }
136 if ((*outputMask)[GRAD_WEIGHT_INDEX]) {136 if ((*outputMask)[GRAD_WEIGHT_INDEX]) {
137- OP_CHECK_DTYPE_NOT_SUPPORT(gradWeight, supportList, return false);137+ OP_CHECK_DTYPE_NOT_SUPPORT(gradWeight, fastSupportList, return false);
138 }138 }
139 if ((*outputMask)[GRAD_BIAS_INDEX]) {139 if ((*outputMask)[GRAD_BIAS_INDEX]) {
140- OP_CHECK_DTYPE_NOT_SUPPORT(gradBias, supportList, return false);140+ OP_CHECK_DTYPE_NOT_SUPPORT(gradBias, fastSupportList, return false);
141 }141 }
142 142 
143 return true;143 return true;
@@ -146,21 +146,21 @@ static bool CheckGradDtypeValid(const aclTensor* gradInput, const aclTensor* gra
146static bool CheckOtherDtypeValid(const aclTensor* weight, const aclTensor* runningMean, const aclTensor* runningVar,146static bool CheckOtherDtypeValid(const aclTensor* weight, const aclTensor* runningMean, const aclTensor* runningVar,
147 const aclTensor* saveMean, const aclTensor* saveInvstd)147 const aclTensor* saveMean, const aclTensor* saveInvstd)
148{148{
149- const auto& supportList = GetDtypeSupportList();149+ const auto& fastSupportList = GetDtypeSupportList();
150 if (weight != nullptr) {150 if (weight != nullptr) {
151- OP_CHECK_DTYPE_NOT_SUPPORT(weight, supportList, return false);151+ OP_CHECK_DTYPE_NOT_SUPPORT(weight, fastSupportList, return false);
152 }152 }
153 if (runningMean != nullptr) {153 if (runningMean != nullptr) {
154- OP_CHECK_DTYPE_NOT_SUPPORT(runningMean, supportList, return false);154+ OP_CHECK_DTYPE_NOT_SUPPORT(runningMean, fastSupportList, return false);
155 }155 }
156 if (runningVar != nullptr) {156 if (runningVar != nullptr) {
157- OP_CHECK_DTYPE_NOT_SUPPORT(runningVar, supportList, return false);157+ OP_CHECK_DTYPE_NOT_SUPPORT(runningVar, fastSupportList, return false);
158 }158 }
159 if (saveMean != nullptr) {159 if (saveMean != nullptr) {
160- OP_CHECK_DTYPE_NOT_SUPPORT(saveMean, supportList, return false);160+ OP_CHECK_DTYPE_NOT_SUPPORT(saveMean, fastSupportList, return false);
161 }161 }
162 if (saveInvstd != nullptr) {162 if (saveInvstd != nullptr) {
163- OP_CHECK_DTYPE_NOT_SUPPORT(saveInvstd, supportList, return false);163+ OP_CHECK_DTYPE_NOT_SUPPORT(saveInvstd, fastSupportList, return false);
164 }164 }
165 return true;165 return true;
166}166}
@@ -208,27 +208,28 @@ static bool CheckShape(const aclTensor* gradOut, const aclTensor* input, const a
208 return true;208 return true;
209}209}
210 210 
211-static bool CheckOtherShape(int dimC, const aclTensor* weight, const aclTensor* runningMean,211+static bool CheckOtherShape(int fastDimC, const aclTensor* fastWeight, const aclTensor* fastRunningMean,
212- const aclTensor* runningVar)212+ const aclTensor* fastRunningVar)
213{213{
214- if (weight != nullptr && (weight->GetViewShape().GetDimNum() != 1 || weight->GetViewShape()[0] != dimC)) {214+ if (fastWeight != nullptr &&
215+ (fastWeight->GetViewShape().GetDimNum() != 1 || fastWeight->GetViewShape()[0] != fastDimC)) {
215 OP_LOGE(ACLNN_ERR_PARAM_INVALID,216 OP_LOGE(ACLNN_ERR_PARAM_INVALID,
216- "Dim of weight should be one and shape is channel num of input[%d], but got [%s].", dimC,217+ "Dim of weight should be one and shape is channel num of input[%d], but got [%s].", fastDimC,
217- op::ToString(weight->GetViewShape()).GetString());218+ op::ToString(fastWeight->GetViewShape()).GetString());
218 return false;219 return false;
219 }220 }
220- if (runningMean != nullptr &&221+ if (fastRunningMean != nullptr &&
221- (runningMean->GetViewShape().GetDimNum() != 1 || runningMean->GetViewShape()[0] != dimC)) {222+ (fastRunningMean->GetViewShape().GetDimNum() != 1 || fastRunningMean->GetViewShape()[0] != fastDimC)) {
222 OP_LOGE(ACLNN_ERR_PARAM_INVALID,223 OP_LOGE(ACLNN_ERR_PARAM_INVALID,
223- "Dim of runningMean should be one and shape is channel num of input[%d], but got [%s].", dimC,224+ "Dim of runningMean should be one and shape is channel num of input[%d], but got [%s].", fastDimC,
224- op::ToString(runningMean->GetViewShape()).GetString());225+ op::ToString(fastRunningMean->GetViewShape()).GetString());
225 return false;226 return false;
226 }227 }
227- if (runningVar != nullptr &&228+ if (fastRunningVar != nullptr &&
228- (runningVar->GetViewShape().GetDimNum() != 1 || runningVar->GetViewShape()[0] != dimC)) {229+ (fastRunningVar->GetViewShape().GetDimNum() != 1 || fastRunningVar->GetViewShape()[0] != fastDimC)) {
229 OP_LOGE(ACLNN_ERR_PARAM_INVALID,230 OP_LOGE(ACLNN_ERR_PARAM_INVALID,
230- "Dim of runningVar should be one and shape is channel num of input[%d], but got [%s].", dimC,231+ "Dim of runningVar should be one and shape is channel num of input[%d], but got [%s].", fastDimC,
231- op::ToString(runningVar->GetViewShape()).GetString());232+ op::ToString(fastRunningVar->GetViewShape()).GetString());
232 return false;233 return false;
233 }234 }
234 return true;235 return true;
@@ -482,32 +483,32 @@ aclnnStatus FastBatchNormBackwardProcForAscendC(const aclTensor* gradOut, const
482 return ACLNN_SUCCESS;483 return ACLNN_SUCCESS;
483}484}
484 485 
485-aclnnStatus FastBatchNormBackwardPrepare(const aclTensor* input, const aclTensor*& weight,486+aclnnStatus FastBatchNormBackwardPrepare(const aclTensor* input, const aclTensor*& fastWeight,
486- const aclTensor*& runningMean, const aclTensor*& runningVar,487+ const aclTensor*& fastRunningMean, const aclTensor*& fastRunningVar,
487- const aclTensor*& saveMean, const aclTensor*& saveInvstd,488+ const aclTensor*& fastSaveMean, const aclTensor*& fastSaveInvstd,
488 aclOpExecutor* executor)489 aclOpExecutor* executor)
489{490{
490 // fast batch norm backward: prepare default values for optional tensors491 // fast batch norm backward: prepare default values for optional tensors
491- size_t dimC = input->GetViewShape()[1];492+ size_t fastDimC = input->GetViewShape()[1];
492- if (runningMean == nullptr) {493+ if (fastRunningMean == nullptr) {
493- runningMean = op::FillScalar(dimC, 0, executor);494+ fastRunningMean = op::FillScalar(fastDimC, 0, executor);
494- CHECK_RET(runningMean != nullptr, ACLNN_ERR_INNER_NULLPTR);495+ CHECK_RET(fastRunningMean != nullptr, ACLNN_ERR_INNER_NULLPTR);
495 }496 }
496- if (runningVar == nullptr) {497+ if (fastRunningVar == nullptr) {
497- runningVar = op::FillScalar(dimC, 1, executor);498+ fastRunningVar = op::FillScalar(fastDimC, 1, executor);
498- CHECK_RET(runningVar != nullptr, ACLNN_ERR_INNER_NULLPTR);499+ CHECK_RET(fastRunningVar != nullptr, ACLNN_ERR_INNER_NULLPTR);
499 }500 }
500- if (weight == nullptr) {501+ if (fastWeight == nullptr) {
501- weight = op::FillScalar(dimC, 1, executor);502+ fastWeight = op::FillScalar(fastDimC, 1, executor);
502- CHECK_RET(weight != nullptr, ACLNN_ERR_INNER_NULLPTR);503+ CHECK_RET(fastWeight != nullptr, ACLNN_ERR_INNER_NULLPTR);
503 }504 }
504- if (saveMean == nullptr) {505+ if (fastSaveMean == nullptr) {
505- saveMean = op::FillScalar(dimC, 0, executor);506+ fastSaveMean = op::FillScalar(fastDimC, 0, executor);
506- CHECK_RET(saveMean != nullptr, ACLNN_ERR_INNER_NULLPTR);507+ CHECK_RET(fastSaveMean != nullptr, ACLNN_ERR_INNER_NULLPTR);
507 }508 }
508- if (saveInvstd == nullptr) {509+ if (fastSaveInvstd == nullptr) {
509- saveInvstd = op::FillScalar(dimC, 1, executor);510+ fastSaveInvstd = op::FillScalar(fastDimC, 1, executor);
510- CHECK_RET(saveInvstd != nullptr, ACLNN_ERR_INNER_NULLPTR);511+ CHECK_RET(fastSaveInvstd != nullptr, ACLNN_ERR_INNER_NULLPTR);
511 }512 }
512 return ACLNN_SUCCESS;513 return ACLNN_SUCCESS;
513}514}
@@ -39,7 +39,7 @@ constexpr int32_t DEEP_NORM_OUTPUT_Y_INDEX = 2;
39 39 
40inline ge::graphStatus CheckDeepNormShapeDim(const gert::TilingContext* context)40inline ge::graphStatus CheckDeepNormShapeDim(const gert::TilingContext* context)
41{41{
42- const gert::StorageShape* xShape = context->GetInputShape(DEEP_NORM_INPUT_X_INDEX);42+ const gert::StorageShape* deepXShape = context->GetInputShape(DEEP_NORM_INPUT_X_INDEX);
43 const gert::StorageShape* gxShape = context->GetInputShape(DEEP_NORM_INPUT_GX_INDEX);43 const gert::StorageShape* gxShape = context->GetInputShape(DEEP_NORM_INPUT_GX_INDEX);
44 const gert::StorageShape* betaShape = context->GetInputShape(DEEP_NORM_INPUT_BETA_INDEX);44 const gert::StorageShape* betaShape = context->GetInputShape(DEEP_NORM_INPUT_BETA_INDEX);
45 const gert::StorageShape* gammaShape = context->GetInputShape(DEEP_NORM_INPUT_GAMMA_INDEX);45 const gert::StorageShape* gammaShape = context->GetInputShape(DEEP_NORM_INPUT_GAMMA_INDEX);
@@ -47,7 +47,7 @@ inline ge::graphStatus CheckDeepNormShapeDim(const gert::TilingContext* context)
47 const gert::StorageShape* rstdShape = context->GetOutputShape(DEEP_NORM_OUTPUT_RSTD_INDEX);47 const gert::StorageShape* rstdShape = context->GetOutputShape(DEEP_NORM_OUTPUT_RSTD_INDEX);
48 const gert::StorageShape* yShape = context->GetOutputShape(DEEP_NORM_OUTPUT_Y_INDEX);48 const gert::StorageShape* yShape = context->GetOutputShape(DEEP_NORM_OUTPUT_Y_INDEX);
49 49 
50- OP_CHECK_NULL_WITH_CONTEXT(context, xShape);50+ OP_CHECK_NULL_WITH_CONTEXT(context, deepXShape);
51 OP_CHECK_NULL_WITH_CONTEXT(context, gxShape);51 OP_CHECK_NULL_WITH_CONTEXT(context, gxShape);
52 OP_CHECK_NULL_WITH_CONTEXT(context, betaShape);52 OP_CHECK_NULL_WITH_CONTEXT(context, betaShape);
53 OP_CHECK_NULL_WITH_CONTEXT(context, gammaShape);53 OP_CHECK_NULL_WITH_CONTEXT(context, gammaShape);
@@ -55,7 +55,7 @@ inline ge::graphStatus CheckDeepNormShapeDim(const gert::TilingContext* context)
55 OP_CHECK_NULL_WITH_CONTEXT(context, rstdShape);55 OP_CHECK_NULL_WITH_CONTEXT(context, rstdShape);
56 OP_CHECK_NULL_WITH_CONTEXT(context, yShape);56 OP_CHECK_NULL_WITH_CONTEXT(context, yShape);
57 57 
58- size_t xDimNum = xShape->GetStorageShape().GetDimNum();58+ size_t xDimNum = deepXShape->GetStorageShape().GetDimNum();
59 size_t gxDimNum = gxShape->GetStorageShape().GetDimNum();59 size_t gxDimNum = gxShape->GetStorageShape().GetDimNum();
60 size_t betaDimNum = betaShape->GetStorageShape().GetDimNum();60 size_t betaDimNum = betaShape->GetStorageShape().GetDimNum();
61 size_t gammaDimNum = gammaShape->GetStorageShape().GetDimNum();61 size_t gammaDimNum = gammaShape->GetStorageShape().GetDimNum();
@@ -83,37 +83,37 @@ public:
83private:83private:
84 OpAICoreConfig GetKirinCoreConfig() const84 OpAICoreConfig GetKirinCoreConfig() const
85 {85 {
86- OpAICoreConfig config_kirin;86+ OpAICoreConfig gemmaKirinConfig;
87- config_kirin.DynamicCompileStaticFlag(true)87+ gemmaKirinConfig.DynamicCompileStaticFlag(true)
88 .DynamicFormatFlag(true)88 .DynamicFormatFlag(true)
89 .DynamicRankSupportFlag(true)89 .DynamicRankSupportFlag(true)
90 .DynamicShapeSupportFlag(true)90 .DynamicShapeSupportFlag(true)
91 .NeedCheckSupportFlag(false)91 .NeedCheckSupportFlag(false)
92 .PrecisionReduceFlag(true);92 .PrecisionReduceFlag(true);
93- config_kirin.Input("x")93+ gemmaKirinConfig.Input("x")
94 .ParamType(REQUIRED)94 .ParamType(REQUIRED)
95 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})95 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
96 .Format({ge::FORMAT_ND, ge::FORMAT_ND})96 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
97 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})97 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
98 .AutoContiguous();98 .AutoContiguous();
99- config_kirin.Input("gamma")99+ gemmaKirinConfig.Input("gamma")
100 .ParamType(REQUIRED)100 .ParamType(REQUIRED)
101 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})101 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
102 .Format({ge::FORMAT_ND, ge::FORMAT_ND})102 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
103 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})103 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
104 .AutoContiguous();104 .AutoContiguous();
105- config_kirin.Output("y")105+ gemmaKirinConfig.Output("y")
106 .ParamType(REQUIRED)106 .ParamType(REQUIRED)
107 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})107 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
108 .Format({ge::FORMAT_ND, ge::FORMAT_ND})108 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
109 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});109 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});
110- config_kirin.Output("rstd")110+ gemmaKirinConfig.Output("rstd")
111 .ParamType(REQUIRED)111 .ParamType(REQUIRED)
112 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})112 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})
113 .Format({ge::FORMAT_ND, ge::FORMAT_ND})113 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
114 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});114 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});
115- return config_kirin;115+ return gemmaKirinConfig;
116 }116 }
117};117};
118OP_ADD(GemmaRmsNorm);118OP_ADD(GemmaRmsNorm);
119-} // namespace ops119+} // namespace ops
@@ -282,15 +282,15 @@ static const aclTensor* RstdProcess(const aclTensor* variance, int64_t N, int64_
282 282 
283static aclnnStatus FillScalar(aclTensor* out, float val, aclOpExecutor* executor)283static aclnnStatus FillScalar(aclTensor* out, float val, aclOpExecutor* executor)
284{284{
285- FVector<int64_t> shape;285+ FVector<int64_t> groupShape;
286 size_t dimNum = out->GetViewShape().GetDimNum();286 size_t dimNum = out->GetViewShape().GetDimNum();
287 for (size_t idx = 0; idx < dimNum; idx++) {287 for (size_t idx = 0; idx < dimNum; idx++) {
288 int64_t tmpVal = out->GetViewShape().GetDim(idx);288 int64_t tmpVal = out->GetViewShape().GetDim(idx);
289- shape.push_back(tmpVal);289+ groupShape.push_back(tmpVal);
290 }290 }
291- auto dims = executor->ConvertToTensor(shape.data(), shape.size(), DataType::DT_INT64);291+ auto dims = executor->ConvertToTensor(groupShape.data(), groupShape.size(), DataType::DT_INT64);
292 CHECK_RET(dims != nullptr, ACLNN_ERR_INNER_NULLPTR);292 CHECK_RET(dims != nullptr, ACLNN_ERR_INNER_NULLPTR);
293- auto shapeArray = executor->AllocIntArray(shape.data(), shape.size());293+ auto shapeArray = executor->AllocIntArray(groupShape.data(), groupShape.size());
294 CHECK_RET(shapeArray != nullptr, ACLNN_ERR_INNER_NULLPTR);294 CHECK_RET(shapeArray != nullptr, ACLNN_ERR_INNER_NULLPTR);
295 295 
296 FVector<float> valVector = {val};296 FVector<float> valVector = {val};
@@ -77,64 +77,64 @@ public:
77 this->AICore().AddConfig("ascend910b");77 this->AICore().AddConfig("ascend910b");
78 this->AICore().AddConfig("ascend910_93");78 this->AICore().AddConfig("ascend910_93");
79 79 
80- OpAICoreConfig config_310p;80+ OpAICoreConfig inplaceConfig310p;
81- config_310p.Input("x1")81+ inplaceConfig310p.Input("x1")
82 .ParamType(REQUIRED)82 .ParamType(REQUIRED)
83 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})83 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
84 .Format({ge::FORMAT_ND, ge::FORMAT_ND})84 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
85 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})85 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
86 .AutoContiguous();86 .AutoContiguous();
87- config_310p.Input("x2")87+ inplaceConfig310p.Input("x2")
88 .ParamType(REQUIRED)88 .ParamType(REQUIRED)
89 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})89 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
90 .Format({ge::FORMAT_ND, ge::FORMAT_ND})90 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
91 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})91 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
92 .AutoContiguous();92 .AutoContiguous();
93- config_310p.Input("gamma")93+ inplaceConfig310p.Input("gamma")
94 .ParamType(REQUIRED)94 .ParamType(REQUIRED)
95 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})95 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
96 .Format({ge::FORMAT_ND, ge::FORMAT_ND})96 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
97 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})97 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
98 .AutoContiguous();98 .AutoContiguous();
99- config_310p.Input("beta")99+ inplaceConfig310p.Input("beta")
100 .ParamType(REQUIRED)100 .ParamType(REQUIRED)
101 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})101 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
102 .Format({ge::FORMAT_ND, ge::FORMAT_ND})102 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
103 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})103 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
104 .AutoContiguous();104 .AutoContiguous();
105- config_310p.Input("bias")105+ inplaceConfig310p.Input("bias")
106 .ParamType(OPTIONAL)106 .ParamType(OPTIONAL)
107 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})107 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
108 .Format({ge::FORMAT_ND, ge::FORMAT_ND})108 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
109 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})109 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
110 .AutoContiguous();110 .AutoContiguous();
111- config_310p.Output("x1")111+ inplaceConfig310p.Output("x1")
112 .ParamType(REQUIRED)112 .ParamType(REQUIRED)
113 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})113 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
114 .Format({ge::FORMAT_ND, ge::FORMAT_ND})114 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
115 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});115 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});
116- config_310p.Output("mean")116+ inplaceConfig310p.Output("mean")
117 .ParamType(REQUIRED)117 .ParamType(REQUIRED)
118 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})118 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})
119 .Format({ge::FORMAT_ND, ge::FORMAT_ND})119 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
120 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});120 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});
121- config_310p.Output("rstd")121+ inplaceConfig310p.Output("rstd")
122 .ParamType(REQUIRED)122 .ParamType(REQUIRED)
123 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})123 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})
124 .Format({ge::FORMAT_ND, ge::FORMAT_ND})124 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
125 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});125 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});
126- config_310p.Output("x2")126+ inplaceConfig310p.Output("x2")
127 .ParamType(REQUIRED)127 .ParamType(REQUIRED)
128 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})128 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
129 .Format({ge::FORMAT_ND, ge::FORMAT_ND})129 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
130 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});130 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});
131- config_310p.DynamicCompileStaticFlag(true)131+ inplaceConfig310p.DynamicCompileStaticFlag(true)
132 .DynamicRankSupportFlag(true)132 .DynamicRankSupportFlag(true)
133 .DynamicShapeSupportFlag(true)133 .DynamicShapeSupportFlag(true)
134 .NeedCheckSupportFlag(false);134 .NeedCheckSupportFlag(false);
135- this->AICore().AddConfig("ascend310p", config_310p);135+ this->AICore().AddConfig("ascend310p", inplaceConfig310p);
136- this->AICore().AddConfig("kirinx90", config_310p);136+ this->AICore().AddConfig("kirinx90", inplaceConfig310p);
137- this->AICore().AddConfig("kirin9030", config_310p);137+ this->AICore().AddConfig("kirin9030", inplaceConfig310p);
138 138 
139 OpAICoreConfig config_950;139 OpAICoreConfig config_950;
140 config_950.Input("x1")140 config_950.Input("x1")
@@ -1,12 +1,11 @@
1/**1/**
2- * This program is free software, you can redistribute it and/or modify.
3 * Copyright (c) 2025 Huawei Technologies Co., Ltd.2 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
4- * This file is a part of the CANN Open Software.3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
5- * Licensed under CANN Open Software License Agreement Version 2.0 (the "License").4+ * CANN Open Software License Agreement Version 2.0 (the "License").
6 * Please refer to the License for details. You may not use this file except in compliance with the License.5 * Please refer to the License for details. You may not use this file except in compliance with the License.
7- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
8- * BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. See LICENSE in the root of7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
9- * the software repository for the full text of the License.8+ * See LICENSE in the root of the software repository for the full text of the License.
10 */9 */
11 10 
12/*!11/*!
@@ -61,47 +60,47 @@ public:
61 this->AICore().AddConfig("ascend910b");60 this->AICore().AddConfig("ascend910b");
62 this->AICore().AddConfig("ascend910_93");61 this->AICore().AddConfig("ascend910_93");
63 62 
64- OpAICoreConfig config310P;63+ OpAICoreConfig inplaceRmsConfig310p;
65- config310P.Input("x1")64+ inplaceRmsConfig310p.Input("x1")
66 .ParamType(REQUIRED)65 .ParamType(REQUIRED)
67 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})66 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
68 .Format({ge::FORMAT_ND, ge::FORMAT_ND})67 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
69 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})68 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
70 .AutoContiguous();69 .AutoContiguous();
71- config310P.Input("x2")70+ inplaceRmsConfig310p.Input("x2")
72 .ParamType(REQUIRED)71 .ParamType(REQUIRED)
73 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})72 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
74 .Format({ge::FORMAT_ND, ge::FORMAT_ND})73 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
75 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})74 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
76 .AutoContiguous();75 .AutoContiguous();
77- config310P.Input("gamma")76+ inplaceRmsConfig310p.Input("gamma")
78 .ParamType(REQUIRED)77 .ParamType(REQUIRED)
79 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})78 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
80 .Format({ge::FORMAT_ND, ge::FORMAT_ND})79 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
81 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})80 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
82 .AutoContiguous();81 .AutoContiguous();
83- config310P.Output("x1")82+ inplaceRmsConfig310p.Output("x1")
84 .ParamType(REQUIRED)83 .ParamType(REQUIRED)
85 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})84 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
86 .Format({ge::FORMAT_ND, ge::FORMAT_ND})85 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
87 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})86 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
88 .AutoContiguous();87 .AutoContiguous();
89- config310P.Output("rstd")88+ inplaceRmsConfig310p.Output("rstd")
90 .ParamType(REQUIRED)89 .ParamType(REQUIRED)
91 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})90 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})
92 .Format({ge::FORMAT_ND, ge::FORMAT_ND})91 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
93 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})92 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
94 .AutoContiguous();93 .AutoContiguous();
95- config310P.Output("x2")94+ inplaceRmsConfig310p.Output("x2")
96 .ParamType(REQUIRED)95 .ParamType(REQUIRED)
97 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})96 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
98 .Format({ge::FORMAT_ND, ge::FORMAT_ND})97 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
99 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})98 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
100 .AutoContiguous();99 .AutoContiguous();
101- config310P.DynamicCompileStaticFlag(true).DynamicRankSupportFlag(true).DynamicShapeSupportFlag(true);100+ inplaceRmsConfig310p.DynamicCompileStaticFlag(true).DynamicRankSupportFlag(true).DynamicShapeSupportFlag(true);
102- this->AICore().AddConfig("ascend310p", config310P);101+ this->AICore().AddConfig("ascend310p", inplaceRmsConfig310p);
103- this->AICore().AddConfig("kirinx90", config310P);102+ this->AICore().AddConfig("kirinx90", inplaceRmsConfig310p);
104- this->AICore().AddConfig("kirin9030", config310P);103+ this->AICore().AddConfig("kirin9030", inplaceRmsConfig310p);
105 104 
106 OpAICoreConfig config_950;105 OpAICoreConfig config_950;
107 config_950.Input("x1")106 config_950.Input("x1")
@@ -148,4 +147,4 @@ public:
148 }147 }
149};148};
150OP_ADD(InplaceAddRmsNorm);149OP_ADD(InplaceAddRmsNorm);
151-} // namespace ops150+} // namespace ops
@@ -317,12 +317,12 @@ aclnnStatus aclnnLayerNormBackwardGetWorkspaceSize(const aclTensor* gradOut, con
317 // 固定写法,将输入转换成连续的tensor317 // 固定写法,将输入转换成连续的tensor
318 auto gradOutContiguous = l0op::Contiguous(gradOut, uniqueExecutor.get());318 auto gradOutContiguous = l0op::Contiguous(gradOut, uniqueExecutor.get());
319 CHECK_RET(gradOutContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);319 CHECK_RET(gradOutContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);
320- auto inputContiguous = l0op::Contiguous(input, uniqueExecutor.get());320+ auto lnInput = l0op::Contiguous(input, uniqueExecutor.get());
321- CHECK_RET(inputContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);321+ CHECK_RET(lnInput != nullptr, ACLNN_ERR_INNER_NULLPTR);
322- auto meanContiguous = l0op::Contiguous(mean, uniqueExecutor.get());322+ auto lnMean = l0op::Contiguous(mean, uniqueExecutor.get());
323- CHECK_RET(meanContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);323+ CHECK_RET(lnMean != nullptr, ACLNN_ERR_INNER_NULLPTR);
324- auto rstdContiguous = l0op::Contiguous(rstd, uniqueExecutor.get());324+ auto lnRstd = l0op::Contiguous(rstd, uniqueExecutor.get());
325- CHECK_RET(rstdContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);325+ CHECK_RET(lnRstd != nullptr, ACLNN_ERR_INNER_NULLPTR);
326 // 构造新的weightContiguous326 // 构造新的weightContiguous
327 const aclTensor* weightContiguous = nullptr;327 const aclTensor* weightContiguous = nullptr;
328 if (weightOptional) {328 if (weightOptional) {
@@ -330,7 +330,7 @@ aclnnStatus aclnnLayerNormBackwardGetWorkspaceSize(const aclTensor* gradOut, con
330 } else {330 } else {
331 auto weightTensor = uniqueExecutor.get()->ConvertToTensor(normalizedShape, DataType::DT_INT64);331 auto weightTensor = uniqueExecutor.get()->ConvertToTensor(normalizedShape, DataType::DT_INT64);
332 aclScalar* scalarOne = uniqueExecutor.get()->AllocScalar(1);332 aclScalar* scalarOne = uniqueExecutor.get()->AllocScalar(1);
333- auto oneTensor = uniqueExecutor.get()->ConvertToTensor(scalarOne, inputContiguous->GetDataType());333+ auto oneTensor = uniqueExecutor.get()->ConvertToTensor(scalarOne, lnInput->GetDataType());
334 weightContiguous = l0op::Fill(weightTensor, oneTensor, normalizedShape, uniqueExecutor.get());334 weightContiguous = l0op::Fill(weightTensor, oneTensor, normalizedShape, uniqueExecutor.get());
335 }335 }
336 CHECK_RET(weightContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);336 CHECK_RET(weightContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);
@@ -341,9 +341,9 @@ aclnnStatus aclnnLayerNormBackwardGetWorkspaceSize(const aclTensor* gradOut, con
341 if (gradV3Compute) {341 if (gradV3Compute) {
342 OP_LOGD("Entering into layer_norm_grad Func.");342 OP_LOGD("Entering into layer_norm_grad Func.");
343 // LayerNormGradV3只支持fp32 rstd mean输入,如果不是fp32先转fp32343 // LayerNormGradV3只支持fp32 rstd mean输入,如果不是fp32先转fp32
344- auto rstdContiguousFp32 = l0op::Cast(rstdContiguous, DataType::DT_FLOAT, uniqueExecutor.get());344+ auto rstdContiguousFp32 = l0op::Cast(lnRstd, DataType::DT_FLOAT, uniqueExecutor.get());
345 CHECK_RET(rstdContiguousFp32 != nullptr, ACLNN_ERR_INNER_NULLPTR);345 CHECK_RET(rstdContiguousFp32 != nullptr, ACLNN_ERR_INNER_NULLPTR);
346- auto meanContiguousFp32 = l0op::Cast(meanContiguous, DataType::DT_FLOAT, uniqueExecutor.get());346+ auto meanContiguousFp32 = l0op::Cast(lnMean, DataType::DT_FLOAT, uniqueExecutor.get());
347 CHECK_RET(meanContiguousFp32 != nullptr, ACLNN_ERR_INNER_NULLPTR);347 CHECK_RET(meanContiguousFp32 != nullptr, ACLNN_ERR_INNER_NULLPTR);
348 // npuArch 3510 支持更多的输出数据类型,只在不满足信息库条件时cast348 // npuArch 3510 支持更多的输出数据类型,只在不满足信息库条件时cast
349 DataType gradWeightType = DataType::DT_FLOAT;349 DataType gradWeightType = DataType::DT_FLOAT;
@@ -353,7 +353,7 @@ aclnnStatus aclnnLayerNormBackwardGetWorkspaceSize(const aclTensor* gradOut, con
353 gradWeightType = weightContiguous->GetDataType();353 gradWeightType = weightContiguous->GetDataType();
354 }354 }
355 std::array<aclTensor*, GRAD_OUT_NUM> gradRes = l0op::LayerNormGradV3(355 std::array<aclTensor*, GRAD_OUT_NUM> gradRes = l0op::LayerNormGradV3(
356- gradOutContiguous, inputContiguous, rstdContiguousFp32, meanContiguousFp32, weightContiguous, outputMask,356+ gradOutContiguous, lnInput, rstdContiguousFp32, meanContiguousFp32, weightContiguous, outputMask,
357 gradWeightType, uniqueExecutor.get());357 gradWeightType, uniqueExecutor.get());
358 // 根据mask处理输出358 // 根据mask处理输出
359 GenOutWithMask(gradRes[GRAD_INPUT_INDEX], gradInputOut, (*outputMask)[GRAD_INPUT_INDEX], uniqueExecutor.get());359 GenOutWithMask(gradRes[GRAD_INPUT_INDEX], gradInputOut, (*outputMask)[GRAD_INPUT_INDEX], uniqueExecutor.get());
@@ -366,13 +366,13 @@ aclnnStatus aclnnLayerNormBackwardGetWorkspaceSize(const aclTensor* gradOut, con
366 const aclTensor* meanCastTemp = nullptr;366 const aclTensor* meanCastTemp = nullptr;
367 const aclTensor* rstdCastTemp = nullptr;367 const aclTensor* rstdCastTemp = nullptr;
368 if (mean->GetDataType() != rstd->GetDataType()) {368 if (mean->GetDataType() != rstd->GetDataType()) {
369- meanCastTemp = l0op::Cast(meanContiguous, DataType::DT_FLOAT, uniqueExecutor.get());369+ meanCastTemp = l0op::Cast(lnMean, DataType::DT_FLOAT, uniqueExecutor.get());
370 CHECK_RET(meanCastTemp != nullptr, ACLNN_ERR_INNER_NULLPTR);370 CHECK_RET(meanCastTemp != nullptr, ACLNN_ERR_INNER_NULLPTR);
371- rstdCastTemp = l0op::Cast(rstdContiguous, DataType::DT_FLOAT, uniqueExecutor.get());371+ rstdCastTemp = l0op::Cast(lnRstd, DataType::DT_FLOAT, uniqueExecutor.get());
372 CHECK_RET(rstdCastTemp != nullptr, ACLNN_ERR_INNER_NULLPTR);372 CHECK_RET(rstdCastTemp != nullptr, ACLNN_ERR_INNER_NULLPTR);
373 } else {373 } else {
374- meanCastTemp = meanContiguous;374+ meanCastTemp = lnMean;
375- rstdCastTemp = rstdContiguous;375+ rstdCastTemp = lnRstd;
376 }376 }
377 const aclTensor* meanCast = nullptr;377 const aclTensor* meanCast = nullptr;
378 const aclTensor* rstdCast = nullptr;378 const aclTensor* rstdCast = nullptr;
@@ -389,7 +389,7 @@ aclnnStatus aclnnLayerNormBackwardGetWorkspaceSize(const aclTensor* gradOut, con
389 }389 }
390 390 
391 std::array<aclTensor*, X_OUT_NUM> xBackpropV3Res = l0op::LayerNormXBackpropV3(391 std::array<aclTensor*, X_OUT_NUM> xBackpropV3Res = l0op::LayerNormXBackpropV3(
392- gradOutContiguous, inputContiguous, rstdCast, meanCast, weightContiguous, uniqueExecutor.get());392+ gradOutContiguous, lnInput, rstdCast, meanCast, weightContiguous, uniqueExecutor.get());
393 auto TempWeightRes = xBackpropV3Res[1];393 auto TempWeightRes = xBackpropV3Res[1];
394 CHECK_RET(TempWeightRes != nullptr, ACLNN_ERR_INNER_NULLPTR);394 CHECK_RET(TempWeightRes != nullptr, ACLNN_ERR_INNER_NULLPTR);
395 // 调用layer_norm_beta_gamma_backprop_v2算子进行计算395 // 调用layer_norm_beta_gamma_backprop_v2算子进行计算
@@ -1,12 +1,11 @@
1/**1/**
2- * This program is free software, you can redistribute it and/or modify.
3 * Copyright (c) 2025 Huawei Technologies Co., Ltd.2 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
4- * This file is a part of the CANN Open Software.3+ * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
5- * Licensed under CANN Open Software License Agreement Version 2.0 (the "License").4+ * CANN Open Software License Agreement Version 2.0 (the "License").
6 * Please refer to the License for details. You may not use this file except in compliance with the License.5 * Please refer to the License for details. You may not use this file except in compliance with the License.
7- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING6+ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
8- * BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. See LICENSE in the root of7+ * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
9- * the software repository for the full text of the License.8+ * See LICENSE in the root of the software repository for the full text of the License.
10 */9 */
11 10 
12/*!11/*!
@@ -179,51 +178,51 @@ public:
179private:178private:
180 OpAICoreConfig GetKirinCoreConfig() const179 OpAICoreConfig GetKirinCoreConfig() const
181 {180 {
182- OpAICoreConfig config_kirin;181+ OpAICoreConfig layerV4KirinConfig;
183- config_kirin.DynamicCompileStaticFlag(true)182+ layerV4KirinConfig.DynamicCompileStaticFlag(true)
184 .DynamicFormatFlag(true)183 .DynamicFormatFlag(true)
185 .DynamicRankSupportFlag(true)184 .DynamicRankSupportFlag(true)
186 .DynamicShapeSupportFlag(true)185 .DynamicShapeSupportFlag(true)
187 .NeedCheckSupportFlag(false)186 .NeedCheckSupportFlag(false)
188 .PrecisionReduceFlag(true);187 .PrecisionReduceFlag(true);
189- config_kirin.Input("x")188+ layerV4KirinConfig.Input("x")
190 .ParamType(REQUIRED)189 .ParamType(REQUIRED)
191 .DataType({ge::DT_FLOAT, ge::DT_FLOAT16, ge::DT_FLOAT16})190 .DataType({ge::DT_FLOAT, ge::DT_FLOAT16, ge::DT_FLOAT16})
192 .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND})191 .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND})
193 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});192 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});
194- config_kirin.Input("normalized_shape")193+ layerV4KirinConfig.Input("normalized_shape")
195 .ParamType(REQUIRED)194 .ParamType(REQUIRED)
196 .DataType({ge::DT_INT32, ge::DT_INT32, ge::DT_INT32})195 .DataType({ge::DT_INT32, ge::DT_INT32, ge::DT_INT32})
197 .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND})196 .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND})
198 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});197 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});
199- config_kirin.Input("gamma")198+ layerV4KirinConfig.Input("gamma")
200 .ParamType(OPTIONAL)199 .ParamType(OPTIONAL)
201 .DataType({ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT16})200 .DataType({ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT16})
202 .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND})201 .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND})
203 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});202 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});
204- config_kirin.Input("beta")203+ layerV4KirinConfig.Input("beta")
205 .ParamType(OPTIONAL)204 .ParamType(OPTIONAL)
206 .DataType({ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT16})205 .DataType({ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT16})
207 .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND})206 .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND})
208 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});207 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});
209- config_kirin.Output("y")208+ layerV4KirinConfig.Output("y")
210 .ParamType(REQUIRED)209 .ParamType(REQUIRED)
211 .DataType({ge::DT_FLOAT, ge::DT_FLOAT16, ge::DT_FLOAT16})210 .DataType({ge::DT_FLOAT, ge::DT_FLOAT16, ge::DT_FLOAT16})
212 .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND})211 .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND})
213 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});212 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});
214- config_kirin.Output("mean")213+ layerV4KirinConfig.Output("mean")
215 .ParamType(REQUIRED)214 .ParamType(REQUIRED)
216 .DataType({ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT})215 .DataType({ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT})
217 .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND})216 .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND})
218 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});217 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});
219- config_kirin.Output("rstd")218+ layerV4KirinConfig.Output("rstd")
220 .ParamType(REQUIRED)219 .ParamType(REQUIRED)
221 .DataType({ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT})220 .DataType({ge::DT_FLOAT, ge::DT_FLOAT, ge::DT_FLOAT})
222 .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND})221 .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND})
223 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});222 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});
224- return config_kirin;223+ return layerV4KirinConfig;
225 }224 }
226};225};
227 226 
228OP_ADD(LayerNormV4);227OP_ADD(LayerNormV4);
229-} // namespace ops228+} // namespace ops
@@ -343,8 +343,8 @@ aclnnStatus aclnnLinalgVectorNormGetWorkspaceSize(const aclTensor* self, const a
343 auto castOut = l0op::Cast(updateOut, out->GetDataType(), uniqueExecutor.get());343 auto castOut = l0op::Cast(updateOut, out->GetDataType(), uniqueExecutor.get());
344 CHECK_RET(castOut != nullptr, ACLNN_ERR_INNER_NULLPTR);344 CHECK_RET(castOut != nullptr, ACLNN_ERR_INNER_NULLPTR);
345 345 
346- auto viewCopyResult = l0op::ViewCopy(castOut, out, uniqueExecutor.get());346+ auto linalgViewCopyResult = l0op::ViewCopy(castOut, out, uniqueExecutor.get());
347- CHECK_RET(viewCopyResult != nullptr, ACLNN_ERR_INNER_NULLPTR);347+ CHECK_RET(linalgViewCopyResult != nullptr, ACLNN_ERR_INNER_NULLPTR);
348 }348 }
349 349 
350 *workspaceSize = uniqueExecutor->GetWorkspaceSize();350 *workspaceSize = uniqueExecutor->GetWorkspaceSize();
@@ -99,40 +99,40 @@ public:
99private:99private:
100 OpAICoreConfig GetKirinCoreConfig() const100 OpAICoreConfig GetKirinCoreConfig() const
101 {101 {
102- OpAICoreConfig config_kirin;102+ OpAICoreConfig maskedKirinConfig;
103- config_kirin.DynamicCompileStaticFlag(true)103+ maskedKirinConfig.DynamicCompileStaticFlag(true)
104 .DynamicFormatFlag(true)104 .DynamicFormatFlag(true)
105 .DynamicRankSupportFlag(true)105 .DynamicRankSupportFlag(true)
106 .DynamicShapeSupportFlag(true)106 .DynamicShapeSupportFlag(true)
107 .NeedCheckSupportFlag(false)107 .NeedCheckSupportFlag(false)
108 .PrecisionReduceFlag(true);108 .PrecisionReduceFlag(true);
109- config_kirin.Input("x")109+ maskedKirinConfig.Input("x")
110 .ParamType(REQUIRED)110 .ParamType(REQUIRED)
111 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})111 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
112 .Format({ge::FORMAT_ND, ge::FORMAT_ND})112 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
113 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})113 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
114 .AutoContiguous();114 .AutoContiguous();
115- config_kirin.Input("atten_mask")115+ maskedKirinConfig.Input("atten_mask")
116 .ParamType(OPTIONAL)116 .ParamType(OPTIONAL)
117 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})117 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
118 .Format({ge::FORMAT_ND, ge::FORMAT_ND})118 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
119 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})119 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
120 .AutoContiguous();120 .AutoContiguous();
121- config_kirin.Input("relative_pos_bias")121+ maskedKirinConfig.Input("relative_pos_bias")
122 .ParamType(REQUIRED)122 .ParamType(REQUIRED)
123 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})123 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
124 .Format({ge::FORMAT_ND, ge::FORMAT_ND})124 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
125 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})125 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
126 .AutoContiguous();126 .AutoContiguous();
127- config_kirin.Output("y")127+ maskedKirinConfig.Output("y")
128 .ParamType(REQUIRED)128 .ParamType(REQUIRED)
129 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})129 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
130 .Format({ge::FORMAT_ND, ge::FORMAT_ND})130 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
131 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})131 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
132 .AutoContiguous();132 .AutoContiguous();
133- return config_kirin;133+ return maskedKirinConfig;
134 }134 }
135};135};
136 136 
137OP_ADD(MaskedSoftmaxWithRelPosBias);137OP_ADD(MaskedSoftmaxWithRelPosBias);
138-} // namespace ops138+} // namespace ops
@@ -87,68 +87,68 @@ public:
87private:87private:
88 OpAICoreConfig GetKirinCoreConfig() const88 OpAICoreConfig GetKirinCoreConfig() const
89 {89 {
90- OpAICoreConfig config_kirin;90+ OpAICoreConfig quantKirinConfig;
91- config_kirin.DynamicCompileStaticFlag(true)91+ quantKirinConfig.DynamicCompileStaticFlag(true)
92 .DynamicFormatFlag(true)92 .DynamicFormatFlag(true)
93 .DynamicRankSupportFlag(true)93 .DynamicRankSupportFlag(true)
94 .DynamicShapeSupportFlag(true)94 .DynamicShapeSupportFlag(true)
95 .NeedCheckSupportFlag(false)95 .NeedCheckSupportFlag(false)
96 .PrecisionReduceFlag(true);96 .PrecisionReduceFlag(true);
97- config_kirin.Input("x1")97+ quantKirinConfig.Input("x1")
98 .ParamType(REQUIRED)98 .ParamType(REQUIRED)
99 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})99 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
100 .Format({ge::FORMAT_ND, ge::FORMAT_ND})100 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
101 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})101 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
102 .AutoContiguous();102 .AutoContiguous();
103- config_kirin.Input("x2")103+ quantKirinConfig.Input("x2")
104 .ParamType(REQUIRED)104 .ParamType(REQUIRED)
105 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})105 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
106 .Format({ge::FORMAT_ND, ge::FORMAT_ND})106 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
107 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})107 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
108 .AutoContiguous();108 .AutoContiguous();
109- config_kirin.Input("gamma")109+ quantKirinConfig.Input("gamma")
110 .ParamType(REQUIRED)110 .ParamType(REQUIRED)
111 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})111 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
112 .Format({ge::FORMAT_ND, ge::FORMAT_ND})112 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
113 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})113 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
114 .AutoContiguous();114 .AutoContiguous();
115- config_kirin.Input("beta")115+ quantKirinConfig.Input("beta")
116 .ParamType(REQUIRED)116 .ParamType(REQUIRED)
117 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})117 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
118 .Format({ge::FORMAT_ND, ge::FORMAT_ND})118 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
119 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})119 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
120 .AutoContiguous();120 .AutoContiguous();
121- config_kirin.Input("bias")121+ quantKirinConfig.Input("bias")
122 .ParamType(REQUIRED)122 .ParamType(REQUIRED)
123 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})123 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
124 .Format({ge::FORMAT_ND, ge::FORMAT_ND})124 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
125 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})125 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
126 .AutoContiguous();126 .AutoContiguous();
127- config_kirin.Input("scales")127+ quantKirinConfig.Input("scales")
128 .ParamType(REQUIRED)128 .ParamType(REQUIRED)
129 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})129 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})
130 .Format({ge::FORMAT_ND, ge::FORMAT_ND})130 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
131 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})131 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
132 .AutoContiguous();132 .AutoContiguous();
133- config_kirin.Input("zero_points")133+ quantKirinConfig.Input("zero_points")
134 .ParamType(OPTIONAL)134 .ParamType(OPTIONAL)
135 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})135 .DataType({ge::DT_FLOAT, ge::DT_FLOAT})
136 .Format({ge::FORMAT_ND, ge::FORMAT_ND})136 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
137 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})137 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND})
138 .AutoContiguous();138 .AutoContiguous();
139- config_kirin.Output("y")139+ quantKirinConfig.Output("y")
140 .ParamType(REQUIRED)140 .ParamType(REQUIRED)
141 .DataType({ge::DT_INT8, ge::DT_INT8})141 .DataType({ge::DT_INT8, ge::DT_INT8})
142 .Format({ge::FORMAT_ND, ge::FORMAT_ND})142 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
143 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});143 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});
144- config_kirin.Output("x")144+ quantKirinConfig.Output("x")
145 .ParamType(REQUIRED)145 .ParamType(REQUIRED)
146 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})146 .DataType({ge::DT_FLOAT16, ge::DT_FLOAT})
147 .Format({ge::FORMAT_ND, ge::FORMAT_ND})147 .Format({ge::FORMAT_ND, ge::FORMAT_ND})
148 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});148 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});
149- return config_kirin;149+ return quantKirinConfig;
150 }150 }
151};151};
152 152 
153OP_ADD(QuantizeAddLayerNorm);153OP_ADD(QuantizeAddLayerNorm);
154-} // namespace ops154+} // namespace ops
@@ -177,9 +177,9 @@ static bool CheckInputDim(const gert::TilingContext* context, size_t dyDimNum, s
177 "in the range of [1, 8]"),177 "in the range of [1, 8]"),
178 return false);178 return false);
179 if (gammaDimNum > xDimNum) {179 if (gammaDimNum > xDimNum) {
180- std::string dimsMsg = std::to_string(gammaDimNum) + " and " + std::to_string(xDimNum);180+ std::string gammaDimsMsg = std::to_string(gammaDimNum) + " and " + std::to_string(xDimNum);
181 OP_LOGE_FOR_INVALID_SHAPEDIMS_WITH_REASON(181 OP_LOGE_FOR_INVALID_SHAPEDIMS_WITH_REASON(
182- context->GetNodeName(), "gamma and x", dimsMsg.c_str(),182+ context->GetNodeName(), "gamma and x", gammaDimsMsg.c_str(),
183 "The shape dim of input gamma must be less than or equal to that of input x");183 "The shape dim of input gamma must be less than or equal to that of input x");
184 return false;184 return false;
185 }185 }
@@ -537,4 +537,4 @@ static ge::graphStatus TilingPrepare4RmsNormGrad(gert::TilingParseContext* conte
537struct RmsNormCompileInfo {};537struct RmsNormCompileInfo {};
538IMPL_OP_OPTILING(RmsNormGrad).Tiling(Tiling4RmsNormGrad).TilingParse<RmsNormCompileInfo>(TilingPrepare4RmsNormGrad);538IMPL_OP_OPTILING(RmsNormGrad).Tiling(Tiling4RmsNormGrad).TilingParse<RmsNormCompileInfo>(TilingPrepare4RmsNormGrad);
539 539 
540-} // namespace optiling540+} // namespace optiling
@@ -211,31 +211,31 @@ ge::graphStatus RmsNormGradQuantEmptyTiling::CheckInputsDtype()
211 }211 }
212 212 
213 // check offsetX213 // check offsetX
214- auto offsetXDesc = context_->GetInputDesc(INPUT_INDEX_5);214+ auto emptyOffsetDesc = context_->GetInputDesc(INPUT_INDEX_5);
215- if (offsetXDesc != nullptr) {215+ if (emptyOffsetDesc != nullptr) {
216- auto offsetXDtype = offsetXDesc->GetDataType();216+ auto emptyOffsetType = emptyOffsetDesc->GetDataType();
217- if (offsetXDtype != ge::DataType::DT_INT32) {217+ if (emptyOffsetType != ge::DataType::DT_INT32) {
218- std::string dtypeMsg = ToString(offsetXDtype);218+ std::string emptyDtypeMsg = ToString(emptyOffsetType);
219- OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(context_->GetNodeName(), "offsetX", dtypeMsg.c_str(),219+ OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(context_->GetNodeName(), "offsetX", emptyDtypeMsg.c_str(),
220 "The dtype of input offsetX should be INT32");220 "The dtype of input offsetX should be INT32");
221 return ge::GRAPH_FAILED;221 return ge::GRAPH_FAILED;
222 }222 }
223 }223 }
224 224 
225 // check dx dtype (scales_x is required, always quant mode)225 // check dx dtype (scales_x is required, always quant mode)
226- auto dxDesc = context_->GetOutputDesc(0);226+ auto emptyDxDesc = context_->GetOutputDesc(0);
227- OP_CHECK_NULL_WITH_CONTEXT(context_, dxDesc);227+ OP_CHECK_NULL_WITH_CONTEXT(context_, emptyDxDesc);
228- auto dxDtype = dxDesc->GetDataType();228+ auto edxType = emptyDxDesc->GetDataType();
229- OP_CHECK_IF((dxDtype != ge::DataType::DT_HIFLOAT8 && dxDtype != ge::DataType::DT_INT8),229+ OP_CHECK_IF((edxType != ge::DataType::DT_HIFLOAT8 && edxType != ge::DataType::DT_INT8),
230- OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "dx", ToString(dxDtype).c_str(), "HIFLOAT8 or INT8"),230+ OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "dx", ToString(edxType).c_str(), "HIFLOAT8 or INT8"),
231 return ge::GRAPH_FAILED);231 return ge::GRAPH_FAILED);
232 232 
233 // check dgamma dtype233 // check dgamma dtype
234- auto dgammaDesc = context_->GetOutputDesc(1);234+ auto emptyDgammaDesc = context_->GetOutputDesc(1);
235- OP_CHECK_NULL_WITH_CONTEXT(context_, dgammaDesc);235+ OP_CHECK_NULL_WITH_CONTEXT(context_, emptyDgammaDesc);
236- auto dgammaDtype = dgammaDesc->GetDataType();236+ auto eDgammaType = emptyDgammaDesc->GetDataType();
237- OP_CHECK_IF((dgammaDtype != ge::DataType::DT_FLOAT),237+ OP_CHECK_IF((eDgammaType != ge::DataType::DT_FLOAT),
238- OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "dgamma", ToString(dgammaDtype).c_str(), "FLOAT"),238+ OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "dgamma", ToString(eDgammaType).c_str(), "FLOAT"),
239 return ge::GRAPH_FAILED);239 return ge::GRAPH_FAILED);
240 240 
241 return ge::GRAPH_SUCCESS;241 return ge::GRAPH_SUCCESS;
@@ -308,23 +308,23 @@ uint64_t RmsNormGradQuantEmptyTiling::GetTilingKey() const
308ge::graphStatus RmsNormGradQuantEmptyTiling::PostTiling()308ge::graphStatus RmsNormGradQuantEmptyTiling::PostTiling()
309{309{
310 context_->SetBlockDim(aivCoreNum_);310 context_->SetBlockDim(aivCoreNum_);
311- auto rawTilingData = context_->GetRawTilingData();311+ auto emptyRawData = context_->GetRawTilingData();
312- OP_CHECK_IF(sizeof(tilingData_) > rawTilingData->GetCapacity(),312+ OP_CHECK_IF(sizeof(tilingData_) > emptyRawData->GetCapacity(),
313 OP_LOGE(context_->GetNodeName(), "actual tiling data size %zu > context tiling data size %zu",313 OP_LOGE(context_->GetNodeName(), "actual tiling data size %zu > context tiling data size %zu",
314- sizeof(tilingData_), rawTilingData->GetCapacity()),314+ sizeof(tilingData_), emptyRawData->GetCapacity()),
315 return ge::GRAPH_FAILED);315 return ge::GRAPH_FAILED);
316- auto capSize = rawTilingData->GetCapacity();316+ auto emptyCapacity = emptyRawData->GetCapacity();
317- void* ptrData = rawTilingData->GetData();317+ void* emptyDataPtr = emptyRawData->GetData();
318- OP_CHECK_NULL_WITH_CONTEXT(context_, ptrData);318+ OP_CHECK_NULL_WITH_CONTEXT(context_, emptyDataPtr);
319- void* ptrStruct = static_cast<void*>(&tilingData_);319+ void* emptyStructPtr = static_cast<void*>(&tilingData_);
320- OP_CHECK_NULL_WITH_CONTEXT(context_, ptrStruct);320+ OP_CHECK_NULL_WITH_CONTEXT(context_, emptyStructPtr);
321- OP_CHECK_IF(memcpy_s(ptrData, capSize, ptrStruct, sizeof(tilingData_)) != 0,321+ OP_CHECK_IF(memcpy_s(emptyDataPtr, emptyCapacity, emptyStructPtr, sizeof(tilingData_)) != 0,
322 OP_LOGE(context_->GetNodeName(), "Set tiling data is failed!"), return ge::GRAPH_FAILED);322 OP_LOGE(context_->GetNodeName(), "Set tiling data is failed!"), return ge::GRAPH_FAILED);
323- rawTilingData->SetDataSize(sizeof(tilingData_));323+ emptyRawData->SetDataSize(sizeof(tilingData_));
324 324 
325- size_t* currentWorkspace = context_->GetWorkspaceSizes(1);325+ size_t* emptyWorkspace = context_->GetWorkspaceSizes(1);
326- OP_CHECK_NULL_WITH_CONTEXT(context_, currentWorkspace);326+ OP_CHECK_NULL_WITH_CONTEXT(context_, emptyWorkspace);
327- currentWorkspace[0] = workspaceSize_;327+ emptyWorkspace[0] = workspaceSize_;
328 return ge::GRAPH_SUCCESS;328 return ge::GRAPH_SUCCESS;
329}329}
330 330 
@@ -434,4 +434,4 @@ ge::graphStatus RmsNormGradQuantEmptyTiling::DoOpTiling()
434}434}
435 435 
436REGISTER_OPS_TILING_TEMPLATE(RmsNormGradQuant, RmsNormGradQuantEmptyTiling, 100);436REGISTER_OPS_TILING_TEMPLATE(RmsNormGradQuant, RmsNormGradQuantEmptyTiling, 100);
437-} // namespace optiling437+} // namespace optiling
@@ -90,118 +90,118 @@ ge::graphStatus RmsNormGradQuantBigMTiling::DgammaDoTilingStg0()
90 // m 切分,合轴后的shape为(m, n)沿m轴做reduce90 // m 切分,合轴后的shape为(m, n)沿m轴做reduce
91 constexpr static int64_t mFactorBlockAligned = MFACTOR_DEFAULT;91 constexpr static int64_t mFactorBlockAligned = MFACTOR_DEFAULT;
92 92 
93- int64_t blocksNeeded = Ops::Base::CeilDiv(rows_, mFactorBlockAligned);93+ int64_t quantBlocksNeeded = Ops::Base::CeilDiv(rows_, mFactorBlockAligned);
94- usedCoreNumDgamma_ = blocksNeeded < static_cast<int64_t>(aivCoreNum_) ? blocksNeeded : aivCoreNum_;94+ usedCoreNumDgamma_ = quantBlocksNeeded < static_cast<int64_t>(aivCoreNum_) ? quantBlocksNeeded : aivCoreNum_;
95 95 
96- int64_t mPerBlock = Ops::Base::FloorDiv(rows_, usedCoreNumDgamma_);96+ int64_t quantMPerBlock = Ops::Base::FloorDiv(rows_, usedCoreNumDgamma_);
97- int64_t remainder = rows_ - usedCoreNumDgamma_ * mPerBlock;97+ int64_t quantRemainder = rows_ - usedCoreNumDgamma_ * quantMPerBlock;
98 98 
99- int64_t mToProcessMainBlock = mPerBlock + 1;99+ int64_t quantMainMToProcess = quantMPerBlock + 1;
100- int64_t mToProcessTailBlock = mPerBlock;100+ int64_t quantTailMToProcess = quantMPerBlock;
101 101 
102- int64_t mLoopMainBlock = Ops::Base::FloorDiv(mToProcessMainBlock, mFactorBlockAligned);102+ int64_t quantMainMLoop = Ops::Base::FloorDiv(quantMainMToProcess, mFactorBlockAligned);
103- int64_t mTotalLoopMainBlock = Ops::Base::CeilDiv(mToProcessMainBlock, mFactorBlockAligned);103+ int64_t quantMainMTotalLoop = Ops::Base::CeilDiv(quantMainMToProcess, mFactorBlockAligned);
104- int64_t mTailMainBlock = mToProcessMainBlock - mLoopMainBlock * mFactorBlockAligned;104+ int64_t quantMainMTail = quantMainMToProcess - quantMainMLoop * mFactorBlockAligned;
105- int64_t basicBlockLoopMainBlock = FindNearestPower2(mTotalLoopMainBlock);105+ int64_t quantMainBasicBlockLoop = FindNearestPower2(quantMainMTotalLoop);
106- int64_t mainFoldCountMainBlock = mLoopMainBlock - basicBlockLoopMainBlock;106+ int64_t quantMainFoldCount = quantMainMLoop - quantMainBasicBlockLoop;
107 107 
108- int64_t cacheBufferCountMainBlock = 1;108+ int64_t quantMainCacheBufferCount = 1;
109- int64_t resultCacheIDMainBlock = 0;109+ int64_t quantMainResultCacheId = 0;
110- if (basicBlockLoopMainBlock != 0) {110+ if (quantMainBasicBlockLoop != 0) {
111- cacheBufferCountMainBlock = ULONG_BIT_LEN - static_cast<int64_t>(111+ quantMainCacheBufferCount = ULONG_BIT_LEN - static_cast<int64_t>(
112- __builtin_clzl(static_cast<uint64_t>(basicBlockLoopMainBlock)));112+ __builtin_clzl(static_cast<uint64_t>(quantMainBasicBlockLoop)));
113- resultCacheIDMainBlock = GetCacheID(basicBlockLoopMainBlock - 1);113+ quantMainResultCacheId = GetCacheID(quantMainBasicBlockLoop - 1);
114 }114 }
115 115 
116- int64_t mLoopTailBlock = Ops::Base::FloorDiv(mToProcessTailBlock, mFactorBlockAligned);116+ int64_t quantTailMLoop = Ops::Base::FloorDiv(quantTailMToProcess, mFactorBlockAligned);
117- int64_t mTotalLoopTailBlock = Ops::Base::CeilDiv(mToProcessTailBlock, mFactorBlockAligned);117+ int64_t quantTailMTotalLoop = Ops::Base::CeilDiv(quantTailMToProcess, mFactorBlockAligned);
118- int64_t mTailTailBlock = mToProcessTailBlock - mLoopTailBlock * mFactorBlockAligned;118+ int64_t quantTailMTail = quantTailMToProcess - quantTailMLoop * mFactorBlockAligned;
119- int64_t basicBlockLoopTailBlock = FindNearestPower2(mTotalLoopTailBlock);119+ int64_t quantTailBasicBlockLoop = FindNearestPower2(quantTailMTotalLoop);
120- int64_t mainFoldCountTailBlock = mLoopTailBlock - basicBlockLoopTailBlock;120+ int64_t quantTailFoldCount = quantTailMLoop - quantTailBasicBlockLoop;
121 121 
122- int64_t cacheBufferCountTailBlock = 1;122+ int64_t quantTailCacheBufferCount = 1;
123- int64_t resultCacheIDTailBlock = 0;123+ int64_t quantTailResultCacheId = 0;
124- if (basicBlockLoopTailBlock != 0) {124+ if (quantTailBasicBlockLoop != 0) {
125- cacheBufferCountTailBlock = ULONG_BIT_LEN - static_cast<int64_t>(125+ quantTailCacheBufferCount = ULONG_BIT_LEN - static_cast<int64_t>(
126- __builtin_clzl(static_cast<uint64_t>(basicBlockLoopTailBlock)));126+ __builtin_clzl(static_cast<uint64_t>(quantTailBasicBlockLoop)));
127- resultCacheIDTailBlock = GetCacheID(basicBlockLoopTailBlock - 1);127+ quantTailResultCacheId = GetCacheID(quantTailBasicBlockLoop - 1);
128 }128 }
129 129 
130 // n切分130 // n切分
131 constexpr static int64_t gammaDefaultNfactor = 64;131 constexpr static int64_t gammaDefaultNfactor = 64;
132 132 
133- int64_t dyDtypeSize = dyDtype_ == ge::DataType::DT_FLOAT ? CONST_FOUR : CONST_TWO;133+ int64_t quantDyDtypeSize = dyDtype_ == ge::DataType::DT_FLOAT ? CONST_FOUR : CONST_TWO;
134 134 
135- int64_t nFactorMax = (ubSize_ - mFactorBlockAligned * sizeof(float) * CONST_THREE) /135+ int64_t quantNFactorMax = (ubSize_ - mFactorBlockAligned * sizeof(float) * CONST_THREE) /
136- (mFactorBlockAligned * (CONST_SIX * dyDtypeSize + sizeof(float)) +136+ (mFactorBlockAligned * (CONST_SIX * quantDyDtypeSize + sizeof(float)) +
137- sizeof(float) * (CONST_THREE + cacheBufferCountMainBlock));137+ sizeof(float) * (CONST_THREE + quantMainCacheBufferCount));
138- OP_TILING_CHECK(nFactorMax < blockSize_ / gammaDefaultNfactor,138+ OP_TILING_CHECK(quantNFactorMax < blockSize_ / gammaDefaultNfactor,
139 OP_LOGI(context_->GetNodeName(),139 OP_LOGI(context_->GetNodeName(),
140 "Big M template is not capable. merged shape is (%lu, %lu), ub size: %luB, "140 "Big M template is not capable. merged shape is (%lu, %lu), ub size: %luB, "
141- "nFactorMax: %ld.",141+ "quantNFactorMax: %ld.",
142- rows_, cols_, ubSize_, nFactorMax),142+ rows_, cols_, ubSize_, quantNFactorMax),
143 return ge::GRAPH_PARAM_INVALID);143 return ge::GRAPH_PARAM_INVALID);
144 144 
145- int64_t dyBlockLen = blockSize_ / dyDtypeSize;145+ int64_t quantDyBlockLen = blockSize_ / quantDyDtypeSize;
146- int64_t nFactorBlockAligned = Ops::Base::FloorAlign(nFactorMax, dyBlockLen);146+ int64_t quantNFactorBlockAligned = Ops::Base::FloorAlign(quantNFactorMax, quantDyBlockLen);
147- nFactorBlockAligned = nFactorBlockAligned > cols_ ? cols_ : nFactorBlockAligned;147+ quantNFactorBlockAligned = quantNFactorBlockAligned > cols_ ? cols_ : quantNFactorBlockAligned;
148- nFactorBlockAligned = Ops::Base::CeilAlign(nFactorBlockAligned, dyBlockLen);148+ quantNFactorBlockAligned = Ops::Base::CeilAlign(quantNFactorBlockAligned, quantDyBlockLen);
149- int64_t nLoop = Ops::Base::FloorDiv(cols_, nFactorBlockAligned);149+ int64_t quantNLoop = Ops::Base::FloorDiv(cols_, quantNFactorBlockAligned);
150- int64_t nTail = cols_ - nLoop * nFactorBlockAligned;150+ int64_t quantNTail = cols_ - quantNLoop * quantNFactorBlockAligned;
151 151 
152 // 参数设置152 // 参数设置
153 tilingData_.dgammaUsedCoreNum = usedCoreNumDgamma_;153 tilingData_.dgammaUsedCoreNum = usedCoreNumDgamma_;
154- tilingData_.dgammaMPerBlock = mPerBlock;154+ tilingData_.dgammaMPerBlock = quantMPerBlock;
155- tilingData_.dgammaMReminder = remainder;155+ tilingData_.dgammaMReminder = quantRemainder;
156- tilingData_.dgammaNloop = nLoop;156+ tilingData_.dgammaNloop = quantNLoop;
157- tilingData_.dgammaNtail = nTail;157+ tilingData_.dgammaNtail = quantNTail;
158 tilingData_.dgammaMfactorBlockAligned = mFactorBlockAligned;158 tilingData_.dgammaMfactorBlockAligned = mFactorBlockAligned;
159- tilingData_.dgammaNfactorBlockAligned = nFactorBlockAligned;159+ tilingData_.dgammaNfactorBlockAligned = quantNFactorBlockAligned;
160 160 
161- tilingData_.dgammaMToProcessMainBlock = mToProcessMainBlock;161+ tilingData_.dgammaMToProcessMainBlock = quantMainMToProcess;
162- tilingData_.dgammaMLoopMainBlock = mLoopMainBlock;162+ tilingData_.dgammaMLoopMainBlock = quantMainMLoop;
163- tilingData_.dgammaMTotalLoopMainBlock = mTotalLoopMainBlock;163+ tilingData_.dgammaMTotalLoopMainBlock = quantMainMTotalLoop;
164- tilingData_.dgammaMTailMainBlock = mTailMainBlock;164+ tilingData_.dgammaMTailMainBlock = quantMainMTail;
165- tilingData_.dgammaBasicBlockLoopMainBlock = basicBlockLoopMainBlock;165+ tilingData_.dgammaBasicBlockLoopMainBlock = quantMainBasicBlockLoop;
166- tilingData_.dgammaMainFoldCountMainBlock = mainFoldCountMainBlock;166+ tilingData_.dgammaMainFoldCountMainBlock = quantMainFoldCount;
167- tilingData_.dgammaCacheBufferCountMainBlock = cacheBufferCountMainBlock;167+ tilingData_.dgammaCacheBufferCountMainBlock = quantMainCacheBufferCount;
168- tilingData_.dgammaResultCacheIDMainBlock = resultCacheIDMainBlock;168+ tilingData_.dgammaResultCacheIDMainBlock = quantMainResultCacheId;
169 169 
170- tilingData_.dgammaMToProcessTailBlock = mToProcessTailBlock;170+ tilingData_.dgammaMToProcessTailBlock = quantTailMToProcess;
171- tilingData_.dgammaMLoopTailBlock = mLoopTailBlock;171+ tilingData_.dgammaMLoopTailBlock = quantTailMLoop;
172- tilingData_.dgammaMTotalLoopTailBlock = mTotalLoopTailBlock;172+ tilingData_.dgammaMTotalLoopTailBlock = quantTailMTotalLoop;
173- tilingData_.dgammaMTailTailBlock = mTailTailBlock;173+ tilingData_.dgammaMTailTailBlock = quantTailMTail;
174- tilingData_.dgammaBasicBlockLoopTailBlock = basicBlockLoopTailBlock;174+ tilingData_.dgammaBasicBlockLoopTailBlock = quantTailBasicBlockLoop;
175- tilingData_.dgammaMainFoldCountTailBlock = mainFoldCountTailBlock;175+ tilingData_.dgammaMainFoldCountTailBlock = quantTailFoldCount;
176- tilingData_.dgammaCacheBufferCountTailBlock = cacheBufferCountTailBlock;176+ tilingData_.dgammaCacheBufferCountTailBlock = quantTailCacheBufferCount;
177- tilingData_.dgammaResultCacheIDTailBlock = resultCacheIDTailBlock;177+ tilingData_.dgammaResultCacheIDTailBlock = quantTailResultCacheId;
178 178 
179 return ge::GRAPH_SUCCESS;179 return ge::GRAPH_SUCCESS;
180}180}
181 181 
182ge::graphStatus RmsNormGradQuantBigMTiling::DgammaDoTilingStg1()182ge::graphStatus RmsNormGradQuantBigMTiling::DgammaDoTilingStg1()
183{183{
184- int64_t aInnerMax = ubSize_ / CONST_TWO / sizeof(float) / (usedCoreNumDgamma_ + 1);184+ int64_t quantAInnerMax = ubSize_ / CONST_TWO / sizeof(float) / (usedCoreNumDgamma_ + 1);
185 185 
186- int64_t blockLen = blockSize_ / sizeof(float);186+ int64_t quantBlockLen = blockSize_ / sizeof(float);
187 187 
188 OP_TILING_CHECK(188 OP_TILING_CHECK(
189- aInnerMax < blockLen,189+ quantAInnerMax < quantBlockLen,
190 OP_LOGI(context_->GetNodeName(),190 OP_LOGI(context_->GetNodeName(),
191- "Big M template is not capable for dgamma compute, aInnerMax in stage1 is %ld .", aInnerMax),191+ "Big M template is not capable for dgamma compute, aInnerMax in stage1 is %ld .", quantAInnerMax),
192 return ge::GRAPH_PARAM_INVALID);192 return ge::GRAPH_PARAM_INVALID);
193 193 
194- int64_t aInnerMaxAligned = Ops::Base::FloorAlign(aInnerMax, blockLen);194+ int64_t quantAInnerMaxAligned = Ops::Base::FloorAlign(quantAInnerMax, quantBlockLen);
195 195 
196- int64_t aInner = cols_ < aInnerMaxAligned ? cols_ : aInnerMaxAligned;196+ int64_t quantAInner = cols_ < quantAInnerMaxAligned ? cols_ : quantAInnerMaxAligned;
197- int64_t aInnerAligned = Ops::Base::CeilAlign(aInner, blockLen);197+ int64_t quantAInnerAligned = Ops::Base::CeilAlign(quantAInner, quantBlockLen);
198 198 
199- int64_t aOuter = Ops::Base::CeilDiv(cols_, aInnerAligned);199+ int64_t quantAOuter = Ops::Base::CeilDiv(cols_, quantAInnerAligned);
200- int64_t aTail = cols_ - (aOuter - 1) * aInnerAligned;200+ int64_t quantATail = cols_ - (quantAOuter - 1) * quantAInnerAligned;
201 201 
202- tilingData_.dgammaAInnerAlignedStg1 = aInnerAligned;202+ tilingData_.dgammaAInnerAlignedStg1 = quantAInnerAligned;
203- tilingData_.dgammaAOuterStg1 = aOuter;203+ tilingData_.dgammaAOuterStg1 = quantAOuter;
204- tilingData_.dgammaATailStg1 = aTail;204+ tilingData_.dgammaATailStg1 = quantATail;
205 205 
206 return ge::GRAPH_SUCCESS;206 return ge::GRAPH_SUCCESS;
207}207}
@@ -260,21 +260,21 @@ int64_t RmsNormGradQuantBigMTiling::GetCacheID(const int64_t idx)
260 return __builtin_popcountll(idx ^ (idx + CONST_ONE)) - CONST_ONE;260 return __builtin_popcountll(idx ^ (idx + CONST_ONE)) - CONST_ONE;
261}261}
262 262 
263-int64_t RmsNormGradQuantBigMTiling::FindNearestPower2(const int64_t value)263+int64_t RmsNormGradQuantBigMTiling::FindNearestPower2(const int64_t quantValue)
264{264{
265- if (value <= CONST_ONE) {265+ if (quantValue <= CONST_ONE) {
266 return CONST_ZERO;266 return CONST_ZERO;
267- } else if (value <= CONST_TWO) {267+ } else if (quantValue <= CONST_TWO) {
268 return CONST_ONE;268 return CONST_ONE;
269- } else if (value <= CONST_FOUR) {269+ } else if (quantValue <= CONST_FOUR) {
270 return CONST_TWO;270 return CONST_TWO;
271 } else {271 } else {
272- const int64_t num = value - CONST_ONE;272+ const int64_t quantNum = quantValue - CONST_ONE;
273- const int64_t pow = CONST_SIXTY_THREE - __builtin_clzl(num);273+ const int64_t quantPower = CONST_SIXTY_THREE - __builtin_clzl(quantNum);
274- return (CONST_ONE << pow);274+ return (CONST_ONE << quantPower);
275 }275 }
276}276}
277 277 
278REGISTER_OPS_TILING_TEMPLATE(RmsNormGradQuant, RmsNormGradQuantBigMTiling, 500);278REGISTER_OPS_TILING_TEMPLATE(RmsNormGradQuant, RmsNormGradQuantBigMTiling, 500);
279 279 
280-} // namespace optiling280+} // namespace optiling
@@ -342,12 +342,12 @@ ge::graphStatus RmsNormGradQuantRegbaseTiling::CheckInputsDtype()
342 }342 }
343 343 
344 // check offsetX344 // check offsetX
345- auto offsetXDesc = context_->GetInputDesc(INPUT_INDEX_5);345+ auto regbaseOffsetXDesc = context_->GetInputDesc(INPUT_INDEX_5);
346- if (offsetXDesc != nullptr) {346+ if (regbaseOffsetXDesc != nullptr) {
347- auto offsetXDtype = offsetXDesc->GetDataType();347+ auto regbaseOffsetXDtype = regbaseOffsetXDesc->GetDataType();
348- if (offsetXDtype != ge::DataType::DT_INT32) {348+ if (regbaseOffsetXDtype != ge::DataType::DT_INT32) {
349- std::string dtypeMsg = ToString(offsetXDtype);349+ std::string regbaseOffsetDtypeMsg = ToString(regbaseOffsetXDtype);
350- OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(context_->GetNodeName(), "offsetX", dtypeMsg.c_str(),350+ OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(context_->GetNodeName(), "offsetX", regbaseOffsetDtypeMsg.c_str(),
351 "The dtype of input offsetX should be INT32");351 "The dtype of input offsetX should be INT32");
352 return ge::GRAPH_FAILED;352 return ge::GRAPH_FAILED;
353 }353 }
@@ -390,21 +390,21 @@ ge::graphStatus RmsNormGradQuantRegbaseTiling::GetShapeAttrsInfo()
390 }390 }
391 391 
392 // set Attrs392 // set Attrs
393- auto attrs = context_->GetAttrs();393+ auto regbaseAttrs = context_->GetAttrs();
394- OP_CHECK_NULL_WITH_CONTEXT(context_, attrs);394+ OP_CHECK_NULL_WITH_CONTEXT(context_, regbaseAttrs);
395 // check quant395 // check quant
396- const char* quantMode = attrs->GetAttrPointer<char>(ATTR_INDEX_0);396+ const char* regbaseQuantMode = regbaseAttrs->GetAttrPointer<char>(ATTR_INDEX_0);
397- OP_CHECK_NULL_WITH_CONTEXT(context_, quantMode);397+ OP_CHECK_NULL_WITH_CONTEXT(context_, regbaseQuantMode);
398- if (strcmp(quantMode, "static") == 0) {398+ if (strcmp(regbaseQuantMode, "static") == 0) {
399 quantMode_ = STATIC_QUANT_MODE;399 quantMode_ = STATIC_QUANT_MODE;
400 } else {400 } else {
401 OP_CHECK_IF((true), OP_LOGE(context_->GetNodeName(), "the attr of quant mode should be static."),401 OP_CHECK_IF((true), OP_LOGE(context_->GetNodeName(), "the attr of quant mode should be static."),
402 return ge::GRAPH_FAILED);402 return ge::GRAPH_FAILED);
403 }403 }
404 // set divMode404 // set divMode
405- const bool* divModePtr = attrs->GetBool(ATTR_INDEX_1);405+ const bool* regbaseDivModePtr = regbaseAttrs->GetBool(ATTR_INDEX_1);
406- OP_CHECK_NULL_WITH_CONTEXT(context_, divModePtr);406+ OP_CHECK_NULL_WITH_CONTEXT(context_, regbaseDivModePtr);
407- divMode_ = *divModePtr ? ComputeModeDivMode::DIV_MODE : ComputeModeDivMode::NOT_DIV_MODE;407+ divMode_ = *regbaseDivModePtr ? ComputeModeDivMode::DIV_MODE : ComputeModeDivMode::NOT_DIV_MODE;
408 return ge::GRAPH_SUCCESS;408 return ge::GRAPH_SUCCESS;
409}409}
410 410 
@@ -615,4 +615,4 @@ ge::graphStatus RmsNormGradQuantRegbaseTiling::DoOpTiling()
615}615}
616 616 
617REGISTER_OPS_TILING_TEMPLATE(RmsNormGradQuant, RmsNormGradQuantRegbaseTiling, 1000);617REGISTER_OPS_TILING_TEMPLATE(RmsNormGradQuant, RmsNormGradQuantRegbaseTiling, 1000);
618-} // namespace optiling618+} // namespace optiling
@@ -59,47 +59,47 @@ public:
59 this->AICore().AddConfig("ascend910b");59 this->AICore().AddConfig("ascend910b");
60 this->AICore().AddConfig("ascend910_93");60 this->AICore().AddConfig("ascend910_93");
61 61 
62- OpAICoreConfig config310P;62+ OpAICoreConfig rmsQuantConfig310p;
63- config310P.Input("x")63+ rmsQuantConfig310p.Input("x")
64 .ParamType(REQUIRED)64 .ParamType(REQUIRED)
65 .DataType({ge::DT_FLOAT16})65 .DataType({ge::DT_FLOAT16})
66 .Format({ge::FORMAT_ND})66 .Format({ge::FORMAT_ND})
67 .UnknownShapeFormat({ge::FORMAT_ND});67 .UnknownShapeFormat({ge::FORMAT_ND});
68- config310P.Input("gamma")68+ rmsQuantConfig310p.Input("gamma")
69 .ParamType(REQUIRED)69 .ParamType(REQUIRED)
70 .DataType({ge::DT_FLOAT16})70 .DataType({ge::DT_FLOAT16})
71 .Format({ge::FORMAT_ND})71 .Format({ge::FORMAT_ND})
72 .UnknownShapeFormat({ge::FORMAT_ND});72 .UnknownShapeFormat({ge::FORMAT_ND});
73- config310P.Input("beta")73+ rmsQuantConfig310p.Input("beta")
74 .ParamType(OPTIONAL)74 .ParamType(OPTIONAL)
75 .DataType({ge::DT_FLOAT16})75 .DataType({ge::DT_FLOAT16})
76 .Format({ge::FORMAT_ND})76 .Format({ge::FORMAT_ND})
77 .UnknownShapeFormat({ge::FORMAT_ND});77 .UnknownShapeFormat({ge::FORMAT_ND});
78- config310P.Input("scale")78+ rmsQuantConfig310p.Input("scale")
79 .ParamType(REQUIRED)79 .ParamType(REQUIRED)
80 .DataType({ge::DT_FLOAT16})80 .DataType({ge::DT_FLOAT16})
81 .Format({ge::FORMAT_ND})81 .Format({ge::FORMAT_ND})
82 .UnknownShapeFormat({ge::FORMAT_ND});82 .UnknownShapeFormat({ge::FORMAT_ND});
83- config310P.Input("offset")83+ rmsQuantConfig310p.Input("offset")
84 .ParamType(REQUIRED)84 .ParamType(REQUIRED)
85 .DataType({ge::DT_INT8})85 .DataType({ge::DT_INT8})
86 .Format({ge::FORMAT_ND})86 .Format({ge::FORMAT_ND})
87 .UnknownShapeFormat({ge::FORMAT_ND});87 .UnknownShapeFormat({ge::FORMAT_ND});
88 88 
89- config310P.Output("y")89+ rmsQuantConfig310p.Output("y")
90 .ParamType(REQUIRED)90 .ParamType(REQUIRED)
91 .DataType({ge::DT_INT8})91 .DataType({ge::DT_INT8})
92 .Format({ge::FORMAT_ND})92 .Format({ge::FORMAT_ND})
93 .UnknownShapeFormat({ge::FORMAT_ND});93 .UnknownShapeFormat({ge::FORMAT_ND});
94- config310P.DynamicCompileStaticFlag(true)94+ rmsQuantConfig310p.DynamicCompileStaticFlag(true)
95 .DynamicFormatFlag(true)95 .DynamicFormatFlag(true)
96 .DynamicRankSupportFlag(true)96 .DynamicRankSupportFlag(true)
97 .DynamicShapeSupportFlag(true)97 .DynamicShapeSupportFlag(true)
98 .NeedCheckSupportFlag(false);98 .NeedCheckSupportFlag(false);
99- this->AICore().AddConfig("ascend310p", config310P);99+ this->AICore().AddConfig("ascend310p", rmsQuantConfig310p);
100- this->AICore().AddConfig("ascend310b", config310P);100+ this->AICore().AddConfig("ascend310b", rmsQuantConfig310p);
101- this->AICore().AddConfig("kirinx90", config310P);101+ this->AICore().AddConfig("kirinx90", rmsQuantConfig310p);
102- this->AICore().AddConfig("kirin9030", config310P);102+ this->AICore().AddConfig("kirin9030", rmsQuantConfig310p);
103 }103 }
104};104};
105 105