已合并
Fix:avoid use high level AscendC API in Blaze impl #274
wangzitao创建于 7月10日
Fix:avoid use high level AscendC API in Blaze impl #274
已合并
共 3 个文件变更+72-2
| @@ -0,0 +1,70 @@ | |||
| 1 | +/** | ||
| 2 | + * Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | + * This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 4 | + * CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | + * Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 6 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 7 | + * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | + * See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | + */ | ||
| 10 | + | ||
| 11 | +/*! | ||
| 12 | + * \file aux_get_c0_size.h | ||
| 13 | + * \brief Local self-contained replacement for AscendC::AuxGetC0Size, decoupling | ||
| 14 | + * blasLt MXFP8/MXFP4 kernels from the adv_api/matmul/matmul.h header. | ||
| 15 | + */ | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | +namespace AscendC { | ||
| 26 | + | ||
| 27 | +namespace AuxC0SizeDetail { | ||
| 28 | +constexpr int32_t B4_C0SIZE = 64; | ||
| 29 | +constexpr int32_t B8_C0SIZE = 32; | ||
| 30 | +constexpr int32_t B16_C0SIZE = 16; | ||
| 31 | +constexpr int32_t B32_C0SIZE = 8; | ||
| 32 | + | ||
| 33 | +template <typename T, typename... Others> | ||
| 34 | +struct IsTypeOneOf { | ||
| 35 | + static constexpr bool value = false; | ||
| 36 | +}; | ||
| 37 | + | ||
| 38 | +template <typename T, typename First, typename... Others> | ||
| 39 | +struct IsTypeOneOf<T, First, Others...> { | ||
| 40 | + static constexpr bool value = IsSameType<T, First>::value || IsTypeOneOf<T, Others...>::value; | ||
| 41 | +}; | ||
| 42 | + | ||
| 43 | +template <typename T, typename... Others> | ||
| 44 | +constexpr bool IsTypeOneOfV = IsTypeOneOf<T, Others...>::value; | ||
| 45 | +} // namespace AuxC0SizeDetail | ||
| 46 | + | ||
| 47 | +template <typename SrcT> | ||
| 48 | +__aicore__ inline constexpr static int32_t AuxGetC0Size() | ||
| 49 | +{ | ||
| 50 | + if (sizeof(SrcT) == sizeof(float)) { | ||
| 51 | + return AuxC0SizeDetail::B32_C0SIZE; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + else if (AuxC0SizeDetail::IsTypeOneOfV<SrcT, uint8_t, int8_t, hifloat8_t, fp8_e4m3fn_t, fp8_e5m2_t, | ||
| 55 | + fp8_e8m0_t>) { | ||
| 56 | + return AuxC0SizeDetail::B8_C0SIZE; | ||
| 57 | + } else if (AuxC0SizeDetail::IsTypeOneOfV<SrcT, int4b_t, fp4x2_e1m2_t, fp4x2_e2m1_t>) { | ||
| 58 | + return AuxC0SizeDetail::B4_C0SIZE; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + else if (IsSameType<SrcT, int8_t>::value) { | ||
| 62 | + return AuxC0SizeDetail::B8_C0SIZE; | ||
| 63 | + } else if (IsSameType<SrcT, int4b_t>::value) { | ||
| 64 | + return AuxC0SizeDetail::B4_C0SIZE; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + return AuxC0SizeDetail::B16_C0SIZE; | ||
| 68 | +} | ||
| 69 | + | ||
| 70 | +} // namespace AscendC | ||
| @@ -17,7 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | -#include "adv_api/matmul/matmul.h" | 20 | +#include "aux_get_c0_size.h" |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | 23 | ||