已合并
ASC基础API(规约计算/转置/矩阵)添加合法检查 #1467
zhangyike创建于 4月7日
ASC基础API(规约计算/转置/矩阵)添加合法检查 #1467
已合并
共 13 个文件变更+1605-131
| @@ -480,21 +480,27 @@ template <typename T> | |||
| 480 | __aicore__ inline void LoadData3DV1L12L0ACal(__ca__ T* dst, __cbuf__ T* src, | 480 | __aicore__ inline void LoadData3DV1L12L0ACal(__ca__ T* dst, __cbuf__ T* src, |
| 481 | const LoadData3DParamsV1<T>& loadDataParams) | 481 | const LoadData3DParamsV1<T>& loadDataParams) |
| 482 | { | 482 | { |
| 483 | - ASCENDC_REPORT_NOT_SUPPORT(false, "LoadData with LoadData3DParamsV1 from A1 to A2"); | 483 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 484 | + ReportNotSupport(false, "LoadData with LoadData3DParamsV1 from A1 to A2"); | ||
| 485 | + | ||
| 484 | } | 486 | } |
| 485 | 487 | ||
| 486 | template <typename T> | 488 | template <typename T> |
| 487 | __aicore__ inline void LoadData3DV1L12L0BCal(__cb__ T* dst, __cbuf__ T* src, | 489 | __aicore__ inline void LoadData3DV1L12L0BCal(__cb__ T* dst, __cbuf__ T* src, |
| 488 | const LoadData3DParamsV1<T>& loadDataParams) | 490 | const LoadData3DParamsV1<T>& loadDataParams) |
| 489 | { | 491 | { |
| 490 | - ASCENDC_REPORT_NOT_SUPPORT(false, "LoadData with LoadData3DParamsV1 from B1 to B2"); | 492 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 493 | + ReportNotSupport(false, "LoadData with LoadData3DParamsV1 from B1 to B2"); | ||
| 494 | + | ||
| 491 | } | 495 | } |
| 492 | 496 | ||
| 493 | template <typename T> | 497 | template <typename T> |
| 494 | __aicore__ inline void LoadData3DV1L12UBCal(__ubuf__ T* dst, __cbuf__ T* src, | 498 | __aicore__ inline void LoadData3DV1L12UBCal(__ubuf__ T* dst, __cbuf__ T* src, |
| 495 | const LoadData3DParamsV1<T>& loadDataParams) | 499 | const LoadData3DParamsV1<T>& loadDataParams) |
| 496 | { | 500 | { |
| 497 | - ASCENDC_REPORT_NOT_SUPPORT(false, "LoadData with LoadData3DParamsV1 from L1 to UB"); | 501 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 502 | + ReportNotSupport(false, "LoadData with LoadData3DParamsV1 from L1 to UB"); | ||
| 503 | + | ||
| 498 | } | 504 | } |
| 499 | 505 | ||
| 500 | /* ************************************************************************************************** | 506 | /* ************************************************************************************************** |
| @@ -504,21 +510,27 @@ template <typename T> | |||
| 504 | __aicore__ inline void LoadData3DV2L12UBCal(__ubuf__ T* dst, __cbuf__ T* src, | 510 | __aicore__ inline void LoadData3DV2L12UBCal(__ubuf__ T* dst, __cbuf__ T* src, |
| 505 | const LoadData3DParamsV2<T>& loadDataParams) | 511 | const LoadData3DParamsV2<T>& loadDataParams) |
| 506 | { | 512 | { |
| 507 | - ASCENDC_REPORT_NOT_SUPPORT(false, "LoadData with LoadData3DParamsV2 from L1 to UB"); | 513 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 514 | + ReportNotSupport(false, "LoadData with LoadData3DParamsV2 from L1 to UB"); | ||
| 515 | + | ||
| 508 | } | 516 | } |
| 509 | 517 | ||
| 510 | template <> | 518 | template <> |
| 511 | __aicore__ inline void LoadData3DV2L12L0BCal(__cb__ int8_t* dst, __cbuf__ int8_t* src, | 519 | __aicore__ inline void LoadData3DV2L12L0BCal(__cb__ int8_t* dst, __cbuf__ int8_t* src, |
| 512 | const LoadData3DParamsV2<int8_t>& loadDataParams) | 520 | const LoadData3DParamsV2<int8_t>& loadDataParams) |
| 513 | { | 521 | { |
| 514 | - ASCENDC_REPORT_NOT_SUPPORT(false, "LoadData with LoadData3DParamsV2 from B1 to B2 with type int8_t"); | 522 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 523 | + ReportNotSupport(false, "LoadData with LoadData3DParamsV2 from B1 to B2 with type int8_t"); | ||
| 524 | + | ||
| 515 | } | 525 | } |
| 516 | 526 | ||
| 517 | template <> | 527 | template <> |
| 518 | __aicore__ inline void LoadData3DV2L12L0BCal(__cb__ uint8_t* dst, __cbuf__ uint8_t* src, | 528 | __aicore__ inline void LoadData3DV2L12L0BCal(__cb__ uint8_t* dst, __cbuf__ uint8_t* src, |
| 519 | const LoadData3DParamsV2<uint8_t>& loadDataParams) | 529 | const LoadData3DParamsV2<uint8_t>& loadDataParams) |
| 520 | { | 530 | { |
| 521 | - ASCENDC_REPORT_NOT_SUPPORT(false, "LoadData with LoadData3DParamsV2 from B1 to B2 with type uint8_t"); | 531 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 532 | + ReportNotSupport(false, "LoadData with LoadData3DParamsV2 from B1 to B2 with type uint8_t"); | ||
| 533 | + | ||
| 522 | } | 534 | } |
| 523 | 535 | ||
| 524 | /* ************************************************************************************************** | 536 | /* ************************************************************************************************** |
| @@ -835,7 +835,7 @@ __aicore__ inline void ReduceTailCompute(const LocalTensor<T>& dst, const LocalT | |||
| 835 | struct ReduceRepeatParams tailParams(tailCount, 1, DEFAULT_REDUCE_DST_REP_STRIDE, DEFAULT_BLK_STRIDE, | 835 | struct ReduceRepeatParams tailParams(tailCount, 1, DEFAULT_REDUCE_DST_REP_STRIDE, DEFAULT_BLK_STRIDE, |
| 836 | DEFAULT_REPEAT_STRIDE); | 836 | DEFAULT_REPEAT_STRIDE); |
| 837 | 837 | ||
| 838 | - ReduceImpl<PrimT<T>>((__ubuf__ PrimT<T>*)dst.GetPhyAddr(), // 复用dst | 838 | + ReduceImpl<PrimT<T>>((__ubuf__ PrimT<T>*)dst.GetPhyAddr(), // reuse dst |
| 839 | (__ubuf__ PrimT<T>*)src.GetPhyAddr(elementNumPerRep * repeatTime), (__ubuf__ PrimT<T>*)sharedTmpBuffer.GetPhyAddr(), | 839 | (__ubuf__ PrimT<T>*)src.GetPhyAddr(elementNumPerRep * repeatTime), (__ubuf__ PrimT<T>*)sharedTmpBuffer.GetPhyAddr(), |
| 840 | tailParams, calIndex, mode); | 840 | tailParams, calIndex, mode); |
| 841 | eventIdVToS = static_cast<event_t>(GetTPipePtr()->FetchEventID(HardEvent::V_S)); | 841 | eventIdVToS = static_cast<event_t>(GetTPipePtr()->FetchEventID(HardEvent::V_S)); |
| @@ -226,9 +226,9 @@ template <typename T> | |||
| 226 | __aicore__ inline void TransDataTo5HDImpl(__ubuf__ T* dstList[16], __ubuf__ T* srcList[16], | 226 | __aicore__ inline void TransDataTo5HDImpl(__ubuf__ T* dstList[16], __ubuf__ T* srcList[16], |
| 227 | const TransDataTo5HDParams& transDataTo5HDParams) | 227 | const TransDataTo5HDParams& transDataTo5HDParams) |
| 228 | { | 228 | { |
| 229 | - ASCENDC_ASSERT((SupportType<T, int8_t, uint8_t, int16_t, uint16_t, half, float, int32_t, uint32_t>()), | 229 | + ASCENDC_DEBUG_ASSERT((SupportType<T, int8_t, uint8_t, int16_t, uint16_t, half, float, int32_t, uint32_t>()), |
| 230 | - {KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in TransDataTo5HD, current api support dtype combination is " | 230 | + KERNEL_LOG_INTERNAL(KERNEL_ERROR, "Failed to check dtype in TransDataTo5HD, current api support dtype combination is " |
| 231 | - "src and dst both: int8_t, uint8_t, int16_t, uint16_t, half, float, int32_t, uint32_t");}); | 231 | + "src and dst both: int8_t, uint8_t, int16_t, uint16_t, half, float, int32_t, uint32_t")); |
| 232 | if ASCEND_IS_AIV { | 232 | if ASCEND_IS_AIV { |
| 233 | SetVaReg(dstList, srcList); | 233 | SetVaReg(dstList, srcList); |
| 234 | TransDataTo5HDIntrinsicsImpl(dstList, srcList, transDataTo5HDParams); | 234 | TransDataTo5HDIntrinsicsImpl(dstList, srcList, transDataTo5HDParams); |
| @@ -239,9 +239,9 @@ template <typename T> | |||
| 239 | __aicore__ inline void TransDataTo5HDImpl(uint64_t dstList[NCHW_CONV_ADDR_LIST_SIZE], | 239 | __aicore__ inline void TransDataTo5HDImpl(uint64_t dstList[NCHW_CONV_ADDR_LIST_SIZE], |
| 240 | uint64_t srcList[NCHW_CONV_ADDR_LIST_SIZE], const TransDataTo5HDParams& transDataTo5HDParams) | 240 | uint64_t srcList[NCHW_CONV_ADDR_LIST_SIZE], const TransDataTo5HDParams& transDataTo5HDParams) |
| 241 | { | 241 | { |
| 242 | - ASCENDC_ASSERT((SupportType<T, int8_t, uint8_t, int16_t, uint16_t, half, float, int32_t, uint32_t>()), | 242 | + ASCENDC_DEBUG_ASSERT((SupportType<T, int8_t, uint8_t, int16_t, uint16_t, half, float, int32_t, uint32_t>()), |
| 243 | - {KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in TransDataTo5HD, current api support dtype combination is " | 243 | + KERNEL_LOG_INTERNAL(KERNEL_ERROR, "Failed to check dtype in TransDataTo5HD, current api support dtype combination is " |
| 244 | - "src and dst both: int8_t, uint8_t, int16_t, uint16_t, half, float, int32_t, uint32_t");}); | 244 | + "src and dst both: int8_t, uint8_t, int16_t, uint16_t, half, float, int32_t, uint32_t")); |
| 245 | if ASCEND_IS_AIV { | 245 | if ASCEND_IS_AIV { |
| 246 | SetVaReg(dstList, srcList); | 246 | SetVaReg(dstList, srcList); |
| 247 | TransDataTo5HDIntrinsicsImpl<T>(dstList, srcList, transDataTo5HDParams); | 247 | TransDataTo5HDIntrinsicsImpl<T>(dstList, srcList, transDataTo5HDParams); |
| @@ -252,9 +252,9 @@ template <typename T> | |||
| 252 | __aicore__ inline void TransDataTo5HDVldVaRegImpl( | 252 | __aicore__ inline void TransDataTo5HDVldVaRegImpl( |
| 253 | __ubuf__ uint64_t* dst, __ubuf__ uint64_t* src, const TransDataTo5HDParams& transDataTo5HDParams) | 253 | __ubuf__ uint64_t* dst, __ubuf__ uint64_t* src, const TransDataTo5HDParams& transDataTo5HDParams) |
| 254 | { | 254 | { |
| 255 | - ASCENDC_ASSERT((SupportType<T, int8_t, uint8_t, int16_t, uint16_t, half, float, int32_t, uint32_t>()), | 255 | + ASCENDC_DEBUG_ASSERT((SupportType<T, int8_t, uint8_t, int16_t, uint16_t, half, float, int32_t, uint32_t>()), |
| 256 | - {KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in TransDataTo5HD, current api support dtype combination is " | 256 | + KERNEL_LOG_INTERNAL(KERNEL_ERROR, "Failed to check dtype in TransDataTo5HD, current api support dtype combination is " |
| 257 | - "src and dst both: int8_t, uint8_t, int16_t, uint16_t, half, float, int32_t, uint32_t");}); | 257 | + "src and dst both: int8_t, uint8_t, int16_t, uint16_t, half, float, int32_t, uint32_t")); |
| 258 | if ASCEND_IS_AIV { | 258 | if ASCEND_IS_AIV { |
| 259 | VldVaReg(dst, src); | 259 | VldVaReg(dst, src); |
| 260 | uint64_t dstList[NCHW_CONV_ADDR_LIST_SIZE] = { 0 }; | 260 | uint64_t dstList[NCHW_CONV_ADDR_LIST_SIZE] = { 0 }; |
| @@ -111,6 +111,19 @@ __aicore__ inline void CheckTensorAlignment(const LocalTensor<T>& inputTensor, u | |||
| 111 | tensorName, apiName, alignBytes, static_cast<unsigned long long>(tensorAddr))); | 111 | tensorName, apiName, alignBytes, static_cast<unsigned long long>(tensorAddr))); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | +__aicore__ inline void CheckAddrAlignment(uint64_t addr, Hardware phyPos, uint32_t alignBytes, | ||
| 115 | + const __gm__ char* addrName, const __gm__ char* apiName) | ||
| 116 | +{ | ||
| 117 | + uint64_t checkAddr = addr; | ||
| 118 | + | ||
| 119 | + checkAddr = addr - reinterpret_cast<uint64_t>( | ||
| 120 | + ConstDefiner::Instance().hardwareCpuBufferMap.at(phyPos)); | ||
| 121 | + | ||
| 122 | + ASCENDC_DEBUG_ASSERT((checkAddr % alignBytes == 0), KERNEL_LOG_INTERNAL(KERNEL_ERROR, "Failed to check %s " | ||
| 123 | + "address alignment in %s, its address must align with %u bytes, current address is %llu.\n", | ||
| 124 | + addrName, apiName, alignBytes, static_cast<unsigned long long>(checkAddr))); | ||
| 125 | +} | ||
C | |||
| 126 | + | ||
| 114 | template <typename T> | 127 | template <typename T> |
| 115 | __aicore__ inline void CheckValueRange(T value, T valueLow, T valueHigh, const __gm__ char* paramName, | 128 | __aicore__ inline void CheckValueRange(T value, T valueLow, T valueHigh, const __gm__ char* paramName, |
| 116 | const __gm__ char* apiName) | 129 | const __gm__ char* apiName) |
| @@ -21,6 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | + | ||
| 24 | 25 | ||
| 25 | 26 | ||
| 26 | 27 | ||
| @@ -514,15 +515,17 @@ template <typename T = int32_t, typename U = int8_t, | |||
| 514 | __aicore__ inline void MmadSpImpl(const LocalTensor<T>& dst, const LocalTensor<U>& fm, | 515 | __aicore__ inline void MmadSpImpl(const LocalTensor<T>& dst, const LocalTensor<U>& fm, |
| 515 | const LocalTensor<U>& filter, const MmadParams& mmadParams) | 516 | const LocalTensor<U>& filter, const MmadParams& mmadParams) |
| 516 | { | 517 | { |
| 517 | - CheckTensorPos<T>(dst, Hardware::L0C, "dst", "CO1", "MmadWithSparse"); | 518 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 518 | - CheckTensorPos<U>(fm, Hardware::L0A, "fm", "A2", "MmadWithSparse"); | 519 | + CheckTensorPhyPosition<Hardware::L0C>(dst, "dst", "CO1", "MmadWithSparse"); |
| 519 | - CheckTensorPos<U>(filter, Hardware::L0B, "filter", "B2", "MmadWithSparse"); | 520 | + CheckTensorPhyPosition<Hardware::L0A>(fm, "fm", "A2", "MmadWithSparse"); |
| 520 | - CheckTensorAlign<T>(dst, 1024, "dst", "MmadWithSparse"); // 1024B aligned | 521 | + CheckTensorPhyPosition<Hardware::L0B>(filter, "filter", "B2", "MmadWithSparse"); |
| 521 | - CheckTensorAlign<U>(fm, VALUE_512, "fm", "MmadWithSparse"); // 512B aligned | 522 | + CheckTensorAlignment(dst, 1024, "dst", "MmadWithSparse"); // 1024B aligned |
| 522 | - CheckTensorAlign<U>(filter, VALUE_512, "filter", "MmadWithSparse"); // 512B aligned | 523 | + CheckTensorAlignment(fm, VALUE_512, "fm", "MmadWithSparse"); // 512B aligned |
| 523 | - ASCENDC_CHECK_VALUE_RANGE(mmadParams.m, 0, UINT12_MAX, "m", "MmadWithSparse"); | 524 | + CheckTensorAlignment(filter, VALUE_512, "filter", "MmadWithSparse"); // 512B aligned |
| 524 | - ASCENDC_CHECK_VALUE_RANGE(mmadParams.n, 0, UINT12_MAX, "n", "MmadWithSparse"); | 525 | + CheckValueRange<uint16_t>(mmadParams.m, 0, UINT12_MAX, "m", "MmadWithSparse"); |
| 525 | - ASCENDC_CHECK_VALUE_RANGE(mmadParams.k, 0, UINT12_MAX, "k", "MmadWithSparse"); | 526 | + CheckValueRange<uint16_t>(mmadParams.n, 0, UINT12_MAX, "n", "MmadWithSparse"); |
| 527 | + CheckValueRange<uint16_t>(mmadParams.k, 0, UINT12_MAX, "k", "MmadWithSparse"); | ||
| 528 | + | ||
| 526 | MmadSpCal((__cc__ int32_t*)dst.GetPhyAddr(), (__ca__ int8_t*)fm.GetPhyAddr(), | 529 | MmadSpCal((__cc__ int32_t*)dst.GetPhyAddr(), (__ca__ int8_t*)fm.GetPhyAddr(), |
| 527 | (__cb__ int8_t*)filter.GetPhyAddr(), mmadParams); | 530 | (__cb__ int8_t*)filter.GetPhyAddr(), mmadParams); |
| 528 | } | 531 | } |
| @@ -533,12 +536,14 @@ template <typename T = int8_t, typename U = uint8_t, | |||
| 533 | __aicore__ inline void LoadDataWithSparseImpl(const LocalTensor<T> &dst, const LocalTensor<T> &src, | 536 | __aicore__ inline void LoadDataWithSparseImpl(const LocalTensor<T> &dst, const LocalTensor<T> &src, |
| 534 | const LocalTensor<U> &idx, const LoadData2dParams &loadDataParam) | 537 | const LocalTensor<U> &idx, const LoadData2dParams &loadDataParam) |
| 535 | { | 538 | { |
| 536 | - CheckTensorPos<T>(dst, Hardware::L0B, "dst", "B2", "LoadDataWithSparse"); | 539 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 537 | - CheckTensorPos<T>(src, Hardware::L1, "src", "B1", "LoadDataWithSparse"); | 540 | + CheckTensorPhyPosition<Hardware::L0B>(dst, "dst", "B2", "LoadDataWithSparse"); |
| 538 | - CheckTensorPos<U>(idx, Hardware::L1, "idx", "B1", "LoadDataWithSparse"); | 541 | + CheckTensorPhyPosition<Hardware::L1>(src, "src", "B1", "LoadDataWithSparse"); |
| 539 | - CheckTensorAlign<T>(dst, VALUE_512, "dst", "LoadDataWithSparse"); // 512B align | 542 | + CheckTensorPhyPosition<Hardware::L1>(idx, "idx", "B1", "LoadDataWithSparse"); |
| 540 | - CheckTensorAlign<T>(src, ONE_BLK_SIZE, "src", "LoadDataWithSparse"); // 32B align | 543 | + CheckTensorAlignment(dst, VALUE_512, "dst", "LoadDataWithSparse"); // 512B align |
| 541 | - CheckTensorAlign<U>(idx, ONE_BLK_SIZE, "idx", "LoadDataWithSparse"); // 32B align | 544 | + CheckTensorAlignment(src, ONE_BLK_SIZE, "src", "LoadDataWithSparse"); // 32B align |
| 545 | + CheckTensorAlignment(idx, ONE_BLK_SIZE, "idx", "LoadDataWithSparse"); // 32B align | ||
| 546 | + | ||
| 542 | LoadDataWithSparseCal(dst, src, idx, loadDataParam); | 547 | LoadDataWithSparseCal(dst, src, idx, loadDataParam); |
| 543 | } | 548 | } |
| 544 | 549 | ||
| @@ -326,14 +326,68 @@ __aicore__ static inline void CheckLoadDataWithTranspose(const LocalTensor<T>& d | |||
| 326 | __aicore__ static inline void CheckLoadData3dParams(const uint16_t srcHeight, const uint16_t srcWidth, | 326 | __aicore__ static inline void CheckLoadData3dParams(const uint16_t srcHeight, const uint16_t srcWidth, |
| 327 | const uint8_t srcWStride, const uint8_t srcHStride) | 327 | const uint8_t srcWStride, const uint8_t srcHStride) |
| 328 | { | 328 | { |
| 329 | - ASCENDC_CHECK_VALUE_RANGE(srcHeight, MIN_LOAD3D_L1, MAX_LOAD3D_L1, "l1H", "LoadData with LoadData3DParams"); | 329 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 330 | - ASCENDC_CHECK_VALUE_RANGE(srcWidth, MIN_LOAD3D_L1, MAX_LOAD3D_L1, "l1W", "LoadData with LoadData3DParams"); | 330 | + CheckValueRange<uint16_t>(srcHeight, MIN_LOAD3D_L1, MAX_LOAD3D_L1, "l1H", "LoadData with LoadData3DParams"); |
| 331 | - ASCENDC_CHECK_VALUE_RANGE(srcWStride, MIN_LOAD3D_STRIDE, MAX_LOAD3D_STRIDE, "strideW", | 331 | + CheckValueRange<uint16_t>(srcWidth, MIN_LOAD3D_L1, MAX_LOAD3D_L1, "l1W", "LoadData with LoadData3DParams"); |
| 332 | - "LoadData with LoadData3DParams"); | 332 | + CheckValueRange<uint8_t>(srcWStride, static_cast<uint8_t>(MIN_LOAD3D_STRIDE), |
| 333 | - ASCENDC_CHECK_VALUE_RANGE(srcHStride, MIN_LOAD3D_STRIDE, MAX_LOAD3D_STRIDE, "strideH", | 333 | + static_cast<uint8_t>(MAX_LOAD3D_STRIDE), "strideW", "LoadData with LoadData3DParams"); |
| 334 | - "LoadData with LoadData3DParams"); | 334 | + CheckValueRange<uint8_t>(srcHStride, static_cast<uint8_t>(MIN_LOAD3D_STRIDE), |
| 335 | + static_cast<uint8_t>(MAX_LOAD3D_STRIDE), "strideH", "LoadData with LoadData3DParams"); | ||
| 336 | + | ||
| 335 | } | 337 | } |
| 336 | 338 | ||
| 339 | + | ||
| 340 | +template <typename U> | ||
| 341 | +__aicore__ inline void CheckLoadData3dv1Params(const LoadData3DParamsV1<U>& loadDataParams) | ||
| 342 | +{ | ||
| 343 | + CheckValueRange<uint16_t>(loadDataParams.c1Index, static_cast<uint16_t>(MIN_LOAD3D_C1_IDX), | ||
| 344 | + static_cast<uint16_t>(MAX_LOAD3D_C1_IDX), "c1Index", "LoadData with LoadData3DParamsV1"); | ||
| 345 | + CheckValueRange<uint8_t>(loadDataParams.fetchFilterW, static_cast<uint8_t>(MIN_LOAD3D_FETCH_FILTER), | ||
| 346 | + static_cast<uint8_t>(MAX_LOAD3D_FETCH_FILTER), "fetchFilterW", "LoadData with LoadData3DParamsV1"); | ||
| 347 | + CheckValueRange<uint8_t>(loadDataParams.fetchFilterH, static_cast<uint8_t>(MIN_LOAD3D_FETCH_FILTER), | ||
| 348 | + static_cast<uint8_t>(MAX_LOAD3D_FETCH_FILTER), "fetchFilterH", "LoadData with LoadData3DParamsV1"); | ||
| 349 | + CheckValueRange<int16_t>(loadDataParams.leftTopW, static_cast<int16_t>(MIN_LOAD3D_LEFT_TOP), | ||
| 350 | + static_cast<int16_t>(MAX_LOAD3D_LEFT_TOP), "leftTopW", "LoadData with LoadData3DParamsV1"); | ||
| 351 | + CheckValueRange<int16_t>(loadDataParams.leftTopH, static_cast<int16_t>(MIN_LOAD3D_LEFT_TOP), | ||
| 352 | + static_cast<int16_t>(MAX_LOAD3D_LEFT_TOP), "leftTopH", "LoadData with LoadData3DParamsV1"); | ||
| 353 | + CheckValueRange<uint8_t>(loadDataParams.filterW, static_cast<uint8_t>(MIN_LOAD3D_FILTER), | ||
| 354 | + static_cast<uint8_t>(MAX_LOAD3D_FILTER), "filterW", "LoadData with LoadData3DParamsV1"); | ||
| 355 | + CheckValueRange<uint8_t>(loadDataParams.filterH, static_cast<uint8_t>(MIN_LOAD3D_FILTER), | ||
| 356 | + static_cast<uint8_t>(MAX_LOAD3D_FILTER), "filterH", "LoadData with LoadData3DParamsV1"); | ||
| 357 | + CheckValueRange<uint8_t>(loadDataParams.dilationFilterW, static_cast<uint8_t>(MIN_LOAD3D_DILATION_FILTER), | ||
| 358 | + static_cast<uint8_t>(MAX_LOAD3D_FILTER), "dilationFilterW", "LoadData with LoadData3DParamsV1"); | ||
| 359 | + CheckValueRange<uint8_t>(loadDataParams.dilationFilterH, static_cast<uint8_t>(MIN_LOAD3D_DILATION_FILTER), | ||
| 360 | + static_cast<uint8_t>(MAX_LOAD3D_FILTER), "dilationFilterH", "LoadData with LoadData3DParamsV1"); | ||
| 361 | + CheckValueRange<uint8_t>(loadDataParams.jumpStride, static_cast<uint8_t>(MIN_LOAD3D_JUMP_STRIDE), | ||
| 362 | + static_cast<uint8_t>(MAX_LOAD3D_JUMP_STRIDE), "jumpStride", "LoadData with LoadData3DParamsV1"); | ||
| 363 | + CheckValueRange<uint8_t>(loadDataParams.repeatMode, 0, 1, "repeatMode", "LoadData with LoadData3DParamsV1"); | ||
| 364 | + CheckValueRange<uint8_t>(loadDataParams.cSize, 0, 1, "cSize", "LoadData with LoadData3DParamsV1"); | ||
| 365 | + CheckValueRange<uint8_t>(loadDataParams.repeatTime, static_cast<uint8_t>(MIN_LOAD3D_REPEAT_TIMES), | ||
| 366 | + static_cast<uint8_t>(MAX_LOAD3D_FILTER), "repeatTime", "LoadData with LoadData3DParamsV1"); | ||
| 367 | +} | ||
| 368 | + | ||
| 369 | +template <typename U> | ||
| 370 | +__aicore__ inline void CheckLoadData3dv2Params(const LoadData3DParamsV2<U>& loadDataParams) | ||
| 371 | +{ | ||
| 372 | + CheckValueRange<uint16_t>(loadDataParams.kExtension, static_cast<uint16_t>(MIN_LOAD3D_EXTENSION), | ||
| 373 | + static_cast<uint16_t>(MAX_LOAD3D_EXTENSION), "kExtension", "LoadData with LoadData3DParamsV2"); | ||
| 374 | + CheckValueRange<uint16_t>(loadDataParams.mExtension, static_cast<uint16_t>(MIN_LOAD3D_EXTENSION), | ||
| 375 | + static_cast<uint16_t>(MAX_LOAD3D_EXTENSION), "mExtension", "LoadData with LoadData3DParamsV2"); | ||
| 376 | + CheckValueRange<uint16_t>(loadDataParams.kStartPt, static_cast<uint16_t>(MIN_LOAD3D_START_PT), | ||
| 377 | + static_cast<uint16_t>(MAX_LOAD3D_START_PT), "kStartPt", "LoadData with LoadData3DParamsV2"); | ||
| 378 | + CheckValueRange<uint16_t>(loadDataParams.mStartPt, static_cast<uint16_t>(MIN_LOAD3D_START_PT), | ||
| 379 | + static_cast<uint16_t>(MAX_LOAD3D_START_PT), "mStartPt", "LoadData with LoadData3DParamsV2"); | ||
| 380 | + CheckValueRange<uint8_t>(loadDataParams.filterW, static_cast<uint8_t>(MIN_LOAD3D_FILTER), | ||
| 381 | + static_cast<uint8_t>(MAX_LOAD3D_FILTER), "filterW", "LoadData with LoadData3DParamsV2"); | ||
| 382 | + CheckValueRange<uint8_t>(loadDataParams.filterH, static_cast<uint8_t>(MIN_LOAD3D_FILTER), | ||
| 383 | + static_cast<uint8_t>(MAX_LOAD3D_FILTER), "filterH", "LoadData with LoadData3DParamsV2"); | ||
| 384 | + CheckValueRange<uint8_t>(loadDataParams.dilationFilterW, static_cast<uint8_t>(MIN_LOAD3D_DILATION_FILTER), | ||
| 385 | + static_cast<uint8_t>(MAX_LOAD3D_FILTER), "dilationFilterW", "LoadData with LoadData3DParamsV2"); | ||
| 386 | + CheckValueRange<uint8_t>(loadDataParams.dilationFilterH, static_cast<uint8_t>(MIN_LOAD3D_DILATION_FILTER), | ||
| 387 | + static_cast<uint8_t>(MAX_LOAD3D_FILTER), "dilationFilterH", "LoadData with LoadData3DParamsV2"); | ||
| 388 | +} | ||
| 389 | + | ||
| 390 | + | ||
| 337 | // check Load3dv2 ChannelSize | 391 | // check Load3dv2 ChannelSize |
| 338 | template <typename T> | 392 | template <typename T> |
| 339 | __aicore__ static inline void CheckLoadData3dv2ChannelSize(const uint16_t channelSize) | 393 | __aicore__ static inline void CheckLoadData3dv2ChannelSize(const uint16_t channelSize) |
| @@ -23,10 +23,12 @@ | |||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | + | ||
| 26 | 27 | ||
| 27 | 28 | ||
| 28 | 29 | ||
| 29 | namespace AscendC { | 30 | namespace AscendC { |
| 31 | + | ||
| 30 | /* ************************************************************************************************** | 32 | /* ************************************************************************************************** |
| 31 | * LoadData 2d * | 33 | * LoadData 2d * |
| 32 | * ************************************************************************************************* */ | 34 | * ************************************************************************************************* */ |
| @@ -157,21 +159,18 @@ template <typename T, const IsResetLoad3dConfig &defaultConfig, | |||
| 157 | __aicore__ inline void LoadData(const LocalTensor<T>& dst, const LocalTensor<T>& src, | 159 | __aicore__ inline void LoadData(const LocalTensor<T>& dst, const LocalTensor<T>& src, |
| 158 | const LoadData3DParamsV1<U>& loadDataParams) | 160 | const LoadData3DParamsV1<U>& loadDataParams) |
| 159 | { | 161 | { |
| 162 | + | ||
| 163 | + CheckTensorPhyPosition<Hardware::L1>(src, "src", "A1 / B1", "LoadData with LoadData3DParamsV1"); | ||
| 164 | + CheckTensorAlignment(src, ONE_BLK_SIZE, "src", "LoadData with LoadData3DParamsV1"); | ||
| 165 | + const Hardware dstScope = GetPhyType((TPosition)dst.GetPosition()); | ||
| 166 | + if (dstScope == Hardware::L0A || dstScope == Hardware::L0B) { | ||
| 167 | + CheckTensorAlignment(dst, VALUE_512, "dst", "LoadData with LoadData3DParamsV1"); | ||
| 168 | + } else if (dstScope == Hardware::UB) { | ||
| 169 | + CheckTensorAlignment(dst, ONE_BLK_SIZE, "dst", "LoadData with LoadData3DParamsV1"); | ||
| 170 | + } | ||
| 171 | + CheckLoadData3dv1Params<U>(loadDataParams); | ||
| 160 | CheckLoadData3dParams(loadDataParams.l1H, loadDataParams.l1W, loadDataParams.strideW, loadDataParams.strideH); | 172 | CheckLoadData3dParams(loadDataParams.l1H, loadDataParams.l1W, loadDataParams.strideW, loadDataParams.strideH); |
| 161 | - ASCENDC_CHECK_VALUE_RANGE(loadDataParams.c1Index, MIN_LOAD3D_C1_IDX, MAX_LOAD3D_C1_IDX, "c1Index", | 173 | +#endif |
| 162 | - "LoadData with LoadData3DParamsV1"); | ||
| 163 | - ASCENDC_CHECK_VALUE_RANGE(loadDataParams.fetchFilterW, MIN_LOAD3D_FETCH_FILTER, MAX_LOAD3D_FETCH_FILTER, | ||
| 164 | - "fetchFilterW", "LoadData with LoadData3DParamsV1"); | ||
| 165 | - ASCENDC_CHECK_VALUE_RANGE(loadDataParams.fetchFilterH, MIN_LOAD3D_FETCH_FILTER, MAX_LOAD3D_FETCH_FILTER, | ||
| 166 | - "fetchFilterH", "LoadData with LoadData3DParamsV1"); | ||
| 167 | - ASCENDC_CHECK_VALUE_RANGE(loadDataParams.leftTopW, MIN_LOAD3D_LEFT_TOP, MAX_LOAD3D_LEFT_TOP, "leftTopW", | ||
| 168 | - "LoadData with LoadData3DParamsV1"); | ||
| 169 | - ASCENDC_CHECK_VALUE_RANGE(loadDataParams.leftTopH, MIN_LOAD3D_LEFT_TOP, MAX_LOAD3D_LEFT_TOP, "leftTopH", | ||
| 170 | - "LoadData with LoadData3DParamsV1"); | ||
| 171 | - ASCENDC_CHECK_VALUE_RANGE(loadDataParams.jumpStride, MIN_LOAD3D_JUMP_STRIDE, MAX_LOAD3D_JUMP_STRIDE, "jumpStride", | ||
| 172 | - "LoadData with LoadData3DParamsV1"); | ||
| 173 | - ASCENDC_CHECK_VALUE_RANGE(loadDataParams.repeatMode, 0, 1, "repeatMode", "LoadData with LoadData3DParamsV1"); | ||
| 174 | - ASCENDC_CHECK_VALUE_RANGE(loadDataParams.cSize, 0, 1, "cSize", "LoadData with LoadData3DParamsV1"); | ||
| 175 | LoadDataImpl<T, defaultConfig>(dst, src, loadDataParams); | 174 | LoadDataImpl<T, defaultConfig>(dst, src, loadDataParams); |
| 176 | } | 175 | } |
| 177 | 176 | ||
| @@ -207,7 +206,16 @@ template <typename T, const IsResetLoad3dConfig &defaultConfig, | |||
| 207 | __aicore__ inline void LoadData(const LocalTensor<T>& dst, const LocalTensor<T>& src, | 206 | __aicore__ inline void LoadData(const LocalTensor<T>& dst, const LocalTensor<T>& src, |
| 208 | const LoadData3DParamsV2<U>& loadDataParams) | 207 | const LoadData3DParamsV2<U>& loadDataParams) |
| 209 | { | 208 | { |
| 210 | -#if ASCENDC_CPU_DEBUG | 209 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 210 | + CheckTensorPhyPosition<Hardware::L1>(src, "src", "A1 / B1", "LoadData with LoadData3DParamsV2"); | ||
| 211 | + CheckTensorAlignment(src, ONE_BLK_SIZE, "src", "LoadData with LoadData3DParamsV2"); | ||
| 212 | + const Hardware dstScope = GetPhyType((TPosition)dst.GetPosition()); | ||
| 213 | + if (dstScope == Hardware::L0A || dstScope == Hardware::L0B) { | ||
| 214 | + CheckTensorAlignment(dst, VALUE_512, "dst", "LoadData with LoadData3DParamsV2"); | ||
| 215 | + } else if (dstScope == Hardware::UB) { | ||
| 216 | + CheckTensorAlignment(dst, ONE_BLK_SIZE, "dst", "LoadData with LoadData3DParamsV2"); | ||
| 217 | + } | ||
| 218 | + CheckLoadData3dv2Params<U>(loadDataParams); | ||
| 211 | CheckLoadData3dv2ChannelSize<T>(loadDataParams.channelSize); | 219 | CheckLoadData3dv2ChannelSize<T>(loadDataParams.channelSize); |
C 这些CPU部分的是不是冗余了?可以删掉,上述类似 ![]() ![]() | |||
| 212 | CheckLoadData3dParams(loadDataParams.l1H, loadDataParams.l1W, loadDataParams.strideW, loadDataParams.strideH); | 220 | CheckLoadData3dParams(loadDataParams.l1H, loadDataParams.l1W, loadDataParams.strideW, loadDataParams.strideH); |
| 213 | CheckLoadData3dv2MatrixParams<T>(loadDataParams.kExtension, loadDataParams.mExtension, loadDataParams.kStartPt, | 221 | CheckLoadData3dv2MatrixParams<T>(loadDataParams.kExtension, loadDataParams.mExtension, loadDataParams.kStartPt, |
| @@ -43,8 +43,60 @@ | |||
| 43 | 43 | ||
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | + | ||
| 46 | 47 | ||
| 47 | namespace AscendC { | 48 | namespace AscendC { |
| 49 | + | ||
| 50 | +// Reduce base checks: dtype, repeatTime, position, src alignment | ||
| 51 | +// Shared by BlockReduce and WholeReduce (both maskCount and maskBit overloads) | ||
| 52 | +template <typename T> | ||
| 53 | +__aicore__ inline void CheckReduceBaseParams(const LocalTensor<T>& dst, const LocalTensor<T>& src, | ||
| 54 | + const int32_t repeatTime, const __gm__ char* apiName) | ||
| 55 | +{ | ||
| 56 | + using PrimType = PrimT<T>; | ||
| 57 | + ASCENDC_DEBUG_ASSERT((SupportType<PrimType, half, float>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, | ||
| 58 | + "Failed to check dtype in %s, current api support dtype combination is " | ||
| 59 | + "src and dst both: half / float.\n", apiName)); | ||
| 60 | + CheckValueRange<int32_t>(repeatTime, 0, 255, "repeatTime", apiName); | ||
| 61 | + CheckTensorPhyPosition<Hardware::UB>(dst, "dst", "VECIN / VECCALC / VECOUT", apiName); | ||
| 62 | + CheckTensorPhyPosition<Hardware::UB>(src, "src", "VECIN / VECCALC / VECOUT", apiName); | ||
| 63 | + CheckTensorAlignment(src, ONE_BLK_SIZE, "src", apiName); | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +// BlockReduce common checks: dtype, repeatTime, position, alignment | ||
| 67 | +// Used by: BlockReduceSum/Max/Min (both maskCount and maskBit overloads) | ||
| 68 | +template <typename T> | ||
| 69 | +__aicore__ inline void CheckBlockReduceParams(const LocalTensor<T>& dst, const LocalTensor<T>& src, | ||
| 70 | + const int32_t repeatTime, const __gm__ char* apiName) | ||
| 71 | +{ | ||
| 72 | + CheckReduceBaseParams<T>(dst, src, repeatTime, apiName); | ||
| 73 | + using PrimType = PrimT<T>; | ||
| 74 | + CheckTensorAlignment(dst, 8 * sizeof(PrimType), "dst", apiName); // half: 16B, float: 32B | ||
| 75 | +} | ||
| 76 | + | ||
| 77 | +// WholeReduce common checks: dtype, repeatTime, position, alignment (with order) | ||
| 78 | +// Used by: WholeReduceMax/Min (both maskCount and maskBit overloads) | ||
| 79 | +template <typename T> | ||
| 80 | +__aicore__ inline void CheckWholeReduceCommonParams(const LocalTensor<T>& dst, const LocalTensor<T>& src, | ||
| 81 | + const int32_t repeatTime, ReduceOrder order, const __gm__ char* apiName) | ||
| 82 | +{ | ||
| 83 | + CheckReduceBaseParams<T>(dst, src, repeatTime, apiName); | ||
| 84 | + CheckValueRange<int>(static_cast<int>(order), 0, 3, "order", apiName); | ||
| 85 | + using PrimType = PrimT<T>; | ||
| 86 | + CheckTensorAlignment(dst, 2 * sizeof(PrimType), "dst", apiName); // half: 4B, float: 8B | ||
| 87 | +} | ||
| 88 | + | ||
| 89 | +// WholeReduce common checks: dtype, repeatTime, position, alignment (without order) | ||
| 90 | +// Used by: WholeReduceSum (both maskCount and maskBit overloads) | ||
| 91 | +template <typename T> | ||
| 92 | +__aicore__ inline void CheckWholeReduceCommonParams(const LocalTensor<T>& dst, const LocalTensor<T>& src, | ||
| 93 | + const int32_t repeatTime, const __gm__ char* apiName) | ||
| 94 | +{ | ||
| 95 | + CheckReduceBaseParams<T>(dst, src, repeatTime, apiName); | ||
| 96 | + using PrimType = PrimT<T>; | ||
| 97 | + CheckTensorAlignment(dst, sizeof(PrimType), "dst", apiName); // half: 2B, float: 4B | ||
| 98 | +} | ||
| 99 | + | ||
| 48 | 100 | ||
| 49 | /* *************** BlockReduceMax /BlockReduceMin /BlockReduceSum PairReduceSum ********************* */ | 101 | /* *************** BlockReduceMax /BlockReduceMin /BlockReduceSum PairReduceSum ********************* */ |
| 50 | /* | 102 | /* |
| @@ -67,13 +119,16 @@ __aicore__ inline void BlockReduceSum(const LocalTensor<T>& dst, const LocalTens | |||
| 67 | MstxTensor::GetMstxVecReduceBlkInfo(dst, src, mask, repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "BlockReduceSum"); | 119 | MstxTensor::GetMstxVecReduceBlkInfo(dst, src, mask, repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "BlockReduceSum"); |
| 68 | 120 | ||
| 69 | using PrimType = PrimT<T>; | 121 | using PrimType = PrimT<T>; |
| 70 | - ASCENDC_ASSERT((SupportType<PrimType, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 122 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 71 | - "BlockReduceSum, current api support dtype combination is src and dst both: half / float");}); | 123 | + ASCENDC_DEBUG_ASSERT((SupportType<PrimType, half, float>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, |
| 72 | - ASCENDC_CHECK_VALUE_RANGE(repeatTime, 0, 255, "repeatTime", "BlockReduceSum"); | 124 | + "Failed to check dtype in BlockReduceSum, current api support dtype combination is " |
| 125 | + "src and dst both: half / float.\n")); | ||
| 126 | + CheckBlockReduceParams<T>(dst, src, repeatTime, "BlockReduceSum"); | ||
| 127 | + CheckMaskValue<PrimType, isSetMask>(mask, "BlockReduceSum"); | ||
| 128 | + | ||
| 73 | 129 | ||
| 74 | MaskSetter::Instance().SetMask(isSetMask); | 130 | MaskSetter::Instance().SetMask(isSetMask); |
| 75 | - if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, | 131 | + if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, "BlockReduceSum")) { |
| 76 | - "BlockReduceSum")) { | ||
| 77 | ASCENDC_REPORT_CHECK_ERROR("BlockReduceSum", KernelFuncType::MASK_COUNT_MODE); | 132 | ASCENDC_REPORT_CHECK_ERROR("BlockReduceSum", KernelFuncType::MASK_COUNT_MODE); |
| 78 | } | 133 | } |
| 79 | 134 | ||
| @@ -101,13 +156,16 @@ __aicore__ inline void BlockReduceMax(const LocalTensor<T>& dst, const LocalTens | |||
| 101 | MstxTensor::GetMstxVecReduceBlkInfo(dst, src, mask, repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "BlockReduceMax"); | 156 | MstxTensor::GetMstxVecReduceBlkInfo(dst, src, mask, repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "BlockReduceMax"); |
| 102 | 157 | ||
| 103 | using PrimType = PrimT<T>; | 158 | using PrimType = PrimT<T>; |
| 104 | - ASCENDC_ASSERT((SupportType<PrimType, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 159 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 105 | - "BlockReduceMax, current api support dtype combination is src and dst both: half / float");}); | 160 | + ASCENDC_DEBUG_ASSERT((SupportType<PrimType, half, float>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, |
| 106 | - ASCENDC_CHECK_VALUE_RANGE(repeatTime, 0, 255, "repeatTime", "BlockReduceMax"); | 161 | + "Failed to check dtype in BlockReduceMax, current api support dtype combination is " |
| 162 | + "src and dst both: half / float.\n")); | ||
| 163 | + CheckBlockReduceParams<T>(dst, src, repeatTime, "BlockReduceMax"); | ||
| 164 | + CheckMaskValue<PrimType, isSetMask>(mask, "BlockReduceMax"); | ||
| 165 | + | ||
| 107 | 166 | ||
| 108 | MaskSetter::Instance().SetMask(isSetMask); | 167 | MaskSetter::Instance().SetMask(isSetMask); |
| 109 | - if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, | 168 | + if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, "BlockReduceMax")) { |
| 110 | - "BlockReduceMax")) { | ||
| 111 | ASCENDC_REPORT_CHECK_ERROR("BlockReduceMax", KernelFuncType::MASK_COUNT_MODE); | 169 | ASCENDC_REPORT_CHECK_ERROR("BlockReduceMax", KernelFuncType::MASK_COUNT_MODE); |
| 112 | } | 170 | } |
| 113 | 171 | ||
| @@ -135,13 +193,16 @@ __aicore__ inline void BlockReduceMin(const LocalTensor<T>& dst, const LocalTens | |||
| 135 | MstxTensor::GetMstxVecReduceBlkInfo(dst, src, mask, repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "BlockReduceMin"); | 193 | MstxTensor::GetMstxVecReduceBlkInfo(dst, src, mask, repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "BlockReduceMin"); |
| 136 | 194 | ||
| 137 | using PrimType = PrimT<T>; | 195 | using PrimType = PrimT<T>; |
| 138 | - ASCENDC_ASSERT((SupportType<PrimType, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 196 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 139 | - "BlockReduceMin, current api support dtype combination is src and dst both: half / float");}); | 197 | + ASCENDC_DEBUG_ASSERT((SupportType<PrimType, half, float>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, |
| 140 | - ASCENDC_CHECK_VALUE_RANGE(repeatTime, 0, 255, "repeatTime", "BlockReduceMin"); | 198 | + "Failed to check dtype in BlockReduceMin, current api support dtype combination is " |
| 199 | + "src and dst both: half / float.\n")); | ||
| 200 | + CheckBlockReduceParams<T>(dst, src, repeatTime, "BlockReduceMin"); | ||
| 201 | + CheckMaskValue<PrimType, isSetMask>(mask, "BlockReduceMin"); | ||
| 202 | + | ||
| 141 | 203 | ||
| 142 | MaskSetter::Instance().SetMask(isSetMask); | 204 | MaskSetter::Instance().SetMask(isSetMask); |
| 143 | - if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, | 205 | + if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, "BlockReduceMin")) { |
| 144 | - "BlockReduceMin")) { | ||
| 145 | ASCENDC_REPORT_CHECK_ERROR("BlockReduceMin", KernelFuncType::MASK_COUNT_MODE); | 206 | ASCENDC_REPORT_CHECK_ERROR("BlockReduceMin", KernelFuncType::MASK_COUNT_MODE); |
| 146 | } | 207 | } |
| 147 | 208 | ||
| @@ -169,13 +230,17 @@ __aicore__ inline void PairReduceSum(const LocalTensor<T>& dst, const LocalTenso | |||
| 169 | MstxTensor::GetMstxVecReducePairInfo(dst, src, mask, repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "PairReduceSum"); | 230 | MstxTensor::GetMstxVecReducePairInfo(dst, src, mask, repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "PairReduceSum"); |
| 170 | 231 | ||
| 171 | using PrimType = PrimT<T>; | 232 | using PrimType = PrimT<T>; |
| 172 | - ASCENDC_ASSERT((SupportType<PrimType, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 233 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 173 | - "PairReduceSum, current api support dtype combination is src and dst both: half / float");}); | 234 | + ASCENDC_DEBUG_ASSERT((SupportType<PrimType, half, float>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, |
| 174 | - ASCENDC_CHECK_VALUE_RANGE(repeatTime, 0, 255, "repeatTime", "PairReduceSum"); | 235 | + "Failed to check dtype in PairReduceSum, current api support dtype combination is " |
| 236 | + "src and dst both: half / float.\n")); | ||
| 237 | + CheckValueRange<int32_t>(repeatTime, 0, 255, "repeatTime", "PairReduceSum"); | ||
| 238 | + CheckVectorTensor("PairReduceSum", NamedTensor(dst, "dst"), NamedTensor(src, "src")); | ||
| 239 | + CheckMaskValue<PrimType, isSetMask>(mask, "PairReduceSum"); | ||
| 240 | + | ||
| 175 | 241 | ||
| 176 | MaskSetter::Instance().SetMask(isSetMask); | 242 | MaskSetter::Instance().SetMask(isSetMask); |
| 177 | - if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, | 243 | + if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, "PairReduceSum")) { |
| 178 | - "PairReduceSum")) { | ||
| 179 | ASCENDC_REPORT_CHECK_ERROR("PairReduceSum", KernelFuncType::MASK_COUNT_MODE); | 244 | ASCENDC_REPORT_CHECK_ERROR("PairReduceSum", KernelFuncType::MASK_COUNT_MODE); |
| 180 | } | 245 | } |
| 181 | 246 | ||
| @@ -192,13 +257,16 @@ __aicore__ inline void BlockReduceSum(const LocalTensor<T>& dst, const LocalTens | |||
| 192 | MstxTensor::GetMstxVecReduceBlkInfo(dst, src, mask[0], mask[1], repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "BlockReduceSum"); | 257 | MstxTensor::GetMstxVecReduceBlkInfo(dst, src, mask[0], mask[1], repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "BlockReduceSum"); |
| 193 | 258 | ||
| 194 | using PrimType = PrimT<T>; | 259 | using PrimType = PrimT<T>; |
| 195 | - ASCENDC_ASSERT((SupportType<PrimType, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 260 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 196 | - "BlockReduceSum, current api support dtype combination is src and dst both: half / float");}); | 261 | + ASCENDC_DEBUG_ASSERT((SupportType<PrimType, half, float>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, |
| 197 | - ASCENDC_CHECK_VALUE_RANGE(repeatTime, 0, 255, "repeatTime", "BlockReduceSum"); | 262 | + "Failed to check dtype in BlockReduceSum, current api support dtype combination is " |
| 263 | + "src and dst both: half / float.\n")); | ||
| 264 | + CheckBlockReduceParams<T>(dst, src, repeatTime, "BlockReduceSum"); | ||
| 265 | + CheckMaskArray<PrimType, isSetMask>(mask, "BlockReduceSum"); | ||
| 266 | + | ||
| 198 | 267 | ||
| 199 | MaskSetter::Instance().SetMask(isSetMask); | 268 | MaskSetter::Instance().SetMask(isSetMask); |
| 200 | - if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, | 269 | + if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, "BlockReduceSum")) { |
| 201 | - "BlockReduceSum")) { | ||
| 202 | ASCENDC_REPORT_CHECK_ERROR("BlockReduceSum", KernelFuncType::MASK_BIT_MODE); | 270 | ASCENDC_REPORT_CHECK_ERROR("BlockReduceSum", KernelFuncType::MASK_BIT_MODE); |
| 203 | } | 271 | } |
| 204 | 272 | ||
| @@ -215,13 +283,16 @@ __aicore__ inline void BlockReduceMax(const LocalTensor<T>& dst, const LocalTens | |||
| 215 | MstxTensor::GetMstxVecReduceBlkInfo(dst, src, mask[0], mask[1], repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "BlockReduceMax"); | 283 | MstxTensor::GetMstxVecReduceBlkInfo(dst, src, mask[0], mask[1], repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "BlockReduceMax"); |
| 216 | 284 | ||
| 217 | using PrimType = PrimT<T>; | 285 | using PrimType = PrimT<T>; |
| 218 | - ASCENDC_ASSERT((SupportType<PrimType, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 286 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 219 | - "BlockReduceMax, current api support dtype combination is src and dst both: half / float");}); | 287 | + ASCENDC_DEBUG_ASSERT((SupportType<PrimType, half, float>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, |
| 220 | - ASCENDC_CHECK_VALUE_RANGE(repeatTime, 0, 255, "repeatTime", "BlockReduceMax"); | 288 | + "Failed to check dtype in BlockReduceMax, current api support dtype combination is " |
| 289 | + "src and dst both: half / float.\n")); | ||
| 290 | + CheckBlockReduceParams<T>(dst, src, repeatTime, "BlockReduceMax"); | ||
| 291 | + CheckMaskArray<PrimType, isSetMask>(mask, "BlockReduceMax"); | ||
| 292 | + | ||
| 221 | 293 | ||
| 222 | MaskSetter::Instance().SetMask(isSetMask); | 294 | MaskSetter::Instance().SetMask(isSetMask); |
| 223 | - if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, | 295 | + if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, "BlockReduceMax")) { |
| 224 | - "BlockReduceMax")) { | ||
| 225 | ASCENDC_REPORT_CHECK_ERROR("BlockReduceMax", KernelFuncType::MASK_BIT_MODE); | 296 | ASCENDC_REPORT_CHECK_ERROR("BlockReduceMax", KernelFuncType::MASK_BIT_MODE); |
| 226 | } | 297 | } |
| 227 | 298 | ||
| @@ -238,13 +309,16 @@ __aicore__ inline void BlockReduceMin(const LocalTensor<T>& dst, const LocalTens | |||
| 238 | MstxTensor::GetMstxVecReduceBlkInfo(dst, src, mask[0], mask[1], repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "BlockReduceMin"); | 309 | MstxTensor::GetMstxVecReduceBlkInfo(dst, src, mask[0], mask[1], repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "BlockReduceMin"); |
| 239 | 310 | ||
| 240 | using PrimType = PrimT<T>; | 311 | using PrimType = PrimT<T>; |
| 241 | - ASCENDC_ASSERT((SupportType<PrimType, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 312 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 242 | - "BlockReduceMin, current api support dtype combination is src and dst both: half / float");}); | 313 | + ASCENDC_DEBUG_ASSERT((SupportType<PrimType, half, float>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, |
| 243 | - ASCENDC_CHECK_VALUE_RANGE(repeatTime, 0, 255, "repeatTime", "BlockReduceMin"); | 314 | + "Failed to check dtype in BlockReduceMin, current api support dtype combination is " |
| 315 | + "src and dst both: half / float.\n")); | ||
| 316 | + CheckBlockReduceParams<T>(dst, src, repeatTime, "BlockReduceMin"); | ||
| 317 | + CheckMaskArray<PrimType, isSetMask>(mask, "BlockReduceMin"); | ||
| 318 | + | ||
| 244 | 319 | ||
| 245 | MaskSetter::Instance().SetMask(isSetMask); | 320 | MaskSetter::Instance().SetMask(isSetMask); |
| 246 | - if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, | 321 | + if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, "BlockReduceMin")) { |
| 247 | - "BlockReduceMin")) { | ||
| 248 | ASCENDC_REPORT_CHECK_ERROR("BlockReduceMin", KernelFuncType::MASK_BIT_MODE); | 322 | ASCENDC_REPORT_CHECK_ERROR("BlockReduceMin", KernelFuncType::MASK_BIT_MODE); |
| 249 | } | 323 | } |
| 250 | 324 | ||
| @@ -261,13 +335,17 @@ __aicore__ inline void PairReduceSum(const LocalTensor<T>& dst, const LocalTenso | |||
| 261 | MstxTensor::GetMstxVecReducePairInfo(dst, src, mask[0], mask[1], repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "PairReduceSum"); | 335 | MstxTensor::GetMstxVecReducePairInfo(dst, src, mask[0], mask[1], repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "PairReduceSum"); |
| 262 | 336 | ||
| 263 | using PrimType = PrimT<T>; | 337 | using PrimType = PrimT<T>; |
| 264 | - ASCENDC_ASSERT((SupportType<PrimType, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 338 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 265 | - "PairReduceSum, current api support dtype combination is src and dst both: half / float");}); | 339 | + ASCENDC_DEBUG_ASSERT((SupportType<PrimType, half, float>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, |
| 266 | - ASCENDC_CHECK_VALUE_RANGE(repeatTime, 0, 255, "repeatTime", "PairReduceSum"); | 340 | + "Failed to check dtype in PairReduceSum, current api support dtype combination is " |
| 341 | + "src and dst both: half / float.\n")); | ||
| 342 | + CheckValueRange<int32_t>(repeatTime, 0, 255, "repeatTime", "PairReduceSum"); | ||
| 343 | + CheckVectorTensor("PairReduceSum", NamedTensor(dst, "dst"), NamedTensor(src, "src")); | ||
| 344 | + CheckMaskArray<PrimType, isSetMask>(mask, "PairReduceSum"); | ||
| 345 | + | ||
| 267 | 346 | ||
| 268 | MaskSetter::Instance().SetMask(isSetMask); | 347 | MaskSetter::Instance().SetMask(isSetMask); |
| 269 | - if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, | 348 | + if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, "PairReduceSum")) { |
| 270 | - "PairReduceSum")) { | ||
| 271 | ASCENDC_REPORT_CHECK_ERROR("PairReduceSum", KernelFuncType::MASK_BIT_MODE); | 349 | ASCENDC_REPORT_CHECK_ERROR("PairReduceSum", KernelFuncType::MASK_BIT_MODE); |
| 272 | } | 350 | } |
| 273 | 351 | ||
| @@ -307,9 +385,21 @@ __aicore__ inline void RepeatReduceSum(const LocalTensor<T>& dst, const LocalTen | |||
| 307 | MstxTensor::GetMstxVecReduceRepeatInfo(dst, src, mask, repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "RepeatReduceSum"); | 385 | MstxTensor::GetMstxVecReduceRepeatInfo(dst, src, mask, repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "RepeatReduceSum"); |
| 308 | 386 | ||
| 309 | using PrimType = PrimT<T>; | 387 | using PrimType = PrimT<T>; |
| 310 | - ASCENDC_ASSERT((SupportType<PrimType, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 388 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 311 | - "RepeatReduceSum, current api support dtype combination is src and dst both: half / float");}); | 389 | + ASCENDC_DEBUG_ASSERT((SupportType<PrimType, half, float>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, |
| 312 | - ASCENDC_CHECK_VALUE_RANGE(repeatTime, 0, 255, "repeatTime", "RepeatReduceSum"); | 390 | + "Failed to check dtype in RepeatReduceSum, current api support dtype combination is " |
| 391 | + "src and dst both: half / float.\n")); | ||
| 392 | + CheckValueRange<int32_t>(repeatTime, 0, 255, "repeatTime", "RepeatReduceSum"); | ||
| 393 | + CheckTensorPhyPosition<Hardware::UB>(dst, "dst", "VECIN / VECCALC / VECOUT", "RepeatReduceSum"); | ||
| 394 | + CheckTensorPhyPosition<Hardware::UB>(src, "src", "VECIN / VECCALC / VECOUT", "RepeatReduceSum"); | ||
| 395 | + CheckTensorAlignment(src, ONE_BLK_SIZE, "src", "RepeatReduceSum"); | ||
| 396 | + if constexpr (sizeof(PrimType) == 2) { | ||
| 397 | + CheckTensorAlignment(dst, 2, "dst", "RepeatReduceSum"); // half: 2B | ||
| 398 | + } else if constexpr (sizeof(PrimType) == 4) { | ||
| 399 | + CheckTensorAlignment(dst, 4, "dst", "RepeatReduceSum"); // float: 4B | ||
| 400 | + } | ||
| 401 | + CheckMaskValue<PrimType, isSetMask>(mask, "RepeatReduceSum"); | ||
| 402 | + | ||
| 313 | 403 | ||
| 314 | MaskSetter::Instance().SetMask(isSetMask); | 404 | MaskSetter::Instance().SetMask(isSetMask); |
| 315 | if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, | 405 | if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, |
| @@ -366,13 +456,16 @@ __aicore__ inline void WholeReduceSum(const LocalTensor<T>& dst, const LocalTens | |||
| 366 | MstxTensor::GetMstxVecReduceInfo(dst, src, mask[0], mask[1], repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "WholeReduceSum"); | 456 | MstxTensor::GetMstxVecReduceInfo(dst, src, mask[0], mask[1], repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "WholeReduceSum"); |
| 367 | 457 | ||
| 368 | using PrimType = PrimT<T>; | 458 | using PrimType = PrimT<T>; |
| 369 | - ASCENDC_ASSERT((SupportType<PrimType, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 459 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 370 | - "WholeReduceSum, current api support dtype combination is src and dst both: half / float");}); | 460 | + ASCENDC_DEBUG_ASSERT((SupportType<PrimType, half, float>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, |
| 371 | - ASCENDC_CHECK_VALUE_RANGE(repeatTime, 0, 255, "repeatTime", "WholeReduceSum"); | 461 | + "Failed to check dtype in WholeReduceSum, current api support dtype combination is " |
| 462 | + "src and dst both: half / float.\n")); | ||
| 463 | + CheckWholeReduceCommonParams<T>(dst, src, repeatTime, "WholeReduceSum"); | ||
| 464 | + CheckMaskArray<PrimType, isSetMask>(mask, "WholeReduceSum"); | ||
| 465 | + | ||
| 372 | 466 | ||
| 373 | MaskSetter::Instance().SetMask(isSetMask); | 467 | MaskSetter::Instance().SetMask(isSetMask); |
| 374 | - if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, | 468 | + if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, "WholeReduceSum")) { |
| 375 | - "WholeReduceSum")) { | ||
| 376 | ASCENDC_REPORT_CHECK_ERROR("WholeReduceSum", KernelFuncType::MASK_BIT_MODE); | 469 | ASCENDC_REPORT_CHECK_ERROR("WholeReduceSum", KernelFuncType::MASK_BIT_MODE); |
| 377 | } | 470 | } |
| 378 | 471 | ||
| @@ -401,11 +494,16 @@ __aicore__ inline void WholeReduceMax(const LocalTensor<T>& dst, const LocalTens | |||
| 401 | MstxTensor::GetMstxVecReduceInfo(dst, src, mask[0], mask[1], repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "WholeReduceMax"); | 494 | MstxTensor::GetMstxVecReduceInfo(dst, src, mask[0], mask[1], repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "WholeReduceMax"); |
| 402 | 495 | ||
| 403 | using PrimType = PrimT<T>; | 496 | using PrimType = PrimT<T>; |
| 404 | -#if !((__NPU_ARCH__ == 3510) || (__NPU_ARCH__ == 5102) || (__NPU_ARCH__ == 3003) || (__NPU_ARCH__ == 3113)) | 497 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 405 | - ASCENDC_ASSERT((SupportType<PrimType, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 498 | + CheckWholeReduceCommonParams<T>(dst, src, repeatTime, order, "WholeReduceMax"); |
| 406 | - "WholeReduceMax, current api support dtype combination is src and dst both: half / float");}); | 499 | + CheckMaskArray<PrimType, isSetMask>(mask, "WholeReduceMax"); |
| 500 | + | ||
| 501 | + | ||
| 502 | + (__NPU_ARCH__ == 3113)) | ||
| 503 | + ASCENDC_DEBUG_ASSERT((SupportType<PrimType, half, float>()), | ||
| 504 | + KERNEL_LOG_INTERNAL(KERNEL_ERROR, "Failed to check dtype in " | ||
| 505 | + "WholeReduceMax, current api support dtype combination is src and dst both: half / float.\n")); | ||
| 407 | 506 | ||
| 408 | - ASCENDC_CHECK_VALUE_RANGE(repeatTime, 0, 255, "repeatTime", "WholeReduceMax"); | ||
| 409 | 507 | ||
| 410 | (__NPU_ARCH__ == 3002) || (__NPU_ARCH__ == 3102) || \ | 508 | (__NPU_ARCH__ == 3002) || (__NPU_ARCH__ == 3102) || \ |
| 411 | (__NPU_ARCH__ == 5102) || \ | 509 | (__NPU_ARCH__ == 5102) || \ |
| @@ -452,10 +550,10 @@ __aicore__ inline void WholeReduceMinCommon(const LocalTensor<T>& dst, const Loc | |||
| 452 | { | 550 | { |
| 453 | using PrimType = PrimT<T>; | 551 | using PrimType = PrimT<T>; |
| 454 | 552 | ||
| 455 | - ASCENDC_ASSERT((SupportType<PrimType, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 553 | + ASCENDC_DEBUG_ASSERT((SupportType<PrimType, half, float>()), |
| 456 | - "WholeReduceMin, current api support dtype combination is src and dst both: half / float");}); | 554 | + KERNEL_LOG_INTERNAL(KERNEL_ERROR, "Failed to check dtype in " |
| 555 | + "WholeReduceMin, current api support dtype combination is src and dst both: half / float.\n")); | ||
| 457 | 556 | ||
| 458 | - ASCENDC_CHECK_VALUE_RANGE(repeatTime, 0, 255, "repeatTime", "WholeReduceMin"); | ||
| 459 | 557 | ||
| 460 | (__NPU_ARCH__ == 3002) || (__NPU_ARCH__ == 3102) || \ | 558 | (__NPU_ARCH__ == 3002) || (__NPU_ARCH__ == 3102) || \ |
| 461 | (__NPU_ARCH__ == 5102) || \ | 559 | (__NPU_ARCH__ == 5102) || \ |
| @@ -484,6 +582,11 @@ __aicore__ inline void WholeReduceMin(const LocalTensor<T>& dst, const LocalTens | |||
| 484 | { | 582 | { |
| 485 | 583 | ||
| 486 | MstxTensor::GetMstxVecReduceInfo(dst, src, mask[0], mask[1], repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "WholeReduceMin"); | 584 | MstxTensor::GetMstxVecReduceInfo(dst, src, mask[0], mask[1], repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "WholeReduceMin"); |
| 585 | + | ||
| 586 | + using PrimType = PrimT<T>; | ||
| 587 | + | ||
| 588 | + CheckWholeReduceCommonParams<T>(dst, src, repeatTime, order, "WholeReduceMin"); | ||
| 589 | + CheckMaskArray<PrimType, isSetMask>(mask, "WholeReduceMin"); | ||
| 487 | 590 | ||
| 488 | 591 | ||
| 489 | MaskSetter::Instance().SetMask(isSetMask); | 592 | MaskSetter::Instance().SetMask(isSetMask); |
| @@ -527,13 +630,16 @@ __aicore__ inline void WholeReduceSum(const LocalTensor<T>& dst, const LocalTens | |||
| 527 | MstxTensor::GetMstxVecReduceInfo(dst, src, mask, repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "WholeReduceSum"); | 630 | MstxTensor::GetMstxVecReduceInfo(dst, src, mask, repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "WholeReduceSum"); |
| 528 | 631 | ||
| 529 | using PrimType = PrimT<T>; | 632 | using PrimType = PrimT<T>; |
| 530 | - ASCENDC_ASSERT((SupportType<PrimType, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 633 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 531 | - "WholeReduceSum, current api support dtype combination is src and dst both: half / float");}); | 634 | + ASCENDC_DEBUG_ASSERT((SupportType<PrimType, half, float>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, |
| 532 | - ASCENDC_CHECK_VALUE_RANGE(repeatTime, 0, 255, "repeatTime", "WholeReduceSum"); | 635 | + "Failed to check dtype in WholeReduceSum, current api support dtype combination is " |
| 636 | + "src and dst both: half / float.\n")); | ||
| 637 | + CheckWholeReduceCommonParams<T>(dst, src, repeatTime, "WholeReduceSum"); | ||
| 638 | + CheckMaskValue<PrimType, isSetMask>(mask, "WholeReduceSum"); | ||
| 639 | + | ||
| 533 | 640 | ||
| 534 | MaskSetter::Instance().SetMask(isSetMask); | 641 | MaskSetter::Instance().SetMask(isSetMask); |
| 535 | - if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, | 642 | + if (!CheckFunVecReduceOther(dst, src, repeatTime, mask, dstRepStride, srcBlkStride, srcRepStride, "WholeReduceSum")) { |
| 536 | - "WholeReduceSum")) { | ||
| 537 | ASCENDC_REPORT_CHECK_ERROR("WholeReduceSum", KernelFuncType::MASK_COUNT_MODE); | 643 | ASCENDC_REPORT_CHECK_ERROR("WholeReduceSum", KernelFuncType::MASK_COUNT_MODE); |
| 538 | } | 644 | } |
| 539 | 645 | ||
| @@ -551,11 +657,16 @@ __aicore__ inline void WholeReduceMax(const LocalTensor<T>& dst, const LocalTens | |||
| 551 | MstxTensor::GetMstxVecReduceInfo(dst, src, mask, repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "WholeReduceMax"); | 657 | MstxTensor::GetMstxVecReduceInfo(dst, src, mask, repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "WholeReduceMax"); |
| 552 | 658 | ||
| 553 | using PrimType = PrimT<T>; | 659 | using PrimType = PrimT<T>; |
| 554 | -#if !((__NPU_ARCH__ == 3510) || (__NPU_ARCH__ == 5102) || __NPU_ARCH__ == 3003 || __NPU_ARCH__ == 3113) | 660 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) |
| 555 | - ASCENDC_ASSERT((SupportType<PrimType, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 661 | + CheckWholeReduceCommonParams<T>(dst, src, repeatTime, order, "WholeReduceMax"); |
| 556 | - "WholeReduceMax, current api support dtype combination is src and dst both: half / float");}); | 662 | + CheckMaskValue<PrimType, isSetMask>(mask, "WholeReduceMax"); |
| 663 | + | ||
| 664 | + | ||
| 665 | + __NPU_ARCH__ == 3113) | ||
| 666 | + ASCENDC_DEBUG_ASSERT((SupportType<PrimType, half, float>()), | ||
| 667 | + KERNEL_LOG_INTERNAL(KERNEL_ERROR, "Failed to check dtype in " | ||
| 668 | + "WholeReduceMax, current api support dtype combination is src and dst both: half / float.\n")); | ||
| 557 | 669 | ||
| 558 | - ASCENDC_CHECK_VALUE_RANGE(repeatTime, 0, 255, "repeatTime", "WholeReduceMax"); | ||
| 559 | 670 | ||
| 560 | ASCENDC_CHECK_VALUE_RANGE(static_cast<int>(order), 0, 3, "order", "WholeReduceMax"); | 671 | ASCENDC_CHECK_VALUE_RANGE(static_cast<int>(order), 0, 3, "order", "WholeReduceMax"); |
| 561 | 672 | ||
| @@ -586,6 +697,11 @@ __aicore__ inline void WholeReduceMin(const LocalTensor<T>& dst, const LocalTens | |||
| 586 | { | 697 | { |
| 587 | 698 | ||
| 588 | MstxTensor::GetMstxVecReduceInfo(dst, src, mask, repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "WholeReduceMin"); | 699 | MstxTensor::GetMstxVecReduceInfo(dst, src, mask, repeatTime, dstRepStride, srcBlkStride, srcRepStride, isSetMask, "WholeReduceMin"); |
| 700 | + | ||
| 701 | + using PrimType = PrimT<T>; | ||
| 702 | + | ||
| 703 | + CheckWholeReduceCommonParams<T>(dst, src, repeatTime, order, "WholeReduceMin"); | ||
| 704 | + CheckMaskValue<PrimType, isSetMask>(mask, "WholeReduceMin"); | ||
| 589 | 705 | ||
| 590 | 706 | ||
| 591 | MaskSetter::Instance().SetMask(isSetMask); | 707 | MaskSetter::Instance().SetMask(isSetMask); |
| @@ -946,7 +1062,7 @@ __aicore__ inline void ReduceSum(const LocalTensor<T>& dst, const LocalTensor<T> | |||
| 946 | 1062 | ||
| 947 | using PrimType = PrimT<T>; | 1063 | using PrimType = PrimT<T>; |
| 948 | ASCENDC_CHECK_VALUE_RANGE(count, 1, TOTAL_UB_SIZE / sizeof(PrimType), "count", "ReduceSum"); | 1064 | ASCENDC_CHECK_VALUE_RANGE(count, 1, TOTAL_UB_SIZE / sizeof(PrimType), "count", "ReduceSum"); |
| 949 | -#if __NPU_ARCH__ == 2201 | 1065 | +#if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 2201) |
| 950 | ASCENDC_ASSERT((SupportType<PrimType, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in ReduceSum, " | 1066 | ASCENDC_ASSERT((SupportType<PrimType, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in ReduceSum, " |
| 951 | "current api support dtype combination is src and dst both: half / float");}); | 1067 | "current api support dtype combination is src and dst both: half / float");}); |
| 952 | 1068 | ||
| @@ -1032,7 +1148,7 @@ template <typename T> | |||
| 1032 | __aicore__ inline void GetReduceMaxMinCount(uint32_t &maxMinValue, uint32_t &maxMinIndex) | 1148 | __aicore__ inline void GetReduceMaxMinCount(uint32_t &maxMinValue, uint32_t &maxMinIndex) |
| 1033 | { | 1149 | { |
| 1034 | using PrimType = PrimT<T>; | 1150 | using PrimType = PrimT<T>; |
| 1035 | -#if __NPU_ARCH__ == 2201 | 1151 | +#if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 2201) |
| 1036 | if (g_coreType == AIC) { | 1152 | if (g_coreType == AIC) { |
| 1037 | return; | 1153 | return; |
| 1038 | } | 1154 | } |
| @@ -1053,7 +1169,7 @@ template <typename T> | |||
| 1053 | __aicore__ inline void GetReduceRepeatMaxMinSpr(uint32_t &maxMinValue, uint32_t &maxMinIndex) | 1169 | __aicore__ inline void GetReduceRepeatMaxMinSpr(uint32_t &maxMinValue, uint32_t &maxMinIndex) |
| 1054 | { | 1170 | { |
| 1055 | using PrimType = PrimT<T>; | 1171 | using PrimType = PrimT<T>; |
| 1056 | -#if __NPU_ARCH__ == 2201 | 1172 | +#if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 2201) |
| 1057 | if (g_coreType == AIC) { | 1173 | if (g_coreType == AIC) { |
| 1058 | return; | 1174 | return; |
| 1059 | } | 1175 | } |
| @@ -1070,7 +1186,7 @@ __aicore__ inline void GetReduceRepeatMaxMinSpr(uint32_t &maxMinValue) | |||
| 1070 | 1186 | ||
| 1071 | __aicore__ inline int64_t GetReduceRepeatSumSpr() | 1187 | __aicore__ inline int64_t GetReduceRepeatSumSpr() |
| 1072 | { | 1188 | { |
| 1073 | -#if __NPU_ARCH__ == 2201 | 1189 | +#if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 2201) |
| 1074 | if (g_coreType == AIC) { | 1190 | if (g_coreType == AIC) { |
| 1075 | return 0; | 1191 | return 0; |
| 1076 | } | 1192 | } |
| @@ -1095,7 +1211,7 @@ __aicore__ inline __inout_pipe__(S) void GetReduceMaxMinCount(T &maxMinValue, T | |||
| 1095 | ASCENDC_ASSERT((SupportType<T, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 1211 | ASCENDC_ASSERT((SupportType<T, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " |
| 1096 | "GetReduceMaxMinCount, current api support dtype combination is maxMinValue and maxMinIndex both: half / " | 1212 | "GetReduceMaxMinCount, current api support dtype combination is maxMinValue and maxMinIndex both: half / " |
| 1097 | "float");}); | 1213 | "float");}); |
| 1098 | -#if __NPU_ARCH__ == 2201 | 1214 | +#if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 2201) |
| 1099 | if (g_coreType == AIC) { | 1215 | if (g_coreType == AIC) { |
| 1100 | return; | 1216 | return; |
| 1101 | } | 1217 | } |
| @@ -1118,7 +1234,7 @@ __aicore__ inline __inout_pipe__(S) void GetReduceRepeatMaxMinSpr(T &maxMinValue | |||
| 1118 | ASCENDC_ASSERT((SupportType<T, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 1234 | ASCENDC_ASSERT((SupportType<T, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " |
| 1119 | "GetReduceRepeatMaxMinSpr, current api support dtype combination is maxMinValue and maxMinIndex both: half / " | 1235 | "GetReduceRepeatMaxMinSpr, current api support dtype combination is maxMinValue and maxMinIndex both: half / " |
| 1120 | "float");}); | 1236 | "float");}); |
| 1121 | -#if __NPU_ARCH__ == 2201 | 1237 | +#if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 2201) |
| 1122 | if (g_coreType == AIC) { | 1238 | if (g_coreType == AIC) { |
| 1123 | return; | 1239 | return; |
| 1124 | } | 1240 | } |
| @@ -1139,7 +1255,7 @@ __aicore__ inline __inout_pipe__(S) T GetReduceRepeatSumSpr() | |||
| 1139 | { | 1255 | { |
| 1140 | ASCENDC_ASSERT((SupportType<T, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in GetReduceRepeatSumSpr, " | 1256 | ASCENDC_ASSERT((SupportType<T, half, float>()), { KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in GetReduceRepeatSumSpr, " |
| 1141 | "current api support dtype combination is half / float");}); | 1257 | "current api support dtype combination is half / float");}); |
| 1142 | -#if __NPU_ARCH__ == 2201 | 1258 | +#if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 2201) |
| 1143 | if (g_coreType == AIC) { | 1259 | if (g_coreType == AIC) { |
| 1144 | return 0; | 1260 | return 0; |
| 1145 | } | 1261 | } |
| @@ -22,6 +22,7 @@ | |||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | + | ||
| 25 | 26 | ||
| 26 | 27 | ||
| 27 | 28 | ||
| @@ -47,6 +48,28 @@ | |||
| 47 | 48 | ||
| 48 | namespace AscendC { | 49 | namespace AscendC { |
| 49 | 50 | ||
| 51 | + | ||
| 52 | +// TransDataTo5HD common checks: dtype, dstHighHalf/srcHighHalf, repeatTimes | ||
| 53 | +// Used by: all 3 TransDataTo5HD overloads | ||
| 54 | +template <typename T> | ||
| 55 | +__aicore__ inline void CheckTransDataTo5HDParams(const TransDataTo5HDParams& nchwconvParams) | ||
| 56 | +{ | ||
| 57 | + using PrimType = PrimT<T>; | ||
| 58 | + ASCENDC_DEBUG_ASSERT((SupportType<PrimType, int8_t, uint8_t, int16_t, uint16_t, half, int32_t, uint32_t, float>()), | ||
| 59 | + KERNEL_LOG_INTERNAL(KERNEL_ERROR, "Failed to check dtype in TransDataTo5HD, current api support dtype is " | ||
| 60 | + "int8_t / uint8_t / int16_t / uint16_t / half / int32_t / uint32_t / float.\n")); | ||
| 61 | + // dstHighHalf/srcHighHalf only valid for int8_t/uint8_t | ||
| 62 | + if constexpr (!SupportType<PrimType, int8_t, uint8_t>()) { | ||
| 63 | + ASCENDC_DEBUG_ASSERT((nchwconvParams.dstHighHalf == false), | ||
| 64 | + KERNEL_LOG_INTERNAL(KERNEL_ERROR, "Failed to check dstHighHalf in TransDataTo5HD, " | ||
| 65 | + "dstHighHalf is only valid for int8_t / uint8_t dtype.\n")); | ||
| 66 | + ASCENDC_DEBUG_ASSERT((nchwconvParams.srcHighHalf == false), | ||
| 67 | + KERNEL_LOG_INTERNAL(KERNEL_ERROR, "Failed to check srcHighHalf in TransDataTo5HD, " | ||
| 68 | + "srcHighHalf is only valid for int8_t / uint8_t dtype.\n")); | ||
| 69 | + } | ||
| 70 | + CheckValueRange<int32_t>(nchwconvParams.repeatTimes, 0, 255, "repeatTimes", "TransDataTo5HD"); | ||
| 71 | +} | ||
| 72 | + | ||
| 50 | /* ************************************************************************************************** | 73 | /* ************************************************************************************************** |
| 51 | * Transpose * | 74 | * Transpose * |
| 52 | * ************************************************************************************************* */ | 75 | * ************************************************************************************************* */ |
| @@ -90,6 +113,15 @@ template <typename T> | |||
| 90 | __aicore__ inline void TransDataTo5HD(const LocalTensor<T> (&dstList)[NCHW_CONV_ADDR_LIST_SIZE], | 113 | __aicore__ inline void TransDataTo5HD(const LocalTensor<T> (&dstList)[NCHW_CONV_ADDR_LIST_SIZE], |
| 91 | const LocalTensor<T> (&srcList)[NCHW_CONV_ADDR_LIST_SIZE], const TransDataTo5HDParams& nchwconvParams) | 114 | const LocalTensor<T> (&srcList)[NCHW_CONV_ADDR_LIST_SIZE], const TransDataTo5HDParams& nchwconvParams) |
| 92 | { | 115 | { |
| 116 | + | ||
| 117 | + CheckTransDataTo5HDParams<T>(nchwconvParams); | ||
| 118 | + for (int32_t i = 0; i < NCHW_CONV_ADDR_LIST_SIZE; i++) { | ||
| 119 | + CheckTensorPhyPosition<Hardware::UB>(dstList[i], "dstList", "VECIN / VECCALC / VECOUT", "TransDataTo5HD"); | ||
| 120 | + CheckTensorPhyPosition<Hardware::UB>(srcList[i], "srcList", "VECIN / VECCALC / VECOUT", "TransDataTo5HD"); | ||
| 121 | + CheckTensorAlignment(dstList[i], ONE_BLK_SIZE, "dstList", "TransDataTo5HD"); | ||
| 122 | + CheckTensorAlignment(srcList[i], ONE_BLK_SIZE, "srcList", "TransDataTo5HD"); | ||
| 123 | + } | ||
| 124 | + | ||
| 93 | 125 | ||
| 94 | if (!CheckFunTransDataTo5HD(dstList, srcList, nchwconvParams, "TransDataTo5HD")) { | 126 | if (!CheckFunTransDataTo5HD(dstList, srcList, nchwconvParams, "TransDataTo5HD")) { |
| 95 | ASCENDC_REPORT_CHECK_ERROR("TransDataTo5HD", KernelFuncType::NONE_MODE); | 127 | ASCENDC_REPORT_CHECK_ERROR("TransDataTo5HD", KernelFuncType::NONE_MODE); |
| @@ -110,18 +142,25 @@ template <typename T> | |||
| 110 | __aicore__ inline void TransDataTo5HD(uint64_t dstList[NCHW_CONV_ADDR_LIST_SIZE], | 142 | __aicore__ inline void TransDataTo5HD(uint64_t dstList[NCHW_CONV_ADDR_LIST_SIZE], |
| 111 | uint64_t srcList[NCHW_CONV_ADDR_LIST_SIZE], const TransDataTo5HDParams& nchwconvParams) | 143 | uint64_t srcList[NCHW_CONV_ADDR_LIST_SIZE], const TransDataTo5HDParams& nchwconvParams) |
| 112 | { | 144 | { |
| 145 | + | ||
| 146 | + CheckTransDataTo5HDParams<T>(nchwconvParams); | ||
| 147 | + for (int32_t i = 0; i < NCHW_CONV_ADDR_LIST_SIZE; i++) { | ||
| 148 | + CheckAddrAlignment(dstList[i], GetPhyType(TPosition::VECIN), ONE_BLK_SIZE, "dstList", "TransDataTo5HD"); | ||
| 149 | + CheckAddrAlignment(srcList[i], GetPhyType(TPosition::VECIN), ONE_BLK_SIZE, "srcList", "TransDataTo5HD"); | ||
| 150 | + } | ||
| 151 | + | ||
| 113 | 152 | ||
| 114 | for (int8_t i = 0; i < NCHW_CONV_ADDR_LIST_SIZE; i++) { | 153 | for (int8_t i = 0; i < NCHW_CONV_ADDR_LIST_SIZE; i++) { |
| 115 | uint64_t dstAddr = (uint8_t *)dstList[i] - | 154 | uint64_t dstAddr = (uint8_t *)dstList[i] - |
| 116 | (uint8_t*)(GetTPipePtr()->GetBaseAddr(int8_t(AscendC::TPosition(TPosition::VECIN)))); | 155 | (uint8_t*)(GetTPipePtr()->GetBaseAddr(int8_t(AscendC::TPosition(TPosition::VECIN)))); |
| 117 | uint64_t srcAddr = (uint8_t *)srcList[i] - | 156 | uint64_t srcAddr = (uint8_t *)srcList[i] - |
| 118 | (uint8_t*)(GetTPipePtr()->GetBaseAddr(int8_t(AscendC::TPosition(TPosition::VECIN)))); | 157 | (uint8_t*)(GetTPipePtr()->GetBaseAddr(int8_t(AscendC::TPosition(TPosition::VECIN)))); |
| 119 | - ASCENDC_ASSERT((dstAddr % ONE_BLK_SIZE == 0), | 158 | + ASCENDC_DEBUG_ASSERT((dstAddr % ONE_BLK_SIZE == 0), |
| 120 | - {KERNEL_LOG(KERNEL_ERROR, "Failed to check dst tensor address list alignment in TransDataTo5HD, " | 159 | + KERNEL_LOG_INTERNAL(KERNEL_ERROR, "Failed to check dst tensor address list alignment in TransDataTo5HD, " |
| 121 | - "it should be 32B aligned");}); | 160 | + "it should be 32B aligned.\n")); |
| 122 | - ASCENDC_ASSERT((srcAddr % ONE_BLK_SIZE == 0), | 161 | + ASCENDC_DEBUG_ASSERT((srcAddr % ONE_BLK_SIZE == 0), |
| 123 | - {KERNEL_LOG(KERNEL_ERROR, "Failed to check src tensor address list alignment in TransDataTo5HD, " | 162 | + KERNEL_LOG_INTERNAL(KERNEL_ERROR, "Failed to check src tensor address list alignment in TransDataTo5HD, " |
| 124 | - "it should be 32B aligned");}); | 163 | + "it should be 32B aligned.\n")); |
| 125 | } | 164 | } |
| 126 | 165 | ||
| 127 | TransDataTo5HDImpl<T>(dstList, srcList, nchwconvParams); | 166 | TransDataTo5HDImpl<T>(dstList, srcList, nchwconvParams); |
| @@ -176,6 +215,13 @@ template <typename T> | |||
| 176 | __aicore__ inline __in_pipe__(S) __out_pipe__(V) void TransDataTo5HD(const LocalTensor<uint64_t> &dst, | 215 | __aicore__ inline __in_pipe__(S) __out_pipe__(V) void TransDataTo5HD(const LocalTensor<uint64_t> &dst, |
| 177 | const LocalTensor<uint64_t> &src, const TransDataTo5HDParams &nchwconvParams) | 216 | const LocalTensor<uint64_t> &src, const TransDataTo5HDParams &nchwconvParams) |
| 178 | { | 217 | { |
| 218 | + | ||
| 219 | + CheckTransDataTo5HDParams<T>(nchwconvParams); | ||
| 220 | + CheckTensorPhyPosition<Hardware::UB>(dst, "dst", "VECIN / VECCALC / VECOUT", "TransDataTo5HD"); | ||
| 221 | + CheckTensorPhyPosition<Hardware::UB>(src, "src", "VECIN / VECCALC / VECOUT", "TransDataTo5HD"); | ||
| 222 | + CheckTensorAlignment(dst, ONE_BLK_SIZE, "dst", "TransDataTo5HD"); | ||
| 223 | + CheckTensorAlignment(src, ONE_BLK_SIZE, "src", "TransDataTo5HD"); | ||
| 224 | + | ||
| 179 | 225 | ||
| 180 | if (!CheckFunTransDataTo5HD<T, uint64_t>(dst, src, nchwconvParams, "TransDataTo5HD")) { | 226 | if (!CheckFunTransDataTo5HD<T, uint64_t>(dst, src, nchwconvParams, "TransDataTo5HD")) { |
| 181 | ASCENDC_REPORT_CHECK_ERROR("TransDataTo5HD", KernelFuncType::NONE_MODE); | 227 | ASCENDC_REPORT_CHECK_ERROR("TransDataTo5HD", KernelFuncType::NONE_MODE); |
| @@ -350,7 +350,7 @@ namespace Internal { | |||
| 350 | constexpr int32_t TSCM_CROSS_SYNC_ID_MAX = 11; | 350 | constexpr int32_t TSCM_CROSS_SYNC_ID_MAX = 11; |
| 351 | } | 351 | } |
| 352 | 352 | ||
| 353 | -#if defined(ASCENDC_CPU_DEBUG) && ASCENDC_CPU_DEBUG == 1 | 353 | +#if (defined(ASCENDC_CPU_DEBUG) && ASCENDC_CPU_DEBUG == 1) || defined(ASCENDC_DEBUG) |
| 354 | // param check size | 354 | // param check size |
| 355 | const int32_t MAX_BLOCK_COUNT = 4095; | 355 | const int32_t MAX_BLOCK_COUNT = 4095; |
| 356 | const int32_t MIN_BLOCK_COUNT = 1; | 356 | const int32_t MIN_BLOCK_COUNT = 1; |
| @@ -431,6 +431,10 @@ namespace Internal { | |||
| 431 | constexpr uint8_t REGION_PROPOSAL_ELEMENT_NUM = 8; | 431 | constexpr uint8_t REGION_PROPOSAL_ELEMENT_NUM = 8; |
| 432 | } | 432 | } |
| 433 | 433 | ||
| 434 | + | ||
| 435 | + | ||
| 436 | + | ||
| 437 | + | ||
| 434 | template <typename T> std::string ScalarToString(T scalarValue); | 438 | template <typename T> std::string ScalarToString(T scalarValue); |
| 435 | template <> inline std::string ScalarToString(half scalarValue) | 439 | template <> inline std::string ScalarToString(half scalarValue) |
| 436 | { | 440 | { |
Mtests/api/basic_api/ascendc_case_ascend910b1/ascendc_case_ascend910b1_aic/test_operator_mmad_sp.cpp+233-0
| @@ -10,8 +10,17 @@ | |||
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | + | ||
| 13 | 14 | ||
| 14 | using namespace std; | 15 | using namespace std; |
| 16 | +using namespace AscendC; | ||
| 17 | + | ||
| 18 | +namespace { | ||
| 19 | +int32_t RaiseStubForNpuDebug(int32_t i) | ||
| 20 | +{ | ||
| 21 | + return 0; | ||
| 22 | +} | ||
| 23 | +} | ||
| 15 | 24 | ||
| 16 | namespace AscendC { | 25 | namespace AscendC { |
| 17 | class KernelMatmulSp { | 26 | class KernelMatmulSp { |
| @@ -188,4 +197,228 @@ TEST_F(TEST_MMAD_SP, MMAD_SP_Case) | |||
| 188 | for (int32_t i = 0; i < m * n * sizeof(int32_t); i++) { | 197 | for (int32_t i = 0; i < m * n * sizeof(int32_t); i++) { |
| 189 | EXPECT_EQ(c[i], 0x00); | 198 | EXPECT_EQ(c[i], 0x00); |
| 190 | } | 199 | } |
| 200 | +} | ||
| 201 | + | ||
| 202 | +// ============================================================ | ||
| 203 | +// LoadDataWithSparse NPU Debug validation - negative test cases | ||
| 204 | +// Validation: dst position (B2), src position (B1), idx position (B1), | ||
| 205 | +// alignment (dst 512B, src 32B, idx 32B) | ||
| 206 | +// Note: LoadDataWithSparse is only available on C220 (__NPU_ARCH__ == 2201) | ||
| 207 | +// ============================================================ | ||
| 208 | + | ||
| 209 | + | ||
| 210 | +class TestLoadDataWithSparseNpuDebug : public testing::Test { | ||
| 211 | +protected: | ||
| 212 | + void SetUp() | ||
| 213 | + { | ||
| 214 | + g_coreType = AscendC::AIC_TYPE; | ||
| 215 | + } | ||
| 216 | + void TearDown() | ||
| 217 | + { | ||
| 218 | + AscendC::CheckSyncState(); | ||
| 219 | + AscendC::SetGCoreType(0); | ||
| 220 | + GlobalMockObject::verify(); | ||
| 221 | + } | ||
| 222 | +}; | ||
| 223 | + | ||
| 224 | +// dst position not B2 (using A2 instead) | ||
| 225 | +TEST_F(TestLoadDataWithSparseNpuDebug, DstPositionNotB2) | ||
| 226 | +{ | ||
| 227 | + if ASCEND_IS_AIV { | ||
| 228 | + return; | ||
| 229 | + } | ||
| 230 | + TPipe tpipe; | ||
| 231 | + TBuf<TPosition::A2> dstBuf; | ||
| 232 | + tpipe.InitBuffer(dstBuf, 512 * sizeof(int8_t)); | ||
| 233 | + LocalTensor<int8_t> dstLocal = dstBuf.Get<int8_t>(); | ||
| 234 | + | ||
| 235 | + TBuf<TPosition::B1> srcBuf; | ||
| 236 | + tpipe.InitBuffer(srcBuf, 512 * sizeof(int8_t)); | ||
| 237 | + LocalTensor<int8_t> srcLocal = srcBuf.Get<int8_t>(); | ||
| 238 | + | ||
| 239 | + TBuf<TPosition::B1> idxBuf; | ||
| 240 | + tpipe.InitBuffer(idxBuf, 128 * sizeof(uint8_t)); | ||
| 241 | + LocalTensor<uint8_t> idxLocal = idxBuf.Get<uint8_t>(); | ||
| 242 | + | ||
| 243 | + LoadData2dParams loadDataParams; | ||
| 244 | + loadDataParams.repeatTimes = 1; | ||
| 245 | + loadDataParams.srcStride = 0; | ||
| 246 | + loadDataParams.ifTranspose = false; | ||
| 247 | + | ||
| 248 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStubForNpuDebug)); | ||
| 249 | + LoadDataWithSparse(dstLocal, srcLocal, idxLocal, loadDataParams); | ||
| 250 | +} | ||
| 251 | + | ||
| 252 | +// src position not B1 (using A1 instead) | ||
| 253 | +TEST_F(TestLoadDataWithSparseNpuDebug, SrcPositionNotB1) | ||
| 254 | +{ | ||
| 255 | + if ASCEND_IS_AIV { | ||
| 256 | + return; | ||
| 257 | + } | ||
| 258 | + TPipe tpipe; | ||
| 259 | + TBuf<TPosition::B2> dstBuf; | ||
| 260 | + tpipe.InitBuffer(dstBuf, 512 * sizeof(int8_t)); | ||
| 261 | + LocalTensor<int8_t> dstLocal = dstBuf.Get<int8_t>(); | ||
| 262 | + | ||
| 263 | + TBuf<TPosition::A1> srcBuf; | ||
| 264 | + tpipe.InitBuffer(srcBuf, 512 * sizeof(int8_t)); | ||
| 265 | + LocalTensor<int8_t> srcLocal = srcBuf.Get<int8_t>(); | ||
| 266 | + | ||
| 267 | + TBuf<TPosition::B1> idxBuf; | ||
| 268 | + tpipe.InitBuffer(idxBuf, 128 * sizeof(uint8_t)); | ||
| 269 | + LocalTensor<uint8_t> idxLocal = idxBuf.Get<uint8_t>(); | ||
| 270 | + | ||
| 271 | + LoadData2dParams loadDataParams; | ||
| 272 | + loadDataParams.repeatTimes = 1; | ||
| 273 | + loadDataParams.srcStride = 0; | ||
| 274 | + loadDataParams.ifTranspose = false; | ||
| 275 | + | ||
| 276 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStubForNpuDebug)); | ||
| 277 | + LoadDataWithSparse(dstLocal, srcLocal, idxLocal, loadDataParams); | ||
| 278 | +} | ||
| 279 | + | ||
| 280 | +// idx position not B1 (using A1 instead) | ||
| 281 | +TEST_F(TestLoadDataWithSparseNpuDebug, IdxPositionNotB1) | ||
| 282 | +{ | ||
| 283 | + if ASCEND_IS_AIV { | ||
| 284 | + return; | ||
| 285 | + } | ||
| 286 | + TPipe tpipe; | ||
| 287 | + TBuf<TPosition::B2> dstBuf; | ||
| 288 | + tpipe.InitBuffer(dstBuf, 512 * sizeof(int8_t)); | ||
| 289 | + LocalTensor<int8_t> dstLocal = dstBuf.Get<int8_t>(); | ||
| 290 | + | ||
| 291 | + TBuf<TPosition::B1> srcBuf; | ||
| 292 | + tpipe.InitBuffer(srcBuf, 512 * sizeof(int8_t)); | ||
| 293 | + LocalTensor<int8_t> srcLocal = srcBuf.Get<int8_t>(); | ||
| 294 | + | ||
| 295 | + TBuf<TPosition::A1> idxBuf; | ||
| 296 | + tpipe.InitBuffer(idxBuf, 128 * sizeof(uint8_t)); | ||
| 297 | + LocalTensor<uint8_t> idxLocal = idxBuf.Get<uint8_t>(); | ||
| 298 | + | ||
| 299 | + LoadData2dParams loadDataParams; | ||
| 300 | + loadDataParams.repeatTimes = 1; | ||
| 301 | + loadDataParams.srcStride = 0; | ||
| 302 | + loadDataParams.ifTranspose = false; | ||
| 303 | + | ||
| 304 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStubForNpuDebug)); | ||
| 305 | + LoadDataWithSparse(dstLocal, srcLocal, idxLocal, loadDataParams); | ||
| 306 | +} | ||
| 307 | + | ||
| 308 | +// ============================================================ | ||
| 309 | +// MmadWithSparse NPU Debug validation - negative test cases | ||
| 310 | +// Validation: dst position (CO1), fm position (A2), filter position (B2), | ||
| 311 | +// alignment (dst 1024B, fm 512B, filter 512B), | ||
| 312 | +// parameter ranges: m [0, UINT12_MAX], n [0, UINT12_MAX], k [0, UINT12_MAX] | ||
| 313 | +// Note: MmadWithSparse is only available on C220 (__NPU_ARCH__ == 2201) | ||
| 314 | +// ============================================================ | ||
| 315 | + | ||
| 316 | +class TestMmadWithSparseNpuDebug : public testing::Test { | ||
| 317 | +protected: | ||
| 318 | + void SetUp() | ||
| 319 | + { | ||
| 320 | + g_coreType = AscendC::AIC_TYPE; | ||
| 321 | + } | ||
| 322 | + void TearDown() | ||
| 323 | + { | ||
| 324 | + AscendC::CheckSyncState(); | ||
| 325 | + AscendC::SetGCoreType(0); | ||
| 326 | + GlobalMockObject::verify(); | ||
| 327 | + } | ||
| 328 | +}; | ||
| 329 | + | ||
| 330 | +// dst position not CO1 (using A2 instead) | ||
| 331 | +TEST_F(TestMmadWithSparseNpuDebug, DstPositionNotCO1) | ||
| 332 | +{ | ||
| 333 | + if ASCEND_IS_AIV { | ||
| 334 | + return; | ||
| 335 | + } | ||
| 336 | + TPipe tpipe; | ||
| 337 | + TBuf<TPosition::A2> dstBuf; | ||
| 338 | + tpipe.InitBuffer(dstBuf, 256 * sizeof(int32_t)); | ||
| 339 | + LocalTensor<int32_t> dstLocal = dstBuf.Get<int32_t>(); | ||
| 340 | + | ||
| 341 | + TBuf<TPosition::A2> fmBuf; | ||
| 342 | + tpipe.InitBuffer(fmBuf, 1024 * sizeof(int8_t)); | ||
| 343 | + LocalTensor<int8_t> fmLocal = fmBuf.Get<int8_t>(); | ||
| 344 | + | ||
| 345 | + TBuf<TPosition::B2> filterBuf; | ||
| 346 | + tpipe.InitBuffer(filterBuf, 512 * sizeof(int8_t)); | ||
| 347 | + LocalTensor<int8_t> filterLocal = filterBuf.Get<int8_t>(); | ||
| 348 | + | ||
| 349 | + MmadParams mmadParams; | ||
| 350 | + mmadParams.m = 16; | ||
| 351 | + mmadParams.n = 16; | ||
| 352 | + mmadParams.k = 64; | ||
| 353 | + mmadParams.unitFlag = false; | ||
| 354 | + mmadParams.kDirectionAlign = 0; | ||
| 355 | + mmadParams.cmatrixSource = false; | ||
| 356 | + mmadParams.cmatrixInitVal = false; | ||
| 357 | + | ||
| 358 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStubForNpuDebug)); | ||
| 359 | + MmadWithSparse(dstLocal, fmLocal, filterLocal, mmadParams); | ||
| 360 | +} | ||
| 361 | + | ||
| 362 | +// fm position not A2 (using B2 instead) | ||
| 363 | +TEST_F(TestMmadWithSparseNpuDebug, FmPositionNotA2) | ||
| 364 | +{ | ||
| 365 | + if ASCEND_IS_AIV { | ||
| 366 | + return; | ||
| 367 | + } | ||
| 368 | + TPipe tpipe; | ||
| 369 | + TBuf<TPosition::CO1> dstBuf; | ||
| 370 | + tpipe.InitBuffer(dstBuf, 256 * sizeof(int32_t)); | ||
| 371 | + LocalTensor<int32_t> dstLocal = dstBuf.Get<int32_t>(); | ||
| 372 | + | ||
| 373 | + TBuf<TPosition::B2> fmBuf; | ||
| 374 | + tpipe.InitBuffer(fmBuf, 1024 * sizeof(int8_t)); | ||
| 375 | + LocalTensor<int8_t> fmLocal = fmBuf.Get<int8_t>(); | ||
| 376 | + | ||
| 377 | + TBuf<TPosition::B2> filterBuf; | ||
| 378 | + tpipe.InitBuffer(filterBuf, 512 * sizeof(int8_t)); | ||
| 379 | + LocalTensor<int8_t> filterLocal = filterBuf.Get<int8_t>(); | ||
| 380 | + | ||
| 381 | + MmadParams mmadParams; | ||
| 382 | + mmadParams.m = 16; | ||
| 383 | + mmadParams.n = 16; | ||
| 384 | + mmadParams.k = 64; | ||
| 385 | + mmadParams.unitFlag = false; | ||
| 386 | + mmadParams.kDirectionAlign = 0; | ||
| 387 | + mmadParams.cmatrixSource = false; | ||
| 388 | + mmadParams.cmatrixInitVal = false; | ||
| 389 | + | ||
| 390 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStubForNpuDebug)); | ||
| 391 | + MmadWithSparse(dstLocal, fmLocal, filterLocal, mmadParams); | ||
| 392 | +} | ||
| 393 | + | ||
| 394 | +// filter position not B2 (using A2 instead) | ||
| 395 | +TEST_F(TestMmadWithSparseNpuDebug, FilterPositionNotB2) | ||
| 396 | +{ | ||
| 397 | + if ASCEND_IS_AIV { | ||
| 398 | + return; | ||
| 399 | + } | ||
| 400 | + TPipe tpipe; | ||
| 401 | + TBuf<TPosition::CO1> dstBuf; | ||
| 402 | + tpipe.InitBuffer(dstBuf, 256 * sizeof(int32_t)); | ||
| 403 | + LocalTensor<int32_t> dstLocal = dstBuf.Get<int32_t>(); | ||
| 404 | + | ||
| 405 | + TBuf<TPosition::A2> fmBuf; | ||
| 406 | + tpipe.InitBuffer(fmBuf, 1024 * sizeof(int8_t)); | ||
| 407 | + LocalTensor<int8_t> fmLocal = fmBuf.Get<int8_t>(); | ||
| 408 | + | ||
| 409 | + TBuf<TPosition::A2> filterBuf; | ||
| 410 | + tpipe.InitBuffer(filterBuf, 512 * sizeof(int8_t)); | ||
| 411 | + LocalTensor<int8_t> filterLocal = filterBuf.Get<int8_t>(); | ||
| 412 | + | ||
| 413 | + MmadParams mmadParams; | ||
| 414 | + mmadParams.m = 16; | ||
| 415 | + mmadParams.n = 16; | ||
| 416 | + mmadParams.k = 64; | ||
| 417 | + mmadParams.unitFlag = false; | ||
| 418 | + mmadParams.kDirectionAlign = 0; | ||
| 419 | + mmadParams.cmatrixSource = false; | ||
| 420 | + mmadParams.cmatrixInitVal = false; | ||
| 421 | + | ||
| 422 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStubForNpuDebug)); | ||
| 423 | + MmadWithSparse(dstLocal, fmLocal, filterLocal, mmadParams); | ||
| 191 | } | 424 | } |
Mtests/api/basic_api/ascendc_case_ascend910b1/ascendc_case_ascend910b1_aiv/test_loaddata_check.cpp+826-0
| @@ -333,3 +333,829 @@ TEST_P(TestLoaddata3dv2ApiCheckSuite, Loaddata3dv2ApiCheckAllHighLevel) | |||
| 333 | 333 | ||
| 334 | // EXPECT_EQ(flag, param.expect); | 334 | // EXPECT_EQ(flag, param.expect); |
| 335 | } | 335 | } |
| 336 | + | ||
| 337 | +// ============================================================ | ||
| 338 | +// LoadData3DParamsV1 NPU Debug validation - negative test cases | ||
| 339 | +// Validation: dtype (uint8_t/int8_t/half), src position (L1), src alignment (32B), | ||
| 340 | +// dst alignment (512B if L0A/L0B, 32B if UB), | ||
| 341 | +// parameter ranges: l1H, l1W, c1Index, fetchFilterW/H, leftTopW/H, | ||
| 342 | +// strideW/H, filterW/H, dilationFilterW/H, jumpStride, repeatMode, cSize, repeatTime | ||
| 343 | +// ============================================================ | ||
| 344 | + | ||
| 345 | +class TestLoadData3dv1NpuDebug : public testing::Test { | ||
| 346 | +protected: | ||
| 347 | + void SetUp() | ||
| 348 | + { | ||
| 349 | + AscendC::SetGCoreType(2); | ||
| 350 | + } | ||
| 351 | + void TearDown() | ||
| 352 | + { | ||
| 353 | + AscendC::CheckSyncState(); | ||
| 354 | + AscendC::SetGCoreType(0); | ||
| 355 | + GlobalMockObject::verify(); | ||
| 356 | + } | ||
| 357 | +}; | ||
| 358 | + | ||
| 359 | +// src position not L1 (using A2 instead) | ||
| 360 | +TEST_F(TestLoadData3dv1NpuDebug, SrcPositionNotL1) | ||
| 361 | +{ | ||
| 362 | + TPipe tpipe; | ||
| 363 | + TBuf<TPosition::A2> srcBuf; | ||
| 364 | + tpipe.InitBuffer(srcBuf, 4096 * sizeof(half)); | ||
| 365 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 366 | + | ||
| 367 | + TBuf<TPosition::A2> dstBuf; | ||
| 368 | + tpipe.InitBuffer(dstBuf, 4096 * sizeof(half)); | ||
| 369 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 370 | + | ||
| 371 | + LoadData3DParamsV1<half> params; | ||
| 372 | + params.padList[0] = 0; | ||
| 373 | + params.padList[1] = 0; | ||
| 374 | + params.padList[2] = 0; | ||
| 375 | + params.padList[3] = 0; | ||
| 376 | + params.l1H = 2; | ||
| 377 | + params.l1W = 56; | ||
| 378 | + params.c1Index = 0; | ||
| 379 | + params.fetchFilterW = 0; | ||
| 380 | + params.fetchFilterH = 0; | ||
| 381 | + params.leftTopW = 0; | ||
| 382 | + params.leftTopH = 0; | ||
| 383 | + params.strideW = 1; | ||
| 384 | + params.strideH = 1; | ||
| 385 | + params.filterW = 1; | ||
| 386 | + params.filterH = 1; | ||
| 387 | + params.dilationFilterW = 1; | ||
| 388 | + params.dilationFilterH = 1; | ||
| 389 | + params.jumpStride = 1; | ||
| 390 | + params.repeatMode = 0; | ||
| 391 | + params.repeatTime = 1; | ||
| 392 | + params.cSize = 0; | ||
| 393 | + params.padValue = 0; | ||
| 394 | + | ||
| 395 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 396 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 397 | +} | ||
| 398 | + | ||
| 399 | +// repeatTimes=0 (below MIN_LOAD3D_REPEAT_TIMES=1) | ||
| 400 | +TEST_F(TestLoadData3dv1NpuDebug, RepeatTimesUnderflow) | ||
| 401 | +{ | ||
| 402 | + TPipe tpipe; | ||
| 403 | + TBuf<TPosition::A1> srcBuf; | ||
| 404 | + tpipe.InitBuffer(srcBuf, 4096 * sizeof(half)); | ||
| 405 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 406 | + | ||
| 407 | + TBuf<TPosition::A2> dstBuf; | ||
| 408 | + tpipe.InitBuffer(dstBuf, 4096 * sizeof(half)); | ||
| 409 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 410 | + | ||
| 411 | + LoadData3DParamsV1<half> params; | ||
| 412 | + params.padList[0] = 0; | ||
| 413 | + params.padList[1] = 0; | ||
| 414 | + params.padList[2] = 0; | ||
| 415 | + params.padList[3] = 0; | ||
| 416 | + params.l1H = 2; | ||
| 417 | + params.l1W = 56; | ||
| 418 | + params.c1Index = 0; | ||
| 419 | + params.fetchFilterW = 0; | ||
| 420 | + params.fetchFilterH = 0; | ||
| 421 | + params.leftTopW = 0; | ||
| 422 | + params.leftTopH = 0; | ||
| 423 | + params.strideW = 1; | ||
| 424 | + params.strideH = 1; | ||
| 425 | + params.filterW = 1; | ||
| 426 | + params.filterH = 1; | ||
| 427 | + params.dilationFilterW = 1; | ||
| 428 | + params.dilationFilterH = 1; | ||
| 429 | + params.jumpStride = 1; | ||
| 430 | + params.repeatMode = 0; | ||
| 431 | + params.repeatTime = 0; // below min=1 | ||
| 432 | + params.cSize = 0; | ||
| 433 | + params.padValue = 0; | ||
| 434 | + | ||
| 435 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 436 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 437 | +} | ||
| 438 | + | ||
| 439 | +// l1H=0 (below MIN_LOAD3D_L1=1) | ||
| 440 | +TEST_F(TestLoadData3dv1NpuDebug, L1HUnderflow) | ||
| 441 | +{ | ||
| 442 | + TPipe tpipe; | ||
| 443 | + TBuf<TPosition::A1> srcBuf; | ||
| 444 | + tpipe.InitBuffer(srcBuf, 4096 * sizeof(half)); | ||
| 445 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 446 | + | ||
| 447 | + TBuf<TPosition::A2> dstBuf; | ||
| 448 | + tpipe.InitBuffer(dstBuf, 4096 * sizeof(half)); | ||
| 449 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 450 | + | ||
| 451 | + LoadData3DParamsV1<half> params; | ||
| 452 | + params.padList[0] = 0; | ||
| 453 | + params.padList[1] = 0; | ||
| 454 | + params.padList[2] = 0; | ||
| 455 | + params.padList[3] = 0; | ||
| 456 | + params.l1H = 0; // below min=1 | ||
| 457 | + params.l1W = 56; | ||
| 458 | + params.c1Index = 0; | ||
| 459 | + params.fetchFilterW = 0; | ||
| 460 | + params.fetchFilterH = 0; | ||
| 461 | + params.leftTopW = 0; | ||
| 462 | + params.leftTopH = 0; | ||
| 463 | + params.strideW = 1; | ||
| 464 | + params.strideH = 1; | ||
| 465 | + params.filterW = 1; | ||
| 466 | + params.filterH = 1; | ||
| 467 | + params.dilationFilterW = 1; | ||
| 468 | + params.dilationFilterH = 1; | ||
| 469 | + params.jumpStride = 1; | ||
| 470 | + params.repeatMode = 0; | ||
| 471 | + params.repeatTime = 1; | ||
| 472 | + params.cSize = 0; | ||
| 473 | + params.padValue = 0; | ||
| 474 | + | ||
| 475 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 476 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 477 | +} | ||
| 478 | + | ||
| 479 | +// repeatMode=2 (exceeds [0, 1]) | ||
| 480 | +TEST_F(TestLoadData3dv1NpuDebug, RepeatModeOverflow) | ||
| 481 | +{ | ||
| 482 | + TPipe tpipe; | ||
| 483 | + TBuf<TPosition::A1> srcBuf; | ||
| 484 | + tpipe.InitBuffer(srcBuf, 4096 * sizeof(half)); | ||
| 485 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 486 | + | ||
| 487 | + TBuf<TPosition::A2> dstBuf; | ||
| 488 | + tpipe.InitBuffer(dstBuf, 4096 * sizeof(half)); | ||
| 489 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 490 | + | ||
| 491 | + LoadData3DParamsV1<half> params; | ||
| 492 | + params.padList[0] = 0; | ||
| 493 | + params.padList[1] = 0; | ||
| 494 | + params.padList[2] = 0; | ||
| 495 | + params.padList[3] = 0; | ||
| 496 | + params.l1H = 2; | ||
| 497 | + params.l1W = 56; | ||
| 498 | + params.c1Index = 0; | ||
| 499 | + params.fetchFilterW = 0; | ||
| 500 | + params.fetchFilterH = 0; | ||
| 501 | + params.leftTopW = 0; | ||
| 502 | + params.leftTopH = 0; | ||
| 503 | + params.strideW = 1; | ||
| 504 | + params.strideH = 1; | ||
| 505 | + params.filterW = 1; | ||
| 506 | + params.filterH = 1; | ||
| 507 | + params.dilationFilterW = 1; | ||
| 508 | + params.dilationFilterH = 1; | ||
| 509 | + params.jumpStride = 1; | ||
| 510 | + params.repeatMode = 2; // exceeds [0, 1] | ||
| 511 | + params.repeatTime = 1; | ||
| 512 | + params.cSize = 0; | ||
| 513 | + params.padValue = 0; | ||
| 514 | + | ||
| 515 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 516 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 517 | +} | ||
| 518 | + | ||
| 519 | +// strideW=0 (below MIN_LOAD3D_STRIDE=1) | ||
| 520 | +TEST_F(TestLoadData3dv1NpuDebug, StrideWUnderflow) | ||
| 521 | +{ | ||
| 522 | + TPipe tpipe; | ||
| 523 | + TBuf<TPosition::A1> srcBuf; | ||
| 524 | + tpipe.InitBuffer(srcBuf, 4096 * sizeof(half)); | ||
| 525 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 526 | + | ||
| 527 | + TBuf<TPosition::A2> dstBuf; | ||
| 528 | + tpipe.InitBuffer(dstBuf, 4096 * sizeof(half)); | ||
| 529 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 530 | + | ||
| 531 | + LoadData3DParamsV1<half> params; | ||
| 532 | + params.padList[0] = 0; | ||
| 533 | + params.padList[1] = 0; | ||
| 534 | + params.padList[2] = 0; | ||
| 535 | + params.padList[3] = 0; | ||
| 536 | + params.l1H = 2; | ||
| 537 | + params.l1W = 56; | ||
| 538 | + params.c1Index = 0; | ||
| 539 | + params.fetchFilterW = 0; | ||
| 540 | + params.fetchFilterH = 0; | ||
| 541 | + params.leftTopW = 0; | ||
| 542 | + params.leftTopH = 0; | ||
| 543 | + params.strideW = 0; // below min=1 | ||
| 544 | + params.strideH = 1; | ||
| 545 | + params.filterW = 1; | ||
| 546 | + params.filterH = 1; | ||
| 547 | + params.dilationFilterW = 1; | ||
| 548 | + params.dilationFilterH = 1; | ||
| 549 | + params.jumpStride = 1; | ||
| 550 | + params.repeatMode = 0; | ||
| 551 | + params.repeatTime = 1; | ||
| 552 | + params.cSize = 0; | ||
| 553 | + params.padValue = 0; | ||
| 554 | + | ||
| 555 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 556 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 557 | +} | ||
| 558 | + | ||
| 559 | +// l1W=0 (below MIN_LOAD3D_L1=1) | ||
| 560 | +TEST_F(TestLoadData3dv1NpuDebug, L1WUnderflow) | ||
| 561 | +{ | ||
| 562 | + TPipe tpipe; | ||
| 563 | + TBuf<TPosition::A1> srcBuf; | ||
| 564 | + tpipe.InitBuffer(srcBuf, 4096 * sizeof(half)); | ||
| 565 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 566 | + | ||
| 567 | + TBuf<TPosition::A2> dstBuf; | ||
| 568 | + tpipe.InitBuffer(dstBuf, 4096 * sizeof(half)); | ||
| 569 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 570 | + | ||
| 571 | + LoadData3DParamsV1<half> params; | ||
| 572 | + params.padList[0] = 0; | ||
| 573 | + params.padList[1] = 0; | ||
| 574 | + params.padList[2] = 0; | ||
| 575 | + params.padList[3] = 0; | ||
| 576 | + params.l1H = 2; | ||
| 577 | + params.l1W = 0; // below min=1 | ||
| 578 | + params.c1Index = 0; | ||
| 579 | + params.fetchFilterW = 0; | ||
| 580 | + params.fetchFilterH = 0; | ||
| 581 | + params.leftTopW = 0; | ||
| 582 | + params.leftTopH = 0; | ||
| 583 | + params.strideW = 1; | ||
| 584 | + params.strideH = 1; | ||
| 585 | + params.filterW = 1; | ||
| 586 | + params.filterH = 1; | ||
| 587 | + params.dilationFilterW = 1; | ||
| 588 | + params.dilationFilterH = 1; | ||
| 589 | + params.jumpStride = 1; | ||
| 590 | + params.repeatMode = 0; | ||
| 591 | + params.repeatTime = 1; | ||
| 592 | + params.cSize = 0; | ||
| 593 | + params.padValue = 0; | ||
| 594 | + | ||
| 595 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 596 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 597 | +} | ||
| 598 | + | ||
| 599 | +// c1Index=4096 (exceeds MAX_LOAD3D_C1_IDX=4095) | ||
| 600 | +TEST_F(TestLoadData3dv1NpuDebug, C1IndexOverflow) | ||
| 601 | +{ | ||
| 602 | + TPipe tpipe; | ||
| 603 | + TBuf<TPosition::A1> srcBuf; | ||
| 604 | + tpipe.InitBuffer(srcBuf, 4096 * sizeof(half)); | ||
| 605 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 606 | + | ||
| 607 | + TBuf<TPosition::A2> dstBuf; | ||
| 608 | + tpipe.InitBuffer(dstBuf, 4096 * sizeof(half)); | ||
| 609 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 610 | + | ||
| 611 | + LoadData3DParamsV1<half> params; | ||
| 612 | + params.padList[0] = 0; | ||
| 613 | + params.padList[1] = 0; | ||
| 614 | + params.padList[2] = 0; | ||
| 615 | + params.padList[3] = 0; | ||
| 616 | + params.l1H = 2; | ||
| 617 | + params.l1W = 56; | ||
| 618 | + params.c1Index = 4096; // exceeds max=4095 | ||
| 619 | + params.fetchFilterW = 0; | ||
| 620 | + params.fetchFilterH = 0; | ||
| 621 | + params.leftTopW = 0; | ||
| 622 | + params.leftTopH = 0; | ||
| 623 | + params.strideW = 1; | ||
| 624 | + params.strideH = 1; | ||
| 625 | + params.filterW = 1; | ||
| 626 | + params.filterH = 1; | ||
| 627 | + params.dilationFilterW = 1; | ||
| 628 | + params.dilationFilterH = 1; | ||
| 629 | + params.jumpStride = 1; | ||
| 630 | + params.repeatMode = 0; | ||
| 631 | + params.repeatTime = 1; | ||
| 632 | + params.cSize = 0; | ||
| 633 | + params.padValue = 0; | ||
| 634 | + | ||
| 635 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 636 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 637 | +} | ||
| 638 | + | ||
| 639 | +// filterW=0 (below MIN_LOAD3D_FILTER=1) | ||
| 640 | +TEST_F(TestLoadData3dv1NpuDebug, FilterWUnderflow) | ||
| 641 | +{ | ||
| 642 | + TPipe tpipe; | ||
| 643 | + TBuf<TPosition::A1> srcBuf; | ||
| 644 | + tpipe.InitBuffer(srcBuf, 4096 * sizeof(half)); | ||
| 645 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 646 | + | ||
| 647 | + TBuf<TPosition::A2> dstBuf; | ||
| 648 | + tpipe.InitBuffer(dstBuf, 4096 * sizeof(half)); | ||
| 649 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 650 | + | ||
| 651 | + LoadData3DParamsV1<half> params; | ||
| 652 | + params.padList[0] = 0; | ||
| 653 | + params.padList[1] = 0; | ||
| 654 | + params.padList[2] = 0; | ||
| 655 | + params.padList[3] = 0; | ||
| 656 | + params.l1H = 2; | ||
| 657 | + params.l1W = 56; | ||
| 658 | + params.c1Index = 0; | ||
| 659 | + params.fetchFilterW = 0; | ||
| 660 | + params.fetchFilterH = 0; | ||
| 661 | + params.leftTopW = 0; | ||
| 662 | + params.leftTopH = 0; | ||
| 663 | + params.strideW = 1; | ||
| 664 | + params.strideH = 1; | ||
| 665 | + params.filterW = 0; // below min=1 | ||
| 666 | + params.filterH = 1; | ||
| 667 | + params.dilationFilterW = 1; | ||
| 668 | + params.dilationFilterH = 1; | ||
| 669 | + params.jumpStride = 1; | ||
| 670 | + params.repeatMode = 0; | ||
| 671 | + params.repeatTime = 1; | ||
| 672 | + params.cSize = 0; | ||
| 673 | + params.padValue = 0; | ||
| 674 | + | ||
| 675 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 676 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 677 | +} | ||
| 678 | + | ||
| 679 | +// dilationFilterW=0 (below MIN_LOAD3D_DILATION_FILTER=1) | ||
| 680 | +TEST_F(TestLoadData3dv1NpuDebug, DilationFilterWUnderflow) | ||
| 681 | +{ | ||
| 682 | + TPipe tpipe; | ||
| 683 | + TBuf<TPosition::A1> srcBuf; | ||
| 684 | + tpipe.InitBuffer(srcBuf, 4096 * sizeof(half)); | ||
| 685 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 686 | + | ||
| 687 | + TBuf<TPosition::A2> dstBuf; | ||
| 688 | + tpipe.InitBuffer(dstBuf, 4096 * sizeof(half)); | ||
| 689 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 690 | + | ||
| 691 | + LoadData3DParamsV1<half> params; | ||
| 692 | + params.padList[0] = 0; | ||
| 693 | + params.padList[1] = 0; | ||
| 694 | + params.padList[2] = 0; | ||
| 695 | + params.padList[3] = 0; | ||
| 696 | + params.l1H = 2; | ||
| 697 | + params.l1W = 56; | ||
| 698 | + params.c1Index = 0; | ||
| 699 | + params.fetchFilterW = 0; | ||
| 700 | + params.fetchFilterH = 0; | ||
| 701 | + params.leftTopW = 0; | ||
| 702 | + params.leftTopH = 0; | ||
| 703 | + params.strideW = 1; | ||
| 704 | + params.strideH = 1; | ||
| 705 | + params.filterW = 1; | ||
| 706 | + params.filterH = 1; | ||
| 707 | + params.dilationFilterW = 0; // below min=1 | ||
| 708 | + params.dilationFilterH = 1; | ||
| 709 | + params.jumpStride = 1; | ||
| 710 | + params.repeatMode = 0; | ||
| 711 | + params.repeatTime = 1; | ||
| 712 | + params.cSize = 0; | ||
| 713 | + params.padValue = 0; | ||
| 714 | + | ||
| 715 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 716 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 717 | +} | ||
| 718 | + | ||
| 719 | +// jumpStride=0 (below MIN_LOAD3D_JUMP_STRIDE=1) | ||
| 720 | +TEST_F(TestLoadData3dv1NpuDebug, JumpStrideUnderflow) | ||
| 721 | +{ | ||
| 722 | + TPipe tpipe; | ||
| 723 | + TBuf<TPosition::A1> srcBuf; | ||
| 724 | + tpipe.InitBuffer(srcBuf, 4096 * sizeof(half)); | ||
| 725 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 726 | + | ||
| 727 | + TBuf<TPosition::A2> dstBuf; | ||
| 728 | + tpipe.InitBuffer(dstBuf, 4096 * sizeof(half)); | ||
| 729 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 730 | + | ||
| 731 | + LoadData3DParamsV1<half> params; | ||
| 732 | + params.padList[0] = 0; | ||
| 733 | + params.padList[1] = 0; | ||
| 734 | + params.padList[2] = 0; | ||
| 735 | + params.padList[3] = 0; | ||
| 736 | + params.l1H = 2; | ||
| 737 | + params.l1W = 56; | ||
| 738 | + params.c1Index = 0; | ||
| 739 | + params.fetchFilterW = 0; | ||
| 740 | + params.fetchFilterH = 0; | ||
| 741 | + params.leftTopW = 0; | ||
| 742 | + params.leftTopH = 0; | ||
| 743 | + params.strideW = 1; | ||
| 744 | + params.strideH = 1; | ||
| 745 | + params.filterW = 1; | ||
| 746 | + params.filterH = 1; | ||
| 747 | + params.dilationFilterW = 1; | ||
| 748 | + params.dilationFilterH = 1; | ||
| 749 | + params.jumpStride = 0; // below min=1 | ||
| 750 | + params.repeatMode = 0; | ||
| 751 | + params.repeatTime = 1; | ||
| 752 | + params.cSize = 0; | ||
| 753 | + params.padValue = 0; | ||
| 754 | + | ||
| 755 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 756 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 757 | +} | ||
| 758 | + | ||
| 759 | +// cSize=2 (exceeds [0, 1]) | ||
| 760 | +TEST_F(TestLoadData3dv1NpuDebug, CSizeOverflow) | ||
| 761 | +{ | ||
| 762 | + TPipe tpipe; | ||
| 763 | + TBuf<TPosition::A1> srcBuf; | ||
| 764 | + tpipe.InitBuffer(srcBuf, 4096 * sizeof(half)); | ||
| 765 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 766 | + | ||
| 767 | + TBuf<TPosition::A2> dstBuf; | ||
| 768 | + tpipe.InitBuffer(dstBuf, 4096 * sizeof(half)); | ||
| 769 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 770 | + | ||
| 771 | + LoadData3DParamsV1<half> params; | ||
| 772 | + params.padList[0] = 0; | ||
| 773 | + params.padList[1] = 0; | ||
| 774 | + params.padList[2] = 0; | ||
| 775 | + params.padList[3] = 0; | ||
| 776 | + params.l1H = 2; | ||
| 777 | + params.l1W = 56; | ||
| 778 | + params.c1Index = 0; | ||
| 779 | + params.fetchFilterW = 0; | ||
| 780 | + params.fetchFilterH = 0; | ||
| 781 | + params.leftTopW = 0; | ||
| 782 | + params.leftTopH = 0; | ||
| 783 | + params.strideW = 1; | ||
| 784 | + params.strideH = 1; | ||
| 785 | + params.filterW = 1; | ||
| 786 | + params.filterH = 1; | ||
| 787 | + params.dilationFilterW = 1; | ||
| 788 | + params.dilationFilterH = 1; | ||
| 789 | + params.jumpStride = 1; | ||
| 790 | + params.repeatMode = 0; | ||
| 791 | + params.repeatTime = 1; | ||
| 792 | + params.cSize = 2; // exceeds [0, 1] | ||
| 793 | + params.padValue = 0; | ||
| 794 | + | ||
| 795 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 796 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 797 | +} | ||
| 798 | + | ||
| 799 | +// ============================================================ | ||
| 800 | +// LoadData3DParamsV2 NPU Debug validation - negative test cases | ||
| 801 | +// Validation: src position (L1), src alignment (32B), dst alignment (512B if L0A/L0B, 32B if UB), | ||
| 802 | +// dtype based on dst position (A2 vs B2), | ||
| 803 | +// parameter ranges: l1H, l1W, kExtension, mExtension, kStartPt, mStartPt, | ||
| 804 | +// strideW/H, filterW/H, dilationFilterW/H, channelSize, enTranspose, enSmallK | ||
| 805 | +// ============================================================ | ||
| 806 | + | ||
| 807 | +class TestLoadData3dv2NpuDebug : public testing::Test { | ||
| 808 | +protected: | ||
| 809 | + void SetUp() | ||
| 810 | + { | ||
| 811 | + AscendC::SetGCoreType(2); | ||
| 812 | + } | ||
| 813 | + void TearDown() | ||
| 814 | + { | ||
| 815 | + AscendC::CheckSyncState(); | ||
| 816 | + AscendC::SetGCoreType(0); | ||
| 817 | + GlobalMockObject::verify(); | ||
| 818 | + } | ||
| 819 | +}; | ||
| 820 | + | ||
| 821 | +// src position not L1 (using A2 instead) | ||
| 822 | +TEST_F(TestLoadData3dv2NpuDebug, SrcPositionNotL1) | ||
| 823 | +{ | ||
| 824 | + TPipe tpipe; | ||
| 825 | + TBuf<TPosition::A2> srcBuf; | ||
| 826 | + tpipe.InitBuffer(srcBuf, 8192 * sizeof(half)); | ||
| 827 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 828 | + | ||
| 829 | + TBuf<TPosition::A2> dstBuf; | ||
| 830 | + tpipe.InitBuffer(dstBuf, 8192 * sizeof(half)); | ||
| 831 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 832 | + | ||
| 833 | + LoadData3DParamsV2<half> params; | ||
| 834 | + params.padList[0] = 0; | ||
| 835 | + params.padList[1] = 0; | ||
| 836 | + params.padList[2] = 0; | ||
| 837 | + params.padList[3] = 0; | ||
| 838 | + params.l1H = 12; | ||
| 839 | + params.l1W = 16; | ||
| 840 | + params.channelSize = 32; | ||
| 841 | + params.kExtension = 32; | ||
| 842 | + params.mExtension = 192; | ||
| 843 | + params.kStartPt = 0; | ||
| 844 | + params.mStartPt = 0; | ||
| 845 | + params.strideW = 1; | ||
| 846 | + params.strideH = 1; | ||
| 847 | + params.filterW = 1; | ||
| 848 | + params.filterH = 1; | ||
| 849 | + params.dilationFilterW = 1; | ||
| 850 | + params.dilationFilterH = 1; | ||
| 851 | + params.enTranspose = false; | ||
| 852 | + params.enSmallK = false; | ||
| 853 | + params.padValue = 0; | ||
| 854 | + | ||
| 855 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 856 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 857 | +} | ||
| 858 | + | ||
| 859 | +// l1H=0 (below MIN_LOAD3D_L1=1) | ||
| 860 | +TEST_F(TestLoadData3dv2NpuDebug, L1HUnderflow) | ||
| 861 | +{ | ||
| 862 | + TPipe tpipe; | ||
| 863 | + TBuf<TPosition::A1> srcBuf; | ||
| 864 | + tpipe.InitBuffer(srcBuf, 8192 * sizeof(half)); | ||
| 865 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 866 | + | ||
| 867 | + TBuf<TPosition::A2> dstBuf; | ||
| 868 | + tpipe.InitBuffer(dstBuf, 8192 * sizeof(half)); | ||
| 869 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 870 | + | ||
| 871 | + LoadData3DParamsV2<half> params; | ||
| 872 | + params.padList[0] = 0; | ||
| 873 | + params.padList[1] = 0; | ||
| 874 | + params.padList[2] = 0; | ||
| 875 | + params.padList[3] = 0; | ||
| 876 | + params.l1H = 0; // below min=1 | ||
| 877 | + params.l1W = 16; | ||
| 878 | + params.channelSize = 32; | ||
| 879 | + params.kExtension = 32; | ||
| 880 | + params.mExtension = 192; | ||
| 881 | + params.kStartPt = 0; | ||
| 882 | + params.mStartPt = 0; | ||
| 883 | + params.strideW = 1; | ||
| 884 | + params.strideH = 1; | ||
| 885 | + params.filterW = 1; | ||
| 886 | + params.filterH = 1; | ||
| 887 | + params.dilationFilterW = 1; | ||
| 888 | + params.dilationFilterH = 1; | ||
| 889 | + params.enTranspose = false; | ||
| 890 | + params.enSmallK = false; | ||
| 891 | + params.padValue = 0; | ||
| 892 | + | ||
| 893 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 894 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 895 | +} | ||
| 896 | + | ||
| 897 | +// kExtension=0 (below MIN_LOAD3D_EXTENSION=1) | ||
| 898 | +TEST_F(TestLoadData3dv2NpuDebug, KExtensionUnderflow) | ||
| 899 | +{ | ||
| 900 | + TPipe tpipe; | ||
| 901 | + TBuf<TPosition::A1> srcBuf; | ||
| 902 | + tpipe.InitBuffer(srcBuf, 8192 * sizeof(half)); | ||
| 903 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 904 | + | ||
| 905 | + TBuf<TPosition::A2> dstBuf; | ||
| 906 | + tpipe.InitBuffer(dstBuf, 8192 * sizeof(half)); | ||
| 907 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 908 | + | ||
| 909 | + LoadData3DParamsV2<half> params; | ||
| 910 | + params.padList[0] = 0; | ||
| 911 | + params.padList[1] = 0; | ||
| 912 | + params.padList[2] = 0; | ||
| 913 | + params.padList[3] = 0; | ||
| 914 | + params.l1H = 12; | ||
| 915 | + params.l1W = 16; | ||
| 916 | + params.channelSize = 32; | ||
| 917 | + params.kExtension = 0; // below min=1 | ||
| 918 | + params.mExtension = 192; | ||
| 919 | + params.kStartPt = 0; | ||
| 920 | + params.mStartPt = 0; | ||
| 921 | + params.strideW = 1; | ||
| 922 | + params.strideH = 1; | ||
| 923 | + params.filterW = 1; | ||
| 924 | + params.filterH = 1; | ||
| 925 | + params.dilationFilterW = 1; | ||
| 926 | + params.dilationFilterH = 1; | ||
| 927 | + params.enTranspose = false; | ||
| 928 | + params.enSmallK = false; | ||
| 929 | + params.padValue = 0; | ||
| 930 | + | ||
| 931 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 932 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 933 | +} | ||
| 934 | + | ||
| 935 | +// strideW=0 (below MIN_LOAD3D_STRIDE=1) | ||
| 936 | +TEST_F(TestLoadData3dv2NpuDebug, StrideWUnderflow) | ||
| 937 | +{ | ||
| 938 | + TPipe tpipe; | ||
| 939 | + TBuf<TPosition::A1> srcBuf; | ||
| 940 | + tpipe.InitBuffer(srcBuf, 8192 * sizeof(half)); | ||
| 941 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 942 | + | ||
| 943 | + TBuf<TPosition::A2> dstBuf; | ||
| 944 | + tpipe.InitBuffer(dstBuf, 8192 * sizeof(half)); | ||
| 945 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 946 | + | ||
| 947 | + LoadData3DParamsV2<half> params; | ||
| 948 | + params.padList[0] = 0; | ||
| 949 | + params.padList[1] = 0; | ||
| 950 | + params.padList[2] = 0; | ||
| 951 | + params.padList[3] = 0; | ||
| 952 | + params.l1H = 12; | ||
| 953 | + params.l1W = 16; | ||
| 954 | + params.channelSize = 32; | ||
| 955 | + params.kExtension = 32; | ||
| 956 | + params.mExtension = 192; | ||
| 957 | + params.kStartPt = 0; | ||
| 958 | + params.mStartPt = 0; | ||
| 959 | + params.strideW = 0; // below min=1 | ||
| 960 | + params.strideH = 1; | ||
| 961 | + params.filterW = 1; | ||
| 962 | + params.filterH = 1; | ||
| 963 | + params.dilationFilterW = 1; | ||
| 964 | + params.dilationFilterH = 1; | ||
| 965 | + params.enTranspose = false; | ||
| 966 | + params.enSmallK = false; | ||
| 967 | + params.padValue = 0; | ||
| 968 | + | ||
| 969 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 970 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 971 | +} | ||
| 972 | + | ||
| 973 | +// dst on B2 with int8_t type (B2 only supports half/bfloat16_t/float/uint32_t/int32_t, not int8_t) | ||
| 974 | +TEST_F(TestLoadData3dv2NpuDebug, DstB2InvalidDtypeInt8) | ||
| 975 | +{ | ||
| 976 | + TPipe tpipe; | ||
| 977 | + TBuf<TPosition::B1> srcBuf; | ||
| 978 | + tpipe.InitBuffer(srcBuf, 8192 * sizeof(int8_t)); | ||
| 979 | + LocalTensor<int8_t> srcLocal = srcBuf.Get<int8_t>(); | ||
| 980 | + | ||
| 981 | + TBuf<TPosition::B2> dstBuf; | ||
| 982 | + tpipe.InitBuffer(dstBuf, 8192 * sizeof(int8_t)); | ||
| 983 | + LocalTensor<int8_t> dstLocal = dstBuf.Get<int8_t>(); | ||
| 984 | + | ||
| 985 | + LoadData3DParamsV2<int8_t> params; | ||
| 986 | + params.padList[0] = 0; | ||
| 987 | + params.padList[1] = 0; | ||
| 988 | + params.padList[2] = 0; | ||
| 989 | + params.padList[3] = 0; | ||
| 990 | + params.l1H = 12; | ||
| 991 | + params.l1W = 16; | ||
| 992 | + params.channelSize = 32; | ||
| 993 | + params.kExtension = 32; | ||
| 994 | + params.mExtension = 192; | ||
| 995 | + params.kStartPt = 0; | ||
| 996 | + params.mStartPt = 0; | ||
| 997 | + params.strideW = 1; | ||
| 998 | + params.strideH = 1; | ||
| 999 | + params.filterW = 1; | ||
| 1000 | + params.filterH = 1; | ||
| 1001 | + params.dilationFilterW = 1; | ||
| 1002 | + params.dilationFilterH = 1; | ||
| 1003 | + params.enTranspose = false; | ||
| 1004 | + params.enSmallK = false; | ||
| 1005 | + params.padValue = 0; | ||
| 1006 | + | ||
| 1007 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 1008 | + LoadData<int8_t>(dstLocal, srcLocal, params); | ||
| 1009 | +} | ||
| 1010 | + | ||
| 1011 | +// l1W=0 (below MIN_LOAD3D_L1=1) | ||
| 1012 | +TEST_F(TestLoadData3dv2NpuDebug, L1WUnderflow) | ||
| 1013 | +{ | ||
| 1014 | + TPipe tpipe; | ||
| 1015 | + TBuf<TPosition::A1> srcBuf; | ||
| 1016 | + tpipe.InitBuffer(srcBuf, 8192 * sizeof(half)); | ||
| 1017 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 1018 | + | ||
| 1019 | + TBuf<TPosition::A2> dstBuf; | ||
| 1020 | + tpipe.InitBuffer(dstBuf, 8192 * sizeof(half)); | ||
| 1021 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 1022 | + | ||
| 1023 | + LoadData3DParamsV2<half> params; | ||
| 1024 | + params.padList[0] = 0; | ||
| 1025 | + params.padList[1] = 0; | ||
| 1026 | + params.padList[2] = 0; | ||
| 1027 | + params.padList[3] = 0; | ||
| 1028 | + params.l1H = 12; | ||
| 1029 | + params.l1W = 0; // below min=1 | ||
| 1030 | + params.channelSize = 32; | ||
| 1031 | + params.kExtension = 32; | ||
| 1032 | + params.mExtension = 192; | ||
| 1033 | + params.kStartPt = 0; | ||
| 1034 | + params.mStartPt = 0; | ||
| 1035 | + params.strideW = 1; | ||
| 1036 | + params.strideH = 1; | ||
| 1037 | + params.filterW = 1; | ||
| 1038 | + params.filterH = 1; | ||
| 1039 | + params.dilationFilterW = 1; | ||
| 1040 | + params.dilationFilterH = 1; | ||
| 1041 | + params.enTranspose = false; | ||
| 1042 | + params.enSmallK = false; | ||
| 1043 | + params.padValue = 0; | ||
| 1044 | + | ||
| 1045 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 1046 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 1047 | +} | ||
| 1048 | + | ||
| 1049 | +// mExtension=0 (below MIN_LOAD3D_EXTENSION=1) | ||
| 1050 | +TEST_F(TestLoadData3dv2NpuDebug, MExtensionUnderflow) | ||
| 1051 | +{ | ||
| 1052 | + TPipe tpipe; | ||
| 1053 | + TBuf<TPosition::A1> srcBuf; | ||
| 1054 | + tpipe.InitBuffer(srcBuf, 8192 * sizeof(half)); | ||
| 1055 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 1056 | + | ||
| 1057 | + TBuf<TPosition::A2> dstBuf; | ||
| 1058 | + tpipe.InitBuffer(dstBuf, 8192 * sizeof(half)); | ||
| 1059 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 1060 | + | ||
| 1061 | + LoadData3DParamsV2<half> params; | ||
| 1062 | + params.padList[0] = 0; | ||
| 1063 | + params.padList[1] = 0; | ||
| 1064 | + params.padList[2] = 0; | ||
| 1065 | + params.padList[3] = 0; | ||
| 1066 | + params.l1H = 12; | ||
| 1067 | + params.l1W = 16; | ||
| 1068 | + params.channelSize = 32; | ||
| 1069 | + params.kExtension = 32; | ||
| 1070 | + params.mExtension = 0; // below min=1 | ||
| 1071 | + params.kStartPt = 0; | ||
| 1072 | + params.mStartPt = 0; | ||
| 1073 | + params.strideW = 1; | ||
| 1074 | + params.strideH = 1; | ||
| 1075 | + params.filterW = 1; | ||
| 1076 | + params.filterH = 1; | ||
| 1077 | + params.dilationFilterW = 1; | ||
| 1078 | + params.dilationFilterH = 1; | ||
| 1079 | + params.enTranspose = false; | ||
| 1080 | + params.enSmallK = false; | ||
| 1081 | + params.padValue = 0; | ||
| 1082 | + | ||
| 1083 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 1084 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 1085 | +} | ||
| 1086 | + | ||
| 1087 | +// filterW=0 (below MIN_LOAD3D_FILTER=1) | ||
| 1088 | +TEST_F(TestLoadData3dv2NpuDebug, FilterWUnderflow) | ||
| 1089 | +{ | ||
| 1090 | + TPipe tpipe; | ||
| 1091 | + TBuf<TPosition::A1> srcBuf; | ||
| 1092 | + tpipe.InitBuffer(srcBuf, 8192 * sizeof(half)); | ||
| 1093 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 1094 | + | ||
| 1095 | + TBuf<TPosition::A2> dstBuf; | ||
| 1096 | + tpipe.InitBuffer(dstBuf, 8192 * sizeof(half)); | ||
| 1097 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 1098 | + | ||
| 1099 | + LoadData3DParamsV2<half> params; | ||
| 1100 | + params.padList[0] = 0; | ||
| 1101 | + params.padList[1] = 0; | ||
| 1102 | + params.padList[2] = 0; | ||
| 1103 | + params.padList[3] = 0; | ||
| 1104 | + params.l1H = 12; | ||
| 1105 | + params.l1W = 16; | ||
| 1106 | + params.channelSize = 32; | ||
| 1107 | + params.kExtension = 32; | ||
| 1108 | + params.mExtension = 192; | ||
| 1109 | + params.kStartPt = 0; | ||
| 1110 | + params.mStartPt = 0; | ||
| 1111 | + params.strideW = 1; | ||
| 1112 | + params.strideH = 1; | ||
| 1113 | + params.filterW = 0; // below min=1 | ||
| 1114 | + params.filterH = 1; | ||
| 1115 | + params.dilationFilterW = 1; | ||
| 1116 | + params.dilationFilterH = 1; | ||
| 1117 | + params.enTranspose = false; | ||
| 1118 | + params.enSmallK = false; | ||
| 1119 | + params.padValue = 0; | ||
| 1120 | + | ||
| 1121 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 1122 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 1123 | +} | ||
| 1124 | + | ||
| 1125 | +// dilationFilterW=0 (below MIN_LOAD3D_DILATION_FILTER=1) | ||
| 1126 | +TEST_F(TestLoadData3dv2NpuDebug, DilationFilterWUnderflow) | ||
| 1127 | +{ | ||
| 1128 | + TPipe tpipe; | ||
| 1129 | + TBuf<TPosition::A1> srcBuf; | ||
| 1130 | + tpipe.InitBuffer(srcBuf, 8192 * sizeof(half)); | ||
| 1131 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 1132 | + | ||
| 1133 | + TBuf<TPosition::A2> dstBuf; | ||
| 1134 | + tpipe.InitBuffer(dstBuf, 8192 * sizeof(half)); | ||
| 1135 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 1136 | + | ||
| 1137 | + LoadData3DParamsV2<half> params; | ||
| 1138 | + params.padList[0] = 0; | ||
| 1139 | + params.padList[1] = 0; | ||
| 1140 | + params.padList[2] = 0; | ||
| 1141 | + params.padList[3] = 0; | ||
| 1142 | + params.l1H = 12; | ||
| 1143 | + params.l1W = 16; | ||
| 1144 | + params.channelSize = 32; | ||
| 1145 | + params.kExtension = 32; | ||
| 1146 | + params.mExtension = 192; | ||
| 1147 | + params.kStartPt = 0; | ||
| 1148 | + params.mStartPt = 0; | ||
| 1149 | + params.strideW = 1; | ||
| 1150 | + params.strideH = 1; | ||
| 1151 | + params.filterW = 1; | ||
| 1152 | + params.filterH = 1; | ||
| 1153 | + params.dilationFilterW = 0; // below min=1 | ||
| 1154 | + params.dilationFilterH = 1; | ||
| 1155 | + params.enTranspose = false; | ||
| 1156 | + params.enSmallK = false; | ||
| 1157 | + params.padValue = 0; | ||
| 1158 | + | ||
| 1159 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStub)); | ||
| 1160 | + LoadData<half>(dstLocal, srcLocal, params); | ||
| 1161 | +} | ||
Mtests/api/basic_api/ascendc_case_ascend910b1/ascendc_case_ascend910b1_aiv/test_operator_nchwconv.cpp+158-1
| @@ -9,6 +9,7 @@ | |||
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | + | ||
| 12 | 13 | ||
| 13 | using namespace std; | 14 | using namespace std; |
| 14 | using namespace AscendC; | 15 | using namespace AscendC; |
| @@ -110,4 +111,160 @@ TEST_P(NchwconvTestsuite, NchwconvTestCase) | |||
| 110 | for (int i = 0; i < param.dataSize; i++) { | 111 | for (int i = 0; i < param.dataSize; i++) { |
| 111 | EXPECT_EQ(dstGm[i], 0x00); | 112 | EXPECT_EQ(dstGm[i], 0x00); |
| 112 | } | 113 | } |
| 113 | -} | 114 | +} |
| 115 | + | ||
| 116 | +// ============================================================ | ||
| 117 | +// TransDataTo5HD NPU Debug validation - negative test cases | ||
| 118 | +// 3 overloads: | ||
| 119 | +// 1. (LocalTensor<T> (&dstList)[16], LocalTensor<T> (&srcList)[16], TransDataTo5HDParams) | ||
| 120 | +// 2. (uint64_t dstList[16], uint64_t srcList[16], TransDataTo5HDParams) | ||
| 121 | +// 3. (LocalTensor<uint64_t> &dst, LocalTensor<uint64_t> &src, TransDataTo5HDParams) | ||
| 122 | +// Validation: dtype, dstHighHalf/srcHighHalf (only valid for int8_t/uint8_t), | ||
| 123 | +// repeatTimes [0,255], position (UB), alignment (32B) | ||
| 124 | +// ============================================================ | ||
| 125 | + | ||
| 126 | +namespace { | ||
| 127 | +int32_t RaiseStubForNpuDebug(int32_t i) | ||
| 128 | +{ | ||
| 129 | + return 0; | ||
| 130 | +} | ||
| 131 | +} | ||
| 132 | + | ||
| 133 | +class TestTransDataTo5HDNpuDebug : public testing::Test { | ||
| 134 | +protected: | ||
| 135 | + void SetUp() | ||
| 136 | + { | ||
| 137 | + AscendC::SetGCoreType(2); | ||
| 138 | + } | ||
| 139 | + void TearDown() | ||
| 140 | + { | ||
| 141 | + AscendC::CheckSyncState(); | ||
| 142 | + AscendC::SetGCoreType(0); | ||
| 143 | + GlobalMockObject::verify(); | ||
| 144 | + } | ||
| 145 | +}; | ||
| 146 | + | ||
| 147 | +// --- Overload 1: LocalTensor array - dstList position not UB --- | ||
| 148 | +TEST_F(TestTransDataTo5HDNpuDebug, DstListPositionNotUbOverload1) | ||
| 149 | +{ | ||
| 150 | + TPipe tpipe; | ||
| 151 | + LocalTensor<half> dstList[NCHW_CONV_ADDR_LIST_SIZE]; | ||
| 152 | + LocalTensor<half> srcList[NCHW_CONV_ADDR_LIST_SIZE]; | ||
| 153 | + | ||
| 154 | + TBuf<TPosition::A2> dstBuf; | ||
| 155 | + tpipe.InitBuffer(dstBuf, 256 * sizeof(half)); | ||
| 156 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 157 | + | ||
| 158 | + TBuf<TPosition::VECCALC> srcBuf; | ||
| 159 | + tpipe.InitBuffer(srcBuf, 256 * sizeof(half)); | ||
| 160 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 161 | + | ||
| 162 | + for (int i = 0; i < NCHW_CONV_ADDR_LIST_SIZE; i++) { | ||
| 163 | + dstList[i] = dstLocal[16 * i]; | ||
| 164 | + srcList[i] = srcLocal[16 * i]; | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + TransDataTo5HDParams params; | ||
| 168 | + params.dstHighHalf = false; | ||
| 169 | + params.srcHighHalf = false; | ||
| 170 | + params.repeatTimes = 1; | ||
| 171 | + params.dstRepStride = 16; | ||
| 172 | + params.srcRepStride = 16; | ||
| 173 | + | ||
| 174 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStubForNpuDebug)); | ||
| 175 | + TransDataTo5HD<half>(dstList, srcList, params); | ||
| 176 | +} | ||
| 177 | + | ||
| 178 | +// --- Overload 1: LocalTensor array - srcList position not UB --- | ||
| 179 | +TEST_F(TestTransDataTo5HDNpuDebug, SrcListPositionNotUbOverload1) | ||
| 180 | +{ | ||
| 181 | + TPipe tpipe; | ||
| 182 | + LocalTensor<half> dstList[NCHW_CONV_ADDR_LIST_SIZE]; | ||
| 183 | + LocalTensor<half> srcList[NCHW_CONV_ADDR_LIST_SIZE]; | ||
| 184 | + | ||
| 185 | + TBuf<TPosition::VECCALC> dstBuf; | ||
| 186 | + tpipe.InitBuffer(dstBuf, 256 * sizeof(half)); | ||
| 187 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 188 | + | ||
| 189 | + TBuf<TPosition::A1> srcBuf; | ||
| 190 | + tpipe.InitBuffer(srcBuf, 256 * sizeof(half)); | ||
| 191 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 192 | + | ||
| 193 | + for (int i = 0; i < NCHW_CONV_ADDR_LIST_SIZE; i++) { | ||
| 194 | + dstList[i] = dstLocal[16 * i]; | ||
| 195 | + srcList[i] = srcLocal[16 * i]; | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + TransDataTo5HDParams params; | ||
| 199 | + params.dstHighHalf = false; | ||
| 200 | + params.srcHighHalf = false; | ||
| 201 | + params.repeatTimes = 1; | ||
| 202 | + params.dstRepStride = 16; | ||
| 203 | + params.srcRepStride = 16; | ||
| 204 | + | ||
| 205 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStubForNpuDebug)); | ||
| 206 | + TransDataTo5HD<half>(dstList, srcList, params); | ||
| 207 | +} | ||
| 208 | + | ||
| 209 | +// --- Overload 1: half type with dstHighHalf=true (only valid for int8_t/uint8_t) --- | ||
| 210 | +TEST_F(TestTransDataTo5HDNpuDebug, DstHighHalfInvalidForHalfOverload1) | ||
| 211 | +{ | ||
| 212 | + TPipe tpipe; | ||
| 213 | + LocalTensor<half> dstList[NCHW_CONV_ADDR_LIST_SIZE]; | ||
| 214 | + LocalTensor<half> srcList[NCHW_CONV_ADDR_LIST_SIZE]; | ||
| 215 | + | ||
| 216 | + TBuf<TPosition::VECCALC> dstBuf; | ||
| 217 | + tpipe.InitBuffer(dstBuf, 256 * sizeof(half)); | ||
| 218 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 219 | + | ||
| 220 | + TBuf<TPosition::VECCALC> srcBuf; | ||
| 221 | + tpipe.InitBuffer(srcBuf, 256 * sizeof(half)); | ||
| 222 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 223 | + | ||
| 224 | + for (int i = 0; i < NCHW_CONV_ADDR_LIST_SIZE; i++) { | ||
| 225 | + dstList[i] = dstLocal[16 * i]; | ||
| 226 | + srcList[i] = srcLocal[16 * i]; | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + TransDataTo5HDParams params; | ||
| 230 | + params.dstHighHalf = true; // invalid for half | ||
| 231 | + params.srcHighHalf = false; | ||
| 232 | + params.repeatTimes = 1; | ||
| 233 | + params.dstRepStride = 16; | ||
| 234 | + params.srcRepStride = 16; | ||
| 235 | + | ||
| 236 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStubForNpuDebug)); | ||
| 237 | + TransDataTo5HD<half>(dstList, srcList, params); | ||
| 238 | +} | ||
| 239 | + | ||
| 240 | +// --- Overload 1: half type with srcHighHalf=true (only valid for int8_t/uint8_t) --- | ||
| 241 | +TEST_F(TestTransDataTo5HDNpuDebug, SrcHighHalfInvalidForHalfOverload1) | ||
| 242 | +{ | ||
| 243 | + TPipe tpipe; | ||
| 244 | + LocalTensor<half> dstList[NCHW_CONV_ADDR_LIST_SIZE]; | ||
| 245 | + LocalTensor<half> srcList[NCHW_CONV_ADDR_LIST_SIZE]; | ||
| 246 | + | ||
| 247 | + TBuf<TPosition::VECCALC> dstBuf; | ||
| 248 | + tpipe.InitBuffer(dstBuf, 256 * sizeof(half)); | ||
| 249 | + LocalTensor<half> dstLocal = dstBuf.Get<half>(); | ||
| 250 | + | ||
| 251 | + TBuf<TPosition::VECCALC> srcBuf; | ||
| 252 | + tpipe.InitBuffer(srcBuf, 256 * sizeof(half)); | ||
| 253 | + LocalTensor<half> srcLocal = srcBuf.Get<half>(); | ||
| 254 | + | ||
| 255 | + for (int i = 0; i < NCHW_CONV_ADDR_LIST_SIZE; i++) { | ||
| 256 | + dstList[i] = dstLocal[16 * i]; | ||
| 257 | + srcList[i] = srcLocal[16 * i]; | ||
| 258 | + } | ||
| 259 | + | ||
| 260 | + TransDataTo5HDParams params; | ||
| 261 | + params.dstHighHalf = false; | ||
| 262 | + params.srcHighHalf = true; // invalid for half | ||
| 263 | + params.repeatTimes = 1; | ||
| 264 | + params.dstRepStride = 16; | ||
| 265 | + params.srcRepStride = 16; | ||
| 266 | + | ||
| 267 | + MOCKER(raise, int32_t (*)(int32_t)).stubs().will(invoke(RaiseStubForNpuDebug)); | ||
| 268 | + TransDataTo5HD<half>(dstList, srcList, params); | ||
| 269 | +} | ||
| 270 | + | ||


仿照上面的报错tensor比较好点,也得报出来现在是多少字节