已合并
SyncBatchNormGatherStatsFused算子除法精度修复 #6431
Chao-Wu创建于 6月23日
SyncBatchNormGatherStatsFused算子除法精度修复 #6431
已合并
共 8 个文件变更+26-200
| @@ -221,7 +221,7 @@ public: | |||
| 221 | Duplicate(buffer1_, countsSumScalar, curRowNum * cAlign); | 221 | Duplicate(buffer1_, countsSumScalar, curRowNum * cAlign); |
| 222 | PipeBarrier<PIPE_V>(); | 222 | PipeBarrier<PIPE_V>(); |
| 223 | 223 | ||
| 224 | - Div(buffer0_, buffer0_, buffer1_, curRowNum * cAlign); | 224 | + Div<float, divConfig>(buffer0_, buffer0_, buffer1_, curRowNum * cAlign); |
| 225 | PipeBarrier<PIPE_V>(); | 225 | PipeBarrier<PIPE_V>(); |
| 226 | 226 | ||
| 227 | NlastReduceSum(buffer3_, buffer0_, curRowNum); | 227 | NlastReduceSum(buffer3_, buffer0_, curRowNum); |
| @@ -241,7 +241,7 @@ public: | |||
| 241 | Duplicate(buffer0_, static_cast<float>(1.0), curRowNum * cAlign); | 241 | Duplicate(buffer0_, static_cast<float>(1.0), curRowNum * cAlign); |
| 242 | PipeBarrier<PIPE_V>(); | 242 | PipeBarrier<PIPE_V>(); |
| 243 | 243 | ||
| 244 | - Div(buffer1_, buffer0_, buffer1_, curRowNum * cAlign); | 244 | + Div<float, divConfig>(buffer1_, buffer0_, buffer1_, curRowNum * cAlign); |
| 245 | PipeBarrier<PIPE_V>(); | 245 | PipeBarrier<PIPE_V>(); |
| 246 | 246 | ||
| 247 | queue0_.FreeTensor(buffer0_); | 247 | queue0_.FreeTensor(buffer0_); |
| @@ -320,7 +320,7 @@ public: | |||
| 320 | Duplicate(buffer1_, unbiasCountsSum, cAlign); | 320 | Duplicate(buffer1_, unbiasCountsSum, cAlign); |
| 321 | PipeBarrier<PIPE_V>(); | 321 | PipeBarrier<PIPE_V>(); |
| 322 | 322 | ||
| 323 | - Div(buffer6_, buffer4_, buffer1_, cAlign); | 323 | + Div<float, divConfig>(buffer6_, buffer4_, buffer1_, cAlign); |
| 324 | PipeBarrier<PIPE_V>(); | 324 | PipeBarrier<PIPE_V>(); |
| 325 | 325 | ||
| 326 | Muls(buffer6_, buffer6_, momentum, cAlign); | 326 | Muls(buffer6_, buffer6_, momentum, cAlign); |
| @@ -344,7 +344,7 @@ public: | |||
| 344 | Duplicate(buffer0_, countsSumScalar, cAlign); | 344 | Duplicate(buffer0_, countsSumScalar, cAlign); |
| 345 | PipeBarrier<PIPE_V>(); | 345 | PipeBarrier<PIPE_V>(); |
| 346 | 346 | ||
| 347 | - Div(buffer4_, buffer4_, buffer0_, cAlign); | 347 | + Div<float, divConfig>(buffer4_, buffer4_, buffer0_, cAlign); |
| 348 | PipeBarrier<PIPE_V>(); | 348 | PipeBarrier<PIPE_V>(); |
| 349 | 349 | ||
| 350 | Adds(buffer4_, buffer4_, eps, cAlign); | 350 | Adds(buffer4_, buffer4_, eps, cAlign); |
| @@ -356,7 +356,7 @@ public: | |||
| 356 | Duplicate(buffer0_, static_cast<float>(1.0), cAlign); | 356 | Duplicate(buffer0_, static_cast<float>(1.0), cAlign); |
| 357 | PipeBarrier<PIPE_V>(); | 357 | PipeBarrier<PIPE_V>(); |
| 358 | 358 | ||
| 359 | - Div(buffer4_, buffer0_, buffer4_, cAlign); | 359 | + Div<float, divConfig>(buffer4_, buffer0_, buffer4_, cAlign); |
| 360 | PipeBarrier<PIPE_V>(); | 360 | PipeBarrier<PIPE_V>(); |
| 361 | 361 | ||
| 362 | queue0_.FreeTensor(buffer0_); | 362 | queue0_.FreeTensor(buffer0_); |
| @@ -449,6 +449,7 @@ private: | |||
| 449 | 449 | ||
| 450 | private: | 450 | private: |
| 451 | TPipe pipe; | 451 | TPipe pipe; |
| 452 | + static constexpr DivConfig divConfig = {DivAlgo::PRECISION_0ULP_FTZ_FALSE}; | ||
| 452 | constexpr static uint16_t SYNC_AIV_ONLY_ALL = 14; | 453 | constexpr static uint16_t SYNC_AIV_ONLY_ALL = 14; |
| 453 | int64_t nLength; | 454 | int64_t nLength; |
| 454 | int64_t cLength; | 455 | int64_t cLength; |
| @@ -159,7 +159,7 @@ public: | |||
| 159 | Duplicate(buffer3_, unbiasCountsSum_, colSize); | 159 | Duplicate(buffer3_, unbiasCountsSum_, colSize); |
| 160 | PipeBarrier<PIPE_V>(); | 160 | PipeBarrier<PIPE_V>(); |
| 161 | 161 | ||
| 162 | - Div(buffer3_, buffer1_, buffer3_, colSize); | 162 | + Div<float, divConfig>(buffer3_, buffer1_, buffer3_, colSize); |
| 163 | PipeBarrier<PIPE_V>(); | 163 | PipeBarrier<PIPE_V>(); |
| 164 | 164 | ||
| 165 | Muls(buffer3_, buffer3_, momentum_, colSize); | 165 | Muls(buffer3_, buffer3_, momentum_, colSize); |
| @@ -171,7 +171,7 @@ public: | |||
| 171 | Duplicate(buffer2_, countSum_, colSize); | 171 | Duplicate(buffer2_, countSum_, colSize); |
| 172 | PipeBarrier<PIPE_V>(); | 172 | PipeBarrier<PIPE_V>(); |
| 173 | 173 | ||
| 174 | - Div(buffer4_, buffer1_, buffer2_, colSize); | 174 | + Div<float, divConfig>(buffer4_, buffer1_, buffer2_, colSize); |
| 175 | PipeBarrier<PIPE_V>(); | 175 | PipeBarrier<PIPE_V>(); |
| 176 | 176 | ||
| 177 | Adds(buffer4_, buffer4_, eps_, colSize); | 177 | Adds(buffer4_, buffer4_, eps_, colSize); |
| @@ -183,7 +183,7 @@ public: | |||
| 183 | Duplicate(buffer2_, 1.0f, colSize); | 183 | Duplicate(buffer2_, 1.0f, colSize); |
| 184 | PipeBarrier<PIPE_V>(); | 184 | PipeBarrier<PIPE_V>(); |
| 185 | 185 | ||
| 186 | - Div(buffer4_, buffer2_, buffer4_, colSize); | 186 | + Div<float, divConfig>(buffer4_, buffer2_, buffer4_, colSize); |
| 187 | PipeBarrier<PIPE_V>(); | 187 | PipeBarrier<PIPE_V>(); |
| 188 | } | 188 | } |
| 189 | 189 | ||
| @@ -211,6 +211,7 @@ public: | |||
| 211 | 211 | ||
| 212 | private: | 212 | private: |
| 213 | TPipe pipe_; | 213 | TPipe pipe_; |
| 214 | + static constexpr DivConfig divConfig = {DivAlgo::PRECISION_0ULP_FTZ_FALSE}; | ||
| 214 | TQue<QuePosition::VECOUT, DOUBLE_BUFFER> queueRunningVarOut_; | 215 | TQue<QuePosition::VECOUT, DOUBLE_BUFFER> queueRunningVarOut_; |
| 215 | TQue<QuePosition::VECOUT, DOUBLE_BUFFER> queueInvstdAllOut_; | 216 | TQue<QuePosition::VECOUT, DOUBLE_BUFFER> queueInvstdAllOut_; |
| 216 | TQue<QuePosition::VECIN, DOUBLE_BUFFER> queueRunningVarIn_; | 217 | TQue<QuePosition::VECIN, DOUBLE_BUFFER> queueRunningVarIn_; |
Mnorm/sync_batch_norm_gather_stats_fused/op_kernel/sync_batch_norm_gather_stats_fused_first_axis_common.h+5-4
| @@ -225,16 +225,17 @@ private: | |||
| 225 | const LocalTensor<float>&, const LocalTensor<float>&, const LocalTensor<float>&, uint64_t, uint8_t, | 225 | const LocalTensor<float>&, const LocalTensor<float>&, const LocalTensor<float>&, uint64_t, uint8_t, |
| 226 | const BinaryRepeatParams&)); | 226 | const BinaryRepeatParams&)); |
| 227 | 227 | ||
| 228 | - __aicore__ inline void LastReduceSumLargeStride( | ||
| 229 | - const LocalTensor<float>& tmp, const LocalTensor<float>& src, const int64_t curRowsNum, | ||
| 230 | - const int64_t curColNum); | ||
| 231 | - | ||
| 232 | __aicore__ inline void LastReduceSum( | 228 | __aicore__ inline void LastReduceSum( |
| 233 | const LocalTensor<float>& dst, const LocalTensor<float>& src, const LocalTensor<float>& tmp, | 229 | const LocalTensor<float>& dst, const LocalTensor<float>& src, const LocalTensor<float>& tmp, |
| 234 | const int64_t curRowsNum, const int64_t curColNum); | 230 | const int64_t curRowsNum, const int64_t curColNum); |
| 235 | 231 | ||
| 232 | + __aicore__ inline void LastReduceSumLargeStride( | ||
| 233 | + const LocalTensor<float>& tmp, const LocalTensor<float>& src, const int64_t curRowsNum, | ||
| 234 | + const int64_t curColNum); | ||
| 235 | + | ||
| 236 | private: | 236 | private: |
| 237 | TPipe pipe; | 237 | TPipe pipe; |
| 238 | + static constexpr DivConfig divConfig = {DivAlgo::PRECISION_0ULP_FTZ_FALSE}; | ||
| 238 | constexpr static uint16_t SYNC_AIV_ONLY_ALL = 14; | 239 | constexpr static uint16_t SYNC_AIV_ONLY_ALL = 14; |
| 239 | constexpr static int64_t WORKSPACE_NUM = 1; | 240 | constexpr static int64_t WORKSPACE_NUM = 1; |
| 240 | int64_t nLength; | 241 | int64_t nLength; |
Mnorm/sync_batch_norm_gather_stats_fused/op_kernel/sync_batch_norm_gather_stats_fused_first_axis_common.inl+2-2
| @@ -123,7 +123,7 @@ __aicore__ inline void SyncBatchNormGatherStatsFusedFirstAxisCommon<T>::ComputeG | |||
| 123 | Duplicate(buffer1_, countsSumScalar, curRowsNum * cAlign); | 123 | Duplicate(buffer1_, countsSumScalar, curRowsNum * cAlign); |
| 124 | PipeBarrier<PIPE_V>(); | 124 | PipeBarrier<PIPE_V>(); |
| 125 | 125 | ||
| 126 | - Div(buffer0_, buffer0_, buffer1_, curRowsNum * cAlign); | 126 | + Div<float, divConfig>(buffer0_, buffer0_, buffer1_, curRowsNum * cAlign); |
| 127 | PipeBarrier<PIPE_V>(); | 127 | PipeBarrier<PIPE_V>(); |
| 128 | 128 | ||
| 129 | NlastReduceSum(buffer3_, buffer0_, curRowsNum); | 129 | NlastReduceSum(buffer3_, buffer0_, curRowsNum); |
| @@ -156,7 +156,7 @@ __aicore__ inline void SyncBatchNormGatherStatsFusedFirstAxisCommon<T>::ComputeG | |||
| 156 | Duplicate(buffer0_, static_cast<float>(1.0f), curRowsNum * cAlign); | 156 | Duplicate(buffer0_, static_cast<float>(1.0f), curRowsNum * cAlign); |
| 157 | PipeBarrier<PIPE_V>(); | 157 | PipeBarrier<PIPE_V>(); |
| 158 | 158 | ||
| 159 | - Div(buffer1_, buffer0_, buffer1_, curRowsNum * cAlign); | 159 | + Div<float, divConfig>(buffer1_, buffer0_, buffer1_, curRowsNum * cAlign); |
| 160 | PipeBarrier<PIPE_V>(); | 160 | PipeBarrier<PIPE_V>(); |
| 161 | 161 | ||
| 162 | queue0_.FreeTensor(buffer0_); | 162 | queue0_.FreeTensor(buffer0_); |
Mnorm/sync_batch_norm_gather_stats_fused/op_kernel/sync_batch_norm_gather_stats_fused_first_axis_workspace.h+3-2
| @@ -217,7 +217,7 @@ public: | |||
| 217 | Duplicate(buffer1, countsSumScalar, curColNum); | 217 | Duplicate(buffer1, countsSumScalar, curColNum); |
| 218 | PipeBarrier<PIPE_V>(); | 218 | PipeBarrier<PIPE_V>(); |
| 219 | 219 | ||
| 220 | - Div(buffer0, buffer0, buffer1, curColNum); | 220 | + Div<float, divConfig>(buffer0, buffer0, buffer1, curColNum); |
| 221 | PipeBarrier<PIPE_V>(); | 221 | PipeBarrier<PIPE_V>(); |
| 222 | 222 | ||
| 223 | event_t event1 = static_cast<event_t>(GetTPipePtr()->FetchEventID(HardEvent::V_MTE3)); | 223 | event_t event1 = static_cast<event_t>(GetTPipePtr()->FetchEventID(HardEvent::V_MTE3)); |
| @@ -242,7 +242,7 @@ public: | |||
| 242 | Duplicate(buffer0, static_cast<float>(1.0f), curColNum); | 242 | Duplicate(buffer0, static_cast<float>(1.0f), curColNum); |
| 243 | PipeBarrier<PIPE_V>(); | 243 | PipeBarrier<PIPE_V>(); |
| 244 | 244 | ||
| 245 | - Div(buffer1, buffer0, buffer1, curColNum); | 245 | + Div<float, divConfig>(buffer1, buffer0, buffer1, curColNum); |
| 246 | PipeBarrier<PIPE_V>(); | 246 | PipeBarrier<PIPE_V>(); |
| 247 | queue0.FreeTensor(buffer0); | 247 | queue0.FreeTensor(buffer0); |
| 248 | 248 | ||
| @@ -307,6 +307,7 @@ public: | |||
| 307 | 307 | ||
| 308 | private: | 308 | private: |
| 309 | TPipe pipe; | 309 | TPipe pipe; |
| 310 | + static constexpr DivConfig divConfig = {DivAlgo::PRECISION_0ULP_FTZ_FALSE}; | ||
| 310 | constexpr static uint16_t SYNC_AIV_ONLY_ALL = 14; | 311 | constexpr static uint16_t SYNC_AIV_ONLY_ALL = 14; |
| 311 | constexpr static uint16_t WORKSPACE_NUM = 1; | 312 | constexpr static uint16_t WORKSPACE_NUM = 1; |
| 312 | int64_t nLength; | 313 | int64_t nLength; |
Mnorm/sync_batch_norm_gather_stats_fused/op_kernel/sync_batch_norm_gather_stats_fused_workspace.h+6-5
| @@ -177,7 +177,7 @@ public: | |||
| 177 | Duplicate(buffer1_, countsSumScalar, curColNum); | 177 | Duplicate(buffer1_, countsSumScalar, curColNum); |
| 178 | PipeBarrier<PIPE_V>(); | 178 | PipeBarrier<PIPE_V>(); |
| 179 | 179 | ||
| 180 | - Div(buffer0_, buffer0_, buffer1_, curColNum); | 180 | + Div<float, divConfig>(buffer0_, buffer0_, buffer1_, curColNum); |
| 181 | PipeBarrier<PIPE_V>(); | 181 | PipeBarrier<PIPE_V>(); |
| 182 | 182 | ||
| 183 | Add(buffer2_, buffer2_, buffer0_, curColNum); | 183 | Add(buffer2_, buffer2_, buffer0_, curColNum); |
| @@ -196,7 +196,7 @@ public: | |||
| 196 | Duplicate(buffer0_, static_cast<float>(1.0f), curColNum); | 196 | Duplicate(buffer0_, static_cast<float>(1.0f), curColNum); |
| 197 | PipeBarrier<PIPE_V>(); | 197 | PipeBarrier<PIPE_V>(); |
| 198 | 198 | ||
| 199 | - Div(buffer1_, buffer0_, buffer1_, curColNum); | 199 | + Div<float, divConfig>(buffer1_, buffer0_, buffer1_, curColNum); |
| 200 | PipeBarrier<PIPE_V>(); | 200 | PipeBarrier<PIPE_V>(); |
| 201 | queue0_.FreeTensor(buffer0_); | 201 | queue0_.FreeTensor(buffer0_); |
| 202 | 202 | ||
| @@ -300,7 +300,7 @@ public: | |||
| 300 | Duplicate(buffer1_, unbiasCountsSum, curColNum); | 300 | Duplicate(buffer1_, unbiasCountsSum, curColNum); |
| 301 | PipeBarrier<PIPE_V>(); | 301 | PipeBarrier<PIPE_V>(); |
| 302 | 302 | ||
| 303 | - Div(buffer1_, buffer3_, buffer1_, curColNum); | 303 | + Div<float, divConfig>(buffer1_, buffer3_, buffer1_, curColNum); |
| 304 | PipeBarrier<PIPE_V>(); | 304 | PipeBarrier<PIPE_V>(); |
| 305 | 305 | ||
| 306 | Muls(buffer1_, buffer1_, momentum, curColNum); | 306 | Muls(buffer1_, buffer1_, momentum, curColNum); |
| @@ -317,7 +317,7 @@ public: | |||
| 317 | Duplicate(buffer1_, countsSumScalar, curColNum); | 317 | Duplicate(buffer1_, countsSumScalar, curColNum); |
| 318 | PipeBarrier<PIPE_V>(); | 318 | PipeBarrier<PIPE_V>(); |
| 319 | 319 | ||
| 320 | - Div(buffer3_, buffer3_, buffer1_, curColNum); | 320 | + Div<float, divConfig>(buffer3_, buffer3_, buffer1_, curColNum); |
| 321 | PipeBarrier<PIPE_V>(); | 321 | PipeBarrier<PIPE_V>(); |
| 322 | 322 | ||
| 323 | Adds(buffer3_, buffer3_, eps, curColNum); | 323 | Adds(buffer3_, buffer3_, eps, curColNum); |
| @@ -329,7 +329,7 @@ public: | |||
| 329 | Duplicate(buffer1_, static_cast<float>(1.0), curColNum); | 329 | Duplicate(buffer1_, static_cast<float>(1.0), curColNum); |
| 330 | PipeBarrier<PIPE_V>(); | 330 | PipeBarrier<PIPE_V>(); |
| 331 | 331 | ||
| 332 | - Div(buffer3_, buffer1_, buffer3_, curColNum); | 332 | + Div<float, divConfig>(buffer3_, buffer1_, buffer3_, curColNum); |
| 333 | PipeBarrier<PIPE_V>(); | 333 | PipeBarrier<PIPE_V>(); |
| 334 | queue0_.FreeTensor(buffer0_); | 334 | queue0_.FreeTensor(buffer0_); |
| 335 | queue1_.FreeTensor(buffer1_); | 335 | queue1_.FreeTensor(buffer1_); |
| @@ -363,6 +363,7 @@ public: | |||
| 363 | 363 | ||
| 364 | private: | 364 | private: |
| 365 | TPipe pipe; | 365 | TPipe pipe; |
| 366 | + static constexpr DivConfig divConfig = {DivAlgo::PRECISION_0ULP_FTZ_FALSE}; | ||
| 366 | constexpr static uint16_t SYNC_AIV_ONLY_ALL = 14; | 367 | constexpr static uint16_t SYNC_AIV_ONLY_ALL = 14; |
| 367 | int64_t nLength; | 368 | int64_t nLength; |
| 368 | int64_t cLength; | 369 | int64_t cLength; |
Dnorm/sync_batch_norm_gather_stats_fused/tests/ut/op_kernel/CMakeLists.txt+0-13
| @@ -1,13 +0,0 @@ | |||
| 1 | -# ---------------------------------------------------------------------------------------------------------- | ||
| 2 | -# Copyright (c) 2025-2026 Huawei Technologies Co., Ltd. | ||
| 3 | -# This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 4 | -# CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | -# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 6 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 7 | -# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | -# See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | -# ---------------------------------------------------------------------------------------------------------- | ||
| 10 | - | ||
| 11 | -if ((UT_TEST_ALL OR OP_KERNEL_UT) AND NOT UT_DONE) | ||
| 12 | - AddOpTestCase(sync_batch_norm_gather_stats_fused "ascend950pr_9599" "") | ||
| 13 | -endif() | ||
Dnorm/sync_batch_norm_gather_stats_fused/tests/ut/op_kernel/sync_batch_norm_gather_stats_fused_tiling_def.h+0-166
| @@ -1,166 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | - * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 4 | - * CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | - * Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 6 | - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 7 | - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | - * See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | - */ | ||
| 10 | - | ||
| 11 | - | ||
| 12 | - | ||
| 13 | - | ||
| 14 | - | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | -struct SyncBatchNormGatherStatsFusedTilingDataCommon { | ||
| 22 | - int64_t nLength = 0; | ||
| 23 | - int64_t cLength = 0; | ||
| 24 | - int64_t cFormerAlignV_ = 0; | ||
| 25 | - int64_t cFormerAlignM_ = 0; | ||
| 26 | - int64_t cTailAlignV_ = 0; | ||
| 27 | - int64_t cTailAlignM_ = 0; | ||
| 28 | - int64_t blockFormer = 0; | ||
| 29 | - int64_t blockNum = 0; | ||
| 30 | - int64_t blockTail = 0; | ||
| 31 | - int64_t ubFormer = 0; | ||
| 32 | - int64_t ubLoop = 0; | ||
| 33 | - int64_t ubTail = 0; | ||
| 34 | - int64_t wholeBufferByteSize = 0; | ||
| 35 | - int64_t nBufferByteSize = 0; | ||
| 36 | - int64_t cBufferByteSize = 0; | ||
| 37 | - int64_t nBrcbBufferByteSize = 0; | ||
| 38 | - int64_t wholeBufferElemNums = 0; | ||
| 39 | - float momentum = 0.1f; | ||
| 40 | - float eps = 1e-5f; | ||
| 41 | -}; | ||
| 42 | - | ||
| 43 | - | ||
| 44 | - | ||
| 45 | -struct SyncBatchNormGatherStatsFusedTilingDataWorkspace { | ||
| 46 | - int64_t nLength = 0; | ||
| 47 | - int64_t cLength = 0; | ||
| 48 | - int64_t blockFormer = 0; | ||
| 49 | - int64_t blockNum = 0; | ||
| 50 | - int64_t blockTail = 0; | ||
| 51 | - int64_t ubFormerOfFormer = 0; | ||
| 52 | - int64_t ubTailOfFormer = 0; | ||
| 53 | - int64_t ubLoopOfFormer = 0; | ||
| 54 | - int64_t ubFormerOfTail = 0; | ||
| 55 | - int64_t ubTailOfTail = 0; | ||
| 56 | - int64_t ubLoopOfTail = 0; | ||
| 57 | - float momentum = 0.1f; | ||
| 58 | - float eps = 1e-5f; | ||
| 59 | -}; | ||
| 60 | - | ||
| 61 | - | ||
| 62 | - | ||
| 63 | -struct SyncBatchNormGatherStatsFusedTilingDataFirstAxisCommon { | ||
| 64 | - int64_t nLength = 0; | ||
| 65 | - int64_t cLength = 0; | ||
| 66 | - int64_t cAlignV = 0; | ||
| 67 | - int64_t cAlignM = 0; | ||
| 68 | - int64_t blockFormer = 0; | ||
| 69 | - int64_t blockNum = 0; | ||
| 70 | - int64_t blockTail = 0; | ||
| 71 | - int64_t ubFormer = 0; | ||
| 72 | - int64_t ubLoopOfFormerBlock = 0; | ||
| 73 | - int64_t ubLoopOfTailBlock = 0; | ||
| 74 | - int64_t ubTailOfFormerBlock = 0; | ||
| 75 | - int64_t ubTailOfTailBlock = 0; | ||
| 76 | - int64_t wholeBufferByteSize = 0; | ||
| 77 | - int64_t nBufferByteSize = 0; | ||
| 78 | - int64_t cBufferByteSize = 0; | ||
| 79 | - int64_t nBrcbBufferByteSize = 0; | ||
| 80 | - int64_t wholeBufferElemNums = 0; | ||
| 81 | - float momentum = 0.1f; | ||
| 82 | - float eps = 1e-5f; | ||
| 83 | -}; | ||
| 84 | - | ||
| 85 | - | ||
| 86 | - | ||
| 87 | -struct SyncBatchNormGatherStatsFusedTilingDataFirstAxisWorkspace { | ||
| 88 | - int64_t nLength = 0; | ||
| 89 | - int64_t cLength = 0; | ||
| 90 | - int64_t cAlignV = 0; | ||
| 91 | - int64_t blockFormer = 0; | ||
| 92 | - int64_t blockNum = 0; | ||
| 93 | - int64_t blockTail = 0; | ||
| 94 | - int64_t ubFormer = 0; | ||
| 95 | - int64_t ubTail = 0; | ||
| 96 | - int64_t ubLoop = 0; | ||
| 97 | - float momentum = 0.1f; | ||
| 98 | - float eps = 1e-5f; | ||
| 99 | -}; | ||
| 100 | - | ||
| 101 | - | ||
| 102 | - | ||
| 103 | -inline[aicore] void InitTilingData(const __gm__ uint8_t* tiling, SyncBatchNormGatherStatsFusedTilingDataCommon* const_data) | ||
| 104 | -{ | ||
| 105 | - const __gm__ uint32_t* src = (const __gm__ uint32_t*)tiling; | ||
| 106 | - uint32_t* dst = (uint32_t*)const_data; | ||
| 107 | - for (auto i = 0; i < sizeof(SyncBatchNormGatherStatsFusedTilingDataCommon) / 4; i++) | ||
| 108 | - *(dst + i) = *(src + i); | ||
| 109 | -} | ||
| 110 | - | ||
| 111 | -inline void InitTilingData(uint8_t* tiling, SyncBatchNormGatherStatsFusedTilingDataCommon* const_data) | ||
| 112 | -{ | ||
| 113 | - memcpy(const_data, tiling, sizeof(SyncBatchNormGatherStatsFusedTilingDataCommon)); | ||
| 114 | -} | ||
| 115 | - | ||
| 116 | - | ||
| 117 | - | ||
| 118 | -inline[aicore] void InitTilingData(const __gm__ uint8_t* tiling, SyncBatchNormGatherStatsFusedTilingDataWorkspace* const_data) | ||
| 119 | -{ | ||
| 120 | - const __gm__ uint32_t* src = (const __gm__ uint32_t*)tiling; | ||
| 121 | - uint32_t* dst = (uint32_t*)const_data; | ||
| 122 | - for (auto i = 0; i < sizeof(SyncBatchNormGatherStatsFusedTilingDataWorkspace) / 4; i++) | ||
| 123 | - *(dst + i) = *(src + i); | ||
| 124 | -} | ||
| 125 | - | ||
| 126 | -inline void InitTilingData(uint8_t* tiling, SyncBatchNormGatherStatsFusedTilingDataWorkspace* const_data) | ||
| 127 | -{ | ||
| 128 | - memcpy(const_data, tiling, sizeof(SyncBatchNormGatherStatsFusedTilingDataWorkspace)); | ||
| 129 | -} | ||
| 130 | - | ||
| 131 | - | ||
| 132 | - | ||
| 133 | -inline[aicore] void InitTilingData(const __gm__ uint8_t* tiling, SyncBatchNormGatherStatsFusedTilingDataFirstAxisCommon* const_data) | ||
| 134 | -{ | ||
| 135 | - const __gm__ uint32_t* src = (const __gm__ uint32_t*)tiling; | ||
| 136 | - uint32_t* dst = (uint32_t*)const_data; | ||
| 137 | - for (auto i = 0; i < sizeof(SyncBatchNormGatherStatsFusedTilingDataFirstAxisCommon) / 4; i++) | ||
| 138 | - *(dst + i) = *(src + i); | ||
| 139 | -} | ||
| 140 | - | ||
| 141 | -inline void InitTilingData(uint8_t* tiling, SyncBatchNormGatherStatsFusedTilingDataFirstAxisCommon* const_data) | ||
| 142 | -{ | ||
| 143 | - memcpy(const_data, tiling, sizeof(SyncBatchNormGatherStatsFusedTilingDataFirstAxisCommon)); | ||
| 144 | -} | ||
| 145 | - | ||
| 146 | - | ||
| 147 | - | ||
| 148 | -inline[aicore] void InitTilingData(const __gm__ uint8_t* tiling, SyncBatchNormGatherStatsFusedTilingDataFirstAxisWorkspace* const_data) | ||
| 149 | -{ | ||
| 150 | - const __gm__ uint32_t* src = (const __gm__ uint32_t*)tiling; | ||
| 151 | - uint32_t* dst = (uint32_t*)const_data; | ||
| 152 | - for (auto i = 0; i < sizeof(SyncBatchNormGatherStatsFusedTilingDataFirstAxisWorkspace) / 4; i++) | ||
| 153 | - *(dst + i) = *(src + i); | ||
| 154 | -} | ||
| 155 | - | ||
| 156 | -inline void InitTilingData(uint8_t* tiling, SyncBatchNormGatherStatsFusedTilingDataFirstAxisWorkspace* const_data) | ||
| 157 | -{ | ||
| 158 | - memcpy(const_data, tiling, sizeof(SyncBatchNormGatherStatsFusedTilingDataFirstAxisWorkspace)); | ||
| 159 | -} | ||
| 160 | - | ||
| 161 | - | ||
| 162 | - | ||
| 163 | - tiling_struct tiling_data; \ | ||
| 164 | - InitTilingData(tiling_arg, &tiling_data) | ||
| 165 | - | ||
| 166 | - | ||
🔵 Low Priority
PR 描述为"除法精度修复",但未添加任何用于验证精度改进或防止回归的测试用例。该算子涉及 5 个不同变体(common、compute、workspace、first_axis_common、first_axis_workspace),共计替换了约 17 处
Div调用。精度修复是关键变更,缺乏对应的回归测试会增加未来重构或 SDK 升级时精度回退的风险。建议:添加针对该精度修复的回归测试用例,验证
PRECISION_0ULP_FTZ_FALSE除法模式下的数值精度符合预期。