已合并
【性能优化】conv正向卷积算子性能优化 #3793
ray-shaw创建于 4月14日
【性能优化】conv正向卷积算子性能优化 #3793
已合并
共 88 个文件变更+4424-3574
| @@ -159,6 +159,26 @@ struct ShapeInfo { | |||
| 159 | uint8_t dualOutput = 0; | 159 | uint8_t dualOutput = 0; |
| 160 | }; | 160 | }; |
| 161 | 161 | ||
| 162 | +#pragma pack(push, 1) // 确保无填充,严格按位排列 | ||
| 163 | +typedef struct { | ||
| 164 | + uint64_t strideW : 6; // bits 0-5 | ||
| 165 | + uint64_t strideH : 6; // bits 6-11 | ||
| 166 | + uint64_t kernelW : 8; // bits 12-19 | ||
| 167 | + uint64_t kernelH : 8; // bits 20-27 | ||
| 168 | + uint64_t dilationW : 8; // bits 28-35 | ||
| 169 | + uint64_t dilationH : 8; // bits 36-43 | ||
| 170 | + uint64_t kernelW_highest_bit : 1; // bit 44 | ||
| 171 | + uint64_t kernelH_highest_bit : 1; // bit 45 | ||
| 172 | + uint64_t reserve1 : 2; // bits 46-47 | ||
| 173 | + uint64_t channelSize : 16; // bits 48-63 | ||
| 174 | +} BitFieldData; | ||
| 175 | +#pragma pack(pop) | ||
| 176 | + | ||
| 177 | +union UnionDataXt { | ||
| 178 | + uint64_t n; | ||
| 179 | + BitFieldData bf; // n与bf共享同一块内存空间 | ||
| 180 | +}; | ||
| 181 | + | ||
| 162 | struct AttrInfo { | 182 | struct AttrInfo { |
| 163 | int32_t padHead = 0; | 183 | int32_t padHead = 0; |
| 164 | int32_t padTail = 0; | 184 | int32_t padTail = 0; |
| @@ -178,6 +198,9 @@ struct AttrInfo { | |||
| 178 | int32_t groups = 1; | 198 | int32_t groups = 1; |
| 179 | int8_t offsetx = 0; | 199 | int8_t offsetx = 0; |
| 180 | int8_t roundMode = 0; | 200 | int8_t roundMode = 0; |
| 201 | + | ||
| 202 | + UnionDataXt unionDataXt; | ||
| 203 | + AttrInfo() : unionDataXt{} {} | ||
| 181 | }; | 204 | }; |
| 182 | 205 | ||
| 183 | struct DescInfo { | 206 | struct DescInfo { |
| @@ -132,7 +132,11 @@ const std::vector<std::vector<ge::Format>> SUPPORT_CONV2D_FORMAT_LIST = { | |||
| 132 | const std::vector<std::vector<ge::Format>> SUPPORT_CONV2D_FORMAT_LIST_MDC = { | 132 | const std::vector<std::vector<ge::Format>> SUPPORT_CONV2D_FORMAT_LIST_MDC = { |
| 133 | {ge::Format::FORMAT_NCHW, ge::Format::FORMAT_NCHW, ge::Format::FORMAT_NCHW}, | 133 | {ge::Format::FORMAT_NCHW, ge::Format::FORMAT_NCHW, ge::Format::FORMAT_NCHW}, |
| 134 | {ge::Format::FORMAT_NCHW, ge::Format::FORMAT_HWCN, ge::Format::FORMAT_NCHW}, | 134 | {ge::Format::FORMAT_NCHW, ge::Format::FORMAT_HWCN, ge::Format::FORMAT_NCHW}, |
| 135 | - {ge::Format::FORMAT_NHWC, ge::Format::FORMAT_HWCN, ge::Format::FORMAT_NHWC} | 135 | + {ge::Format::FORMAT_NHWC, ge::Format::FORMAT_HWCN, ge::Format::FORMAT_NHWC}, |
| 136 | + {ge::Format::FORMAT_NCHW, ge::Format::FORMAT_NCHW, ge::Format::FORMAT_NHWC}, | ||
| 137 | + {ge::Format::FORMAT_NCHW, ge::Format::FORMAT_HWCN, ge::Format::FORMAT_NHWC}, | ||
| 138 | + {ge::Format::FORMAT_NHWC, ge::Format::FORMAT_NCHW, ge::Format::FORMAT_NCHW}, | ||
| 139 | + {ge::Format::FORMAT_NHWC, ge::Format::FORMAT_HWCN, ge::Format::FORMAT_NCHW} | ||
| 136 | }; | 140 | }; |
| 137 | 141 | ||
| 138 | const std::vector<std::vector<ge::Format>> SUPPORT_QUANT_CONV2D_FORMAT_LIST = { | 142 | const std::vector<std::vector<ge::Format>> SUPPORT_QUANT_CONV2D_FORMAT_LIST = { |
| @@ -167,7 +171,11 @@ const std::vector<std::vector<ge::Format>> EXTENDCONV2D_SUPPORT_FORMAT_LIST = { | |||
| 167 | const std::vector<std::vector<ge::Format>> EXTENDCONV2D_SUPPORT_FORMAT_LIST_MDC = { | 171 | const std::vector<std::vector<ge::Format>> EXTENDCONV2D_SUPPORT_FORMAT_LIST_MDC = { |
| 168 | {ge::Format::FORMAT_NCHW, ge::Format::FORMAT_NCHW, ge::Format::FORMAT_NCHW}, | 172 | {ge::Format::FORMAT_NCHW, ge::Format::FORMAT_NCHW, ge::Format::FORMAT_NCHW}, |
| 169 | {ge::Format::FORMAT_NCHW, ge::Format::FORMAT_HWCN, ge::Format::FORMAT_NCHW}, | 173 | {ge::Format::FORMAT_NCHW, ge::Format::FORMAT_HWCN, ge::Format::FORMAT_NCHW}, |
| 170 | - {ge::Format::FORMAT_NHWC, ge::Format::FORMAT_HWCN, ge::Format::FORMAT_NHWC} | 174 | + {ge::Format::FORMAT_NHWC, ge::Format::FORMAT_HWCN, ge::Format::FORMAT_NHWC}, |
| 175 | + {ge::Format::FORMAT_NCHW, ge::Format::FORMAT_NCHW, ge::Format::FORMAT_NHWC}, | ||
| 176 | + {ge::Format::FORMAT_NCHW, ge::Format::FORMAT_HWCN, ge::Format::FORMAT_NHWC}, | ||
| 177 | + {ge::Format::FORMAT_NHWC, ge::Format::FORMAT_NCHW, ge::Format::FORMAT_NCHW}, | ||
| 178 | + {ge::Format::FORMAT_NHWC, ge::Format::FORMAT_HWCN, ge::Format::FORMAT_NCHW} | ||
| 171 | }; | 179 | }; |
| 172 | 180 | ||
| 173 | struct ConvParamInfo { | 181 | struct ConvParamInfo { |
| @@ -134,6 +134,7 @@ struct Conv2dCacheTilingData { | |||
| 134 | uint32_t singleCoreCi = 0; | 134 | uint32_t singleCoreCi = 0; |
| 135 | uint32_t singleCoreCo = 0; | 135 | uint32_t singleCoreCo = 0; |
| 136 | uint64_t orgHixWi = 0; | 136 | uint64_t orgHixWi = 0; |
| 137 | + uint64_t unionDataXt = 0; | ||
| 137 | uint32_t hoL1 = 0; | 138 | uint32_t hoL1 = 0; |
| 138 | uint32_t woL1 = 0; | 139 | uint32_t woL1 = 0; |
| 139 | uint32_t kAL1 = 0; | 140 | uint32_t kAL1 = 0; |
| @@ -207,6 +208,7 @@ struct Conv3dCacheTilingData { | |||
| 207 | uint64_t oriWixk0 = 0; | 208 | uint64_t oriWixk0 = 0; |
| 208 | uint64_t orgHixWi = 0; | 209 | uint64_t orgHixWi = 0; |
| 209 | uint64_t orgHoxWo = 0; | 210 | uint64_t orgHoxWo = 0; |
| 211 | + uint64_t unionDataXt = 0; | ||
| 210 | 212 | ||
| 211 | // uint32_t fields | 213 | // uint32_t fields |
| 212 | uint32_t orgCi = 0; | 214 | uint32_t orgCi = 0; |
| @@ -222,8 +222,13 @@ constexpr uint64_t CONV_INNER_BATCH_SINGLE = 0; | |||
| 222 | constexpr uint64_t CONV_INNER_BATCH_KERNEL_1X1_MULTI = 1; | 222 | constexpr uint64_t CONV_INNER_BATCH_KERNEL_1X1_MULTI = 1; |
| 223 | constexpr uint64_t CONV_INNER_BATCH_MULTI = 2; | 223 | constexpr uint64_t CONV_INNER_BATCH_MULTI = 2; |
| 224 | 224 | ||
| 225 | +constexpr uint64_t CONV_NOT_SMALL_WEIGHT = 0; | ||
| 226 | +constexpr uint64_t CONV_FULLLOAD_KL1_NL0 = 1; | ||
| 227 | +constexpr uint64_t CONV_WEIGHT_SMALLER_THAN_BL0 = 2; | ||
| 228 | + | ||
| 225 | constexpr uint32_t FP16_DTYPE_SIZE = 2; | 229 | constexpr uint32_t FP16_DTYPE_SIZE = 2; |
| 226 | constexpr uint32_t INT64_DTYPE_SIZE_COMPARE_FP16 = 4; | 230 | constexpr uint32_t INT64_DTYPE_SIZE_COMPARE_FP16 = 4; |
| 231 | +constexpr uint32_t FLOAT_DTYPE_SIZE_COMPARE_FP16 = 2; | ||
| 227 | 232 | ||
| 228 | // idxList | 233 | // idxList |
| 229 | constexpr size_t IDX_LIST_N_IDX = 0; | 234 | constexpr size_t IDX_LIST_N_IDX = 0; |
| @@ -425,6 +430,9 @@ struct ConvTilingKeyPara { | |||
| 425 | uint64_t fmapCppyMode = 0; | 430 | uint64_t fmapCppyMode = 0; |
| 426 | uint64_t innerBatch = 0; | 431 | uint64_t innerBatch = 0; |
| 427 | uint64_t disContinuous = 0; | 432 | uint64_t disContinuous = 0; |
| 433 | + uint64_t batchOne = 0; | ||
| 434 | + uint64_t noPad = 0; | ||
| 435 | + uint64_t smallWeight = 0; | ||
| 428 | }; | 436 | }; |
| 429 | 437 | ||
| 430 | static std::map<ge::DataType, uint32_t> dtypeSizeTab = { | 438 | static std::map<ge::DataType, uint32_t> dtypeSizeTab = { |
| @@ -53,10 +53,10 @@ struct ExtendParams { | |||
| 53 | GM_ADDR y1 = nullptr; | 53 | GM_ADDR y1 = nullptr; |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | -template <class CONV, class RUN_INFO> | 56 | +template <class CONV, class CONV_TILING> |
| 57 | class ConvCommon { | 57 | class ConvCommon { |
| 58 | public: | 58 | public: |
| 59 | - __aicore__ __forceinline__ void Init(CONV *convPtr, const RUN_INFO* tilingPtr, bool hasScaleFlag); | 59 | + __aicore__ __forceinline__ void Init(CONV *convPtr, const CONV_TILING* tilingPtr, bool hasScaleFlag); |
| 60 | 60 | ||
| 61 | // Calc singleCore dim data | 61 | // Calc singleCore dim data |
| 62 | __aicore__ __forceinline__ bool CalcDimData(const uint32_t& blockPerDim, const uint32_t& dim, | 62 | __aicore__ __forceinline__ bool CalcDimData(const uint32_t& blockPerDim, const uint32_t& dim, |
| @@ -100,21 +100,22 @@ public: | |||
| 100 | 100 | ||
| 101 | protected: | 101 | protected: |
| 102 | CONV *convOps; | 102 | CONV *convOps; |
| 103 | - const RUN_INFO *convRunInfo; | 103 | + const CONV_TILING *convTilingData; |
| 104 | bool hasScale = true; | 104 | bool hasScale = true; |
| 105 | uint64_t fmStartAddr = 0; | 105 | uint64_t fmStartAddr = 0; |
| 106 | uint64_t weightStartAddr = 0; | 106 | uint64_t weightStartAddr = 0; |
| 107 | uint64_t biasStartAddr = 0; | 107 | uint64_t biasStartAddr = 0; |
| 108 | uint64_t scaleStartAddr = 0; | 108 | uint64_t scaleStartAddr = 0; |
| 109 | + uint64_t reluWeightStartAddr = 0; | ||
| 109 | uint64_t outputStartAddr = 0; | 110 | uint64_t outputStartAddr = 0; |
| 110 | 111 | ||
| 111 | uint64_t hwIn = 0; | 112 | uint64_t hwIn = 0; |
| 112 | uint64_t hwOut = 0; | 113 | uint64_t hwOut = 0; |
| 113 | }; | 114 | }; |
| 114 | 115 | ||
| 115 | -template <class CONV, class RUN_INFO> | 116 | +template <class CONV, class CONV_TILING> |
| 116 | -__aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | 117 | +__aicore__ __forceinline__ void ConvCommon<CONV, CONV_TILING>:: |
| 117 | - Init(CONV *convPtr, const RUN_INFO* tilingPtr, bool hasScaleFlag) | 118 | + Init(CONV *convPtr, const CONV_TILING* tilingPtr, bool hasScaleFlag) |
| 118 | { | 119 | { |
| 119 | if ASCEND_IS_AIV { | 120 | if ASCEND_IS_AIV { |
| 120 | blockIdx = GetBlockIdx(); | 121 | blockIdx = GetBlockIdx(); |
| @@ -124,12 +125,12 @@ __aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | |||
| 124 | blockIdx = GetBlockIdx(); | 125 | blockIdx = GetBlockIdx(); |
| 125 | } | 126 | } |
| 126 | convOps = convPtr; | 127 | convOps = convPtr; |
| 127 | - convRunInfo = tilingPtr; | 128 | + convTilingData = tilingPtr; |
| 128 | hasScale = hasScaleFlag; | 129 | hasScale = hasScaleFlag; |
| 129 | } | 130 | } |
| 130 | 131 | ||
| 131 | -template <class CONV, class RUN_INFO> | 132 | +template <class CONV, class CONV_TILING> |
| 132 | -__aicore__ __forceinline__ bool ConvCommon<CONV, RUN_INFO>:: | 133 | +__aicore__ __forceinline__ bool ConvCommon<CONV, CONV_TILING>:: |
| 133 | CalcDimData(const uint32_t& blockPerDim, const uint32_t& dim, const uint64_t& wholeDim, | 134 | CalcDimData(const uint32_t& blockPerDim, const uint32_t& dim, const uint64_t& wholeDim, |
| 134 | const uint64_t &realWholeDim, DimDataToFill& curStruct) | 135 | const uint64_t &realWholeDim, DimDataToFill& curStruct) |
| 135 | { | 136 | { |
| @@ -147,8 +148,8 @@ __aicore__ __forceinline__ bool ConvCommon<CONV, RUN_INFO>:: | |||
| 147 | return true; | 148 | return true; |
| 148 | } | 149 | } |
| 149 | 150 | ||
| 150 | -template <class CONV, class RUN_INFO> | 151 | +template <class CONV, class CONV_TILING> |
| 151 | -__aicore__ __forceinline__ bool ConvCommon<CONV, RUN_INFO>::CalcNDimDataAlign(const uint64_t& blockPerDim, | 152 | +__aicore__ __forceinline__ bool ConvCommon<CONV, CONV_TILING>::CalcNDimDataAlign(const uint64_t& blockPerDim, |
| 152 | const uint64_t& dim, | 153 | const uint64_t& dim, |
| 153 | const uint64_t& wholeDim, | 154 | const uint64_t& wholeDim, |
| 154 | DimDataToFill& curStruct) | 155 | DimDataToFill& curStruct) |
| @@ -167,17 +168,17 @@ __aicore__ __forceinline__ bool ConvCommon<CONV, RUN_INFO>::CalcNDimDataAlign(co | |||
| 167 | return true; | 168 | return true; |
| 168 | } | 169 | } |
| 169 | 170 | ||
| 170 | -template <class CONV, class RUN_INFO> | 171 | +template <class CONV, class CONV_TILING> |
| 171 | -__aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | 172 | +__aicore__ __forceinline__ void ConvCommon<CONV, CONV_TILING>:: |
| 172 | CalcStartAddrCommon(const uint32_t din, const uint32_t dout) | 173 | CalcStartAddrCommon(const uint32_t din, const uint32_t dout) |
| 173 | { | 174 | { |
| 174 | - hwIn = convRunInfo->hin * convRunInfo->win; | 175 | + hwIn = convTilingData->convRunInfo.hin * convTilingData->convRunInfo.win; |
| 175 | - hwOut = convRunInfo->hout * convRunInfo->wout; | 176 | + hwOut = convTilingData->convRunInfo.hout * convTilingData->convRunInfo.wout; |
| 176 | 177 | ||
| 177 | - convOps->fmapOneBatchSize = convRunInfo->cin * din * hwIn; | 178 | + convOps->fmapOneBatchSize = convTilingData->convRunInfo.cin * din * hwIn; |
| 178 | - convOps->outputOneBatchSize = convRunInfo->cout * dout * hwOut; | 179 | + convOps->outputOneBatchSize = convTilingData->convRunInfo.cout * dout * hwOut; |
| 179 | 180 | ||
| 180 | - if (convRunInfo->hasBias) { | 181 | + if (convTilingData->convRunInfo.hasBias) { |
| 181 | biasStartAddr = convOps->nIdxStart; | 182 | biasStartAddr = convOps->nIdxStart; |
| 182 | } | 183 | } |
| 183 | 184 | ||
| @@ -188,22 +189,22 @@ __aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | |||
| 188 | } | 189 | } |
| 189 | } | 190 | } |
| 190 | 191 | ||
| 191 | -template <class CONV, class RUN_INFO> | 192 | +template <class CONV, class CONV_TILING> |
| 192 | -__aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | 193 | +__aicore__ __forceinline__ void ConvCommon<CONV, CONV_TILING>:: |
| 193 | CalcStartAddrMMode(const uint32_t din, const uint32_t dout, const uint32_t kd, const uint64_t doIdxStart, | 194 | CalcStartAddrMMode(const uint32_t din, const uint32_t dout, const uint32_t kd, const uint64_t doIdxStart, |
| 194 | const int64_t diIdxStart) | 195 | const int64_t diIdxStart) |
| 195 | { | 196 | { |
| 196 | CalcStartAddrCommon(din, dout); | 197 | CalcStartAddrCommon(din, dout); |
| 197 | 198 | ||
| 198 | if constexpr (CONV::DIS_CONTINUOUS) { | 199 | if constexpr (CONV::DIS_CONTINUOUS) { |
| 199 | - fmStartAddr = convOps->batchIdxStart * convRunInfo->cin; | 200 | + fmStartAddr = convOps->batchIdxStart * convTilingData->convRunInfo.cin; |
| 200 | } else { | 201 | } else { |
| 201 | fmStartAddr = convOps->batchIdxStart * convOps->fmapOneBatchSize; | 202 | fmStartAddr = convOps->batchIdxStart * convOps->fmapOneBatchSize; |
| 202 | } | 203 | } |
| 203 | if constexpr (CONV::B_FORMAT == ConvFormat::FRACTAL_Z || CONV::B_FORMAT == ConvFormat::FRACTAL_Z_C04) { | 204 | if constexpr (CONV::B_FORMAT == ConvFormat::FRACTAL_Z || CONV::B_FORMAT == ConvFormat::FRACTAL_Z_C04) { |
| 204 | weightStartAddr = convOps->nIdxStart * convOps->k0; | 205 | weightStartAddr = convOps->nIdxStart * convOps->k0; |
| 205 | } else { | 206 | } else { |
| 206 | - weightStartAddr = convOps->nIdxStart * convRunInfo->cin * kd * convRunInfo->kh * convRunInfo->kw; | 207 | + weightStartAddr = convOps->nIdxStart * convTilingData->convRunInfo.cin * kd * convTilingData->convRunInfo.kh * convTilingData->convRunInfo.kw; |
| 207 | } | 208 | } |
| 208 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + | 209 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + |
| 209 | convOps->nIdxStart * dout * hwOut + | 210 | convOps->nIdxStart * dout * hwOut + |
| @@ -215,37 +216,42 @@ __aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | |||
| 215 | } | 216 | } |
| 216 | 217 | ||
| 217 | if constexpr (CONV::IS_EXTEND_CONV2D) { | 218 | if constexpr (CONV::IS_EXTEND_CONV2D) { |
| 218 | - if (convOps->conv2dApiTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT) || | 219 | + if (convOps->convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT) || |
| 219 | - convOps->conv2dApiTiling->quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 220 | + convOps->convTilingData->convApiTiling.quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 220 | scaleStartAddr = convOps->nIdxStart; | 221 | scaleStartAddr = convOps->nIdxStart; |
| 221 | } | 222 | } |
| 223 | + if (convTilingData->convApiTiling.reluMode0 == static_cast<uint8_t>(ReluMode::VECTOR_RELU) || | ||
| 224 | + convTilingData->convApiTiling.reluMode1 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { | ||
| 225 | + reluWeightStartAddr = convOps->nIdxStart; | ||
| 226 | + } | ||
| 222 | } | 227 | } |
| 223 | } | 228 | } |
| 224 | 229 | ||
| 225 | -template <class CONV, class RUN_INFO> | 230 | +template <class CONV, class CONV_TILING> |
| 226 | -__aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | 231 | +__aicore__ __forceinline__ void ConvCommon<CONV, CONV_TILING>:: |
| 227 | CalcStartAddrHWode(const uint32_t din, const uint32_t dout, const uint32_t kd, const uint64_t doIdxStart, | 232 | CalcStartAddrHWode(const uint32_t din, const uint32_t dout, const uint32_t kd, const uint64_t doIdxStart, |
| 228 | const int64_t diIdxStart) | 233 | const int64_t diIdxStart) |
| 229 | { | 234 | { |
| 230 | CalcStartAddrCommon(din, dout); | 235 | CalcStartAddrCommon(din, dout); |
| 231 | 236 | ||
| 232 | - int64_t hiStartPosTmp = static_cast<int64_t>(convOps->hoIdxStart * convRunInfo->strideH) - | 237 | + int64_t hiStartPosTmp = static_cast<int64_t>(convOps->hoIdxStart * convTilingData->convRunInfo.strideH) - |
| 233 | - static_cast<int64_t>(convRunInfo->padTop); | 238 | + static_cast<int64_t>(convTilingData->convRunInfo.padTop); |
| 234 | convOps->singleCoreHiStartPos = hiStartPosTmp < 0 ? 0 : hiStartPosTmp; | 239 | convOps->singleCoreHiStartPos = hiStartPosTmp < 0 ? 0 : hiStartPosTmp; |
| 235 | if constexpr (CONV::DIS_CONTINUOUS) { | 240 | if constexpr (CONV::DIS_CONTINUOUS) { |
| 236 | - fmStartAddr = convOps->singleCoreHiStartPos * convRunInfo->win * convRunInfo->batch * convRunInfo->cin + | 241 | + fmStartAddr = convOps->singleCoreHiStartPos * convTilingData->convRunInfo.win * |
| 237 | - convOps->batchIdxStart * convRunInfo->cin; | 242 | + convTilingData->convRunInfo.batch * convTilingData->convRunInfo.cin + |
| 243 | + convOps->batchIdxStart * convTilingData->convRunInfo.cin; | ||
| 238 | } else { | 244 | } else { |
| 239 | fmStartAddr = convOps->batchIdxStart * convOps->fmapOneBatchSize + convOps->singleCoreHiStartPos * | 245 | fmStartAddr = convOps->batchIdxStart * convOps->fmapOneBatchSize + convOps->singleCoreHiStartPos * |
| 240 | - convRunInfo->win; | 246 | + convTilingData->convRunInfo.win; |
| 241 | } | 247 | } |
| 242 | convOps->singleCoreHiStartPos = hiStartPosTmp; | 248 | convOps->singleCoreHiStartPos = hiStartPosTmp; |
| 243 | if constexpr (CONV::A_FORMAT == ConvFormat::NCHW) { | 249 | if constexpr (CONV::A_FORMAT == ConvFormat::NCHW) { |
| 244 | - int64_t wiStartPosTmp = static_cast<int64_t>(convOps->woIdxStart * convRunInfo->strideW) - | 250 | + int64_t wiStartPosTmp = static_cast<int64_t>(convOps->woIdxStart * convTilingData->convRunInfo.strideW) - |
| 245 | - static_cast<int64_t>(convRunInfo->padLeft); | 251 | + static_cast<int64_t>(convTilingData->convRunInfo.padLeft); |
| 246 | convOps->singleCoreWiStartPos = wiStartPosTmp < 0 ? 0 : wiStartPosTmp; | 252 | convOps->singleCoreWiStartPos = wiStartPosTmp < 0 ? 0 : wiStartPosTmp; |
| 247 | if constexpr (CONV::DIS_CONTINUOUS) { | 253 | if constexpr (CONV::DIS_CONTINUOUS) { |
| 248 | - fmStartAddr += convOps->singleCoreWiStartPos * convRunInfo->batch * convRunInfo->cin; | 254 | + fmStartAddr += convOps->singleCoreWiStartPos * convTilingData->convRunInfo.batch * convTilingData->convRunInfo.cin; |
| 249 | } else { | 255 | } else { |
| 250 | fmStartAddr += convOps->singleCoreWiStartPos; | 256 | fmStartAddr += convOps->singleCoreWiStartPos; |
| 251 | } | 257 | } |
| @@ -255,12 +261,12 @@ __aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | |||
| 255 | if constexpr (CONV::B_FORMAT == ConvFormat::FRACTAL_Z || CONV::B_FORMAT == ConvFormat::FRACTAL_Z_C04) { | 261 | if constexpr (CONV::B_FORMAT == ConvFormat::FRACTAL_Z || CONV::B_FORMAT == ConvFormat::FRACTAL_Z_C04) { |
| 256 | weightStartAddr = convOps->nIdxStart * convOps->k0; | 262 | weightStartAddr = convOps->nIdxStart * convOps->k0; |
| 257 | } else { | 263 | } else { |
| 258 | - weightStartAddr = convOps->nIdxStart * convRunInfo->cin * kd * convRunInfo->kh * convRunInfo->kw; | 264 | + weightStartAddr = convOps->nIdxStart * convTilingData->convRunInfo.cin * kd * convTilingData->convRunInfo.kh * convTilingData->convRunInfo.kw; |
| 259 | } | 265 | } |
| 260 | 266 | ||
| 261 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + | 267 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + |
| 262 | convOps->nIdxStart * dout * hwOut + | 268 | convOps->nIdxStart * dout * hwOut + |
| 263 | - convOps->hoIdxStart * convRunInfo->wout; | 269 | + convOps->hoIdxStart * convTilingData->convRunInfo.wout; |
| 264 | if constexpr (CONV::A_FORMAT == ConvFormat::NCHW) { | 270 | if constexpr (CONV::A_FORMAT == ConvFormat::NCHW) { |
| 265 | outputStartAddr += convOps->woIdxStart; | 271 | outputStartAddr += convOps->woIdxStart; |
| 266 | } | 272 | } |
| @@ -271,8 +277,8 @@ __aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | |||
| 271 | } | 277 | } |
| 272 | } | 278 | } |
| 273 | 279 | ||
| 274 | -template <class CONV, class RUN_INFO> | 280 | +template <class CONV, class CONV_TILING> |
| 275 | -__aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | 281 | +__aicore__ __forceinline__ void ConvCommon<CONV, CONV_TILING>:: |
| 276 | CalcStartAddrMModeHWC(const uint32_t din, const uint32_t dout, const uint64_t doIdxStart, const int64_t diIdxStart) | 282 | CalcStartAddrMModeHWC(const uint32_t din, const uint32_t dout, const uint64_t doIdxStart, const int64_t diIdxStart) |
| 277 | { | 283 | { |
| 278 | CalcStartAddrCommon(din, dout); | 284 | CalcStartAddrCommon(din, dout); |
| @@ -280,50 +286,50 @@ __aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | |||
| 280 | fmStartAddr = convOps->batchIdxStart * convOps->fmapOneBatchSize; | 286 | fmStartAddr = convOps->batchIdxStart * convOps->fmapOneBatchSize; |
| 281 | weightStartAddr = convOps->nIdxStart; | 287 | weightStartAddr = convOps->nIdxStart; |
| 282 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + | 288 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + |
| 283 | - convOps->mIdxStart * convRunInfo->cout + | 289 | + convOps->mIdxStart * convTilingData->convRunInfo.cout + |
| 284 | convOps->nIdxStart; | 290 | convOps->nIdxStart; |
| 285 | 291 | ||
| 286 | if constexpr (CONV::A_FORMAT == ConvFormat::NDHWC) { | 292 | if constexpr (CONV::A_FORMAT == ConvFormat::NDHWC) { |
| 287 | - fmStartAddr += diIdxStart * hwIn * convRunInfo->cin; | 293 | + fmStartAddr += diIdxStart * hwIn * convTilingData->convRunInfo.cin; |
| 288 | - outputStartAddr += doIdxStart * hwOut * convRunInfo->cout; | 294 | + outputStartAddr += doIdxStart * hwOut * convTilingData->convRunInfo.cout; |
| 289 | } | 295 | } |
| 290 | } | 296 | } |
| 291 | 297 | ||
| 292 | -template <class CONV, class RUN_INFO> | 298 | +template <class CONV, class CONV_TILING> |
| 293 | -__aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | 299 | +__aicore__ __forceinline__ void ConvCommon<CONV, CONV_TILING>:: |
| 294 | CalcStartAddrHWodeHWC(const uint32_t din, const uint32_t dout, const uint64_t doIdxStart, const int64_t diIdxStart) | 300 | CalcStartAddrHWodeHWC(const uint32_t din, const uint32_t dout, const uint64_t doIdxStart, const int64_t diIdxStart) |
| 295 | { | 301 | { |
| 296 | CalcStartAddrCommon(din, dout); | 302 | CalcStartAddrCommon(din, dout); |
| 297 | 303 | ||
| 298 | - int64_t hiStartPosTmp = static_cast<int64_t>(convOps->hoIdxStart * convRunInfo->strideH) - | 304 | + int64_t hiStartPosTmp = static_cast<int64_t>(convOps->hoIdxStart * convTilingData->convRunInfo.strideH) - |
| 299 | - static_cast<int64_t>(convRunInfo->padTop); | 305 | + static_cast<int64_t>(convTilingData->convRunInfo.padTop); |
| 300 | convOps->singleCoreHiStartPos = hiStartPosTmp < 0 ? 0 : hiStartPosTmp; | 306 | convOps->singleCoreHiStartPos = hiStartPosTmp < 0 ? 0 : hiStartPosTmp; |
| 301 | fmStartAddr = convOps->batchIdxStart * convOps->fmapOneBatchSize + convOps->singleCoreHiStartPos * | 307 | fmStartAddr = convOps->batchIdxStart * convOps->fmapOneBatchSize + convOps->singleCoreHiStartPos * |
| 302 | - convRunInfo->win * convRunInfo->cin; | 308 | + convTilingData->convRunInfo.win * convTilingData->convRunInfo.cin; |
| 303 | convOps->singleCoreHiStartPos = hiStartPosTmp; | 309 | convOps->singleCoreHiStartPos = hiStartPosTmp; |
| 304 | if constexpr (CONV::A_FORMAT == ConvFormat::NHWC) { | 310 | if constexpr (CONV::A_FORMAT == ConvFormat::NHWC) { |
| 305 | - int64_t wiStartPosTmp = static_cast<int64_t>(convOps->woIdxStart * convRunInfo->strideW) - | 311 | + int64_t wiStartPosTmp = static_cast<int64_t>(convOps->woIdxStart * convTilingData->convRunInfo.strideW) - |
| 306 | - static_cast<int64_t>(convRunInfo->padLeft); | 312 | + static_cast<int64_t>(convTilingData->convRunInfo.padLeft); |
| 307 | convOps->singleCoreWiStartPos = wiStartPosTmp; | 313 | convOps->singleCoreWiStartPos = wiStartPosTmp; |
| 308 | - fmStartAddr += Max(convOps->singleCoreWiStartPos, 0) * convRunInfo->cin; | 314 | + fmStartAddr += Max(convOps->singleCoreWiStartPos, 0) * convTilingData->convRunInfo.cin; |
| 309 | } | 315 | } |
| 310 | 316 | ||
| 311 | weightStartAddr = convOps->nIdxStart; | 317 | weightStartAddr = convOps->nIdxStart; |
| 312 | 318 | ||
| 313 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + convOps->hoIdxStart * | 319 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + convOps->hoIdxStart * |
| 314 | - convRunInfo->wout * convRunInfo->cout + convOps->nIdxStart; | 320 | + convTilingData->convRunInfo.wout * convTilingData->convRunInfo.cout + convOps->nIdxStart; |
| 315 | 321 | ||
| 316 | if constexpr (CONV::A_FORMAT == ConvFormat::NHWC) { | 322 | if constexpr (CONV::A_FORMAT == ConvFormat::NHWC) { |
| 317 | - outputStartAddr += convOps->woIdxStart * convRunInfo->cout; | 323 | + outputStartAddr += convOps->woIdxStart * convTilingData->convRunInfo.cout; |
| 318 | } | 324 | } |
| 319 | if constexpr (CONV::A_FORMAT == ConvFormat::NDHWC) { | 325 | if constexpr (CONV::A_FORMAT == ConvFormat::NDHWC) { |
| 320 | - fmStartAddr += diIdxStart * hwIn * convRunInfo->cin; | 326 | + fmStartAddr += diIdxStart * hwIn * convTilingData->convRunInfo.cin; |
| 321 | - outputStartAddr += doIdxStart * hwOut * convRunInfo->cout; | 327 | + outputStartAddr += doIdxStart * hwOut * convTilingData->convRunInfo.cout; |
| 322 | } | 328 | } |
| 323 | } | 329 | } |
| 324 | 330 | ||
| 325 | -template <class CONV, class RUN_INFO> | 331 | +template <class CONV, class CONV_TILING> |
| 326 | -__aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | 332 | +__aicore__ __forceinline__ void ConvCommon<CONV, CONV_TILING>:: |
| 327 | CalcStartAddrDeQuant(const uint32_t din, const uint32_t dout, const uint32_t kd, | 333 | CalcStartAddrDeQuant(const uint32_t din, const uint32_t dout, const uint32_t kd, |
| 328 | const uint64_t doIdxStart, const int64_t diIdxStart) | 334 | const uint64_t doIdxStart, const int64_t diIdxStart) |
| 329 | { | 335 | { |
| @@ -333,60 +339,65 @@ __aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | |||
| 333 | fmStartAddr = convOps->batchIdxStart * convOps->fmapOneBatchSize + diIdxStart * hwIn; | 339 | fmStartAddr = convOps->batchIdxStart * convOps->fmapOneBatchSize + diIdxStart * hwIn; |
| 334 | 340 | ||
| 335 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + | 341 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + |
| 336 | - convOps->mIdxStart * convRunInfo->cout + convOps->nIdxStart + | 342 | + convOps->mIdxStart * convTilingData->convRunInfo.cout + convOps->nIdxStart + |
| 337 | - doIdxStart * hwOut * convRunInfo->cout; | 343 | + doIdxStart * hwOut * convTilingData->convRunInfo.cout; |
| 338 | } else { | 344 | } else { |
| 339 | - int64_t hiStartPosTmp = static_cast<int64_t>(convOps->hoIdxStart * convRunInfo->strideH) - | 345 | + int64_t hiStartPosTmp = static_cast<int64_t>(convOps->hoIdxStart * convTilingData->convRunInfo.strideH) - |
| 340 | - static_cast<int64_t>(convRunInfo->padTop); | 346 | + static_cast<int64_t>(convTilingData->convRunInfo.padTop); |
| 341 | convOps->singleCoreHiStartPos = hiStartPosTmp < 0 ? 0 : hiStartPosTmp; | 347 | convOps->singleCoreHiStartPos = hiStartPosTmp < 0 ? 0 : hiStartPosTmp; |
| 342 | fmStartAddr = convOps->batchIdxStart * convOps->fmapOneBatchSize + convOps->singleCoreHiStartPos * | 348 | fmStartAddr = convOps->batchIdxStart * convOps->fmapOneBatchSize + convOps->singleCoreHiStartPos * |
| 343 | - convRunInfo->win + diIdxStart * hwIn; | 349 | + convTilingData->convRunInfo.win + diIdxStart * hwIn; |
| 344 | convOps->singleCoreHiStartPos = hiStartPosTmp; | 350 | convOps->singleCoreHiStartPos = hiStartPosTmp; |
| 345 | 351 | ||
| 346 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + convOps->hoIdxStart * | 352 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + convOps->hoIdxStart * |
| 347 | - convRunInfo->wout * convRunInfo->cout + convOps->nIdxStart + | 353 | + convTilingData->convRunInfo.wout * convTilingData->convRunInfo.cout + convOps->nIdxStart + |
| 348 | - doIdxStart * hwOut * convRunInfo->cout; | 354 | + doIdxStart * hwOut * convTilingData->convRunInfo.cout; |
| 349 | } | 355 | } |
| 350 | - weightStartAddr = convOps->nIdxStart * convRunInfo->cin * kd * convRunInfo->kh * convRunInfo->kw; | 356 | + weightStartAddr = convOps->nIdxStart * convTilingData->convRunInfo.cin * kd * convTilingData->convRunInfo.kh * convTilingData->convRunInfo.kw; |
| 351 | } | 357 | } |
| 352 | 358 | ||
| 353 | -template <class CONV, class RUN_INFO> | 359 | +template <class CONV, class CONV_TILING> |
| 354 | -__aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | 360 | +__aicore__ __forceinline__ void ConvCommon<CONV, CONV_TILING>:: |
| 355 | InitFixpipeBuffer(const ExtendParams* extendParams) | 361 | InitFixpipeBuffer(const ExtendParams* extendParams) |
| 356 | { | 362 | { |
| 357 | if constexpr (CONV::isQuant || CONV::IS_EXTEND_CONV2D) { | 363 | if constexpr (CONV::isQuant || CONV::IS_EXTEND_CONV2D) { |
| 358 | if (hasScale) { | 364 | if (hasScale) { |
| 359 | if constexpr (CONV::A_FORMAT == ConvFormat::NCHW || CONV::A_FORMAT == ConvFormat::NHWC) { | 365 | if constexpr (CONV::A_FORMAT == ConvFormat::NCHW || CONV::A_FORMAT == ConvFormat::NHWC) { |
| 360 | - if (convOps->conv2dApiTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 366 | + if (convOps->convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 361 | convOps->fixpipeParams.scale0.SetGlobalBuffer( | 367 | convOps->fixpipeParams.scale0.SetGlobalBuffer( |
| 362 | reinterpret_cast<__gm__ typename CONV::SCALE_T*>(extendParams->scale0 + scaleStartAddr * | 368 | reinterpret_cast<__gm__ typename CONV::SCALE_T*>(extendParams->scale0 + scaleStartAddr * |
| 363 | sizeof(typename CONV::SCALE_T))); | 369 | sizeof(typename CONV::SCALE_T))); |
| 364 | - } else if (convOps->conv2dApiTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::SCALAR_QUANT)) { | 370 | + } else if (convOps->convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::SCALAR_QUANT)) { |
| 365 | convOps->fixpipeParams.scale0.SetGlobalBuffer( | 371 | convOps->fixpipeParams.scale0.SetGlobalBuffer( |
| 366 | reinterpret_cast<__gm__ typename CONV::SCALE_T*>(extendParams->scale0)); | 372 | reinterpret_cast<__gm__ typename CONV::SCALE_T*>(extendParams->scale0)); |
| 367 | } | 373 | } |
| 368 | -#if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102) | ||
| 369 | - if (convOps->conv2dApiTiling->reluMode0 == static_cast<uint8_t>(ReluMode::SCALAR_RELU)) { | ||
| 370 | - convOps->fixpipeParams.reluWeight0.SetGlobalBuffer( | ||
| 371 | - reinterpret_cast<__gm__ typename CONV::RELU_WEIGHT_T*>(extendParams->reluWeight0)); | ||
| 372 | - } | ||
| 373 | -#endif | ||
| 374 | if constexpr (CONV::IS_EXTEND_CONV2D) { | 374 | if constexpr (CONV::IS_EXTEND_CONV2D) { |
| 375 | - if (convOps->dualOutput) { | 375 | + if (convTilingData->convApiTiling.reluMode0 == static_cast<uint8_t>(ReluMode::SCALAR_RELU)) { |
| 376 | - if (convOps->conv2dApiTiling->quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 376 | + convOps->fixpipeParams.reluWeight0.SetGlobalBuffer( |
| 377 | + reinterpret_cast<__gm__ typename CONV::RELU_WEIGHT_T*>(extendParams->reluWeight0)); | ||
| 378 | + } else if (convTilingData->convApiTiling.reluMode0 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { | ||
| 379 | + // copy relu_weight from om to gm | ||
| 380 | + convOps->fixpipeParams.reluWeight0.SetGlobalBuffer( | ||
| 381 | + reinterpret_cast<__gm__ typename CONV::RELU_WEIGHT_T*>(extendParams->reluWeight0 + | ||
| 382 | + reluWeightStartAddr * sizeof(typename CONV::RELU_WEIGHT_T))); | ||
| 383 | + } | ||
| 384 | + if (convTilingData->convApiTiling.dualOutput) { | ||
| 385 | + if (convTilingData->convApiTiling.quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | ||
| 377 | convOps->fixpipeParams.scale1.SetGlobalBuffer( | 386 | convOps->fixpipeParams.scale1.SetGlobalBuffer( |
| 378 | reinterpret_cast<__gm__ typename CONV::SCALE_T*>(extendParams->scale1 + scaleStartAddr * | 387 | reinterpret_cast<__gm__ typename CONV::SCALE_T*>(extendParams->scale1 + scaleStartAddr * |
| 379 | sizeof(typename CONV::SCALE_T))); | 388 | sizeof(typename CONV::SCALE_T))); |
| 380 | - } else if (convOps->conv2dApiTiling->quantMode1 == static_cast<uint8_t>(QuantModeType::SCALAR_QUANT)) { | 389 | + } else if (convOps->convTilingData->convApiTiling.quantMode1 == static_cast<uint8_t>(QuantModeType::SCALAR_QUANT)) { |
| 381 | convOps->fixpipeParams.scale1.SetGlobalBuffer( | 390 | convOps->fixpipeParams.scale1.SetGlobalBuffer( |
| 382 | reinterpret_cast<__gm__ typename CONV::SCALE_T*>(extendParams->scale1)); | 391 | reinterpret_cast<__gm__ typename CONV::SCALE_T*>(extendParams->scale1)); |
| 383 | } | 392 | } |
| 384 | -#if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102) | 393 | + if (convTilingData->convApiTiling.reluMode1 == static_cast<uint8_t>(ReluMode::SCALAR_RELU)) { |
| 385 | - if (convOps->conv2dApiTiling->reluMode1 == static_cast<uint8_t>(ReluMode::SCALAR_RELU)) { | ||
| 386 | convOps->fixpipeParams.reluWeight1.SetGlobalBuffer( | 394 | convOps->fixpipeParams.reluWeight1.SetGlobalBuffer( |
| 387 | reinterpret_cast<__gm__ typename CONV::RELU_WEIGHT_T*>(extendParams->reluWeight1)); | 395 | reinterpret_cast<__gm__ typename CONV::RELU_WEIGHT_T*>(extendParams->reluWeight1)); |
| 396 | + } else if (convTilingData->convApiTiling.reluMode1 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { | ||
| 397 | + convOps->fixpipeParams.reluWeight1.SetGlobalBuffer( | ||
| 398 | + reinterpret_cast<__gm__ typename CONV::RELU_WEIGHT_T*>(extendParams->reluWeight1 + | ||
| 399 | + reluWeightStartAddr * sizeof(typename CONV::RELU_WEIGHT_T))); | ||
| 388 | } | 400 | } |
| 389 | -#endif | ||
| 390 | } | 401 | } |
| 391 | } | 402 | } |
| 392 | } else { | 403 | } else { |
| @@ -398,8 +409,8 @@ __aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | |||
| 398 | } | 409 | } |
| 399 | } | 410 | } |
| 400 | 411 | ||
| 401 | -template <class CONV, class RUN_INFO> | 412 | +template <class CONV, class CONV_TILING> |
| 402 | -__aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | 413 | +__aicore__ __forceinline__ void ConvCommon<CONV, CONV_TILING>:: |
| 403 | InitBufferCommon(GM_ADDR x, GM_ADDR filter, GM_ADDR bias, GM_ADDR y, const ExtendParams* extendParams) | 414 | InitBufferCommon(GM_ADDR x, GM_ADDR filter, GM_ADDR bias, GM_ADDR y, const ExtendParams* extendParams) |
| 404 | { | 415 | { |
| 405 | convOps->fmapGm.SetGlobalBuffer( | 416 | convOps->fmapGm.SetGlobalBuffer( |
| @@ -409,13 +420,13 @@ __aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | |||
| 409 | convOps->outputGm.SetGlobalBuffer( | 420 | convOps->outputGm.SetGlobalBuffer( |
| 410 | reinterpret_cast<__gm__ typename CONV::OUTPUT_T*>(y + outputStartAddr * sizeof(typename CONV::OUTPUT_T))); | 421 | reinterpret_cast<__gm__ typename CONV::OUTPUT_T*>(y + outputStartAddr * sizeof(typename CONV::OUTPUT_T))); |
| 411 | if constexpr (CONV::IS_EXTEND_CONV2D) { | 422 | if constexpr (CONV::IS_EXTEND_CONV2D) { |
| 412 | - if (convOps->dualOutput) { | 423 | + if (convTilingData->convApiTiling.dualOutput) { |
| 413 | convOps->output1Gm.SetGlobalBuffer( | 424 | convOps->output1Gm.SetGlobalBuffer( |
| 414 | reinterpret_cast<__gm__ typename CONV::OUTPUT1_T*>( | 425 | reinterpret_cast<__gm__ typename CONV::OUTPUT1_T*>( |
| 415 | extendParams->y1 + outputStartAddr * sizeof(typename CONV::OUTPUT1_T))); | 426 | extendParams->y1 + outputStartAddr * sizeof(typename CONV::OUTPUT1_T))); |
| 416 | } | 427 | } |
| 417 | } | 428 | } |
| 418 | - if (convRunInfo->hasBias) { | 429 | + if (convTilingData->convRunInfo.hasBias) { |
| 419 | convOps->biasGm.SetGlobalBuffer( | 430 | convOps->biasGm.SetGlobalBuffer( |
| 420 | reinterpret_cast<__gm__ typename CONV::BIAS_T*>(bias + biasStartAddr * sizeof(typename CONV::BIAS_T))); | 431 | reinterpret_cast<__gm__ typename CONV::BIAS_T*>(bias + biasStartAddr * sizeof(typename CONV::BIAS_T))); |
| 421 | } | 432 | } |
| @@ -423,22 +434,22 @@ __aicore__ __forceinline__ void ConvCommon<CONV, RUN_INFO>:: | |||
| 423 | InitFixpipeBuffer(extendParams); | 434 | InitFixpipeBuffer(extendParams); |
| 424 | } | 435 | } |
| 425 | 436 | ||
| 426 | -template <class CONV, class RUN_INFO> | 437 | +template <class CONV, class CONV_TILING> |
| 427 | -__aicore__ __forceinline__ uint64_t ConvCommon<CONV, RUN_INFO>:: | 438 | +__aicore__ __forceinline__ uint64_t ConvCommon<CONV, CONV_TILING>:: |
| 428 | AlignB(const uint64_t numA, const uint64_t numB) | 439 | AlignB(const uint64_t numA, const uint64_t numB) |
| 429 | { | 440 | { |
| 430 | return ((numA + numB - 1) / numB) * numB; | 441 | return ((numA + numB - 1) / numB) * numB; |
| 431 | } | 442 | } |
| 432 | 443 | ||
| 433 | -template <class CONV, class RUN_INFO> | 444 | +template <class CONV, class CONV_TILING> |
| 434 | -__aicore__ __forceinline__ uint64_t ConvCommon<CONV, RUN_INFO>:: | 445 | +__aicore__ __forceinline__ uint64_t ConvCommon<CONV, CONV_TILING>:: |
| 435 | CeilDiv(const uint64_t numA, const uint64_t numB) | 446 | CeilDiv(const uint64_t numA, const uint64_t numB) |
| 436 | { | 447 | { |
| 437 | return (numA + numB - 1) / numB; | 448 | return (numA + numB - 1) / numB; |
| 438 | } | 449 | } |
| 439 | 450 | ||
| 440 | -template <class CONV, class RUN_INFO> | 451 | +template <class CONV, class CONV_TILING> |
| 441 | -__aicore__ __forceinline__ int64_t ConvCommon<CONV, RUN_INFO>:: | 452 | +__aicore__ __forceinline__ int64_t ConvCommon<CONV, CONV_TILING>:: |
| 442 | Max(const int64_t numA, const int64_t numB) | 453 | Max(const int64_t numA, const int64_t numB) |
| 443 | { | 454 | { |
| 444 | return numA > numB ? numA : numB; | 455 | return numA > numB ? numA : numB; |
| @@ -104,45 +104,52 @@ struct SetFixpipeParams { | |||
| 104 | static __aicore__ inline void call(Intf *self, const Extendconv2dFixpipeParams<typename Intf::ScaleT, typename Intf::ReluWeightT, typename Intf::ClipValue0T, typename Intf::ClipValue1T>& fixpipeParams) | 104 | static __aicore__ inline void call(Intf *self, const Extendconv2dFixpipeParams<typename Intf::ScaleT, typename Intf::ReluWeightT, typename Intf::ClipValue0T, typename Intf::ClipValue1T>& fixpipeParams) |
| 105 | { | 105 | { |
| 106 | if ASCEND_IS_AIC_CONV { | 106 | if ASCEND_IS_AIC_CONV { |
| 107 | - if (self->ctx.convTiling->quantMode0 != static_cast<uint8_t>(QuantModeType::NO_QUANT)) { | 107 | + if (self->ctx.convTilingData->convApiTiling.quantMode0 != static_cast<uint8_t>(QuantModeType::NO_QUANT)) { |
| 108 | self->ctx.scalegm.SetGlobalBuffer(fixpipeParams.scale0.GetPhyAddr(0), fixpipeParams.scale0.GetSize()); | 108 | self->ctx.scalegm.SetGlobalBuffer(fixpipeParams.scale0.GetPhyAddr(0), fixpipeParams.scale0.GetSize()); |
| 109 | - if (self->ctx.convTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::SCALAR_QUANT)) { | 109 | + if (self->ctx.convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::SCALAR_QUANT)) { |
| 110 | self->ctx.deqScalar0 = fixpipeParams.scale0.GetValue(0); | 110 | self->ctx.deqScalar0 = fixpipeParams.scale0.GetValue(0); |
| 111 | } | 111 | } |
| 112 | } | 112 | } |
| 113 | -#if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102) | 113 | + if (self->ctx.convTilingData->convApiTiling.reluMode0 == static_cast<uint8_t>(ReluMode::SCALAR_RELU)) { |
| 114 | - if (self->ctx.convTiling->reluMode0 == static_cast<uint8_t>(ReluMode::SCALAR_RELU)) { | ||
| 115 | float m2 = fixpipeParams.reluWeight0.GetValue(0); | 114 | float m2 = fixpipeParams.reluWeight0.GetValue(0); |
| 116 | self->ctx.preReluScalar0 = reinterpret_cast<uint64_t&>(m2); | 115 | self->ctx.preReluScalar0 = reinterpret_cast<uint64_t&>(m2); |
| 116 | + } else if (self->ctx.convTilingData->convApiTiling.reluMode0 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { | ||
| 117 | + // copy from fixpipe paramIn to global tensor | ||
| 118 | + self->ctx.reluWeightGM.SetGlobalBuffer(fixpipeParams.reluWeight0.GetPhyAddr(0), | ||
| 119 | + fixpipeParams.reluWeight0.GetSize()); | ||
| 117 | } | 120 | } |
| 118 | -#endif | ||
| 119 | if constexpr (Intf::isExtendConv2d) { | 121 | if constexpr (Intf::isExtendConv2d) { |
| 120 | - if (self->ctx.convTiling->dualOutput && | 122 | + if (self->ctx.convTilingData->convApiTiling.dualOutput && |
| 121 | - self->ctx.convTiling->quantMode1 != static_cast<uint8_t>(QuantModeType::NO_QUANT)) { | 123 | + self->ctx.convTilingData->convApiTiling.quantMode1 != static_cast<uint8_t>(QuantModeType::NO_QUANT)) { |
| 122 | self->ctx.scale1gm.SetGlobalBuffer(fixpipeParams.scale1.GetPhyAddr(0), fixpipeParams.scale1.GetSize()); | 124 | self->ctx.scale1gm.SetGlobalBuffer(fixpipeParams.scale1.GetPhyAddr(0), fixpipeParams.scale1.GetSize()); |
| 123 | - if (self->ctx.convTiling->quantMode1 == static_cast<uint8_t>(QuantModeType::SCALAR_QUANT)) { | 125 | + if (self->ctx.convTilingData->convApiTiling.quantMode1 == static_cast<uint8_t>(QuantModeType::SCALAR_QUANT)) { |
| 124 | self->ctx.deqScalar1 = fixpipeParams.scale1.GetValue(0); | 126 | self->ctx.deqScalar1 = fixpipeParams.scale1.GetValue(0); |
| 125 | } | 127 | } |
| 126 | -#if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102) | 128 | + if (self->ctx.convTilingData->convApiTiling.reluMode1 == static_cast<uint8_t>(ReluMode::SCALAR_RELU)) { |
| 127 | - if (self->ctx.convTiling->reluMode1 == static_cast<uint8_t>(ReluMode::SCALAR_RELU)) { | ||
| 128 | float m2 = fixpipeParams.reluWeight1.GetValue(0); | 129 | float m2 = fixpipeParams.reluWeight1.GetValue(0); |
| 129 | self->ctx.preReluScalar1 = reinterpret_cast<uint64_t&>(m2); | 130 | self->ctx.preReluScalar1 = reinterpret_cast<uint64_t&>(m2); |
| 131 | + } else if (self->ctx.convTilingData->convApiTiling.reluMode1 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { | ||
| 132 | + self->ctx.reluWeight1GM.SetGlobalBuffer(fixpipeParams.reluWeight1.GetPhyAddr(0), | ||
| 133 | + fixpipeParams.reluWeight1.GetSize()); | ||
| 130 | } | 134 | } |
| 131 | -#endif | ||
| 132 | } | 135 | } |
| 133 | - if (self->ctx.convTiling->quantMode0 != static_cast<uint8_t>(QuantModeType::NO_QUANT) || | 136 | + if (self->ctx.convTilingData->convApiTiling.quantMode0 != static_cast<uint8_t>(QuantModeType::NO_QUANT) || |
| 134 | - self->ctx.convTiling->quantMode1 != static_cast<uint8_t>(QuantModeType::NO_QUANT)) { | 137 | + self->ctx.convTilingData->convApiTiling.quantMode1 != static_cast<uint8_t>(QuantModeType::NO_QUANT)) { |
| 135 | self->ctx.isFirstIterate = true; | 138 | self->ctx.isFirstIterate = true; |
| 136 | } | 139 | } |
| 137 | - if (self->ctx.convTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT) || | 140 | + if (self->ctx.convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT) || |
| 138 | - self->ctx.convTiling->quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 141 | + self->ctx.convTilingData->convApiTiling.quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 139 | self->ctx.enableVectorQuant = true; | 142 | self->ctx.enableVectorQuant = true; |
| 140 | } | 143 | } |
| 144 | + if (self->ctx.convTilingData->convApiTiling.reluMode0 == static_cast<uint8_t>(ReluMode::VECTOR_RELU) || | ||
| 145 | + self->ctx.convTilingData->convApiTiling.reluMode1 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { | ||
| 146 | + self->ctx.enableVectorRelu = true; | ||
| 147 | + } | ||
| 141 | } else { | 148 | } else { |
| 142 | - if (self->ctx.convTiling->quantMode0 != static_cast<uint8_t>(QuantModeType::NO_QUANT)) { | 149 | + if (self->ctx.convTilingData->convApiTiling.quantMode0 != static_cast<uint8_t>(QuantModeType::NO_QUANT)) { |
| 143 | self->ctx.isFirstIterate = true; | 150 | self->ctx.isFirstIterate = true; |
| 144 | } | 151 | } |
| 145 | - if (self->ctx.convTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 152 | + if (self->ctx.convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 146 | self->ctx.enableVectorQuant = true; | 153 | self->ctx.enableVectorQuant = true; |
| 147 | } | 154 | } |
| 148 | } | 155 | } |
| @@ -168,7 +175,7 @@ struct GetTensorC { | |||
| 168 | if ASCEND_IS_AIC_CONV { | 175 | if ASCEND_IS_AIC_CONV { |
| 169 | self->ctx.copyOutIns.template CopyOut<TensorTypeT, config>(output0, ubInfo); | 176 | self->ctx.copyOutIns.template CopyOut<TensorTypeT, config>(output0, ubInfo); |
| 170 | if constexpr (Intf::isExtendConv2d) { | 177 | if constexpr (Intf::isExtendConv2d) { |
| 171 | - if (self->ctx.convTiling->dualOutput) { | 178 | + if (self->ctx.convTilingData->convApiTiling.dualOutput) { |
| 172 | self->ctx.copyOutIns1.template CopyOut<GlobalTensor, config>(output1, ubInfo); | 179 | self->ctx.copyOutIns1.template CopyOut<GlobalTensor, config>(output1, ubInfo); |
| 173 | } | 180 | } |
| 174 | } | 181 | } |
| @@ -177,9 +184,13 @@ struct GetTensorC { | |||
| 177 | self->ctx.queueCL0.FreeTensor(self->ctx.cl0); | 184 | self->ctx.queueCL0.FreeTensor(self->ctx.cl0); |
| 178 | } | 185 | } |
| 179 | 186 | ||
| 180 | - if (self->ctx.enableVectorQuant && !self->ctx.convTiling->fixpParamsFullLoadFlag) { | 187 | + if (self->ctx.enableVectorQuant && !self->ctx.convTilingData->convApiTiling.fixpParamsFullLoadFlag) { |
| 181 | self->ctx.queueScaleL1.FreeTensor(self->ctx.scaleL1); | 188 | self->ctx.queueScaleL1.FreeTensor(self->ctx.scaleL1); |
| 182 | } | 189 | } |
| 190 | + | ||
| 191 | + if (self->ctx.enableVectorRelu && !self->ctx.convTilingData->convApiTiling.fixpParamsFullLoadFlag) { | ||
| 192 | + self->ctx.queueReluWeightL1.FreeTensor(self->ctx.reluWeightL1); | ||
| 193 | + } | ||
| 183 | } | 194 | } |
| 184 | } | 195 | } |
| 185 | }; | 196 | }; |
| @@ -190,44 +201,62 @@ struct ConvPreProcess { | |||
| 190 | { | 201 | { |
| 191 | if ASCEND_IS_AIC_CONV { | 202 | if ASCEND_IS_AIC_CONV { |
| 192 | if constexpr (!Intf::isDeQuantFlag) { | 203 | if constexpr (!Intf::isDeQuantFlag) { |
| 193 | - if (self->ctx.convTiling->biasFullLoadFlag && self->ctx.enableBias) { | 204 | + if (self->ctx.convTilingData->convApiTiling.biasFullLoadFlag && self->ctx.enableBias) { |
| 194 | self->ctx.biasL1 = self->ctx.queueBiasL1.template AllocTensor<typename Intf::BiasT>(); | 205 | self->ctx.biasL1 = self->ctx.queueBiasL1.template AllocTensor<typename Intf::BiasT>(); |
| 195 | uint64_t biasLoadNum = self->ctx.singleCoreCo; | 206 | uint64_t biasLoadNum = self->ctx.singleCoreCo; |
| 196 | if constexpr (Intf::groupOptPreloadFlag) { | 207 | if constexpr (Intf::groupOptPreloadFlag) { |
| 197 | - biasLoadNum = self->ctx.orgCo; | 208 | + biasLoadNum = self->ctx.convTilingData->convApiTiling.orgCo; |
| 198 | } | 209 | } |
| 199 | self->ctx.loadBiasL1Ins.LoadChannelWiseL1FullLoad(self->ctx.biasL1, self->ctx.biasgm, | 210 | self->ctx.loadBiasL1Ins.LoadChannelWiseL1FullLoad(self->ctx.biasL1, self->ctx.biasgm, |
| 200 | biasLoadNum, 0); | 211 | biasLoadNum, 0); |
| 201 | self->ctx.queueBiasL1.EnQue(self->ctx.biasL1); | 212 | self->ctx.queueBiasL1.EnQue(self->ctx.biasL1); |
| 202 | self->ctx.biasL1 = self->ctx.queueBiasL1.template DeQue<typename Intf::BiasT>(); | 213 | self->ctx.biasL1 = self->ctx.queueBiasL1.template DeQue<typename Intf::BiasT>(); |
| 203 | } | 214 | } |
| 204 | - if (self->ctx.convTiling->fixpParamsFullLoadFlag && self->ctx.enableVectorQuant) { | 215 | + if (self->ctx.convTilingData->convApiTiling.fixpParamsFullLoadFlag) { |
| 205 | - if constexpr (Intf::groupType != static_cast<int8_t>(ConvGroupType::NORMAL_CONV)) { | 216 | + if (self->ctx.enableVectorQuant || self->ctx.enableVectorRelu) { |
| 206 | - event_t eventId = static_cast<event_t>(self->ctx.pipe.FetchEventID(HardEvent::FIX_MTE2)); | 217 | + if constexpr (Intf::groupType != static_cast<int8_t>(ConvGroupType::NORMAL_CONV)) { |
| 207 | - SetFlag<HardEvent::FIX_MTE2>(eventId); | 218 | + event_t eventId = static_cast<event_t>(self->ctx.pipe.FetchEventID(HardEvent::FIX_MTE2)); |
| 208 | - WaitFlag<HardEvent::FIX_MTE2>(eventId); | 219 | + SetFlag<HardEvent::FIX_MTE2>(eventId); |
| 220 | + WaitFlag<HardEvent::FIX_MTE2>(eventId); | ||
| 221 | + } | ||
| 209 | } | 222 | } |
| 210 | - self->ctx.scaleL1 = self->ctx.queueScaleL1.template AllocTensor<typename Intf::ScaleT>(); | ||
| 211 | uint64_t scaleLoadNum = self->ctx.singleCoreCo; | 223 | uint64_t scaleLoadNum = self->ctx.singleCoreCo; |
| 212 | if constexpr (Intf::groupOptPreloadFlag) { | 224 | if constexpr (Intf::groupOptPreloadFlag) { |
| 213 | - scaleLoadNum = self->ctx.orgCo; | 225 | + scaleLoadNum = self->ctx.convTilingData->convApiTiling.orgCo; |
| 214 | } | 226 | } |
| 215 | - if constexpr (Intf::isExtendConv2d) { | 227 | + if (self->ctx.enableVectorQuant) { |
| 216 | - if (self->ctx.convTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 228 | + self->ctx.scaleL1 = self->ctx.queueScaleL1.template AllocTensor<typename Intf::ScaleT>(); |
| 229 | + if constexpr (Intf::isExtendConv2d) { | ||
| 230 | + if (self->ctx.convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | ||
| 231 | + self->ctx.loadScaleL1Ins.LoadChannelWiseL1FullLoad(self->ctx.scaleL1, self->ctx.scalegm, | ||
| 232 | + scaleLoadNum, 0); | ||
| 233 | + } | ||
| 234 | + if (self->ctx.convTilingData->convApiTiling.quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | ||
| 235 | + self->ctx.loadScaleL1Ins.LoadChannelWiseL1FullLoad(self->ctx.scaleL1[self->ctx.scale1L1offset], | ||
| 236 | + self->ctx.scale1gm, scaleLoadNum, 0); | ||
| 237 | + } | ||
| 238 | + } else { | ||
| 217 | self->ctx.loadScaleL1Ins.LoadChannelWiseL1FullLoad(self->ctx.scaleL1, self->ctx.scalegm, | 239 | self->ctx.loadScaleL1Ins.LoadChannelWiseL1FullLoad(self->ctx.scaleL1, self->ctx.scalegm, |
| 218 | scaleLoadNum, 0); | 240 | scaleLoadNum, 0); |
| 219 | } | 241 | } |
| 220 | - if (self->ctx.convTiling->dualOutput && | 242 | + self->ctx.queueScaleL1.EnQue(self->ctx.scaleL1); |
| 221 | - self->ctx.convTiling->quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 243 | + self->ctx.scaleL1 = self->ctx.queueScaleL1.template DeQue<typename Intf::ScaleT>(); |
| 222 | - self->ctx.loadScaleL1Ins.LoadChannelWiseL1FullLoad(self->ctx.scaleL1[self->ctx.scale1L1offset], | 244 | + } |
| 223 | - self->ctx.scale1gm, scaleLoadNum, 0); | 245 | + if constexpr (Intf::isExtendConv2d) { |
| 224 | - } | 246 | + if (self->ctx.enableVectorRelu) { |
| 225 | - } else { | 247 | + self->ctx.reluWeightL1 = |
| 226 | - self->ctx.loadScaleL1Ins.LoadChannelWiseL1FullLoad(self->ctx.scaleL1, self->ctx.scalegm, | 248 | + self->ctx.queueReluWeightL1.template AllocTensor<typename Intf::ReluWeightT>(); |
| 227 | - scaleLoadNum, 0); | 249 | + if (self->ctx.convTilingData->convApiTiling.reluMode0 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { |
| 250 | + self->ctx.loadReluWeightL1Ins.LoadChannelWiseL1FullLoad(self->ctx.reluWeightL1, | ||
| 251 | + self->ctx.reluWeightGM, scaleLoadNum, 0); | ||
| 252 | + } | ||
| 253 | + if (self->ctx.convTilingData->convApiTiling.reluMode1 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { | ||
| 254 | + self->ctx.loadReluWeightL1Ins.LoadChannelWiseL1FullLoad( | ||
| 255 | + self->ctx.reluWeightL1[self->ctx.reluWeight1L1offset], | ||
| 256 | + self->ctx.reluWeight1GM, scaleLoadNum, 0); | ||
| 257 | + } | ||
| 258 | + } | ||
| 228 | } | 259 | } |
| 229 | - self->ctx.queueScaleL1.EnQue(self->ctx.scaleL1); | ||
| 230 | - self->ctx.scaleL1 = self->ctx.queueScaleL1.template DeQue<typename Intf::ScaleT>(); | ||
| 231 | } | 260 | } |
| 232 | } | 261 | } |
| 233 | } | 262 | } |
| @@ -242,13 +271,20 @@ struct ConvPostProcess { | |||
| 242 | { | 271 | { |
| 243 | if ASCEND_IS_AIC_CONV { | 272 | if ASCEND_IS_AIC_CONV { |
| 244 | if constexpr (!Intf::isDeQuantFlag) { | 273 | if constexpr (!Intf::isDeQuantFlag) { |
| 245 | - if (self->ctx.convTiling->biasFullLoadFlag && self->ctx.enableBias) { | 274 | + if (self->ctx.convTilingData->convApiTiling.biasFullLoadFlag && self->ctx.enableBias) { |
| 246 | self->ctx.queueBiasL1.FreeTensor(self->ctx.biasL1); | 275 | self->ctx.queueBiasL1.FreeTensor(self->ctx.biasL1); |
| 247 | } | 276 | } |
| 248 | - if (self->ctx.convTiling->fixpParamsFullLoadFlag && self->ctx.enableVectorQuant) { | 277 | + if (self->ctx.convTilingData->convApiTiling.fixpParamsFullLoadFlag && self->ctx.enableVectorQuant) { |
| 249 | self->ctx.queueScaleL1.FreeTensor(self->ctx.scaleL1); | 278 | self->ctx.queueScaleL1.FreeTensor(self->ctx.scaleL1); |
| 250 | } | 279 | } |
| 251 | } | 280 | } |
| 281 | + if (self->ctx.convTilingData->convApiTiling.fixpParamsFullLoadFlag && self->ctx.enableVectorRelu) { | ||
| 282 | + self->ctx.queueReluWeightL1.FreeTensor(self->ctx.reluWeightL1); | ||
| 283 | + } | ||
| 284 | + | ||
| 285 | + if constexpr (Intf::isMPreLoad) { | ||
| 286 | + self->ctx.queueBL1.FreeTensor(self->ctx.bl1); | ||
| 287 | + } | ||
| 252 | 288 | ||
| 253 | self->ctx.isFirstIterate = true; | 289 | self->ctx.isFirstIterate = true; |
| 254 | } | 290 | } |
| @@ -315,7 +351,7 @@ struct IterateAll { | |||
| 315 | const GlobalTensor<typename Intf::Output1T> &output1) { | 351 | const GlobalTensor<typename Intf::Output1T> &output1) { |
| 316 | if constexpr (Intf::formatOutput == ConvFormat::NHWC) { | 352 | if constexpr (Intf::formatOutput == ConvFormat::NHWC) { |
| 317 | if constexpr (Intf::isFixedPoint) { | 353 | if constexpr (Intf::isFixedPoint) { |
| 318 | - if (self->ctx.convTiling->dualOutput) { | 354 | + if (self->ctx.convTilingData->convApiTiling.dualOutput) { |
| 319 | GetTensorC<Intf, ImplType>::template | 355 | GetTensorC<Intf, ImplType>::template |
| 320 | call<GlobalTensor, CFG_ROW_MAJOR_FIXED_POINT, sync>(self, output0, output1); | 356 | call<GlobalTensor, CFG_ROW_MAJOR_FIXED_POINT, sync>(self, output0, output1); |
| 321 | } else { | 357 | } else { |
| @@ -323,7 +359,7 @@ struct IterateAll { | |||
| 323 | call<GlobalTensor, CFG_ROW_MAJOR_FIXED_POINT, sync>(self, output0); | 359 | call<GlobalTensor, CFG_ROW_MAJOR_FIXED_POINT, sync>(self, output0); |
| 324 | } | 360 | } |
| 325 | } else { | 361 | } else { |
| 326 | - if (self->ctx.convTiling->dualOutput) { | 362 | + if (self->ctx.convTilingData->convApiTiling.dualOutput) { |
| 327 | GetTensorC<Intf, ImplType>::template | 363 | GetTensorC<Intf, ImplType>::template |
| 328 | call<GlobalTensor, CFG_ROW_MAJOR, sync>(self, output0, output1); | 364 | call<GlobalTensor, CFG_ROW_MAJOR, sync>(self, output0, output1); |
| 329 | } else { | 365 | } else { |
| @@ -333,7 +369,7 @@ struct IterateAll { | |||
| 333 | } | 369 | } |
| 334 | } else { | 370 | } else { |
| 335 | if constexpr (Intf::isFixedPoint) { | 371 | if constexpr (Intf::isFixedPoint) { |
| 336 | - if (self->ctx.convTiling->dualOutput) { | 372 | + if (self->ctx.convTilingData->convApiTiling.dualOutput) { |
| 337 | GetTensorC<Intf, ImplType>::template | 373 | GetTensorC<Intf, ImplType>::template |
| 338 | call<GlobalTensor, CFG_COLUMN_MAJOR_FIXED_POINT, sync>(self, output0, output1); | 374 | call<GlobalTensor, CFG_COLUMN_MAJOR_FIXED_POINT, sync>(self, output0, output1); |
| 339 | } else { | 375 | } else { |
| @@ -341,7 +377,7 @@ struct IterateAll { | |||
| 341 | call<GlobalTensor, CFG_COLUMN_MAJOR_FIXED_POINT, sync>(self, output0); | 377 | call<GlobalTensor, CFG_COLUMN_MAJOR_FIXED_POINT, sync>(self, output0); |
| 342 | } | 378 | } |
| 343 | } else { | 379 | } else { |
| 344 | - if (self->ctx.convTiling->dualOutput) { | 380 | + if (self->ctx.convTilingData->convApiTiling.dualOutput) { |
| 345 | GetTensorC<Intf, ImplType>::template | 381 | GetTensorC<Intf, ImplType>::template |
| 346 | call<GlobalTensor, CFG_COLUMN_MAJOR, sync>(self, output0, output1); | 382 | call<GlobalTensor, CFG_COLUMN_MAJOR, sync>(self, output0, output1); |
| 347 | } else { | 383 | } else { |
| @@ -363,6 +399,7 @@ struct End { | |||
| 363 | if constexpr (!Intf::isDeQuantFlag) { | 399 | if constexpr (!Intf::isDeQuantFlag) { |
| 364 | self->ctx.queueBiasL1.FreeAllEvent(); | 400 | self->ctx.queueBiasL1.FreeAllEvent(); |
| 365 | self->ctx.queueScaleL1.FreeAllEvent(); | 401 | self->ctx.queueScaleL1.FreeAllEvent(); |
| 402 | + self->ctx.queueReluWeightL1.FreeAllEvent(); | ||
| 366 | self->ctx.queueBiasBT.FreeAllEvent(); | 403 | self->ctx.queueBiasBT.FreeAllEvent(); |
| 367 | } | 404 | } |
| 368 | 405 | ||
| @@ -370,6 +407,15 @@ struct End { | |||
| 370 | self->ctx.queueCL0.FreeAllEvent(); | 407 | self->ctx.queueCL0.FreeAllEvent(); |
| 371 | } | 408 | } |
| 372 | } | 409 | } |
| 410 | + if constexpr (Intf::preFusionFlag) { | ||
| 411 | + GetTPipePtr()->ReleaseEventID<AscendC::HardEvent::MTE3_MTE1>(self->ctx.eventIdMte3ToMte1Ping); | ||
| 412 | + GetTPipePtr()->ReleaseEventID<AscendC::HardEvent::MTE3_MTE1>(self->ctx.eventIdMte3ToMte1Pong); | ||
| 413 | + GetTPipePtr()->ReleaseEventID<AscendC::HardEvent::MTE1_MTE3>(self->ctx.eventIdMte1ToMte3Ping); | ||
| 414 | + GetTPipePtr()->ReleaseEventID<AscendC::HardEvent::MTE1_MTE3>(self->ctx.eventIdMte1ToMte3Pong); | ||
| 415 | + if constexpr ((Intf::preFusionFlag && ConvParam::weightTiling == 0)) { | ||
| 416 | + self->ctx.queueBL1.FreeTensor(self->ctx.bl1); | ||
| 417 | + } | ||
| 418 | + } | ||
| 373 | } | 419 | } |
| 374 | }; | 420 | }; |
| 375 | 421 | ||
| @@ -381,14 +427,11 @@ __aicore__ inline void InitBufferWithDoubleBuf(Intf *self) | |||
| 381 | self->ctx.wholeAl0Tensor = self->ctx.al0Buf.template Get<typename Intf::FmapT>(); | 427 | self->ctx.wholeAl0Tensor = self->ctx.al0Buf.template Get<typename Intf::FmapT>(); |
| 382 | self->ctx.wholeBl0Tensor = self->ctx.bl0Buf.template Get<typename Intf::WeightT>(); | 428 | self->ctx.wholeBl0Tensor = self->ctx.bl0Buf.template Get<typename Intf::WeightT>(); |
| 383 | 429 | ||
| 384 | - int8_t cl0db = (self->ctx.convTiling->pBufferFlag & 0x04) >> 2; | 430 | + int8_t cl0db = (self->ctx.convTilingData->convApiTiling.pBufferFlag & 0x04) >> 2; |
| 385 | - int8_t al1db = (self->ctx.convTiling->pBufferFlag & 0x08) >> 3; | ||
| 386 | - int8_t bl1db = (self->ctx.convTiling->pBufferFlag & 0x10) >> 4; | ||
| 387 | - | ||
| 388 | if constexpr (Intf::isInnerBatchFlag || Intf::isDeQuantFlag) { | 431 | if constexpr (Intf::isInnerBatchFlag || Intf::isDeQuantFlag) { |
| 389 | - uint64_t cl0Spacesize = self->ctx.convTiling->mStep * self->ctx.convTiling->nL0; | 432 | + uint64_t cl0Spacesize = self->ctx.convTilingData->convApiTiling.mStep * self->ctx.convTilingData->convApiTiling.nL0; |
| 390 | if constexpr (Intf::isInnerBatchFlag) { | 433 | if constexpr (Intf::isInnerBatchFlag) { |
| 391 | - cl0Spacesize *= self->ctx.convTiling->innerBatch; | 434 | + cl0Spacesize *= self->ctx.convTilingData->convApiTiling.innerBatch; |
| 392 | } | 435 | } |
| 393 | if (!cl0db) { | 436 | if (!cl0db) { |
| 394 | self->ctx.pipe.InitBuffer(self->ctx.queueCL0, 1, cl0Spacesize * Intf::sizeOfL0c); | 437 | self->ctx.pipe.InitBuffer(self->ctx.queueCL0, 1, cl0Spacesize * Intf::sizeOfL0c); |
| @@ -400,10 +443,10 @@ __aicore__ inline void InitBufferWithDoubleBuf(Intf *self) | |||
| 400 | self->ctx.wholeCl0Tensor = self->ctx.l0cBuf.template Get<typename Intf::L0cT>(); | 443 | self->ctx.wholeCl0Tensor = self->ctx.l0cBuf.template Get<typename Intf::L0cT>(); |
| 401 | } | 444 | } |
| 402 | 445 | ||
| 403 | - if (!al1db) { | 446 | + if (!((self->ctx.convTilingData->convApiTiling.pBufferFlag & AL1_DB_IDX) >> AL1_DB_OFFSET)) { |
| 404 | - self->ctx.pipe.InitBuffer(self->ctx.queueAL1, 1, self->ctx.convTiling->aL1SpaceSize); | 447 | + self->ctx.pipe.InitBuffer(self->ctx.queueAL1, 1, self->ctx.convTilingData->convApiTiling.aL1SpaceSize); |
| 405 | } else { | 448 | } else { |
| 406 | - self->ctx.pipe.InitBuffer(self->ctx.queueAL1, DOUBLE_BUF, self->ctx.convTiling->aL1SpaceSize); | 449 | + self->ctx.pipe.InitBuffer(self->ctx.queueAL1, DOUBLE_BUF, self->ctx.convTilingData->convApiTiling.aL1SpaceSize); |
| 407 | } | 450 | } |
| 408 | 451 | ||
| 409 | if constexpr (!Intf::bL1DBFlag) { | 452 | if constexpr (!Intf::bL1DBFlag) { |
| @@ -420,7 +463,7 @@ __aicore__ inline void InitBufferWithDoubleBuf(Intf *self) | |||
| 420 | 463 | ||
| 421 | if constexpr (Intf::isDeQuantFlag) { | 464 | if constexpr (Intf::isDeQuantFlag) { |
| 422 | self->ctx.pipe.InitBuffer(self->ctx.mmadResUbBuf, | 465 | self->ctx.pipe.InitBuffer(self->ctx.mmadResUbBuf, |
| 423 | - self->ctx.convTiling->mUB * self->ctx.convTiling->nUB * Intf::sizeOfL0c); | 466 | + self->ctx.convTilingData->convApiTiling.mUB * self->ctx.convTilingData->convApiTiling.nUB * Intf::sizeOfL0c); |
| 424 | self->ctx.mmadResUbTensor = self->ctx.mmadResUbBuf.template Get<typename Intf::L0cT>(); | 467 | self->ctx.mmadResUbTensor = self->ctx.mmadResUbBuf.template Get<typename Intf::L0cT>(); |
| 425 | } | 468 | } |
| 426 | } | 469 | } |
| @@ -428,21 +471,21 @@ __aicore__ inline void InitBufferWithDoubleBuf(Intf *self) | |||
| 428 | template <class Intf> | 471 | template <class Intf> |
| 429 | __aicore__ inline void InitBuffer(Intf *self) | 472 | __aicore__ inline void InitBuffer(Intf *self) |
| 430 | { | 473 | { |
| 431 | - self->ctx.bL1SpaceSize = self->ctx.convTiling->nBL1 * self->ctx.convTiling->kBL1; | 474 | + self->ctx.bL1SpaceSize = self->ctx.convTilingData->convApiTiling.nBL1 * self->ctx.convTilingData->convApiTiling.kBL1; |
| 432 | 475 | ||
| 433 | InitBufferWithDoubleBuf<Intf>(self); | 476 | InitBufferWithDoubleBuf<Intf>(self); |
| 434 | 477 | ||
| 435 | if constexpr (!Intf::isDeQuantFlag) { | 478 | if constexpr (!Intf::isDeQuantFlag) { |
| 436 | - if (self->ctx.convTiling->hasBias) { | 479 | + if (self->ctx.convTilingData->convApiTiling.hasBias) { |
| 437 | - uint64_t biasl1Spacesize = self->ctx.convTiling->biasFullLoadFlag ? AlignB( | 480 | + uint64_t biasl1Spacesize = self->ctx.convTilingData->convApiTiling.biasFullLoadFlag ? AlignB( |
| 438 | self->ctx.singleCoreCo * Intf::sizeOfBias, BLOCK_L0_N * Intf::sizeOfBias) : | 481 | self->ctx.singleCoreCo * Intf::sizeOfBias, BLOCK_L0_N * Intf::sizeOfBias) : |
| 439 | - self->ctx.convTiling->nL0 * Intf::sizeOfBias; | 482 | + self->ctx.convTilingData->convApiTiling.nL0 * Intf::sizeOfBias; |
| 440 | if constexpr (Intf::groupOptPreloadFlag) { | 483 | if constexpr (Intf::groupOptPreloadFlag) { |
| 441 | - if (self->ctx.convTiling->biasFullLoadFlag) { | 484 | + if (self->ctx.convTilingData->convApiTiling.biasFullLoadFlag) { |
| 442 | - biasl1Spacesize = AlignB(self->ctx.orgCo * Intf::sizeOfBias, BLOCK_L0_N * Intf::sizeOfBias); | 485 | + biasl1Spacesize = AlignB(self->ctx.convTilingData->convApiTiling.orgCo * Intf::sizeOfBias, BLOCK_L0_N * Intf::sizeOfBias); |
| 443 | } | 486 | } |
| 444 | } | 487 | } |
| 445 | - uint64_t biasBTSpacesize = self->ctx.convTiling->nL0; | 488 | + uint64_t biasBTSpacesize = self->ctx.convTilingData->convApiTiling.nL0; |
| 446 | self->ctx.pipe.InitBuffer(self->ctx.queueBiasL1, 1, AlignB(biasl1Spacesize, C0_SIZE)); | 489 | self->ctx.pipe.InitBuffer(self->ctx.queueBiasL1, 1, AlignB(biasl1Spacesize, C0_SIZE)); |
| 447 | self->ctx.pipe.InitBuffer( | 490 | self->ctx.pipe.InitBuffer( |
| 448 | self->ctx.queueBiasBT, 1, AlignB(biasBTSpacesize * Intf::sizeOfL0c, BT_SIZE)); | 491 | self->ctx.queueBiasBT, 1, AlignB(biasBTSpacesize * Intf::sizeOfL0c, BT_SIZE)); |
| @@ -450,34 +493,50 @@ __aicore__ inline void InitBuffer(Intf *self) | |||
| 450 | } | 493 | } |
| 451 | 494 | ||
| 452 | if constexpr (Intf::isExtendConv2d) { | 495 | if constexpr (Intf::isExtendConv2d) { |
| 453 | - uint64_t scaleL1SpaceSize = 0; | 496 | + if (self->ctx.convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT) || |
| 454 | - uint64_t scale0L1Size = self->ctx.convTiling->fixpParamsFullLoadFlag ? AlignB( | 497 | + self->ctx.convTilingData->convApiTiling.quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 455 | - self->ctx.singleCoreCo * Intf::sizeOfScale, BLOCK_L0_N * Intf::sizeOfScale) : | 498 | + uint64_t scaleL1SpaceSize = 0; |
| 456 | - self->ctx.convTiling->nL0 * Intf::sizeOfScale; | 499 | + uint64_t scale0L1Size = self->ctx.convTilingData->convApiTiling.fixpParamsFullLoadFlag ? AlignB( |
| 457 | - if constexpr (Intf::groupOptPreloadFlag) { | 500 | + self->ctx.singleCoreCo * Intf::sizeOfScale, BLOCK_L0_N * Intf::sizeOfScale) : |
| 458 | - if (self->ctx.convTiling->fixpParamsFullLoadFlag) { | 501 | + self->ctx.convTilingData->convApiTiling.nL0 * Intf::sizeOfScale; |
| 459 | - scale0L1Size = AlignB(self->ctx.orgCo * Intf::sizeOfScale, BLOCK_L0_N * Intf::sizeOfScale); | 502 | + if constexpr (Intf::groupOptPreloadFlag) { |
| 503 | + if (self->ctx.convTilingData->convApiTiling.fixpParamsFullLoadFlag) { | ||
| 504 | + scale0L1Size = AlignB(self->ctx.convTilingData->convApiTiling.orgCo * Intf::sizeOfScale, | ||
| 505 | + BLOCK_L0_N * Intf::sizeOfScale); | ||
| 506 | + } | ||
| 507 | + } | ||
| 508 | + if (self->ctx.convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | ||
| 509 | + scaleL1SpaceSize += scale0L1Size; | ||
| 510 | + } | ||
| 511 | + if (self->ctx.convTilingData->convApiTiling.quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | ||
| 512 | + self->ctx.scale1L1offset = scaleL1SpaceSize / Intf::sizeOfScale; | ||
| 513 | + scaleL1SpaceSize += scale0L1Size; | ||
| 460 | } | 514 | } |
| 461 | - } | ||
| 462 | - if (self->ctx.convTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | ||
| 463 | - scaleL1SpaceSize += scale0L1Size; | ||
| 464 | - } | ||
| 465 | - if (self->ctx.convTiling->quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | ||
| 466 | - self->ctx.scale1L1offset = scaleL1SpaceSize / Intf::sizeOfScale; | ||
| 467 | - scaleL1SpaceSize += scale0L1Size; | ||
| 468 | - } | ||
| 469 | - if (self->ctx.convTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT) || | ||
| 470 | - self->ctx.convTiling->quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | ||
| 471 | self->ctx.pipe.InitBuffer(self->ctx.queueScaleL1, 1, AlignB(scaleL1SpaceSize, C0_SIZE)); | 515 | self->ctx.pipe.InitBuffer(self->ctx.queueScaleL1, 1, AlignB(scaleL1SpaceSize, C0_SIZE)); |
| 472 | } | 516 | } |
| 517 | + if (self->ctx.convTilingData->convApiTiling.reluMode0 == static_cast<uint8_t>(ReluMode::VECTOR_RELU) || | ||
| 518 | + self->ctx.convTilingData->convApiTiling.reluMode1 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { | ||
| 519 | + uint32_t reluWeightL1SpaceSize = 0; | ||
| 520 | + uint32_t reluWeight0L1Size = self->ctx.convTilingData->convApiTiling.fixpParamsFullLoadFlag ? AlignB( | ||
| 521 | + self->ctx.singleCoreCo * Intf::sizeOfReluWeight, BLOCK_L0_N * Intf::sizeOfReluWeight) : | ||
| 522 | + self->ctx.convTilingData->convApiTiling.nL0 * Intf::sizeOfReluWeight; | ||
| 523 | + if (self->ctx.convTilingData->convApiTiling.reluMode0 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { | ||
| 524 | + reluWeightL1SpaceSize += reluWeight0L1Size; | ||
| 525 | + } | ||
| 526 | + if (self->ctx.convTilingData->convApiTiling.reluMode1 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { | ||
| 527 | + self->ctx.reluWeight1L1offset = reluWeightL1SpaceSize / Intf::sizeOfReluWeight; | ||
| 528 | + reluWeightL1SpaceSize += reluWeight0L1Size; | ||
| 529 | + } | ||
| 530 | + self->ctx.pipe.InitBuffer(self->ctx.queueReluWeightL1, 1, AlignB(reluWeightL1SpaceSize, C0_SIZE)); | ||
| 531 | + } | ||
| 473 | } else if constexpr (Intf::isQuantScene) { | 532 | } else if constexpr (Intf::isQuantScene) { |
| 474 | - if (self->ctx.convTiling->hasScale != 0) { | 533 | + if (self->ctx.convTilingData->convApiTiling.hasScale != 0) { |
| 475 | - uint64_t scaleL1SpaceSize = self->ctx.convTiling->fixpParamsFullLoadFlag ? AlignB( | 534 | + uint64_t scaleL1SpaceSize = self->ctx.convTilingData->convApiTiling.fixpParamsFullLoadFlag ? AlignB( |
| 476 | self->ctx.singleCoreCo * Intf::sizeOfScale, BLOCK_L0_N * Intf::sizeOfScale) : | 535 | self->ctx.singleCoreCo * Intf::sizeOfScale, BLOCK_L0_N * Intf::sizeOfScale) : |
| 477 | - self->ctx.convTiling->nL0 * Intf::sizeOfScale; | 536 | + self->ctx.convTilingData->convApiTiling.nL0 * Intf::sizeOfScale; |
| 478 | if constexpr (Intf::groupOptPreloadFlag) { | 537 | if constexpr (Intf::groupOptPreloadFlag) { |
| 479 | - if (self->ctx.convTiling->fixpParamsFullLoadFlag) { | 538 | + if (self->ctx.convTilingData->convApiTiling.fixpParamsFullLoadFlag) { |
| 480 | - scaleL1SpaceSize = AlignB(self->ctx.orgCo * Intf::sizeOfScale, BLOCK_L0_N * Intf::sizeOfScale); | 539 | + scaleL1SpaceSize = AlignB(self->ctx.convTilingData->convApiTiling.orgCo * Intf::sizeOfScale, BLOCK_L0_N * Intf::sizeOfScale); |
| 481 | } | 540 | } |
| 482 | } | 541 | } |
| 483 | self->ctx.pipe.InitBuffer(self->ctx.queueScaleL1, 1, AlignB(scaleL1SpaceSize, C0_SIZE)); | 542 | self->ctx.pipe.InitBuffer(self->ctx.queueScaleL1, 1, AlignB(scaleL1SpaceSize, C0_SIZE)); |
| @@ -488,9 +547,9 @@ __aicore__ inline void InitBuffer(Intf *self) | |||
| 488 | template <class Intf> | 547 | template <class Intf> |
| 489 | __aicore__ inline void InitHf32Mode(Intf *self) | 548 | __aicore__ inline void InitHf32Mode(Intf *self) |
| 490 | { | 549 | { |
| 491 | - if (self->ctx.convTiling->hf32Enable) { | 550 | + if (self->ctx.convTilingData->convApiTiling.hf32Enable) { |
| 492 | - SetHF32Mode(self->ctx.convTiling->hf32Enable); | 551 | + SetHF32Mode(self->ctx.convTilingData->convApiTiling.hf32Enable); |
| 493 | - SetHF32TransMode(self->ctx.convTiling->hf32TransMode); | 552 | + SetHF32TransMode(self->ctx.convTilingData->convApiTiling.hf32TransMode); |
| 494 | } else { | 553 | } else { |
| 495 | SetHF32Mode(0); | 554 | SetHF32Mode(0); |
| 496 | SetHF32TransMode(0); | 555 | SetHF32TransMode(0); |
| @@ -59,14 +59,14 @@ struct Extendconv2dFixpipeParams { | |||
| 59 | 59 | ||
| 60 | struct CopyUbInfo { | 60 | struct CopyUbInfo { |
| 61 | // only support batchUb = 1 in tiling hw mode | 61 | // only support batchUb = 1 in tiling hw mode |
| 62 | - // when batchUb > 1, mUb should equal to convTiling->hoL0 | 62 | + // when batchUb > 1, mUb should equal to hoL0 |
| 63 | uint64_t batchUb = 0; | 63 | uint64_t batchUb = 0; |
| 64 | // nUb should be aligned to BLOCK_L0_N | 64 | // nUb should be aligned to BLOCK_L0_N |
| 65 | uint64_t nUb = 0; | 65 | uint64_t nUb = 0; |
| 66 | // mUb should be aligned to BLOCK_L0_M | 66 | // mUb should be aligned to BLOCK_L0_M |
| 67 | - // In tiling m mode, mUb is part of convTiling->hoL0 | 67 | + // In tiling m mode, mUb is part of hoL0 |
| 68 | - // In tiling hw mode, mUb is part of convTiling->hoL0*convTiling->woL0, | 68 | + // In tiling hw mode, mUb is part of hoL0*woL0, |
| 69 | - // additionally, when convTiling->hoL0 != 1, mUb must be >= convTiling->woL0. | 69 | + // additionally, when hoL0 != 1, mUb must be >= woL0. |
| 70 | uint64_t mUb = 0; | 70 | uint64_t mUb = 0; |
| 71 | uint64_t batchLoopIdx = 0; | 71 | uint64_t batchLoopIdx = 0; |
| 72 | uint64_t nLoopIdx = 0; | 72 | uint64_t nLoopIdx = 0; |
| @@ -164,6 +164,9 @@ struct ConvParam { | |||
| 164 | constexpr static int8_t iterOrder = 0; | 164 | constexpr static int8_t iterOrder = 0; |
| 165 | constexpr static int8_t groupType = 0; | 165 | constexpr static int8_t groupType = 0; |
| 166 | constexpr static int8_t innerBatch = static_cast<int8_t>(ConvInnerBatch::SINGLE_BATCH); | 166 | constexpr static int8_t innerBatch = static_cast<int8_t>(ConvInnerBatch::SINGLE_BATCH); |
| 167 | + constexpr static int8_t batchOne = 0; | ||
| 168 | + constexpr static int8_t noPad = 0; | ||
| 169 | + constexpr static int8_t smallWeight = 0; | ||
| 167 | }; | 170 | }; |
| 168 | 171 | ||
| 169 | template <typename T> | 172 | template <typename T> |
| @@ -263,8 +266,11 @@ public: | |||
| 263 | GlobalTensor<typename ConvDataType::BiasT> biasgm; | 266 | GlobalTensor<typename ConvDataType::BiasT> biasgm; |
| 264 | GlobalTensor<typename ConvDataType::ScaleT> scalegm; | 267 | GlobalTensor<typename ConvDataType::ScaleT> scalegm; |
| 265 | GlobalTensor<typename ConvDataType::ScaleT> scale1gm; | 268 | GlobalTensor<typename ConvDataType::ScaleT> scale1gm; |
| 269 | + GlobalTensor<typename ConvDataType::ReluWeightT> reluWeightGM; | ||
| 270 | + GlobalTensor<typename ConvDataType::ReluWeightT> reluWeight1GM; | ||
| 266 | TQue<QuePosition::A1, 1> queueBiasL1; // BiasL1 | 271 | TQue<QuePosition::A1, 1> queueBiasL1; // BiasL1 |
| 267 | TQue<QuePosition::A1, 1> queueScaleL1; // ScaleL1 | 272 | TQue<QuePosition::A1, 1> queueScaleL1; // ScaleL1 |
| 273 | + TQue<QuePosition::A1, 1> queueReluWeightL1; // ReluWeightL1 | ||
| 268 | TQue<TPosition::C2, 1> queueBiasBT; // BT | 274 | TQue<TPosition::C2, 1> queueBiasBT; // BT |
| 269 | TQue<QuePosition::CO1, 1> queueCL0; | 275 | TQue<QuePosition::CO1, 1> queueCL0; |
| 270 | TBuf<TPosition::A2> al0Buf; | 276 | TBuf<TPosition::A2> al0Buf; |
| @@ -275,10 +281,9 @@ public: | |||
| 275 | LocalTensor<typename ConvDataType::WeightT> bl1; | 281 | LocalTensor<typename ConvDataType::WeightT> bl1; |
| 276 | LocalTensor<typename ConvDataType::BiasT> biasL1; | 282 | LocalTensor<typename ConvDataType::BiasT> biasL1; |
| 277 | LocalTensor<typename ConvDataType::ScaleT> scaleL1; | 283 | LocalTensor<typename ConvDataType::ScaleT> scaleL1; |
| 284 | + LocalTensor<typename ConvDataType::ReluWeightT> reluWeightL1; | ||
| 278 | LocalTensor<typename ConvDataType::FmapT> wholeAl0Tensor; | 285 | LocalTensor<typename ConvDataType::FmapT> wholeAl0Tensor; |
| 279 | - LocalTensor<typename ConvDataType::FmapT> al0; | ||
| 280 | LocalTensor<typename ConvDataType::WeightT> wholeBl0Tensor; | 286 | LocalTensor<typename ConvDataType::WeightT> wholeBl0Tensor; |
| 281 | - LocalTensor<typename ConvDataType::WeightT> bl0; | ||
| 282 | LocalTensor<typename ConvDataType::L0cT> biasBT; | 287 | LocalTensor<typename ConvDataType::L0cT> biasBT; |
| 283 | LocalTensor<typename ConvDataType::L0cT> wholeCl0Tensor = | 288 | LocalTensor<typename ConvDataType::L0cT> wholeCl0Tensor = |
| 284 | LocalTensor<typename ConvDataType::L0cT>(TPosition::CO1, 0, 0); | 289 | LocalTensor<typename ConvDataType::L0cT>(TPosition::CO1, 0, 0); |
| @@ -287,7 +292,9 @@ public: | |||
| 287 | 292 | ||
| 288 | uint8_t enableBias = false; // 是否有bias | 293 | uint8_t enableBias = false; // 是否有bias |
| 289 | uint8_t enableVectorQuant = false; // 是否有vector类型scale,双输出场景下任一scale为vector类型,即为true | 294 | uint8_t enableVectorQuant = false; // 是否有vector类型scale,双输出场景下任一scale为vector类型,即为true |
| 295 | + uint8_t enableVectorRelu = false; // 是否有vector类型relu_weight,双输出场景下任一relu_weight为vector类型,即为true | ||
| 290 | uint64_t scale1L1offset = 0; // 双输出时scale1在L1上的偏移 | 296 | uint64_t scale1L1offset = 0; // 双输出时scale1在L1上的偏移 |
| 297 | + uint64_t reluWeight1L1offset = 0; // 双输出时reluWeight1在L1上的偏移 | ||
| 291 | uint64_t deqScalar0 = DEQ_SCALAR_ONE; // m1 = 1.0, other bits are 0. | 298 | uint64_t deqScalar0 = DEQ_SCALAR_ONE; // m1 = 1.0, other bits are 0. |
| 292 | uint64_t deqScalar1 = DEQ_SCALAR_ONE; // m1 = 1.0, other bits are 0. | 299 | uint64_t deqScalar1 = DEQ_SCALAR_ONE; // m1 = 1.0, other bits are 0. |
| 293 | uint64_t preReluScalar0 = 0; | 300 | uint64_t preReluScalar0 = 0; |
| @@ -396,6 +403,14 @@ public: | |||
| 396 | uint8_t loadBL1Flag = true; // 是否载入BL1的标志 | 403 | uint8_t loadBL1Flag = true; // 是否载入BL1的标志 |
| 397 | uint8_t loadAL0Flag = true; // 是否载入AL0的标志 | 404 | uint8_t loadAL0Flag = true; // 是否载入AL0的标志 |
| 398 | uint8_t loadBL0Flag = true; // 是否载入BL0的标志 | 405 | uint8_t loadBL0Flag = true; // 是否载入BL0的标志 |
| 406 | + uint8_t updateL1Flag = false; // 是否更新AL1数据的标志 | ||
| 407 | + // 用于管理前融合场景下MTE1/MTE3之前的同步管理,在后续处理中赋值后使用 | ||
| 408 | + AscendC::TEventID eventIdMte3ToMte1; | ||
| 409 | + AscendC::TEventID eventIdMte1ToMte3; | ||
| 410 | + AscendC::TEventID eventIdMte3ToMte1Ping; | ||
| 411 | + AscendC::TEventID eventIdMte3ToMte1Pong; | ||
| 412 | + AscendC::TEventID eventIdMte1ToMte3Ping; | ||
| 413 | + AscendC::TEventID eventIdMte1ToMte3Pong; | ||
| 399 | 414 | ||
| 400 | uint64_t kIter = 0; // k方向迭代器,从DDR到L0 | 415 | uint64_t kIter = 0; // k方向迭代器,从DDR到L0 |
| 401 | uint64_t batchIter = 0; // batch方向迭代器 | 416 | uint64_t batchIter = 0; // batch方向迭代器 |
| @@ -406,7 +421,6 @@ public: | |||
| 406 | uint64_t kBL0Iter = 0; // L1B 到L0方向的迭代器 | 421 | uint64_t kBL0Iter = 0; // L1B 到L0方向的迭代器 |
| 407 | uint64_t nL0Iter = 0; // BL0上n方向迭代器 | 422 | uint64_t nL0Iter = 0; // BL0上n方向迭代器 |
| 408 | 423 | ||
| 409 | - uint64_t maxBatchIter = 0; | ||
| 410 | uint64_t multiKAL1 = 1; | 424 | uint64_t multiKAL1 = 1; |
| 411 | uint64_t multiKBL1 = 1; | 425 | uint64_t multiKBL1 = 1; |
| 412 | uint64_t maxKAL1Iter = 0; | 426 | uint64_t maxKAL1Iter = 0; |
| @@ -444,17 +458,7 @@ public: | |||
| 444 | uint16_t kL0FullLoadAl0PingPongFlag = 0; | 458 | uint16_t kL0FullLoadAl0PingPongFlag = 0; |
| 445 | uint16_t kL0FullLoadBl0PingPongFlag = 0; | 459 | uint16_t kL0FullLoadBl0PingPongFlag = 0; |
| 446 | uint16_t cl0PingPongFlag = 0; | 460 | uint16_t cl0PingPongFlag = 0; |
| 447 | - | 461 | + uint16_t al1PingPongFlag = 0; |
| 448 | - // Input shape info | ||
| 449 | - uint64_t orgBatch = 0; // fmap上batch大小 | ||
| 450 | - uint64_t orgCi = 0; // fmap上cin大小 | ||
| 451 | - uint64_t orgCo = 0; // weight上cout大小 | ||
| 452 | - uint64_t orgHi = 0; // fmap上h大小 | ||
| 453 | - uint64_t orgWi = 0; // fmap上w大小 | ||
| 454 | - uint64_t orgHo = 0; // output上h大小 | ||
| 455 | - uint64_t orgWo = 0; // output上w大小 | ||
| 456 | - uint64_t kernelH = 0; // weight上h大小 | ||
| 457 | - uint64_t kernelW = 0; // weight上w大小 | ||
| 458 | }; | 462 | }; |
| 459 | }; | 463 | }; |
| 460 | 464 | ||
| @@ -62,6 +62,9 @@ using namespace AscendC; | |||
| 62 | #define CONV_CHECK_FUN_TEMPLATE(T, NAMESPACE, ARG, ...) \ | 62 | #define CONV_CHECK_FUN_TEMPLATE(T, NAMESPACE, ARG, ...) \ |
| 63 | (!IsSameType<decltype(T::template call<ARG>(__VA_ARGS__)), NAMESPACE::TypeFalse>::value) | 63 | (!IsSameType<decltype(T::template call<ARG>(__VA_ARGS__)), NAMESPACE::TypeFalse>::value) |
| 64 | 64 | ||
| 65 | +#define CONV_CHECK_FUN_THREE_TEMPLATE(T, NAMESPACE, ARG0, ARG1, ARG2, ...) \ | ||
| 66 | + (!IsSameType<decltype(T::template call<ARG0, ARG1, ARG2>(__VA_ARGS__)), NAMESPACE::TypeFalse>::value) | ||
| 67 | + | ||
| 65 | // Define struct _has_member_MEMBER for check whether MEMBER exists. | 68 | // Define struct _has_member_MEMBER for check whether MEMBER exists. |
| 66 | #define CONV_DECLARE_CHECK_MEMBER(MEMBER) namespace __ConvFramework { \ | 69 | #define CONV_DECLARE_CHECK_MEMBER(MEMBER) namespace __ConvFramework { \ |
| 67 | template <typename T> \ | 70 | template <typename T> \ |
| @@ -18,8 +18,8 @@ | |||
| 18 | 18 | ||
| 19 | #include "conv_common.h" | 19 | #include "conv_common.h" |
| 20 | 20 | ||
| 21 | -template <class CONV, class RUN_INFO> | 21 | +template <class CONV, class CONV_TILING> |
| 22 | -class ConvGroupCommon : public ConvCommon<CONV, RUN_INFO> { | 22 | +class ConvGroupCommon : public ConvCommon<CONV, CONV_TILING> { |
| 23 | public: | 23 | public: |
| 24 | __aicore__ __forceinline__ void CalcStartAddrFmapHW(); | 24 | __aicore__ __forceinline__ void CalcStartAddrFmapHW(); |
| 25 | 25 | ||
| @@ -41,14 +41,16 @@ public: | |||
| 41 | __aicore__ __forceinline__ void SetOptGroupTail(); | 41 | __aicore__ __forceinline__ void SetOptGroupTail(); |
| 42 | 42 | ||
| 43 | private: | 43 | private: |
| 44 | - using ConvCommon<CONV, RUN_INFO>::convOps; | 44 | + using ConvCommon<CONV, CONV_TILING>::convOps; |
| 45 | - using ConvCommon<CONV, RUN_INFO>::convRunInfo; | 45 | + // 2d and 3d is conflict, need to fix in future |
| 46 | - using ConvCommon<CONV, RUN_INFO>::hasScale; | 46 | + using ConvCommon<CONV, CONV_TILING>::convTilingData; |
| 47 | - using ConvCommon<CONV, RUN_INFO>::fmStartAddr; | 47 | + using ConvCommon<CONV, CONV_TILING>::hasScale; |
| 48 | - using ConvCommon<CONV, RUN_INFO>::weightStartAddr; | 48 | + using ConvCommon<CONV, CONV_TILING>::fmStartAddr; |
| 49 | - using ConvCommon<CONV, RUN_INFO>::biasStartAddr; | 49 | + using ConvCommon<CONV, CONV_TILING>::weightStartAddr; |
| 50 | - using ConvCommon<CONV, RUN_INFO>::scaleStartAddr; | 50 | + using ConvCommon<CONV, CONV_TILING>::biasStartAddr; |
| 51 | - using ConvCommon<CONV, RUN_INFO>::outputStartAddr; | 51 | + using ConvCommon<CONV, CONV_TILING>::scaleStartAddr; |
| 52 | + using ConvCommon<CONV, CONV_TILING>::reluWeightStartAddr; | ||
| 53 | + using ConvCommon<CONV, CONV_TILING>::outputStartAddr; | ||
| 52 | 54 | ||
| 53 | uint64_t fmapOneGroupSize = 0; | 55 | uint64_t fmapOneGroupSize = 0; |
| 54 | uint64_t weightOneCoSize = 0; | 56 | uint64_t weightOneCoSize = 0; |
| @@ -62,28 +64,28 @@ private: | |||
| 62 | uint64_t dhwIn = 0; | 64 | uint64_t dhwIn = 0; |
| 63 | }; | 65 | }; |
| 64 | 66 | ||
| 65 | -template <class CONV, class RUN_INFO> | 67 | +template <class CONV, class CONV_TILING> |
| 66 | -__aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | 68 | +__aicore__ __forceinline__ void ConvGroupCommon<CONV, CONV_TILING>:: |
| 67 | CalcStartAddrFmapHW() | 69 | CalcStartAddrFmapHW() |
| 68 | { | 70 | { |
| 69 | if constexpr (!CONV::isMMode) { | 71 | if constexpr (!CONV::isMMode) { |
| 70 | - int64_t hiStartPosTmp = static_cast<int64_t>(convOps->hoIdxStart * convRunInfo->strideH) - | 72 | + int64_t hiStartPosTmp = static_cast<int64_t>(convOps->hoIdxStart * convTilingData->convRunInfo.strideH) - |
| 71 | - static_cast<int64_t>(convRunInfo->padTop); | 73 | + static_cast<int64_t>(convTilingData->convRunInfo.padTop); |
| 72 | convOps->singleCoreHiStartPos = hiStartPosTmp < 0 ? 0 : hiStartPosTmp; | 74 | convOps->singleCoreHiStartPos = hiStartPosTmp < 0 ? 0 : hiStartPosTmp; |
| 73 | if constexpr (CONV::A_FORMAT == ConvFormat::NDHWC || CONV::A_FORMAT == ConvFormat::NHWC) { | 75 | if constexpr (CONV::A_FORMAT == ConvFormat::NDHWC || CONV::A_FORMAT == ConvFormat::NHWC) { |
| 74 | - fmStartAddr += convOps->singleCoreHiStartPos * convRunInfo->win * convRunInfo->cin; | 76 | + fmStartAddr += convOps->singleCoreHiStartPos * convTilingData->convRunInfo.win * convTilingData->convRunInfo.cin; |
| 75 | } else { | 77 | } else { |
| 76 | - fmStartAddr += convOps->singleCoreHiStartPos * convRunInfo->win; | 78 | + fmStartAddr += convOps->singleCoreHiStartPos * convTilingData->convRunInfo.win; |
| 77 | } | 79 | } |
| 78 | 80 | ||
| 79 | // Conv2D Split W | 81 | // Conv2D Split W |
| 80 | convOps->singleCoreHiStartPos = hiStartPosTmp; | 82 | convOps->singleCoreHiStartPos = hiStartPosTmp; |
| 81 | if constexpr (CONV::A_FORMAT == ConvFormat::NCHW || CONV::A_FORMAT == ConvFormat::NHWC) { | 83 | if constexpr (CONV::A_FORMAT == ConvFormat::NCHW || CONV::A_FORMAT == ConvFormat::NHWC) { |
| 82 | - int64_t wiStartPosTmp = static_cast<int64_t>(convOps->woIdxStart * convRunInfo->strideW) - | 84 | + int64_t wiStartPosTmp = static_cast<int64_t>(convOps->woIdxStart * convTilingData->convRunInfo.strideW) - |
| 83 | - static_cast<int64_t>(convRunInfo->padLeft); | 85 | + static_cast<int64_t>(convTilingData->convRunInfo.padLeft); |
| 84 | convOps->singleCoreWiStartPos = wiStartPosTmp < 0 ? 0 : wiStartPosTmp; | 86 | convOps->singleCoreWiStartPos = wiStartPosTmp < 0 ? 0 : wiStartPosTmp; |
| 85 | if constexpr (CONV::A_FORMAT == ConvFormat::NHWC) { | 87 | if constexpr (CONV::A_FORMAT == ConvFormat::NHWC) { |
| 86 | - fmStartAddr += convOps->singleCoreWiStartPos * convRunInfo->cin; | 88 | + fmStartAddr += convOps->singleCoreWiStartPos * convTilingData->convRunInfo.cin; |
| 87 | } else { | 89 | } else { |
| 88 | fmStartAddr += convOps->singleCoreWiStartPos; | 90 | fmStartAddr += convOps->singleCoreWiStartPos; |
| 89 | } | 91 | } |
| @@ -92,8 +94,8 @@ __aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | |||
| 92 | } | 94 | } |
| 93 | } | 95 | } |
| 94 | 96 | ||
| 95 | -template <class CONV, class RUN_INFO> | 97 | +template <class CONV, class CONV_TILING> |
| 96 | -__aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | 98 | +__aicore__ __forceinline__ void ConvGroupCommon<CONV, CONV_TILING>:: |
| 97 | CalcStartAddrOriGroupHWC(const uint64_t doIdxStart, const int64_t diIdxStart) | 99 | CalcStartAddrOriGroupHWC(const uint64_t doIdxStart, const int64_t diIdxStart) |
| 98 | { | 100 | { |
| 99 | // fmap: Batch -> Di -> HiWi -> Group -> Ci_perg | 101 | // fmap: Batch -> Di -> HiWi -> Group -> Ci_perg |
| @@ -107,21 +109,21 @@ __aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | |||
| 107 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + | 109 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + |
| 108 | convOps->groupIdxStart * convOps->coPerGroup + convOps->nIdxStart; | 110 | convOps->groupIdxStart * convOps->coPerGroup + convOps->nIdxStart; |
| 109 | if constexpr (CONV::isMMode) { | 111 | if constexpr (CONV::isMMode) { |
| 110 | - outputStartAddr += convOps->mIdxStart * convRunInfo->cout; | 112 | + outputStartAddr += convOps->mIdxStart * convTilingData->convRunInfo.cout; |
| 111 | } else { | 113 | } else { |
| 112 | - outputStartAddr += convOps->hoIdxStart * convRunInfo->wout * convRunInfo->cout; | 114 | + outputStartAddr += convOps->hoIdxStart * convTilingData->convRunInfo.wout * convTilingData->convRunInfo.cout; |
| 113 | if constexpr (CONV::A_FORMAT == ConvFormat::NHWC) { | 115 | if constexpr (CONV::A_FORMAT == ConvFormat::NHWC) { |
| 114 | - outputStartAddr += convOps->woIdxStart * convRunInfo->cout; | 116 | + outputStartAddr += convOps->woIdxStart * convTilingData->convRunInfo.cout; |
| 115 | } | 117 | } |
| 116 | } | 118 | } |
| 117 | if constexpr (CONV::A_FORMAT == ConvFormat::NDHWC) { | 119 | if constexpr (CONV::A_FORMAT == ConvFormat::NDHWC) { |
| 118 | - fmStartAddr += diIdxStart * hwIn * convRunInfo->cin; | 120 | + fmStartAddr += diIdxStart * hwIn * convTilingData->convRunInfo.cin; |
| 119 | - outputStartAddr += doIdxStart * hwOut * convRunInfo->cout; | 121 | + outputStartAddr += doIdxStart * hwOut * convTilingData->convRunInfo.cout; |
| 120 | } | 122 | } |
| 121 | } | 123 | } |
| 122 | 124 | ||
| 123 | -template <class CONV, class RUN_INFO> | 125 | +template <class CONV, class CONV_TILING> |
| 124 | -__aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | 126 | +__aicore__ __forceinline__ void ConvGroupCommon<CONV, CONV_TILING>:: |
| 125 | CalcStartAddrOriGroupCHW(const uint64_t doIdxStart, const int64_t diIdxStart) | 127 | CalcStartAddrOriGroupCHW(const uint64_t doIdxStart, const int64_t diIdxStart) |
| 126 | { | 128 | { |
| 127 | // fmap: Batch -> Group -> Ci_perg -> Di -> HiWi | 129 | // fmap: Batch -> Group -> Ci_perg -> Di -> HiWi |
| @@ -138,7 +140,7 @@ __aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | |||
| 138 | if constexpr (CONV::isMMode) { | 140 | if constexpr (CONV::isMMode) { |
| 139 | outputStartAddr += convOps->mIdxStart; | 141 | outputStartAddr += convOps->mIdxStart; |
| 140 | } else { | 142 | } else { |
| 141 | - outputStartAddr += convOps->hoIdxStart * convRunInfo->wout; | 143 | + outputStartAddr += convOps->hoIdxStart * convTilingData->convRunInfo.wout; |
| 142 | if constexpr (CONV::A_FORMAT == ConvFormat::NCHW) { | 144 | if constexpr (CONV::A_FORMAT == ConvFormat::NCHW) { |
| 143 | outputStartAddr += convOps->woIdxStart; | 145 | outputStartAddr += convOps->woIdxStart; |
| 144 | } | 146 | } |
| @@ -150,17 +152,17 @@ __aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | |||
| 150 | } | 152 | } |
| 151 | } | 153 | } |
| 152 | 154 | ||
| 153 | -template <class CONV, class RUN_INFO> | 155 | +template <class CONV, class CONV_TILING> |
| 154 | -__aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | 156 | +__aicore__ __forceinline__ void ConvGroupCommon<CONV, CONV_TILING>:: |
| 155 | CalcStartAddrOriGroup(const uint64_t din, const uint64_t dout, const uint32_t kd, const uint64_t doIdxStart, | 157 | CalcStartAddrOriGroup(const uint64_t din, const uint64_t dout, const uint32_t kd, const uint64_t doIdxStart, |
| 156 | const int64_t diIdxStart) | 158 | const int64_t diIdxStart) |
| 157 | { | 159 | { |
| 158 | - hwIn = convRunInfo->hin * convRunInfo->win; | 160 | + hwIn = convTilingData->convRunInfo.hin * convTilingData->convRunInfo.win; |
| 159 | - hwOut = convRunInfo->hout * convRunInfo->wout; | 161 | + hwOut = convTilingData->convRunInfo.hout * convTilingData->convRunInfo.wout; |
| 160 | dhwOut = dout * hwOut; | 162 | dhwOut = dout * hwOut; |
| 161 | dhwIn = din * hwIn; | 163 | dhwIn = din * hwIn; |
| 162 | - convOps->fmapOneBatchSize = dhwIn * convRunInfo->cin; | 164 | + convOps->fmapOneBatchSize = dhwIn * convTilingData->convRunInfo.cin; |
| 163 | - convOps->outputOneBatchSize = dhwOut * convRunInfo->cout; | 165 | + convOps->outputOneBatchSize = dhwOut * convTilingData->convRunInfo.cout; |
| 164 | 166 | ||
| 165 | if constexpr (CONV::A_FORMAT == ConvFormat::NDHWC || CONV::A_FORMAT == ConvFormat::NHWC) { | 167 | if constexpr (CONV::A_FORMAT == ConvFormat::NDHWC || CONV::A_FORMAT == ConvFormat::NHWC) { |
| 166 | fmapOneGroupSize = convOps->ciPerGroup; | 168 | fmapOneGroupSize = convOps->ciPerGroup; |
| @@ -169,13 +171,13 @@ __aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | |||
| 169 | CalcStartAddrOriGroupHWC(doIdxStart, diIdxStart); | 171 | CalcStartAddrOriGroupHWC(doIdxStart, diIdxStart); |
| 170 | } else { | 172 | } else { |
| 171 | fmapOneGroupSize = convOps->ciPerGroup * dhwIn; | 173 | fmapOneGroupSize = convOps->ciPerGroup * dhwIn; |
| 172 | - weightOneCoSize = convOps->ciPerGroup * kd * convRunInfo->kh * convRunInfo->kw; | 174 | + weightOneCoSize = convOps->ciPerGroup * kd * convTilingData->convRunInfo.kh * convTilingData->convRunInfo.kw; |
| 173 | weightOneGroupSize = convOps->coPerGroup * weightOneCoSize; | 175 | weightOneGroupSize = convOps->coPerGroup * weightOneCoSize; |
| 174 | outputOneGroupSize = convOps->coPerGroup * dhwOut; | 176 | outputOneGroupSize = convOps->coPerGroup * dhwOut; |
| 175 | CalcStartAddrOriGroupCHW(doIdxStart, diIdxStart); | 177 | CalcStartAddrOriGroupCHW(doIdxStart, diIdxStart); |
| 176 | } | 178 | } |
| 177 | 179 | ||
| 178 | - if (convRunInfo->hasBias) { | 180 | + if (convTilingData->convRunInfo.hasBias) { |
| 179 | biasStartAddr = convOps->groupIdxStart * convOps->coPerGroup + convOps->nIdxStart; | 181 | biasStartAddr = convOps->groupIdxStart * convOps->coPerGroup + convOps->nIdxStart; |
| 180 | } | 182 | } |
| 181 | 183 | ||
| @@ -186,34 +188,38 @@ __aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | |||
| 186 | } | 188 | } |
| 187 | } | 189 | } |
| 188 | 190 | ||
| 189 | -template <class CONV, class RUN_INFO> | 191 | +template <class CONV, class CONV_TILING> |
| 190 | -__aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | 192 | +__aicore__ __forceinline__ void ConvGroupCommon<CONV, CONV_TILING>:: |
| 191 | DealFixpiepParams(uint64_t groupIter, uint64_t coPerGroup) | 193 | DealFixpiepParams(uint64_t groupIter, uint64_t coPerGroup) |
| 192 | { | 194 | { |
| 193 | if constexpr (CONV::isQuant || CONV::IS_EXTEND_CONV2D) { | 195 | if constexpr (CONV::isQuant || CONV::IS_EXTEND_CONV2D) { |
| 194 | if (hasScale) { | 196 | if (hasScale) { |
| 195 | if constexpr (CONV::A_FORMAT == ConvFormat::NCHW || CONV::A_FORMAT == ConvFormat::NHWC) { | 197 | if constexpr (CONV::A_FORMAT == ConvFormat::NCHW || CONV::A_FORMAT == ConvFormat::NHWC) { |
| 196 | Extendconv2dFixpipeParams fixpipeParamsCopy(convOps->fixpipeParams); | 198 | Extendconv2dFixpipeParams fixpipeParamsCopy(convOps->fixpipeParams); |
| 197 | - if (convOps->conv2dApiTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 199 | + if (convOps->convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 198 | fixpipeParamsCopy.scale0 = convOps->fixpipeParams.scale0[groupIter * coPerGroup]; | 200 | fixpipeParamsCopy.scale0 = convOps->fixpipeParams.scale0[groupIter * coPerGroup]; |
| 199 | } | 201 | } |
| 200 | if constexpr (CONV::IS_EXTEND_CONV2D) { | 202 | if constexpr (CONV::IS_EXTEND_CONV2D) { |
| 201 | - if (convOps->dualOutput) { | 203 | + if (convTilingData->convApiTiling.reluMode0 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { |
| 202 | - if (convOps->conv2dApiTiling->quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 204 | + fixpipeParamsCopy.reluWeight0 = convOps->fixpipeParams.reluWeight0[groupIter * coPerGroup]; |
| 205 | + } | ||
| 206 | + if (convTilingData->convApiTiling.dualOutput) { | ||
| 207 | + if (convTilingData->convApiTiling.quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | ||
| 203 | fixpipeParamsCopy.scale1 = convOps->fixpipeParams.scale1[groupIter * coPerGroup]; | 208 | fixpipeParamsCopy.scale1 = convOps->fixpipeParams.scale1[groupIter * coPerGroup]; |
| 204 | } | 209 | } |
| 205 | - } | 210 | + if (convTilingData->convApiTiling.reluMode1 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { |
| 206 | - } | 211 | + fixpipeParamsCopy.reluWeight1 = convOps->fixpipeParams.reluWeight1[groupIter * coPerGroup]; |
| 207 | - if constexpr (CONV::IS_EXTEND_CONV2D) { | 212 | + } |
| 208 | - if (convOps->dualOutput) { | 213 | + if (convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT) || |
| 209 | - if (convOps->conv2dApiTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT) || | 214 | + convTilingData->convApiTiling.quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT) || |
| 210 | - convOps->conv2dApiTiling->quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 215 | + convTilingData->convApiTiling.reluMode0 == static_cast<uint8_t>(ReluMode::VECTOR_RELU) || |
| 216 | + convTilingData->convApiTiling.reluMode1 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { | ||
| 211 | convOps->conv.SetFixpipeParams(fixpipeParamsCopy); | 217 | convOps->conv.SetFixpipeParams(fixpipeParamsCopy); |
| 212 | } | 218 | } |
| 213 | - } else if (convOps->conv2dApiTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 219 | + } else if (convOps->convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 214 | convOps->conv.SetFixpipeParams(fixpipeParamsCopy); | 220 | convOps->conv.SetFixpipeParams(fixpipeParamsCopy); |
| 215 | } | 221 | } |
| 216 | - } else if (convOps->conv2dApiTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 222 | + } else if (convOps->convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 217 | convOps->conv.SetFixpipeParams(fixpipeParamsCopy); | 223 | convOps->conv.SetFixpipeParams(fixpipeParamsCopy); |
| 218 | } | 224 | } |
| 219 | } else { | 225 | } else { |
| @@ -223,21 +229,21 @@ __aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | |||
| 223 | } | 229 | } |
| 224 | } | 230 | } |
| 225 | 231 | ||
| 226 | -template <class CONV, class RUN_INFO> | 232 | +template <class CONV, class CONV_TILING> |
| 227 | -__aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | 233 | +__aicore__ __forceinline__ void ConvGroupCommon<CONV, CONV_TILING>:: |
| 228 | ConvKernelImplOriGroup() | 234 | ConvKernelImplOriGroup() |
| 229 | { | 235 | { |
| 230 | for (uint64_t groupIter = 0; groupIter < convOps->singleGroups; ++groupIter) { | 236 | for (uint64_t groupIter = 0; groupIter < convOps->singleGroups; ++groupIter) { |
| 231 | convOps->conv.SetWeight(convOps->filterGm[groupIter * weightOneGroupSize]); | 237 | convOps->conv.SetWeight(convOps->filterGm[groupIter * weightOneGroupSize]); |
| 232 | convOps->conv.SetFmap(convOps->fmapGm[groupIter * fmapOneGroupSize]); | 238 | convOps->conv.SetFmap(convOps->fmapGm[groupIter * fmapOneGroupSize]); |
| 233 | - if (convRunInfo->hasBias) { | 239 | + if (convTilingData->convRunInfo.hasBias) { |
| 234 | convOps->conv.SetBias(convOps->biasGm[groupIter * convOps->coPerGroup]); | 240 | convOps->conv.SetBias(convOps->biasGm[groupIter * convOps->coPerGroup]); |
| 235 | } | 241 | } |
| 236 | 242 | ||
| 237 | DealFixpiepParams(groupIter, convOps->coPerGroup); | 243 | DealFixpiepParams(groupIter, convOps->coPerGroup); |
| 238 | 244 | ||
| 239 | if constexpr (CONV::IS_EXTEND_CONV2D) { | 245 | if constexpr (CONV::IS_EXTEND_CONV2D) { |
| 240 | - if (convOps->dualOutput) { | 246 | + if (this->convTilingData->convApiTiling.dualOutput) { |
| 241 | convOps->conv.IterateAll(convOps->outputGm[groupIter * outputOneGroupSize], | 247 | convOps->conv.IterateAll(convOps->outputGm[groupIter * outputOneGroupSize], |
| 242 | convOps->output1Gm[groupIter * outputOneGroupSize]); | 248 | convOps->output1Gm[groupIter * outputOneGroupSize]); |
| 243 | } else { | 249 | } else { |
| @@ -250,13 +256,14 @@ __aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | |||
| 250 | } | 256 | } |
| 251 | } | 257 | } |
| 252 | 258 | ||
| 253 | -template <class CONV, class RUN_INFO> | 259 | +template <class CONV, class CONV_TILING> |
| 254 | -__aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | 260 | +__aicore__ __forceinline__ void ConvGroupCommon<CONV, CONV_TILING>:: |
| 255 | UpdateRealCoutOptGroup() | 261 | UpdateRealCoutOptGroup() |
| 256 | { | 262 | { |
| 257 | convOps->singleCoreN = convOps->singleCoOpt; | 263 | convOps->singleCoreN = convOps->singleCoOpt; |
| 258 | 264 | ||
| 259 | - enlargeTail = convRunInfo->groups % convRunInfo->enlarge; | 265 | + // update singleGroups : real groups nums in singlecore |
| 266 | + enlargeTail = convTilingData->convRunInfo.groups % convTilingData->convRunInfo.enlarge; | ||
| 260 | 267 | ||
| 261 | if (unlikely(convOps->isGroupDimTail && enlargeTail != 0)) { | 268 | if (unlikely(convOps->isGroupDimTail && enlargeTail != 0)) { |
| 262 | uint64_t realCout = enlargeTail * convOps->coPerGroup; | 269 | uint64_t realCout = enlargeTail * convOps->coPerGroup; |
| @@ -270,12 +277,12 @@ __aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | |||
| 270 | } | 277 | } |
| 271 | 278 | ||
| 272 | if (unlikely(convOps->isGroupDimTail)) { | 279 | if (unlikely(convOps->isGroupDimTail)) { |
| 273 | - convOps->singleGroups = enlargeTail == 0 ? convRunInfo->enlarge : enlargeTail; | 280 | + convOps->singleGroups = enlargeTail == 0 ? convTilingData->convRunInfo.enlarge : enlargeTail; |
| 274 | } | 281 | } |
| 275 | } | 282 | } |
| 276 | 283 | ||
| 277 | -template <class CONV, class RUN_INFO> | 284 | +template <class CONV, class CONV_TILING> |
| 278 | -__aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | 285 | +__aicore__ __forceinline__ void ConvGroupCommon<CONV, CONV_TILING>:: |
| 279 | CalcStartAddrOptGroupCHW(const uint64_t doIdxStart, const int64_t diIdxStart, const uint32_t kd) | 286 | CalcStartAddrOptGroupCHW(const uint64_t doIdxStart, const int64_t diIdxStart, const uint32_t kd) |
| 280 | { | 287 | { |
| 281 | // fmap: Batch -> Group(enlarge) -> Ci_opt -> Di -> HiWi | 288 | // fmap: Batch -> Group(enlarge) -> Ci_opt -> Di -> HiWi |
| @@ -285,10 +292,10 @@ __aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | |||
| 285 | convOps->groupIdxStart * fmapOneGroupSize; | 292 | convOps->groupIdxStart * fmapOneGroupSize; |
| 286 | CalcStartAddrFmapHW(); | 293 | CalcStartAddrFmapHW(); |
| 287 | if constexpr (CONV::B_FORMAT == ConvFormat::FRACTAL_Z) { | 294 | if constexpr (CONV::B_FORMAT == ConvFormat::FRACTAL_Z) { |
| 288 | - weightOneGroupSize = convRunInfo->coutOpt * convRunInfo->cinOpt * kd * convRunInfo->kh * convRunInfo->kw; | 295 | + weightOneGroupSize = convTilingData->convRunInfo.coutOpt * convTilingData->convRunInfo.cinOpt * kd * convTilingData->convRunInfo.kh * convTilingData->convRunInfo.kw; |
| 289 | weightStartAddr = convOps->groupIdxStart * weightOneGroupSize + convOps->nIdxStart * convOps->k0; | 296 | weightStartAddr = convOps->groupIdxStart * weightOneGroupSize + convOps->nIdxStart * convOps->k0; |
| 290 | } else { | 297 | } else { |
| 291 | - weightOneGroupSize = convRunInfo->coutOpt * convOps->ciPerGroup * kd * convRunInfo->kh * convRunInfo->kw; | 298 | + weightOneGroupSize = convTilingData->convRunInfo.coutOpt * convOps->ciPerGroup * kd * convTilingData->convRunInfo.kh * convTilingData->convRunInfo.kw; |
| 292 | weightStartAddr = convOps->groupIdxStart * weightOneGroupSize; | 299 | weightStartAddr = convOps->groupIdxStart * weightOneGroupSize; |
| 293 | } | 300 | } |
| 294 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + | 301 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + |
| @@ -303,90 +310,94 @@ __aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | |||
| 303 | if constexpr (CONV::isMMode) { | 310 | if constexpr (CONV::isMMode) { |
| 304 | outputStartAddr += convOps->mIdxStart; | 311 | outputStartAddr += convOps->mIdxStart; |
| 305 | } else { | 312 | } else { |
| 306 | - outputStartAddr += convOps->hoIdxStart * convRunInfo->wout; | 313 | + outputStartAddr += convOps->hoIdxStart * convTilingData->convRunInfo.wout; |
| 307 | if constexpr (CONV::A_FORMAT == ConvFormat::NCHW) { | 314 | if constexpr (CONV::A_FORMAT == ConvFormat::NCHW) { |
| 308 | outputStartAddr += convOps->woIdxStart; | 315 | outputStartAddr += convOps->woIdxStart; |
| 309 | } | 316 | } |
| 310 | } | 317 | } |
| 311 | } | 318 | } |
| 312 | 319 | ||
| 313 | -template <class CONV, class RUN_INFO> | 320 | +template <class CONV, class CONV_TILING> |
| 314 | -__aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | 321 | +__aicore__ __forceinline__ void ConvGroupCommon<CONV, CONV_TILING>:: |
| 315 | CalcStartAddrOptGroupHWC(const uint64_t doIdxStart, const int64_t diIdxStart, const uint32_t kd) | 322 | CalcStartAddrOptGroupHWC(const uint64_t doIdxStart, const int64_t diIdxStart, const uint32_t kd) |
| 316 | { | 323 | { |
| 317 | // fmap: Batch -> Di -> HiWi -> Group(enlarge) -> Ci_opt | 324 | // fmap: Batch -> Di -> HiWi -> Group(enlarge) -> Ci_opt |
| 318 | // weight: Kd -> KhKw -> Ci_opt -> Group(enlarge) -> Co_opt | 325 | // weight: Kd -> KhKw -> Ci_opt -> Group(enlarge) -> Co_opt |
| 319 | // output: Batch -> Do -> HoWo -> Group(enlarge) -> Co_opt | 326 | // output: Batch -> Do -> HoWo -> Group(enlarge) -> Co_opt |
| 320 | fmStartAddr = convOps->batchIdxStart * convOps->fmapOneBatchSize + | 327 | fmStartAddr = convOps->batchIdxStart * convOps->fmapOneBatchSize + |
| 321 | - convOps->groupIdxStart * convRunInfo->cinOpt; | 328 | + convOps->groupIdxStart * convTilingData->convRunInfo.cinOpt; |
| 322 | CalcStartAddrFmapHW(); | 329 | CalcStartAddrFmapHW(); |
| 323 | if constexpr (CONV::B_FORMAT == ConvFormat::FRACTAL_Z) { | 330 | if constexpr (CONV::B_FORMAT == ConvFormat::FRACTAL_Z) { |
| 324 | - weightOneGroupSize = convRunInfo->coutOpt * convRunInfo->cinOpt * kd * convRunInfo->kh * convRunInfo->kw; | 331 | + weightOneGroupSize = convTilingData->convRunInfo.coutOpt * convTilingData->convRunInfo.cinOpt * kd * convTilingData->convRunInfo.kh * convTilingData->convRunInfo.kw; |
| 325 | weightStartAddr = convOps->groupIdxStart * weightOneGroupSize + convOps->nIdxStart * convOps->k0; | 332 | weightStartAddr = convOps->groupIdxStart * weightOneGroupSize + convOps->nIdxStart * convOps->k0; |
| 326 | } else { | 333 | } else { |
| 327 | - weightOneGroupSize = convRunInfo->coutOpt; | 334 | + weightOneGroupSize = convTilingData->convRunInfo.coutOpt; |
| 328 | - weightStartAddr = convOps->groupIdxStart * convRunInfo->coutOpt; | 335 | + weightStartAddr = convOps->groupIdxStart * convTilingData->convRunInfo.coutOpt; |
| 329 | } | 336 | } |
| 330 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + | 337 | outputStartAddr = convOps->batchIdxStart * convOps->outputOneBatchSize + |
| 331 | - convOps->groupIdxStart * convRunInfo->coutOpt + | 338 | + convOps->groupIdxStart * convTilingData->convRunInfo.coutOpt + |
| 332 | convOps->nIdxStart; | 339 | convOps->nIdxStart; |
| 333 | 340 | ||
| 334 | if constexpr (CONV::A_FORMAT == ConvFormat::NDHWC) { | 341 | if constexpr (CONV::A_FORMAT == ConvFormat::NDHWC) { |
| 335 | - fmStartAddr += diIdxStart * hwIn * convRunInfo->cin; | 342 | + fmStartAddr += diIdxStart * hwIn * convTilingData->convRunInfo.cin; |
| 336 | - outputStartAddr += doIdxStart * hwOut * convRunInfo->cout; | 343 | + outputStartAddr += doIdxStart * hwOut * convTilingData->convRunInfo.cout; |
| 337 | } | 344 | } |
| 338 | 345 | ||
| 339 | if constexpr (CONV::isMMode) { | 346 | if constexpr (CONV::isMMode) { |
| 340 | - outputStartAddr += convOps->mIdxStart * convRunInfo->cout; | 347 | + outputStartAddr += convOps->mIdxStart * convTilingData->convRunInfo.cout; |
| 341 | } else { | 348 | } else { |
| 342 | - outputStartAddr += convOps->hoIdxStart * convRunInfo->wout * convRunInfo->cout; | 349 | + outputStartAddr += convOps->hoIdxStart * convTilingData->convRunInfo.wout * convTilingData->convRunInfo.cout; |
| 343 | if constexpr (CONV::A_FORMAT == ConvFormat::NHWC) { | 350 | if constexpr (CONV::A_FORMAT == ConvFormat::NHWC) { |
| 344 | - outputStartAddr += convOps->woIdxStart * convRunInfo->cout; | 351 | + outputStartAddr += convOps->woIdxStart * convTilingData->convRunInfo.cout; |
| 345 | } | 352 | } |
| 346 | } | 353 | } |
| 347 | } | 354 | } |
| 348 | 355 | ||
| 349 | -template <class CONV, class RUN_INFO> | 356 | +template <class CONV, class CONV_TILING> |
| 350 | -__aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | 357 | +__aicore__ __forceinline__ void ConvGroupCommon<CONV, CONV_TILING>:: |
| 351 | CalcStartAddrOptGroup(const uint64_t din, const uint64_t dout, const uint32_t kd, const uint64_t doIdxStart, | 358 | CalcStartAddrOptGroup(const uint64_t din, const uint64_t dout, const uint32_t kd, const uint64_t doIdxStart, |
| 352 | const int64_t diIdxStart) | 359 | const int64_t diIdxStart) |
| 353 | { | 360 | { |
| 354 | - hwIn = convRunInfo->hin * convRunInfo->win; | 361 | + hwIn = convTilingData->convRunInfo.hin * convTilingData->convRunInfo.win; |
| 355 | - hwOut = convRunInfo->hout * convRunInfo->wout; | 362 | + hwOut = convTilingData->convRunInfo.hout * convTilingData->convRunInfo.wout; |
| 356 | dhwOut = dout * hwOut; | 363 | dhwOut = dout * hwOut; |
| 357 | dhwIn = din * hwIn; | 364 | dhwIn = din * hwIn; |
| 358 | - convOps->fmapOneBatchSize = convRunInfo->cin * dhwIn; | 365 | + convOps->fmapOneBatchSize = convTilingData->convRunInfo.cin * dhwIn; |
| 359 | - convOps->outputOneBatchSize = convRunInfo->cout * dhwOut; | 366 | + convOps->outputOneBatchSize = convTilingData->convRunInfo.cout * dhwOut; |
| 360 | if constexpr (CONV::A_FORMAT == ConvFormat::NDHWC || CONV::A_FORMAT == ConvFormat::NHWC) { | 367 | if constexpr (CONV::A_FORMAT == ConvFormat::NDHWC || CONV::A_FORMAT == ConvFormat::NHWC) { |
| 361 | - fmapOneGroupSize = convRunInfo->cinOpt; | 368 | + fmapOneGroupSize = convTilingData->convRunInfo.cinOpt; |
| 362 | - outputOneGroupSize = convRunInfo->coutOpt; | 369 | + outputOneGroupSize = convTilingData->convRunInfo.coutOpt; |
| 363 | CalcStartAddrOptGroupHWC(doIdxStart, diIdxStart, kd); | 370 | CalcStartAddrOptGroupHWC(doIdxStart, diIdxStart, kd); |
| 364 | } else { | 371 | } else { |
| 365 | - fmapOneGroupSize = convRunInfo->cinOpt * dhwIn; | 372 | + fmapOneGroupSize = convTilingData->convRunInfo.cinOpt * dhwIn; |
| 366 | - outputOneGroupSize = convRunInfo->coutOpt * dhwOut; | 373 | + outputOneGroupSize = convTilingData->convRunInfo.coutOpt * dhwOut; |
| 367 | CalcStartAddrOptGroupCHW(doIdxStart, diIdxStart, kd); | 374 | CalcStartAddrOptGroupCHW(doIdxStart, diIdxStart, kd); |
| 368 | } | 375 | } |
| 369 | 376 | ||
| 370 | - if (convRunInfo->hasBias) { | 377 | + if (convTilingData->convRunInfo.hasBias) { |
| 371 | - biasStartAddr = convOps->groupIdxStart * convRunInfo->coutOpt + convOps->nIdxStart; | 378 | + biasStartAddr = convOps->groupIdxStart * convTilingData->convRunInfo.coutOpt + convOps->nIdxStart; |
| 372 | } | 379 | } |
| 373 | 380 | ||
| 374 | if constexpr (CONV::isQuant) { | 381 | if constexpr (CONV::isQuant) { |
| 375 | if (hasScale) { | 382 | if (hasScale) { |
| 376 | - scaleStartAddr = convOps->groupIdxStart * convRunInfo->coutOpt + convOps->nIdxStart; | 383 | + scaleStartAddr = convOps->groupIdxStart * convTilingData->convRunInfo.coutOpt + convOps->nIdxStart; |
| 377 | } | 384 | } |
| 378 | } | 385 | } |
| 379 | 386 | ||
| 380 | if constexpr (CONV::IS_EXTEND_CONV2D) { | 387 | if constexpr (CONV::IS_EXTEND_CONV2D) { |
| 381 | - if (convOps->conv2dApiTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT) || | 388 | + if (convOps->convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT) || |
| 382 | - convOps->conv2dApiTiling->quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 389 | + convOps->convTilingData->convApiTiling.quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 383 | - scaleStartAddr = convOps->groupIdxStart * convRunInfo->coutOpt + convOps->nIdxStart; | 390 | + scaleStartAddr = convOps->groupIdxStart * convTilingData->convRunInfo.coutOpt + convOps->nIdxStart; |
| 391 | + } | ||
| 392 | + if (convTilingData->convApiTiling.reluMode0 == static_cast<uint8_t>(ReluMode::VECTOR_RELU) || | ||
| 393 | + convTilingData->convApiTiling.reluMode1 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { | ||
| 394 | + reluWeightStartAddr = convOps->groupIdxStart * convTilingData->convRunInfo.coutOpt + convOps->nIdxStart; | ||
| 384 | } | 395 | } |
| 385 | } | 396 | } |
| 386 | } | 397 | } |
| 387 | 398 | ||
| 388 | -template <class CONV, class RUN_INFO> | 399 | +template <class CONV, class CONV_TILING> |
| 389 | -__aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | 400 | +__aicore__ __forceinline__ void ConvGroupCommon<CONV, CONV_TILING>:: |
| 390 | ConvKernelImplOptGroup() | 401 | ConvKernelImplOptGroup() |
| 391 | { | 402 | { |
| 392 | convOps->conv.SetWeightStartPosition(convOps->nIdxStart); | 403 | convOps->conv.SetWeightStartPosition(convOps->nIdxStart); |
| @@ -408,14 +419,14 @@ __aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | |||
| 408 | convOps->conv.SetFmap(convOps->fmapGm[groupOptIter * fmapOneGroupSize]); | 419 | convOps->conv.SetFmap(convOps->fmapGm[groupOptIter * fmapOneGroupSize]); |
| 409 | convOps->conv.SetWeight(convOps->filterGm[groupOptIter * weightOneGroupSize]); | 420 | convOps->conv.SetWeight(convOps->filterGm[groupOptIter * weightOneGroupSize]); |
| 410 | 421 | ||
| 411 | - if (convRunInfo->hasBias) { | 422 | + if (convTilingData->convRunInfo.hasBias) { |
| 412 | - convOps->conv.SetBias(convOps->biasGm[groupOptIter * convRunInfo->coutOpt]); | 423 | + convOps->conv.SetBias(convOps->biasGm[groupOptIter * convTilingData->convRunInfo.coutOpt]); |
| 413 | } | 424 | } |
| 414 | 425 | ||
| 415 | - DealFixpiepParams(groupOptIter, convRunInfo->coutOpt); | 426 | + DealFixpiepParams(groupOptIter, convTilingData->convRunInfo.coutOpt); |
| 416 | 427 | ||
| 417 | if constexpr (CONV::IS_EXTEND_CONV2D) { | 428 | if constexpr (CONV::IS_EXTEND_CONV2D) { |
| 418 | - if (convOps->dualOutput) { | 429 | + if (this->convTilingData->convApiTiling.dualOutput) { |
| 419 | convOps->conv.IterateAll(convOps->outputGm[groupOptIter * outputOneGroupSize], | 430 | convOps->conv.IterateAll(convOps->outputGm[groupOptIter * outputOneGroupSize], |
| 420 | convOps->output1Gm[groupOptIter * outputOneGroupSize]); | 431 | convOps->output1Gm[groupOptIter * outputOneGroupSize]); |
| 421 | } else { | 432 | } else { |
| @@ -428,8 +439,8 @@ __aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | |||
| 428 | } | 439 | } |
| 429 | } | 440 | } |
| 430 | 441 | ||
| 431 | -template <class CONV, class RUN_INFO> | 442 | +template <class CONV, class CONV_TILING> |
| 432 | -__aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | 443 | +__aicore__ __forceinline__ void ConvGroupCommon<CONV, CONV_TILING>:: |
| 433 | ConvKernelImplOptGroupPreload() | 444 | ConvKernelImplOptGroupPreload() |
| 434 | { | 445 | { |
| 435 | uint64_t groupOptIter = 0; | 446 | uint64_t groupOptIter = 0; |
| @@ -440,7 +451,7 @@ __aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | |||
| 440 | } | 451 | } |
| 441 | convOps->conv.SetOptGroupParams(enlargeTail, convOps->singleGroupOpt, convOps->singleCoOpt); | 452 | convOps->conv.SetOptGroupParams(enlargeTail, convOps->singleGroupOpt, convOps->singleCoOpt); |
| 442 | } else { | 453 | } else { |
| 443 | - convOps->conv.SetOptGroupParams(convRunInfo->enlarge, convOps->singleGroupOpt, convOps->singleCoOpt); | 454 | + convOps->conv.SetOptGroupParams(convTilingData->convRunInfo.enlarge, convOps->singleGroupOpt, convOps->singleCoOpt); |
| 444 | } | 455 | } |
| 445 | 456 | ||
| 446 | convOps->conv.SetIterIndex(groupOptIter); | 457 | convOps->conv.SetIterIndex(groupOptIter); |
| @@ -448,12 +459,12 @@ __aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | |||
| 448 | convOps->conv.SetFmap(convOps->fmapGm); | 459 | convOps->conv.SetFmap(convOps->fmapGm); |
| 449 | convOps->conv.SetWeight(convOps->filterGm); | 460 | convOps->conv.SetWeight(convOps->filterGm); |
| 450 | 461 | ||
| 451 | - if (convRunInfo->hasBias) { | 462 | + if (convTilingData->convRunInfo.hasBias) { |
| 452 | convOps->conv.SetBias(convOps->biasGm); | 463 | convOps->conv.SetBias(convOps->biasGm); |
| 453 | } | 464 | } |
| 454 | 465 | ||
| 455 | // quant need, current not care | 466 | // quant need, current not care |
| 456 | - DealFixpiepParams(groupOptIter, convRunInfo->coutOpt); | 467 | + DealFixpiepParams(groupOptIter, convTilingData->convRunInfo.coutOpt); |
| 457 | 468 | ||
| 458 | if constexpr (CONV::IS_EXTEND_CONV2D) { | 469 | if constexpr (CONV::IS_EXTEND_CONV2D) { |
| 459 | if (convOps->dualOutput) { | 470 | if (convOps->dualOutput) { |
| @@ -467,8 +478,8 @@ __aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | |||
| 467 | convOps->conv.End(); | 478 | convOps->conv.End(); |
| 468 | } | 479 | } |
| 469 | 480 | ||
| 470 | -template <class CONV, class RUN_INFO> | 481 | +template <class CONV, class CONV_TILING> |
| 471 | -__aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | 482 | +__aicore__ __forceinline__ void ConvGroupCommon<CONV, CONV_TILING>:: |
| 472 | SetOptGroupTail() | 483 | SetOptGroupTail() |
| 473 | { | 484 | { |
| 474 | if (convOps->singleCoOpt != convOps->singleCoreN) { | 485 | if (convOps->singleCoOpt != convOps->singleCoreN) { |
| @@ -478,7 +489,7 @@ __aicore__ __forceinline__ void ConvGroupCommon<CONV, RUN_INFO>:: | |||
| 478 | convOps->singleCoreBatch); | 489 | convOps->singleCoreBatch); |
| 479 | } else { | 490 | } else { |
| 480 | convOps->conv.SetSingleOutputShape(convOps->singleCoOpt, convOps->singleCoreDout, convOps->singleCoreHo, | 491 | convOps->conv.SetSingleOutputShape(convOps->singleCoOpt, convOps->singleCoreDout, convOps->singleCoreHo, |
| 481 | - convRunInfo->wout, convOps->singleCoreBatch); | 492 | + convTilingData->convRunInfo.wout, convOps->singleCoreBatch); |
| 482 | } | 493 | } |
| 483 | } else { | 494 | } else { |
| 484 | if constexpr (CONV::isMMode) { | 495 | if constexpr (CONV::isMMode) { |
| @@ -32,24 +32,32 @@ public: | |||
| 32 | self_ = self; | 32 | self_ = self; |
| 33 | if constexpr (Intf::isConv3D) { | 33 | if constexpr (Intf::isConv3D) { |
| 34 | if constexpr (Intf::kPreLoadFlag) { | 34 | if constexpr (Intf::kPreLoadFlag) { |
| 35 | - channelSize_ = self_->ctx.kAL1Iter - 1 != self_->ctx.maxKAL1Iter ? self_->ctx.convTiling->cinAInCore : | 35 | + channelSize_ = self_->ctx.kAL1Iter - 1 != self_->ctx.maxKAL1Iter ? self_->ctx.convTilingData->convApiTiling.cinAInCore : |
| 36 | - self_->ctx.convTiling->cinATailInCore; | 36 | + self_->ctx.convTilingData->convApiTiling.cinATailInCore; |
| 37 | } else { | 37 | } else { |
| 38 | - channelSize_ = self_->ctx.kAL1Iter != self_->ctx.maxKAL1Iter ? self_->ctx.convTiling->cinAInCore : | 38 | + channelSize_ = self_->ctx.kAL1Iter != self_->ctx.maxKAL1Iter ? self_->ctx.convTilingData->convApiTiling.cinAInCore : |
| 39 | - self_->ctx.convTiling->cinATailInCore; | 39 | + self_->ctx.convTilingData->convApiTiling.cinATailInCore; |
| 40 | } | 40 | } |
| 41 | } else { | 41 | } else { |
| 42 | if constexpr (Intf::c04Flag) { | 42 | if constexpr (Intf::c04Flag) { |
| 43 | channelSize_ = conv::C04_CIN_SIZE; | 43 | channelSize_ = conv::C04_CIN_SIZE; |
| 44 | - c04KStepTail = (channelSize_ * self_->ctx.convTiling->kernelHxkernelW) % self_->ctx.convTiling->kL0; | 44 | + c04KStepTail = (channelSize_ * self_->ctx.convTilingData->convApiTiling.kernelHxkernelW) % self_->ctx.convTilingData->convApiTiling.kL0; |
| 45 | - c04KStepTail = c04KStepTail == 0 ? self_->ctx.convTiling->kL0 : c04KStepTail; | 45 | + c04KStepTail = c04KStepTail == 0 ? self_->ctx.convTilingData->convApiTiling.kL0 : c04KStepTail; |
| 46 | } else { | 46 | } else { |
| 47 | if constexpr (Intf::kPreLoadFlag) { | 47 | if constexpr (Intf::kPreLoadFlag) { |
| 48 | - channelSize_ = self_->ctx.kAL1Iter - 1 != self_->ctx.maxKAL1Iter ? | 48 | + if constexpr (Intf::isKL1NL0FullLoad) { |
| 49 | - self_->ctx.convTiling->cinAInCore : AlignB(self_->ctx.convTiling->cinATailInCore, Intf::k0); | 49 | + channelSize_ = AlignB(self_->ctx.convTilingData->convApiTiling.cinATailInCore, Intf::k0); |
| 50 | + } else { | ||
| 51 | + channelSize_ = self_->ctx.kAL1Iter - 1 != self_->ctx.maxKAL1Iter ? | ||
| 52 | + self_->ctx.convTilingData->convApiTiling.cinAInCore : AlignB(self_->ctx.convTilingData->convApiTiling.cinATailInCore, Intf::k0); | ||
| 53 | + } | ||
| 50 | } else { | 54 | } else { |
| 51 | - channelSize_ = self_->ctx.kAL1Iter != self_->ctx.maxKAL1Iter ? | 55 | + if constexpr (Intf::isKL1NL0FullLoad) { |
| 52 | - self_->ctx.convTiling->cinAInCore : AlignB(self_->ctx.convTiling->cinATailInCore, Intf::k0); | 56 | + channelSize_ = AlignB(self_->ctx.convTilingData->convApiTiling.cinATailInCore, Intf::k0); |
| 57 | + } else { | ||
| 58 | + channelSize_ = self_->ctx.kAL1Iter != self_->ctx.maxKAL1Iter ? | ||
| 59 | + self_->ctx.convTilingData->convApiTiling.cinAInCore : AlignB(self_->ctx.convTilingData->convApiTiling.cinATailInCore, Intf::k0); | ||
| 60 | + } | ||
| 53 | } | 61 | } |
| 54 | } | 62 | } |
| 55 | } | 63 | } |
| @@ -60,8 +68,8 @@ public: | |||
| 60 | currentML0_ = m; | 68 | currentML0_ = m; |
| 61 | if constexpr (!Intf::isDmaFlag) { | 69 | if constexpr (!Intf::isDmaFlag) { |
| 62 | currentML0Align_ = mNotAlign; | 70 | currentML0Align_ = mNotAlign; |
| 63 | - mStartPt_ = self_->ctx.hoL0Iter * self_->ctx.currentWoL1 * self_->ctx.convTiling->hoL0 + | 71 | + mStartPt_ = self_->ctx.hoL0Iter * self_->ctx.currentWoL1 * self_->ctx.convTilingData->convApiTiling.hoL0 + |
| 64 | - self_->ctx.woL0Iter * self_->ctx.convTiling->woL0; | 72 | + self_->ctx.woL0Iter * self_->ctx.convTilingData->convApiTiling.woL0; |
| 65 | SetLoad3dRepeatParams(); | 73 | SetLoad3dRepeatParams(); |
| 66 | } | 74 | } |
| 67 | } | 75 | } |
| @@ -74,14 +82,14 @@ public: | |||
| 74 | uint8_t repeatMode = 0; | 82 | uint8_t repeatMode = 0; |
| 75 | mExtension_ = currentML0Align_; | 83 | mExtension_ = currentML0Align_; |
| 76 | 84 | ||
| 77 | - if (self_->ctx.currentWoL0 == self_->ctx.convTiling->woL0 && | 85 | + if (self_->ctx.currentWoL0 == self_->ctx.convTilingData->convApiTiling.woL0 && |
| 78 | - self_->ctx.currentHoL0 == self_->ctx.convTiling->hoL0) { | 86 | + self_->ctx.currentHoL0 == self_->ctx.convTilingData->convApiTiling.hoL0) { |
| 79 | - dstStride = self_->ctx.convTiling->fmapKStride; | 87 | + dstStride = self_->ctx.convTilingData->convApiTiling.fmapKStride; |
| 80 | } else { | 88 | } else { |
| 81 | dstStride = currentML0_ / BLOCK_L0_M; | 89 | dstStride = currentML0_ / BLOCK_L0_M; |
| 82 | } | 90 | } |
| 83 | 91 | ||
| 84 | - if (unlikely(CeilDiv(self_->ctx.currentWoL1, self_->ctx.convTiling->woL0) > 1)) { | 92 | + if (unlikely(CeilDiv(self_->ctx.currentWoL1, self_->ctx.convTilingData->convApiTiling.woL0) > 1)) { |
| 85 | mExtension_ = self_->ctx.currentWoL0; | 93 | mExtension_ = self_->ctx.currentWoL0; |
| 86 | repeatStride = self_->ctx.currentWoL1 / BLOCK_L0_M; | 94 | repeatStride = self_->ctx.currentWoL1 / BLOCK_L0_M; |
| 87 | repeatTime = self_->ctx.currentHoL0; | 95 | repeatTime = self_->ctx.currentHoL0; |
| @@ -91,70 +99,63 @@ public: | |||
| 91 | SetLoadDataRepeatWithStride(repeatParams); | 99 | SetLoadDataRepeatWithStride(repeatParams); |
| 92 | } | 100 | } |
| 93 | 101 | ||
| 94 | - __aicore__ inline void LoadAL0(bool isFirst = true) | 102 | + __aicore__ inline void SetFirst() |
| 103 | + { | ||
| 104 | + xm_.bf.mExtension_ = mExtension_ & MASK_16; | ||
| 105 | + xm_.bf.mStartPt_ = mStartPt_ & MASK_16; | ||
| 106 | + | ||
| 107 | + xt_.n = static_cast<uint64_t>(self_->ctx.convTilingData->convApiTiling.unionDataXt); | ||
| 108 | + xt_.bf.channelSize = channelSize_; | ||
| 109 | + param_.SetConfig1(xt_.n); | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + __aicore__ inline uint64_t GetC04KStepTail() | ||
| 113 | + { | ||
| 114 | + return c04KStepTail; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + __aicore__ inline void LoadAL0(const uint64_t ¤tKL0, const uint64_t &posK, const uint64_t &kIter, const LocalTensor<typename Intf::FmapT> &al0) | ||
| 95 | { | 118 | { |
| 96 | if ASCEND_IS_AIV { | 119 | if ASCEND_IS_AIV { |
| 97 | return; | 120 | return; |
| 98 | } | 121 | } |
| 99 | if constexpr (Intf::isDmaFlag) { | 122 | if constexpr (Intf::isDmaFlag) { |
| 100 | - DmaLoad2DImpl(); | 123 | + DmaLoad2DImpl(kIter, al0); |
| 101 | return; | 124 | return; |
| 102 | } else { | 125 | } else { |
| 103 | - uint64_t currentKL0 = 0; | 126 | + xm_.bf.currentKL0 = currentKL0 & MASK_16; |
| 104 | - if constexpr (Intf::c04Flag) { | 127 | + xm_.bf.posK = posK & MASK_16; |
| 105 | - currentKL0 = IsKL0Tail() ? c04KStepTail : self_->ctx.convTiling->kL0; | 128 | + param_.SetConfig0(xm_.n); |
| 106 | - } else { | 129 | + |
| 107 | - if constexpr (Intf::k0 == Intf::k0FmapTail) { | 130 | + LoadData<TPosition::A2, TPosition::A1, typename Intf::FmapT>(al0, self_->ctx.al1, param_); |
| 108 | - currentKL0 = IsKL0Tail() ? self_->ctx.kL0Tail : self_->ctx.convTiling->kL0; | ||
| 109 | - } else { | ||
| 110 | - currentKL0 = IsKL0Tail() ? self_->ctx.kAL0Tail : self_->ctx.convTiling->kL0; | ||
| 111 | - } | ||
| 112 | - } | ||
| 113 | - uint64_t posK = self_->ctx.kAL0Iter * self_->ctx.convTiling->kL0; | ||
| 114 | - if (isFirst) { | ||
| 115 | - xmtmp_ = ((mExtension_ & MASK_16) << MSTEP_OFFSET) | ((mStartPt_ & MASK_16) << POSM_OFFSET); | ||
| 116 | - xt_ = ((static_cast<uint64_t>(self_->ctx.convTiling->strideW) & MASK_6) << 0) | | ||
| 117 | - ((static_cast<uint64_t>(self_->ctx.convTiling->strideH) & MASK_6) << STRIDEH_OFFSET) | | ||
| 118 | - ((static_cast<uint64_t>(self_->ctx.kernelW) & MASK_8) << KERNELW_OFFSET) | | ||
| 119 | - ((static_cast<uint64_t>(self_->ctx.kernelW) & NINTH_BIT_MASK) << KERNELW_HIGHEST_BIT_OFFSET) | | ||
| 120 | - ((static_cast<uint64_t>(self_->ctx.kernelH) & MASK_8) << KERNELH_OFFSET) | | ||
| 121 | - ((static_cast<uint64_t>(self_->ctx.kernelH) & NINTH_BIT_MASK) << KERNELH_HIGHEST_BIT_OFFSET) | | ||
| 122 | - ((static_cast<uint64_t>(self_->ctx.convTiling->dilationW) & MASK_8) << DILATIONW_OFFSET) | | ||
| 123 | - ((static_cast<uint64_t>(self_->ctx.convTiling->dilationH) & MASK_8) << DILATIONH_OFFSET) | | ||
| 124 | - ((static_cast<uint64_t>(channelSize_) & MASK_16) << CIN_OFFSET); | ||
| 125 | - param_.SetConfig1(xt_); | ||
| 126 | - } | ||
| 127 | - xm_ = ((currentKL0 & MASK_16) << 0) | ((posK & MASK_16) << POSK_OFFSET) | xmtmp_; | ||
| 128 | - param_.SetConfig0(xm_); | ||
| 129 | - LoadData<TPosition::A2, TPosition::A1, typename Intf::FmapT>(self_->ctx.al0, self_->ctx.al1, param_); | ||
| 130 | } | 131 | } |
| 131 | }; | 132 | }; |
| 132 | 133 | ||
| 133 | private: | 134 | private: |
| 134 | - __aicore__ inline bool IsKL0Tail() | 135 | + __aicore__ inline bool IsKL0Tail(const uint64_t &kIter) |
| 135 | { | 136 | { |
| 136 | - return self_->ctx.kIter == self_->ctx.maxKL0Iter; | 137 | + return kIter == self_->ctx.maxKL0Iter; |
| 137 | } | 138 | } |
| 138 | 139 | ||
| 139 | - __aicore__ inline void DmaLoad2DImpl() | 140 | + __aicore__ inline void DmaLoad2DImpl(const uint64_t &kIter, const LocalTensor<typename Intf::FmapT> &al0) |
| 140 | { | 141 | { |
| 141 | uint64_t currentWoL1Align = AlignB(self_->ctx.currentWoL1, BLOCK_L0_M); | 142 | uint64_t currentWoL1Align = AlignB(self_->ctx.currentWoL1, BLOCK_L0_M); |
| 142 | - uint64_t currentKL0 = IsKL0Tail() ? self_->ctx.kL0Tail : self_->ctx.convTiling->kL0; | 143 | + uint64_t currentKL0 = IsKL0Tail(kIter) ? self_->ctx.kL0Tail : self_->ctx.convTilingData->convApiTiling.kL0; |
| 143 | 144 | ||
| 144 | LoadData2DParamsV2 loadParams; | 145 | LoadData2DParamsV2 loadParams; |
| 145 | - loadParams.kStartPosition = self_->ctx.kAL0Iter * self_->ctx.convTiling->kL0 / Intf::k0; | 146 | + loadParams.kStartPosition = (kIter % self_->ctx.multiKAL1) * self_->ctx.convTilingData->convApiTiling.kL0 / Intf::k0; |
| 146 | loadParams.mStep = CeilDiv(self_->ctx.currentWoL0, BLOCK_L0_M); | 147 | loadParams.mStep = CeilDiv(self_->ctx.currentWoL0, BLOCK_L0_M); |
| 147 | loadParams.kStep = currentKL0 / Intf::k0; | 148 | loadParams.kStep = currentKL0 / Intf::k0; |
| 148 | loadParams.srcStride = self_->ctx.currentHoL1 * currentWoL1Align / BLOCK_L0_M; | 149 | loadParams.srcStride = self_->ctx.currentHoL1 * currentWoL1Align / BLOCK_L0_M; |
| 149 | loadParams.dstStride = currentML0_ / BLOCK_L0_M; | 150 | loadParams.dstStride = currentML0_ / BLOCK_L0_M; |
| 150 | 151 | ||
| 151 | - uint32_t mStartPosition = self_->ctx.hoL0Iter * self_->ctx.convTiling->hoL0 * currentWoL1Align + | 152 | + uint32_t mStartPosition = self_->ctx.hoL0Iter * self_->ctx.convTilingData->convApiTiling.hoL0 * currentWoL1Align + |
| 152 | - self_->ctx.woL0Iter * self_->ctx.convTiling->woL0; | 153 | + self_->ctx.woL0Iter * self_->ctx.convTilingData->convApiTiling.woL0; |
| 153 | uint32_t dstOffset = 0; | 154 | uint32_t dstOffset = 0; |
| 154 | uint32_t dstOffsetStride = AlignB(self_->ctx.currentWoL0, BLOCK_L0_M) * Intf::k0; | 155 | uint32_t dstOffsetStride = AlignB(self_->ctx.currentWoL0, BLOCK_L0_M) * Intf::k0; |
| 155 | for (uint16_t hoL0Idx = 0; hoL0Idx < self_->ctx.currentHoL0; ++ hoL0Idx) { | 156 | for (uint16_t hoL0Idx = 0; hoL0Idx < self_->ctx.currentHoL0; ++ hoL0Idx) { |
| 156 | loadParams.mStartPosition = mStartPosition / BLOCK_L0_M; | 157 | loadParams.mStartPosition = mStartPosition / BLOCK_L0_M; |
| 157 | - LoadData<typename Intf::FmapT>(self_->ctx.al0[dstOffset], self_->ctx.al1, loadParams); | 158 | + LoadData<typename Intf::FmapT>(al0[dstOffset], self_->ctx.al1, loadParams); |
| 158 | mStartPosition += currentWoL1Align; | 159 | mStartPosition += currentWoL1Align; |
| 159 | dstOffset += dstOffsetStride; | 160 | dstOffset += dstOffsetStride; |
| 160 | } | 161 | } |
| @@ -168,10 +169,9 @@ private: | |||
| 168 | uint16_t mStartPt_ = 0; | 169 | uint16_t mStartPt_ = 0; |
| 169 | uint16_t channelSize_ = 0; | 170 | uint16_t channelSize_ = 0; |
| 170 | uint64_t c04KStepTail = 0; | 171 | uint64_t c04KStepTail = 0; |
| 171 | - uint64_t xm_ = 0; | ||
| 172 | - uint64_t xt_ = 0; | ||
| 173 | - uint64_t xmtmp_ = 0; | ||
| 174 | Load3DBitModeParam param_; | 172 | Load3DBitModeParam param_; |
| 173 | + UnionDataXt xt_; | ||
| 174 | + UnionDataXm xm_; | ||
| 175 | }; | 175 | }; |
| 176 | 176 | ||
| 177 | template <class Intf, typename OutputT, uint64_t FixpipeIdx = 0> | 177 | template <class Intf, typename OutputT, uint64_t FixpipeIdx = 0> |
| @@ -181,7 +181,7 @@ public: | |||
| 181 | __aicore__ inline void SetParams(Intf *self) | 181 | __aicore__ inline void SetParams(Intf *self) |
| 182 | { | 182 | { |
| 183 | self_ = self; | 183 | self_ = self; |
| 184 | - valueHoWo_ = self_->ctx.orgHo * self_->ctx.orgWo; | 184 | + valueHoWo_ = self_->ctx.convTilingData->convApiTiling.orgHo * self_->ctx.convTilingData->convApiTiling.orgWo; |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | __aicore__ inline void SetMN(uint64_t m, uint64_t n) | 187 | __aicore__ inline void SetMN(uint64_t m, uint64_t n) |
| @@ -198,7 +198,7 @@ public: | |||
| 198 | intriParams.params.dnNum = self_->ctx.currentHoL0; | 198 | intriParams.params.dnNum = self_->ctx.currentHoL0; |
| 199 | intriParams.params.dstDnMatrixStride = self_->ctx.singleCoreWo; | 199 | intriParams.params.dstDnMatrixStride = self_->ctx.singleCoreWo; |
| 200 | } else { | 200 | } else { |
| 201 | - if (likely(self_->ctx.convTiling->woL0 >= self_->ctx.singleCoreWo)) { | 201 | + if (likely(self_->ctx.convTilingData->convApiTiling.woL0 >= self_->ctx.singleCoreWo)) { |
| 202 | intriParams.mSize = currentML0_; | 202 | intriParams.mSize = currentML0_; |
| 203 | intriParams.params.srcNzMatrixStride = 0; | 203 | intriParams.params.srcNzMatrixStride = 0; |
| 204 | intriParams.params.dnNum = 1; | 204 | intriParams.params.dnNum = 1; |
| @@ -214,7 +214,7 @@ public: | |||
| 214 | intriParams.nSize = currentNL0_; | 214 | intriParams.nSize = currentNL0_; |
| 215 | intriParams.srcStride = AlignB(currentML0_, BLOCK_L0_M); | 215 | intriParams.srcStride = AlignB(currentML0_, BLOCK_L0_M); |
| 216 | if constexpr (Intf::formatOutput == ConvFormat::NCDHW) { | 216 | if constexpr (Intf::formatOutput == ConvFormat::NCDHW) { |
| 217 | - intriParams.dstStride = self_->ctx.orgDo * valueHoWo_; | 217 | + intriParams.dstStride = self_->ctx.convTilingData->convApiTiling.orgDo * valueHoWo_; |
| 218 | } else { | 218 | } else { |
| 219 | intriParams.dstStride = valueHoWo_; | 219 | intriParams.dstStride = valueHoWo_; |
| 220 | } | 220 | } |
| @@ -228,8 +228,8 @@ public: | |||
| 228 | intriParams.mSize = self_->ctx.currentWoL0; | 228 | intriParams.mSize = self_->ctx.currentWoL0; |
| 229 | intriParams.params.srcNdStride = AlignB(self_->ctx.currentWoL0, BLOCK_L0_M); | 229 | intriParams.params.srcNdStride = AlignB(self_->ctx.currentWoL0, BLOCK_L0_M); |
| 230 | intriParams.params.ndNum = self_->ctx.currentHoL0; | 230 | intriParams.params.ndNum = self_->ctx.currentHoL0; |
| 231 | - intriParams.params.dstNdStride = self_->ctx.singleCoreWo * self_->ctx.orgCo; | 231 | + intriParams.params.dstNdStride = self_->ctx.singleCoreWo * self_->ctx.convTilingData->convApiTiling.orgCo; |
| 232 | - } else if (likely(self_->ctx.convTiling->woL0 >= self_->ctx.singleCoreWo)) { | 232 | + } else if (likely(self_->ctx.convTilingData->convApiTiling.woL0 >= self_->ctx.singleCoreWo)) { |
| 233 | intriParams.mSize = currentML0_; | 233 | intriParams.mSize = currentML0_; |
| 234 | intriParams.params.srcNdStride = 0; | 234 | intriParams.params.srcNdStride = 0; |
| 235 | intriParams.params.ndNum = 1; | 235 | intriParams.params.ndNum = 1; |
| @@ -238,10 +238,10 @@ public: | |||
| 238 | intriParams.mSize = self_->ctx.currentWoL0; | 238 | intriParams.mSize = self_->ctx.currentWoL0; |
| 239 | intriParams.params.srcNdStride = self_->ctx.currentWoL0; | 239 | intriParams.params.srcNdStride = self_->ctx.currentWoL0; |
| 240 | intriParams.params.ndNum = self_->ctx.currentHoL0; | 240 | intriParams.params.ndNum = self_->ctx.currentHoL0; |
| 241 | - intriParams.params.dstNdStride = self_->ctx.singleCoreWo * self_->ctx.orgCo; | 241 | + intriParams.params.dstNdStride = self_->ctx.singleCoreWo * self_->ctx.convTilingData->convApiTiling.orgCo; |
| 242 | } | 242 | } |
| 243 | 243 | ||
| 244 | - intriParams.dstStride = self_->ctx.orgCo; | 244 | + intriParams.dstStride = self_->ctx.convTilingData->convApiTiling.orgCo; |
| 245 | intriParams.srcStride = AlignB(currentML0_, BLOCK_L0_M); | 245 | intriParams.srcStride = AlignB(currentML0_, BLOCK_L0_M); |
| 246 | intriParams.nSize = currentNL0_; | 246 | intriParams.nSize = currentNL0_; |
| 247 | SetBaseParams<CO2Layout::ROW_MAJOR>(intriParams); | 247 | SetBaseParams<CO2Layout::ROW_MAJOR>(intriParams); |
| @@ -260,20 +260,24 @@ public: | |||
| 260 | ubInfo->realWUb = unUsedML0 < ubInfo->mUb ? unUsedML0 : ubInfo->mUb; | 260 | ubInfo->realWUb = unUsedML0 < ubInfo->mUb ? unUsedML0 : ubInfo->mUb; |
| 261 | ubInfo->realBatchUb = 1; | 261 | ubInfo->realBatchUb = 1; |
| 262 | ubInfo->outBatchIdx = self_->ctx.batchIter + ubInfo->batchLoopIdx * ubInfo->batchUb; | 262 | ubInfo->outBatchIdx = self_->ctx.batchIter + ubInfo->batchLoopIdx * ubInfo->batchUb; |
| 263 | - ubInfo->outCIdx = self_->ctx.nBL1Iter * self_->ctx.convTiling->nBL1 + | 263 | + if constexpr (Intf::isKL1NL0FullLoad) { |
| 264 | - self_->ctx.nL0Iter * self_->ctx.convTiling->nL0 + ubInfo->nLoopIdx * ubInfo->nUb; | 264 | + ubInfo->outCIdx = ubInfo->nLoopIdx * ubInfo->nUb; |
| 265 | - ubInfo->outHIdx = self_->ctx.hoAL1Iter * self_->ctx.convTiling->hoL1 + | 265 | + } else { |
| 266 | - self_->ctx.hoL0Iter * self_->ctx.convTiling->hoL0 + ubInfo->mLoopIdx * ubInfo->mUb / self_->ctx.convTiling->woL0; | 266 | + ubInfo->outCIdx = self_->ctx.nBL1Iter * self_->ctx.convTilingData->convApiTiling.nBL1 + |
| 267 | + self_->ctx.nL0Iter * self_->ctx.convTilingData->convApiTiling.nL0 + ubInfo->nLoopIdx * ubInfo->nUb; | ||
| 268 | + } | ||
| 269 | + ubInfo->outHIdx = self_->ctx.hoAL1Iter * self_->ctx.convTilingData->convApiTiling.hoL1 + | ||
| 270 | + self_->ctx.hoL0Iter * self_->ctx.convTilingData->convApiTiling.hoL0 + ubInfo->mLoopIdx * ubInfo->mUb / self_->ctx.convTilingData->convApiTiling.woL0; | ||
| 267 | if (self_->ctx.woL1SmallTail == 0) { | 271 | if (self_->ctx.woL1SmallTail == 0) { |
| 268 | - ubInfo->outWIdx = self_->ctx.woAL1Iter * self_->ctx.convTiling->woL1 + | 272 | + ubInfo->outWIdx = self_->ctx.woAL1Iter * self_->ctx.convTilingData->convApiTiling.woL1 + |
| 269 | - self_->ctx.woL0Iter * self_->ctx.convTiling->woL0 + ubInfo->mLoopIdx * ubInfo->mUb % self_->ctx.convTiling->woL0; | 273 | + self_->ctx.woL0Iter * self_->ctx.convTilingData->convApiTiling.woL0 + ubInfo->mLoopIdx * ubInfo->mUb % self_->ctx.convTilingData->convApiTiling.woL0; |
| 270 | } else { | 274 | } else { |
| 271 | if (self_->ctx.woAL1Iter == self_->ctx.maxWoL1Iter) { | 275 | if (self_->ctx.woAL1Iter == self_->ctx.maxWoL1Iter) { |
| 272 | - ubInfo->outWIdx = ((self_->ctx.woAL1Iter - 1) * self_->ctx.convTiling->woL1 + self_->ctx.woAL1Tail) + | 276 | + ubInfo->outWIdx = ((self_->ctx.woAL1Iter - 1) * self_->ctx.convTilingData->convApiTiling.woL1 + self_->ctx.woAL1Tail) + |
| 273 | - self_->ctx.woL0Iter * self_->ctx.convTiling->woL0 + ubInfo->mLoopIdx * ubInfo->mUb % self_->ctx.convTiling->woL0; | 277 | + self_->ctx.woL0Iter * self_->ctx.convTilingData->convApiTiling.woL0 + ubInfo->mLoopIdx * ubInfo->mUb % self_->ctx.convTilingData->convApiTiling.woL0; |
| 274 | } else { | 278 | } else { |
| 275 | - ubInfo->outWIdx = self_->ctx.woAL1Iter * self_->ctx.convTiling->woL1 + | 279 | + ubInfo->outWIdx = self_->ctx.woAL1Iter * self_->ctx.convTilingData->convApiTiling.woL1 + |
| 276 | - self_->ctx.woL0Iter * self_->ctx.convTiling->woL0 + ubInfo->mLoopIdx * ubInfo->mUb % self_->ctx.convTiling->woL0; | 280 | + self_->ctx.woL0Iter * self_->ctx.convTilingData->convApiTiling.woL0 + ubInfo->mLoopIdx * ubInfo->mUb % self_->ctx.convTilingData->convApiTiling.woL0; |
| 277 | } | 281 | } |
| 278 | } | 282 | } |
| 279 | 283 | ||
| @@ -299,25 +303,31 @@ public: | |||
| 299 | __aicore__ inline void SetBaseParams(FixpipeParamsC310<format> &intriParams) | 303 | __aicore__ inline void SetBaseParams(FixpipeParamsC310<format> &intriParams) |
| 300 | { | 304 | { |
| 301 | intriParams.quantPre = GetQuantPre<Intf, OutputT, FixpipeIdx>(self_); | 305 | intriParams.quantPre = GetQuantPre<Intf, OutputT, FixpipeIdx>(self_); |
| 302 | - if (self_->ctx.convTiling->hasScale == 0) { | 306 | + if (self_->ctx.convTilingData->convApiTiling.hasScale == 0) { |
| 303 | intriParams.deqScalar = DEQ_SCALAR_ONE; | 307 | intriParams.deqScalar = DEQ_SCALAR_ONE; |
| 304 | } | 308 | } |
| 305 | if constexpr (Intf::isExtendConv2d) { | 309 | if constexpr (Intf::isExtendConv2d) { |
| 306 | if constexpr (FixpipeIdx == 0) { | 310 | if constexpr (FixpipeIdx == 0) { |
| 307 | - intriParams.reluEn = self_->ctx.convTiling->reluMode0 != 0; | 311 | + intriParams.reluEn = self_->ctx.convTilingData->convApiTiling.reluMode0 != 0; |
| 308 | #if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102) | 312 | #if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102) |
| 309 | - intriParams.preReluMode = static_cast<ReluMode>(self_->ctx.convTiling->reluMode0); | 313 | + intriParams.preReluMode = static_cast<ReluMode>(self_->ctx.convTilingData->convApiTiling.reluMode0); |
| 310 | - if (self_->ctx.convTiling->reluMode0 == static_cast<uint8_t>(ReluMode::SCALAR_RELU)) { | 314 | + if (self_->ctx.convTilingData->convApiTiling.reluMode0 == static_cast<uint8_t>(ReluMode::SCALAR_RELU)) { |
| 311 | intriParams.reluScalar = self_->ctx.preReluScalar0; | 315 | intriParams.reluScalar = self_->ctx.preReluScalar0; |
| 316 | + } else if (self_->ctx.convTilingData->convApiTiling.reluMode0 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { | ||
| 317 | + intriParams.vectorRelu = | ||
| 318 | + self_->ctx.reluWeightL1[GetExtendConv2dScaleL1Addr()].GetPhyAddr(); | ||
| 312 | } | 319 | } |
| 313 | #endif | 320 | #endif |
| 314 | intriParams.deqScalar = self_->ctx.deqScalar0; | 321 | intriParams.deqScalar = self_->ctx.deqScalar0; |
| 315 | } else { | 322 | } else { |
| 316 | - intriParams.reluEn = self_->ctx.convTiling->reluMode1 != 0; | 323 | + intriParams.reluEn = self_->ctx.convTilingData->convApiTiling.reluMode1 != 0; |
| 317 | #if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102) | 324 | #if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102) |
| 318 | - intriParams.preReluMode = static_cast<ReluMode>(self_->ctx.convTiling->reluMode1); | 325 | + intriParams.preReluMode = static_cast<ReluMode>(self_->ctx.convTilingData->convApiTiling.reluMode1); |
| 319 | - if (self_->ctx.convTiling->reluMode1 == static_cast<uint8_t>(ReluMode::SCALAR_RELU)) { | 326 | + if (self_->ctx.convTilingData->convApiTiling.reluMode1 == static_cast<uint8_t>(ReluMode::SCALAR_RELU)) { |
| 320 | intriParams.reluScalar = self_->ctx.preReluScalar1; | 327 | intriParams.reluScalar = self_->ctx.preReluScalar1; |
| 328 | + } else if(self_->ctx.convTilingData->convApiTiling.reluMode1 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { | ||
| 329 | + intriParams.vectorRelu = | ||
| 330 | + self_->ctx.reluWeightL1[GetExtendConv2dScaleL1Addr() + self_->ctx.reluWeight1L1offset].GetPhyAddr(); | ||
| 321 | } | 331 | } |
| 322 | #endif | 332 | #endif |
| 323 | intriParams.deqScalar = self_->ctx.deqScalar1; | 333 | intriParams.deqScalar = self_->ctx.deqScalar1; |
| @@ -327,7 +337,7 @@ public: | |||
| 327 | intriParams.unitFlag = UNIT_FLAG_ENABLE_WITH_FLIP; | 337 | intriParams.unitFlag = UNIT_FLAG_ENABLE_WITH_FLIP; |
| 328 | } else { | 338 | } else { |
| 329 | if constexpr (Intf::isExtendConv2d) { | 339 | if constexpr (Intf::isExtendConv2d) { |
| 330 | - if (self_->ctx.convTiling->dualOutput) { | 340 | + if (self_->ctx.convTilingData->convApiTiling.dualOutput) { |
| 331 | intriParams.unitFlag = UNIT_FLAG_ENABLE_ONLY; | 341 | intriParams.unitFlag = UNIT_FLAG_ENABLE_ONLY; |
| 332 | } else { | 342 | } else { |
| 333 | intriParams.unitFlag = UNIT_FLAG_ENABLE_WITH_FLIP; | 343 | intriParams.unitFlag = UNIT_FLAG_ENABLE_WITH_FLIP; |
| @@ -341,38 +351,42 @@ public: | |||
| 341 | __aicore__ inline uint64_t CalcFixpipeOffset() | 351 | __aicore__ inline uint64_t CalcFixpipeOffset() |
| 342 | { | 352 | { |
| 343 | uint64_t offset = self_->ctx.batchIter * self_->ctx.outputOneBatchSize; | 353 | uint64_t offset = self_->ctx.batchIter * self_->ctx.outputOneBatchSize; |
| 344 | - uint64_t offsetH = self_->ctx.hoAL1Iter * self_->ctx.convTiling->hoL1 + | 354 | + uint64_t offsetH = self_->ctx.hoAL1Iter * self_->ctx.convTilingData->convApiTiling.hoL1 + |
| 345 | - self_->ctx.hoL0Iter * self_->ctx.convTiling->hoL0; | 355 | + self_->ctx.hoL0Iter * self_->ctx.convTilingData->convApiTiling.hoL0; |
| 346 | uint64_t offsetW; | 356 | uint64_t offsetW; |
| 347 | if (self_->ctx.woL1SmallTail == 0) { | 357 | if (self_->ctx.woL1SmallTail == 0) { |
| 348 | - offsetW = self_->ctx.woAL1Iter * self_->ctx.convTiling->woL1 + | 358 | + offsetW = self_->ctx.woAL1Iter * self_->ctx.convTilingData->convApiTiling.woL1 + |
| 349 | - self_->ctx.woL0Iter * self_->ctx.convTiling->woL0; | 359 | + self_->ctx.woL0Iter * self_->ctx.convTilingData->convApiTiling.woL0; |
| 350 | } else { | 360 | } else { |
| 351 | if (self_->ctx.woAL1Iter == self_->ctx.maxWoL1Iter) { | 361 | if (self_->ctx.woAL1Iter == self_->ctx.maxWoL1Iter) { |
| 352 | - offsetW = ((self_->ctx.woAL1Iter - 1) * self_->ctx.convTiling->woL1 + self_->ctx.woAL1Tail) + | 362 | + offsetW = ((self_->ctx.woAL1Iter - 1) * self_->ctx.convTilingData->convApiTiling.woL1 + self_->ctx.woAL1Tail) + |
| 353 | - self_->ctx.woL0Iter * self_->ctx.convTiling->woL0; | 363 | + self_->ctx.woL0Iter * self_->ctx.convTilingData->convApiTiling.woL0; |
| 354 | } else { | 364 | } else { |
| 355 | - offsetW = self_->ctx.woAL1Iter * self_->ctx.convTiling->woL1 + | 365 | + offsetW = self_->ctx.woAL1Iter * self_->ctx.convTilingData->convApiTiling.woL1 + |
| 356 | - self_->ctx.woL0Iter * self_->ctx.convTiling->woL0; | 366 | + self_->ctx.woL0Iter * self_->ctx.convTilingData->convApiTiling.woL0; |
| 357 | } | 367 | } |
| 358 | } | 368 | } |
| 359 | 369 | ||
| 360 | - uint64_t offsetCout = self_->ctx.nBL1Iter * self_->ctx.convTiling->nBL1 + | 370 | + uint64_t offsetCout = 0U; |
| 361 | - self_->ctx.nL0Iter * self_->ctx.convTiling->nL0; | 371 | + if constexpr (!Intf::isKL1NL0FullLoad) { |
| 372 | + offsetCout = self_->ctx.nBL1Iter * self_->ctx.convTilingData->convApiTiling.nBL1 + | ||
| 373 | + self_->ctx.nL0Iter * self_->ctx.convTilingData->convApiTiling.nL0; | ||
| 374 | + } | ||
| 362 | if constexpr (Intf::groupOptPreloadFlag) { | 375 | if constexpr (Intf::groupOptPreloadFlag) { |
| 363 | - offsetCout += self_->ctx.groupOptIter * self_->ctx.convTiling->orgCo / self_->ctx.convTiling->groups * | 376 | + offsetCout += self_->ctx.groupOptIter * self_->ctx.convTilingData->convApiTiling.orgCo / |
| 364 | - self_->ctx.convTiling->enlarge; | 377 | + self_->ctx.convTilingData->convApiTiling.groups * |
| 378 | + self_->ctx.convTilingData->convApiTiling.enlarge; | ||
| 365 | } | 379 | } |
| 366 | if constexpr (Intf::formatOutput == ConvFormat::NCDHW) { | 380 | if constexpr (Intf::formatOutput == ConvFormat::NCDHW) { |
| 367 | - offset += offsetCout * self_->ctx.orgDo * valueHoWo_ + self_->ctx.dOutIter * valueHoWo_ + | 381 | + offset += offsetCout * self_->ctx.convTilingData->convApiTiling.orgDo * valueHoWo_ + self_->ctx.dOutIter * valueHoWo_ + |
| 368 | - offsetH * self_->ctx.orgWo + offsetW; | 382 | + offsetH * self_->ctx.convTilingData->convApiTiling.orgWo + offsetW; |
| 369 | } else if constexpr (Intf::formatOutput == ConvFormat::NDHWC) { | 383 | } else if constexpr (Intf::formatOutput == ConvFormat::NDHWC) { |
| 370 | - offset += self_->ctx.dOutIter * valueHoWo_ * self_->ctx.orgCo + offsetH * self_->ctx.orgWo * | 384 | + offset += self_->ctx.dOutIter * valueHoWo_ * self_->ctx.convTilingData->convApiTiling.orgCo + offsetH * self_->ctx.convTilingData->convApiTiling.orgWo * |
| 371 | - self_->ctx.orgCo + offsetW * self_->ctx.orgCo + offsetCout; | 385 | + self_->ctx.convTilingData->convApiTiling.orgCo + offsetW * self_->ctx.convTilingData->convApiTiling.orgCo + offsetCout; |
| 372 | } else if constexpr (Intf::formatOutput == ConvFormat::NCHW) { | 386 | } else if constexpr (Intf::formatOutput == ConvFormat::NCHW) { |
| 373 | - offset += offsetCout * valueHoWo_ + offsetH * self_->ctx.orgWo + offsetW; | 387 | + offset += offsetCout * valueHoWo_ + offsetH * self_->ctx.convTilingData->convApiTiling.orgWo + offsetW; |
| 374 | } else { | 388 | } else { |
| 375 | - offset += offsetH * self_->ctx.orgWo * self_->ctx.orgCo + offsetW * self_->ctx.orgCo + offsetCout; | 389 | + offset += offsetH * self_->ctx.convTilingData->convApiTiling.orgWo * self_->ctx.convTilingData->convApiTiling.orgCo + offsetW * self_->ctx.convTilingData->convApiTiling.orgCo + offsetCout; |
| 376 | } | 390 | } |
| 377 | 391 | ||
| 378 | return offset; | 392 | return offset; |
| @@ -398,9 +412,12 @@ public: | |||
| 398 | 412 | ||
| 399 | __aicore__ inline uint64_t GetExtendConv2dScaleL1Addr() | 413 | __aicore__ inline uint64_t GetExtendConv2dScaleL1Addr() |
| 400 | { | 414 | { |
| 401 | - if (self_->ctx.convTiling->fixpParamsFullLoadFlag) { | 415 | + if constexpr (Intf::isKL1NL0FullLoad) { |
| 402 | - return self_->ctx.nBL1Iter * self_->ctx.convTiling->nBL1 + | 416 | + return 0; |
| 403 | - self_->ctx.nL0Iter * self_->ctx.convTiling->nL0; | 417 | + } |
| 418 | + if (self_->ctx.convTilingData->convApiTiling.fixpParamsFullLoadFlag) { | ||
| 419 | + return self_->ctx.nBL1Iter * self_->ctx.convTilingData->convApiTiling.nBL1 + | ||
| 420 | + self_->ctx.nL0Iter * self_->ctx.convTilingData->convApiTiling.nL0; | ||
| 404 | } | 421 | } |
| 405 | return 0; | 422 | return 0; |
| 406 | } | 423 | } |
| @@ -428,7 +445,7 @@ public: | |||
| 428 | if constexpr (Intf::isExtendConv2d) { | 445 | if constexpr (Intf::isExtendConv2d) { |
| 429 | ExtendConv2DFixpipe<TensorTypeT, config>(output, intriParams, offset); | 446 | ExtendConv2DFixpipe<TensorTypeT, config>(output, intriParams, offset); |
| 430 | } else if constexpr (Intf::isQuantScene) { | 447 | } else if constexpr (Intf::isQuantScene) { |
| 431 | - if (self_->ctx.convTiling->hasScale != 0) { | 448 | + if (self_->ctx.convTilingData->convApiTiling.hasScale != 0) { |
| 432 | Fixpipe<OutputT, typename Intf::L0cT, config>( | 449 | Fixpipe<OutputT, typename Intf::L0cT, config>( |
| 433 | output[offset], self_->ctx.cl0, self_->ctx.scaleL1[GetScaleL1Addr()], intriParams); | 450 | output[offset], self_->ctx.cl0, self_->ctx.scaleL1[GetScaleL1Addr()], intriParams); |
| 434 | } else { | 451 | } else { |
| @@ -447,10 +464,13 @@ private: | |||
| 447 | 464 | ||
| 448 | __aicore__ inline uint64_t GetScaleL1Addr() | 465 | __aicore__ inline uint64_t GetScaleL1Addr() |
| 449 | { | 466 | { |
| 467 | + if constexpr (Intf::isKL1NL0FullLoad) { | ||
| 468 | + return 0; | ||
| 469 | + } | ||
| 450 | if constexpr (Intf::isQuantScene) { | 470 | if constexpr (Intf::isQuantScene) { |
| 451 | - if (self_->ctx.convTiling->hasScale != 0 && self_->ctx.convTiling->fixpParamsFullLoadFlag) { | 471 | + if (self_->ctx.convTilingData->convApiTiling.hasScale != 0 && self_->ctx.convTilingData->convApiTiling.fixpParamsFullLoadFlag) { |
| 452 | - return self_->ctx.nBL1Iter * self_->ctx.convTiling->nBL1 + | 472 | + return self_->ctx.nBL1Iter * self_->ctx.convTilingData->convApiTiling.nBL1 + |
| 453 | - self_->ctx.nL0Iter * self_->ctx.convTiling->nL0; | 473 | + self_->ctx.nL0Iter * self_->ctx.convTilingData->convApiTiling.nL0; |
| 454 | } | 474 | } |
| 455 | } | 475 | } |
| 456 | return 0; | 476 | return 0; |
| @@ -52,10 +52,13 @@ public: | |||
| 52 | __aicore__ inline void LoadChannelWiseL1(const LocalTensor<ChannelWiseT> &tensorL1, | 52 | __aicore__ inline void LoadChannelWiseL1(const LocalTensor<ChannelWiseT> &tensorL1, |
| 53 | const GlobalTensor<ChannelWiseT> &tensorGm) | 53 | const GlobalTensor<ChannelWiseT> &tensorGm) |
| 54 | { | 54 | { |
| 55 | - uint64_t tensorGmOffset = self_->ctx.nBL1Iter * self_->ctx.convTiling->nBL1 + | 55 | + if constexpr (Intf::isKL1NL0FullLoad) { |
| 56 | - self_->ctx.nL0Iter * self_->ctx.convTiling->nL0; | 56 | + LoadChannelWiseL1FullLoad(tensorL1, tensorGm, currentNL0_, 0); |
| 57 | - | 57 | + } else { |
| 58 | - LoadChannelWiseL1FullLoad(tensorL1, tensorGm, currentNL0_, tensorGmOffset); | 58 | + uint64_t tensorGmOffset = self_->ctx.nBL1Iter * self_->ctx.convTilingData->convApiTiling.nBL1 + |
| 59 | + self_->ctx.nL0Iter * self_->ctx.convTilingData->convApiTiling.nL0; | ||
| 60 | + LoadChannelWiseL1FullLoad(tensorL1, tensorGm, currentNL0_, tensorGmOffset); | ||
| 61 | + } | ||
| 59 | } | 62 | } |
| 60 | 63 | ||
| 61 | private: | 64 | private: |
| @@ -86,12 +89,16 @@ public: | |||
| 86 | return; | 89 | return; |
| 87 | } | 90 | } |
| 88 | uint32_t offset = 0; | 91 | uint32_t offset = 0; |
| 89 | - if (self_->ctx.convTiling->biasFullLoadFlag) { | 92 | + |
| 90 | - offset = self_->ctx.nBL1Iter * self_->ctx.convTiling->nBL1 + | 93 | + if (self_->ctx.convTilingData->convApiTiling.biasFullLoadFlag) { |
| 91 | - self_->ctx.nL0Iter * self_->ctx.convTiling->nL0; | 94 | + if constexpr (!Intf::isKL1NL0FullLoad) { |
| 95 | + offset += self_->ctx.nBL1Iter * self_->ctx.convTilingData->convApiTiling.nBL1 + | ||
| 96 | + self_->ctx.nL0Iter * self_->ctx.convTilingData->convApiTiling.nL0; | ||
| 97 | + } | ||
| 92 | if constexpr (Intf::groupOptPreloadFlag) { | 98 | if constexpr (Intf::groupOptPreloadFlag) { |
| 93 | - offset += self_->ctx.groupOptIter * self_->ctx.convTiling->orgCo / self_->ctx.convTiling->groups * | 99 | + offset += self_->ctx.groupOptIter * self_->ctx.convTilingData->convApiTiling.orgCo / |
| 94 | - self_->ctx.convTiling->enlarge; | 100 | + self_->ctx.convTilingData->convApiTiling.groups * |
| 101 | + self_->ctx.convTilingData->convApiTiling.enlarge; | ||
| 95 | } | 102 | } |
| 96 | } | 103 | } |
| 97 | 104 | ||
| @@ -114,41 +121,59 @@ public: | |||
| 114 | __aicore__ inline void SetParams(Intf *self) | 121 | __aicore__ inline void SetParams(Intf *self) |
| 115 | { | 122 | { |
| 116 | self_ = self; | 123 | self_ = self; |
| 117 | - nStep_ = self_->ctx.convTiling->nL0 / BLOCK_L0_N; | 124 | + nStep_ = self_->ctx.convTilingData->convApiTiling.nL0 / BLOCK_L0_N; |
| 118 | } | 125 | } |
| 119 | 126 | ||
| 120 | __aicore__ inline void SetN(uint64_t n) | 127 | __aicore__ inline void SetN(uint64_t n) |
| 121 | { | 128 | { |
| 122 | - ratioOfNToN0 = (self_->ctx.nBL1Iter == self_->ctx.maxNBL1Iter && self_->ctx.nL0Iter == self_->ctx.maxNL0Iter) ? | 129 | + if constexpr (Intf::isKL1NL0FullLoad) { |
| 123 | - n / BLOCK_L0_N : self_->ctx.convTiling->nStep; | 130 | + ratioOfNToN0 = n / BLOCK_L0_N; |
| 124 | - } | ||
| 125 | - | ||
| 126 | - __aicore__ inline void LoadBL0(bool isFirst) | ||
| 127 | - { | ||
| 128 | - uint64_t kStep = (self_->ctx.kIter != self_->ctx.maxKL0Iter) ? | ||
| 129 | - self_->ctx.convTiling->kStep : (self_->ctx.kL0Tail / Intf::k0); | ||
| 130 | - if (unlikely(isFirst)) { | ||
| 131 | - uint64_t mStartPosition = self_->ctx.nL0Iter * nStep_; | ||
| 132 | - param_.SetMStartPosition(static_cast<uint32_t>(mStartPosition)); | ||
| 133 | - param_.SetKStartPosition(static_cast<uint32_t>(self_->ctx.kBL0Iter * self_->ctx.convTiling->kStep)); | ||
| 134 | - param_.SetMStep(static_cast<uint16_t>(ratioOfNToN0)); | ||
| 135 | - param_.SetKStep(static_cast<uint16_t>(kStep)); | ||
| 136 | - param_.SetSrcStride(static_cast<int32_t>(self_->ctx.convTiling->nL1DivBlockSize)); | ||
| 137 | - param_.SetDstStride(static_cast<uint16_t>(ratioOfNToN0)); | ||
| 138 | - param_.SetIfTranspose(false); | ||
| 139 | } else { | 131 | } else { |
| 140 | - param_.SetKStartPosition(static_cast<uint32_t>(self_->ctx.kBL0Iter * self_->ctx.convTiling->kStep)); | 132 | + ratioOfNToN0 = (self_->ctx.nBL1Iter == self_->ctx.maxNBL1Iter && self_->ctx.nL0Iter == self_->ctx.maxNL0Iter) ? |
| 141 | - param_.SetKStep(static_cast<uint16_t>(kStep)); | 133 | + n / BLOCK_L0_N : self_->ctx.convTilingData->convApiTiling.nStep; |
| 142 | } | 134 | } |
| 143 | - LoadData<TPosition::B2, TPosition::B1, typename Intf::WeightT>(self_->ctx.bl0, self_->ctx.bl1, param_); | ||
| 144 | } | 135 | } |
| 145 | 136 | ||
| 137 | + __aicore__ inline void SetFirst() | ||
| 138 | + { | ||
| 139 | + if constexpr (Intf::isKL1NL0FullLoad) { | ||
| 140 | + param_.SetMStartPosition(static_cast<uint32_t>(0)); | ||
| 141 | + } else { | ||
| 142 | + param_.SetMStartPosition(static_cast<uint32_t>(self_->ctx.nL0Iter * nStep_)); | ||
| 143 | + } | ||
| 144 | + param_.SetMStep(static_cast<uint16_t>(ratioOfNToN0)); | ||
| 145 | + param_.SetSrcStride(static_cast<int32_t>(self_->ctx.convTilingData->convApiTiling.nL1DivBlockSize)); | ||
| 146 | + param_.SetDstStride(static_cast<uint16_t>(ratioOfNToN0)); | ||
| 147 | + param_.SetIfTranspose(false); | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + __aicore__ inline void LoadBL0(const uint64_t &KStartPosition, const uint64_t &kStep, const LocalTensor<typename Intf::WeightT> &bl0) | ||
| 151 | + { | ||
| 152 | + param_.SetKStartPosition(static_cast<uint32_t>(KStartPosition)); | ||
| 153 | + param_.SetKStep(static_cast<uint16_t>(kStep)); | ||
| 154 | + LoadData<TPosition::B2, TPosition::B1, typename Intf::WeightT>(bl0, self_->ctx.bl1, param_); | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + __aicore__ inline void FullLoadBL0(const LocalTensor<typename Intf::WeightT> &bl0) | ||
| 158 | + { | ||
| 159 | + static uint32_t isLoaded = false; | ||
| 160 | + if (isLoaded) { | ||
| 161 | + return; | ||
| 162 | + } | ||
| 163 | + isLoaded = true; | ||
| 164 | + param_.SetMStartPosition(0); | ||
| 165 | + param_.SetKStartPosition(0); | ||
| 166 | + param_.SetMStep(static_cast<uint16_t>(self_->ctx.convTilingData->convApiTiling.nL0 / BLOCK_L0_N)); | ||
| 167 | + param_.SetKStep(static_cast<uint16_t>(AlignB(self_->ctx.convTilingData->convApiTiling.kBL1, Intf::k0)/Intf::k0)); | ||
| 168 | + uint16_t stride = static_cast<uint16_t>(self_->ctx.convTilingData->convApiTiling.nBL1 / BLOCK_L0_N); | ||
| 169 | + param_.SetSrcStride(stride); | ||
| 170 | + param_.SetDstStride(stride); | ||
| 171 | + param_.SetIfTranspose(false); | ||
| 172 | + LoadData<TPosition::B2, TPosition::B1, typename Intf::WeightT>(bl0, self_->ctx.bl1, param_); | ||
| 173 | + } | ||
| 146 | private: | 174 | private: |
| 147 | Intf *self_ = nullptr; | 175 | Intf *self_ = nullptr; |
| 148 | uint64_t ratioOfNToN0 = 0; | 176 | uint64_t ratioOfNToN0 = 0; |
| 149 | - uint64_t xm_ = 0; | ||
| 150 | - uint64_t xt_ = 0; | ||
| 151 | - uint64_t xmtmp_ = 0; | ||
| 152 | uint64_t nStep_ = 0; | 177 | uint64_t nStep_ = 0; |
| 153 | Load2DBitModeParam param_; | 178 | Load2DBitModeParam param_; |
| 154 | }; | 179 | }; |
| @@ -164,80 +189,33 @@ public: | |||
| 164 | self_ = self; | 189 | self_ = self; |
| 165 | } | 190 | } |
| 166 | 191 | ||
| 167 | - __aicore__ inline void SetMN(uint64_t m, uint64_t n) | 192 | + __aicore__ inline void Mad(const uint64_t &kIter, const LocalTensor<typename Intf::FmapT> &al0, const LocalTensor<typename Intf::WeightT> &bl0, const MmadParams &mmadParams) |
| 168 | { | 193 | { |
| 169 | - currentML0_ = m; | ||
| 170 | - currentNL0_ = n; | ||
| 171 | - } | ||
| 172 | - | ||
| 173 | - __aicore__ inline void Mad() | ||
| 174 | - { | ||
| 175 | - MmadParams mmadParams; | ||
| 176 | - SetMmadParams(mmadParams); | ||
| 177 | - | ||
| 178 | if constexpr (Intf::ConvParam::innerBatch == static_cast<int8_t>(ConvInnerBatch::MULTI_BATCH)) { | 194 | if constexpr (Intf::ConvParam::innerBatch == static_cast<int8_t>(ConvInnerBatch::MULTI_BATCH)) { |
| 179 | uint32_t srcOffset = 0; | 195 | uint32_t srcOffset = 0; |
| 180 | uint32_t dstOffset = 0; | 196 | uint32_t dstOffset = 0; |
| 181 | - uint32_t srcBatchStride = self_->ctx.currentML0Align * self_->ctx.convTiling->kL0; | 197 | + uint32_t srcBatchStride = self_->ctx.currentML0Align * self_->ctx.convTilingData->convApiTiling.kL0; |
| 182 | uint32_t dstBatchStride = self_->ctx.currentML0Align * self_->ctx.currentNL0Align; | 198 | uint32_t dstBatchStride = self_->ctx.currentML0Align * self_->ctx.currentNL0Align; |
| 183 | for (uint32_t batchIdx = 0; batchIdx < self_->ctx.innerBatch; batchIdx++) { | 199 | for (uint32_t batchIdx = 0; batchIdx < self_->ctx.innerBatch; batchIdx++) { |
| 184 | Mmad<typename Intf::L0cT, typename Intf::FmapT, typename Intf::WeightT>( | 200 | Mmad<typename Intf::L0cT, typename Intf::FmapT, typename Intf::WeightT>( |
| 185 | - self_->ctx.cl0[dstOffset], self_->ctx.al0[srcOffset], self_->ctx.bl0, mmadParams); | 201 | + self_->ctx.cl0[dstOffset], al0[srcOffset], bl0, mmadParams); |
| 186 | srcOffset += srcBatchStride; | 202 | srcOffset += srcBatchStride; |
| 187 | dstOffset += dstBatchStride; | 203 | dstOffset += dstBatchStride; |
| 188 | } | 204 | } |
| 189 | } else { | 205 | } else { |
| 190 | Mmad<typename Intf::L0cT, typename Intf::FmapT, typename Intf::WeightT>( | 206 | Mmad<typename Intf::L0cT, typename Intf::FmapT, typename Intf::WeightT>( |
| 191 | - self_->ctx.cl0, self_->ctx.al0, self_->ctx.bl0, mmadParams); | 207 | + self_->ctx.cl0, al0, bl0, mmadParams); |
| 192 | } | 208 | } |
| 193 | } | 209 | } |
| 194 | 210 | ||
| 195 | private: | 211 | private: |
| 196 | - __aicore__ inline void SetMmadParams(MmadParams &mmadParams) | 212 | + __aicore__ inline bool IsKL0Tail(const uint64_t &kIter) |
| 197 | { | 213 | { |
| 198 | - if constexpr (Intf::ConvParam::innerBatch == static_cast<int8_t>(ConvInnerBatch::KERNEL_1X1_MULTI_BATCH)) { | 214 | + return kIter == self_->ctx.maxKL0Iter; |
| 199 | - if constexpr (Intf::formatOutput == ConvFormat::NCHW && Intf::c04Flag) { | ||
| 200 | - mmadParams.m = self_->ctx.innerBatch * AlignB(C04_CIN_SIZE * currentML0_, Intf::k0) / C04_CIN_SIZE; | ||
| 201 | - } else { | ||
| 202 | - mmadParams.m = self_->ctx.innerBatch * currentML0_; | ||
| 203 | - } | ||
| 204 | - } else { | ||
| 205 | - mmadParams.m = currentML0_; | ||
| 206 | - } | ||
| 207 | - mmadParams.n = currentNL0_; | ||
| 208 | - if constexpr (Intf::k0 == Intf::k0FmapTail) { | ||
| 209 | - mmadParams.k = IsKL0Tail() ? self_->ctx.kL0Tail : self_->ctx.convTiling->kL0; | ||
| 210 | - } else { | ||
| 211 | - mmadParams.k = IsKL0Tail() ? self_->ctx.kAL0Tail : self_->ctx.convTiling->kL0; | ||
| 212 | - } | ||
| 213 | - | ||
| 214 | - if constexpr (!Intf::isDeQuantFlag) { | ||
| 215 | - if (!self_->ctx.enableBias) { | ||
| 216 | - mmadParams.cmatrixInitVal = self_->ctx.kIter == 0; | ||
| 217 | - mmadParams.cmatrixSource = false; | ||
| 218 | - } else { | ||
| 219 | - mmadParams.cmatrixInitVal = false; | ||
| 220 | - mmadParams.cmatrixSource = self_->ctx.kIter == 0; | ||
| 221 | - } | ||
| 222 | - } else { | ||
| 223 | - mmadParams.cmatrixInitVal = self_->ctx.kIter == 0; | ||
| 224 | - mmadParams.cmatrixSource = false; | ||
| 225 | - } | ||
| 226 | - | ||
| 227 | - if constexpr (!Intf::isInnerBatchFlag && !Intf::isDeQuantFlag) { | ||
| 228 | - mmadParams.unitFlag = IsKL0Tail() ? UNIT_FLAG_ENABLE_WITH_FLIP : UNIT_FLAG_ENABLE_ONLY; | ||
| 229 | - } | ||
| 230 | - } | ||
| 231 | - | ||
| 232 | - __aicore__ inline bool IsKL0Tail() | ||
| 233 | - { | ||
| 234 | - return self_->ctx.kIter == self_->ctx.maxKL0Iter; | ||
| 235 | } | 215 | } |
| 236 | 216 | ||
| 237 | private: | 217 | private: |
| 238 | Intf *self_ = nullptr; | 218 | Intf *self_ = nullptr; |
| 239 | - uint64_t currentML0_ = 0; | ||
| 240 | - uint64_t currentNL0_ = 0; | ||
| 241 | }; | 219 | }; |
| 242 | 220 | ||
| 243 | template <class Intf, typename OutputT, uint64_t FixpipeIdx = 0> | 221 | template <class Intf, typename OutputT, uint64_t FixpipeIdx = 0> |
| @@ -247,7 +225,7 @@ __aicore__ inline QuantMode_t GetQuantPreHif8Fp8(Intf *self) | |||
| 247 | // extend conv2d: may be scalar or vector quant | 225 | // extend conv2d: may be scalar or vector quant |
| 248 | if constexpr (AscendC::IsSameType<OutputT, float>::value) { | 226 | if constexpr (AscendC::IsSameType<OutputT, float>::value) { |
| 249 | if constexpr (Intf::isExtendConv2d) { | 227 | if constexpr (Intf::isExtendConv2d) { |
| 250 | - if (self->ctx.convTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 228 | + if (self->ctx.convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 251 | return QuantMode_t::VQF322F32_PRE; | 229 | return QuantMode_t::VQF322F32_PRE; |
| 252 | } else { | 230 | } else { |
| 253 | return QuantMode_t::QF322F32_PRE; | 231 | return QuantMode_t::QF322F32_PRE; |
| @@ -259,7 +237,7 @@ __aicore__ inline QuantMode_t GetQuantPreHif8Fp8(Intf *self) | |||
| 259 | 237 | ||
| 260 | if constexpr (AscendC::IsSameType<OutputT, half>::value) { | 238 | if constexpr (AscendC::IsSameType<OutputT, half>::value) { |
| 261 | if constexpr (Intf::isExtendConv2d) { | 239 | if constexpr (Intf::isExtendConv2d) { |
| 262 | - if (self->ctx.convTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 240 | + if (self->ctx.convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 263 | return QuantMode_t::VQF322F16_PRE; | 241 | return QuantMode_t::VQF322F16_PRE; |
| 264 | } else { | 242 | } else { |
| 265 | return QuantMode_t::QF322F16_PRE; | 243 | return QuantMode_t::QF322F16_PRE; |
| @@ -271,7 +249,7 @@ __aicore__ inline QuantMode_t GetQuantPreHif8Fp8(Intf *self) | |||
| 271 | 249 | ||
| 272 | if constexpr (AscendC::IsSameType<OutputT, bfloat16_t>::value) { | 250 | if constexpr (AscendC::IsSameType<OutputT, bfloat16_t>::value) { |
| 273 | if constexpr (Intf::isExtendConv2d) { | 251 | if constexpr (Intf::isExtendConv2d) { |
| 274 | - if (self->ctx.convTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 252 | + if (self->ctx.convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 275 | return QuantMode_t::VQF322BF16_PRE; | 253 | return QuantMode_t::VQF322BF16_PRE; |
| 276 | } else { | 254 | } else { |
| 277 | return QuantMode_t::QF322BF16_PRE; | 255 | return QuantMode_t::QF322BF16_PRE; |
| @@ -283,16 +261,16 @@ __aicore__ inline QuantMode_t GetQuantPreHif8Fp8(Intf *self) | |||
| 283 | 261 | ||
| 284 | if constexpr (AscendC::IsSameType<OutputT, hifloat8_t>::value) { | 262 | if constexpr (AscendC::IsSameType<OutputT, hifloat8_t>::value) { |
| 285 | if constexpr (Intf::isExtendConv2d) { | 263 | if constexpr (Intf::isExtendConv2d) { |
| 286 | - if (self->ctx.convTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 264 | + if (self->ctx.convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 287 | return QuantMode_t::VQF322HIF8_PRE; | 265 | return QuantMode_t::VQF322HIF8_PRE; |
| 288 | } else { | 266 | } else { |
| 289 | return QuantMode_t::QF322HIF8_PRE; | 267 | return QuantMode_t::QF322HIF8_PRE; |
| 290 | } | 268 | } |
| 291 | } else { | 269 | } else { |
| 292 | - if (self->ctx.convTiling->hasScale == 0) { | 270 | + if (self->ctx.convTilingData->convApiTiling.hasScale == 0) { |
| 293 | // conv2d support hif8 in hif8 out | 271 | // conv2d support hif8 in hif8 out |
| 294 | return QuantMode_t::QF322HIF8_PRE; | 272 | return QuantMode_t::QF322HIF8_PRE; |
| 295 | - } else if (self->ctx.convTiling->roundMode == ROUND_MODE_ROUND) { | 273 | + } else if (self->ctx.convTilingData->convApiTiling.roundMode == ROUND_MODE_ROUND) { |
| 296 | // quantconv2d/quantconv3d | 274 | // quantconv2d/quantconv3d |
| 297 | return QuantMode_t::VQF322HIF8_PRE; | 275 | return QuantMode_t::VQF322HIF8_PRE; |
| 298 | } | 276 | } |
| @@ -301,7 +279,7 @@ __aicore__ inline QuantMode_t GetQuantPreHif8Fp8(Intf *self) | |||
| 301 | 279 | ||
| 302 | if constexpr (AscendC::IsSameType<OutputT, fp8_e4m3fn_t>::value) { | 280 | if constexpr (AscendC::IsSameType<OutputT, fp8_e4m3fn_t>::value) { |
| 303 | if constexpr (Intf::isExtendConv2d) { | 281 | if constexpr (Intf::isExtendConv2d) { |
| 304 | - if (self->ctx.convTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 282 | + if (self->ctx.convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 305 | return QuantMode_t::VQF322FP8_PRE; | 283 | return QuantMode_t::VQF322FP8_PRE; |
| 306 | } else { | 284 | } else { |
| 307 | return QuantMode_t::QF322FP8_PRE; | 285 | return QuantMode_t::QF322FP8_PRE; |
| @@ -321,13 +299,13 @@ __aicore__ inline QuantMode_t GetQuantPreInt32(Intf *self) | |||
| 321 | if constexpr (AscendC::IsSameType<OutputT, half>::value) { | 299 | if constexpr (AscendC::IsSameType<OutputT, half>::value) { |
| 322 | if constexpr (Intf::isExtendConv2d) { | 300 | if constexpr (Intf::isExtendConv2d) { |
| 323 | if constexpr (FixpipeIdx == 0) { | 301 | if constexpr (FixpipeIdx == 0) { |
| 324 | - if (self->ctx.convTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 302 | + if (self->ctx.convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 325 | return QuantMode_t::VDEQF16; | 303 | return QuantMode_t::VDEQF16; |
| 326 | } else { | 304 | } else { |
| 327 | return QuantMode_t::DEQF16; | 305 | return QuantMode_t::DEQF16; |
| 328 | } | 306 | } |
| 329 | } else { | 307 | } else { |
| 330 | - if (self->ctx.convTiling->quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 308 | + if (self->ctx.convTilingData->convApiTiling.quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 331 | return QuantMode_t::VDEQF16; | 309 | return QuantMode_t::VDEQF16; |
| 332 | } else { | 310 | } else { |
| 333 | return QuantMode_t::DEQF16; | 311 | return QuantMode_t::DEQF16; |
| @@ -342,13 +320,13 @@ __aicore__ inline QuantMode_t GetQuantPreInt32(Intf *self) | |||
| 342 | } else if constexpr (AscendC::IsSameType<OutputT, int8_t>::value) { | 320 | } else if constexpr (AscendC::IsSameType<OutputT, int8_t>::value) { |
| 343 | if constexpr (Intf::isExtendConv2d) { | 321 | if constexpr (Intf::isExtendConv2d) { |
| 344 | if constexpr (FixpipeIdx == 0) { | 322 | if constexpr (FixpipeIdx == 0) { |
| 345 | - if (self->ctx.convTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 323 | + if (self->ctx.convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 346 | return QuantMode_t::VREQ8; | 324 | return QuantMode_t::VREQ8; |
| 347 | } else { | 325 | } else { |
| 348 | return QuantMode_t::REQ8; | 326 | return QuantMode_t::REQ8; |
| 349 | } | 327 | } |
| 350 | } else { | 328 | } else { |
| 351 | - if (self->ctx.convTiling->quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 329 | + if (self->ctx.convTilingData->convApiTiling.quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 352 | return QuantMode_t::VREQ8; | 330 | return QuantMode_t::VREQ8; |
| 353 | } else { | 331 | } else { |
| 354 | return QuantMode_t::REQ8; | 332 | return QuantMode_t::REQ8; |
| @@ -378,13 +356,13 @@ __aicore__ inline QuantMode_t GetQuantPreFp32(Intf *self) | |||
| 378 | } else if constexpr (AscendC::IsSameType<OutputT, int8_t>::value) { | 356 | } else if constexpr (AscendC::IsSameType<OutputT, int8_t>::value) { |
| 379 | if constexpr (Intf::isExtendConv2d) { | 357 | if constexpr (Intf::isExtendConv2d) { |
| 380 | if constexpr (FixpipeIdx == 0) { | 358 | if constexpr (FixpipeIdx == 0) { |
| 381 | - if (self->ctx.convTiling->quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 359 | + if (self->ctx.convTilingData->convApiTiling.quantMode0 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 382 | return QuantMode_t::VQF322B8_PRE; | 360 | return QuantMode_t::VQF322B8_PRE; |
| 383 | } else { | 361 | } else { |
| 384 | return QuantMode_t::QF322B8_PRE; | 362 | return QuantMode_t::QF322B8_PRE; |
| 385 | } | 363 | } |
| 386 | } else { | 364 | } else { |
| 387 | - if (self->ctx.convTiling->quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { | 365 | + if (self->ctx.convTilingData->convApiTiling.quantMode1 == static_cast<uint8_t>(QuantModeType::VECTOR_QUANT)) { |
| 388 | return QuantMode_t::VQF322B8_PRE; | 366 | return QuantMode_t::VQF322B8_PRE; |
| 389 | } else { | 367 | } else { |
| 390 | return QuantMode_t::QF322B8_PRE; | 368 | return QuantMode_t::QF322B8_PRE; |
| @@ -32,27 +32,35 @@ public: | |||
| 32 | __aicore__ inline void SetParams(Intf *self) | 32 | __aicore__ inline void SetParams(Intf *self) |
| 33 | { | 33 | { |
| 34 | self_ = self; | 34 | self_ = self; |
| 35 | - alignCinATailInCore_ = AlignB(self_->ctx.convTiling->cinATailInCore, Intf::k0FmapTail); | 35 | + alignCinATailInCore_ = AlignB(self_->ctx.convTilingData->convApiTiling.cinATailInCore, Intf::k0FmapTail); |
| 36 | 36 | ||
| 37 | if constexpr (Intf::c04Flag) { | 37 | if constexpr (Intf::c04Flag) { |
| 38 | channelSize_ = conv::C04_CIN_SIZE; | 38 | channelSize_ = conv::C04_CIN_SIZE; |
| 39 | - c04KStepTail = (channelSize_ * self_->ctx.convTiling->kernelHxkernelW) % self_->ctx.convTiling->kL0; | 39 | + c04KStepTail = (conv::C04_CIN_SIZE * self_->ctx.convTilingData->convApiTiling.kernelHxkernelW) % self_->ctx.convTilingData->convApiTiling.kL0; |
| 40 | - c04KStepTail = c04KStepTail == 0 ? self_->ctx.convTiling->kL0 : c04KStepTail; | 40 | + c04KStepTail = c04KStepTail == 0 ? self_->ctx.convTilingData->convApiTiling.kL0 : c04KStepTail; |
| 41 | } else { | 41 | } else { |
| 42 | if constexpr (Intf::kPreLoadFlag) { | 42 | if constexpr (Intf::kPreLoadFlag) { |
| 43 | - channelSize_ = (self_->ctx.kAL1Iter - 1 != self_->ctx.maxKAL1Iter ? | 43 | + if constexpr (Intf::isKL1NL0FullLoad) { |
| 44 | - self_->ctx.convTiling->cinAInCore : alignCinATailInCore_); | 44 | + channelSize_ = alignCinATailInCore_; |
| 45 | + } else { | ||
| 46 | + channelSize_ = (self_->ctx.kAL1Iter - 1 != self_->ctx.maxKAL1Iter ? | ||
| 47 | + self_->ctx.convTilingData->convApiTiling.cinAInCore : alignCinATailInCore_); | ||
| 48 | + } | ||
| 45 | } else { | 49 | } else { |
| 46 | - channelSize_ = (self_->ctx.kAL1Iter != self_->ctx.maxKAL1Iter ? | 50 | + if constexpr (Intf::isKL1NL0FullLoad) { |
| 47 | - self_->ctx.convTiling->cinAInCore : alignCinATailInCore_); | 51 | + channelSize_ = alignCinATailInCore_; |
| 52 | + } else { | ||
| 53 | + channelSize_ = (self_->ctx.kAL1Iter != self_->ctx.maxKAL1Iter ? | ||
| 54 | + self_->ctx.convTilingData->convApiTiling.cinAInCore : alignCinATailInCore_); | ||
| 55 | + } | ||
| 48 | } | 56 | } |
| 49 | } | 57 | } |
| 50 | 58 | ||
| 51 | if constexpr (Intf::ConvParam::innerBatch == static_cast<int8_t>(ConvInnerBatch::MULTI_BATCH)) { | 59 | if constexpr (Intf::ConvParam::innerBatch == static_cast<int8_t>(ConvInnerBatch::MULTI_BATCH)) { |
| 52 | - uint64_t hiLoadL1 = (self_->ctx.convTiling->orgHo - 1) * self_->ctx.convTiling->strideH + | 60 | + uint64_t hiLoadL1 = (self_->ctx.convTilingData->convApiTiling.orgHo - 1) * self_->ctx.convTilingData->convApiTiling.strideH + |
| 53 | self_->ctx.dilatedKernelH; | 61 | self_->ctx.dilatedKernelH; |
| 54 | - hiLoadL1 = hiLoadL1 > self_->ctx.convTiling->orgHi ? self_->ctx.convTiling->orgHi : hiLoadL1; | 62 | + hiLoadL1 = hiLoadL1 > self_->ctx.convTilingData->convApiTiling.orgHi ? self_->ctx.convTilingData->convApiTiling.orgHi : hiLoadL1; |
| 55 | - realHixWi = hiLoadL1 * self_->ctx.convTiling->orgWi; | 63 | + realHixWi = hiLoadL1 * self_->ctx.convTilingData->convApiTiling.orgWi; |
| 56 | } | 64 | } |
| 57 | } | 65 | } |
| 58 | 66 | ||
| @@ -74,79 +82,73 @@ public: | |||
| 74 | SetLoadDataRepeatWithStride(repeatParams); | 82 | SetLoadDataRepeatWithStride(repeatParams); |
| 75 | } | 83 | } |
| 76 | 84 | ||
| 77 | - __aicore__ inline void LoadAL0(bool isFirst = true) | 85 | + __aicore__ inline void SetFirst() |
| 86 | + { | ||
| 87 | + uint64_t posM = self_->ctx.mL0Iter * self_->ctx.mL0 + | ||
| 88 | + (self_->ctx.mStartPos + self_->ctx.mAL1Iter * self_->ctx.mAL1) % self_->ctx.convTilingData->convApiTiling.orgWo; | ||
| 89 | + xm_.bf.mExtension_ = currentML0_ & MASK_16; | ||
| 90 | + xm_.bf.mStartPt_ = posM & MASK_16; | ||
| 91 | + | ||
| 92 | + xt_.n = static_cast<uint64_t>(self_->ctx.convTilingData->convApiTiling.unionDataXt); | ||
| 93 | + xt_.bf.channelSize = channelSize_; | ||
| 94 | + param_.SetConfig1(xt_.n); | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + __aicore__ inline uint64_t GetC04KStepTail() | ||
| 98 | + { | ||
| 99 | + return c04KStepTail; | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + __aicore__ inline void LoadAL0(const uint64_t ¤tKL0, const uint64_t &posK, const uint64_t &kIter, const LocalTensor<typename Intf::FmapT> &al0) | ||
| 78 | { | 103 | { |
| 79 | if ASCEND_IS_AIV { | 104 | if ASCEND_IS_AIV { |
| 80 | return; | 105 | return; |
| 81 | } | 106 | } |
| 82 | - if constexpr (Intf::c04Flag) { | 107 | + xm_.bf.currentKL0 = currentKL0 & MASK_16; |
| 83 | - currentKL0 = IsKL0Tail() ? c04KStepTail : self_->ctx.convTiling->kL0; | 108 | + xm_.bf.posK = posK & MASK_16; |
| 84 | - } else if constexpr (Intf::k0 == Intf::k0FmapTail) { | 109 | + param_.SetConfig0(xm_.n); |
| 85 | - currentKL0 = IsKL0Tail() ? self_->ctx.kL0Tail : self_->ctx.convTiling->kL0; | ||
| 86 | - } else { | ||
| 87 | - currentKL0 = IsKL0Tail() ? self_->ctx.kAL0Tail : self_->ctx.convTiling->kL0; | ||
| 88 | - } | ||
| 89 | 110 | ||
| 90 | - uint64_t posK = self_->ctx.kAL0Iter * self_->ctx.convTiling->kL0; | 111 | + if constexpr (Intf::preFusionFlag) { |
| 91 | - if (isFirst) { | 112 | + uint64_t aL1Offset = 0; |
| 92 | - uint64_t posM = self_->ctx.mL0Iter * self_->ctx.mL0 + | 113 | + if ((self_->ctx.convTilingData->convApiTiling.pBufferFlag & AL1_DB_IDX) >> AL1_DB_OFFSET) { |
| 93 | - (self_->ctx.mStartPos + self_->ctx.mAL1Iter * self_->ctx.mAL1) % self_->ctx.orgWo; | 114 | + aL1Offset = (self_->ctx.al1PingPongFlag^1) * self_->ctx.convTilingData->convApiTiling.aL1SpaceSize / Intf::sizeOfFmap; |
| 94 | - xmtmp_ = ((currentML0_ & MASK_16) << MSTEP_OFFSET) | ((posM & MASK_16) << POSM_OFFSET); | 115 | + } |
| 95 | - xt_ = ((static_cast<uint64_t>(self_->ctx.convTiling->strideW) & MASK_6) << 0) | | 116 | + LoadData<TPosition::A2, TPosition::A1, typename Intf::FmapT>(al0, |
| 96 | - ((static_cast<uint64_t>(self_->ctx.kernelW) & MASK_8) << KERNELW_OFFSET) | | 117 | + self_->ctx.al1[aL1Offset], param_); |
| 97 | - ((static_cast<uint64_t>(self_->ctx.kernelH) & MASK_8) << KERNELH_OFFSET) | | 118 | + } else if constexpr (Intf::ConvParam::innerBatch == static_cast<int8_t>(ConvInnerBatch::MULTI_BATCH)) { |
| 98 | - ((static_cast<uint64_t>(self_->ctx.convTiling->strideH) & MASK_6) << STRIDEH_OFFSET) | | ||
| 99 | - ((static_cast<uint64_t>(self_->ctx.kernelW) & NINTH_BIT_MASK) << KERNELW_HIGHEST_BIT_OFFSET) | | ||
| 100 | - ((static_cast<uint64_t>(self_->ctx.kernelH) & NINTH_BIT_MASK) << KERNELH_HIGHEST_BIT_OFFSET) | | ||
| 101 | - ((static_cast<uint64_t>(self_->ctx.convTiling->dilationW) & MASK_8) << DILATIONW_OFFSET) | | ||
| 102 | - ((static_cast<uint64_t>(self_->ctx.convTiling->dilationH) & MASK_8) << DILATIONH_OFFSET) | | ||
| 103 | - ((static_cast<uint64_t>(channelSize_) & MASK_16) << CIN_OFFSET); | ||
| 104 | - param_.SetConfig1(xt_); | ||
| 105 | - } | ||
| 106 | - xm_ = currentKL0 | (posK << POSK_OFFSET) | xmtmp_; | ||
| 107 | - param_.SetConfig0(xm_); | ||
| 108 | - | ||
| 109 | - if constexpr (Intf::ConvParam::innerBatch == static_cast<int8_t>(ConvInnerBatch::MULTI_BATCH)) { | ||
| 110 | uint32_t srcOffset = 0; | 119 | uint32_t srcOffset = 0; |
| 111 | uint32_t dstOffset = 0; | 120 | uint32_t dstOffset = 0; |
| 112 | uint32_t srcBatchStride = 0; | 121 | uint32_t srcBatchStride = 0; |
| 113 | if constexpr (Intf::c04Flag) { | 122 | if constexpr (Intf::c04Flag) { |
| 114 | - srcBatchStride = AlignB(C04_CIN_SIZE * self_->ctx.convTiling->orgHixWi, Intf::k0); | 123 | + srcBatchStride = AlignB(C04_CIN_SIZE * self_->ctx.convTilingData->convApiTiling.orgHixWi, Intf::k0); |
| 115 | } else { | 124 | } else { |
| 116 | - srcBatchStride = ((self_->ctx.kIter / self_->ctx.multiKAL1) != self_->ctx.maxKAL1Iter ? | 125 | + srcBatchStride = ((kIter / self_->ctx.multiKAL1) != self_->ctx.maxKAL1Iter ? |
| 117 | - self_->ctx.convTiling->cinAInCore : alignCinATailInCore_) * realHixWi; | 126 | + self_->ctx.convTilingData->convApiTiling.cinAInCore : alignCinATailInCore_) * realHixWi; |
| 118 | - } | 127 | + } |
| 119 | - uint32_t dstBatchStride = currentML0Align_ * self_->ctx.convTiling->kL0; | 128 | + uint32_t dstBatchStride = currentML0Align_ * self_->ctx.convTilingData->convApiTiling.kL0; |
| 120 | for (uint16_t batchIter = 0; batchIter < self_->ctx.innerBatch; batchIter++) { | 129 | for (uint16_t batchIter = 0; batchIter < self_->ctx.innerBatch; batchIter++) { |
| 121 | - LoadData<TPosition::A2, TPosition::A1, typename Intf::FmapT>(self_->ctx.al0[dstOffset], | 130 | + LoadData<TPosition::A2, TPosition::A1, typename Intf::FmapT>(al0[dstOffset], |
| 122 | self_->ctx.al1[srcOffset], param_); | 131 | self_->ctx.al1[srcOffset], param_); |
| 123 | srcOffset += srcBatchStride; | 132 | srcOffset += srcBatchStride; |
| 124 | dstOffset += dstBatchStride; | 133 | dstOffset += dstBatchStride; |
| 125 | } | 134 | } |
| 126 | } else { | 135 | } else { |
| 127 | - LoadData<TPosition::A2, TPosition::A1, typename Intf::FmapT>(self_->ctx.al0, self_->ctx.al1, param_); | 136 | + LoadData<TPosition::A2, TPosition::A1, typename Intf::FmapT>(al0, self_->ctx.al1, param_); |
| 128 | } | 137 | } |
| 129 | }; | 138 | }; |
| 130 | 139 | ||
| 131 | -private: | ||
| 132 | - __aicore__ inline bool IsKL0Tail() | ||
| 133 | - { | ||
| 134 | - return self_->ctx.kIter == self_->ctx.maxKL0Iter; | ||
| 135 | - } | ||
| 136 | 140 | ||
| 137 | private: | 141 | private: |
| 138 | Intf *self_ = nullptr; | 142 | Intf *self_ = nullptr; |
| 139 | uint64_t currentML0_ = 0; | 143 | uint64_t currentML0_ = 0; |
| 140 | uint64_t currentML0Align_ = 0; | 144 | uint64_t currentML0Align_ = 0; |
| 141 | - uint64_t xm_ = 0; | ||
| 142 | - uint64_t xt_ = 0; | ||
| 143 | - uint64_t xmtmp_ = 0; | ||
| 144 | uint64_t alignCinATailInCore_ = 0; | 145 | uint64_t alignCinATailInCore_ = 0; |
| 145 | uint16_t channelSize_ = 0; | 146 | uint16_t channelSize_ = 0; |
| 146 | uint64_t c04KStepTail = 0; | 147 | uint64_t c04KStepTail = 0; |
| 147 | uint64_t realHixWi = 0; | 148 | uint64_t realHixWi = 0; |
| 148 | - uint64_t currentKL0 = 0; | ||
| 149 | Load3DBitModeParam param_; | 149 | Load3DBitModeParam param_; |
| 150 | + UnionDataXt xt_; | ||
| 151 | + UnionDataXm xm_; | ||
| 150 | }; | 152 | }; |
| 151 | 153 | ||
| 152 | template <class Intf, typename OutputT, uint64_t FixpipeIdx = 0> | 154 | template <class Intf, typename OutputT, uint64_t FixpipeIdx = 0> |
| @@ -155,18 +157,18 @@ public: | |||
| 155 | __aicore__ inline CopyOutToolsMMode() | 157 | __aicore__ inline CopyOutToolsMMode() |
| 156 | {} | 158 | {} |
| 157 | 159 | ||
| 160 | + __aicore__ inline void SetParams(Intf *self) | ||
| 161 | + { | ||
| 162 | + self_ = self; | ||
| 163 | + valueHoWo_ = self_->ctx.convTilingData->convApiTiling.orgHo * self_->ctx.convTilingData->convApiTiling.orgWo; | ||
| 164 | + } | ||
| 165 | + | ||
| 158 | __aicore__ inline void SetMN(uint64_t m, uint64_t n) | 166 | __aicore__ inline void SetMN(uint64_t m, uint64_t n) |
| 159 | { | 167 | { |
| 160 | currentML0_ = m; | 168 | currentML0_ = m; |
| 161 | currentNL0_ = n; | 169 | currentNL0_ = n; |
| 162 | } | 170 | } |
| 163 | 171 | ||
| 164 | - __aicore__ inline void SetParams(Intf *self) | ||
| 165 | - { | ||
| 166 | - self_ = self; | ||
| 167 | - valueHoWo_ = self_->ctx.orgHo * self_->ctx.orgWo; | ||
| 168 | - } | ||
| 169 | - | ||
| 170 | template <template <typename> class TensorTypeT, const FixpipeConfig &config> | 172 | template <template <typename> class TensorTypeT, const FixpipeConfig &config> |
| 171 | __aicore__ inline void CopyOut(const TensorTypeT<OutputT> &output, CopyUbInfo* ubInfo = nullptr) | 173 | __aicore__ inline void CopyOut(const TensorTypeT<OutputT> &output, CopyUbInfo* ubInfo = nullptr) |
| 172 | { | 174 | { |
| @@ -193,7 +195,7 @@ public: | |||
| 193 | if constexpr (Intf::isExtendConv2d) { | 195 | if constexpr (Intf::isExtendConv2d) { |
| 194 | ExtendConv2DFixpipe<TensorTypeT, config>(output, intriParams, offset); | 196 | ExtendConv2DFixpipe<TensorTypeT, config>(output, intriParams, offset); |
| 195 | } else if constexpr (Intf::isQuantScene) { | 197 | } else if constexpr (Intf::isQuantScene) { |
| 196 | - if (self_->ctx.convTiling->hasScale == 0) { | 198 | + if (self_->ctx.convTilingData->convApiTiling.hasScale == 0) { |
| 197 | Fixpipe<OutputT, typename Intf::L0cT, config>(output[offset], self_->ctx.cl0, intriParams); | 199 | Fixpipe<OutputT, typename Intf::L0cT, config>(output[offset], self_->ctx.cl0, intriParams); |
| 198 | } else { | 200 | } else { |
| 199 | Fixpipe<OutputT, typename Intf::L0cT, config>( | 201 | Fixpipe<OutputT, typename Intf::L0cT, config>( |
| @@ -225,7 +227,7 @@ private: | |||
| 225 | if constexpr (Intf::isExtendConv2d) { | 227 | if constexpr (Intf::isExtendConv2d) { |
| 226 | ExtendConv2DFixpipe<TensorTypeT, config>(output, intriParams, offset); | 228 | ExtendConv2DFixpipe<TensorTypeT, config>(output, intriParams, offset); |
| 227 | } else if constexpr (Intf::isQuantScene) { | 229 | } else if constexpr (Intf::isQuantScene) { |
| 228 | - if (self_->ctx.convTiling->hasScale != 0) { | 230 | + if (self_->ctx.convTilingData->convApiTiling.hasScale != 0) { |
| 229 | Fixpipe<OutputT, typename Intf::L0cT, config>( | 231 | Fixpipe<OutputT, typename Intf::L0cT, config>( |
| 230 | output[offset], self_->ctx.cl0, self_->ctx.scaleL1[GetScaleL1Addr()], intriParams); | 232 | output[offset], self_->ctx.cl0, self_->ctx.scaleL1[GetScaleL1Addr()], intriParams); |
| 231 | } else { | 233 | } else { |
| @@ -255,7 +257,7 @@ private: | |||
| 255 | intriParams.params.srcNzMatrixStride = self_->ctx.currentML0Align * CeilDiv(currentNL0_ , BLOCK_L0_N); | 257 | intriParams.params.srcNzMatrixStride = self_->ctx.currentML0Align * CeilDiv(currentNL0_ , BLOCK_L0_N); |
| 256 | } | 258 | } |
| 257 | intriParams.params.srcNzC0Stride = 1; | 259 | intriParams.params.srcNzC0Stride = 1; |
| 258 | - intriParams.params.dstDnMatrixStride = self_->ctx.orgCo * valueHoWo_; | 260 | + intriParams.params.dstDnMatrixStride = self_->ctx.convTilingData->convApiTiling.orgCo * valueHoWo_; |
| 259 | intriParams.dstStride = valueHoWo_; | 261 | intriParams.dstStride = valueHoWo_; |
| 260 | } | 262 | } |
| 261 | 263 | ||
| @@ -271,8 +273,8 @@ private: | |||
| 271 | intriParams.srcStride = self_->ctx.currentML0Align; | 273 | intriParams.srcStride = self_->ctx.currentML0Align; |
| 272 | intriParams.params.srcNdStride = self_->ctx.currentML0Align * CeilDiv(currentNL0_ , BLOCK_L0_N); | 274 | intriParams.params.srcNdStride = self_->ctx.currentML0Align * CeilDiv(currentNL0_ , BLOCK_L0_N); |
| 273 | } | 275 | } |
| 274 | - intriParams.params.dstNdStride = self_->ctx.orgCo * valueHoWo_; | 276 | + intriParams.params.dstNdStride = self_->ctx.convTilingData->convApiTiling.orgCo * valueHoWo_; |
| 275 | - intriParams.dstStride = self_->ctx.orgCo; | 277 | + intriParams.dstStride = self_->ctx.convTilingData->convApiTiling.orgCo; |
| 276 | } | 278 | } |
| 277 | 279 | ||
| 278 | __aicore__ inline void SetFixpipeIntriParamsHWC(FixpipeParamsC310<CO2Layout::ROW_MAJOR> &intriParams) | 280 | __aicore__ inline void SetFixpipeIntriParamsHWC(FixpipeParamsC310<CO2Layout::ROW_MAJOR> &intriParams) |
| @@ -280,7 +282,7 @@ private: | |||
| 280 | intriParams.nSize = currentNL0_; | 282 | intriParams.nSize = currentNL0_; |
| 281 | intriParams.mSize = currentML0_; | 283 | intriParams.mSize = currentML0_; |
| 282 | intriParams.srcStride = AlignB(currentML0_, BLOCK_L0_M); | 284 | intriParams.srcStride = AlignB(currentML0_, BLOCK_L0_M); |
| 283 | - intriParams.dstStride = self_->ctx.orgCo; | 285 | + intriParams.dstStride = self_->ctx.convTilingData->convApiTiling.orgCo; |
| 284 | intriParams.params.ndNum = 1; | 286 | intriParams.params.ndNum = 1; |
| 285 | intriParams.params.dstNdStride = 0; | 287 | intriParams.params.dstNdStride = 0; |
| 286 | intriParams.params.srcNdStride = 0; | 288 | intriParams.params.srcNdStride = 0; |
| @@ -293,7 +295,7 @@ private: | |||
| 293 | intriParams.mSize = currentML0_; | 295 | intriParams.mSize = currentML0_; |
| 294 | intriParams.srcStride = AlignB(currentML0_, BLOCK_L0_M); | 296 | intriParams.srcStride = AlignB(currentML0_, BLOCK_L0_M); |
| 295 | if constexpr (Intf::formatOutput == ConvFormat::NCDHW) { | 297 | if constexpr (Intf::formatOutput == ConvFormat::NCDHW) { |
| 296 | - intriParams.dstStride = self_->ctx.orgDo * valueHoWo_; | 298 | + intriParams.dstStride = self_->ctx.convTilingData->convApiTiling.orgDo * valueHoWo_; |
| 297 | } else { | 299 | } else { |
| 298 | intriParams.dstStride = valueHoWo_; | 300 | intriParams.dstStride = valueHoWo_; |
| 299 | } | 301 | } |
| @@ -318,8 +320,12 @@ private: | |||
| 318 | ubInfo->realBatchUb = 1; | 320 | ubInfo->realBatchUb = 1; |
| 319 | } | 321 | } |
| 320 | ubInfo->outBatchIdx = self_->ctx.batchIter + ubInfo->batchLoopIdx * ubInfo->batchUb; | 322 | ubInfo->outBatchIdx = self_->ctx.batchIter + ubInfo->batchLoopIdx * ubInfo->batchUb; |
| 321 | - ubInfo->outCIdx = self_->ctx.nBL1Iter * self_->ctx.convTiling->nBL1 + | 323 | + if constexpr (Intf::isKL1NL0FullLoad) { |
| 322 | - self_->ctx.nL0Iter * self_->ctx.convTiling->nL0 + ubInfo->nLoopIdx * ubInfo->nUb; | 324 | + ubInfo->outCIdx = ubInfo->nLoopIdx * ubInfo->nUb; |
| 325 | + } else { | ||
| 326 | + ubInfo->outCIdx = self_->ctx.nBL1Iter * self_->ctx.convTilingData->convApiTiling.nBL1 + | ||
| 327 | + self_->ctx.nL0Iter * self_->ctx.convTilingData->convApiTiling.nL0 + ubInfo->nLoopIdx * ubInfo->nUb; | ||
| 328 | + } | ||
| 323 | ubInfo->outHIdx = 0; | 329 | ubInfo->outHIdx = 0; |
| 324 | ubInfo->outWIdx = self_->ctx.mAL1Iter * self_->ctx.mAL1 + | 330 | ubInfo->outWIdx = self_->ctx.mAL1Iter * self_->ctx.mAL1 + |
| 325 | self_->ctx.mL0Iter * self_->ctx.mL0 + ubInfo->mLoopIdx * ubInfo->mUb; | 331 | self_->ctx.mL0Iter * self_->ctx.mL0 + ubInfo->mLoopIdx * ubInfo->mUb; |
| @@ -329,28 +335,34 @@ private: | |||
| 329 | __aicore__ inline void SetBaseParams(FixpipeParamsC310<format> &intriParams) | 335 | __aicore__ inline void SetBaseParams(FixpipeParamsC310<format> &intriParams) |
| 330 | { | 336 | { |
| 331 | intriParams.quantPre = GetQuantPre<Intf, OutputT, FixpipeIdx>(self_); | 337 | intriParams.quantPre = GetQuantPre<Intf, OutputT, FixpipeIdx>(self_); |
| 332 | - if (self_->ctx.convTiling->hasScale == 0) { | 338 | + if (self_->ctx.convTilingData->convApiTiling.hasScale == 0) { |
| 333 | intriParams.deqScalar = DEQ_SCALAR_ONE; | 339 | intriParams.deqScalar = DEQ_SCALAR_ONE; |
| 334 | } | 340 | } |
| 335 | if constexpr (Intf::isExtendConv2d) { | 341 | if constexpr (Intf::isExtendConv2d) { |
| 336 | if constexpr (FixpipeIdx == 0) { | 342 | if constexpr (FixpipeIdx == 0) { |
| 337 | - intriParams.deqScalar = self_->ctx.deqScalar0; | 343 | + intriParams.reluEn = self_->ctx.convTilingData->convApiTiling.reluMode0 != 0; |
| 338 | - intriParams.reluEn = self_->ctx.convTiling->reluMode0 != 0; | ||
| 339 | #if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102) | 344 | #if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102) |
| 340 | - intriParams.preReluMode = static_cast<ReluMode>(self_->ctx.convTiling->reluMode0); | 345 | + intriParams.preReluMode = static_cast<ReluMode>(self_->ctx.convTilingData->convApiTiling.reluMode0); |
| 341 | - if (self_->ctx.convTiling->reluMode0 == static_cast<uint8_t>(ReluMode::SCALAR_RELU)) { | 346 | + if (self_->ctx.convTilingData->convApiTiling.reluMode0 == static_cast<uint8_t>(ReluMode::SCALAR_RELU)) { |
| 342 | intriParams.reluScalar = self_->ctx.preReluScalar0; | 347 | intriParams.reluScalar = self_->ctx.preReluScalar0; |
| 348 | + } else if (self_->ctx.convTilingData->convApiTiling.reluMode0 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { | ||
| 349 | + intriParams.vectorRelu = | ||
| 350 | + self_->ctx.reluWeightL1[GetExtendConv2dScaleL1Addr()].GetPhyAddr(); | ||
| 343 | } | 351 | } |
| 344 | #endif | 352 | #endif |
| 353 | + intriParams.deqScalar = self_->ctx.deqScalar0; | ||
| 345 | } else { | 354 | } else { |
| 346 | - intriParams.deqScalar = self_->ctx.deqScalar1; | 355 | + intriParams.reluEn = self_->ctx.convTilingData->convApiTiling.reluMode1 != 0; |
| 347 | - intriParams.reluEn = self_->ctx.convTiling->reluMode1 != 0; | ||
| 348 | #if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102) | 356 | #if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102) |
| 349 | - intriParams.preReluMode = static_cast<ReluMode>(self_->ctx.convTiling->reluMode1); | 357 | + intriParams.preReluMode = static_cast<ReluMode>(self_->ctx.convTilingData->convApiTiling.reluMode1); |
| 350 | - if (self_->ctx.convTiling->reluMode1 == static_cast<uint8_t>(ReluMode::SCALAR_RELU)) { | 358 | + if (self_->ctx.convTilingData->convApiTiling.reluMode1 == static_cast<uint8_t>(ReluMode::SCALAR_RELU)) { |
| 351 | intriParams.reluScalar = self_->ctx.preReluScalar1; | 359 | intriParams.reluScalar = self_->ctx.preReluScalar1; |
| 360 | + } else if(self_->ctx.convTilingData->convApiTiling.reluMode1 == static_cast<uint8_t>(ReluMode::VECTOR_RELU)) { | ||
| 361 | + intriParams.vectorRelu = | ||
| 362 | + self_->ctx.reluWeightL1[GetExtendConv2dScaleL1Addr() + self_->ctx.reluWeight1L1offset].GetPhyAddr(); | ||
| 352 | } | 363 | } |
| 353 | #endif | 364 | #endif |
| 365 | + intriParams.deqScalar = self_->ctx.deqScalar1; | ||
| 354 | } | 366 | } |
| 355 | } | 367 | } |
| 356 | 368 | ||
| @@ -359,10 +371,10 @@ private: | |||
| 359 | intriParams.unitFlag = UNIT_FLAG_ENABLE_WITH_FLIP; | 371 | intriParams.unitFlag = UNIT_FLAG_ENABLE_WITH_FLIP; |
| 360 | } else { | 372 | } else { |
| 361 | if constexpr (Intf::isExtendConv2d) { | 373 | if constexpr (Intf::isExtendConv2d) { |
| 362 | - if (!self_->ctx.convTiling->dualOutput) { | 374 | + if (self_->ctx.convTilingData->convApiTiling.dualOutput) { |
| 363 | - intriParams.unitFlag = UNIT_FLAG_ENABLE_WITH_FLIP; | ||
| 364 | - } else { | ||
| 365 | intriParams.unitFlag = UNIT_FLAG_ENABLE_ONLY; | 375 | intriParams.unitFlag = UNIT_FLAG_ENABLE_ONLY; |
| 376 | + } else { | ||
| 377 | + intriParams.unitFlag = UNIT_FLAG_ENABLE_WITH_FLIP; | ||
| 366 | } | 378 | } |
| 367 | } else { | 379 | } else { |
| 368 | intriParams.unitFlag = UNIT_FLAG_ENABLE_WITH_FLIP; | 380 | intriParams.unitFlag = UNIT_FLAG_ENABLE_WITH_FLIP; |
| @@ -424,27 +436,34 @@ private: | |||
| 424 | 436 | ||
| 425 | __aicore__ inline uint64_t CalcFixpipeOffset() | 437 | __aicore__ inline uint64_t CalcFixpipeOffset() |
| 426 | { | 438 | { |
| 427 | - uint64_t offset = self_->ctx.batchIter * self_->ctx.outputOneBatchSize; | 439 | + uint64_t offset = 0; |
| 428 | - if constexpr (Intf::isInnerBatchFlag) { | 440 | + if constexpr (!Intf::isOneBatch) { |
| 429 | - offset *= self_->ctx.convTiling->innerBatch; | 441 | + offset = self_->ctx.batchIter * self_->ctx.outputOneBatchSize; |
| 430 | } | 442 | } |
| 431 | - uint64_t offsetCout = self_->ctx.nBL1Iter * self_->ctx.convTiling->nBL1 + | 443 | + if constexpr (Intf::isInnerBatchFlag) { |
| 432 | - self_->ctx.nL0Iter * self_->ctx.convTiling->nL0; | 444 | + offset *= self_->ctx.convTilingData->convApiTiling.innerBatch; |
| 445 | + } | ||
| 446 | + | ||
| 447 | + uint64_t offsetCout = 0; | ||
| 433 | if constexpr (Intf::groupOptPreloadFlag) { | 448 | if constexpr (Intf::groupOptPreloadFlag) { |
| 434 | - offsetCout += self_->ctx.groupOptIter * self_->ctx.convTiling->orgCo / self_->ctx.convTiling->groups * | 449 | + offsetCout += self_->ctx.groupOptIter * self_->ctx.convTilingData->convApiTiling.orgCo / self_->ctx.convTilingData->convApiTiling.groups * |
| 435 | - self_->ctx.convTiling->enlarge; | 450 | + self_->ctx.convTilingData->convApiTiling.enlarge; |
| 451 | + } | ||
| 452 | + if constexpr (!Intf::isKL1NL0FullLoad) { | ||
| 453 | + offsetCout += self_->ctx.nBL1Iter * self_->ctx.convTilingData->convApiTiling.nBL1 + | ||
| 454 | + self_->ctx.nL0Iter * self_->ctx.convTilingData->convApiTiling.nL0; | ||
| 436 | } | 455 | } |
| 437 | uint64_t offsetMAL1 = self_->ctx.mAL1Iter * self_->ctx.mAL1 + | 456 | uint64_t offsetMAL1 = self_->ctx.mAL1Iter * self_->ctx.mAL1 + |
| 438 | self_->ctx.mL0Iter * self_->ctx.mL0; | 457 | self_->ctx.mL0Iter * self_->ctx.mL0; |
| 439 | 458 | ||
| 440 | if constexpr (Intf::formatOutput == ConvFormat::NCDHW) { | 459 | if constexpr (Intf::formatOutput == ConvFormat::NCDHW) { |
| 441 | - offset += offsetCout * self_->ctx.orgDo * valueHoWo_ + self_->ctx.dOutIter * valueHoWo_ + offsetMAL1; | 460 | + offset += offsetCout * self_->ctx.convTilingData->convApiTiling.orgDo * valueHoWo_ + self_->ctx.dOutIter * valueHoWo_ + offsetMAL1; |
| 442 | } else if constexpr (Intf::formatOutput == ConvFormat::NDHWC) { | 461 | } else if constexpr (Intf::formatOutput == ConvFormat::NDHWC) { |
| 443 | - offset += self_->ctx.dOutIter * valueHoWo_ * self_->ctx.orgCo + offsetMAL1 * self_->ctx.orgCo + offsetCout; | 462 | + offset += self_->ctx.dOutIter * valueHoWo_ * self_->ctx.convTilingData->convApiTiling.orgCo + offsetMAL1 * self_->ctx.convTilingData->convApiTiling.orgCo + offsetCout; |
| 444 | } else if constexpr (Intf::formatOutput == ConvFormat::NCHW) { | 463 | } else if constexpr (Intf::formatOutput == ConvFormat::NCHW) { |
| 445 | offset += offsetCout * valueHoWo_ + offsetMAL1; | 464 | offset += offsetCout * valueHoWo_ + offsetMAL1; |
| 446 | } else { | 465 | } else { |
| 447 | - offset += offsetMAL1 * self_->ctx.orgCo + offsetCout; | 466 | + offset += offsetMAL1 * self_->ctx.convTilingData->convApiTiling.orgCo + offsetCout; |
| 448 | } | 467 | } |
| 449 | 468 | ||
| 450 | return offset; | 469 | return offset; |
| @@ -470,10 +489,13 @@ private: | |||
| 470 | 489 | ||
| 471 | __aicore__ inline uint64_t GetScaleL1Addr() | 490 | __aicore__ inline uint64_t GetScaleL1Addr() |
| 472 | { | 491 | { |
| 492 | + if constexpr (Intf::isKL1NL0FullLoad) { | ||
| 493 | + return 0; | ||
| 494 | + } | ||
| 473 | if constexpr (Intf::isQuantScene) { | 495 | if constexpr (Intf::isQuantScene) { |
| 474 | - if (self_->ctx.convTiling->fixpParamsFullLoadFlag && self_->ctx.convTiling->hasScale != 0) { | 496 | + if (self_->ctx.convTilingData->convApiTiling.hasScale != 0 && self_->ctx.convTilingData->convApiTiling.fixpParamsFullLoadFlag) { |
| 475 | - return self_->ctx.nBL1Iter * self_->ctx.convTiling->nBL1 + | 497 | + return self_->ctx.nBL1Iter * self_->ctx.convTilingData->convApiTiling.nBL1 + |
| 476 | - self_->ctx.nL0Iter * self_->ctx.convTiling->nL0; | 498 | + self_->ctx.nL0Iter * self_->ctx.convTilingData->convApiTiling.nL0; |
| 477 | } | 499 | } |
| 478 | } | 500 | } |
| 479 | 501 | ||
| @@ -482,9 +504,12 @@ private: | |||
| 482 | 504 | ||
| 483 | __aicore__ inline uint64_t GetExtendConv2dScaleL1Addr() | 505 | __aicore__ inline uint64_t GetExtendConv2dScaleL1Addr() |
| 484 | { | 506 | { |
| 485 | - if (self_->ctx.convTiling->fixpParamsFullLoadFlag) { | 507 | + if constexpr (Intf::isKL1NL0FullLoad) { |
| 486 | - return self_->ctx.nBL1Iter * self_->ctx.convTiling->nBL1 + | 508 | + return 0; |
| 487 | - self_->ctx.nL0Iter * self_->ctx.convTiling->nL0; | 509 | + } |
| 510 | + if (self_->ctx.convTilingData->convApiTiling.fixpParamsFullLoadFlag) { | ||
| 511 | + return self_->ctx.nBL1Iter * self_->ctx.convTilingData->convApiTiling.nBL1 + | ||
| 512 | + self_->ctx.nL0Iter * self_->ctx.convTilingData->convApiTiling.nL0; | ||
| 488 | } | 513 | } |
| 489 | return 0; | 514 | return 0; |
| 490 | } | 515 | } |
| @@ -62,12 +62,12 @@ public: | |||
| 62 | if constexpr (Intf::groupOptPreloadFlag) { | 62 | if constexpr (Intf::groupOptPreloadFlag) { |
| 63 | uint64_t weightOneGroupSize = self_->ctx.coPerGroup * self_->ctx.ciPerGroup * self_->ctx.enlarge; | 63 | uint64_t weightOneGroupSize = self_->ctx.coPerGroup * self_->ctx.ciPerGroup * self_->ctx.enlarge; |
| 64 | if constexpr (Intf::formatOutput == ConvFormat::NCHW) { | 64 | if constexpr (Intf::formatOutput == ConvFormat::NCHW) { |
| 65 | - weightOneGroupSize *= self_->ctx.convTiling->kernelHxkernelWxkernelD; | 65 | + weightOneGroupSize *= self_->ctx.convTilingData->convApiTiling.kernelHxkernelWxkernelD; |
| 66 | } | 66 | } |
| 67 | gmOffset = weightOneGroupSize * self_->ctx.groupOptIter; | 67 | gmOffset = weightOneGroupSize * self_->ctx.groupOptIter; |
| 68 | } | 68 | } |
| 69 | if constexpr (Intf::formatOutput == ConvFormat::NDHWC || Intf::formatOutput == ConvFormat::NHWC) { | 69 | if constexpr (Intf::formatOutput == ConvFormat::NDHWC || Intf::formatOutput == ConvFormat::NHWC) { |
| 70 | - uint64_t curSrcCoOpt = self_->ctx.convTiling->orgCo; | 70 | + uint64_t curSrcCoOpt = self_->ctx.convTilingData->convApiTiling.orgCo; |
| 71 | copyParamsHWC.loopInfo.loopSrcStride[NDDMA_LOOP1_INDEX] = curSrcCoOpt; | 71 | copyParamsHWC.loopInfo.loopSrcStride[NDDMA_LOOP1_INDEX] = curSrcCoOpt; |
| 72 | copyParamsHWC.loopInfo.loopSrcStride[NDDMA_LOOP3_INDEX] = curSrcCoOpt * self_->ctx.ciPerGroup; | 72 | copyParamsHWC.loopInfo.loopSrcStride[NDDMA_LOOP3_INDEX] = curSrcCoOpt * self_->ctx.ciPerGroup; |
| 73 | copyParamsHWC.loopInfo.loopSize[NDDMA_LOOP2_INDEX] = self_->ctx.singleGroups; | 73 | copyParamsHWC.loopInfo.loopSize[NDDMA_LOOP2_INDEX] = self_->ctx.singleGroups; |
| @@ -83,7 +83,7 @@ public: | |||
| 83 | private: | 83 | private: |
| 84 | __aicore__ inline void NDDMAFirstSetCopyParamsCHW() | 84 | __aicore__ inline void NDDMAFirstSetCopyParamsCHW() |
| 85 | { | 85 | { |
| 86 | - uint64_t srcKSize = self_->ctx.ciPerGroup * self_->ctx.convTiling->kernelHxkernelWxkernelD; | 86 | + uint64_t srcKSize = self_->ctx.ciPerGroup * self_->ctx.convTilingData->convApiTiling.kernelHxkernelWxkernelD; |
| 87 | // NDDMA Loop0 params | 87 | // NDDMA Loop0 params |
| 88 | copyParams.loopInfo.loopSize[NDDMA_LOOP0_INDEX] = srcKSize; | 88 | copyParams.loopInfo.loopSize[NDDMA_LOOP0_INDEX] = srcKSize; |
| 89 | copyParams.loopInfo.loopSrcStride[NDDMA_LOOP0_INDEX] = 1; | 89 | copyParams.loopInfo.loopSrcStride[NDDMA_LOOP0_INDEX] = 1; |
| @@ -112,7 +112,7 @@ __aicore__ inline void NDDMAFirstSetCopyParamsCHW() | |||
| 112 | copyParamsHWC.loopInfo.loopDstStride[NDDMA_LOOP2_INDEX] = self_->ctx.coOptAlign * self_->ctx.ciPerGroup + | 112 | copyParamsHWC.loopInfo.loopDstStride[NDDMA_LOOP2_INDEX] = self_->ctx.coOptAlign * self_->ctx.ciPerGroup + |
| 113 | self_->ctx.coPerGroup; | 113 | self_->ctx.coPerGroup; |
| 114 | // NDDMA Loop3 params | 114 | // NDDMA Loop3 params |
| 115 | - copyParamsHWC.loopInfo.loopSize[NDDMA_LOOP3_INDEX] = self_->ctx.convTiling->kernelHxkernelWxkernelD; | 115 | + copyParamsHWC.loopInfo.loopSize[NDDMA_LOOP3_INDEX] = self_->ctx.convTilingData->convApiTiling.kernelHxkernelWxkernelD; |
| 116 | copyParamsHWC.loopInfo.loopDstStride[NDDMA_LOOP3_INDEX] = self_->ctx.coOptAlign * self_->ctx.ciOptAlign; | 116 | copyParamsHWC.loopInfo.loopDstStride[NDDMA_LOOP3_INDEX] = self_->ctx.coOptAlign * self_->ctx.ciOptAlign; |
| 117 | } | 117 | } |
| 118 | 118 | ||
| @@ -170,7 +170,7 @@ private: | |||
| 170 | for (uint8_t idx = 0; idx < Intf::k0; ++idx) { | 170 | for (uint8_t idx = 0; idx < Intf::k0; ++idx) { |
| 171 | indexTensor.SetValue(idx, curValue); | 171 | indexTensor.SetValue(idx, curValue); |
| 172 | if constexpr (Intf::formatOutput == ConvFormat::NCDHW || Intf::formatOutput == ConvFormat::NCHW) { | 172 | if constexpr (Intf::formatOutput == ConvFormat::NCDHW || Intf::formatOutput == ConvFormat::NCHW) { |
| 173 | - curValue += self_->ctx.convTiling->kernelHxkernelWxkernelD; | 173 | + curValue += self_->ctx.convTilingData->convApiTiling.kernelHxkernelWxkernelD; |
| 174 | } else { | 174 | } else { |
| 175 | curValue += self_->ctx.coOptAlign; | 175 | curValue += self_->ctx.coOptAlign; |
| 176 | } | 176 | } |
| @@ -209,10 +209,10 @@ private: | |||
| 209 | { | 209 | { |
| 210 | uint16_t ciLoopTimes = self_->ctx.ci1Opt; | 210 | uint16_t ciLoopTimes = self_->ctx.ci1Opt; |
| 211 | uint16_t coLoopTimes = coOptLoopTimes; | 211 | uint16_t coLoopTimes = coOptLoopTimes; |
| 212 | - uint16_t khkwLoopTimes = self_->ctx.convTiling->kernelHxkernelW; | 212 | + uint16_t khkwLoopTimes = self_->ctx.convTilingData->convApiTiling.kernelHxkernelW; |
| 213 | - uint32_t srcCiStride = self_->ctx.convTiling->kernelHxkernelW * Intf::k0; | 213 | + uint32_t srcCiStride = self_->ctx.convTilingData->convApiTiling.kernelHxkernelW * Intf::k0; |
| 214 | uint32_t srcCoStride = coPerReg * self_->ctx.kUbSize; | 214 | uint32_t srcCoStride = coPerReg * self_->ctx.kUbSize; |
| 215 | - uint32_t dstCiStride = self_->ctx.convTiling->kernelHxkernelW * Intf::k0 * self_->ctx.coOptAlign; | 215 | + uint32_t dstCiStride = self_->ctx.convTilingData->convApiTiling.kernelHxkernelW * Intf::k0 * self_->ctx.coOptAlign; |
| 216 | uint32_t dstKhKwStride = Intf::k0 * self_->ctx.coOptAlign; | 216 | uint32_t dstKhKwStride = Intf::k0 * self_->ctx.coOptAlign; |
| 217 | uint32_t dstCoStride = coPerReg * Intf::k0; | 217 | uint32_t dstCoStride = coPerReg * Intf::k0; |
| 218 | 218 | ||
| @@ -262,16 +262,16 @@ private: | |||
| 262 | 262 | ||
| 263 | __aicore__ inline void TransNCDHW2NZ() | 263 | __aicore__ inline void TransNCDHW2NZ() |
| 264 | { | 264 | { |
| 265 | - uint16_t kdLoopTimes = self_->ctx.convTiling->kernelD; | 265 | + uint16_t kdLoopTimes = self_->ctx.convTilingData->convApiTiling.kernelD; |
| 266 | uint16_t ciLoopTimes = self_->ctx.ci1Opt; | 266 | uint16_t ciLoopTimes = self_->ctx.ci1Opt; |
| 267 | uint16_t coLoopTimes = coOptLoopTimes; | 267 | uint16_t coLoopTimes = coOptLoopTimes; |
| 268 | - uint16_t khkwLoopTimes = self_->ctx.convTiling->kernelHxkernelW; | 268 | + uint16_t khkwLoopTimes = self_->ctx.convTilingData->convApiTiling.kernelHxkernelW; |
| 269 | - uint32_t srcCiStride = self_->ctx.convTiling->kernelHxkernelWxkernelD * Intf::k0; | 269 | + uint32_t srcCiStride = self_->ctx.convTilingData->convApiTiling.kernelHxkernelWxkernelD * Intf::k0; |
| 270 | uint32_t srcCoStride = coPerReg * self_->ctx.kUbSize; | 270 | uint32_t srcCoStride = coPerReg * self_->ctx.kUbSize; |
| 271 | - uint32_t dstCiStride = self_->ctx.convTiling->kernelHxkernelW * Intf::k0 * self_->ctx.coOptAlign; | 271 | + uint32_t dstCiStride = self_->ctx.convTilingData->convApiTiling.kernelHxkernelW * Intf::k0 * self_->ctx.coOptAlign; |
| 272 | uint32_t dstKhKwStride = Intf::k0 * self_->ctx.coOptAlign; | 272 | uint32_t dstKhKwStride = Intf::k0 * self_->ctx.coOptAlign; |
| 273 | uint32_t dstCoStride = coPerReg * Intf::k0; | 273 | uint32_t dstCoStride = coPerReg * Intf::k0; |
| 274 | - uint32_t srcKdStride = self_->ctx.convTiling->kernelHxkernelW; | 274 | + uint32_t srcKdStride = self_->ctx.convTilingData->convApiTiling.kernelHxkernelW; |
| 275 | uint32_t dstKdStride = self_->ctx.ci1Opt * dstCiStride; | 275 | uint32_t dstKdStride = self_->ctx.ci1Opt * dstCiStride; |
| 276 | 276 | ||
| 277 | __VEC_SCOPE__ | 277 | __VEC_SCOPE__ |
| @@ -321,19 +321,19 @@ private: | |||
| 321 | 321 | ||
| 322 | __aicore__ inline void TransNDHWC2NZ() | 322 | __aicore__ inline void TransNDHWC2NZ() |
| 323 | { | 323 | { |
| 324 | - uint16_t kdLoopTimes = self_->ctx.convTiling->kernelD; | 324 | + uint16_t kdLoopTimes = self_->ctx.convTilingData->convApiTiling.kernelD; |
| 325 | uint16_t ciLoopTimes = self_->ctx.ci1Opt; | 325 | uint16_t ciLoopTimes = self_->ctx.ci1Opt; |
| 326 | uint16_t coLoopTimes = coOptLoopTimes; | 326 | uint16_t coLoopTimes = coOptLoopTimes; |
| 327 | - uint16_t khkwLoopTimes = self_->ctx.convTiling->kernelHxkernelW; | 327 | + uint16_t khkwLoopTimes = self_->ctx.convTilingData->convApiTiling.kernelHxkernelW; |
| 328 | uint32_t srcGroupOptSize = self_->ctx.coOptAlign * self_->ctx.ciOptAlign; | 328 | uint32_t srcGroupOptSize = self_->ctx.coOptAlign * self_->ctx.ciOptAlign; |
| 329 | uint32_t srcCiStride = self_->ctx.coOptAlign * Intf::k0; | 329 | uint32_t srcCiStride = self_->ctx.coOptAlign * Intf::k0; |
| 330 | uint32_t srcCoStride = coPerReg; | 330 | uint32_t srcCoStride = coPerReg; |
| 331 | - uint32_t dstCiStride = self_->ctx.convTiling->kernelHxkernelW * Intf::k0 * self_->ctx.coOptAlign; | 331 | + uint32_t dstCiStride = self_->ctx.convTilingData->convApiTiling.kernelHxkernelW * Intf::k0 * self_->ctx.coOptAlign; |
| 332 | uint32_t dstKhKwStride = Intf::k0 * self_->ctx.coOptAlign; | 332 | uint32_t dstKhKwStride = Intf::k0 * self_->ctx.coOptAlign; |
| 333 | uint32_t srcKhKwStride = srcGroupOptSize; | 333 | uint32_t srcKhKwStride = srcGroupOptSize; |
| 334 | uint32_t dstCoStride = coPerReg * Intf::k0; | 334 | uint32_t dstCoStride = coPerReg * Intf::k0; |
| 335 | - uint32_t srcKdStride = self_->ctx.convTiling->kernelHxkernelW * srcGroupOptSize; | 335 | + uint32_t srcKdStride = self_->ctx.convTilingData->convApiTiling.kernelHxkernelW * srcGroupOptSize; |
| 336 | - uint32_t dstKdStride = self_->ctx.convTiling->kernelHxkernelW * self_->ctx.coOptAlign * | 336 | + uint32_t dstKdStride = self_->ctx.convTilingData->convApiTiling.kernelHxkernelW * self_->ctx.coOptAlign * |
| 337 | self_->ctx.ci1Opt * Intf::k0; // ci1Opt has updated in groupOptTail | 337 | self_->ctx.ci1Opt * Intf::k0; // ci1Opt has updated in groupOptTail |
| 338 | __VEC_SCOPE__ | 338 | __VEC_SCOPE__ |
| 339 | { | 339 | { |
| @@ -383,12 +383,12 @@ private: | |||
| 383 | __aicore__ inline void TransNHWC2NZ() | 383 | __aicore__ inline void TransNHWC2NZ() |
| 384 | { | 384 | { |
| 385 | uint16_t ciLoopTimes = self_->ctx.ci1Opt; | 385 | uint16_t ciLoopTimes = self_->ctx.ci1Opt; |
| 386 | - uint16_t khkwLoopTimes = self_->ctx.convTiling->kernelHxkernelW; | 386 | + uint16_t khkwLoopTimes = self_->ctx.convTilingData->convApiTiling.kernelHxkernelW; |
| 387 | uint16_t coLoopTimes = coOptLoopTimes; | 387 | uint16_t coLoopTimes = coOptLoopTimes; |
| 388 | uint32_t srcCiStride = self_->ctx.coOptAlign * Intf::k0; | 388 | uint32_t srcCiStride = self_->ctx.coOptAlign * Intf::k0; |
| 389 | uint32_t srcKhKwStride = self_->ctx.coOptAlign * self_->ctx.ciOptAlign; | 389 | uint32_t srcKhKwStride = self_->ctx.coOptAlign * self_->ctx.ciOptAlign; |
| 390 | uint32_t srcCoStride = coPerReg; | 390 | uint32_t srcCoStride = coPerReg; |
| 391 | - uint32_t dstCiStride = self_->ctx.convTiling->kernelHxkernelW * Intf::k0 * self_->ctx.coOptAlign; | 391 | + uint32_t dstCiStride = self_->ctx.convTilingData->convApiTiling.kernelHxkernelW * Intf::k0 * self_->ctx.coOptAlign; |
| 392 | uint32_t dstKhKwStride = Intf::k0 * self_->ctx.coOptAlign; | 392 | uint32_t dstKhKwStride = Intf::k0 * self_->ctx.coOptAlign; |
| 393 | uint32_t dstCoStride = coPerReg * Intf::k0; | 393 | uint32_t dstCoStride = coPerReg * Intf::k0; |
| 394 | 394 | ||
| @@ -482,30 +482,39 @@ private: | |||
| 482 | __aicore__ inline void SetCopyParams2D() | 482 | __aicore__ inline void SetCopyParams2D() |
| 483 | { | 483 | { |
| 484 | if (unlikely(self_->ctx.groupOptIter == self_->ctx.vecId)) { | 484 | if (unlikely(self_->ctx.groupOptIter == self_->ctx.vecId)) { |
| 485 | - copyParams.blockCount = self_->ctx.convTiling->kBL1 / Intf::k0; | 485 | + copyParams.blockCount = self_->ctx.convTilingData->convApiTiling.kBL1 / Intf::k0; |
| 486 | - copyParams.blockLen = self_->ctx.convTiling->nBL1; | 486 | + copyParams.blockLen = self_->ctx.convTilingData->convApiTiling.nBL1; |
| 487 | - copyParams.srcStride = self_->ctx.co1Opt * BLOCK_L0_N - self_->ctx.convTiling->nBL1; | 487 | + copyParams.srcStride = self_->ctx.co1Opt * BLOCK_L0_N - self_->ctx.convTilingData->convApiTiling.nBL1; |
| 488 | } | 488 | } |
| 489 | 489 | ||
| 490 | - srcOffset = (self_->ctx.coStartPos + self_->ctx.nBL1Iter * self_->ctx.convTiling->nBL1) * Intf::k0 + | 490 | + if constexpr (Intf::isKL1NL0FullLoad) { |
| 491 | - self_->ctx.kBL1Iter * self_->ctx.convTiling->kBL1 * self_->ctx.coOptAlign; | 491 | + srcOffset = self_->ctx.coStartPos * Intf::k0 + |
| 492 | + self_->ctx.kBL1Iter * self_->ctx.convTilingData->convApiTiling.kBL1 * self_->ctx.coOptAlign; | ||
| 493 | + } else { | ||
| 494 | + srcOffset = (self_->ctx.coStartPos + self_->ctx.nBL1Iter * self_->ctx.convTilingData->convApiTiling.nBL1) * Intf::k0 + | ||
| 495 | + self_->ctx.kBL1Iter * self_->ctx.convTilingData->convApiTiling.kBL1 * self_->ctx.coOptAlign; | ||
| 496 | + } | ||
| 492 | } | 497 | } |
| 493 | 498 | ||
| 494 | __aicore__ inline void SetCopyParams3D() | 499 | __aicore__ inline void SetCopyParams3D() |
| 495 | { | 500 | { |
| 496 | if (unlikely(self_->ctx.loadUB2L1Iter == 0)) { | 501 | if (unlikely(self_->ctx.loadUB2L1Iter == 0)) { |
| 497 | - copyParams.blockLen = self_->ctx.convTiling->nBL1; | 502 | + copyParams.blockLen = self_->ctx.convTilingData->convApiTiling.nBL1; |
| 498 | - copyParams.srcStride = self_->ctx.co1Opt * BLOCK_L0_N - self_->ctx.convTiling->nBL1; | 503 | + copyParams.srcStride = self_->ctx.co1Opt * BLOCK_L0_N - self_->ctx.convTilingData->convApiTiling.nBL1; |
| 499 | - kOffset = self_->ctx.bL1Dk * self_->ctx.bL1Cin * self_->ctx.convTiling->kernelHxkernelW; | 504 | + kOffset = self_->ctx.bL1Dk * self_->ctx.bL1Cin * self_->ctx.convTilingData->convApiTiling.kernelHxkernelW; |
| 500 | } | 505 | } |
| 501 | 506 | ||
| 502 | uint64_t currentBL1Dk = IsKBL1Tail() ? self_->ctx.bL1DkTail : self_->ctx.bL1Dk; | 507 | uint64_t currentBL1Dk = IsKBL1Tail() ? self_->ctx.bL1DkTail : self_->ctx.bL1Dk; |
| 503 | uint64_t currentBL1Cin1 = IsKBL1Tail() ? self_->ctx.bL1CinTail : self_->ctx.bL1Cin; | 508 | uint64_t currentBL1Cin1 = IsKBL1Tail() ? self_->ctx.bL1CinTail : self_->ctx.bL1Cin; |
| 504 | copyParams.blockCount = currentBL1Dk * CeilDiv(currentBL1Cin1, Intf::k0) * | 509 | copyParams.blockCount = currentBL1Dk * CeilDiv(currentBL1Cin1, Intf::k0) * |
| 505 | - self_->ctx.convTiling->kernelHxkernelW; | 510 | + self_->ctx.convTilingData->convApiTiling.kernelHxkernelW; |
| 506 | 511 | ||
| 507 | - srcOffset = (self_->ctx.coStartPos + self_->ctx.nBL1Iter * self_->ctx.convTiling->nBL1) * Intf::k0 + | 512 | + if constexpr (Intf::isKL1NL0FullLoad) { |
| 508 | - self_->ctx.kBL1Iter * kOffset * self_->ctx.coOptAlign; | 513 | + srcOffset = self_->ctx.coStartPos * Intf::k0 + self_->ctx.kBL1Iter * kOffset * self_->ctx.coOptAlign; |
| 514 | + } else { | ||
| 515 | + srcOffset = (self_->ctx.coStartPos + self_->ctx.nBL1Iter * self_->ctx.convTilingData->convApiTiling.nBL1) * Intf::k0 + | ||
| 516 | + self_->ctx.kBL1Iter * kOffset * self_->ctx.coOptAlign; | ||
| 517 | + } | ||
| 509 | } | 518 | } |
| 510 | 519 | ||
| 511 | __aicore__ inline bool IsKBL1Tail() | 520 | __aicore__ inline bool IsKBL1Tail() |
| @@ -61,11 +61,10 @@ template <class Intf> | |||
| 61 | static __aicore__ inline void InitBatchDirectionValue(Intf *self) | 61 | static __aicore__ inline void InitBatchDirectionValue(Intf *self) |
| 62 | { | 62 | { |
| 63 | if constexpr (Intf::isInnerBatchFlag) { | 63 | if constexpr (Intf::isInnerBatchFlag) { |
| 64 | - self->ctx.ddr2l1LoopBatch = CeilDiv(self->ctx.singleCoreBatch, self->ctx.convTiling->innerBatch); | 64 | + self->ctx.ddr2l1LoopBatch = CeilDiv(self->ctx.singleCoreBatch, self->ctx.convTilingData->convApiTiling.innerBatch); |
| 65 | - self->ctx.maxBatchIter = self->ctx.ddr2l1LoopBatch - 1; | 65 | + self->ctx.innerBatchTail = self->ctx.singleCoreBatch % self->ctx.convTilingData->convApiTiling.innerBatch; |
| 66 | - self->ctx.innerBatchTail = self->ctx.singleCoreBatch % self->ctx.convTiling->innerBatch; | ||
| 67 | self->ctx.innerBatchTail = self->ctx.innerBatchTail == 0 ? | 66 | self->ctx.innerBatchTail = self->ctx.innerBatchTail == 0 ? |
| 68 | - self->ctx.convTiling->innerBatch : self->ctx.innerBatchTail; | 67 | + self->ctx.convTilingData->convApiTiling.innerBatch : self->ctx.innerBatchTail; |
| 69 | } else { | 68 | } else { |
| 70 | self->ctx.ddr2l1LoopBatch = self->ctx.singleCoreBatch; | 69 | self->ctx.ddr2l1LoopBatch = self->ctx.singleCoreBatch; |
| 71 | } | 70 | } |
| @@ -28,11 +28,11 @@ template <class Intf> | |||
| 28 | static __aicore__ inline void InitHoDirectionValue(Intf *self) | 28 | static __aicore__ inline void InitHoDirectionValue(Intf *self) |
| 29 | { | 29 | { |
| 30 | // Ho方向L1及L0均全载时相关变量赋值 | 30 | // Ho方向L1及L0均全载时相关变量赋值 |
| 31 | - self->ctx.hoAL1Tail = self->ctx.singleCoreHo % self->ctx.convTiling->hoL1; | 31 | + self->ctx.hoAL1Tail = self->ctx.singleCoreHo % self->ctx.convTilingData->convApiTiling.hoL1; |
| 32 | - self->ctx.hoAL1Tail = self->ctx.hoAL1Tail == 0 ? self->ctx.convTiling->hoL1 : self->ctx.hoAL1Tail; | 32 | + self->ctx.hoAL1Tail = self->ctx.hoAL1Tail == 0 ? self->ctx.convTilingData->convApiTiling.hoL1 : self->ctx.hoAL1Tail; |
| 33 | self->ctx.currentHoL1 = self->ctx.hoAL1Tail; | 33 | self->ctx.currentHoL1 = self->ctx.hoAL1Tail; |
| 34 | - self->ctx.hoL0Tail = self->ctx.currentHoL1 % self->ctx.convTiling->hoL0; | 34 | + self->ctx.hoL0Tail = self->ctx.currentHoL1 % self->ctx.convTilingData->convApiTiling.hoL0; |
| 35 | - self->ctx.hoL0Tail = self->ctx.hoL0Tail == 0 ? self->ctx.convTiling->hoL0 : self->ctx.hoL0Tail; | 35 | + self->ctx.hoL0Tail = self->ctx.hoL0Tail == 0 ? self->ctx.convTilingData->convApiTiling.hoL0 : self->ctx.hoL0Tail; |
| 36 | self->ctx.currentHoL0 = self->ctx.hoL0Tail; | 36 | self->ctx.currentHoL0 = self->ctx.hoL0Tail; |
| 37 | 37 | ||
| 38 | // Ho方向变量计算 | 38 | // Ho方向变量计算 |
| @@ -40,7 +40,7 @@ static __aicore__ inline void InitHoDirectionValue(Intf *self) | |||
| 40 | self->ctx.ddr2l1LoopH = 1; | 40 | self->ctx.ddr2l1LoopH = 1; |
| 41 | self->ctx.maxHoL1Iter = 0; | 41 | self->ctx.maxHoL1Iter = 0; |
| 42 | } else { | 42 | } else { |
| 43 | - self->ctx.ddr2l1LoopH = CeilDiv(self->ctx.singleCoreHo, self->ctx.convTiling->hoL1); | 43 | + self->ctx.ddr2l1LoopH = CeilDiv(self->ctx.singleCoreHo, self->ctx.convTilingData->convApiTiling.hoL1); |
| 44 | self->ctx.maxHoL1Iter = self->ctx.ddr2l1LoopH - 1; | 44 | self->ctx.maxHoL1Iter = self->ctx.ddr2l1LoopH - 1; |
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| @@ -49,26 +49,26 @@ template <class Intf> | |||
| 49 | static __aicore__ inline void InitWoDirectionValue(Intf *self) | 49 | static __aicore__ inline void InitWoDirectionValue(Intf *self) |
| 50 | { | 50 | { |
| 51 | // Wo方向L1及L0均全载时相关变量赋值 | 51 | // Wo方向L1及L0均全载时相关变量赋值 |
| 52 | - self->ctx.woAL1Tail = self->ctx.singleCoreWo % self->ctx.convTiling->woL1; | 52 | + self->ctx.woAL1Tail = self->ctx.singleCoreWo % self->ctx.convTilingData->convApiTiling.woL1; |
| 53 | - self->ctx.woAL1Tail = self->ctx.woAL1Tail == 0 ? self->ctx.convTiling->woL1 : self->ctx.woAL1Tail; | 53 | + self->ctx.woAL1Tail = self->ctx.woAL1Tail == 0 ? self->ctx.convTilingData->convApiTiling.woL1 : self->ctx.woAL1Tail; |
| 54 | self->ctx.currentWoL1 = self->ctx.woAL1Tail; | 54 | self->ctx.currentWoL1 = self->ctx.woAL1Tail; |
| 55 | self->ctx.maxWoL1Iter = 0; | 55 | self->ctx.maxWoL1Iter = 0; |
| 56 | - self->ctx.woL0Tail = self->ctx.currentWoL1 % self->ctx.convTiling->woL0; | 56 | + self->ctx.woL0Tail = self->ctx.currentWoL1 % self->ctx.convTilingData->convApiTiling.woL0; |
| 57 | - self->ctx.woL0Tail = self->ctx.woL0Tail == 0 ? self->ctx.convTiling->woL0 : self->ctx.woL0Tail; | 57 | + self->ctx.woL0Tail = self->ctx.woL0Tail == 0 ? self->ctx.convTilingData->convApiTiling.woL0 : self->ctx.woL0Tail; |
| 58 | self->ctx.currentWoL0 = self->ctx.woL0Tail; | 58 | self->ctx.currentWoL0 = self->ctx.woL0Tail; |
| 59 | self->ctx.maxWoL0Iter = 0; | 59 | self->ctx.maxWoL0Iter = 0; |
| 60 | self->ctx.l12l0LoopW = 1; | 60 | self->ctx.l12l0LoopW = 1; |
| 61 | 61 | ||
| 62 | // Wo方向变量计算 | 62 | // Wo方向变量计算 |
| 63 | if constexpr (Intf::hasWL1IterFlag) { | 63 | if constexpr (Intf::hasWL1IterFlag) { |
| 64 | - self->ctx.maxWoL1Iter = CeilDiv(self->ctx.singleCoreWo, self->ctx.convTiling->woL1) - 1; | 64 | + self->ctx.maxWoL1Iter = CeilDiv(self->ctx.singleCoreWo, self->ctx.convTilingData->convApiTiling.woL1) - 1; |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | if constexpr (!Intf::isDmaFlag) { | 67 | if constexpr (!Intf::isDmaFlag) { |
| 68 | - if (Intf::hasWL0IterFlag && self->ctx.convTiling->hoL0 > 1 && self->ctx.woAL1Tail % BLOCK_L0_N > 0 && | 68 | + if (Intf::hasWL0IterFlag && self->ctx.convTilingData->convApiTiling.hoL0 > 1 && self->ctx.woAL1Tail % BLOCK_L0_N > 0 && |
| 69 | - CeilDiv(self->ctx.woAL1Tail, self->ctx.convTiling->woL0) > 1) { | 69 | + CeilDiv(self->ctx.woAL1Tail, self->ctx.convTilingData->convApiTiling.woL0) > 1) { |
| 70 | - self->ctx.woL1SmallTail = self->ctx.woAL1Tail % self->ctx.convTiling->woL0; | 70 | + self->ctx.woL1SmallTail = self->ctx.woAL1Tail % self->ctx.convTilingData->convApiTiling.woL0; |
| 71 | - self->ctx.woAL1Tail = (self->ctx.woAL1Tail / self->ctx.convTiling->woL0) * self->ctx.convTiling->woL0; | 71 | + self->ctx.woAL1Tail = (self->ctx.woAL1Tail / self->ctx.convTilingData->convApiTiling.woL0) * self->ctx.convTilingData->convApiTiling.woL0; |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | if (self->ctx.woL1SmallTail > 0) { | 74 | if (self->ctx.woL1SmallTail > 0) { |
| @@ -89,17 +89,17 @@ __aicore__ inline void CalcWoDirectionVar(Intf *self) | |||
| 89 | } else if (self->ctx.woAL1Iter == self->ctx.maxWoL1Iter - 1) { | 89 | } else if (self->ctx.woAL1Iter == self->ctx.maxWoL1Iter - 1) { |
| 90 | self->ctx.currentWoL1 = self->ctx.woAL1Tail; | 90 | self->ctx.currentWoL1 = self->ctx.woAL1Tail; |
| 91 | } else { | 91 | } else { |
| 92 | - self->ctx.currentWoL1 = self->ctx.convTiling->woL1; | 92 | + self->ctx.currentWoL1 = self->ctx.convTilingData->convApiTiling.woL1; |
| 93 | } | 93 | } |
| 94 | } else { | 94 | } else { |
| 95 | self->ctx.currentWoL1 = self->ctx.woAL1Iter == self->ctx.maxWoL1Iter ? | 95 | self->ctx.currentWoL1 = self->ctx.woAL1Iter == self->ctx.maxWoL1Iter ? |
| 96 | - self->ctx.woAL1Tail : self->ctx.convTiling->woL1; | 96 | + self->ctx.woAL1Tail : self->ctx.convTilingData->convApiTiling.woL1; |
| 97 | } | 97 | } |
| 98 | } | 98 | } |
| 99 | if constexpr (Intf::hasWL0IterFlag) { | 99 | if constexpr (Intf::hasWL0IterFlag) { |
| 100 | - self->ctx.woL0Tail = self->ctx.currentWoL1 % self->ctx.convTiling->woL0; | 100 | + self->ctx.woL0Tail = self->ctx.currentWoL1 % self->ctx.convTilingData->convApiTiling.woL0; |
| 101 | - self->ctx.woL0Tail = self->ctx.woL0Tail == 0 ? self->ctx.convTiling->woL0 : self->ctx.woL0Tail; | 101 | + self->ctx.woL0Tail = self->ctx.woL0Tail == 0 ? self->ctx.convTilingData->convApiTiling.woL0 : self->ctx.woL0Tail; |
| 102 | - self->ctx.maxWoL0Iter = CeilDiv(self->ctx.currentWoL1, self->ctx.convTiling->woL0) - 1; | 102 | + self->ctx.maxWoL0Iter = CeilDiv(self->ctx.currentWoL1, self->ctx.convTilingData->convApiTiling.woL0) - 1; |
| 103 | self->ctx.l12l0LoopW = self->ctx.maxWoL0Iter + 1; | 103 | self->ctx.l12l0LoopW = self->ctx.maxWoL0Iter + 1; |
| 104 | } | 104 | } |
| 105 | } | 105 | } |
| @@ -109,13 +109,13 @@ __aicore__ inline void CalcHoDirectionVar(Intf *self) | |||
| 109 | { | 109 | { |
| 110 | if constexpr (Intf::hasHL1IterFlag) { | 110 | if constexpr (Intf::hasHL1IterFlag) { |
| 111 | self->ctx.currentHoL1 = self->ctx.hoAL1Iter == self->ctx.maxHoL1Iter ? | 111 | self->ctx.currentHoL1 = self->ctx.hoAL1Iter == self->ctx.maxHoL1Iter ? |
| 112 | - self->ctx.hoAL1Tail : self->ctx.convTiling->hoL1; | 112 | + self->ctx.hoAL1Tail : self->ctx.convTilingData->convApiTiling.hoL1; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | if constexpr (Intf::hasHL0IterFlag) { | 115 | if constexpr (Intf::hasHL0IterFlag) { |
| 116 | - self->ctx.hoL0Tail = self->ctx.currentHoL1 % self->ctx.convTiling->hoL0; | 116 | + self->ctx.hoL0Tail = self->ctx.currentHoL1 % self->ctx.convTilingData->convApiTiling.hoL0; |
| 117 | - self->ctx.hoL0Tail = self->ctx.hoL0Tail == 0 ? self->ctx.convTiling->hoL0 : self->ctx.hoL0Tail; | 117 | + self->ctx.hoL0Tail = self->ctx.hoL0Tail == 0 ? self->ctx.convTilingData->convApiTiling.hoL0 : self->ctx.hoL0Tail; |
| 118 | - self->ctx.maxHoL0Iter = CeilDiv(self->ctx.currentHoL1, self->ctx.convTiling->hoL0) - 1; | 118 | + self->ctx.maxHoL0Iter = CeilDiv(self->ctx.currentHoL1, self->ctx.convTilingData->convApiTiling.hoL0) - 1; |
| 119 | self->ctx.l12l0LoopH = self->ctx.maxHoL0Iter + 1; | 119 | self->ctx.l12l0LoopH = self->ctx.maxHoL0Iter + 1; |
| 120 | } | 120 | } |
| 121 | } | 121 | } |
| @@ -124,36 +124,36 @@ template <class Intf> | |||
| 124 | __aicore__ inline void UpdateHoL0WoL0(Intf *self) | 124 | __aicore__ inline void UpdateHoL0WoL0(Intf *self) |
| 125 | { | 125 | { |
| 126 | self->ctx.currentHoL0 = self->ctx.hoL0Iter == self->ctx.maxHoL0Iter ? | 126 | self->ctx.currentHoL0 = self->ctx.hoL0Iter == self->ctx.maxHoL0Iter ? |
| 127 | - self->ctx.hoL0Tail : self->ctx.convTiling->hoL0; | 127 | + self->ctx.hoL0Tail : self->ctx.convTilingData->convApiTiling.hoL0; |
| 128 | self->ctx.currentWoL0 = self->ctx.woL0Iter == self->ctx.maxWoL0Iter ? | 128 | self->ctx.currentWoL0 = self->ctx.woL0Iter == self->ctx.maxWoL0Iter ? |
| 129 | - self->ctx.woL0Tail : self->ctx.convTiling->woL0; | 129 | + self->ctx.woL0Tail : self->ctx.convTilingData->convApiTiling.woL0; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | template <class Intf> | 132 | template <class Intf> |
| 133 | __aicore__ inline void CalcGroupOptParamForHWMode(Intf *self) | 133 | __aicore__ inline void CalcGroupOptParamForHWMode(Intf *self) |
| 134 | { | 134 | { |
| 135 | if (((self->ctx.groupOptIter + 1 == self->ctx.singleGroupOpt - 1 && self->ctx.groupOptIter != 0) || | 135 | if (((self->ctx.groupOptIter + 1 == self->ctx.singleGroupOpt - 1 && self->ctx.groupOptIter != 0) || |
| 136 | - self->ctx.singleGroupOpt == 1) && self->ctx.updateEnlarge != self->ctx.convTiling->enlarge) { | 136 | + self->ctx.singleGroupOpt == 1) && self->ctx.updateEnlarge != self->ctx.convTilingData->convApiTiling.enlarge) { |
| 137 | self->ctx.singleGroups = self->ctx.updateEnlarge; | 137 | self->ctx.singleGroups = self->ctx.updateEnlarge; |
| 138 | - self->ctx.singleGroups = self->ctx.singleGroups == 0 ? self->ctx.convTiling->enlarge : self->ctx.singleGroups; | 138 | + self->ctx.singleGroups = self->ctx.singleGroups == 0 ? self->ctx.convTilingData->convApiTiling.enlarge : self->ctx.singleGroups; |
| 139 | } | 139 | } |
| 140 | - uint64_t enlargeTail = self->ctx.singleGroups % self->ctx.convTiling->enlarge; | 140 | + uint64_t enlargeTail = self->ctx.singleGroups % self->ctx.convTilingData->convApiTiling.enlarge; |
| 141 | - enlargeTail = enlargeTail == 0 ? self->ctx.convTiling->enlarge : enlargeTail; | 141 | + enlargeTail = enlargeTail == 0 ? self->ctx.convTilingData->convApiTiling.enlarge : enlargeTail; |
| 142 | - if (enlargeTail != self->ctx.convTiling->enlarge) { | 142 | + if (enlargeTail != self->ctx.convTilingData->convApiTiling.enlarge) { |
| 143 | - self->ctx.singleCoreCi = enlargeTail * (self->ctx.convTiling->orgCi / self->ctx.convTiling->groups); | 143 | + self->ctx.singleCoreCi = enlargeTail * (self->ctx.convTilingData->convApiTiling.orgCi / self->ctx.convTilingData->convApiTiling.groups); |
| 144 | if (self->ctx.groupOptIter == self->ctx.singleGroupOpt - 1) { | 144 | if (self->ctx.groupOptIter == self->ctx.singleGroupOpt - 1) { |
| 145 | self->ctx.singleCoreCo = self->ctx.updateSingleCoOpt; | 145 | self->ctx.singleCoreCo = self->ctx.updateSingleCoOpt; |
| 146 | 146 | ||
| 147 | - uint64_t totalKAlignK0 = AlignB(self->ctx.singleCoreCi, Intf::k0) * self->ctx.convTiling->kernelHxkernelW; | 147 | + uint64_t totalKAlignK0 = AlignB(self->ctx.singleCoreCi, Intf::k0) * self->ctx.convTilingData->convApiTiling.kernelHxkernelW; |
| 148 | - self->ctx.ddr2l0LoopK = CeilDiv(totalKAlignK0, self->ctx.convTiling->kL0); | 148 | + self->ctx.ddr2l0LoopK = CeilDiv(totalKAlignK0, self->ctx.convTilingData->convApiTiling.kL0); |
| 149 | self->ctx.maxKL0Iter = self->ctx.ddr2l0LoopK - 1; | 149 | self->ctx.maxKL0Iter = self->ctx.ddr2l0LoopK - 1; |
| 150 | - self->ctx.kL0Tail = totalKAlignK0 % self->ctx.convTiling->kL0; | 150 | + self->ctx.kL0Tail = totalKAlignK0 % self->ctx.convTilingData->convApiTiling.kL0; |
| 151 | if constexpr (Intf::k0 != Intf::k0FmapTail) { | 151 | if constexpr (Intf::k0 != Intf::k0FmapTail) { |
| 152 | self->ctx.kAL0Tail = AlignB(self->ctx.singleCoreCi, Intf::k0FmapTail) * | 152 | self->ctx.kAL0Tail = AlignB(self->ctx.singleCoreCi, Intf::k0FmapTail) * |
| 153 | - self->ctx.convTiling->kernelHxkernelW % self->ctx.convTiling->kL0; | 153 | + self->ctx.convTilingData->convApiTiling.kernelHxkernelW % self->ctx.convTilingData->convApiTiling.kL0; |
| 154 | - self->ctx.kAL0Tail = self->ctx.kAL0Tail == 0 ? self->ctx.convTiling->kL0 : self->ctx.kAL0Tail; | 154 | + self->ctx.kAL0Tail = self->ctx.kAL0Tail == 0 ? self->ctx.convTilingData->convApiTiling.kL0 : self->ctx.kAL0Tail; |
| 155 | } | 155 | } |
| 156 | - self->ctx.kL0Tail = self->ctx.kL0Tail == 0 ? self->ctx.convTiling->kL0 : self->ctx.kL0Tail; | 156 | + self->ctx.kL0Tail = self->ctx.kL0Tail == 0 ? self->ctx.convTilingData->convApiTiling.kL0 : self->ctx.kL0Tail; |
| 157 | 157 | ||
| 158 | InitCoDirectionValue<Intf>(self); | 158 | InitCoDirectionValue<Intf>(self); |
| 159 | } | 159 | } |
| @@ -199,18 +199,18 @@ __aicore__ inline void FirstIterateImplHWMode(Intf *self) | |||
| 199 | CalcCoDirectionVar<Intf>(self); | 199 | CalcCoDirectionVar<Intf>(self); |
| 200 | 200 | ||
| 201 | if constexpr (Intf::groupOptPreloadFlag) { | 201 | if constexpr (Intf::groupOptPreloadFlag) { |
| 202 | - if (self->ctx.singleGroupOpt == 1 && self->ctx.updateEnlarge != self->ctx.convTiling->enlarge) { | 202 | + if (self->ctx.singleGroupOpt == 1 && self->ctx.updateEnlarge != self->ctx.convTilingData->convApiTiling.enlarge) { |
| 203 | self->ctx.singleGroups = self->ctx.updateEnlarge; | 203 | self->ctx.singleGroups = self->ctx.updateEnlarge; |
| 204 | self->ctx.singleGroups = self->ctx.singleGroups == 0 ? | 204 | self->ctx.singleGroups = self->ctx.singleGroups == 0 ? |
| 205 | - self->ctx.convTiling->enlarge : self->ctx.singleGroups; | 205 | + self->ctx.convTilingData->convApiTiling.enlarge : self->ctx.singleGroups; |
| 206 | CalcGroupOptParamForHWMode<Intf>(self); | 206 | CalcGroupOptParamForHWMode<Intf>(self); |
| 207 | } | 207 | } |
| 208 | LoadAL1BaseModule<Intf>(self); | 208 | LoadAL1BaseModule<Intf>(self); |
| 209 | self->ctx.loadAL1Flag = true; | 209 | self->ctx.loadAL1Flag = true; |
| 210 | - if (self->ctx.singleGroupOpt == 2 && self->ctx.updateEnlarge != self->ctx.convTiling->enlarge) { | 210 | + if (self->ctx.singleGroupOpt == 2 && self->ctx.updateEnlarge != self->ctx.convTilingData->convApiTiling.enlarge) { |
| 211 | self->ctx.singleGroups = self->ctx.updateEnlarge; | 211 | self->ctx.singleGroups = self->ctx.updateEnlarge; |
| 212 | self->ctx.singleGroups = self->ctx.singleGroups == 0 ? | 212 | self->ctx.singleGroups = self->ctx.singleGroups == 0 ? |
| 213 | - self->ctx.convTiling->enlarge : self->ctx.singleGroups; | 213 | + self->ctx.convTilingData->convApiTiling.enlarge : self->ctx.singleGroups; |
| 214 | CalcGroupOptParamForHWMode<Intf>(self); | 214 | CalcGroupOptParamForHWMode<Intf>(self); |
| 215 | } | 215 | } |
| 216 | } | 216 | } |
| @@ -367,7 +367,7 @@ __aicore__ inline bool IterateMFirstHWMode(Intf *self) | |||
| 367 | if (self->ctx.groupOptIter != self->ctx.singleGroupOpt) { | 367 | if (self->ctx.groupOptIter != self->ctx.singleGroupOpt) { |
| 368 | return true; | 368 | return true; |
| 369 | } else if (self->ctx.groupOptIter == self->ctx.singleGroupOpt - 1) { | 369 | } else if (self->ctx.groupOptIter == self->ctx.singleGroupOpt - 1) { |
| 370 | - if (self->ctx.updateSingleCoOpt == 0 && self->ctx.updateEnlarge != self->ctx.convTiling->enlarge) { | 370 | + if (self->ctx.updateSingleCoOpt == 0 && self->ctx.updateEnlarge != self->ctx.convTilingData->convApiTiling.enlarge) { |
| 371 | return false; | 371 | return false; |
| 372 | } | 372 | } |
| 373 | return true; | 373 | return true; |
| @@ -51,28 +51,28 @@ template <class Intf> | |||
| 51 | __aicore__ inline void CalcGroupOptParamForMMode(Intf *self) | 51 | __aicore__ inline void CalcGroupOptParamForMMode(Intf *self) |
| 52 | { | 52 | { |
| 53 | if (((self->ctx.groupOptIter + 1 == self->ctx.singleGroupOpt - 1 && self->ctx.groupOptIter != 0) || | 53 | if (((self->ctx.groupOptIter + 1 == self->ctx.singleGroupOpt - 1 && self->ctx.groupOptIter != 0) || |
| 54 | - self->ctx.singleGroupOpt == 1) && self->ctx.updateEnlarge != self->ctx.convTiling->enlarge) { | 54 | + self->ctx.singleGroupOpt == 1) && self->ctx.updateEnlarge != self->ctx.convTilingData->convApiTiling.enlarge) { |
| 55 | self->ctx.singleGroups = self->ctx.updateEnlarge; | 55 | self->ctx.singleGroups = self->ctx.updateEnlarge; |
| 56 | - self->ctx.singleGroups = self->ctx.singleGroups == 0 ? self->ctx.convTiling->enlarge : self->ctx.singleGroups; | 56 | + self->ctx.singleGroups = self->ctx.singleGroups == 0 ? self->ctx.convTilingData->convApiTiling.enlarge : self->ctx.singleGroups; |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | - uint64_t enlargeTail = self->ctx.singleGroups % self->ctx.convTiling->enlarge; | 59 | + uint64_t enlargeTail = self->ctx.singleGroups % self->ctx.convTilingData->convApiTiling.enlarge; |
| 60 | - enlargeTail = enlargeTail == 0 ? self->ctx.convTiling->enlarge : enlargeTail; | 60 | + enlargeTail = enlargeTail == 0 ? self->ctx.convTilingData->convApiTiling.enlarge : enlargeTail; |
| 61 | - if (enlargeTail != self->ctx.convTiling->enlarge) { | 61 | + if (enlargeTail != self->ctx.convTilingData->convApiTiling.enlarge) { |
| 62 | - self->ctx.singleCoreCi = enlargeTail * (self->ctx.convTiling->orgCi / self->ctx.convTiling->groups); | 62 | + self->ctx.singleCoreCi = enlargeTail * (self->ctx.convTilingData->convApiTiling.orgCi / self->ctx.convTilingData->convApiTiling.groups); |
| 63 | if (self->ctx.groupOptIter == self->ctx.singleGroupOpt - 1) { | 63 | if (self->ctx.groupOptIter == self->ctx.singleGroupOpt - 1) { |
| 64 | self->ctx.singleCoreCo = self->ctx.updateSingleCoOpt; | 64 | self->ctx.singleCoreCo = self->ctx.updateSingleCoOpt; |
| 65 | 65 | ||
| 66 | - uint64_t totalKAlignK0 = AlignB(self->ctx.singleCoreCi, Intf::k0) * self->ctx.convTiling->kernelHxkernelW; | 66 | + uint64_t totalKAlignK0 = AlignB(self->ctx.singleCoreCi, Intf::k0) * self->ctx.convTilingData->convApiTiling.kernelHxkernelW; |
| 67 | - self->ctx.ddr2l0LoopK = CeilDiv(totalKAlignK0, self->ctx.convTiling->kL0); | 67 | + self->ctx.ddr2l0LoopK = CeilDiv(totalKAlignK0, self->ctx.convTilingData->convApiTiling.kL0); |
| 68 | self->ctx.maxKL0Iter = self->ctx.ddr2l0LoopK - 1; | 68 | self->ctx.maxKL0Iter = self->ctx.ddr2l0LoopK - 1; |
| 69 | - self->ctx.kL0Tail = totalKAlignK0 % self->ctx.convTiling->kL0; | 69 | + self->ctx.kL0Tail = totalKAlignK0 % self->ctx.convTilingData->convApiTiling.kL0; |
| 70 | if constexpr (Intf::k0 != Intf::k0FmapTail) { | 70 | if constexpr (Intf::k0 != Intf::k0FmapTail) { |
| 71 | self->ctx.kAL0Tail = AlignB(self->ctx.singleCoreCi, Intf::k0FmapTail) * | 71 | self->ctx.kAL0Tail = AlignB(self->ctx.singleCoreCi, Intf::k0FmapTail) * |
| 72 | - self->ctx.convTiling->kernelHxkernelW % self->ctx.convTiling->kL0; | 72 | + self->ctx.convTilingData->convApiTiling.kernelHxkernelW % self->ctx.convTilingData->convApiTiling.kL0; |
| 73 | - self->ctx.kAL0Tail = self->ctx.kAL0Tail == 0 ? self->ctx.convTiling->kL0 : self->ctx.kAL0Tail; | 73 | + self->ctx.kAL0Tail = self->ctx.kAL0Tail == 0 ? self->ctx.convTilingData->convApiTiling.kL0 : self->ctx.kAL0Tail; |
| 74 | } | 74 | } |
| 75 | - self->ctx.kL0Tail = self->ctx.kL0Tail == 0 ? self->ctx.convTiling->kL0 : self->ctx.kL0Tail; | 75 | + self->ctx.kL0Tail = self->ctx.kL0Tail == 0 ? self->ctx.convTilingData->convApiTiling.kL0 : self->ctx.kL0Tail; |
| 76 | 76 | ||
| 77 | InitCoDirectionValue<Intf>(self); | 77 | InitCoDirectionValue<Intf>(self); |
| 78 | } | 78 | } |
| @@ -113,21 +113,32 @@ __aicore__ inline void FirstIterateImplMMode(Intf *self) | |||
| 113 | CalcMDirectionVar<Intf>(self); | 113 | CalcMDirectionVar<Intf>(self); |
| 114 | CalcCoDirectionVar<Intf>(self); | 114 | CalcCoDirectionVar<Intf>(self); |
| 115 | 115 | ||
| 116 | - if (Intf::groupOptPreloadFlag) { | 116 | + if constexpr (Intf::groupOptPreloadFlag) { |
| 117 | - if (self->ctx.singleGroupOpt == 1 && self->ctx.updateEnlarge != self->ctx.convTiling->enlarge) { | 117 | + if (self->ctx.singleGroupOpt == 1 && self->ctx.updateEnlarge != self->ctx.convTilingData->convApiTiling.enlarge) { |
| 118 | self->ctx.singleGroups = self->ctx.updateEnlarge; | 118 | self->ctx.singleGroups = self->ctx.updateEnlarge; |
| 119 | self->ctx.singleGroups = self->ctx.singleGroups == 0 ? | 119 | self->ctx.singleGroups = self->ctx.singleGroups == 0 ? |
| 120 | - self->ctx.convTiling->enlarge : self->ctx.singleGroups; | 120 | + self->ctx.convTilingData->convApiTiling.enlarge : self->ctx.singleGroups; |
| 121 | CalcGroupOptParamForMMode<Intf>(self); | 121 | CalcGroupOptParamForMMode<Intf>(self); |
| 122 | } | 122 | } |
| 123 | LoadAL1BaseModule<Intf>(self); | 123 | LoadAL1BaseModule<Intf>(self); |
| 124 | self->ctx.loadAL1Flag = true; | 124 | self->ctx.loadAL1Flag = true; |
| 125 | - if (self->ctx.singleGroupOpt == 2 && self->ctx.updateEnlarge != self->ctx.convTiling->enlarge) { | 125 | + if (self->ctx.singleGroupOpt == 2 && self->ctx.updateEnlarge != self->ctx.convTilingData->convApiTiling.enlarge) { |
| 126 | self->ctx.singleGroups = self->ctx.updateEnlarge; | 126 | self->ctx.singleGroups = self->ctx.updateEnlarge; |
| 127 | self->ctx.singleGroups = self->ctx.singleGroups == 0 ? | 127 | self->ctx.singleGroups = self->ctx.singleGroups == 0 ? |
| 128 | - self->ctx.convTiling->enlarge : self->ctx.singleGroups; | 128 | + self->ctx.convTilingData->convApiTiling.enlarge : self->ctx.singleGroups; |
| 129 | CalcGroupOptParamForMMode<Intf>(self); | 129 | CalcGroupOptParamForMMode<Intf>(self); |
| 130 | } | 130 | } |
| 131 | + } else if constexpr (Intf::isMPreLoad) { | ||
| 132 | + self->ctx.al1 = self->ctx.queueAL1.template AllocTensor<typename Intf::FmapT>(); | ||
| 133 | + self->ctx.loadAl1Ins.LoadAL1(); | ||
| 134 | + self->ctx.queueAL1.EnQue(self->ctx.al1); | ||
| 135 | + self->ctx.mAL1UpdateFlag = true; | ||
| 136 | + LoadBL1BaseModule<Intf>(self); | ||
| 137 | + self->ctx.bl1 = self->ctx.queueBL1.template DeQue<typename Intf::WeightT>(); | ||
| 138 | + self->ctx.loadBL0Flag = true; | ||
| 139 | + if constexpr (Intf::isL0BFullLoadable) { | ||
| 140 | + self->ctx.loadBL0Ins.FullLoadBL0(self->ctx.wholeBl0Tensor[0]); | ||
| 141 | + } | ||
| 131 | } | 142 | } |
| 132 | } | 143 | } |
| 133 | 144 | ||
| @@ -175,7 +186,7 @@ __aicore__ inline bool IterateMFirstMMode(Intf *self) | |||
| 175 | } | 186 | } |
| 176 | 187 | ||
| 177 | if ASCEND_IS_AIC_CONV { | 188 | if ASCEND_IS_AIC_CONV { |
| 178 | - if constexpr (!Intf::groupOptPreloadFlag) { | 189 | + if constexpr (!Intf::isMPreLoad && !Intf::groupOptPreloadFlag) { |
| 179 | if (self->ctx.kAL1fullload) { | 190 | if (self->ctx.kAL1fullload) { |
| 180 | self->ctx.queueAL1.FreeTensor(self->ctx.al1); | 191 | self->ctx.queueAL1.FreeTensor(self->ctx.al1); |
| 181 | } | 192 | } |
| @@ -211,7 +222,7 @@ __aicore__ inline bool IterateMFirstMMode(Intf *self) | |||
| 211 | } | 222 | } |
| 212 | 223 | ||
| 213 | if ASCEND_IS_AIC_CONV { | 224 | if ASCEND_IS_AIC_CONV { |
| 214 | - if constexpr (!Intf::groupOptPreloadFlag) { | 225 | + if constexpr (!Intf::groupOptPreloadFlag && !Intf::isMPreLoad) { |
| 215 | if (self->ctx.kBL1fullload) { | 226 | if (self->ctx.kBL1fullload) { |
| 216 | self->ctx.queueBL1.FreeTensor(self->ctx.bl1); | 227 | self->ctx.queueBL1.FreeTensor(self->ctx.bl1); |
| 217 | } | 228 | } |
| @@ -235,7 +246,7 @@ __aicore__ inline bool IterateMFirstMMode(Intf *self) | |||
| 235 | if (self->ctx.groupOptIter < self->ctx.singleGroupOpt - 1) { | 246 | if (self->ctx.groupOptIter < self->ctx.singleGroupOpt - 1) { |
| 236 | return true; | 247 | return true; |
| 237 | } else if (self->ctx.groupOptIter == self->ctx.singleGroupOpt - 1) { | 248 | } else if (self->ctx.groupOptIter == self->ctx.singleGroupOpt - 1) { |
| 238 | - if (self->ctx.updateSingleCoOpt == 0 && self->ctx.updateEnlarge != self->ctx.convTiling->enlarge) { | 249 | + if (self->ctx.updateSingleCoOpt == 0 && self->ctx.updateEnlarge != self->ctx.convTilingData->convApiTiling.enlarge) { |
| 239 | return false; | 250 | return false; |
| 240 | } | 251 | } |
| 241 | return true; | 252 | return true; |
| @@ -341,8 +352,10 @@ __aicore__ inline bool IterateNFirstMMode(Intf *self) | |||
| 341 | } | 352 | } |
| 342 | 353 | ||
| 343 | if ASCEND_IS_AIC_CONV { | 354 | if ASCEND_IS_AIC_CONV { |
| 344 | - if (self->ctx.kBL1fullload) { | 355 | + if constexpr (!(Intf::preFusionFlag && ConvParam::weightTiling == 0)) { |
| 345 | - self->ctx.queueBL1.FreeTensor(self->ctx.bl1); | 356 | + if (self->ctx.kBL1fullload) { |
| 357 | + self->ctx.queueBL1.FreeTensor(self->ctx.bl1); | ||
| 358 | + } | ||
| 346 | } | 359 | } |
| 347 | } | 360 | } |
| 348 | 361 | ||
| @@ -359,8 +372,10 @@ __aicore__ inline bool IterateNFirstMMode(Intf *self) | |||
| 359 | } | 372 | } |
| 360 | 373 | ||
| 361 | if ASCEND_IS_AIC_CONV { | 374 | if ASCEND_IS_AIC_CONV { |
| 362 | - if (self->ctx.kAL1fullload) { | 375 | + if constexpr (!Intf::preFusionFlag) { |
| 363 | - self->ctx.queueAL1.FreeTensor(self->ctx.al1); | 376 | + if (self->ctx.kAL1fullload) { |
| 377 | + self->ctx.queueAL1.FreeTensor(self->ctx.al1); | ||
| 378 | + } | ||
| 364 | } | 379 | } |
| 365 | } | 380 | } |
| 366 | 381 | ||
| @@ -386,7 +401,9 @@ __aicore__ inline bool IterateNFirstMMode(Intf *self) | |||
| 386 | self->ctx.batchIter++; | 401 | self->ctx.batchIter++; |
| 387 | if (likely(self->ctx.batchIter != self->ctx.ddr2l1LoopBatch)) { | 402 | if (likely(self->ctx.batchIter != self->ctx.ddr2l1LoopBatch)) { |
| 388 | self->ctx.loadAL1Flag = true; | 403 | self->ctx.loadAL1Flag = true; |
| 389 | - self->ctx.loadBL1Flag = true; | 404 | + if constexpr (!(Intf::preFusionFlag && ConvParam::weightTiling == 0)) { |
| 405 | + self->ctx.loadBL1Flag = true; | ||
| 406 | + } | ||
| 390 | return true; | 407 | return true; |
| 391 | } | 408 | } |
| 392 | 409 | ||
| @@ -49,10 +49,10 @@ struct SetIterIndex { | |||
| 49 | }; | 49 | }; |
| 50 | 50 | ||
| 51 | template <class Intf> | 51 | template <class Intf> |
| 52 | -__aicore__ inline bool OptGroupUpdateBL1(Intf *self) | 52 | +__aicore__ inline bool OptGroupUpdateBL1(Intf *self, const uint64_t &kIter) |
| 53 | { | 53 | { |
| 54 | - if (!((self->ctx.kIter == self->ctx.ddr2l0LoopK - 1) || | 54 | + if (!((kIter == self->ctx.ddr2l0LoopK - 1) || |
| 55 | - ((self->ctx.kIter + 1) % self->ctx.multiKBL1 == 0))) { | 55 | + ((kIter + 1) % self->ctx.multiKBL1 == 0))) { |
| 56 | return false; | 56 | return false; |
| 57 | } | 57 | } |
| 58 | 58 | ||
| @@ -78,9 +78,9 @@ __aicore__ inline bool OptGroupUpdateBL1(Intf *self) | |||
| 78 | } | 78 | } |
| 79 | } else if constexpr (Intf::outputOrder == static_cast<int8_t>(ConvOutputOrder::M_MODE)) { | 79 | } else if constexpr (Intf::outputOrder == static_cast<int8_t>(ConvOutputOrder::M_MODE)) { |
| 80 | if constexpr (Intf::iterateMFirstFlag) { | 80 | if constexpr (Intf::iterateMFirstFlag) { |
| 81 | - updateBL1Flag = self->ctx.mAL1Iter == self->ctx.maxMAL1Iter && | 81 | + updateBL1Flag = self->ctx.nL0Iter == self->ctx.maxNL0Iter && |
| 82 | - self->ctx.nL0Iter == self->ctx.maxNL0Iter && | ||
| 83 | self->ctx.mL0Iter == self->ctx.maxML0Iter && | 82 | self->ctx.mL0Iter == self->ctx.maxML0Iter && |
| 83 | + self->ctx.mAL1Iter == self->ctx.maxMAL1Iter && | ||
| 84 | self->ctx.batchIter == self->ctx.ddr2l1LoopBatch - 1; | 84 | self->ctx.batchIter == self->ctx.ddr2l1LoopBatch - 1; |
| 85 | } else { | 85 | } else { |
| 86 | updateBL1Flag = self->ctx.nL0Iter == self->ctx.maxNL0Iter && | 86 | updateBL1Flag = self->ctx.nL0Iter == self->ctx.maxNL0Iter && |
| @@ -96,9 +96,9 @@ __aicore__ inline bool OptGroupUpdateBL1(Intf *self) | |||
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | template <class Intf> | 98 | template <class Intf> |
| 99 | -__aicore__ inline void OptGroupSyncSet(Intf *self) | 99 | +__aicore__ inline void OptGroupSyncSet(Intf *self, const uint64_t &kIter) |
| 100 | { | 100 | { |
| 101 | - if (!OptGroupUpdateBL1<Intf>(self)) { | 101 | + if (!OptGroupUpdateBL1<Intf>(self, kIter)) { |
| 102 | return; | 102 | return; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| @@ -124,9 +124,9 @@ __aicore__ inline void OptGroupSyncSet(Intf *self) | |||
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | template <class Intf> | 126 | template <class Intf> |
| 127 | -__aicore__ inline void OptGroupPreloadSyncSet(Intf *self) | 127 | +__aicore__ inline void OptGroupPreloadSyncSet(Intf *self, const uint64_t &kIter) |
| 128 | { | 128 | { |
| 129 | - if (!OptGroupUpdateBL1<Intf>(self)) { | 129 | + if (!OptGroupUpdateBL1<Intf>(self, kIter)) { |
| 130 | return; | 130 | return; |
| 131 | } | 131 | } |
| 132 | 132 | ||
| @@ -138,8 +138,8 @@ __aicore__ inline void OptGroupPreloadSyncSet(Intf *self) | |||
| 138 | template <class Intf> | 138 | template <class Intf> |
| 139 | __aicore__ inline void OptGroupUpdateLoopN(Intf *self) { | 139 | __aicore__ inline void OptGroupUpdateLoopN(Intf *self) { |
| 140 | if constexpr (Intf::hasNL0IterFlag) { | 140 | if constexpr (Intf::hasNL0IterFlag) { |
| 141 | - self->ctx.l12l0LoopN = self->ctx.maxNBL1Iter == self->ctx.nBL1Iter ? | 141 | + self->ctx.l12l0LoopN = self->ctx.nBL1Iter == self->ctx.maxNBL1Iter ? |
| 142 | - CeilDiv(self->ctx.nBL1Tail, self->ctx.convTiling->nL0) : self->ctx.convTiling->multiNBL1; | 142 | + CeilDiv(self->ctx.nBL1Tail, self->ctx.convTilingData->convApiTiling.nL0) : self->ctx.convTilingData->convApiTiling.multiNBL1; |
| 143 | self->ctx.ddr2l1LoopInner = self->ctx.ddr2l1LoopTmp * self->ctx.l12l0LoopN; | 143 | self->ctx.ddr2l1LoopInner = self->ctx.ddr2l1LoopTmp * self->ctx.l12l0LoopN; |
| 144 | } | 144 | } |
| 145 | } | 145 | } |
| @@ -159,24 +159,24 @@ __aicore__ inline void OptGroupUpdateLoopInner(Intf *self) { | |||
| 159 | } else if (self->ctx.woAL1Iter == self->ctx.maxWoL1Iter) { | 159 | } else if (self->ctx.woAL1Iter == self->ctx.maxWoL1Iter) { |
| 160 | self->ctx.currentWoL1 = self->ctx.woL1SmallTail; | 160 | self->ctx.currentWoL1 = self->ctx.woL1SmallTail; |
| 161 | } else { | 161 | } else { |
| 162 | - self->ctx.currentWoL1 = self->ctx.convTiling->woL1; | 162 | + self->ctx.currentWoL1 = self->ctx.convTilingData->convApiTiling.woL1; |
| 163 | } | 163 | } |
| 164 | } else { | 164 | } else { |
| 165 | - self->ctx.currentWoL1 = self->ctx.maxWoL1Iter == self->ctx.woAL1Iter ? | 165 | + self->ctx.currentWoL1 = self->ctx.woAL1Iter == self->ctx.maxWoL1Iter ? |
| 166 | - self->ctx.woAL1Tail : self->ctx.convTiling->woL1; | 166 | + self->ctx.woAL1Tail : self->ctx.convTilingData->convApiTiling.woL1; |
| 167 | } | 167 | } |
| 168 | } | 168 | } |
| 169 | if constexpr (Intf::hasWL0IterFlag) { | 169 | if constexpr (Intf::hasWL0IterFlag) { |
| 170 | - self->ctx.l12l0LoopW = CeilDiv(self->ctx.currentWoL1, self->ctx.convTiling->woL0); | 170 | + self->ctx.l12l0LoopW = CeilDiv(self->ctx.currentWoL1, self->ctx.convTilingData->convApiTiling.woL0); |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | if constexpr (Intf::hasHL1IterFlag) { | 173 | if constexpr (Intf::hasHL1IterFlag) { |
| 174 | self->ctx.hoAL1Iter = (self->ctx.outerIter / self->ctx.ddr2l1LoopW) % self->ctx.ddr2l1LoopH; | 174 | self->ctx.hoAL1Iter = (self->ctx.outerIter / self->ctx.ddr2l1LoopW) % self->ctx.ddr2l1LoopH; |
| 175 | self->ctx.currentHoL1 = self->ctx.hoAL1Iter == self->ctx.maxHoL1Iter ? | 175 | self->ctx.currentHoL1 = self->ctx.hoAL1Iter == self->ctx.maxHoL1Iter ? |
| 176 | - self->ctx.hoAL1Tail : self->ctx.convTiling->hoL1; | 176 | + self->ctx.hoAL1Tail : self->ctx.convTilingData->convApiTiling.hoL1; |
| 177 | } | 177 | } |
| 178 | if constexpr (Intf::hasHL0IterFlag) { | 178 | if constexpr (Intf::hasHL0IterFlag) { |
| 179 | - self->ctx.l12l0LoopH = CeilDiv(self->ctx.currentHoL1, self->ctx.convTiling->hoL0); | 179 | + self->ctx.l12l0LoopH = CeilDiv(self->ctx.currentHoL1, self->ctx.convTilingData->convApiTiling.hoL0); |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | self->ctx.ddr2l1LoopTmp = self->ctx.l12l0LoopW * self->ctx.l12l0LoopH; | 182 | self->ctx.ddr2l1LoopTmp = self->ctx.l12l0LoopW * self->ctx.l12l0LoopH; |
| @@ -29,19 +29,19 @@ __aicore__ inline void OptGroupCalcBL1LoadTimesHWMode(Intf *self) | |||
| 29 | { | 29 | { |
| 30 | if (!self->ctx.kBL1fullload) { | 30 | if (!self->ctx.kBL1fullload) { |
| 31 | self->ctx.ddr2l1LoopKB = self->ctx.maxKBL1Iter + 1; | 31 | self->ctx.ddr2l1LoopKB = self->ctx.maxKBL1Iter + 1; |
| 32 | - uint64_t ddr2l0LoopH = CeilDiv(self->ctx.singleCoreHo, self->ctx.convTiling->hoL0); | 32 | + uint64_t ddr2l0LoopH = CeilDiv(self->ctx.singleCoreHo, self->ctx.convTilingData->convApiTiling.hoL0); |
| 33 | uint64_t ddr2l0LoopW = 0; | 33 | uint64_t ddr2l0LoopW = 0; |
| 34 | if constexpr (Intf::hasWL0IterFlag) { | 34 | if constexpr (Intf::hasWL0IterFlag) { |
| 35 | if (self->ctx.woL1SmallTail > 0) { | 35 | if (self->ctx.woL1SmallTail > 0) { |
| 36 | ddr2l0LoopW = (self->ctx.ddr2l1LoopW - W_TAIL_NUM) * | 36 | ddr2l0LoopW = (self->ctx.ddr2l1LoopW - W_TAIL_NUM) * |
| 37 | - CeilDiv(self->ctx.convTiling->woL1, self->ctx.convTiling->woL0) + | 37 | + CeilDiv(self->ctx.convTilingData->convApiTiling.woL1, self->ctx.convTilingData->convApiTiling.woL0) + |
| 38 | - CeilDiv(self->ctx.woAL1Tail, self->ctx.convTiling->woL0) + | 38 | + CeilDiv(self->ctx.woAL1Tail, self->ctx.convTilingData->convApiTiling.woL0) + |
| 39 | - CeilDiv(self->ctx.woL1SmallTail, self->ctx.convTiling->woL0); | 39 | + CeilDiv(self->ctx.woL1SmallTail, self->ctx.convTilingData->convApiTiling.woL0); |
| 40 | } else { | 40 | } else { |
| 41 | - ddr2l0LoopW = CeilDiv(self->ctx.singleCoreWo, self->ctx.convTiling->woL0); | 41 | + ddr2l0LoopW = CeilDiv(self->ctx.singleCoreWo, self->ctx.convTilingData->convApiTiling.woL0); |
| 42 | } | 42 | } |
| 43 | } else { | 43 | } else { |
| 44 | - ddr2l0LoopW = CeilDiv(self->ctx.singleCoreWo, self->ctx.convTiling->woL0); | 44 | + ddr2l0LoopW = CeilDiv(self->ctx.singleCoreWo, self->ctx.convTilingData->convApiTiling.woL0); |
| 45 | } | 45 | } |
| 46 | self->ctx.bL1LoadTimes = ddr2l0LoopH * ddr2l0LoopW * self->ctx.ddr2l1LoopN * self->ctx.l12l0LoopN * | 46 | self->ctx.bL1LoadTimes = ddr2l0LoopH * ddr2l0LoopW * self->ctx.ddr2l1LoopN * self->ctx.l12l0LoopN * |
| 47 | self->ctx.ddr2l1LoopBatch * self->ctx.ddr2l1LoopKB; | 47 | self->ctx.ddr2l1LoopBatch * self->ctx.ddr2l1LoopKB; |
| @@ -98,27 +98,27 @@ template <class Intf> | |||
| 98 | __aicore__ inline void OptGroupInitIterValueMfirstHWMode(Intf *self) | 98 | __aicore__ inline void OptGroupInitIterValueMfirstHWMode(Intf *self) |
| 99 | { | 99 | { |
| 100 | if (!self->ctx.kBL1fullload) { | 100 | if (!self->ctx.kBL1fullload) { |
| 101 | + uint64_t ddr2l0LoopH = CeilDiv(self->ctx.singleCoreHo, self->ctx.convTilingData->convApiTiling.hoL0); | ||
| 101 | uint64_t ddr2l0LoopW = 0; | 102 | uint64_t ddr2l0LoopW = 0; |
| 102 | - uint64_t ddr2l0LoopH = CeilDiv(self->ctx.singleCoreHo, self->ctx.convTiling->hoL0); | ||
| 103 | if constexpr (Intf::hasWL0IterFlag) { | 103 | if constexpr (Intf::hasWL0IterFlag) { |
| 104 | - self->ctx.woAL1Tail = self->ctx.singleCoreWo % self->ctx.convTiling->woL1; | 104 | + self->ctx.woAL1Tail = self->ctx.singleCoreWo % self->ctx.convTilingData->convApiTiling.woL1; |
| 105 | - self->ctx.woAL1Tail = self->ctx.woAL1Tail == 0 ? self->ctx.convTiling->woL1 : self->ctx.woAL1Tail; | 105 | + self->ctx.woAL1Tail = self->ctx.woAL1Tail == 0 ? self->ctx.convTilingData->convApiTiling.woL1 : self->ctx.woAL1Tail; |
| 106 | - if (self->ctx.convTiling->hoL0 > 1 && self->ctx.woAL1Tail % BLOCK_L0_N > 0 && | 106 | + if (self->ctx.convTilingData->convApiTiling.hoL0 > 1 && self->ctx.woAL1Tail % BLOCK_L0_N > 0 && |
| 107 | - CeilDiv(self->ctx.woAL1Tail, self->ctx.convTiling->woL0) > 1) { | 107 | + CeilDiv(self->ctx.woAL1Tail, self->ctx.convTilingData->convApiTiling.woL0) > 1) { |
| 108 | - self->ctx.woAL1Tail = (self->ctx.woAL1Tail / self->ctx.convTiling->woL0) * self->ctx.convTiling->woL0; | 108 | + self->ctx.woL1SmallTail = self->ctx.woAL1Tail % self->ctx.convTilingData->convApiTiling.woL0; |
| 109 | - self->ctx.woL1SmallTail = self->ctx.woAL1Tail % self->ctx.convTiling->woL0; | 109 | + self->ctx.woAL1Tail = (self->ctx.woAL1Tail / self->ctx.convTilingData->convApiTiling.woL0) * self->ctx.convTilingData->convApiTiling.woL0; |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | - self->ctx.ddr2l1LoopW = CeilDiv(self->ctx.singleCoreWo, self->ctx.convTiling->woL1); | 112 | + self->ctx.ddr2l1LoopW = CeilDiv(self->ctx.singleCoreWo, self->ctx.convTilingData->convApiTiling.woL1); |
| 113 | ddr2l0LoopW = | 113 | ddr2l0LoopW = |
| 114 | - (self->ctx.ddr2l1LoopW - 1) * CeilDiv(self->ctx.woAL1Tail, self->ctx.convTiling->woL0) + | 114 | + (self->ctx.ddr2l1LoopW - 1) * CeilDiv(self->ctx.convTilingData->convApiTiling.woL1, self->ctx.convTilingData->convApiTiling.woL0) + |
| 115 | - CeilDiv(self->ctx.convTiling->woL1, self->ctx.convTiling->woL0); | 115 | + CeilDiv(self->ctx.woAL1Tail, self->ctx.convTilingData->convApiTiling.woL0); |
| 116 | 116 | ||
| 117 | if (self->ctx.woL1SmallTail > 0) { | 117 | if (self->ctx.woL1SmallTail > 0) { |
| 118 | - ddr2l0LoopW += CeilDiv(self->ctx.woL1SmallTail, self->ctx.convTiling->woL0); | 118 | + ddr2l0LoopW += CeilDiv(self->ctx.woL1SmallTail, self->ctx.convTilingData->convApiTiling.woL0); |
| 119 | } | 119 | } |
| 120 | } else { | 120 | } else { |
| 121 | - ddr2l0LoopW = CeilDiv(self->ctx.singleCoreWo, self->ctx.convTiling->woL0); | 121 | + ddr2l0LoopW = CeilDiv(self->ctx.singleCoreWo, self->ctx.convTilingData->convApiTiling.woL0); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | self->ctx.ddr2l1LoopTmp = self->ctx.ddr2l1LoopBatch * ddr2l0LoopH * ddr2l0LoopW; | 124 | self->ctx.ddr2l1LoopTmp = self->ctx.ddr2l1LoopBatch * ddr2l0LoopH * ddr2l0LoopW; |
| @@ -135,23 +135,23 @@ __aicore__ inline void OptGroupInitIterValueNfirstHWMode(Intf *self) | |||
| 135 | self->ctx.ddr2l1LoopH = 1; | 135 | self->ctx.ddr2l1LoopH = 1; |
| 136 | self->ctx.maxHoL1Iter = 0; | 136 | self->ctx.maxHoL1Iter = 0; |
| 137 | } else { | 137 | } else { |
| 138 | - self->ctx.ddr2l1LoopH = CeilDiv(self->ctx.singleCoreHo, self->ctx.convTiling->hoL1); | 138 | + self->ctx.ddr2l1LoopH = CeilDiv(self->ctx.singleCoreHo, self->ctx.convTilingData->convApiTiling.hoL1); |
| 139 | self->ctx.maxHoL1Iter = self->ctx.ddr2l1LoopH - 1; | 139 | self->ctx.maxHoL1Iter = self->ctx.ddr2l1LoopH - 1; |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | if constexpr (Intf::hasWL1IterFlag) { | 142 | if constexpr (Intf::hasWL1IterFlag) { |
| 143 | - self->ctx.ddr2l1LoopW = CeilDiv(self->ctx.singleCoreWo, self->ctx.convTiling->woL1); | 143 | + self->ctx.ddr2l1LoopW = CeilDiv(self->ctx.singleCoreWo, self->ctx.convTilingData->convApiTiling.woL1); |
| 144 | } else { | 144 | } else { |
| 145 | self->ctx.ddr2l1LoopW = 1; | 145 | self->ctx.ddr2l1LoopW = 1; |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | - self->ctx.woAL1Tail = self->ctx.singleCoreWo % self->ctx.convTiling->woL1; | 148 | + self->ctx.woAL1Tail = self->ctx.singleCoreWo % self->ctx.convTilingData->convApiTiling.woL1; |
| 149 | - self->ctx.woAL1Tail = self->ctx.woAL1Tail == 0 ? self->ctx.convTiling->woL1 : self->ctx.woAL1Tail; | 149 | + self->ctx.woAL1Tail = self->ctx.woAL1Tail == 0 ? self->ctx.convTilingData->convApiTiling.woL1 : self->ctx.woAL1Tail; |
| 150 | if constexpr (Intf::hasWL0IterFlag) { | 150 | if constexpr (Intf::hasWL0IterFlag) { |
| 151 | - if (self->ctx.convTiling->hoL0 > 1 && self->ctx.woAL1Tail % BLOCK_L0_N > 0 && | 151 | + if (self->ctx.convTilingData->convApiTiling.hoL0 > 1 && self->ctx.woAL1Tail % BLOCK_L0_N > 0 && |
| 152 | - CeilDiv(self->ctx.woAL1Tail, self->ctx.convTiling->woL0) > 1) { | 152 | + CeilDiv(self->ctx.woAL1Tail, self->ctx.convTilingData->convApiTiling.woL0) > 1) { |
| 153 | - self->ctx.woL1SmallTail = self->ctx.woAL1Tail % self->ctx.convTiling->woL0; | 153 | + self->ctx.woL1SmallTail = self->ctx.woAL1Tail % self->ctx.convTilingData->convApiTiling.woL0; |
| 154 | - self->ctx.woAL1Tail = (self->ctx.woAL1Tail / self->ctx.convTiling->woL0) * self->ctx.convTiling->woL0; | 154 | + self->ctx.woAL1Tail = (self->ctx.woAL1Tail / self->ctx.convTilingData->convApiTiling.woL0) * self->ctx.convTilingData->convApiTiling.woL0; |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | if (self->ctx.woL1SmallTail > 0) { | 157 | if (self->ctx.woL1SmallTail > 0) { |
| @@ -160,8 +160,8 @@ __aicore__ inline void OptGroupInitIterValueNfirstHWMode(Intf *self) | |||
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | if (!self->ctx.kBL1fullload) { | 162 | if (!self->ctx.kBL1fullload) { |
| 163 | - self->ctx.hoAL1Tail = self->ctx.singleCoreHo % self->ctx.convTiling->hoL1; | 163 | + self->ctx.hoAL1Tail = self->ctx.singleCoreHo % self->ctx.convTilingData->convApiTiling.hoL1; |
| 164 | - self->ctx.hoAL1Tail = self->ctx.hoAL1Tail == 0 ? self->ctx.convTiling->hoL1 : self->ctx.hoAL1Tail; | 164 | + self->ctx.hoAL1Tail = self->ctx.hoAL1Tail == 0 ? self->ctx.convTilingData->convApiTiling.hoL1 : self->ctx.hoAL1Tail; |
| 165 | self->ctx.currentHoL1 = self->ctx.hoAL1Tail; | 165 | self->ctx.currentHoL1 = self->ctx.hoAL1Tail; |
| 166 | self->ctx.currentWoL1 = self->ctx.woAL1Tail; | 166 | self->ctx.currentWoL1 = self->ctx.woAL1Tail; |
| 167 | self->ctx.maxWoL1Iter = self->ctx.ddr2l1LoopW - 1; | 167 | self->ctx.maxWoL1Iter = self->ctx.ddr2l1LoopW - 1; |
| @@ -225,15 +225,15 @@ template <class Intf> | |||
| 225 | __aicore__ inline void OptGroupInitKValue(Intf *self) | 225 | __aicore__ inline void OptGroupInitKValue(Intf *self) |
| 226 | { | 226 | { |
| 227 | self->ctx.ddr2l1LoopKB = | 227 | self->ctx.ddr2l1LoopKB = |
| 228 | - CeilDiv(AlignB(self->ctx.singleCoreCi, Intf::k0) * self->ctx.convTiling->kernelHxkernelWxkernelD, | 228 | + CeilDiv(AlignB(self->ctx.singleCoreCi, Intf::k0) * self->ctx.convTilingData->convApiTiling.kernelHxkernelWxkernelD, |
| 229 | - self->ctx.convTiling->kBL1); | 229 | + self->ctx.convTilingData->convApiTiling.kBL1); |
| 230 | self->ctx.maxKBL1Iter = self->ctx.ddr2l1LoopKB - 1; | 230 | self->ctx.maxKBL1Iter = self->ctx.ddr2l1LoopKB - 1; |
| 231 | self->ctx.kBL1fullload = self->ctx.ddr2l1LoopKB == 1; | 231 | self->ctx.kBL1fullload = self->ctx.ddr2l1LoopKB == 1; |
| 232 | 232 | ||
| 233 | self->ctx.ci1Opt = CeilDiv(self->ctx.singleCoreCi, Intf::k0); | 233 | self->ctx.ci1Opt = CeilDiv(self->ctx.singleCoreCi, Intf::k0); |
| 234 | 234 | ||
| 235 | if constexpr (Intf::isConv3D) { | 235 | if constexpr (Intf::isConv3D) { |
| 236 | - self->ctx.bL1Cin = self->ctx.convTiling->cinBInCore / self->ctx.bL1Dk; | 236 | + self->ctx.bL1Cin = self->ctx.convTilingData->convApiTiling.cinBInCore / self->ctx.bL1Dk; |
| 237 | self->ctx.bL1CinTail = self->ctx.bL1Dk > 1 ? self->ctx.bL1Cin : self->ctx.singleCoreCi % self->ctx.bL1Cin; | 237 | self->ctx.bL1CinTail = self->ctx.bL1Dk > 1 ? self->ctx.bL1Cin : self->ctx.singleCoreCi % self->ctx.bL1Cin; |
| 238 | self->ctx.bL1CinTail = self->ctx.bL1CinTail == 0 ? self->ctx.bL1Cin : self->ctx.bL1CinTail; | 238 | self->ctx.bL1CinTail = self->ctx.bL1CinTail == 0 ? self->ctx.bL1Cin : self->ctx.bL1CinTail; |
| 239 | self->ctx.bL1CinLoadNum = CeilDiv(self->ctx.singleCoreCi, self->ctx.bL1Cin); | 239 | self->ctx.bL1CinLoadNum = CeilDiv(self->ctx.singleCoreCi, self->ctx.bL1Cin); |
| @@ -243,28 +243,28 @@ __aicore__ inline void OptGroupInitKValue(Intf *self) | |||
| 243 | template <class Intf> | 243 | template <class Intf> |
| 244 | __aicore__ inline void OptGroupInitNValue(Intf *self) | 244 | __aicore__ inline void OptGroupInitNValue(Intf *self) |
| 245 | { | 245 | { |
| 246 | - self->ctx.nBL1Tail = self->ctx.singleCoreCo % self->ctx.convTiling->nBL1; | 246 | + self->ctx.nBL1Tail = self->ctx.singleCoreCo % self->ctx.convTilingData->convApiTiling.nBL1; |
| 247 | - self->ctx.nBL1Tail = self->ctx.nBL1Tail == 0 ? self->ctx.convTiling->nBL1 : self->ctx.nBL1Tail; | 247 | + self->ctx.nBL1Tail = self->ctx.nBL1Tail == 0 ? self->ctx.convTilingData->convApiTiling.nBL1 : self->ctx.nBL1Tail; |
| 248 | 248 | ||
| 249 | if constexpr (!Intf::hasNL1IterFlag) { | 249 | if constexpr (!Intf::hasNL1IterFlag) { |
| 250 | self->ctx.ddr2l1LoopN = 1; | 250 | self->ctx.ddr2l1LoopN = 1; |
| 251 | self->ctx.maxNBL1Iter = 0; | 251 | self->ctx.maxNBL1Iter = 0; |
| 252 | } else { | 252 | } else { |
| 253 | - self->ctx.ddr2l1LoopN = CeilDiv(self->ctx.singleCoreCo, self->ctx.convTiling->nBL1); | 253 | + self->ctx.ddr2l1LoopN = CeilDiv(self->ctx.singleCoreCo, self->ctx.convTilingData->convApiTiling.nBL1); |
| 254 | self->ctx.maxNBL1Iter = self->ctx.ddr2l1LoopN - 1; | 254 | self->ctx.maxNBL1Iter = self->ctx.ddr2l1LoopN - 1; |
| 255 | } | 255 | } |
| 256 | 256 | ||
| 257 | if constexpr (!Intf::hasNL0IterFlag) { | 257 | if constexpr (!Intf::hasNL0IterFlag) { |
| 258 | self->ctx.l12l0LoopN = 1; | 258 | self->ctx.l12l0LoopN = 1; |
| 259 | } else { | 259 | } else { |
| 260 | - self->ctx.l12l0LoopN = self->ctx.convTiling->multiNBL1; | 260 | + self->ctx.l12l0LoopN = self->ctx.convTilingData->convApiTiling.multiNBL1; |
| 261 | } | 261 | } |
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | template <class Intf> | 264 | template <class Intf> |
| 265 | __aicore__ inline void OptGroupInitBuf(Intf *self) | 265 | __aicore__ inline void OptGroupInitBuf(Intf *self) |
| 266 | { | 266 | { |
| 267 | - self->ctx.ubBufSize = self->ctx.ci1Opt * self->ctx.convTiling->kernelHxkernelWxkernelD * self->ctx.co1Opt * | 267 | + self->ctx.ubBufSize = self->ctx.ci1Opt * self->ctx.convTilingData->convApiTiling.kernelHxkernelWxkernelD * self->ctx.co1Opt * |
| 268 | Intf::k0 * BLOCK_L0_N; | 268 | Intf::k0 * BLOCK_L0_N; |
| 269 | self->ctx.pipe.InitBuffer(self->ctx.ndUbBuf, self->ctx.ubBufSize * Intf::sizeOfWeight); | 269 | self->ctx.pipe.InitBuffer(self->ctx.ndUbBuf, self->ctx.ubBufSize * Intf::sizeOfWeight); |
| 270 | self->ctx.pipe.InitBuffer(self->ctx.nzUbBuf, self->ctx.ubBufSize * Intf::sizeOfWeight); | 270 | self->ctx.pipe.InitBuffer(self->ctx.nzUbBuf, self->ctx.ubBufSize * Intf::sizeOfWeight); |
| @@ -272,12 +272,11 @@ __aicore__ inline void OptGroupInitBuf(Intf *self) | |||
| 272 | 272 | ||
| 273 | self->ctx.nzTensor = self->ctx.nzUbBuf.template Get<typename Intf::WeightT>(); | 273 | self->ctx.nzTensor = self->ctx.nzUbBuf.template Get<typename Intf::WeightT>(); |
| 274 | 274 | ||
| 275 | - int8_t al1db = (self->ctx.convTiling->pBufferFlag & AL1_DB_IDX) >> AL1_DB_OFFSET; | 275 | + uint32_t aL1SpaceSize = self->ctx.convTilingData->convApiTiling.aL1SpaceSize; |
| 276 | - uint32_t aL1SpaceSize = self->ctx.convTiling->aL1SpaceSize; | 276 | + if ((self->ctx.convTilingData->convApiTiling.pBufferFlag & AL1_DB_IDX) >> AL1_DB_OFFSET) { |
| 277 | - if (al1db) { | ||
| 278 | aL1SpaceSize *= DOUBLE_BUF; | 277 | aL1SpaceSize *= DOUBLE_BUF; |
| 279 | } | 278 | } |
| 280 | - self->ctx.bL1SpaceSize = self->ctx.convTiling->nBL1 * self->ctx.convTiling->kBL1; | 279 | + self->ctx.bL1SpaceSize = self->ctx.convTilingData->convApiTiling.nBL1 * self->ctx.convTilingData->convApiTiling.kBL1; |
| 281 | 280 | ||
| 282 | if constexpr (Intf::bL1DBFlag) { | 281 | if constexpr (Intf::bL1DBFlag) { |
| 283 | self->ctx.pipe.InitBuffer(self->ctx.bL1TBuf, | 282 | self->ctx.pipe.InitBuffer(self->ctx.bL1TBuf, |
| @@ -295,37 +294,37 @@ __aicore__ inline void OptGroupVecInit(Intf *self) | |||
| 295 | { | 294 | { |
| 296 | self->ctx.vecId = GetSubBlockIdx(); | 295 | self->ctx.vecId = GetSubBlockIdx(); |
| 297 | 296 | ||
| 298 | - self->ctx.singleCoreCi = self->ctx.convTiling->singleCoreCi; | 297 | + self->ctx.singleCoreCi = self->ctx.convTilingData->convApiTiling.singleCoreCi; |
| 299 | - self->ctx.singleCoreCo = self->ctx.convTiling->singleCoreCo; | 298 | + self->ctx.singleCoreCo = self->ctx.convTilingData->convApiTiling.singleCoreCo; |
| 300 | - self->ctx.singleGroups = self->ctx.convTiling->singleCoreGroups; | 299 | + self->ctx.singleGroups = self->ctx.convTilingData->convApiTiling.singleCoreGroups; |
| 301 | - self->ctx.singleGroupOpt = self->ctx.convTiling->singleCoreGroupOpt; | 300 | + self->ctx.singleGroupOpt = self->ctx.convTilingData->convApiTiling.singleCoreGroupOpt; |
| 302 | 301 | ||
| 303 | - self->ctx.enlarge = self->ctx.convTiling->enlarge; | 302 | + self->ctx.enlarge = self->ctx.convTilingData->convApiTiling.enlarge; |
| 304 | - self->ctx.ciPerGroup = self->ctx.convTiling->orgCi / self->ctx.convTiling->groups; | 303 | + self->ctx.ciPerGroup = self->ctx.convTilingData->convApiTiling.orgCi / self->ctx.convTilingData->convApiTiling.groups; |
| 305 | - self->ctx.coPerGroup = self->ctx.convTiling->orgCo / self->ctx.convTiling->groups; | 304 | + self->ctx.coPerGroup = self->ctx.convTilingData->convApiTiling.orgCo / self->ctx.convTilingData->convApiTiling.groups; |
| 306 | - self->ctx.ciOpt = self->ctx.ciPerGroup * self->ctx.convTiling->enlarge; | 305 | + self->ctx.ciOpt = self->ctx.ciPerGroup * self->ctx.convTilingData->convApiTiling.enlarge; |
| 307 | self->ctx.ci1Opt = CeilDiv(self->ctx.ciOpt, Intf::k0); | 306 | self->ctx.ci1Opt = CeilDiv(self->ctx.ciOpt, Intf::k0); |
| 308 | self->ctx.ciOptAlign = self->ctx.ci1Opt * Intf::k0; | 307 | self->ctx.ciOptAlign = self->ctx.ci1Opt * Intf::k0; |
| 309 | - self->ctx.kUbSize = self->ctx.ciOptAlign * self->ctx.convTiling->kernelHxkernelWxkernelD; | 308 | + self->ctx.kUbSize = self->ctx.ciOptAlign * self->ctx.convTilingData->convApiTiling.kernelHxkernelWxkernelD; |
| 310 | - self->ctx.coOpt = self->ctx.coPerGroup * self->ctx.convTiling->enlarge; | 309 | + self->ctx.coOpt = self->ctx.coPerGroup * self->ctx.convTilingData->convApiTiling.enlarge; |
| 311 | self->ctx.co1Opt = CeilDiv(self->ctx.coOpt, BLOCK_L0_N); | 310 | self->ctx.co1Opt = CeilDiv(self->ctx.coOpt, BLOCK_L0_N); |
| 312 | self->ctx.coOptAlign = self->ctx.co1Opt * BLOCK_L0_N; | 311 | self->ctx.coOptAlign = self->ctx.co1Opt * BLOCK_L0_N; |
| 313 | 312 | ||
| 314 | if constexpr (Intf::outputOrder == static_cast<int8_t>(ConvOutputOrder::M_MODE)) { | 313 | if constexpr (Intf::outputOrder == static_cast<int8_t>(ConvOutputOrder::M_MODE)) { |
| 315 | - self->ctx.singleCoreM = self->ctx.convTiling->singleCoreHo; | 314 | + self->ctx.singleCoreM = self->ctx.convTilingData->convApiTiling.singleCoreHo; |
| 316 | - self->ctx.mAL1 = self->ctx.convTiling->hoL1; | 315 | + self->ctx.mAL1 = self->ctx.convTilingData->convApiTiling.hoL1; |
| 317 | - self->ctx.mL0 = self->ctx.convTiling->hoL0; | 316 | + self->ctx.mL0 = self->ctx.convTilingData->convApiTiling.hoL0; |
| 318 | } else { | 317 | } else { |
| 319 | - self->ctx.singleCoreHo = self->ctx.convTiling->singleCoreHo; | 318 | + self->ctx.singleCoreHo = self->ctx.convTilingData->convApiTiling.singleCoreHo; |
| 320 | - self->ctx.singleCoreWo = self->ctx.convTiling->singleCoreWo; | 319 | + self->ctx.singleCoreWo = self->ctx.convTilingData->convApiTiling.singleCoreWo; |
| 321 | } | 320 | } |
| 322 | 321 | ||
| 323 | if constexpr (Intf::isConv3D) { | 322 | if constexpr (Intf::isConv3D) { |
| 324 | - self->ctx.singleCoreDo = self->ctx.convTiling->singleCoreDo; | 323 | + self->ctx.singleCoreDo = self->ctx.convTilingData->convApiTiling.singleCoreDo; |
| 325 | self->ctx.cin1xcin0 = AlignB(self->ctx.singleCoreCi, Intf::k0); | 324 | self->ctx.cin1xcin0 = AlignB(self->ctx.singleCoreCi, Intf::k0); |
| 326 | - self->ctx.bL1Dk = self->ctx.convTiling->cinBInCore <= self->ctx.cin1xcin0 ? | 325 | + self->ctx.bL1Dk = self->ctx.convTilingData->convApiTiling.cinBInCore <= self->ctx.cin1xcin0 ? |
| 327 | - 1 : self->ctx.convTiling->cinBInCore / self->ctx.cin1xcin0; | 326 | + 1 : self->ctx.convTilingData->convApiTiling.cinBInCore / self->ctx.cin1xcin0; |
| 328 | - self->ctx.bL1DkTail = self->ctx.kernelD % self->ctx.bL1Dk; | 327 | + self->ctx.bL1DkTail = self->ctx.convTilingData->convApiTiling.kernelD % self->ctx.bL1Dk; |
| 329 | self->ctx.bL1DkTail = self->ctx.bL1DkTail == 0 ? self->ctx.bL1Dk : self->ctx.bL1DkTail; | 328 | self->ctx.bL1DkTail = self->ctx.bL1DkTail == 0 ? self->ctx.bL1Dk : self->ctx.bL1DkTail; |
| 330 | } | 329 | } |
| 331 | 330 | ||
| @@ -62,6 +62,16 @@ namespace ConvKey { | |||
| 62 | #define CONV_DIS_CONTINUOUS_CLOSE 0 | 62 | #define CONV_DIS_CONTINUOUS_CLOSE 0 |
| 63 | #define CONV_DIS_CONTINUOUS_INPUT_HWNC 1 | 63 | #define CONV_DIS_CONTINUOUS_INPUT_HWNC 1 |
| 64 | 64 | ||
| 65 | +#define CONV_HAS_PAD 0 | ||
| 66 | +#define CONV_NO_PAD 1 | ||
| 67 | + | ||
| 68 | +#define CONV_MULTI_BATCH 0 | ||
| 69 | +#define CONV_ONE_BATCH 1 | ||
| 70 | + | ||
| 71 | +#define CONV_NOT_SMALL_WEIGHT 0 | ||
| 72 | +#define CONV_FULLLOAD_KL1_NL0 1 | ||
| 73 | +#define CONV_WEIGHT_SMALLER_THAN_BL0 2 | ||
| 74 | + | ||
| 65 | #define CONV_COMMON_ONLY_MN_FULLLOAD_SEL() \ | 75 | #define CONV_COMMON_ONLY_MN_FULLLOAD_SEL() \ |
| 66 | ASCENDC_TPL_UINT_SEL(FmapTiling, ASCENDC_TPL_UI_LIST, \ | 76 | ASCENDC_TPL_UINT_SEL(FmapTiling, ASCENDC_TPL_UI_LIST, \ |
| 67 | CONV_FMAP_TILING_ONLY_M_FULLLOAD_AL1_AL0), \ | 77 | CONV_FMAP_TILING_ONLY_M_FULLLOAD_AL1_AL0), \ |
| @@ -21,6 +21,43 @@ | |||
| 21 | namespace conv { | 21 | namespace conv { |
| 22 | using namespace AscendC; | 22 | using namespace AscendC; |
| 23 | 23 | ||
| 24 | +// 新加bitmode | ||
| 25 | +#pragma pack(push, 1) // 确保无填充,严格按位排列 | ||
| 26 | +typedef struct { | ||
| 27 | + uint64_t strideW : 6; // bits 0-5 | ||
| 28 | + uint64_t strideH : 6; // bits 6-11 | ||
| 29 | + uint64_t kernelW : 8; // bits 12-19 | ||
| 30 | + uint64_t kernelH : 8; // bits 20-27 | ||
| 31 | + uint64_t dilationW : 8; // bits 28-35 | ||
| 32 | + uint64_t dilationH : 8; // bits 36-43 | ||
| 33 | + uint64_t kernelW_highest_bit : 1; // bit 44 | ||
| 34 | + uint64_t kernelH_highest_bit : 1; // bit 45 | ||
| 35 | + uint64_t reserve1 : 2; // bits 46-47 | ||
| 36 | + uint64_t channelSize : 16; // bits 48-64 | ||
| 37 | +} BitFieldXtData; | ||
| 38 | +#pragma pack(pop) | ||
| 39 | + | ||
| 40 | +#pragma pack(push, 1) // 确保无填充,严格按位排列 | ||
| 41 | +typedef struct { | ||
| 42 | + uint64_t currentKL0 : 16; // bits 0-15 | ||
| 43 | + uint64_t mExtension_ : 16; // bits 16-31 | ||
| 44 | + uint64_t posK : 16; // bits 32-47 | ||
| 45 | + uint64_t mStartPt_ : 16; // bits 48-63 | ||
| 46 | +} BitFieldXmData; | ||
| 47 | +#pragma pack(pop) | ||
| 48 | + | ||
| 49 | +union UnionDataXt { | ||
| 50 | + uint64_t n; | ||
| 51 | + BitFieldXtData bf; | ||
| 52 | + __aicore__ inline UnionDataXt() : n(0) {} | ||
| 53 | +}; | ||
| 54 | + | ||
| 55 | +union UnionDataXm { | ||
| 56 | + uint64_t n; | ||
| 57 | + BitFieldXmData bf; | ||
| 58 | + __aicore__ inline UnionDataXm() : n(0) {} | ||
| 59 | +}; | ||
| 60 | + | ||
| 24 | const static uint64_t L0A_SIZE = 65536; | 61 | const static uint64_t L0A_SIZE = 65536; |
| 25 | const static uint64_t L0B_SIZE = 65536; | 62 | const static uint64_t L0B_SIZE = 65536; |
| 26 | const static uint64_t L0C_SIZE = 262144; | 63 | const static uint64_t L0C_SIZE = 262144; |
| @@ -1,92 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * Copyright (c) 2025 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 conv2d_mdc_def.cpp | ||
| 13 | - * \brief | ||
| 14 | - */ | ||
| 15 | - | ||
| 16 | -#include <cstdint> | ||
| 17 | -#include <cstring> | ||
| 18 | -#include "register/op_config_registry.h" | ||
| 19 | - | ||
| 20 | -namespace ops { | ||
| 21 | -std::vector<ge::DataType> conv2dv2FmapDataTypeList = { | ||
| 22 | - ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16 | ||
| 23 | -}; | ||
| 24 | -std::vector<ge::DataType> conv2dv2WeightDataTypeList = { | ||
| 25 | - ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16 | ||
| 26 | -}; | ||
| 27 | -std::vector<ge::DataType> conv2dv2BiasDataTypeList = { | ||
| 28 | - ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16 | ||
| 29 | -}; | ||
| 30 | -std::vector<ge::DataType> conv2dv2OffsetWDataTypeList = { | ||
| 31 | - ge::DT_INT8, ge::DT_INT8, ge::DT_INT8, ge::DT_INT8 | ||
| 32 | -}; | ||
| 33 | -std::vector<ge::DataType> conv2dv2OutputDataTypeList = { | ||
| 34 | - ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16, ge::DT_FLOAT16 | ||
| 35 | -}; | ||
| 36 | -std::vector<ge::Format> conv2dV2FmapFormatList = { | ||
| 37 | - ge::FORMAT_NCHW, ge::FORMAT_NCHW, ge::FORMAT_NHWC, ge::FORMAT_NHWC | ||
| 38 | -}; | ||
| 39 | -std::vector<ge::Format> conv2dV2WeightFormatList = { | ||
| 40 | - ge::FORMAT_FRACTAL_Z, ge::FORMAT_FRACTAL_Z_C04, ge::FORMAT_FRACTAL_Z, ge::FORMAT_FRACTAL_Z_C04 | ||
| 41 | -}; | ||
| 42 | -std::vector<ge::Format> conv2dV2BiasFormatList = { | ||
| 43 | - ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND | ||
| 44 | -}; | ||
| 45 | -std::vector<ge::Format> conv2dV2OffsetWFormatList = { | ||
| 46 | - ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND | ||
| 47 | -}; | ||
| 48 | -std::vector<ge::Format> conv2dV2OutputFormatList = { | ||
| 49 | - ge::FORMAT_NCHW, ge::FORMAT_NCHW, ge::FORMAT_NHWC, ge::FORMAT_NHWC | ||
| 50 | -}; | ||
| 51 | - | ||
| 52 | -REGISTER_OP_AICORE_CONFIG(Conv2DV2, mc62cm12a, []() { | ||
| 53 | - OpAICoreConfig aicoreConfig("mc62cm12a"); | ||
| 54 | - aicoreConfig.Input("x") | ||
| 55 | - .ParamType(REQUIRED) | ||
| 56 | - .DataType(conv2dv2FmapDataTypeList) | ||
| 57 | - .Format(conv2dV2FmapFormatList) | ||
| 58 | - .UnknownShapeFormat(conv2dV2FmapFormatList); | ||
| 59 | - aicoreConfig.Input("filter") | ||
| 60 | - .ParamType(REQUIRED) | ||
| 61 | - .DataType(conv2dv2WeightDataTypeList) | ||
| 62 | - .Format(conv2dV2WeightFormatList) | ||
| 63 | - .UnknownShapeFormat(conv2dV2WeightFormatList); | ||
| 64 | - aicoreConfig.Input("bias") | ||
| 65 | - .ParamType(OPTIONAL) | ||
| 66 | - .DataType(conv2dv2BiasDataTypeList) | ||
| 67 | - .Format(conv2dV2BiasFormatList) | ||
| 68 | - .UnknownShapeFormat(conv2dV2BiasFormatList); | ||
| 69 | - aicoreConfig.Input("offset_w") | ||
| 70 | - .ParamType(OPTIONAL) | ||
| 71 | - .DataType(conv2dv2OffsetWDataTypeList) | ||
| 72 | - .Format(conv2dV2OffsetWFormatList) | ||
| 73 | - .UnknownShapeFormat(conv2dV2OffsetWFormatList); | ||
| 74 | - aicoreConfig.Output("y") | ||
| 75 | - .ParamType(REQUIRED) | ||
| 76 | - .DataType(conv2dv2OutputDataTypeList) | ||
| 77 | - .Format(conv2dV2OutputFormatList) | ||
| 78 | - .UnknownShapeFormat(conv2dV2OutputFormatList); | ||
| 79 | - aicoreConfig.DynamicCompileStaticFlag(true) | ||
| 80 | - .DynamicFormatFlag(true) | ||
| 81 | - .DynamicRankSupportFlag(true) | ||
| 82 | - .DynamicShapeSupportFlag(true) | ||
| 83 | - .NeedCheckSupportFlag(false) | ||
| 84 | - .PrecisionReduceFlag(true) | ||
| 85 | - .ExtendCfgInfo("opFile.value", "conv2d_v2") | ||
| 86 | - .ExtendCfgInfo("opInterface.value", "conv2dv2") | ||
| 87 | - .ExtendCfgInfo("aclnnSupport.value", "support_aclnn") | ||
| 88 | - .ExtendCfgInfo("jitCompile.flag", "false"); | ||
| 89 | - | ||
| 90 | - return aicoreConfig; | ||
| 91 | -}); | ||
| 92 | -} | ||
| @@ -425,7 +425,7 @@ void Conv2dTiling::SetAttrsTilingData(optiling::TConv2DTiling& tiling) | |||
| 425 | tiling.set_padBottom(static_cast<uint32_t>(attrInfo.padBottom)); | 425 | tiling.set_padBottom(static_cast<uint32_t>(attrInfo.padBottom)); |
| 426 | tiling.set_padLeft(static_cast<uint32_t>(attrInfo.padLeft)); | 426 | tiling.set_padLeft(static_cast<uint32_t>(attrInfo.padLeft)); |
| 427 | tiling.set_padRight(static_cast<uint32_t>(attrInfo.padRight)); | 427 | tiling.set_padRight(static_cast<uint32_t>(attrInfo.padRight)); |
| 428 | - | 428 | + tiling.set_unionDataXt(static_cast<uint64_t>(attrInfo.unionDataXt.n)); |
| 429 | tiling.set_groups(static_cast<uint32_t>(attrInfo.groups)); | 429 | tiling.set_groups(static_cast<uint32_t>(attrInfo.groups)); |
| 430 | 430 | ||
| 431 | if (this->optGroupFlag) { | 431 | if (this->optGroupFlag) { |
| @@ -492,6 +492,10 @@ void Conv2dTiling::SetOrgWeightShape(int64_t orgCo, int64_t orgkH, int64_t orgkW | |||
| 492 | shapeInfo.orgkH = orgkH; | 492 | shapeInfo.orgkH = orgkH; |
| 493 | shapeInfo.orgkW = orgkW; | 493 | shapeInfo.orgkW = orgkW; |
| 494 | shapeInfo.orgCo = orgCo; | 494 | shapeInfo.orgCo = orgCo; |
| 495 | + attrInfo.unionDataXt.bf.kernelW = static_cast<uint64_t>(orgkW); | ||
| 496 | + attrInfo.unionDataXt.bf.kernelW_highest_bit = (static_cast<uint64_t>(orgkW) & 0x100) >> 8; // 8 kernelW lower 8 bit | ||
| 497 | + attrInfo.unionDataXt.bf.kernelH = static_cast<uint64_t>(orgkH); | ||
| 498 | + attrInfo.unionDataXt.bf.kernelH_highest_bit = (static_cast<uint64_t>(orgkH) & 0x100) >> 8; // 8 kernelH lower 8 bit | ||
| 495 | } | 499 | } |
| 496 | 500 | ||
| 497 | void Conv2dTiling::SetSingleWeightShape(int64_t singleCi, int64_t singlekH, int64_t singlekW) | 501 | void Conv2dTiling::SetSingleWeightShape(int64_t singleCi, int64_t singlekH, int64_t singlekW) |
| @@ -549,12 +553,16 @@ void Conv2dTiling::SetDilation(int32_t dilationH, int32_t dilationW) | |||
| 549 | { | 553 | { |
| 550 | attrInfo.dilationH = dilationH; | 554 | attrInfo.dilationH = dilationH; |
| 551 | attrInfo.dilationW = dilationW; | 555 | attrInfo.dilationW = dilationW; |
| 556 | + attrInfo.unionDataXt.bf.dilationH = static_cast<uint64_t>(dilationH); | ||
| 557 | + attrInfo.unionDataXt.bf.dilationW = static_cast<uint64_t>(dilationW); | ||
| 552 | } | 558 | } |
| 553 | 559 | ||
| 554 | void Conv2dTiling::SetStride(int32_t strideH, int32_t strideW) | 560 | void Conv2dTiling::SetStride(int32_t strideH, int32_t strideW) |
| 555 | { | 561 | { |
| 556 | attrInfo.strideH = strideH; | 562 | attrInfo.strideH = strideH; |
| 557 | attrInfo.strideW = strideW; | 563 | attrInfo.strideW = strideW; |
| 564 | + attrInfo.unionDataXt.bf.strideH = static_cast<uint64_t>(strideH) & 0x3f; | ||
| 565 | + attrInfo.unionDataXt.bf.strideW = static_cast<uint64_t>(strideW) & 0x3f; | ||
| 558 | } | 566 | } |
| 559 | 567 | ||
| 560 | void Conv2dTiling::SetBiasType(TPosition pos, ConvFormat format, ConvDtype dtype) | 568 | void Conv2dTiling::SetBiasType(TPosition pos, ConvFormat format, ConvDtype dtype) |
| @@ -29,6 +29,7 @@ TILING_DATA_FIELD_DEF(uint64_t, orgHixWi); | |||
| 29 | TILING_DATA_FIELD_DEF(uint64_t, singleCoreBatch); | 29 | TILING_DATA_FIELD_DEF(uint64_t, singleCoreBatch); |
| 30 | TILING_DATA_FIELD_DEF(uint64_t, singleCoreHo); | 30 | TILING_DATA_FIELD_DEF(uint64_t, singleCoreHo); |
| 31 | TILING_DATA_FIELD_DEF(uint64_t, singleCoreWo); | 31 | TILING_DATA_FIELD_DEF(uint64_t, singleCoreWo); |
| 32 | +TILING_DATA_FIELD_DEF(uint64_t, unionDataXt); | ||
| 32 | TILING_DATA_FIELD_DEF(uint32_t, orgCi); | 33 | TILING_DATA_FIELD_DEF(uint32_t, orgCi); |
| 33 | TILING_DATA_FIELD_DEF(uint32_t, orgCo); | 34 | TILING_DATA_FIELD_DEF(uint32_t, orgCo); |
| 34 | TILING_DATA_FIELD_DEF(uint32_t, singleCoreCi); | 35 | TILING_DATA_FIELD_DEF(uint32_t, singleCoreCi); |
| @@ -446,12 +446,12 @@ ge::graphStatus Conv2dBaseTiling::GetFeatureFlag() | |||
| 446 | 446 | ||
| 447 | void Conv2dBaseTiling::SetNumBlocksRes() | 447 | void Conv2dBaseTiling::SetNumBlocksRes() |
| 448 | { | 448 | { |
| 449 | - numBlocksRes.batchDim = tilingData_.conv2dRunInfo.get_batchDim(); | 449 | + numBlocksRes.batchDim = tilingData_.convRunInfo.get_batchDim(); |
| 450 | - numBlocksRes.nDim = tilingData_.conv2dRunInfo.get_nDim(); | 450 | + numBlocksRes.nDim = tilingData_.convRunInfo.get_nDim(); |
| 451 | - numBlocksRes.hoDim = tilingData_.conv2dRunInfo.get_hoDim(); | 451 | + numBlocksRes.hoDim = tilingData_.convRunInfo.get_hoDim(); |
| 452 | - numBlocksRes.woDim = tilingData_.conv2dRunInfo.get_woDim(); | 452 | + numBlocksRes.woDim = tilingData_.convRunInfo.get_woDim(); |
| 453 | numBlocksRes.mDim = numBlocksRes.hoDim; | 453 | numBlocksRes.mDim = numBlocksRes.hoDim; |
| 454 | - numBlocksRes.groupDim = tilingData_.conv2dRunInfo.get_groupDim(); | 454 | + numBlocksRes.groupDim = tilingData_.convRunInfo.get_groupDim(); |
| 455 | } | 455 | } |
| 456 | 456 | ||
| 457 | // reset conv2d API's tilingdata | 457 | // reset conv2d API's tilingdata |
| @@ -207,6 +207,8 @@ private: | |||
| 207 | uint64_t GetFmapCopyMode(); | 207 | uint64_t GetFmapCopyMode(); |
| 208 | uint64_t GetEnableInnerBatch(); | 208 | uint64_t GetEnableInnerBatch(); |
| 209 | void ReSetTilingKeyPara(); | 209 | void ReSetTilingKeyPara(); |
| 210 | + uint64_t GetNoPad() const; | ||
| 211 | + uint64_t GetSmallWeightVal(); | ||
| 210 | 212 | ||
| 211 | int32_t BasicBlockSortFWDimScores(vector<tuple<uint64_t, float, uint32_t, double>>& scores); | 213 | int32_t BasicBlockSortFWDimScores(vector<tuple<uint64_t, float, uint32_t, double>>& scores); |
| 212 | ge::graphStatus GetConv2DAxisPosInfo(); | 214 | ge::graphStatus GetConv2DAxisPosInfo(); |
| @@ -240,6 +242,8 @@ private: | |||
| 240 | bool CheckScaleLegal(uint32_t scaleIndex, uint8_t& quantMode, const std::string& scaleType); | 242 | bool CheckScaleLegal(uint32_t scaleIndex, uint8_t& quantMode, const std::string& scaleType); |
| 241 | ge::Format GetWeightFormat() const; | 243 | ge::Format GetWeightFormat() const; |
| 242 | gert::Shape GetWeightShape(const gert::StorageShape* weightShapePtr) const; | 244 | gert::Shape GetWeightShape(const gert::StorageShape* weightShapePtr) const; |
| 245 | + void SetUnionDataXt(shared_ptr<tuningtiling::Conv2DV2TunnerTiling> convRepoTiling); | ||
| 246 | + void PrintInputArgs(shared_ptr<tuningtiling::Conv2DV2InputArgs> conv2DInput); | ||
| 243 | }; | 247 | }; |
| 244 | } | 248 | } |
| 245 | } | 249 | } |
| @@ -402,8 +402,13 @@ void Conv2dBaseTiling::GetInitBasicBlockMN(uint64_t& basicBlockM, uint64_t& basi | |||
| 402 | { | 402 | { |
| 403 | uint64_t howo = shapeInfo_.ho * shapeInfo_.wo; | 403 | uint64_t howo = shapeInfo_.ho * shapeInfo_.wo; |
| 404 | if (shapeInfo_.co <= BASICBLOCK_BOUNDARY_VALUE_64) { | 404 | if (shapeInfo_.co <= BASICBLOCK_BOUNDARY_VALUE_64) { |
| 405 | - basicBlockM = BASICBLOCK_INIT_VALUE_1024; | 405 | + if (descInfo_.fMapDtype == ge::DT_FLOAT16 && descInfo_.weightDtype == ge::DT_INT8) { |
| 406 | - basicBlockN = BASICBLOCK_INIT_VALUE_64; | 406 | + basicBlockM = BASICBLOCK_INIT_VALUE_512; |
| 407 | + basicBlockN = BASICBLOCK_INIT_VALUE_64; | ||
| 408 | + } else { | ||
| 409 | + basicBlockM = BASICBLOCK_INIT_VALUE_1024; | ||
| 410 | + basicBlockN = BASICBLOCK_INIT_VALUE_64; | ||
| 411 | + } | ||
| 407 | } else if (shapeInfo_.co > BASICBLOCK_BOUNDARY_VALUE_64 | 412 | } else if (shapeInfo_.co > BASICBLOCK_BOUNDARY_VALUE_64 |
| 408 | && shapeInfo_.co <= BASICBLOCK_BOUNDARY_VALUE_128) { | 413 | && shapeInfo_.co <= BASICBLOCK_BOUNDARY_VALUE_128) { |
| 409 | basicBlockM = BASICBLOCK_INIT_VALUE_512; | 414 | basicBlockM = BASICBLOCK_INIT_VALUE_512; |
| @@ -63,67 +63,68 @@ bool Conv2dBaseTiling::AddTilingToCache() | |||
| 63 | 63 | ||
| 64 | void Conv2dBaseTiling::GetCachedTilingDataAux() | 64 | void Conv2dBaseTiling::GetCachedTilingDataAux() |
| 65 | { | 65 | { |
| 66 | - cachedTilingData_.fmapKStride = tilingData_.conv2dApiTiling.get_fmapKStride(); | 66 | + cachedTilingData_.fmapKStride = tilingData_.convApiTiling.get_fmapKStride(); |
| 67 | - cachedTilingData_.weightKStride = tilingData_.conv2dApiTiling.get_weightKStride(); | 67 | + cachedTilingData_.weightKStride = tilingData_.convApiTiling.get_weightKStride(); |
| 68 | - cachedTilingData_.cinOffsetBlockInGM = tilingData_.conv2dApiTiling.get_cinOffsetBlockInGM(); | 68 | + cachedTilingData_.cinOffsetBlockInGM = tilingData_.convApiTiling.get_cinOffsetBlockInGM(); |
| 69 | - cachedTilingData_.coutOffsetBlock = tilingData_.conv2dApiTiling.get_coutOffsetBlock(); | 69 | + cachedTilingData_.coutOffsetBlock = tilingData_.convApiTiling.get_coutOffsetBlock(); |
| 70 | - cachedTilingData_.nL1DivBlockSize = tilingData_.conv2dApiTiling.get_nL1DivBlockSize(); | 70 | + cachedTilingData_.nL1DivBlockSize = tilingData_.convApiTiling.get_nL1DivBlockSize(); |
| 71 | - cachedTilingData_.iterateMNOrder = tilingData_.conv2dApiTiling.get_iterateMNOrder(); | 71 | + cachedTilingData_.iterateMNOrder = tilingData_.convApiTiling.get_iterateMNOrder(); |
| 72 | - cachedTilingData_.biasFullLoadFlag = tilingData_.conv2dApiTiling.get_biasFullLoadFlag(); | 72 | + cachedTilingData_.biasFullLoadFlag = tilingData_.convApiTiling.get_biasFullLoadFlag(); |
| 73 | - cachedTilingData_.fixpParamsFullLoadFlag = tilingData_.conv2dApiTiling.get_fixpParamsFullLoadFlag(); | 73 | + cachedTilingData_.fixpParamsFullLoadFlag = tilingData_.convApiTiling.get_fixpParamsFullLoadFlag(); |
| 74 | - cachedTilingData_.hf32Enable = tilingData_.conv2dApiTiling.get_hf32Enable(); | 74 | + cachedTilingData_.hf32Enable = tilingData_.convApiTiling.get_hf32Enable(); |
| 75 | - cachedTilingData_.hf32TransMode = tilingData_.conv2dApiTiling.get_hf32TransMode(); | 75 | + cachedTilingData_.hf32TransMode = tilingData_.convApiTiling.get_hf32TransMode(); |
| 76 | - cachedTilingData_.batchDim = tilingData_.conv2dRunInfo.get_batchDim(); | 76 | + cachedTilingData_.batchDim = tilingData_.convRunInfo.get_batchDim(); |
| 77 | - cachedTilingData_.groupDim = tilingData_.conv2dRunInfo.get_groupDim(); | 77 | + cachedTilingData_.groupDim = tilingData_.convRunInfo.get_groupDim(); |
| 78 | - cachedTilingData_.nDim = tilingData_.conv2dRunInfo.get_nDim(); | 78 | + cachedTilingData_.nDim = tilingData_.convRunInfo.get_nDim(); |
| 79 | - cachedTilingData_.hoDim = tilingData_.conv2dRunInfo.get_hoDim(); | 79 | + cachedTilingData_.hoDim = tilingData_.convRunInfo.get_hoDim(); |
| 80 | - cachedTilingData_.woDim = tilingData_.conv2dRunInfo.get_woDim(); | 80 | + cachedTilingData_.woDim = tilingData_.convRunInfo.get_woDim(); |
| 81 | - cachedTilingData_.cinOpt = tilingData_.conv2dRunInfo.get_cinOpt(); | 81 | + cachedTilingData_.cinOpt = tilingData_.convRunInfo.get_cinOpt(); |
| 82 | - cachedTilingData_.coutOpt = tilingData_.conv2dRunInfo.get_coutOpt(); | 82 | + cachedTilingData_.coutOpt = tilingData_.convRunInfo.get_coutOpt(); |
| 83 | - cachedTilingData_.groupOpt = tilingData_.conv2dRunInfo.get_groupOpt(); | 83 | + cachedTilingData_.groupOpt = tilingData_.convRunInfo.get_groupOpt(); |
| 84 | cachedTilingData_.enableC04Flag = flagInfo_.enableC04Flag; | 84 | cachedTilingData_.enableC04Flag = flagInfo_.enableC04Flag; |
| 85 | cachedTilingData_.mSplitModeFlag = flagInfo_.mSplitModeFlag; | 85 | cachedTilingData_.mSplitModeFlag = flagInfo_.mSplitModeFlag; |
| 86 | + cachedTilingData_.unionDataXt = tilingData_.convApiTiling.get_unionDataXt(); | ||
| 86 | } | 87 | } |
| 87 | 88 | ||
| 88 | void Conv2dBaseTiling::GetCachedTilingData() | 89 | void Conv2dBaseTiling::GetCachedTilingData() |
| 89 | { | 90 | { |
| 90 | - cachedTilingData_.singleCoreBatch = tilingData_.conv2dApiTiling.get_singleCoreBatch(); | 91 | + cachedTilingData_.singleCoreBatch = tilingData_.convApiTiling.get_singleCoreBatch(); |
| 91 | - cachedTilingData_.singleCoreHo = tilingData_.conv2dApiTiling.get_singleCoreHo(); | 92 | + cachedTilingData_.singleCoreHo = tilingData_.convApiTiling.get_singleCoreHo(); |
| 92 | - cachedTilingData_.singleCoreWo = tilingData_.conv2dApiTiling.get_singleCoreWo(); | 93 | + cachedTilingData_.singleCoreWo = tilingData_.convApiTiling.get_singleCoreWo(); |
| 93 | - cachedTilingData_.singleCoreCi = tilingData_.conv2dApiTiling.get_singleCoreCi(); | 94 | + cachedTilingData_.singleCoreCi = tilingData_.convApiTiling.get_singleCoreCi(); |
| 94 | - cachedTilingData_.singleCoreCo = tilingData_.conv2dApiTiling.get_singleCoreCo(); | 95 | + cachedTilingData_.singleCoreCo = tilingData_.convApiTiling.get_singleCoreCo(); |
| 95 | - cachedTilingData_.hoL1 = tilingData_.conv2dApiTiling.get_hoL1(); | 96 | + cachedTilingData_.hoL1 = tilingData_.convApiTiling.get_hoL1(); |
| 96 | - cachedTilingData_.woL1 = tilingData_.conv2dApiTiling.get_woL1(); | 97 | + cachedTilingData_.woL1 = tilingData_.convApiTiling.get_woL1(); |
| 97 | - cachedTilingData_.kAL1 = tilingData_.conv2dApiTiling.get_kAL1(); | 98 | + cachedTilingData_.kAL1 = tilingData_.convApiTiling.get_kAL1(); |
| 98 | - cachedTilingData_.kBL1 = tilingData_.conv2dApiTiling.get_kBL1(); | 99 | + cachedTilingData_.kBL1 = tilingData_.convApiTiling.get_kBL1(); |
| 99 | - cachedTilingData_.khL1 = tilingData_.conv2dApiTiling.get_khL1(); | 100 | + cachedTilingData_.khL1 = tilingData_.convApiTiling.get_khL1(); |
| 100 | - cachedTilingData_.kwL1 = tilingData_.conv2dApiTiling.get_kwL1(); | 101 | + cachedTilingData_.kwL1 = tilingData_.convApiTiling.get_kwL1(); |
| 101 | - cachedTilingData_.nBL1 = tilingData_.conv2dApiTiling.get_nBL1(); | 102 | + cachedTilingData_.nBL1 = tilingData_.convApiTiling.get_nBL1(); |
| 102 | - cachedTilingData_.hoL0 = tilingData_.conv2dApiTiling.get_hoL0(); | 103 | + cachedTilingData_.hoL0 = tilingData_.convApiTiling.get_hoL0(); |
| 103 | - cachedTilingData_.woL0 = tilingData_.conv2dApiTiling.get_woL0(); | 104 | + cachedTilingData_.woL0 = tilingData_.convApiTiling.get_woL0(); |
| 104 | - cachedTilingData_.kL0 = tilingData_.conv2dApiTiling.get_kL0(); | 105 | + cachedTilingData_.kL0 = tilingData_.convApiTiling.get_kL0(); |
| 105 | - cachedTilingData_.nL0 = tilingData_.conv2dApiTiling.get_nL0(); | 106 | + cachedTilingData_.nL0 = tilingData_.convApiTiling.get_nL0(); |
| 106 | - cachedTilingData_.pBufferFlag = tilingData_.conv2dApiTiling.get_pBufferFlag(); | 107 | + cachedTilingData_.pBufferFlag = tilingData_.convApiTiling.get_pBufferFlag(); |
| 107 | - cachedTilingData_.enlarge = tilingData_.conv2dApiTiling.get_enlarge(); | 108 | + cachedTilingData_.enlarge = tilingData_.convApiTiling.get_enlarge(); |
| 108 | - cachedTilingData_.singleCoreGroups = tilingData_.conv2dApiTiling.get_singleCoreGroups(); | 109 | + cachedTilingData_.singleCoreGroups = tilingData_.convApiTiling.get_singleCoreGroups(); |
| 109 | - cachedTilingData_.singleCoreGroupOpt = tilingData_.conv2dApiTiling.get_singleCoreGroupOpt(); | 110 | + cachedTilingData_.singleCoreGroupOpt = tilingData_.convApiTiling.get_singleCoreGroupOpt(); |
| 110 | - cachedTilingData_.bUbNStep = tilingData_.conv2dApiTiling.get_bUbNStep(); | 111 | + cachedTilingData_.bUbNStep = tilingData_.convApiTiling.get_bUbNStep(); |
| 111 | - cachedTilingData_.bUbKStep = tilingData_.conv2dApiTiling.get_bUbKStep(); | 112 | + cachedTilingData_.bUbKStep = tilingData_.convApiTiling.get_bUbKStep(); |
| 112 | - cachedTilingData_.khUb = tilingData_.conv2dApiTiling.get_khUb(); | 113 | + cachedTilingData_.khUb = tilingData_.convApiTiling.get_khUb(); |
| 113 | - cachedTilingData_.kwUb = tilingData_.conv2dApiTiling.get_kwUb(); | 114 | + cachedTilingData_.kwUb = tilingData_.convApiTiling.get_kwUb(); |
| 114 | - cachedTilingData_.orgHixWi = tilingData_.conv2dApiTiling.get_orgHixWi(); | 115 | + cachedTilingData_.orgHixWi = tilingData_.convApiTiling.get_orgHixWi(); |
| 115 | - cachedTilingData_.kernelHxkernelW = tilingData_.conv2dApiTiling.get_kernelHxkernelW(); | 116 | + cachedTilingData_.kernelHxkernelW = tilingData_.convApiTiling.get_kernelHxkernelW(); |
| 116 | - cachedTilingData_.kernelHxkernelWxkernelD = tilingData_.conv2dApiTiling.get_kernelHxkernelWxkernelD(); | 117 | + cachedTilingData_.kernelHxkernelWxkernelD = tilingData_.convApiTiling.get_kernelHxkernelWxkernelD(); |
| 117 | - cachedTilingData_.aL1SpaceSize = tilingData_.conv2dApiTiling.get_aL1SpaceSize(); | 118 | + cachedTilingData_.aL1SpaceSize = tilingData_.convApiTiling.get_aL1SpaceSize(); |
| 118 | - cachedTilingData_.multiNBL1 = tilingData_.conv2dApiTiling.get_multiNBL1(); | 119 | + cachedTilingData_.multiNBL1 = tilingData_.convApiTiling.get_multiNBL1(); |
| 119 | - cachedTilingData_.cinAInCore = tilingData_.conv2dApiTiling.get_cinAInCore(); | 120 | + cachedTilingData_.cinAInCore = tilingData_.convApiTiling.get_cinAInCore(); |
| 120 | - cachedTilingData_.cinATailInCore = tilingData_.conv2dApiTiling.get_cinATailInCore(); | 121 | + cachedTilingData_.cinATailInCore = tilingData_.convApiTiling.get_cinATailInCore(); |
| 121 | - cachedTilingData_.cinBInCore = tilingData_.conv2dApiTiling.get_cinBInCore(); | 122 | + cachedTilingData_.cinBInCore = tilingData_.convApiTiling.get_cinBInCore(); |
| 122 | - cachedTilingData_.cinBTailInCore = tilingData_.conv2dApiTiling.get_cinBTailInCore(); | 123 | + cachedTilingData_.cinBTailInCore = tilingData_.convApiTiling.get_cinBTailInCore(); |
| 123 | - cachedTilingData_.mStep = tilingData_.conv2dApiTiling.get_mStep(); | 124 | + cachedTilingData_.mStep = tilingData_.convApiTiling.get_mStep(); |
| 124 | - cachedTilingData_.kStep = tilingData_.conv2dApiTiling.get_kStep(); | 125 | + cachedTilingData_.kStep = tilingData_.convApiTiling.get_kStep(); |
| 125 | - cachedTilingData_.nStep = tilingData_.conv2dApiTiling.get_nStep(); | 126 | + cachedTilingData_.nStep = tilingData_.convApiTiling.get_nStep(); |
| 126 | - cachedTilingData_.innerBatch = tilingData_.conv2dApiTiling.get_innerBatch(); | 127 | + cachedTilingData_.innerBatch = tilingData_.convApiTiling.get_innerBatch(); |
| 127 | GetCachedTilingDataAux(); | 128 | GetCachedTilingDataAux(); |
| 128 | } | 129 | } |
| 129 | 130 | ||
| @@ -187,115 +188,116 @@ void Conv2dBaseTiling::GetCacheTilingInputArgs() | |||
| 187 | 188 | ||
| 188 | void Conv2dBaseTiling::TranslateCachedRunInfo() | 189 | void Conv2dBaseTiling::TranslateCachedRunInfo() |
| 189 | { | 190 | { |
| 190 | - tilingData_.conv2dRunInfo.set_batch(cacheInputArgs_.inputShapeN); | 191 | + tilingData_.convRunInfo.set_batch(cacheInputArgs_.inputShapeN); |
| 191 | - tilingData_.conv2dRunInfo.set_hin(cacheInputArgs_.inputShapeH); | 192 | + tilingData_.convRunInfo.set_hin(cacheInputArgs_.inputShapeH); |
| 192 | - tilingData_.conv2dRunInfo.set_win(cacheInputArgs_.inputShapeW); | 193 | + tilingData_.convRunInfo.set_win(cacheInputArgs_.inputShapeW); |
| 193 | - tilingData_.conv2dRunInfo.set_batchDim(cachedTilingData_.batchDim); | 194 | + tilingData_.convRunInfo.set_batchDim(cachedTilingData_.batchDim); |
| 194 | - tilingData_.conv2dRunInfo.set_hoDim(cachedTilingData_.hoDim); | 195 | + tilingData_.convRunInfo.set_hoDim(cachedTilingData_.hoDim); |
| 195 | - tilingData_.conv2dRunInfo.set_woDim(cachedTilingData_.woDim); | 196 | + tilingData_.convRunInfo.set_woDim(cachedTilingData_.woDim); |
| 196 | - tilingData_.conv2dRunInfo.set_nDim(cachedTilingData_.nDim); | 197 | + tilingData_.convRunInfo.set_nDim(cachedTilingData_.nDim); |
| 197 | - tilingData_.conv2dRunInfo.set_cin(shapeInfo_.ci); | 198 | + tilingData_.convRunInfo.set_cin(shapeInfo_.ci); |
| 198 | - tilingData_.conv2dRunInfo.set_cout(cacheInputArgs_.weightShapeN); | 199 | + tilingData_.convRunInfo.set_cout(cacheInputArgs_.weightShapeN); |
| 199 | - tilingData_.conv2dRunInfo.set_kh(cacheInputArgs_.weightShapeH); | 200 | + tilingData_.convRunInfo.set_kh(cacheInputArgs_.weightShapeH); |
| 200 | - tilingData_.conv2dRunInfo.set_kw(cacheInputArgs_.weightShapeW); | 201 | + tilingData_.convRunInfo.set_kw(cacheInputArgs_.weightShapeW); |
| 201 | - tilingData_.conv2dRunInfo.set_hout(cacheInputArgs_.outputShapeH); | 202 | + tilingData_.convRunInfo.set_hout(cacheInputArgs_.outputShapeH); |
| 202 | - tilingData_.conv2dRunInfo.set_wout(cacheInputArgs_.outputShapeW); | 203 | + tilingData_.convRunInfo.set_wout(cacheInputArgs_.outputShapeW); |
| 203 | - tilingData_.conv2dRunInfo.set_strideH(cacheInputArgs_.strideH); | 204 | + tilingData_.convRunInfo.set_strideH(cacheInputArgs_.strideH); |
| 204 | - tilingData_.conv2dRunInfo.set_strideW(cacheInputArgs_.strideW); | 205 | + tilingData_.convRunInfo.set_strideW(cacheInputArgs_.strideW); |
| 205 | - tilingData_.conv2dRunInfo.set_dilationH(cacheInputArgs_.dilationH); | 206 | + tilingData_.convRunInfo.set_dilationH(cacheInputArgs_.dilationH); |
| 206 | - tilingData_.conv2dRunInfo.set_dilationW(cacheInputArgs_.dilationW); | 207 | + tilingData_.convRunInfo.set_dilationW(cacheInputArgs_.dilationW); |
| 207 | - tilingData_.conv2dRunInfo.set_padTop(cacheInputArgs_.padTop); | 208 | + tilingData_.convRunInfo.set_padTop(cacheInputArgs_.padTop); |
| 208 | - tilingData_.conv2dRunInfo.set_padLeft(cacheInputArgs_.padLeft); | 209 | + tilingData_.convRunInfo.set_padLeft(cacheInputArgs_.padLeft); |
| 209 | - tilingData_.conv2dRunInfo.set_hasBias(cacheInputArgs_.biasFlag); | 210 | + tilingData_.convRunInfo.set_hasBias(cacheInputArgs_.biasFlag); |
| 210 | - tilingData_.conv2dRunInfo.set_groups(cacheInputArgs_.groups); | 211 | + tilingData_.convRunInfo.set_groups(cacheInputArgs_.groups); |
| 211 | - tilingData_.conv2dRunInfo.set_cinOpt(cachedTilingData_.cinOpt); | 212 | + tilingData_.convRunInfo.set_cinOpt(cachedTilingData_.cinOpt); |
| 212 | - tilingData_.conv2dRunInfo.set_coutOpt(cachedTilingData_.coutOpt); | 213 | + tilingData_.convRunInfo.set_coutOpt(cachedTilingData_.coutOpt); |
| 213 | - tilingData_.conv2dRunInfo.set_groupOpt(cachedTilingData_.groupOpt); | 214 | + tilingData_.convRunInfo.set_groupOpt(cachedTilingData_.groupOpt); |
| 214 | - tilingData_.conv2dRunInfo.set_enlarge(cachedTilingData_.enlarge); | 215 | + tilingData_.convRunInfo.set_enlarge(cachedTilingData_.enlarge); |
| 215 | - tilingData_.conv2dRunInfo.set_groupDim(cachedTilingData_.groupDim); | 216 | + tilingData_.convRunInfo.set_groupDim(cachedTilingData_.groupDim); |
| 216 | } | 217 | } |
| 217 | 218 | ||
| 218 | void Conv2dBaseTiling::TranslateCachedApiTilingPartTwo() | 219 | void Conv2dBaseTiling::TranslateCachedApiTilingPartTwo() |
| 219 | { | 220 | { |
| 220 | - tilingData_.conv2dApiTiling.set_strideH(cacheInputArgs_.strideH); | 221 | + tilingData_.convApiTiling.set_strideH(cacheInputArgs_.strideH); |
| 221 | - tilingData_.conv2dApiTiling.set_strideW(cacheInputArgs_.strideW); | 222 | + tilingData_.convApiTiling.set_strideW(cacheInputArgs_.strideW); |
| 222 | - tilingData_.conv2dApiTiling.set_dilationH(cacheInputArgs_.dilationH); | 223 | + tilingData_.convApiTiling.set_dilationH(cacheInputArgs_.dilationH); |
| 223 | - tilingData_.conv2dApiTiling.set_dilationW(cacheInputArgs_.dilationW); | 224 | + tilingData_.convApiTiling.set_dilationW(cacheInputArgs_.dilationW); |
| 224 | - tilingData_.conv2dApiTiling.set_padTop(cacheInputArgs_.padTop); | 225 | + tilingData_.convApiTiling.set_padTop(cacheInputArgs_.padTop); |
| 225 | - tilingData_.conv2dApiTiling.set_padBottom(cacheInputArgs_.padBottom); | 226 | + tilingData_.convApiTiling.set_padBottom(cacheInputArgs_.padBottom); |
| 226 | - tilingData_.conv2dApiTiling.set_padLeft(cacheInputArgs_.padLeft); | 227 | + tilingData_.convApiTiling.set_padLeft(cacheInputArgs_.padLeft); |
| 227 | - tilingData_.conv2dApiTiling.set_padRight(cacheInputArgs_.padRight); | 228 | + tilingData_.convApiTiling.set_padRight(cacheInputArgs_.padRight); |
| 228 | - tilingData_.conv2dApiTiling.set_iterateMNOrder(cachedTilingData_.iterateMNOrder); | 229 | + tilingData_.convApiTiling.set_iterateMNOrder(cachedTilingData_.iterateMNOrder); |
| 229 | - tilingData_.conv2dApiTiling.set_biasFullLoadFlag(cachedTilingData_.biasFullLoadFlag); | 230 | + tilingData_.convApiTiling.set_biasFullLoadFlag(cachedTilingData_.biasFullLoadFlag); |
| 230 | - tilingData_.conv2dApiTiling.set_fixpParamsFullLoadFlag(cachedTilingData_.fixpParamsFullLoadFlag); | 231 | + tilingData_.convApiTiling.set_fixpParamsFullLoadFlag(cachedTilingData_.fixpParamsFullLoadFlag); |
| 231 | - tilingData_.conv2dApiTiling.set_hf32Enable(cachedTilingData_.hf32Enable); | 232 | + tilingData_.convApiTiling.set_hf32Enable(cachedTilingData_.hf32Enable); |
| 232 | - tilingData_.conv2dApiTiling.set_hf32TransMode(cachedTilingData_.hf32TransMode); | 233 | + tilingData_.convApiTiling.set_hf32TransMode(cachedTilingData_.hf32TransMode); |
| 233 | - tilingData_.conv2dApiTiling.set_hasBias(cacheInputArgs_.biasFlag); | 234 | + tilingData_.convApiTiling.set_hasBias(cacheInputArgs_.biasFlag); |
| 234 | - tilingData_.conv2dApiTiling.set_hasScale(static_cast<uint8_t>(flagInfo_.quantFlag || flagInfo_.extendConvFlag)); | 235 | + tilingData_.convApiTiling.set_hasScale(static_cast<uint8_t>(flagInfo_.quantFlag || flagInfo_.extendConvFlag)); |
| 235 | - tilingData_.conv2dApiTiling.set_offsetx(attrInfo_.offsetx); | 236 | + tilingData_.convApiTiling.set_offsetx(attrInfo_.offsetx); |
| 236 | - tilingData_.conv2dApiTiling.set_roundMode(attrInfo_.roundMode); | 237 | + tilingData_.convApiTiling.set_roundMode(attrInfo_.roundMode); |
| 237 | - tilingData_.conv2dApiTiling.set_dualOutput(fixpipeInfo_.dualOutput); | 238 | + tilingData_.convApiTiling.set_dualOutput(fixpipeInfo_.dualOutput); |
| 238 | - tilingData_.conv2dApiTiling.set_quantMode0(fixpipeInfo_.quantMode0); | 239 | + tilingData_.convApiTiling.set_quantMode0(fixpipeInfo_.quantMode0); |
| 239 | - tilingData_.conv2dApiTiling.set_reluMode0(fixpipeInfo_.reluMode0); | 240 | + tilingData_.convApiTiling.set_reluMode0(fixpipeInfo_.reluMode0); |
| 240 | - tilingData_.conv2dApiTiling.set_clipMode0(fixpipeInfo_.clipMode0); | 241 | + tilingData_.convApiTiling.set_clipMode0(fixpipeInfo_.clipMode0); |
| 241 | - tilingData_.conv2dApiTiling.set_quantMode1(fixpipeInfo_.quantMode1); | 242 | + tilingData_.convApiTiling.set_quantMode1(fixpipeInfo_.quantMode1); |
| 242 | - tilingData_.conv2dApiTiling.set_reluMode1(fixpipeInfo_.reluMode1); | 243 | + tilingData_.convApiTiling.set_reluMode1(fixpipeInfo_.reluMode1); |
| 243 | - tilingData_.conv2dApiTiling.set_clipMode1(fixpipeInfo_.clipMode1); | 244 | + tilingData_.convApiTiling.set_clipMode1(fixpipeInfo_.clipMode1); |
| 244 | - tilingData_.conv2dApiTiling.set_innerBatch(cachedTilingData_.innerBatch); | 245 | + tilingData_.convApiTiling.set_innerBatch(cachedTilingData_.innerBatch); |
| 246 | + tilingData_.convApiTiling.set_unionDataXt(cachedTilingData_.unionDataXt); | ||
| 245 | } | 247 | } |
| 246 | 248 | ||
| 247 | void Conv2dBaseTiling::TranslateCachedApiTilingPartOne() | 249 | void Conv2dBaseTiling::TranslateCachedApiTilingPartOne() |
| 248 | { | 250 | { |
| 249 | - tilingData_.conv2dApiTiling.set_orgHi(cacheInputArgs_.inputShapeH); | 251 | + tilingData_.convApiTiling.set_orgHi(cacheInputArgs_.inputShapeH); |
| 250 | - tilingData_.conv2dApiTiling.set_orgWi(cacheInputArgs_.inputShapeW); | 252 | + tilingData_.convApiTiling.set_orgWi(cacheInputArgs_.inputShapeW); |
| 251 | - tilingData_.conv2dApiTiling.set_orgHo(cacheInputArgs_.outputShapeH); | 253 | + tilingData_.convApiTiling.set_orgHo(cacheInputArgs_.outputShapeH); |
| 252 | - tilingData_.conv2dApiTiling.set_orgWo(cacheInputArgs_.outputShapeW); | 254 | + tilingData_.convApiTiling.set_orgWo(cacheInputArgs_.outputShapeW); |
| 253 | - tilingData_.conv2dApiTiling.set_singleCoreBatch(cachedTilingData_.singleCoreBatch); | 255 | + tilingData_.convApiTiling.set_singleCoreBatch(cachedTilingData_.singleCoreBatch); |
| 254 | - tilingData_.conv2dApiTiling.set_singleCoreHo(cachedTilingData_.singleCoreHo); | 256 | + tilingData_.convApiTiling.set_singleCoreHo(cachedTilingData_.singleCoreHo); |
| 255 | - tilingData_.conv2dApiTiling.set_singleCoreWo(cachedTilingData_.singleCoreWo); | 257 | + tilingData_.convApiTiling.set_singleCoreWo(cachedTilingData_.singleCoreWo); |
| 256 | - tilingData_.conv2dApiTiling.set_orgCi(shapeInfo_.ci); | 258 | + tilingData_.convApiTiling.set_orgCi(shapeInfo_.ci); |
| 257 | - tilingData_.conv2dApiTiling.set_orgCo(cacheInputArgs_.weightShapeN); | 259 | + tilingData_.convApiTiling.set_orgCo(cacheInputArgs_.weightShapeN); |
| 258 | - tilingData_.conv2dApiTiling.set_singleCoreCi(cachedTilingData_.singleCoreCi); | 260 | + tilingData_.convApiTiling.set_singleCoreCi(cachedTilingData_.singleCoreCi); |
| 259 | - tilingData_.conv2dApiTiling.set_singleCoreCo(cachedTilingData_.singleCoreCo); | 261 | + tilingData_.convApiTiling.set_singleCoreCo(cachedTilingData_.singleCoreCo); |
| 260 | - tilingData_.conv2dApiTiling.set_hoL1(cachedTilingData_.hoL1); | 262 | + tilingData_.convApiTiling.set_hoL1(cachedTilingData_.hoL1); |
| 261 | - tilingData_.conv2dApiTiling.set_woL1(cachedTilingData_.woL1); | 263 | + tilingData_.convApiTiling.set_woL1(cachedTilingData_.woL1); |
| 262 | - tilingData_.conv2dApiTiling.set_kAL1(cachedTilingData_.kAL1); | 264 | + tilingData_.convApiTiling.set_kAL1(cachedTilingData_.kAL1); |
| 263 | - tilingData_.conv2dApiTiling.set_kBL1(cachedTilingData_.kBL1); | 265 | + tilingData_.convApiTiling.set_kBL1(cachedTilingData_.kBL1); |
| 264 | - tilingData_.conv2dApiTiling.set_khL1(cachedTilingData_.khL1); | 266 | + tilingData_.convApiTiling.set_khL1(cachedTilingData_.khL1); |
| 265 | - tilingData_.conv2dApiTiling.set_kwL1(cachedTilingData_.kwL1); | 267 | + tilingData_.convApiTiling.set_kwL1(cachedTilingData_.kwL1); |
| 266 | - tilingData_.conv2dApiTiling.set_nBL1(cachedTilingData_.nBL1); | 268 | + tilingData_.convApiTiling.set_nBL1(cachedTilingData_.nBL1); |
| 267 | - tilingData_.conv2dApiTiling.set_hoL0(cachedTilingData_.hoL0); | 269 | + tilingData_.convApiTiling.set_hoL0(cachedTilingData_.hoL0); |
| 268 | - tilingData_.conv2dApiTiling.set_woL0(cachedTilingData_.woL0); | 270 | + tilingData_.convApiTiling.set_woL0(cachedTilingData_.woL0); |
| 269 | - tilingData_.conv2dApiTiling.set_kL0(cachedTilingData_.kL0); | 271 | + tilingData_.convApiTiling.set_kL0(cachedTilingData_.kL0); |
| 270 | - tilingData_.conv2dApiTiling.set_nL0(cachedTilingData_.nL0); | 272 | + tilingData_.convApiTiling.set_nL0(cachedTilingData_.nL0); |
| 271 | - tilingData_.conv2dApiTiling.set_pBufferFlag(cachedTilingData_.pBufferFlag); | 273 | + tilingData_.convApiTiling.set_pBufferFlag(cachedTilingData_.pBufferFlag); |
| 272 | - tilingData_.conv2dApiTiling.set_groups(cacheInputArgs_.groups); | 274 | + tilingData_.convApiTiling.set_groups(cacheInputArgs_.groups); |
| 273 | - tilingData_.conv2dApiTiling.set_enlarge(cachedTilingData_.enlarge); | 275 | + tilingData_.convApiTiling.set_enlarge(cachedTilingData_.enlarge); |
| 274 | - tilingData_.conv2dApiTiling.set_singleCoreGroups(cachedTilingData_.singleCoreGroups); | 276 | + tilingData_.convApiTiling.set_singleCoreGroups(cachedTilingData_.singleCoreGroups); |
| 275 | - tilingData_.conv2dApiTiling.set_singleCoreGroupOpt(cachedTilingData_.singleCoreGroupOpt); | 277 | + tilingData_.convApiTiling.set_singleCoreGroupOpt(cachedTilingData_.singleCoreGroupOpt); |
| 276 | - tilingData_.conv2dApiTiling.set_bUbNStep(cachedTilingData_.bUbNStep); | 278 | + tilingData_.convApiTiling.set_bUbNStep(cachedTilingData_.bUbNStep); |
| 277 | - tilingData_.conv2dApiTiling.set_bUbKStep(cachedTilingData_.bUbKStep); | 279 | + tilingData_.convApiTiling.set_bUbKStep(cachedTilingData_.bUbKStep); |
| 278 | - tilingData_.conv2dApiTiling.set_khUb(cachedTilingData_.khUb); | 280 | + tilingData_.convApiTiling.set_khUb(cachedTilingData_.khUb); |
| 279 | - tilingData_.conv2dApiTiling.set_kwUb(cachedTilingData_.kwUb); | 281 | + tilingData_.convApiTiling.set_kwUb(cachedTilingData_.kwUb); |
| 280 | - tilingData_.conv2dApiTiling.set_orgHixWi(cachedTilingData_.orgHixWi); | 282 | + tilingData_.convApiTiling.set_orgHixWi(cachedTilingData_.orgHixWi); |
| 281 | - tilingData_.conv2dApiTiling.set_kernelHxkernelW(cachedTilingData_.kernelHxkernelW); | 283 | + tilingData_.convApiTiling.set_kernelHxkernelW(cachedTilingData_.kernelHxkernelW); |
| 282 | - tilingData_.conv2dApiTiling.set_kernelHxkernelWxkernelD(cachedTilingData_.kernelHxkernelWxkernelD); | 284 | + tilingData_.convApiTiling.set_kernelHxkernelWxkernelD(cachedTilingData_.kernelHxkernelWxkernelD); |
| 283 | - tilingData_.conv2dApiTiling.set_aL1SpaceSize(cachedTilingData_.aL1SpaceSize); | 285 | + tilingData_.convApiTiling.set_aL1SpaceSize(cachedTilingData_.aL1SpaceSize); |
| 284 | - tilingData_.conv2dApiTiling.set_multiNBL1(cachedTilingData_.multiNBL1); | 286 | + tilingData_.convApiTiling.set_multiNBL1(cachedTilingData_.multiNBL1); |
| 285 | - tilingData_.conv2dApiTiling.set_cinAInCore(cachedTilingData_.cinAInCore); | 287 | + tilingData_.convApiTiling.set_cinAInCore(cachedTilingData_.cinAInCore); |
| 286 | - tilingData_.conv2dApiTiling.set_cinATailInCore(cachedTilingData_.cinATailInCore); | 288 | + tilingData_.convApiTiling.set_cinATailInCore(cachedTilingData_.cinATailInCore); |
| 287 | - tilingData_.conv2dApiTiling.set_cinBInCore(cachedTilingData_.cinBInCore); | 289 | + tilingData_.convApiTiling.set_cinBInCore(cachedTilingData_.cinBInCore); |
| 288 | - tilingData_.conv2dApiTiling.set_cinBTailInCore(cachedTilingData_.cinBTailInCore); | 290 | + tilingData_.convApiTiling.set_cinBTailInCore(cachedTilingData_.cinBTailInCore); |
| 289 | - tilingData_.conv2dApiTiling.set_mStep(cachedTilingData_.mStep); | 291 | + tilingData_.convApiTiling.set_mStep(cachedTilingData_.mStep); |
| 290 | - tilingData_.conv2dApiTiling.set_kStep(cachedTilingData_.kStep); | 292 | + tilingData_.convApiTiling.set_kStep(cachedTilingData_.kStep); |
| 291 | - tilingData_.conv2dApiTiling.set_nStep(cachedTilingData_.nStep); | 293 | + tilingData_.convApiTiling.set_nStep(cachedTilingData_.nStep); |
| 292 | - tilingData_.conv2dApiTiling.set_fmapKStride(cachedTilingData_.fmapKStride); | 294 | + tilingData_.convApiTiling.set_fmapKStride(cachedTilingData_.fmapKStride); |
| 293 | - tilingData_.conv2dApiTiling.set_weightKStride(cachedTilingData_.weightKStride); | 295 | + tilingData_.convApiTiling.set_weightKStride(cachedTilingData_.weightKStride); |
| 294 | - tilingData_.conv2dApiTiling.set_cinOffsetBlockInGM(cachedTilingData_.cinOffsetBlockInGM); | 296 | + tilingData_.convApiTiling.set_cinOffsetBlockInGM(cachedTilingData_.cinOffsetBlockInGM); |
| 295 | - tilingData_.conv2dApiTiling.set_coutOffsetBlock(cachedTilingData_.coutOffsetBlock); | 297 | + tilingData_.convApiTiling.set_coutOffsetBlock(cachedTilingData_.coutOffsetBlock); |
| 296 | - tilingData_.conv2dApiTiling.set_nL1DivBlockSize(cachedTilingData_.nL1DivBlockSize); | 298 | + tilingData_.convApiTiling.set_nL1DivBlockSize(cachedTilingData_.nL1DivBlockSize); |
| 297 | - tilingData_.conv2dApiTiling.set_kernelH(cacheInputArgs_.weightShapeH); | 299 | + tilingData_.convApiTiling.set_kernelH(cacheInputArgs_.weightShapeH); |
| 298 | - tilingData_.conv2dApiTiling.set_kernelW(cacheInputArgs_.weightShapeW); | 300 | + tilingData_.convApiTiling.set_kernelW(cacheInputArgs_.weightShapeW); |
| 299 | } | 301 | } |
| 300 | 302 | ||
| 301 | void Conv2dBaseTiling::TranslateCachedTilingData() | 303 | void Conv2dBaseTiling::TranslateCachedTilingData() |
| @@ -404,6 +404,7 @@ ge::graphStatus Conv2dBaseTiling::CheckExtendConv2dReluWeightAndClipValue(const | |||
| 404 | if (reluWeightShapeLen == 1) { | 404 | if (reluWeightShapeLen == 1) { |
| 405 | reluMode = static_cast<uint8_t>(ReluMode::SCALARRELU); | 405 | reluMode = static_cast<uint8_t>(ReluMode::SCALARRELU); |
| 406 | } else if (reluWeightShapeLen > 1) { | 406 | } else if (reluWeightShapeLen > 1) { |
| 407 | + fixpipeInfo_.channelWiseCoeff += FLOAT_DTYPE_SIZE_COMPARE_FP16; | ||
| 407 | reluMode = static_cast<uint8_t>(ReluMode::VECTORRELU); | 408 | reluMode = static_cast<uint8_t>(ReluMode::VECTORRELU); |
| 408 | } | 409 | } |
| 409 | 410 | ||
| @@ -243,12 +243,12 @@ ge::graphStatus Conv2dBaseTiling::GetConv2dApiTiling() | |||
| 243 | Conv2dApiTilingSetShape(); | 243 | Conv2dApiTilingSetShape(); |
| 244 | 244 | ||
| 245 | if (flagInfo_.mBasicBlockFlag) { | 245 | if (flagInfo_.mBasicBlockFlag) { |
| 246 | - if (!conv2dApiTiling_.GetTiling(conv2dBasicBlockInfo_, tilingData_.conv2dApiTiling)) { | 246 | + if (!conv2dApiTiling_.GetTiling(conv2dBasicBlockInfo_, tilingData_.convApiTiling)) { |
| 247 | OP_LOGE(context_->GetNodeName(), "%s AscendC: get api tiling wrong", paramInfo_.nodeType.c_str()); | 247 | OP_LOGE(context_->GetNodeName(), "%s AscendC: get api tiling wrong", paramInfo_.nodeType.c_str()); |
| 248 | return ge::GRAPH_FAILED; | 248 | return ge::GRAPH_FAILED; |
| 249 | } | 249 | } |
| 250 | } else { | 250 | } else { |
| 251 | - if (conv2dApiTiling_.GetTiling(tilingData_.conv2dApiTiling) == -1) { | 251 | + if (conv2dApiTiling_.GetTiling(tilingData_.convApiTiling) == -1) { |
| 252 | OP_LOGE(context_->GetNodeName(), "%s AscendC: get api tiling wrong", paramInfo_.nodeType.c_str()); | 252 | OP_LOGE(context_->GetNodeName(), "%s AscendC: get api tiling wrong", paramInfo_.nodeType.c_str()); |
| 253 | return ge::GRAPH_FAILED; | 253 | return ge::GRAPH_FAILED; |
| 254 | } | 254 | } |
| @@ -326,39 +326,39 @@ void Conv2dBaseTiling::Conv2dOpTilingSetAttr() | |||
| 326 | 326 | ||
| 327 | ge::graphStatus Conv2dBaseTiling::GetConv2dOpsTiling() | 327 | ge::graphStatus Conv2dBaseTiling::GetConv2dOpsTiling() |
| 328 | { | 328 | { |
| 329 | - tilingData_.conv2dRunInfo.set_hin(static_cast<uint64_t>(shapeInfo_.hi)); | 329 | + tilingData_.convRunInfo.set_hin(static_cast<uint64_t>(shapeInfo_.hi)); |
| 330 | - tilingData_.conv2dRunInfo.set_win(static_cast<uint64_t>(shapeInfo_.wi)); | 330 | + tilingData_.convRunInfo.set_win(static_cast<uint64_t>(shapeInfo_.wi)); |
| 331 | - tilingData_.conv2dRunInfo.set_hout(static_cast<uint64_t>(shapeInfo_.ho)); | 331 | + tilingData_.convRunInfo.set_hout(static_cast<uint64_t>(shapeInfo_.ho)); |
| 332 | - tilingData_.conv2dRunInfo.set_wout(static_cast<uint64_t>(shapeInfo_.wo)); | 332 | + tilingData_.convRunInfo.set_wout(static_cast<uint64_t>(shapeInfo_.wo)); |
| 333 | - tilingData_.conv2dRunInfo.set_batch(static_cast<uint32_t>(shapeInfo_.batch)); | 333 | + tilingData_.convRunInfo.set_batch(static_cast<uint32_t>(shapeInfo_.batch)); |
| 334 | - tilingData_.conv2dRunInfo.set_cin(static_cast<uint32_t>(shapeInfo_.ci)); | 334 | + tilingData_.convRunInfo.set_cin(static_cast<uint32_t>(shapeInfo_.ci)); |
| 335 | - tilingData_.conv2dRunInfo.set_cout(static_cast<uint32_t>(shapeInfo_.co)); | 335 | + tilingData_.convRunInfo.set_cout(static_cast<uint32_t>(shapeInfo_.co)); |
| 336 | - tilingData_.conv2dRunInfo.set_kh(static_cast<uint32_t>(shapeInfo_.kh)); | 336 | + tilingData_.convRunInfo.set_kh(static_cast<uint32_t>(shapeInfo_.kh)); |
| 337 | - tilingData_.conv2dRunInfo.set_kw(static_cast<uint32_t>(shapeInfo_.kw)); | 337 | + tilingData_.convRunInfo.set_kw(static_cast<uint32_t>(shapeInfo_.kw)); |
| 338 | - tilingData_.conv2dRunInfo.set_strideH(static_cast<uint32_t>(attrInfo_.strideH)); | 338 | + tilingData_.convRunInfo.set_strideH(static_cast<uint32_t>(attrInfo_.strideH)); |
| 339 | - tilingData_.conv2dRunInfo.set_strideW(static_cast<uint32_t>(attrInfo_.strideW)); | 339 | + tilingData_.convRunInfo.set_strideW(static_cast<uint32_t>(attrInfo_.strideW)); |
| 340 | - tilingData_.conv2dRunInfo.set_dilationH(static_cast<uint32_t>(attrInfo_.dilationH)); | 340 | + tilingData_.convRunInfo.set_dilationH(static_cast<uint32_t>(attrInfo_.dilationH)); |
| 341 | - tilingData_.conv2dRunInfo.set_dilationW(static_cast<uint32_t>(attrInfo_.dilationW)); | 341 | + tilingData_.convRunInfo.set_dilationW(static_cast<uint32_t>(attrInfo_.dilationW)); |
| 342 | - tilingData_.conv2dRunInfo.set_padTop(static_cast<uint32_t>(attrInfo_.padTop)); | 342 | + tilingData_.convRunInfo.set_padTop(static_cast<uint32_t>(attrInfo_.padTop)); |
| 343 | - tilingData_.conv2dRunInfo.set_padLeft(static_cast<uint32_t>(attrInfo_.padLeft)); | 343 | + tilingData_.convRunInfo.set_padLeft(static_cast<uint32_t>(attrInfo_.padLeft)); |
| 344 | - tilingData_.conv2dRunInfo.set_hasBias(static_cast<uint8_t>(flagInfo_.hasBias)); | 344 | + tilingData_.convRunInfo.set_hasBias(static_cast<uint8_t>(flagInfo_.hasBias)); |
| 345 | - tilingData_.conv2dRunInfo.set_batchDim(static_cast<uint32_t>(numBlocksRes.batchDim)); | 345 | + tilingData_.convRunInfo.set_batchDim(static_cast<uint32_t>(numBlocksRes.batchDim)); |
| 346 | - tilingData_.conv2dRunInfo.set_nDim(static_cast<uint32_t>(numBlocksRes.nDim)); | 346 | + tilingData_.convRunInfo.set_nDim(static_cast<uint32_t>(numBlocksRes.nDim)); |
| 347 | - tilingData_.conv2dRunInfo.set_groupDim(static_cast<uint32_t>(numBlocksRes.groupDim)); | 347 | + tilingData_.convRunInfo.set_groupDim(static_cast<uint32_t>(numBlocksRes.groupDim)); |
| 348 | - tilingData_.conv2dRunInfo.set_groups(static_cast<uint32_t>(attrInfo_.groups)); | 348 | + tilingData_.convRunInfo.set_groups(static_cast<uint32_t>(attrInfo_.groups)); |
| 349 | if (flagInfo_.convGroupType == ConvGroupType::OPT_GROUP_CONV) { | 349 | if (flagInfo_.convGroupType == ConvGroupType::OPT_GROUP_CONV) { |
| 350 | - tilingData_.conv2dRunInfo.set_cinOpt(static_cast<uint32_t>(optGroupInfo_.cinOpt)); | 350 | + tilingData_.convRunInfo.set_cinOpt(static_cast<uint32_t>(optGroupInfo_.cinOpt)); |
| 351 | - tilingData_.conv2dRunInfo.set_coutOpt(static_cast<uint32_t>(optGroupInfo_.coutOpt)); | 351 | + tilingData_.convRunInfo.set_coutOpt(static_cast<uint32_t>(optGroupInfo_.coutOpt)); |
| 352 | - tilingData_.conv2dRunInfo.set_groupOpt(static_cast<uint32_t>(optGroupInfo_.groupOpt)); | 352 | + tilingData_.convRunInfo.set_groupOpt(static_cast<uint32_t>(optGroupInfo_.groupOpt)); |
| 353 | - tilingData_.conv2dRunInfo.set_enlarge(static_cast<uint32_t>(optGroupInfo_.enlarge)); | 353 | + tilingData_.convRunInfo.set_enlarge(static_cast<uint32_t>(optGroupInfo_.enlarge)); |
| 354 | } | 354 | } |
| 355 | 355 | ||
| 356 | if (flagInfo_.mSplitModeFlag) { | 356 | if (flagInfo_.mSplitModeFlag) { |
| 357 | - tilingData_.conv2dRunInfo.set_hoDim(static_cast<uint32_t>(numBlocksRes.mDim)); | 357 | + tilingData_.convRunInfo.set_hoDim(static_cast<uint32_t>(numBlocksRes.mDim)); |
| 358 | - tilingData_.conv2dRunInfo.set_woDim(static_cast<uint32_t>(1)); | 358 | + tilingData_.convRunInfo.set_woDim(static_cast<uint32_t>(1)); |
| 359 | } else { | 359 | } else { |
| 360 | - tilingData_.conv2dRunInfo.set_hoDim(static_cast<uint32_t>(numBlocksRes.hoDim)); | 360 | + tilingData_.convRunInfo.set_hoDim(static_cast<uint32_t>(numBlocksRes.hoDim)); |
| 361 | - tilingData_.conv2dRunInfo.set_woDim(static_cast<uint32_t>(numBlocksRes.woDim)); | 361 | + tilingData_.convRunInfo.set_woDim(static_cast<uint32_t>(numBlocksRes.woDim)); |
| 362 | } | 362 | } |
| 363 | return ge::GRAPH_SUCCESS; | 363 | return ge::GRAPH_SUCCESS; |
| 364 | } | 364 | } |
| @@ -23,26 +23,26 @@ void Conv2dBaseTiling::PrintOpTilingData() | |||
| 23 | do not modify the param name if not necessarily | 23 | do not modify the param name if not necessarily |
| 24 | */ | 24 | */ |
| 25 | std::stringstream ss; | 25 | std::stringstream ss; |
| 26 | - ss << "hin: " << tilingData_.conv2dRunInfo.get_hin() << ", win: " << tilingData_.conv2dRunInfo.get_win() | 26 | + ss << "hin: " << tilingData_.convRunInfo.get_hin() << ", win: " << tilingData_.convRunInfo.get_win() |
| 27 | - << ", hout: " << tilingData_.conv2dRunInfo.get_hout() << ", wout: " << tilingData_.conv2dRunInfo.get_wout() | 27 | + << ", hout: " << tilingData_.convRunInfo.get_hout() << ", wout: " << tilingData_.convRunInfo.get_wout() |
| 28 | - << ", batch: " << tilingData_.conv2dRunInfo.get_batch() << ", cin: " << tilingData_.conv2dRunInfo.get_cin() | 28 | + << ", batch: " << tilingData_.convRunInfo.get_batch() << ", cin: " << tilingData_.convRunInfo.get_cin() |
| 29 | - << ", cout: " << tilingData_.conv2dRunInfo.get_cout() << ", kh: " << tilingData_.conv2dRunInfo.get_kh() | 29 | + << ", cout: " << tilingData_.convRunInfo.get_cout() << ", kh: " << tilingData_.convRunInfo.get_kh() |
| 30 | - << ", kw: " << tilingData_.conv2dRunInfo.get_kw() << ", batchDim: " << tilingData_.conv2dRunInfo.get_batchDim() | 30 | + << ", kw: " << tilingData_.convRunInfo.get_kw() << ", batchDim: " << tilingData_.convRunInfo.get_batchDim() |
| 31 | - << ", hoDim: " << tilingData_.conv2dRunInfo.get_hoDim() << ", woDim: " << tilingData_.conv2dRunInfo.get_woDim() | 31 | + << ", hoDim: " << tilingData_.convRunInfo.get_hoDim() << ", woDim: " << tilingData_.convRunInfo.get_woDim() |
| 32 | - << ", nDim: " << tilingData_.conv2dRunInfo.get_nDim() | 32 | + << ", nDim: " << tilingData_.convRunInfo.get_nDim() |
| 33 | - << ", strideH: " << tilingData_.conv2dRunInfo.get_strideH() | 33 | + << ", strideH: " << tilingData_.convRunInfo.get_strideH() |
| 34 | - << ", strideW: " << tilingData_.conv2dRunInfo.get_strideW() | 34 | + << ", strideW: " << tilingData_.convRunInfo.get_strideW() |
| 35 | - << ", dilationH: " << tilingData_.conv2dRunInfo.get_dilationH() | 35 | + << ", dilationH: " << tilingData_.convRunInfo.get_dilationH() |
| 36 | - << ", dilationW: " << tilingData_.conv2dRunInfo.get_dilationW() | 36 | + << ", dilationW: " << tilingData_.convRunInfo.get_dilationW() |
| 37 | - << ", padTop: " << tilingData_.conv2dRunInfo.get_padTop() | 37 | + << ", padTop: " << tilingData_.convRunInfo.get_padTop() |
| 38 | - << ", padLeft: " << tilingData_.conv2dRunInfo.get_padLeft() | 38 | + << ", padLeft: " << tilingData_.convRunInfo.get_padLeft() |
| 39 | - << ", groups: " << tilingData_.conv2dRunInfo.get_groups() | 39 | + << ", groups: " << tilingData_.convRunInfo.get_groups() |
| 40 | - << ", cinOpt: " << tilingData_.conv2dRunInfo.get_cinOpt() | 40 | + << ", cinOpt: " << tilingData_.convRunInfo.get_cinOpt() |
| 41 | - << ", coutOpt: " << tilingData_.conv2dRunInfo.get_coutOpt() | 41 | + << ", coutOpt: " << tilingData_.convRunInfo.get_coutOpt() |
| 42 | - << ", groupOpt: " << tilingData_.conv2dRunInfo.get_groupOpt() | 42 | + << ", groupOpt: " << tilingData_.convRunInfo.get_groupOpt() |
| 43 | - << ", enlarge: " << tilingData_.conv2dRunInfo.get_enlarge() | 43 | + << ", enlarge: " << tilingData_.convRunInfo.get_enlarge() |
| 44 | - << ", groupDim: " << tilingData_.conv2dRunInfo.get_groupDim() | 44 | + << ", groupDim: " << tilingData_.convRunInfo.get_groupDim() |
| 45 | - << ", hasBias: " << static_cast<uint32_t>(tilingData_.conv2dRunInfo.get_hasBias()); | 45 | + << ", hasBias: " << static_cast<uint32_t>(tilingData_.convRunInfo.get_hasBias()); |
| 46 | OP_LOGD(context_->GetNodeName(), "%s AscendC: ops tilingdata: %s", paramInfo_.nodeType.c_str(), ss.str().c_str()); | 46 | OP_LOGD(context_->GetNodeName(), "%s AscendC: ops tilingdata: %s", paramInfo_.nodeType.c_str(), ss.str().c_str()); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| @@ -73,54 +73,54 @@ void Conv2dBaseTiling::PrintTilingInfo() const | |||
| 73 | 73 | ||
| 74 | void Conv2dBaseTiling::PrintLibApiTilingDataPartOne(std::stringstream &ss) | 74 | void Conv2dBaseTiling::PrintLibApiTilingDataPartOne(std::stringstream &ss) |
| 75 | { | 75 | { |
| 76 | - ss << "singleCoreHo: " << tilingData_.conv2dApiTiling.get_singleCoreHo() | 76 | + ss << "singleCoreHo: " << tilingData_.convApiTiling.get_singleCoreHo() |
| 77 | - << ", singleCoreWo: " << tilingData_.conv2dApiTiling.get_singleCoreWo() | 77 | + << ", singleCoreWo: " << tilingData_.convApiTiling.get_singleCoreWo() |
| 78 | - << ", singleCoreBatch: " << tilingData_.conv2dApiTiling.get_singleCoreBatch() | 78 | + << ", singleCoreBatch: " << tilingData_.convApiTiling.get_singleCoreBatch() |
| 79 | - << ", orgHi: " << tilingData_.conv2dApiTiling.get_orgHi() | 79 | + << ", orgHi: " << tilingData_.convApiTiling.get_orgHi() |
| 80 | - << ", orgWi: " << tilingData_.conv2dApiTiling.get_orgWi() | 80 | + << ", orgWi: " << tilingData_.convApiTiling.get_orgWi() |
| 81 | - << ", orgHo: " << tilingData_.conv2dApiTiling.get_orgHo() | 81 | + << ", orgHo: " << tilingData_.convApiTiling.get_orgHo() |
| 82 | - << ", orgWo: " << tilingData_.conv2dApiTiling.get_orgWo() | 82 | + << ", orgWo: " << tilingData_.convApiTiling.get_orgWo() |
| 83 | - << ", groups: " << tilingData_.conv2dApiTiling.get_groups() | 83 | + << ", groups: " << tilingData_.convApiTiling.get_groups() |
| 84 | - << ", orgCi: " << tilingData_.conv2dApiTiling.get_orgCi() | 84 | + << ", orgCi: " << tilingData_.convApiTiling.get_orgCi() |
| 85 | - << ", orgCo: " << tilingData_.conv2dApiTiling.get_orgCo() | 85 | + << ", orgCo: " << tilingData_.convApiTiling.get_orgCo() |
| 86 | - << ", kernelH: " << tilingData_.conv2dApiTiling.get_kernelH() | 86 | + << ", kernelH: " << tilingData_.convApiTiling.get_kernelH() |
| 87 | - << ", kernelW: " << tilingData_.conv2dApiTiling.get_kernelW() | 87 | + << ", kernelW: " << tilingData_.convApiTiling.get_kernelW() |
| 88 | - << ", singleCoreCi: " << tilingData_.conv2dApiTiling.get_singleCoreCi() | 88 | + << ", singleCoreCi: " << tilingData_.convApiTiling.get_singleCoreCi() |
| 89 | - << ", singleCoreCo: " << tilingData_.conv2dApiTiling.get_singleCoreCo() | 89 | + << ", singleCoreCo: " << tilingData_.convApiTiling.get_singleCoreCo() |
| 90 | - << ", hoL1: " << tilingData_.conv2dApiTiling.get_hoL1() | 90 | + << ", hoL1: " << tilingData_.convApiTiling.get_hoL1() |
| 91 | - << ", woL1: " << tilingData_.conv2dApiTiling.get_woL1() | 91 | + << ", woL1: " << tilingData_.convApiTiling.get_woL1() |
| 92 | - << ", kAL1: " << tilingData_.conv2dApiTiling.get_kAL1() | 92 | + << ", kAL1: " << tilingData_.convApiTiling.get_kAL1() |
| 93 | - << ", kBL1: " << tilingData_.conv2dApiTiling.get_kBL1() | 93 | + << ", kBL1: " << tilingData_.convApiTiling.get_kBL1() |
| 94 | - << ", nBL1: " << tilingData_.conv2dApiTiling.get_nBL1() | 94 | + << ", nBL1: " << tilingData_.convApiTiling.get_nBL1() |
| 95 | - << ", hoL0: " << tilingData_.conv2dApiTiling.get_hoL0() | 95 | + << ", hoL0: " << tilingData_.convApiTiling.get_hoL0() |
| 96 | - << ", woL0: " << tilingData_.conv2dApiTiling.get_woL0() | 96 | + << ", woL0: " << tilingData_.convApiTiling.get_woL0() |
| 97 | - << ", kL0: " << tilingData_.conv2dApiTiling.get_kL0() | 97 | + << ", kL0: " << tilingData_.convApiTiling.get_kL0() |
| 98 | - << ", nL0: " << tilingData_.conv2dApiTiling.get_nL0() | 98 | + << ", nL0: " << tilingData_.convApiTiling.get_nL0() |
| 99 | - << ", pBufferFlag: " << tilingData_.conv2dApiTiling.get_pBufferFlag() | 99 | + << ", pBufferFlag: " << tilingData_.convApiTiling.get_pBufferFlag() |
| 100 | - << ", multiNBL1: " << tilingData_.conv2dApiTiling.get_multiNBL1() | 100 | + << ", multiNBL1: " << tilingData_.convApiTiling.get_multiNBL1() |
| 101 | - << ", strideH: " << tilingData_.conv2dApiTiling.get_strideH() | 101 | + << ", strideH: " << tilingData_.convApiTiling.get_strideH() |
| 102 | - << ", strideW: " << tilingData_.conv2dApiTiling.get_strideW() | 102 | + << ", strideW: " << tilingData_.convApiTiling.get_strideW() |
| 103 | - << ", dilationH: " << tilingData_.conv2dApiTiling.get_dilationH() | 103 | + << ", dilationH: " << tilingData_.convApiTiling.get_dilationH() |
| 104 | - << ", dilationW: " << tilingData_.conv2dApiTiling.get_dilationW() | 104 | + << ", dilationW: " << tilingData_.convApiTiling.get_dilationW() |
| 105 | - << ", padTop: " << tilingData_.conv2dApiTiling.get_padTop() | 105 | + << ", padTop: " << tilingData_.convApiTiling.get_padTop() |
| 106 | - << ", padBottom: " << tilingData_.conv2dApiTiling.get_padBottom() | 106 | + << ", padBottom: " << tilingData_.convApiTiling.get_padBottom() |
| 107 | - << ", padLeft: " << tilingData_.conv2dApiTiling.get_padLeft() | 107 | + << ", padLeft: " << tilingData_.convApiTiling.get_padLeft() |
| 108 | - << ", padRight: " << tilingData_.conv2dApiTiling.get_padRight() | 108 | + << ", padRight: " << tilingData_.convApiTiling.get_padRight() |
| 109 | - << ", aL1SpaceSize: " << tilingData_.conv2dApiTiling.get_aL1SpaceSize() | 109 | + << ", aL1SpaceSize: " << tilingData_.convApiTiling.get_aL1SpaceSize() |
| 110 | - << ", singleCoreGroups: " << tilingData_.conv2dApiTiling.get_singleCoreGroups() | 110 | + << ", singleCoreGroups: " << tilingData_.convApiTiling.get_singleCoreGroups() |
| 111 | - << ", singleCoreGroupOpt: " << tilingData_.conv2dApiTiling.get_singleCoreGroupOpt() | 111 | + << ", singleCoreGroupOpt: " << tilingData_.convApiTiling.get_singleCoreGroupOpt() |
| 112 | - << ", enlarge: " << tilingData_.conv2dApiTiling.get_enlarge() | 112 | + << ", enlarge: " << tilingData_.convApiTiling.get_enlarge() |
| 113 | - << ", bUbNStep: " << tilingData_.conv2dApiTiling.get_bUbNStep() | 113 | + << ", bUbNStep: " << tilingData_.convApiTiling.get_bUbNStep() |
| 114 | - << ", iterateMNOrder: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_iterateMNOrder()) | 114 | + << ", iterateMNOrder: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_iterateMNOrder()) |
| 115 | - << ", biasFullLoadFlag: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_biasFullLoadFlag()) | 115 | + << ", biasFullLoadFlag: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_biasFullLoadFlag()) |
| 116 | - << ", fixpParamsFullLoadFlag: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_fixpParamsFullLoadFlag()) | 116 | + << ", fixpParamsFullLoadFlag: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_fixpParamsFullLoadFlag()) |
| 117 | - << ", hf32Enable: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_hf32Enable()) | 117 | + << ", hf32Enable: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_hf32Enable()) |
| 118 | - << ", hf32TransMode: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_hf32TransMode()) | 118 | + << ", hf32TransMode: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_hf32TransMode()) |
| 119 | - << ", hasBias: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_hasBias()) | 119 | + << ", hasBias: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_hasBias()) |
| 120 | - << ", hasScale: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_hasScale()) | 120 | + << ", hasScale: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_hasScale()) |
| 121 | - << ", offsetx: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_offsetx()) | 121 | + << ", offsetx: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_offsetx()) |
| 122 | - << ", roundMode: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_roundMode()) | 122 | + << ", roundMode: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_roundMode()) |
| 123 | - << ", innerBatch: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_innerBatch()); | 123 | + << ", innerBatch: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_innerBatch()); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | 126 | ||
| @@ -133,33 +133,34 @@ void Conv2dBaseTiling::PrintLibApiTilingData() | |||
| 133 | std::stringstream ss; | 133 | std::stringstream ss; |
| 134 | PrintLibApiTilingDataPartOne(ss); | 134 | PrintLibApiTilingDataPartOne(ss); |
| 135 | std::stringstream ssPartTwo; | 135 | std::stringstream ssPartTwo; |
| 136 | - ssPartTwo << "bUbKStep: " << tilingData_.conv2dApiTiling.get_bUbKStep() | 136 | + ssPartTwo << "bUbKStep: " << tilingData_.convApiTiling.get_bUbKStep() |
| 137 | - << ", orgHixWi: " << tilingData_.conv2dApiTiling.get_orgHixWi() | 137 | + << ", orgHixWi: " << tilingData_.convApiTiling.get_orgHixWi() |
| 138 | - << ", kernelHxkernelW: " << tilingData_.conv2dApiTiling.get_kernelHxkernelW() | 138 | + << ", kernelHxkernelW: " << tilingData_.convApiTiling.get_kernelHxkernelW() |
| 139 | - << ", kernelHxkernelWxkernelD: " << tilingData_.conv2dApiTiling.get_kernelHxkernelWxkernelD() | 139 | + << ", kernelHxkernelWxkernelD: " << tilingData_.convApiTiling.get_kernelHxkernelWxkernelD() |
| 140 | - << ", cinAInCore: " << tilingData_.conv2dApiTiling.get_cinAInCore() | 140 | + << ", cinAInCore: " << tilingData_.convApiTiling.get_cinAInCore() |
| 141 | - << ", cinATailInCore: " << tilingData_.conv2dApiTiling.get_cinATailInCore() | 141 | + << ", cinATailInCore: " << tilingData_.convApiTiling.get_cinATailInCore() |
| 142 | - << ", cinBInCore: " << tilingData_.conv2dApiTiling.get_cinBInCore() | 142 | + << ", cinBInCore: " << tilingData_.convApiTiling.get_cinBInCore() |
| 143 | - << ", cinBTailInCore: " << tilingData_.conv2dApiTiling.get_cinBTailInCore() | 143 | + << ", cinBTailInCore: " << tilingData_.convApiTiling.get_cinBTailInCore() |
| 144 | - << ", mStep: " << tilingData_.conv2dApiTiling.get_mStep() | 144 | + << ", mStep: " << tilingData_.convApiTiling.get_mStep() |
| 145 | - << ", kStep: " << tilingData_.conv2dApiTiling.get_kStep() | 145 | + << ", kStep: " << tilingData_.convApiTiling.get_kStep() |
| 146 | - << ", nStep: " << tilingData_.conv2dApiTiling.get_nStep() | 146 | + << ", nStep: " << tilingData_.convApiTiling.get_nStep() |
| 147 | - << ", fmapKStride: " << tilingData_.conv2dApiTiling.get_fmapKStride() | 147 | + << ", fmapKStride: " << tilingData_.convApiTiling.get_fmapKStride() |
| 148 | - << ", weightKStride: " << tilingData_.conv2dApiTiling.get_weightKStride() | 148 | + << ", weightKStride: " << tilingData_.convApiTiling.get_weightKStride() |
| 149 | - << ", cinOffsetBlockInGM: " << tilingData_.conv2dApiTiling.get_cinOffsetBlockInGM() | 149 | + << ", cinOffsetBlockInGM: " << tilingData_.convApiTiling.get_cinOffsetBlockInGM() |
| 150 | - << ", coutOffsetBlock: " << tilingData_.conv2dApiTiling.get_coutOffsetBlock() | 150 | + << ", coutOffsetBlock: " << tilingData_.convApiTiling.get_coutOffsetBlock() |
| 151 | - << ", nL1DivBlockSize: " << tilingData_.conv2dApiTiling.get_nL1DivBlockSize() | 151 | + << ", nL1DivBlockSize: " << tilingData_.convApiTiling.get_nL1DivBlockSize() |
| 152 | - << ", dualOutput: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_dualOutput()) | 152 | + << ", dualOutput: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_dualOutput()) |
| 153 | - << ", quantMode0: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_quantMode0()) | 153 | + << ", quantMode0: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_quantMode0()) |
| 154 | - << ", reluMode0: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_reluMode0()) | 154 | + << ", reluMode0: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_reluMode0()) |
| 155 | - << ", clipMode0: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_clipMode0()) | 155 | + << ", clipMode0: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_clipMode0()) |
| 156 | - << ", quantMode1: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_quantMode1()) | 156 | + << ", quantMode1: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_quantMode1()) |
| 157 | - << ", reluMode1: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_reluMode1()) | 157 | + << ", reluMode1: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_reluMode1()) |
| 158 | - << ", clipMode1: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_clipMode1()) | 158 | + << ", clipMode1: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_clipMode1()) |
| 159 | - << ", khL1: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_khL1()) | 159 | + << ", khL1: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_khL1()) |
| 160 | - << ", kwL1: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_kwL1()) | 160 | + << ", kwL1: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_kwL1()) |
| 161 | - << ", khUb: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_khUb()) | 161 | + << ", khUb: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_khUb()) |
| 162 | - << ", kwUb: " << static_cast<uint32_t>(tilingData_.conv2dApiTiling.get_kwUb()); | 162 | + << ", kwUb: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_kwUb()) |
| 163 | + << ", unionDataXt: " << static_cast<uint32_t>(tilingData_.convApiTiling.get_unionDataXt()); | ||
| 163 | OP_LOGD(context_->GetNodeName(), "%s AscendC: api tilingdata: %s", paramInfo_.nodeType.c_str(), ss.str().c_str()); | 164 | OP_LOGD(context_->GetNodeName(), "%s AscendC: api tilingdata: %s", paramInfo_.nodeType.c_str(), ss.str().c_str()); |
| 164 | OP_LOGD(context_->GetNodeName(), "%s", ssPartTwo.str().c_str()); | 165 | OP_LOGD(context_->GetNodeName(), "%s", ssPartTwo.str().c_str()); |
| 165 | } | 166 | } |