From 310f01ed35c0c1f3eac6461ec382187a09d5fb70 Mon Sep 17 00:00:00 2001 From: PengC Date: Tue, 29 Apr 2025 10:33:35 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=A4=8D=E5=AE=9A=E4=B9=89=E6=95=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- impl/sort/topk/topk_common_utils.h | 3 ++ lib/matmul/matmul_tiling_base.h | 4 +++ lib/sort/topk_tiling.h | 4 +++ lib/transpose/confusion_transpose_tiling.h | 33 ++++++++++++++++++++++ 4 files changed, 44 insertions(+) diff --git a/impl/sort/topk/topk_common_utils.h b/impl/sort/topk/topk_common_utils.h index e999ed41..2d5a1aba 100644 --- a/impl/sort/topk/topk_common_utils.h +++ b/impl/sort/topk/topk_common_utils.h @@ -53,10 +53,13 @@ struct TopKInfo { int32_t n; // actual length of the tensor }; +#ifndef ASCC_ENUM_TOPKMODE +#define ASCC_ENUM_TOPKMODE enum class TopKMode { TOPK_NORMAL, TOPK_NSMALL, }; +#endif } #endif diff --git a/lib/matmul/matmul_tiling_base.h b/lib/matmul/matmul_tiling_base.h index b6708ce5..05828030 100644 --- a/lib/matmul/matmul_tiling_base.h +++ b/lib/matmul/matmul_tiling_base.h @@ -21,7 +21,9 @@ #include "tiling/platform/platform_ascendc.h" namespace matmul_tiling { +#ifndef __ASCC_DEVICE__ using half = double; +#endif constexpr int32_t UINT8_BYTES = 1; constexpr int32_t INT8_BYTES = 1; constexpr int32_t FP32_BYTES = 4; @@ -66,12 +68,14 @@ enum class DataType : int32_t { DT_MAX = 34 // Mark the boundaries of data types }; +#ifndef __ASCC_DEVICE__ const std::map DTYPE_BYTE_TAB = { {DataType::DT_FLOAT, 4}, {DataType::DT_FLOAT16, 2}, {DataType::DT_INT8, 1}, {DataType::DT_INT16, 2}, {DataType::DT_UINT16, 2}, {DataType::DT_UINT8, 1}, {DataType::DT_INT32, 4}, {DataType::DT_INT64, 8}, {DataType::DT_UINT32, 4}, {DataType::DT_UINT64, 8}, {DataType::DT_BF16, 2}, {DataType::DT_BFLOAT16, 2}, {DataType::DT_INT4, 1} }; +#endif // __ASCC_DEVICE__ const std::map DTYPE_BIT_TAB = { {DataType::DT_FLOAT, 32}, {DataType::DT_FLOAT16, 16}, {DataType::DT_INT8, 8}, {DataType::DT_INT16, 16}, diff --git a/lib/sort/topk_tiling.h b/lib/sort/topk_tiling.h index 07e36dbb..b224737b 100644 --- a/lib/sort/topk_tiling.h +++ b/lib/sort/topk_tiling.h @@ -13,12 +13,16 @@ #include "tiling/platform/platform_ascendc.h" namespace AscendC { +#ifndef ASCC_ENUM_TOPKMODE +#define ASCC_ENUM_TOPKMODE enum class TopKMode { TOPK_NORMAL, TOPK_NSMALL, }; +#endif + /* * @ingroup GetTopKMaxMinTmpSize * @brief Get TopK api calculate need max and min temporary local space size. diff --git a/lib/transpose/confusion_transpose_tiling.h b/lib/transpose/confusion_transpose_tiling.h index d91742ee..ae4a59bc 100644 --- a/lib/transpose/confusion_transpose_tiling.h +++ b/lib/transpose/confusion_transpose_tiling.h @@ -18,9 +18,42 @@ #include "confusion_transpose_tilingdata.h" namespace AscendC { constexpr uint32_t TWO_TIMES = 2; +#ifndef __ASCC_DEVICE__ + +#ifndef ASCC_PARAM_BLOCK_CUBE + +#define ASCC_PARAM_BLOCK_CUBE constexpr uint32_t BLOCK_CUBE = 16; +#endif + +#ifndef ASCC_PARAM_ONE_BLK_SIZE +#define ASCC_PARAM_ONE_BLK_SIZE constexpr uint32_t ONE_BLK_SIZE = 32; +#endif + +#ifndef ASCC_PARAM_CUBE_MAX_SIZE +#define ASCC_PARAM_CUBE_MAX_SIZE constexpr int32_t CUBE_MAX_SIZE = 256; +#endif + +#else // #ifdef __ASCC_DEVICE__ + +#ifndef ASCC_PARAM_BLOCK_CUBE +#define ASCC_PARAM_BLOCK_CUBE +const int32_t BLOCK_CUBE = 16; +#endif + +#ifndef ASCC_PARAM_ONE_BLK_SIZE +#define ASCC_PARAM_ONE_BLK_SIZE +const uint16_t ONE_BLK_SIZE = 32; +#endif + +#ifndef ASCC_PARAM_CUBE_MAX_SIZE +#define ASCC_PARAM_CUBE_MAX_SIZE +const int32_t CUBE_MAX_SIZE = 256; +#endif + +#endif // __ASCC_DEVICE__ /*! * \brief calculate max and min tmp buffer size for ConfusionTranspose interface. tmp buffer size is a input for GetConfusionTransposeTilingInfo -- Gitee