diff --git a/impl/activation/softmax/softmax_common/softmax_common_utils.h b/impl/activation/softmax/softmax_common/softmax_common_utils.h index 8237582e344a86c7f765d170854bfa9e6aef93e9..3314a64679a44d4b7cd0b2953cee8017f08abef7 100644 --- a/impl/activation/softmax/softmax_common/softmax_common_utils.h +++ b/impl/activation/softmax/softmax_common/softmax_common_utils.h @@ -37,15 +37,6 @@ constexpr uint32_t SOFTMAX_SPECIAL_BASICBLOCK_LEN = FLOAT_REPEAT_SIZE * SOFTMAX_ constexpr uint32_t SOFTMAX_SUB_DIV_ROW_COLUMN_SIZE = 192; constexpr uint32_t SOFTMAX_FLOAT_SPECIAL_BLOCKREDUCE_LEN = DEFAULT_BLOCK_SIZE * HALF_FACTOR; -struct SoftMaxParams { - uint32_t srcM{ 0 }; - uint32_t srcK{ 0 }; - uint32_t oriSrcM{ 0 }; - uint32_t oriSrcK{ 0 }; - uint32_t loopCnt{ 1 }; - uint32_t splitMeanCnt{ 8 }; - float alpha{ 0.9375 }; -}; struct LastAxisShapeND { uint32_t m; uint32_t k; @@ -67,12 +58,5 @@ struct BroadCastLastND { uint32_t srcK; }; -struct SoftMaxShapeInfo { - uint32_t srcM{ 0 }; - uint32_t srcK{ 0 }; - uint32_t oriSrcM{ 0 }; - uint32_t oriSrcK{ 0 }; -}; - }; // namespace AscendC #endif // IMPL_ACTIVATION_SOFTMAX_SOFTMAX_COMMON_UTILS_H \ No newline at end of file diff --git a/impl/math/cumsum/cumsum_common_impl.h b/impl/math/cumsum/cumsum_common_impl.h index 63547831ae6bae6ebd6b1d2481adf1d2c322f6a5..106c1385a38cdfb6a89f2b62fcaa18ceff961986 100644 --- a/impl/math/cumsum/cumsum_common_impl.h +++ b/impl/math/cumsum/cumsum_common_impl.h @@ -22,11 +22,6 @@ #include "lib/math/cumsum_utils.h" namespace AscendC { -struct CumSumInfo { - uint32_t outter{0}; - uint32_t inner{0}; // 32-byte aligned -}; - __aicore__ inline TransDataTo5HDParams ExtractTransDataParam(uint8_t repeatTimes, uint32_t inner, uint16_t alignOutter, uint32_t oneBlockElementNum, uint16_t dstRepStride, uint32_t srcRepStride) { diff --git a/impl/normalization/layernorm/layernorm_common_basic_impl.h b/impl/normalization/layernorm/layernorm_common_basic_impl.h index 1a76027e4f8db43e34ba50e7f51e3e4a1bb5c5da..b8bb9b143287c7a642cf90684a6e249688dd3774 100644 --- a/impl/normalization/layernorm/layernorm_common_basic_impl.h +++ b/impl/normalization/layernorm/layernorm_common_basic_impl.h @@ -25,19 +25,6 @@ struct LayerNormRstdTmpTensorParams { LocalTensor varianceTmpTensor; }; -struct LayerNormPara { - uint32_t aLength; - uint32_t rLength; - uint32_t rLengthWithPadding; -}; - -struct WelfordUpdateParam { - uint32_t rnLength; - uint32_t abLength; - uint32_t abComputeLength; - float nRec; -}; - template __aicore__ inline void LayerNormReduceSumImpl(const LocalTensor& dstMVTmp, const LocalTensor& dst, const LocalTensor& src, const uint32_t bsLength, const uint32_t hLength) diff --git a/impl/normalization/layernormgrad/layernormgrad_common_impl.h b/impl/normalization/layernormgrad/layernormgrad_common_impl.h index 57b7d47a9ba0b8c7effe2e0a3db7ac522ed74d32..1460d91c6ef8622f9fbb1bec935f8d2012a4e64e 100644 --- a/impl/normalization/layernormgrad/layernormgrad_common_impl.h +++ b/impl/normalization/layernormgrad/layernormgrad_common_impl.h @@ -17,15 +17,12 @@ #include "kernel_tensor.h" #include "kernel_tiling/kernel_tiling.h" +#include "lib/normalization/layernormgrad_utils.h" const uint32_t LAYERNORM_GRAD_B32_BYTE_SIZE = 4; const uint32_t LAYERNORM_GRAD_B16_BYTE_SIZE = 2; namespace AscendC { -struct LayerNormGradShapeInfo { - DataFormat dataFormat = DataFormat::ND; -}; - struct LayerNormGradParams { __aicore__ LayerNormGradParams(LayerNormGradTiling &tiling, LocalTensor &stackBuffer) : bLength(tiling.bLength), diff --git a/impl/normalization/normalize/normalize_common_impl.h b/impl/normalization/normalize/normalize_common_impl.h index f61ffd2f70ed21d93a8119928bce834a33059335..0d4177e0465754063d489d2e0dde8f95cb7e3425 100644 --- a/impl/normalization/normalize/normalize_common_impl.h +++ b/impl/normalization/normalize/normalize_common_impl.h @@ -22,21 +22,6 @@ namespace AscendC { const float DEFAULT_EPSILON = 1e-5; -struct NormalizePara { - uint32_t aLength; - uint32_t rLength; - uint32_t rLengthWithPadding; -}; - -template -struct NormalizeTmpTensor { - __aicore__ NormalizeTmpTensor(){}; - LocalTensor tempTensorA; - LocalTensor tempTensorB; - LocalTensor gammaTmpTensor; - LocalTensor betaTmpTensor; -}; - template __aicore__ inline constexpr bool IsDtypeValid() { diff --git a/impl/normalization/welfordfinalize/welfordfinalize_common_impl.h b/impl/normalization/welfordfinalize/welfordfinalize_common_impl.h index 9a8b62dd5cba036e19f2decabd8b65730fe46551..08d405a33ce453623f516cbeedb235eec727f063 100644 --- a/impl/normalization/welfordfinalize/welfordfinalize_common_impl.h +++ b/impl/normalization/welfordfinalize/welfordfinalize_common_impl.h @@ -18,6 +18,7 @@ #include "kernel_tensor.h" #include "kernel_pop_stack_buffer.h" #include "kernel_tiling/kernel_tiling.h" +#include "lib/normalization/welfordfinalize_utils.h" namespace AscendC { @@ -25,18 +26,6 @@ constexpr uint32_t OUTPUT_SIZE = 8; constexpr uint32_t B32_LEN = 256 / sizeof(float); constexpr uint32_t OUTPUT_MASK_B32 = 254; -struct WelfordFinalizePara -{ - uint32_t rnLength; - uint32_t abLength; - uint32_t headCount; - uint32_t headCountLength; - uint32_t tailCount; - uint32_t tailCountLength; - float abRec; - float rRec; -}; - struct WelfordFinalizeTilingData { uint32_t computeLength; diff --git a/impl/quantization/antiquant/ascend_antiquant_common.h b/impl/quantization/antiquant/ascend_antiquant_common.h index ee60d0373f54317bc9d4b340d95e41ea9973b4e8..4bf123ce78d39e6570d5180a3f3ad9cea727f35b 100644 --- a/impl/quantization/antiquant/ascend_antiquant_common.h +++ b/impl/quantization/antiquant/ascend_antiquant_common.h @@ -15,6 +15,8 @@ #ifndef IMPL_QUANTIZATION_ANTIQUANT_ASCEND_ANTIQUANT_COMMON_H #define IMPL_QUANTIZATION_ANTIQUANT_ASCEND_ANTIQUANT_COMMON_H +#include "lib/quantization/ascend_antiquant_utils.h" + namespace AscendC { constexpr uint32_t ANTIQUANT_TWO = 2; constexpr uint32_t ANTIQUANT_FOUR = 4; @@ -26,12 +28,5 @@ constexpr uint32_t ANTIQUANT_SINGLE_N_SIZE_FP16 = 128; constexpr uint32_t ANTIQUANT_MAX_K = 255; constexpr uint32_t MAX_K_FOR_FP16_BRCB = 4096; -struct AntiQuantShapeInfo { - uint32_t offsetHeight{0}; - uint32_t offsetWidth{0}; - uint32_t scaleHeight{0}; - uint32_t scaleWidth{0}; -}; - } // namespace AscendC #endif // IMPL_QUANTIZATION_ANTIQUANT_ASCEND_ANTIQUANT_COMMON_H diff --git a/impl/quantization/dequant/ascend_dequant_common_impl.h b/impl/quantization/dequant/ascend_dequant_common_impl.h index 782977ddbde093524ff21969820dcd9238c1a0b4..235ba2b7612d818aa6767301acfa8bee0f92d2cd 100644 --- a/impl/quantization/dequant/ascend_dequant_common_impl.h +++ b/impl/quantization/dequant/ascend_dequant_common_impl.h @@ -17,17 +17,12 @@ #include "kernel_tensor.h" #include "kernel_pop_stack_buffer.h" +#include "lib/quantization/ascend_dequant_utils.h" namespace AscendC { constexpr uint32_t FLOAT_PER_BLOCK = 8; // 32B = FP32(4B) * 8 constexpr uint32_t FLOAT_PER_REPEAT = 64; // 256B = FP32(4B) * 64 -struct DequantParams { - uint32_t m; // outer axis length (do not need 32B align) in unit of element num - uint32_t n; // inner axis length (must be 32B align) in unit of element num - uint32_t calCount; // in one inner line, calCount elements do dequant calculation in unit of element num -}; - __aicore__ inline bool IsCalCountValid(const LocalTensor& srcTensor, uint32_t calCount) { // calCount must be in range (0, srcTensor element num] diff --git a/impl/reduce/mean/mean_common_impl.h b/impl/reduce/mean/mean_common_impl.h index 4215ca7870a2e995e3f0e2d639517624aa3b7ee0..92835d4cf2fa7de4af9671a2d4cbba093e4d519f 100644 --- a/impl/reduce/mean/mean_common_impl.h +++ b/impl/reduce/mean/mean_common_impl.h @@ -17,6 +17,7 @@ #include "kernel_tensor.h" #include "kernel_operator_intf.h" +#include "lib/reduce/mean_utils.h" #if ASCENDC_CPU_DEBUG #include "kernel_log.h" #include @@ -25,11 +26,6 @@ namespace AscendC { constexpr uint32_t HALF_NUM_PER = 128; constexpr uint32_t FLOAT_NUM_PER = 64; -struct MeanParams { - uint32_t outter = 1; - uint32_t inner; // inner = 32-byte alignment of n, inner = (n *sizeof(T) + 32 - 1) / 32 * 32 / sizeof(T) - uint32_t n; // actual length of the tensor -}; template __aicore__ inline void CheckParamsIsValid(const LocalTensor& dstTensor, const LocalTensor& srcTensor, diff --git a/impl/reduce/sum/sum_common_impl.h b/impl/reduce/sum/sum_common_impl.h index 0f9205511d25d3f4c1032ca521004caad9411bb2..7f4dcd29baf6a2a7322fa1b8d53467b5d9f15a20 100644 --- a/impl/reduce/sum/sum_common_impl.h +++ b/impl/reduce/sum/sum_common_impl.h @@ -17,16 +17,12 @@ #include "kernel_tensor.h" #include "kernel_operator_intf.h" +#include "lib/reduce/sum_utils.h" #if ASCENDC_CPU_DEBUG #include "kernel_log.h" #include #endif namespace AscendC { -struct SumParams { - uint32_t outter = 1; - uint32_t inner; // inner = 32-byte alignment of n, inner = (n *sizeof(T) + 32 - 1) / 32 * 32 / sizeof(T) - uint32_t n; // actual length of the tensor -}; template __aicore__ inline void CheckParamsIsValid(const LocalTensor &dstTensor, const LocalTensor &srcTensor, diff --git a/impl/sort/topk/topk_common_utils.h b/impl/sort/topk/topk_common_utils.h index e999ed4113860394fb5a562f9554cef4d361769b..61db22b46f1df117f263a0bef8ea1c1b40e64e40 100644 --- a/impl/sort/topk/topk_common_utils.h +++ b/impl/sort/topk/topk_common_utils.h @@ -15,6 +15,8 @@ #ifndef IMPL_SORT_TOPK_TOPK_COMMON_UTILS_H #define IMPL_SORT_TOPK_TOPK_COMMON_UTILS_H +#include "lib/sort/topk_utils.h" + #if __CCE_AICORE__ >= 200 namespace { constexpr uint16_t MIN_SORT32_SIZE = 32; @@ -46,18 +48,6 @@ constexpr uint32_t TOPK_NSMALL_INNER_LEN = 32; constexpr uint32_t TOPK_NORMAL_INNER_MAX_LEN = 4096; } // namespace -namespace AscendC { -struct TopKInfo { - int32_t outter = 1; - int32_t inner; // inner = 32-byte alignment of n - int32_t n; // actual length of the tensor -}; - -enum class TopKMode { - TOPK_NORMAL, - TOPK_NSMALL, -}; -} #endif #endif // IMPL_SORT_TOPK_TOPK_COMMON_UTILS_H \ No newline at end of file diff --git a/lib/activation/softmax_utils.h b/lib/activation/softmax_utils.h index 49cd6b34d06b7438fc235e6116d3b6706f01a119..afb6ebd184a2d84087f622352c0db8cd8d272e98 100644 --- a/lib/activation/softmax_utils.h +++ b/lib/activation/softmax_utils.h @@ -49,5 +49,22 @@ struct SoftmaxConfig { constexpr SoftmaxConfig SOFTMAX_DEFAULT_CFG = { true, 0, 0 , SoftmaxMode::SOFTMAX_NORMAL}; +struct SoftMaxParams { + uint32_t srcM{ 0 }; + uint32_t srcK{ 0 }; + uint32_t oriSrcM{ 0 }; + uint32_t oriSrcK{ 0 }; + uint32_t loopCnt{ 1 }; + uint32_t splitMeanCnt{ 8 }; + float alpha{ 0.9375 }; +}; + +struct SoftMaxShapeInfo { + uint32_t srcM{ 0 }; + uint32_t srcK{ 0 }; + uint32_t oriSrcM{ 0 }; + uint32_t oriSrcK{ 0 }; +}; + }; // namespace AscendC #endif // LIB_ACTIVATION_SOFTMAX_UTILS_H \ No newline at end of file diff --git a/lib/math/cumsum_utils.h b/lib/math/cumsum_utils.h index 39272ab2d9430bf9bec0c9ea0f7998e7196e10a1..9a19f8fa9a1c41a720d1bf18a5f5681b91eeac9f 100644 --- a/lib/math/cumsum_utils.h +++ b/lib/math/cumsum_utils.h @@ -23,5 +23,10 @@ struct CumSumConfig { bool outputLastRow{false}; }; +struct CumSumInfo { + uint32_t outter{0}; + uint32_t inner{0}; // 32-byte aligned +}; + }; // namespace AscendC #endif // LIB_MATH_CUMSUM_UTILS_H \ No newline at end of file diff --git a/lib/normalization/layernorm_utils.h b/lib/normalization/layernorm_utils.h index 471a0e09acc241e810eb796763396a602477d3e1..a9c608f24f236a0f80a6ade35afb3275fd21ab09 100644 --- a/lib/normalization/layernorm_utils.h +++ b/lib/normalization/layernorm_utils.h @@ -37,5 +37,18 @@ struct WelfordUpdateConfig { constexpr WelfordUpdateConfig WFUPDATE_DEFAULT_CFG = {false}; +struct LayerNormPara { + uint32_t aLength; + uint32_t rLength; + uint32_t rLengthWithPadding; +}; + +struct WelfordUpdateParam { + uint32_t rnLength; + uint32_t abLength; + uint32_t abComputeLength; + float nRec; +}; + }; // namespace AscendC #endif // LIB_NORMALIZATION_LAYERNORM_UTILS_H \ No newline at end of file diff --git a/lib/normalization/layernormgrad.h b/lib/normalization/layernormgrad.h index 06c572beac1dc8f9162d047696c1d96050fd9789..13f06e9e6d1ff6a4383314adfbdeb1ce04da392a 100644 --- a/lib/normalization/layernormgrad.h +++ b/lib/normalization/layernormgrad.h @@ -16,6 +16,7 @@ #define LIB_NORMALIZATION_LAYERNORMGRAD_H #include "kernel_tensor.h" +#include "lib/normalization/layernormgrad_utils.h" #include "../../impl/normalization/layernormgrad/layernormgrad_common_impl.h" #include "kernel_tiling/kernel_tiling.h" diff --git a/lib/normalization/layernormgrad_utils.h b/lib/normalization/layernormgrad_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..b148343bf15490ce6205e2219df8025bdea3a155 --- /dev/null +++ b/lib/normalization/layernormgrad_utils.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. + * This file is a part of the CANN Open Software. + * Licensed under CANN Open Software License Agreement Version 1.0 (the "License"). + * Please refer to the License for details. You may not use this file except in compliance with the License. + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. + * See LICENSE in the root of the software repository for the full text of the License. + */ + +/* ! + * \file layernormgrad_utils.h + * \brief + */ +#ifndef LIB_NORMALIZATION_LAYERNORMGRAD_UTILS_H +#define LIB_NORMALIZATION_LAYERNORMGRAD_UTILS_H + +#include "kernel_tensor.h" + +namespace AscendC { + +struct LayerNormGradShapeInfo { + DataFormat dataFormat = DataFormat::ND; +}; + +}; // namespace AscendC +#endif // LIB_NORMALIZATION_LAYERNORMGRAD_UTILS_H \ No newline at end of file diff --git a/lib/normalization/normalize_utils.h b/lib/normalization/normalize_utils.h index 15bd1bf4f6deba296e0801375516b98e0228f2ee..86e1710e124b4db50915e9ac794a3daa86f31ce8 100644 --- a/lib/normalization/normalize_utils.h +++ b/lib/normalization/normalize_utils.h @@ -47,5 +47,20 @@ constexpr NormalizeConfig NLCFG_NOGAMMA = GetNormalizeConfig(false, true); constexpr NormalizeConfig NLCFG_NOOPT = GetNormalizeConfig(true, true); +struct NormalizePara { + uint32_t aLength; + uint32_t rLength; + uint32_t rLengthWithPadding; +}; + +template +struct NormalizeTmpTensor { + __aicore__ NormalizeTmpTensor(){}; + LocalTensor tempTensorA; + LocalTensor tempTensorB; + LocalTensor gammaTmpTensor; + LocalTensor betaTmpTensor; +}; + }; // namespace AscendC #endif // LIB_NORMALIZATION_NORMALIZE_UTILS_H \ No newline at end of file diff --git a/lib/normalization/welfordfinalize.h b/lib/normalization/welfordfinalize.h index 84e05646d55024d95b959c1310631146a273188b..d4d5c8bed1cc2619c0620f7663a6eb021aa2ea51 100644 --- a/lib/normalization/welfordfinalize.h +++ b/lib/normalization/welfordfinalize.h @@ -17,6 +17,7 @@ #ifndef LIB_NORMALIZATION_WELFORDFINALIZE_H #define LIB_NORMALIZATION_WELFORDFINALIZE_H #if __CCE_AICORE__ == 200 || __CCE_AICORE__ == 220 +#include "lib/normalization/welfordfinalize_utils.h" #include "../../impl/normalization/welfordfinalize/welfordfinalize_common_impl.h" #include "kernel_tensor.h" #include "kernel_tiling/kernel_tiling.h" diff --git a/lib/normalization/welfordfinalize_utils.h b/lib/normalization/welfordfinalize_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..61f80a8335ced58e8af4dd445aca18f9bdaf5b0c --- /dev/null +++ b/lib/normalization/welfordfinalize_utils.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. + * This file is a part of the CANN Open Software. + * Licensed under CANN Open Software License Agreement Version 1.0 (the "License"). + * Please refer to the License for details. You may not use this file except in compliance with the License. + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. + * See LICENSE in the root of the software repository for the full text of the License. + */ + +/* ! + * \file welfordfinalize_utils.h + * \brief + */ +#ifndef LIB_NORMALIZATION_WELFORDFINALIZE_UTILS_H +#define LIB_NORMALIZATION_WELFORDFINALIZE_UTILS_H + +namespace AscendC { + +struct WelfordFinalizePara +{ + uint32_t rnLength; + uint32_t abLength; + uint32_t headCount; + uint32_t headCountLength; + uint32_t tailCount; + uint32_t tailCountLength; + float abRec; + float rRec; +}; + +}; // namespace AscendC +#endif // LIB_NORMALIZATION_WELFORDFINALIZE_UTILS_H \ No newline at end of file diff --git a/lib/quantization/ascend_antiquant.h b/lib/quantization/ascend_antiquant.h index 435367a86f3e45689e96988568ec63fc147faaf5..0275ae1ea922231928ab9c8ba8c3d679d72c2968 100644 --- a/lib/quantization/ascend_antiquant.h +++ b/lib/quantization/ascend_antiquant.h @@ -15,6 +15,7 @@ #ifndef LIB_QUANTIZATION_ASCEND_ANTIQUANT_H #define LIB_QUANTIZATION_ASCEND_ANTIQUANT_H #include "kernel_tensor.h" +#include "lib/quantization/ascend_antiquant_utils.h" #include "../../impl/quantization/antiquant/ascend_antiquant_impl.h" namespace AscendC { #pragma begin_pipe(V) diff --git a/lib/quantization/ascend_antiquant_utils.h b/lib/quantization/ascend_antiquant_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..ce21cc8f59408bd411ecded88ae99e40a62bf618 --- /dev/null +++ b/lib/quantization/ascend_antiquant_utils.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. + * This file is a part of the CANN Open Software. + * Licensed under CANN Open Software License Agreement Version 1.0 (the "License"). + * Please refer to the License for details. You may not use this file except in compliance with the License. + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. + * See LICENSE in the root of the software repository for the full text of the License. + */ + +/* ! + * \file ascend_antiquant_utils.h + * \brief + */ +#ifndef LIB_QUANTIZATION_ASCEND_ANTIQUANT_UTILS_H +#define LIB_QUANTIZATION_ASCEND_ANTIQUANT_UTILS_H + +namespace AscendC { +struct AntiQuantShapeInfo { + uint32_t offsetHeight{0}; + uint32_t offsetWidth{0}; + uint32_t scaleHeight{0}; + uint32_t scaleWidth{0}; +}; + +}; // namespace AscendC +#endif // LIB_QUANTIZATION_ASCEND_ANTIQUANT_UTILS_H \ No newline at end of file diff --git a/lib/quantization/ascend_dequant.h b/lib/quantization/ascend_dequant.h index 11f7790d6accd3bbb3107bd1fb7ccc3640dbbb42..1340a51e18f756cfbdfaac479b9ce3556a2caae0 100644 --- a/lib/quantization/ascend_dequant.h +++ b/lib/quantization/ascend_dequant.h @@ -14,6 +14,7 @@ */ #ifndef LIB_QUANTIZATION_ASCEND_DEQUANT_H #define LIB_QUANTIZATION_ASCEND_DEQUANT_H +#include "lib/quantization/ascend_dequant_utils.h" #if defined(__CCE_AICORE__) && (__CCE_AICORE__ == 220 || __CCE_AICORE__ == 200) #include "kernel_tensor.h" #include "../../impl/quantization/dequant/ascend_dequant_common_impl.h" diff --git a/lib/quantization/ascend_dequant_utils.h b/lib/quantization/ascend_dequant_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..2147be7b693c7e1dc01fcb22b54ac942451d1d10 --- /dev/null +++ b/lib/quantization/ascend_dequant_utils.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. + * This file is a part of the CANN Open Software. + * Licensed under CANN Open Software License Agreement Version 1.0 (the "License"). + * Please refer to the License for details. You may not use this file except in compliance with the License. + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. + * See LICENSE in the root of the software repository for the full text of the License. + */ + +/* ! + * \file ascend_dequant_utils.h + * \brief + */ +#ifndef LIB_QUANTIZATION_ASCEND_DEQUANT_UTILS_H +#define LIB_QUANTIZATION_ASCEND_DEQUANT_UTILS_H + +namespace AscendC { +struct DequantParams { + uint32_t m; // outer axis length (do not need to be 32B aligned) in unit of element num + uint32_t n; // inner axis length (must be 32B aligned) in unit of element num + uint32_t calCount; // in one inner line, calCount elements do dequant calculation in unit of element num +}; + +}; // namespace AscendC +#endif // LIB_QUANTIZATION_ASCEND_DEQUANT_UTILS_H \ No newline at end of file diff --git a/lib/reduce/mean.h b/lib/reduce/mean.h index 914ce78387cbe8ca5f2471e4e65bda0087aebb14..dbc87a136297fc3fc81daa06c611394f92670bd8 100644 --- a/lib/reduce/mean.h +++ b/lib/reduce/mean.h @@ -17,6 +17,7 @@ #include "kernel_tensor.h" #include "kernel_operator_intf.h" +#include "lib/reduce/mean_utils.h" #include "../../impl/reduce/mean/mean_common_impl.h" #if ASCENDC_CPU_DEBUG #include "kernel_log.h" diff --git a/lib/reduce/mean_utils.h b/lib/reduce/mean_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..925d7b6c25ef0211ac7122eab2df3e55db2a2e51 --- /dev/null +++ b/lib/reduce/mean_utils.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. + * This file is a part of the CANN Open Software. + * Licensed under CANN Open Software License Agreement Version 1.0 (the "License"). + * Please refer to the License for details. You may not use this file except in compliance with the License. + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. + * See LICENSE in the root of the software repository for the full text of the License. + */ + +/* ! + * \file mean_utils.h + * \brief + */ +#ifndef LIB_REDUCE_MEAN_UTILS_H +#define LIB_REDUCE_MEAN_UTILS_H + +namespace AscendC { +struct MeanParams { + uint32_t outter = 1; + uint32_t inner; // inner = 32-byte alignment of n, inner = (n *sizeof(T) + 32 - 1) / 32 * 32 / sizeof(T) + uint32_t n; // actual length of the tensor +}; + +}; // namespace AscendC +#endif // LIB_REDUCE_MEAN_UTILS_H \ No newline at end of file diff --git a/lib/reduce/sum.h b/lib/reduce/sum.h index 840ba3fff3cc3612528ede31541517d7b6a9d2b3..a9f877b11350c3997fc1798d1432e892b7a903d0 100644 --- a/lib/reduce/sum.h +++ b/lib/reduce/sum.h @@ -17,6 +17,7 @@ #include "kernel_tensor.h" #include "kernel_operator_intf.h" +#include "lib/reduce/sum_utils.h" #include "../../impl/reduce/sum/sum_common_impl.h" #if ASCENDC_CPU_DEBUG #include "kernel_log.h" diff --git a/lib/reduce/sum_utils.h b/lib/reduce/sum_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..61561799e6e3dba0d9359163693ef47eaa6b9b71 --- /dev/null +++ b/lib/reduce/sum_utils.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. + * This file is a part of the CANN Open Software. + * Licensed under CANN Open Software License Agreement Version 1.0 (the "License"). + * Please refer to the License for details. You may not use this file except in compliance with the License. + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. + * See LICENSE in the root of the software repository for the full text of the License. + */ + +/* ! + * \file sum_utils.h + * \brief + */ +#ifndef LIB_REDUCE_SUM_UTILS_H +#define LIB_REDUCE_SUM_UTILS_H + +namespace AscendC { +struct SumParams { + uint32_t outter = 1; + uint32_t inner; // inner = 32-byte alignment of n, inner = (n *sizeof(T) + 32 - 1) / 32 * 32 / sizeof(T) + uint32_t n; // actual length of the tensor +}; + +}; // namespace AscendC +#endif // LIB_REDUCE_SUM_UTILS_H \ No newline at end of file diff --git a/lib/sort/topk.h b/lib/sort/topk.h index d07e7c7c150dcf409232bbe3af53ccaa60dda665..11e8532d786e8b9a0b38e133664e6f409571837f 100644 --- a/lib/sort/topk.h +++ b/lib/sort/topk.h @@ -15,6 +15,7 @@ #ifndef LIB_SORT_TOPK_H #define LIB_SORT_TOPK_H +#include "lib/sort/topk_utils.h" #if __CCE_AICORE__ >= 200 #include "kernel_tensor.h" diff --git a/lib/sort/topk_utils.h b/lib/sort/topk_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..8dd2076778216c3b6a110f16a19a46485cfad912 --- /dev/null +++ b/lib/sort/topk_utils.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. + * This file is a part of the CANN Open Software. + * Licensed under CANN Open Software License Agreement Version 1.0 (the "License"). + * Please refer to the License for details. You may not use this file except in compliance with the License. + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. + * See LICENSE in the root of the software repository for the full text of the License. + */ + +/* ! + * \file topk_utils.h + * \brief + */ +#ifndef LIB_SORT_TOPK_UTILS_H +#define LIB_SORT_TOPK_UTILS_H + +namespace AscendC { +struct TopKInfo { + int32_t outter = 1; + int32_t inner; // inner = 32-byte alignment of n + int32_t n; // actual length of the tensor +}; +#ifndef ASCC_ENUM_TOPKMODE +#define ASCC_ENUM_TOPKMODE +enum class TopKMode { + TOPK_NORMAL, + TOPK_NSMALL, +}; +#endif + +}; // namespace AscendC +#endif // LIB_SORT_TOPK_UTILS_H \ No newline at end of file