Merged
add npu check #1557
YANXI_ZHAOAdd on Apr 11
add npu check #1557
Merged
Merged fromYANXI_ZHAO/asc-devkitmasterintocann/asc-devkitmaster
Total: 8 files changed+251-90
| @@ -478,8 +478,9 @@ template <typename T> | |||
| 478 | __aicore__ inline void AddReluImpl(__ubuf__ T* dst, __ubuf__ T* src0, __ubuf__ T* src1, const int32_t& count) | 478 | __aicore__ inline void AddReluImpl(__ubuf__ T* dst, __ubuf__ T* src0, __ubuf__ T* src1, const int32_t& count) |
| 479 | { | 479 | { |
| 480 | if ASCEND_IS_AIV { | 480 | if ASCEND_IS_AIV { |
| 481 | - ASCENDC_ASSERT((SupportType<T, int16_t, half, float>()), {KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 481 | + ASCENDC_DEBUG_ASSERT((SupportType<T, int16_t, half, float>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, |
| 482 | - "AddRelu, current api support dtype combination is src and dst both: int16_t / half / float.");}); | 482 | + "Failed to check dtype in AddRelu, current api support dtype combination is src and dst both: int16_t / " |
| 483 | + "half / float.")); | ||
| 483 | set_mask_count(); | 484 | set_mask_count(); |
| 484 | set_vector_mask(0, count); | 485 | set_vector_mask(0, count); |
| 485 | vaddrelu((__ubuf__ T*)dst, (__ubuf__ T*)src0, (__ubuf__ T*)src1, 1, | 486 | vaddrelu((__ubuf__ T*)dst, (__ubuf__ T*)src0, (__ubuf__ T*)src1, 1, |
| @@ -813,9 +814,9 @@ template <typename T, typename U> | |||
| 813 | __aicore__ inline void MulAddDstImpl(__ubuf__ T* dst, __ubuf__ U* src0, __ubuf__ U* src1, const int32_t& count) | 814 | __aicore__ inline void MulAddDstImpl(__ubuf__ T* dst, __ubuf__ U* src0, __ubuf__ U* src1, const int32_t& count) |
| 814 | { | 815 | { |
| 815 | if ASCEND_IS_AIV { | 816 | if ASCEND_IS_AIV { |
| 816 | - ASCENDC_ASSERT((SupportType<Tuple<T, U>, Tuple<half, half>, Tuple<float, float>, Tuple<float, half>>()), | 817 | + ASCENDC_DEBUG_ASSERT((SupportType<Tuple<T, U>, Tuple<half, half>, Tuple<float, float>, |
| 817 | - {KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in MulAddDst, current api support dtype combination is " | 818 | + Tuple<float, half>>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, "Failed to check dtype in MulAddDst, current api " |
| 818 | - "src: half, dst: half / float; src: float, dst: float.");}); | 819 | + "support dtype combination is src: half, dst: half / float; src: float, dst: float.")); |
| 819 | set_mask_count(); | 820 | set_mask_count(); |
| 820 | set_vector_mask(0, count); | 821 | set_vector_mask(0, count); |
| 821 | if constexpr (sizeof(T) == sizeof(U)) { | 822 | if constexpr (sizeof(T) == sizeof(U)) { |
| @@ -871,8 +872,8 @@ template <typename T> | |||
| 871 | __aicore__ inline void FusedMulAddReluImpl(__ubuf__ T* dst, __ubuf__ T* src0, __ubuf__ T* src1, const int32_t& count) | 872 | __aicore__ inline void FusedMulAddReluImpl(__ubuf__ T* dst, __ubuf__ T* src0, __ubuf__ T* src1, const int32_t& count) |
| 872 | { | 873 | { |
| 873 | if ASCEND_IS_AIV { | 874 | if ASCEND_IS_AIV { |
| 874 | - ASCENDC_ASSERT((SupportType<T, half, float>()), {KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 875 | + ASCENDC_DEBUG_ASSERT((SupportType<T, half, float>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, "Failed to check dtype " |
| 875 | - "FusedMulAddRelu, current api support dtype combination is src and dst both: half / float.");}); | 876 | + "in FusedMulAddRelu, current api support dtype combination is src and dst both: half / float.")); |
| 876 | set_mask_count(); | 877 | set_mask_count(); |
| 877 | set_vector_mask(0, count); | 878 | set_vector_mask(0, count); |
| 878 | vmaddrelu(dst, src0, src1, 1, DEFAULT_BLK_STRIDE, DEFAULT_BLK_STRIDE, DEFAULT_BLK_STRIDE, DEFAULT_REPEAT_STRIDE, | 879 | vmaddrelu(dst, src0, src1, 1, DEFAULT_BLK_STRIDE, DEFAULT_BLK_STRIDE, DEFAULT_BLK_STRIDE, DEFAULT_REPEAT_STRIDE, |
| @@ -900,8 +901,9 @@ template <typename T> | |||
| 900 | __aicore__ inline void SubReluImpl(__ubuf__ T* dst, __ubuf__ T* src0, __ubuf__ T* src1, const int32_t& count) | 901 | __aicore__ inline void SubReluImpl(__ubuf__ T* dst, __ubuf__ T* src0, __ubuf__ T* src1, const int32_t& count) |
| 901 | { | 902 | { |
| 902 | if ASCEND_IS_AIV { | 903 | if ASCEND_IS_AIV { |
| 903 | - ASCENDC_ASSERT((SupportType<T, int16_t, half, float>()), {KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in " | 904 | + ASCENDC_DEBUG_ASSERT((SupportType<T, int16_t, half, float>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, |
| 904 | - "SubRelu, current api support dtype combination is src and dst both: int16_t / half / float.");}); | 905 | + "Failed to check dtype in SubRelu, current api support dtype combination is src and dst both: int16_t / " |
| 906 | + "half / float.")); | ||
| 905 | set_mask_count(); | 907 | set_mask_count(); |
| 906 | set_vector_mask(0, count); | 908 | set_vector_mask(0, count); |
| 907 | vsubrelu(dst, src0, src1, 1, DEFAULT_BLK_STRIDE, DEFAULT_BLK_STRIDE, DEFAULT_BLK_STRIDE, | 909 | vsubrelu(dst, src0, src1, 1, DEFAULT_BLK_STRIDE, DEFAULT_BLK_STRIDE, DEFAULT_BLK_STRIDE, |
| @@ -27,9 +27,10 @@ template <typename T, typename U> | |||
| 27 | __aicore__ inline void AxpyIntrinsicsImpl(__ubuf__ T* dst, __ubuf__ U* src, U scalarValue, const uint8_t repeatTime, | 27 | __aicore__ inline void AxpyIntrinsicsImpl(__ubuf__ T* dst, __ubuf__ U* src, U scalarValue, const uint8_t repeatTime, |
| 28 | const UnaryRepeatParams& repeatParams) | 28 | const UnaryRepeatParams& repeatParams) |
| 29 | { | 29 | { |
| 30 | - ASCENDC_ASSERT((SupportType<Tuple<T, U>, Tuple<half, half>, Tuple<float, float>, Tuple<float, half>>()), | 30 | + ASCENDC_DEBUG_ASSERT((SupportType<Tuple<T, U>, Tuple<half, half>, Tuple<float, float>, Tuple<float, half>>()), |
| 31 | - {KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in Axpy, current api support dtype combination is src: half, " | 31 | + KERNEL_LOG_INTERNAL(KERNEL_ERROR, |
| 32 | - "dst: half / float; src: float, dst: float.");}); | 32 | + "Failed to check dtype in Axpy, current api support dtype combination is src: " |
| 33 | + "half, dst: half / float; src: float, dst: float.")); | ||
| 33 | vaxpy(dst, src, scalarValue, repeatTime, repeatParams.dstBlkStride, repeatParams.srcBlkStride, | 34 | vaxpy(dst, src, scalarValue, repeatTime, repeatParams.dstBlkStride, repeatParams.srcBlkStride, |
| 34 | repeatParams.dstRepStride, repeatParams.srcRepStride); | 35 | repeatParams.dstRepStride, repeatParams.srcRepStride); |
| 35 | } | 36 | } |
| @@ -894,9 +894,9 @@ template <typename T, typename U, bool isVecDeq, bool halfBlock> | |||
| 894 | __aicore__ inline void CastDeqImpl(__ubuf__ T* dst, __ubuf__ U* src, | 894 | __aicore__ inline void CastDeqImpl(__ubuf__ T* dst, __ubuf__ U* src, |
| 895 | const uint32_t count) | 895 | const uint32_t count) |
| 896 | { | 896 | { |
| 897 | - ASCENDC_ASSERT((SupportType<Tuple<U, T>, Tuple<int16_t, int8_t>, Tuple<int16_t, uint8_t>, Tuple<int32_t, half>>()), | 897 | + ASCENDC_DEBUG_ASSERT((SupportType<Tuple<U, T>, Tuple<int16_t, int8_t>, Tuple<int16_t, uint8_t>, |
| 898 | - {KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in CastDeqImpl, current api support dtype combination is src:" | 898 | + Tuple<int32_t, half>>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, "Failed to check dtype in CastDeqImpl, current api " |
| 899 | - "int16_t dst: int8_t/uint8_t , src:int32_t dst:half.");}); | 899 | + "support dtype combination is src:int16_t dst: int8_t/uint8_t , src:int32_t dst:half.")); |
| 900 | if ASCEND_IS_AIV { | 900 | if ASCEND_IS_AIV { |
| 901 | set_mask_count(); | 901 | set_mask_count(); |
| 902 | set_vector_mask(0, count); | 902 | set_vector_mask(0, count); |
| @@ -920,9 +920,9 @@ template <typename T, typename U, bool isSetMask, bool isVecDeq, bool halfBlock> | |||
| 920 | __aicore__ inline void CastDeqImpl(__ubuf__ T* dst, __ubuf__ U* src, | 920 | __aicore__ inline void CastDeqImpl(__ubuf__ T* dst, __ubuf__ U* src, |
| 921 | const uint64_t mask[], uint8_t repeatTime, const UnaryRepeatParams& repeatParams) | 921 | const uint64_t mask[], uint8_t repeatTime, const UnaryRepeatParams& repeatParams) |
| 922 | { | 922 | { |
| 923 | - ASCENDC_ASSERT((SupportType<Tuple<U, T>, Tuple<int16_t, int8_t>, Tuple<int16_t, uint8_t>, Tuple<int32_t, half>>()), | 923 | + ASCENDC_DEBUG_ASSERT((SupportType<Tuple<U, T>, Tuple<int16_t, int8_t>, Tuple<int16_t, uint8_t>, |
| 924 | - {KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in CastDeqImpl, current api support dtype combination is src:" | 924 | + Tuple<int32_t, half>>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, "Failed to check dtype in CastDeqImpl, current api " |
| 925 | - "int16_t dst: int8_t/uint8_t , src:int32_t dst:half.");}); | 925 | + "support dtype combination is src:int16_t dst: int8_t/uint8_t , src:int32_t dst:half.")); |
| 926 | if ASCEND_IS_AIV { | 926 | if ASCEND_IS_AIV { |
| 927 | AscendCUtils::SetMask<U, isSetMask>(mask[1], mask[0]); | 927 | AscendCUtils::SetMask<U, isSetMask>(mask[1], mask[0]); |
| 928 | if constexpr (sizeof(U) == sizeof(int32_t)) { | 928 | if constexpr (sizeof(U) == sizeof(int32_t)) { |
| @@ -942,9 +942,9 @@ template <typename T, typename U, bool isSetMask, bool isVecDeq, bool halfBlock> | |||
| 942 | __aicore__ inline void CastDeqImpl(__ubuf__ T* dst, __ubuf__ U* src, | 942 | __aicore__ inline void CastDeqImpl(__ubuf__ T* dst, __ubuf__ U* src, |
| 943 | const int32_t mask, uint8_t repeatTime, const UnaryRepeatParams& repeatParams) | 943 | const int32_t mask, uint8_t repeatTime, const UnaryRepeatParams& repeatParams) |
| 944 | { | 944 | { |
| 945 | - ASCENDC_ASSERT((SupportType<Tuple<U, T>, Tuple<int16_t, int8_t>, Tuple<int16_t, uint8_t>, Tuple<int32_t, half>>()), | 945 | + ASCENDC_DEBUG_ASSERT((SupportType<Tuple<U, T>, Tuple<int16_t, int8_t>, Tuple<int16_t, uint8_t>, |
| 946 | - {KERNEL_LOG(KERNEL_ERROR, "Failed to check dtype in CastDeqImpl, current api support dtype combination is src:" | 946 | + Tuple<int32_t, half>>()), KERNEL_LOG_INTERNAL(KERNEL_ERROR, "Failed to check dtype in CastDeqImpl, current api " |
| 947 | - "int16_t dst: int8_t/uint8_t , src:int32_t dst:half.");}); | 947 | + "support dtype combination is src:int16_t dst: int8_t/uint8_t , src:int32_t dst:half.")); |
| 948 | if ASCEND_IS_AIV { | 948 | if ASCEND_IS_AIV { |
| 949 | AscendCUtils::SetMask<U, isSetMask>(mask); | 949 | AscendCUtils::SetMask<U, isSetMask>(mask); |
| 950 | if constexpr (sizeof(U) == sizeof(int32_t)) { | 950 | if constexpr (sizeof(U) == sizeof(int32_t)) { |
| @@ -494,6 +494,12 @@ __aicore__ inline void MulAddDst(const LocalTensor<T>& dst, const LocalTensor<U> | |||
| 494 | { | 494 | { |
| 495 | using PrimDstType = PrimT<T>; | 495 | using PrimDstType = PrimT<T>; |
| 496 | using PrimSrcType = PrimT<U>; | 496 | using PrimSrcType = PrimT<U>; |
| 497 | + using MaskCheckType = typename Conditional<(sizeof(PrimDstType) >= sizeof(PrimSrcType)), | ||
| 498 | + PrimDstType, PrimSrcType>::type; | ||
| 499 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 500 | + CheckVectorTensor("MulAddDst", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 501 | + CheckMaskArray<MaskCheckType, isSetMask>(mask, "MulAddDst"); | ||
| 502 | +#endif | ||
| 497 | #if ASCENDC_CPU_DEBUG | 503 | #if ASCENDC_CPU_DEBUG |
| 498 | MaskSetter::Instance().SetMask(isSetMask); | 504 | MaskSetter::Instance().SetMask(isSetMask); |
| 499 | if (!CheckFuncVecBinaryDiffType(dst, src0, src1, mask, repeatTime, repeatParams, "MulAddDst")) { | 505 | if (!CheckFuncVecBinaryDiffType(dst, src0, src1, mask, repeatTime, repeatParams, "MulAddDst")) { |
| @@ -515,6 +521,12 @@ __aicore__ inline void MulAddDst(const LocalTensor<T>& dst, const LocalTensor<U> | |||
| 515 | { | 521 | { |
| 516 | using PrimDstType = PrimT<T>; | 522 | using PrimDstType = PrimT<T>; |
| 517 | using PrimSrcType = PrimT<U>; | 523 | using PrimSrcType = PrimT<U>; |
| 524 | + using MaskCheckType = typename Conditional<(sizeof(PrimDstType) >= sizeof(PrimSrcType)), | ||
| 525 | + PrimDstType, PrimSrcType>::type; | ||
| 526 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 527 | + CheckVectorTensor("MulAddDst", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 528 | + CheckMaskValue<MaskCheckType, isSetMask>(mask, "MulAddDst"); | ||
| 529 | +#endif | ||
| 518 | #if ASCENDC_CPU_DEBUG | 530 | #if ASCENDC_CPU_DEBUG |
| 519 | MaskSetter::Instance().SetMask(isSetMask); | 531 | MaskSetter::Instance().SetMask(isSetMask); |
| 520 | if (!CheckFuncVecBinaryDiffType(dst, src0, src1, mask, repeatTime, repeatParams, "MulAddDst")) { | 532 | if (!CheckFuncVecBinaryDiffType(dst, src0, src1, mask, repeatTime, repeatParams, "MulAddDst")) { |
| @@ -543,6 +555,10 @@ __aicore__ inline void MulAddDst(const LocalTensor<T>& dst, const LocalTensor<U> | |||
| 543 | { | 555 | { |
| 544 | using PrimDstType = PrimT<T>; | 556 | using PrimDstType = PrimT<T>; |
| 545 | using PrimSrcType = PrimT<U>; | 557 | using PrimSrcType = PrimT<U>; |
| 558 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 559 | + CheckVectorTensor("MulAddDst", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 560 | + CheckCalcount(count, "count", "MulAddDst"); | ||
| 561 | +#endif | ||
| 546 | #if ASCENDC_CPU_DEBUG | 562 | #if ASCENDC_CPU_DEBUG |
| 547 | if (!CheckFuncVecBinaryDiffType(dst, src0, src1, count, "MulAddDst")) { | 563 | if (!CheckFuncVecBinaryDiffType(dst, src0, src1, count, "MulAddDst")) { |
| 548 | ASCENDC_REPORT_CHECK_ERROR("MulAddDst", KernelFuncType::CALCOUNT_MODE); | 564 | ASCENDC_REPORT_CHECK_ERROR("MulAddDst", KernelFuncType::CALCOUNT_MODE); |
| @@ -997,8 +1013,7 @@ __aicore__ inline void ShiftRight(const LocalTensor<T>& dst, const LocalTensor<T | |||
| 997 | */ | 1013 | */ |
| 998 | template <typename T, bool isSetMask> | 1014 | template <typename T, bool isSetMask> |
| 999 | __aicore__ inline void AddRelu(const LocalTensor<T>& dst, const LocalTensor<T>& src0, | 1015 | __aicore__ inline void AddRelu(const LocalTensor<T>& dst, const LocalTensor<T>& src0, |
| 1000 | - const LocalTensor<T>& src1, uint64_t mask[], const uint8_t repeatTime, | 1016 | + const LocalTensor<T>& src1, uint64_t mask[], const uint8_t repeatTime, const BinaryRepeatParams& repeatParams) |
| 1001 | - const BinaryRepeatParams& repeatParams) | ||
| 1002 | { | 1017 | { |
| 1003 | using PrimType = PrimT<T>; | 1018 | using PrimType = PrimT<T>; |
| 1004 | #if __NPU_ARCH__ == 2201 | 1019 | #if __NPU_ARCH__ == 2201 |
| @@ -1006,6 +1021,10 @@ __aicore__ inline void AddRelu(const LocalTensor<T>& dst, const LocalTensor<T>& | |||
| 1006 | return; | 1021 | return; |
| 1007 | } | 1022 | } |
| 1008 | #endif | 1023 | #endif |
| 1024 | +#if defined(ASCENDC_CPU_DEBUG) || defined(ASCENDC_DEBUG) | ||
| 1025 | + CheckVectorTensor("AddRelu", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 1026 | + CheckMaskArray<PrimType, isSetMask>(mask, "AddRelu"); | ||
| 1027 | +#endif | ||
| 1009 | #if ASCENDC_CPU_DEBUG | 1028 | #if ASCENDC_CPU_DEBUG |
| 1010 | MaskSetter::Instance().SetMask(isSetMask); | 1029 | MaskSetter::Instance().SetMask(isSetMask); |
| 1011 | if (!CheckFuncVecBinary(dst, src0, src1, mask, repeatTime, repeatParams, "AddRelu")) { | 1030 | if (!CheckFuncVecBinary(dst, src0, src1, mask, repeatTime, repeatParams, "AddRelu")) { |
| @@ -1030,6 +1049,10 @@ __aicore__ inline void AddRelu(const LocalTensor<T>& dst, const LocalTensor<T>& | |||
| 1030 | return; | 1049 | return; |
| 1031 | } | 1050 | } |
| 1032 | #endif | 1051 | #endif |
| 1052 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 1053 | + CheckVectorTensor("AddRelu", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 1054 | + CheckMaskValue<PrimType, isSetMask>(mask, "AddRelu"); | ||
| 1055 | +#endif | ||
| 1033 | #if ASCENDC_CPU_DEBUG | 1056 | #if ASCENDC_CPU_DEBUG |
| 1034 | MaskSetter::Instance().SetMask(isSetMask); | 1057 | MaskSetter::Instance().SetMask(isSetMask); |
| 1035 | if (!CheckFuncVecBinary(dst, src0, src1, mask, repeatTime, repeatParams, "AddRelu")) { | 1058 | if (!CheckFuncVecBinary(dst, src0, src1, mask, repeatTime, repeatParams, "AddRelu")) { |
| @@ -1054,6 +1077,10 @@ __aicore__ inline void AddRelu(const LocalTensor<T>& dst, const LocalTensor<T>& | |||
| 1054 | return; | 1077 | return; |
| 1055 | } | 1078 | } |
| 1056 | #endif | 1079 | #endif |
| 1080 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 1081 | + CheckVectorTensor("AddRelu", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 1082 | + CheckCalcount(count, "count", "AddRelu"); | ||
| 1083 | +#endif | ||
| 1057 | #if ASCENDC_CPU_DEBUG | 1084 | #if ASCENDC_CPU_DEBUG |
| 1058 | if (!CheckFuncVecBinary(dst, src0, src1, count, "AddRelu")) { | 1085 | if (!CheckFuncVecBinary(dst, src0, src1, count, "AddRelu")) { |
| 1059 | ASCENDC_REPORT_CHECK_ERROR("AddRelu", KernelFuncType::CALCOUNT_MODE); | 1086 | ASCENDC_REPORT_CHECK_ERROR("AddRelu", KernelFuncType::CALCOUNT_MODE); |
| @@ -1069,6 +1096,39 @@ __aicore__ inline void AddRelu(const LocalTensor<T>& dst, const LocalTensor<T>& | |||
| 1069 | /* ************************************************************************************************** | 1096 | /* ************************************************************************************************** |
| 1070 | * AddDeqRelu * | 1097 | * AddDeqRelu * |
| 1071 | * ************************************************************************************************* */ | 1098 | * ************************************************************************************************* */ |
| 1099 | +template <typename T, typename U, bool isSetMask> | ||
| 1100 | +__aicore__ inline void CheckAddDeqReluMaskArrayParams(const LocalTensor<T>& dst, const LocalTensor<U>& src0, | ||
| 1101 | + const LocalTensor<U>& src1, uint64_t mask[], const uint8_t repeatTime, | ||
| 1102 | + const BinaryRepeatParams& repeatParams) | ||
| 1103 | +{ | ||
| 1104 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 1105 | + CheckVectorTensor("AddDeqRelu", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 1106 | + CheckMaskArray<PrimT<U>, isSetMask>(mask, "AddDeqRelu"); | ||
| 1107 | +#endif | ||
| 1108 | +#if ASCENDC_CPU_DEBUG | ||
| 1109 | + MaskSetter::Instance().SetMask(isSetMask); | ||
| 1110 | + if (!CheckFuncVecBinaryDiffType(dst, src0, src1, mask, repeatTime, repeatParams, "AddDeqRelu")) { | ||
| 1111 | + ASCENDC_REPORT_CHECK_ERROR("AddDeqRelu", KernelFuncType::MASK_BIT_MODE); | ||
| 1112 | + } | ||
| 1113 | +#endif | ||
| 1114 | +} | ||
| 1115 | + | ||
| 1116 | +template <typename T, typename U, bool isSetMask> | ||
| 1117 | +__aicore__ inline void CheckAddDeqReluMaskValueParams(const LocalTensor<T>& dst, const LocalTensor<U>& src0, | ||
| 1118 | + const LocalTensor<U>& src1, uint64_t mask, const uint8_t repeatTime, const BinaryRepeatParams& repeatParams) | ||
| 1119 | +{ | ||
| 1120 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 1121 | + CheckVectorTensor("AddDeqRelu", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 1122 | + CheckMaskValue<PrimT<U>, isSetMask>(mask, "AddDeqRelu"); | ||
| 1123 | +#endif | ||
| 1124 | +#if ASCENDC_CPU_DEBUG | ||
| 1125 | + MaskSetter::Instance().SetMask(isSetMask); | ||
| 1126 | + if (!CheckFuncVecBinaryDiffType(dst, src0, src1, mask, repeatTime, repeatParams, "AddDeqRelu")) { | ||
| 1127 | + ASCENDC_REPORT_CHECK_ERROR("AddDeqRelu", KernelFuncType::MASK_COUNT_MODE); | ||
| 1128 | + } | ||
| 1129 | +#endif | ||
| 1130 | +} | ||
| 1131 | + | ||
| 1072 | /* | 1132 | /* |
| 1073 | * @ingroup AddDeqRelu Level 0 | 1133 | * @ingroup AddDeqRelu Level 0 |
| 1074 | * @brief dst = DeqRelu(src0 + src1) | 1134 | * @brief dst = DeqRelu(src0 + src1) |
| @@ -1089,12 +1149,7 @@ __aicore__ inline void AddDeqRelu(const LocalTensor<half>& dst, const LocalTenso | |||
| 1089 | const LocalTensor<int32_t>& src1, uint64_t mask[], const uint8_t repeatTime, | 1149 | const LocalTensor<int32_t>& src1, uint64_t mask[], const uint8_t repeatTime, |
| 1090 | const BinaryRepeatParams& repeatParams) | 1150 | const BinaryRepeatParams& repeatParams) |
| 1091 | { | 1151 | { |
| 1092 | -#if ASCENDC_CPU_DEBUG | 1152 | + CheckAddDeqReluMaskArrayParams<half, int32_t, isSetMask>(dst, src0, src1, mask, repeatTime, repeatParams); |
| 1093 | - MaskSetter::Instance().SetMask(isSetMask); | ||
| 1094 | - if (!CheckFuncVecBinaryDiffType(dst, src0, src1, mask, repeatTime, repeatParams, "AddDeqRelu")) { | ||
| 1095 | - ASCENDC_REPORT_CHECK_ERROR("AddDeqRelu", KernelFuncType::MASK_BIT_MODE); | ||
| 1096 | - } | ||
| 1097 | -#endif | ||
| 1098 | #ifdef __MSTX_DFX_REPORT__ | 1153 | #ifdef __MSTX_DFX_REPORT__ |
| 1099 | MstxTensor::GetMstxVecBinaryAddReqReluInfo(dst, src0, src1, mask[0], mask[1], repeatTime, repeatParams, isSetMask, "AddDeqRelu"); | 1154 | MstxTensor::GetMstxVecBinaryAddReqReluInfo(dst, src0, src1, mask[0], mask[1], repeatTime, repeatParams, isSetMask, "AddDeqRelu"); |
| 1100 | #endif | 1155 | #endif |
| @@ -1111,12 +1166,7 @@ __aicore__ inline void AddDeqRelu(const LocalTensor<T>& dst, const LocalTensor<U | |||
| 1111 | using PrimSrcType = PrimT<U>; | 1166 | using PrimSrcType = PrimT<U>; |
| 1112 | static_assert((Std::is_same<PrimDstType, half>::value && Std::is_same<PrimSrcType, int32_t>::value) && | 1167 | static_assert((Std::is_same<PrimDstType, half>::value && Std::is_same<PrimSrcType, int32_t>::value) && |
| 1113 | "Failed to check dtype in AddDeqRelu, current api support dtype combination is src: int32_t, dst: half."); | 1168 | "Failed to check dtype in AddDeqRelu, current api support dtype combination is src: int32_t, dst: half."); |
| 1114 | -#if ASCENDC_CPU_DEBUG | 1169 | + CheckAddDeqReluMaskArrayParams<T, U, isSetMask>(dst, src0, src1, mask, repeatTime, repeatParams); |
| 1115 | - MaskSetter::Instance().SetMask(isSetMask); | ||
| 1116 | - if (!CheckFuncVecBinaryDiffType(dst, src0, src1, mask, repeatTime, repeatParams, "AddDeqRelu")) { | ||
| 1117 | - ASCENDC_REPORT_CHECK_ERROR("AddDeqRelu", KernelFuncType::MASK_BIT_MODE); | ||
| 1118 | - } | ||
| 1119 | -#endif | ||
| 1120 | #ifdef __MSTX_DFX_REPORT__ | 1170 | #ifdef __MSTX_DFX_REPORT__ |
| 1121 | MstxTensor::GetMstxVecBinaryAddReqReluInfo(dst, src0, src1, mask[0], mask[1], repeatTime, repeatParams, isSetMask, "AddDeqRelu"); | 1171 | MstxTensor::GetMstxVecBinaryAddReqReluInfo(dst, src0, src1, mask[0], mask[1], repeatTime, repeatParams, isSetMask, "AddDeqRelu"); |
| 1122 | #endif | 1172 | #endif |
| @@ -1130,12 +1180,7 @@ __aicore__ inline void AddDeqRelu(const LocalTensor<half> &dst, const LocalTenso | |||
| 1130 | const LocalTensor<int32_t> &src1, uint64_t mask, const uint8_t repeatTime, | 1180 | const LocalTensor<int32_t> &src1, uint64_t mask, const uint8_t repeatTime, |
| 1131 | const BinaryRepeatParams &repeatParams) | 1181 | const BinaryRepeatParams &repeatParams) |
| 1132 | { | 1182 | { |
| 1133 | -#if ASCENDC_CPU_DEBUG | 1183 | + CheckAddDeqReluMaskValueParams<half, int32_t, isSetMask>(dst, src0, src1, mask, repeatTime, repeatParams); |
| 1134 | - MaskSetter::Instance().SetMask(isSetMask); | ||
| 1135 | - if (!CheckFuncVecBinaryDiffType(dst, src0, src1, mask, repeatTime, repeatParams, "AddDeqRelu")) { | ||
| 1136 | - ASCENDC_REPORT_CHECK_ERROR("AddDeqRelu", KernelFuncType::MASK_COUNT_MODE); | ||
| 1137 | - } | ||
| 1138 | -#endif | ||
| 1139 | #ifdef __MSTX_DFX_REPORT__ | 1184 | #ifdef __MSTX_DFX_REPORT__ |
| 1140 | MstxTensor::GetMstxVecBinaryAddReqReluInfo(dst, src0, src1, mask, repeatTime, repeatParams, isSetMask, "AddDeqRelu"); | 1185 | MstxTensor::GetMstxVecBinaryAddReqReluInfo(dst, src0, src1, mask, repeatTime, repeatParams, isSetMask, "AddDeqRelu"); |
| 1141 | #endif | 1186 | #endif |
| @@ -1152,12 +1197,7 @@ __aicore__ inline void AddDeqRelu(const LocalTensor<T> &dst, const LocalTensor<U | |||
| 1152 | using PrimSrcType = PrimT<U>; | 1197 | using PrimSrcType = PrimT<U>; |
| 1153 | static_assert((Std::is_same<PrimDstType, half>::value && Std::is_same<PrimSrcType, int32_t>::value) && | 1198 | static_assert((Std::is_same<PrimDstType, half>::value && Std::is_same<PrimSrcType, int32_t>::value) && |
| 1154 | "Failed to check dtype in AddDeqRelu, current api support dtype combination is src: int32_t, dst: half."); | 1199 | "Failed to check dtype in AddDeqRelu, current api support dtype combination is src: int32_t, dst: half."); |
| 1155 | -#if ASCENDC_CPU_DEBUG | 1200 | + CheckAddDeqReluMaskValueParams<T, U, isSetMask>(dst, src0, src1, mask, repeatTime, repeatParams); |
| 1156 | - MaskSetter::Instance().SetMask(isSetMask); | ||
| 1157 | - if (!CheckFuncVecBinaryDiffType(dst, src0, src1, mask, repeatTime, repeatParams, "AddDeqRelu")) { | ||
| 1158 | - ASCENDC_REPORT_CHECK_ERROR("AddDeqRelu", KernelFuncType::MASK_COUNT_MODE); | ||
| 1159 | - } | ||
| 1160 | -#endif | ||
| 1161 | #ifdef __MSTX_DFX_REPORT__ | 1201 | #ifdef __MSTX_DFX_REPORT__ |
| 1162 | MstxTensor::GetMstxVecBinaryAddReqReluInfo(dst, src0, src1, mask, repeatTime, repeatParams, isSetMask, "AddDeqRelu"); | 1202 | MstxTensor::GetMstxVecBinaryAddReqReluInfo(dst, src0, src1, mask, repeatTime, repeatParams, isSetMask, "AddDeqRelu"); |
| 1163 | #endif | 1203 | #endif |
| @@ -1177,6 +1217,10 @@ __aicore__ inline void AddDeqRelu(const LocalTensor<T> &dst, const LocalTensor<U | |||
| 1177 | __aicore__ inline void AddDeqRelu(const LocalTensor<half>& dst, const LocalTensor<int32_t>& src0, | 1217 | __aicore__ inline void AddDeqRelu(const LocalTensor<half>& dst, const LocalTensor<int32_t>& src0, |
| 1178 | const LocalTensor<int32_t>& src1, const int32_t& count) | 1218 | const LocalTensor<int32_t>& src1, const int32_t& count) |
| 1179 | { | 1219 | { |
| 1220 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 1221 | + CheckVectorTensor("AddDeqRelu", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 1222 | + CheckCalcount(count, "count", "AddDeqRelu"); | ||
| 1223 | +#endif | ||
| 1180 | #if ASCENDC_CPU_DEBUG | 1224 | #if ASCENDC_CPU_DEBUG |
| 1181 | if (!CheckFuncVecBinaryDiffType(dst, src0, src1, count, "AddDeqRelu")) { | 1225 | if (!CheckFuncVecBinaryDiffType(dst, src0, src1, count, "AddDeqRelu")) { |
| 1182 | ASCENDC_REPORT_CHECK_ERROR("AddDeqRelu", KernelFuncType::CALCOUNT_MODE); | 1226 | ASCENDC_REPORT_CHECK_ERROR("AddDeqRelu", KernelFuncType::CALCOUNT_MODE); |
| @@ -1197,6 +1241,10 @@ __aicore__ inline void AddDeqRelu(const LocalTensor<T>& dst, const LocalTensor<U | |||
| 1197 | using PrimSrcType = PrimT<U>; | 1241 | using PrimSrcType = PrimT<U>; |
| 1198 | static_assert((Std::is_same<PrimDstType, half>::value && Std::is_same<PrimSrcType, int32_t>::value) && | 1242 | static_assert((Std::is_same<PrimDstType, half>::value && Std::is_same<PrimSrcType, int32_t>::value) && |
| 1199 | "Failed to check dtype in AddDeqRelu, current api support dtype combination is src: int32_t, dst: half."); | 1243 | "Failed to check dtype in AddDeqRelu, current api support dtype combination is src: int32_t, dst: half."); |
| 1244 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 1245 | + CheckCalcount(count, "count", "AddDeqRelu"); | ||
| 1246 | + CheckVectorTensor("AddDeqRelu", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 1247 | +#endif | ||
| 1200 | #if ASCENDC_CPU_DEBUG | 1248 | #if ASCENDC_CPU_DEBUG |
| 1201 | if (!CheckFuncVecBinaryDiffType(dst, src0, src1, count, "AddDeqRelu")) { | 1249 | if (!CheckFuncVecBinaryDiffType(dst, src0, src1, count, "AddDeqRelu")) { |
| 1202 | ASCENDC_REPORT_CHECK_ERROR("AddDeqRelu", KernelFuncType::CALCOUNT_MODE); | 1250 | ASCENDC_REPORT_CHECK_ERROR("AddDeqRelu", KernelFuncType::CALCOUNT_MODE); |
| @@ -1326,8 +1374,7 @@ __aicore__ inline void FusedMulAdd(const LocalTensor<T>& dst, const LocalTensor< | |||
| 1326 | */ | 1374 | */ |
| 1327 | template <typename T, bool isSetMask> | 1375 | template <typename T, bool isSetMask> |
| 1328 | __aicore__ inline void MulAddRelu(const LocalTensor<T>& dst, const LocalTensor<T>& src0, | 1376 | __aicore__ inline void MulAddRelu(const LocalTensor<T>& dst, const LocalTensor<T>& src0, |
| 1329 | - const LocalTensor<T>& src1, uint64_t mask[], const uint8_t repeatTime, | 1377 | + const LocalTensor<T>& src1, uint64_t mask[], const uint8_t repeatTime, const BinaryRepeatParams& repeatParams) |
| 1330 | - const BinaryRepeatParams& repeatParams) | ||
| 1331 | { | 1378 | { |
| 1332 | using PrimType = PrimT<T>; | 1379 | using PrimType = PrimT<T>; |
| 1333 | #if __NPU_ARCH__ == 2201 | 1380 | #if __NPU_ARCH__ == 2201 |
| @@ -1335,6 +1382,10 @@ __aicore__ inline void MulAddRelu(const LocalTensor<T>& dst, const LocalTensor<T | |||
| 1335 | return; | 1382 | return; |
| 1336 | } | 1383 | } |
| 1337 | #endif | 1384 | #endif |
| 1385 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 1386 | + CheckVectorTensor("MulAddRelu", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 1387 | + CheckMaskArray<PrimType, isSetMask>(mask, "MulAddRelu"); | ||
| 1388 | +#endif | ||
| 1338 | #if ASCENDC_CPU_DEBUG | 1389 | #if ASCENDC_CPU_DEBUG |
| 1339 | MaskSetter::Instance().SetMask(isSetMask); | 1390 | MaskSetter::Instance().SetMask(isSetMask); |
| 1340 | if (!CheckFuncVecBinary(dst, src0, src1, mask, repeatTime, repeatParams, "MulAddRelu")) { | 1391 | if (!CheckFuncVecBinary(dst, src0, src1, mask, repeatTime, repeatParams, "MulAddRelu")) { |
| @@ -1356,6 +1407,10 @@ __aicore__ inline void MulAddRelu(const LocalTensor<T>& dst, const LocalTensor<T | |||
| 1356 | return; | 1407 | return; |
| 1357 | } | 1408 | } |
| 1358 | #endif | 1409 | #endif |
| 1410 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 1411 | + CheckVectorTensor("MulAddRelu", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 1412 | + CheckMaskValue<PrimType, isSetMask>(mask, "MulAddRelu"); | ||
| 1413 | +#endif | ||
| 1359 | #if ASCENDC_CPU_DEBUG | 1414 | #if ASCENDC_CPU_DEBUG |
| 1360 | MaskSetter::Instance().SetMask(isSetMask); | 1415 | MaskSetter::Instance().SetMask(isSetMask); |
| 1361 | if (!CheckFuncVecBinary(dst, src0, src1, mask, repeatTime, repeatParams, "MulAddRelu")) { | 1416 | if (!CheckFuncVecBinary(dst, src0, src1, mask, repeatTime, repeatParams, "MulAddRelu")) { |
| @@ -1370,8 +1425,7 @@ __aicore__ inline void MulAddRelu(const LocalTensor<T>& dst, const LocalTensor<T | |||
| 1370 | // FusedMulAddRelu has been updated, please use MulAddRelu instead. | 1425 | // FusedMulAddRelu has been updated, please use MulAddRelu instead. |
| 1371 | template <typename T, bool isSetMask> | 1426 | template <typename T, bool isSetMask> |
| 1372 | __aicore__ inline void FusedMulAddRelu(const LocalTensor<T>& dst, const LocalTensor<T>& src0, | 1427 | __aicore__ inline void FusedMulAddRelu(const LocalTensor<T>& dst, const LocalTensor<T>& src0, |
| 1373 | - const LocalTensor<T>& src1, uint64_t mask[], const uint8_t repeatTime, | 1428 | + const LocalTensor<T>& src1, uint64_t mask[], const uint8_t repeatTime, const BinaryRepeatParams& repeatParams) |
| 1374 | - const BinaryRepeatParams& repeatParams) | ||
| 1375 | { | 1429 | { |
| 1376 | using PrimType = PrimT<T>; | 1430 | using PrimType = PrimT<T>; |
| 1377 | #if __NPU_ARCH__ == 2201 | 1431 | #if __NPU_ARCH__ == 2201 |
| @@ -1379,6 +1433,10 @@ __aicore__ inline void FusedMulAddRelu(const LocalTensor<T>& dst, const LocalTen | |||
| 1379 | return; | 1433 | return; |
| 1380 | } | 1434 | } |
| 1381 | #endif | 1435 | #endif |
| 1436 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 1437 | + CheckVectorTensor("FusedMulAddRelu", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 1438 | + CheckMaskArray<PrimType, isSetMask>(mask, "FusedMulAddRelu"); | ||
| 1439 | +#endif | ||
| 1382 | #if ASCENDC_CPU_DEBUG | 1440 | #if ASCENDC_CPU_DEBUG |
| 1383 | MaskSetter::Instance().SetMask(isSetMask); | 1441 | MaskSetter::Instance().SetMask(isSetMask); |
| 1384 | if (!CheckFuncVecBinary(dst, src0, src1, mask, repeatTime, repeatParams, "FusedMulAddRelu")) { | 1442 | if (!CheckFuncVecBinary(dst, src0, src1, mask, repeatTime, repeatParams, "FusedMulAddRelu")) { |
| @@ -1401,6 +1459,10 @@ __aicore__ inline void FusedMulAddRelu(const LocalTensor<T>& dst, const LocalTen | |||
| 1401 | return; | 1459 | return; |
| 1402 | } | 1460 | } |
| 1403 | #endif | 1461 | #endif |
| 1462 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 1463 | + CheckVectorTensor("FusedMulAddRelu", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 1464 | + CheckMaskValue<PrimType, isSetMask>(mask, "FusedMulAddRelu"); | ||
| 1465 | +#endif | ||
| 1404 | #if ASCENDC_CPU_DEBUG | 1466 | #if ASCENDC_CPU_DEBUG |
| 1405 | MaskSetter::Instance().SetMask(isSetMask); | 1467 | MaskSetter::Instance().SetMask(isSetMask); |
| 1406 | if (!CheckFuncVecBinary(dst, src0, src1, mask, repeatTime, repeatParams, "FusedMulAddRelu")) { | 1468 | if (!CheckFuncVecBinary(dst, src0, src1, mask, repeatTime, repeatParams, "FusedMulAddRelu")) { |
| @@ -1430,6 +1492,10 @@ __aicore__ inline void MulAddRelu(const LocalTensor<T>& dst, const LocalTensor<T | |||
| 1430 | return; | 1492 | return; |
| 1431 | } | 1493 | } |
| 1432 | #endif | 1494 | #endif |
| 1495 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 1496 | + CheckVectorTensor("MulAddRelu", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 1497 | + CheckCalcount(count, "count", "MulAddRelu"); | ||
| 1498 | +#endif | ||
| 1433 | #if ASCENDC_CPU_DEBUG | 1499 | #if ASCENDC_CPU_DEBUG |
| 1434 | if (!CheckFuncVecBinary(dst, src0, src1, count, "MulAddRelu")) { | 1500 | if (!CheckFuncVecBinary(dst, src0, src1, count, "MulAddRelu")) { |
| 1435 | ASCENDC_REPORT_CHECK_ERROR("MulAddRelu", KernelFuncType::CALCOUNT_MODE); | 1501 | ASCENDC_REPORT_CHECK_ERROR("MulAddRelu", KernelFuncType::CALCOUNT_MODE); |
| @@ -1449,6 +1515,10 @@ __aicore__ inline void FusedMulAddRelu(const LocalTensor<T>& dst, const LocalTen | |||
| 1449 | return; | 1515 | return; |
| 1450 | } | 1516 | } |
| 1451 | #endif | 1517 | #endif |
| 1518 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 1519 | + CheckVectorTensor("FusedMulAddRelu", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 1520 | + CheckCalcount(count, "count", "FusedMulAddRelu"); | ||
| 1521 | +#endif | ||
| 1452 | #if ASCENDC_CPU_DEBUG | 1522 | #if ASCENDC_CPU_DEBUG |
| 1453 | if (!CheckFuncVecBinary(dst, src0, src1, count, "FusedMulAddRelu")) { | 1523 | if (!CheckFuncVecBinary(dst, src0, src1, count, "FusedMulAddRelu")) { |
| 1454 | ASCENDC_REPORT_CHECK_ERROR("FusedMulAddRelu", KernelFuncType::CALCOUNT_MODE); | 1524 | ASCENDC_REPORT_CHECK_ERROR("FusedMulAddRelu", KernelFuncType::CALCOUNT_MODE); |
| @@ -1481,8 +1551,7 @@ __aicore__ inline void FusedMulAddRelu(const LocalTensor<T>& dst, const LocalTen | |||
| 1481 | */ | 1551 | */ |
| 1482 | template <typename T, bool isSetMask> | 1552 | template <typename T, bool isSetMask> |
| 1483 | __aicore__ inline void SubRelu(const LocalTensor<T>& dst, const LocalTensor<T>& src0, | 1553 | __aicore__ inline void SubRelu(const LocalTensor<T>& dst, const LocalTensor<T>& src0, |
| 1484 | - const LocalTensor<T>& src1, uint64_t mask[], const uint8_t repeatTime, | 1554 | + const LocalTensor<T>& src1, uint64_t mask[], const uint8_t repeatTime, const BinaryRepeatParams& repeatParams) |
| 1485 | - const BinaryRepeatParams& repeatParams) | ||
| 1486 | { | 1555 | { |
| 1487 | using PrimType = PrimT<T>; | 1556 | using PrimType = PrimT<T>; |
| 1488 | #if __NPU_ARCH__ == 2201 | 1557 | #if __NPU_ARCH__ == 2201 |
| @@ -1490,6 +1559,10 @@ __aicore__ inline void SubRelu(const LocalTensor<T>& dst, const LocalTensor<T>& | |||
| 1490 | return; | 1559 | return; |
| 1491 | } | 1560 | } |
| 1492 | #endif | 1561 | #endif |
| 1562 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 1563 | + CheckVectorTensor("SubRelu", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 1564 | + CheckMaskArray<PrimType, isSetMask>(mask, "SubRelu"); | ||
| 1565 | +#endif | ||
| 1493 | #if ASCENDC_CPU_DEBUG | 1566 | #if ASCENDC_CPU_DEBUG |
| 1494 | MaskSetter::Instance().SetMask(isSetMask); | 1567 | MaskSetter::Instance().SetMask(isSetMask); |
| 1495 | if (!CheckFuncVecBinary(dst, src0, src1, mask, repeatTime, repeatParams, "SubRelu")) { | 1568 | if (!CheckFuncVecBinary(dst, src0, src1, mask, repeatTime, repeatParams, "SubRelu")) { |
| @@ -1514,6 +1587,10 @@ __aicore__ inline void SubRelu(const LocalTensor<T>& dst, const LocalTensor<T>& | |||
| 1514 | return; | 1587 | return; |
| 1515 | } | 1588 | } |
| 1516 | #endif | 1589 | #endif |
| 1590 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 1591 | + CheckVectorTensor("SubRelu", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 1592 | + CheckMaskValue<PrimType, isSetMask>(mask, "SubRelu"); | ||
| 1593 | +#endif | ||
| 1517 | #if ASCENDC_CPU_DEBUG | 1594 | #if ASCENDC_CPU_DEBUG |
| 1518 | MaskSetter::Instance().SetMask(isSetMask); | 1595 | MaskSetter::Instance().SetMask(isSetMask); |
| 1519 | if (!CheckFuncVecBinary(dst, src0, src1, mask, repeatTime, repeatParams, "SubRelu")) { | 1596 | if (!CheckFuncVecBinary(dst, src0, src1, mask, repeatTime, repeatParams, "SubRelu")) { |
| @@ -1538,6 +1615,10 @@ __aicore__ inline void SubRelu(const LocalTensor<T>& dst, const LocalTensor<T>& | |||
| 1538 | return; | 1615 | return; |
| 1539 | } | 1616 | } |
| 1540 | #endif | 1617 | #endif |
| 1618 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 1619 | + CheckVectorTensor("SubRelu", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 1620 | + CheckCalcount(count, "count", "SubRelu"); | ||
| 1621 | +#endif | ||
| 1541 | #if ASCENDC_CPU_DEBUG | 1622 | #if ASCENDC_CPU_DEBUG |
| 1542 | if (!CheckFuncVecBinary(dst, src0, src1, count, "SubRelu")) { | 1623 | if (!CheckFuncVecBinary(dst, src0, src1, count, "SubRelu")) { |
| 1543 | ASCENDC_REPORT_CHECK_ERROR("SubRelu", KernelFuncType::CALCOUNT_MODE); | 1624 | ASCENDC_REPORT_CHECK_ERROR("SubRelu", KernelFuncType::CALCOUNT_MODE); |
| @@ -1714,4 +1795,4 @@ __aicore__ inline void FusedExpSub(const LocalTensor<T> &dst, const LocalTensor< | |||
| 1714 | #if defined(__UNDEF_ASCENDC_INCLUDE_INTERNAL_HEADERS_KERNEL_OPERATOR_VEC_BINARY_INTF_IMPL_H__) | 1795 | #if defined(__UNDEF_ASCENDC_INCLUDE_INTERNAL_HEADERS_KERNEL_OPERATOR_VEC_BINARY_INTF_IMPL_H__) |
| 1715 | #undef __ASCENDC_INCLUDE_INTERNAL_HEADERS__ | 1796 | #undef __ASCENDC_INCLUDE_INTERNAL_HEADERS__ |
| 1716 | #undef __UNDEF_ASCENDC_INCLUDE_INTERNAL_HEADERS_KERNEL_OPERATOR_VEC_BINARY_INTF_IMPL_H__ | 1797 | #undef __UNDEF_ASCENDC_INCLUDE_INTERNAL_HEADERS_KERNEL_OPERATOR_VEC_BINARY_INTF_IMPL_H__ |
| 1717 | -#endif | 1798 | +#endif |
| @@ -21,6 +21,7 @@ | |||
| 21 | #define ASCENDC_MODULE_OPERATOR_VEC_TERNARY_SCALAR_INTERFACE_IMPL_H | 21 | #define ASCENDC_MODULE_OPERATOR_VEC_TERNARY_SCALAR_INTERFACE_IMPL_H |
| 22 | #include "kernel_tensor.h" | 22 | #include "kernel_tensor.h" |
| 23 | #include "kernel_struct_unary.h" | 23 | #include "kernel_struct_unary.h" |
| 24 | +#include "kernel_npu_debug.h" | ||
| 24 | #include "mstx_local_tensor_info.h" | 25 | #include "mstx_local_tensor_info.h" |
| 25 | 26 | ||
| 26 | #if __NPU_ARCH__ == 1001 | 27 | #if __NPU_ARCH__ == 1001 |
| @@ -63,6 +64,11 @@ template <typename T, typename U, bool isSetMask> | |||
| 63 | __aicore__ inline void Axpy(const LocalTensor<T>& dst, const LocalTensor<U>& src, const U& scalarValue, | 64 | __aicore__ inline void Axpy(const LocalTensor<T>& dst, const LocalTensor<U>& src, const U& scalarValue, |
| 64 | uint64_t mask, const uint8_t repeatTime, const UnaryRepeatParams& repeatParams) | 65 | uint64_t mask, const uint8_t repeatTime, const UnaryRepeatParams& repeatParams) |
| 65 | { | 66 | { |
| 67 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 68 | + using MaskCheckType = typename Conditional<(sizeof(PrimT<T>) >= sizeof(PrimT<U>)), PrimT<T>, PrimT<U>>::type; | ||
| 69 | + CheckVectorTensor("Axpy", NamedTensor(dst, "dst"), NamedTensor(src, "src")); | ||
| 70 | + CheckMaskValue<MaskCheckType, isSetMask>(mask, "Axpy"); | ||
| 71 | +#endif | ||
| 66 | #if ASCENDC_CPU_DEBUG | 72 | #if ASCENDC_CPU_DEBUG |
| 67 | MaskSetter::Instance().SetMask(isSetMask); | 73 | MaskSetter::Instance().SetMask(isSetMask); |
| 68 | if (!CheckFunVecBinaryScalarDiffType(dst, src, scalarValue, mask, repeatTime, repeatParams, "Axpy")) { | 74 | if (!CheckFunVecBinaryScalarDiffType(dst, src, scalarValue, mask, repeatTime, repeatParams, "Axpy")) { |
| @@ -80,6 +86,11 @@ template <typename T, typename U, bool isSetMask> | |||
| 80 | __aicore__ inline void Axpy(const LocalTensor<T>& dst, const LocalTensor<U>& src, const U& scalarValue, | 86 | __aicore__ inline void Axpy(const LocalTensor<T>& dst, const LocalTensor<U>& src, const U& scalarValue, |
| 81 | uint64_t mask[], const uint8_t repeatTime, const UnaryRepeatParams& repeatParams) | 87 | uint64_t mask[], const uint8_t repeatTime, const UnaryRepeatParams& repeatParams) |
| 82 | { | 88 | { |
| 89 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 90 | + using MaskCheckType = typename Conditional<(sizeof(PrimT<T>) >= sizeof(PrimT<U>)), PrimT<T>, PrimT<U>>::type; | ||
| 91 | + CheckVectorTensor("Axpy", NamedTensor(dst, "dst"), NamedTensor(src, "src")); | ||
| 92 | + CheckMaskArray<MaskCheckType, isSetMask>(mask, "Axpy"); | ||
| 93 | +#endif | ||
| 83 | #if ASCENDC_CPU_DEBUG | 94 | #if ASCENDC_CPU_DEBUG |
| 84 | MaskSetter::Instance().SetMask(isSetMask); | 95 | MaskSetter::Instance().SetMask(isSetMask); |
| 85 | if (!CheckFunVecBinaryScalarDiffType(dst, src, scalarValue, mask, repeatTime, repeatParams, "Axpy")) { | 96 | if (!CheckFunVecBinaryScalarDiffType(dst, src, scalarValue, mask, repeatTime, repeatParams, "Axpy")) { |
| @@ -105,6 +116,10 @@ template <typename T, typename U> | |||
| 105 | __aicore__ inline void Axpy(const LocalTensor<T>& dst, const LocalTensor<U>& src, const U& scalarValue, | 116 | __aicore__ inline void Axpy(const LocalTensor<T>& dst, const LocalTensor<U>& src, const U& scalarValue, |
| 106 | const int32_t& count) | 117 | const int32_t& count) |
| 107 | { | 118 | { |
| 119 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 120 | + CheckVectorTensor("Axpy", NamedTensor(dst, "dst"), NamedTensor(src, "src")); | ||
| 121 | + CheckCalcount(count, "count", "Axpy"); | ||
| 122 | +#endif | ||
| 108 | #if ASCENDC_CPU_DEBUG | 123 | #if ASCENDC_CPU_DEBUG |
| 109 | if (!CheckFunVecBinaryScalarDiffType(dst, src, scalarValue, count, "Axpy")) { | 124 | if (!CheckFunVecBinaryScalarDiffType(dst, src, scalarValue, count, "Axpy")) { |
| 110 | ASCENDC_REPORT_CHECK_ERROR("Axpy", KernelFuncType::CALCOUNT_MODE); | 125 | ASCENDC_REPORT_CHECK_ERROR("Axpy", KernelFuncType::CALCOUNT_MODE); |
| @@ -121,4 +136,4 @@ __aicore__ inline void Axpy(const LocalTensor<T>& dst, const LocalTensor<U>& src | |||
| 121 | #if defined(__UNDEF_ASCENDC_INCLUDE_INTERNAL_HEADERS_KERNEL_OPERATOR_VEC_TERNARY_SCALAR_INTF_IMPL_H__) | 136 | #if defined(__UNDEF_ASCENDC_INCLUDE_INTERNAL_HEADERS_KERNEL_OPERATOR_VEC_TERNARY_SCALAR_INTF_IMPL_H__) |
| 122 | #undef __ASCENDC_INCLUDE_INTERNAL_HEADERS__ | 137 | #undef __ASCENDC_INCLUDE_INTERNAL_HEADERS__ |
| 123 | #undef __UNDEF_ASCENDC_INCLUDE_INTERNAL_HEADERS_KERNEL_OPERATOR_VEC_TERNARY_SCALAR_INTF_IMPL_H__ | 138 | #undef __UNDEF_ASCENDC_INCLUDE_INTERNAL_HEADERS_KERNEL_OPERATOR_VEC_TERNARY_SCALAR_INTF_IMPL_H__ |
| 124 | -#endif | 139 | +#endif |
| @@ -195,6 +195,12 @@ __aicore__ inline void CastDequant(const LocalTensor<T>& dst, const LocalTensor< | |||
| 195 | { | 195 | { |
| 196 | using DstPrimType = PrimT<T>; | 196 | using DstPrimType = PrimT<T>; |
| 197 | using SrcPrimType = PrimT<U>; | 197 | using SrcPrimType = PrimT<U>; |
| 198 | + using MaskCheckType = typename Conditional<(sizeof(DstPrimType) >= sizeof(SrcPrimType)), | ||
| 199 | + DstPrimType, SrcPrimType>::type; | ||
| 200 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 201 | + CheckVectorTensor("CastDequant", NamedTensor(dst, "dst"), NamedTensor(src, "src")); | ||
| 202 | + CheckMaskArray<MaskCheckType, isSetMask>(mask, "CastDequant"); | ||
| 203 | +#endif | ||
| 198 | #if ASCENDC_CPU_DEBUG | 204 | #if ASCENDC_CPU_DEBUG |
| 199 | MaskSetter::Instance().SetMask(isSetMask); | 205 | MaskSetter::Instance().SetMask(isSetMask); |
| 200 | if (!CheckFunVecBinaryScalarDiffType(dst.template ReinterpretCast<half>(), src, static_cast<SrcPrimType>(0), mask, | 206 | if (!CheckFunVecBinaryScalarDiffType(dst.template ReinterpretCast<half>(), src, static_cast<SrcPrimType>(0), mask, |
| @@ -211,6 +217,12 @@ __aicore__ inline void CastDequant(const LocalTensor<T>& dst, const LocalTensor< | |||
| 211 | { | 217 | { |
| 212 | using DstPrimType = PrimT<T>; | 218 | using DstPrimType = PrimT<T>; |
| 213 | using SrcPrimType = PrimT<U>; | 219 | using SrcPrimType = PrimT<U>; |
| 220 | + using MaskCheckType = typename Conditional<(sizeof(DstPrimType) >= sizeof(SrcPrimType)), | ||
| 221 | + DstPrimType, SrcPrimType>::type; | ||
| 222 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 223 | + CheckVectorTensor("CastDequant", NamedTensor(dst, "dst"), NamedTensor(src, "src")); | ||
| 224 | + CheckMaskValue<MaskCheckType, isSetMask>(mask, "CastDequant"); | ||
| 225 | +#endif | ||
| 214 | #if ASCENDC_CPU_DEBUG | 226 | #if ASCENDC_CPU_DEBUG |
| 215 | MaskSetter::Instance().SetMask(isSetMask); | 227 | MaskSetter::Instance().SetMask(isSetMask); |
| 216 | if (!CheckFunVecBinaryScalarDiffType(dst.template ReinterpretCast<half>(), src, static_cast<SrcPrimType>(0), mask, | 228 | if (!CheckFunVecBinaryScalarDiffType(dst.template ReinterpretCast<half>(), src, static_cast<SrcPrimType>(0), mask, |
| @@ -232,6 +244,12 @@ __aicore__ inline void CastDeq(const LocalTensor<T>& dst, const LocalTensor<U>& | |||
| 232 | #endif | 244 | #endif |
| 233 | using DstPrimType = PrimT<T>; | 245 | using DstPrimType = PrimT<T>; |
| 234 | using SrcPrimType = PrimT<U>; | 246 | using SrcPrimType = PrimT<U>; |
| 247 | + using MaskCheckType = typename Conditional<(sizeof(DstPrimType) >= sizeof(SrcPrimType)), | ||
| 248 | + DstPrimType, SrcPrimType>::type; | ||
| 249 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 250 | + CheckVectorTensor("CastDeq", NamedTensor(dst, "dst"), NamedTensor(src, "src")); | ||
| 251 | + CheckMaskArray<MaskCheckType, isSetMask>(mask, "CastDeq"); | ||
| 252 | +#endif | ||
| 235 | #if ASCENDC_CPU_DEBUG | 253 | #if ASCENDC_CPU_DEBUG |
| 236 | MaskSetter::Instance().SetMask(isSetMask); | 254 | MaskSetter::Instance().SetMask(isSetMask); |
| 237 | if (!CheckFunVecBinaryScalarDiffType(dst.template ReinterpretCast<half>(), src, static_cast<SrcPrimType>(0), mask, | 255 | if (!CheckFunVecBinaryScalarDiffType(dst.template ReinterpretCast<half>(), src, static_cast<SrcPrimType>(0), mask, |
| @@ -253,6 +271,12 @@ __aicore__ inline void CastDeq(const LocalTensor<T>& dst, const LocalTensor<U>& | |||
| 253 | #endif | 271 | #endif |
| 254 | using DstPrimType = PrimT<T>; | 272 | using DstPrimType = PrimT<T>; |
| 255 | using SrcPrimType = PrimT<U>; | 273 | using SrcPrimType = PrimT<U>; |
| 274 | + using MaskCheckType = typename Conditional<(sizeof(DstPrimType) >= sizeof(SrcPrimType)), | ||
| 275 | + DstPrimType, SrcPrimType>::type; | ||
| 276 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 277 | + CheckVectorTensor("CastDeq", NamedTensor(dst, "dst"), NamedTensor(src, "src")); | ||
| 278 | + CheckMaskValue<MaskCheckType, isSetMask>(mask, "CastDeq"); | ||
| 279 | +#endif | ||
| 256 | #if ASCENDC_CPU_DEBUG | 280 | #if ASCENDC_CPU_DEBUG |
| 257 | MaskSetter::Instance().SetMask(isSetMask); | 281 | MaskSetter::Instance().SetMask(isSetMask); |
| 258 | if (!CheckFunVecBinaryScalarDiffType(dst.template ReinterpretCast<half>(), src, static_cast<SrcPrimType>(0), mask, | 282 | if (!CheckFunVecBinaryScalarDiffType(dst.template ReinterpretCast<half>(), src, static_cast<SrcPrimType>(0), mask, |
| @@ -281,6 +305,10 @@ __aicore__ inline void CastDequant(const LocalTensor<T>& dst, const LocalTensor< | |||
| 281 | { | 305 | { |
| 282 | using DstPrimType = PrimT<T>; | 306 | using DstPrimType = PrimT<T>; |
| 283 | using SrcPrimType = PrimT<U>; | 307 | using SrcPrimType = PrimT<U>; |
| 308 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 309 | + CheckVectorTensor("CastDequant", NamedTensor(dst, "dst"), NamedTensor(src, "src")); | ||
| 310 | + CheckCalcount(static_cast<int32_t>(count), "count", "CastDequant"); | ||
| 311 | +#endif | ||
| 284 | #if ASCENDC_CPU_DEBUG | 312 | #if ASCENDC_CPU_DEBUG |
| 285 | if (!CheckFunVecBinaryScalarDiffType(dst.template ReinterpretCast<half>(), src, static_cast<SrcPrimType>(0), | 313 | if (!CheckFunVecBinaryScalarDiffType(dst.template ReinterpretCast<half>(), src, static_cast<SrcPrimType>(0), |
| 286 | count, "CastDequant")) { | 314 | count, "CastDequant")) { |
| @@ -301,6 +329,10 @@ __aicore__ inline void CastDeq(const LocalTensor<T>& dst, const LocalTensor<U>& | |||
| 301 | #endif | 329 | #endif |
| 302 | using DstPrimType = PrimT<T>; | 330 | using DstPrimType = PrimT<T>; |
| 303 | using SrcPrimType = PrimT<U>; | 331 | using SrcPrimType = PrimT<U>; |
| 332 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 333 | + CheckVectorTensor("CastDeq", NamedTensor(dst, "dst"), NamedTensor(src, "src")); | ||
| 334 | + CheckCalcount(static_cast<int32_t>(count), "count", "CastDeq"); | ||
| 335 | +#endif | ||
| 304 | #if ASCENDC_CPU_DEBUG | 336 | #if ASCENDC_CPU_DEBUG |
| 305 | if (!CheckFunVecBinaryScalarDiffType(dst.template ReinterpretCast<half>(), src, static_cast<SrcPrimType>(0), | 337 | if (!CheckFunVecBinaryScalarDiffType(dst.template ReinterpretCast<half>(), src, static_cast<SrcPrimType>(0), |
| 306 | count, "CastDeq")) { | 338 | count, "CastDeq")) { |
| @@ -329,16 +361,22 @@ __aicore__ inline void CastDeq(const LocalTensor<T>& dst, const LocalTensor<U>& | |||
| 329 | * @param [in] intriParams.src0RepStride src repeat stride | 361 | * @param [in] intriParams.src0RepStride src repeat stride |
| 330 | * @param [in] intriParams.src1RepStride src repeat stride | 362 | * @param [in] intriParams.src1RepStride src repeat stride |
| 331 | */ | 363 | */ |
| 332 | -// AddReluCast::Level 0 - mask count mode | ||
| 333 | template <typename T, typename U, bool isSetMask> | 364 | template <typename T, typename U, bool isSetMask> |
| 334 | -__aicore__ inline void AddReluCast(const LocalTensor<T>& dst, const LocalTensor<U>& src0, | 365 | +__aicore__ inline void AddReluCast(const LocalTensor<T>& dst, const LocalTensor<U>& src0, const LocalTensor<U>& src1, |
| 335 | - const LocalTensor<U>& src1, uint64_t mask, const uint8_t repeatTime, const BinaryRepeatParams& repeatParams) | 366 | + uint64_t mask, const uint8_t repeatTime, const BinaryRepeatParams& repeatParams) |
| 336 | { | 367 | { |
| 368 | + using SrcPrimType = PrimT<U>; | ||
| 369 | + using DstPrimType = PrimT<T>; | ||
| 370 | + using MaskCheckType = typename Conditional<(sizeof(DstPrimType) >= sizeof(SrcPrimType)), DstPrimType, SrcPrimType>::type; | ||
| 337 | #if __NPU_ARCH__ == 2201 | 371 | #if __NPU_ARCH__ == 2201 |
| 338 | if (g_coreType == AIC) { | 372 | if (g_coreType == AIC) { |
| 339 | return; | 373 | return; |
| 340 | } | 374 | } |
| 341 | #endif | 375 | #endif |
| 376 | +#if defined(ASCENDC_CPU_DEBUG) || defined(ASCENDC_DEBUG) | ||
| 377 | + CheckVectorTensor("AddReluCast", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 378 | + CheckMaskValue<MaskCheckType, isSetMask>(mask, "AddReluCast"); | ||
| 379 | +#endif | ||
| 342 | #if ASCENDC_CPU_DEBUG | 380 | #if ASCENDC_CPU_DEBUG |
| 343 | MaskSetter::Instance().SetMask(isSetMask); | 381 | MaskSetter::Instance().SetMask(isSetMask); |
| 344 | if (!CheckFuncVecBinaryCmp(dst, src0, src1, mask, repeatTime, repeatParams, "AddReluCast")) { | 382 | if (!CheckFuncVecBinaryCmp(dst, src0, src1, mask, repeatTime, repeatParams, "AddReluCast")) { |
| @@ -348,21 +386,27 @@ __aicore__ inline void AddReluCast(const LocalTensor<T>& dst, const LocalTensor< | |||
| 348 | #ifdef __MSTX_DFX_REPORT__ | 386 | #ifdef __MSTX_DFX_REPORT__ |
| 349 | MstxTensor::GetMstxVecBinaryInfo(dst, src0, src1, mask, repeatTime, repeatParams, isSetMask, "AddReluCast"); | 387 | MstxTensor::GetMstxVecBinaryInfo(dst, src0, src1, mask, repeatTime, repeatParams, isSetMask, "AddReluCast"); |
| 350 | #endif | 388 | #endif |
| 351 | - AddReluCastImpl<PrimT<T>, PrimT<U>, isSetMask>((__ubuf__ PrimT<T>*)dst.GetPhyAddr(), (__ubuf__ PrimT<U>*)src0.GetPhyAddr(), | 389 | + AddReluCastImpl<DstPrimType, SrcPrimType, isSetMask>((__ubuf__ DstPrimType*)dst.GetPhyAddr(), |
| 352 | - (__ubuf__ PrimT<U>*)src1.GetPhyAddr(), mask, repeatTime, repeatParams); | 390 | + (__ubuf__ SrcPrimType*)src0.GetPhyAddr(), (__ubuf__ SrcPrimType*)src1.GetPhyAddr(), mask, repeatTime, |
| 391 | + repeatParams); | ||
| 353 | } | 392 | } |
| 354 | 393 | ||
| 355 | -// AddReluCast::Level 0 - mask bit mode | ||
| 356 | template <typename T, typename U, bool isSetMask> | 394 | template <typename T, typename U, bool isSetMask> |
| 357 | -__aicore__ inline void AddReluCast(const LocalTensor<T>& dst, const LocalTensor<U>& src0, | 395 | +__aicore__ inline void AddReluCast(const LocalTensor<T>& dst, const LocalTensor<U>& src0, const LocalTensor<U>& src1, |
| 358 | - const LocalTensor<U>& src1, uint64_t mask[], const uint8_t repeatTime, | 396 | + uint64_t mask[], const uint8_t repeatTime, const BinaryRepeatParams& repeatParams) |
| 359 | - const BinaryRepeatParams& repeatParams) | ||
| 360 | { | 397 | { |
| 398 | + using SrcPrimType = PrimT<U>; | ||
| 399 | + using DstPrimType = PrimT<T>; | ||
| 400 | + using MaskCheckType = typename Conditional<(sizeof(DstPrimType) >= sizeof(SrcPrimType)), DstPrimType, SrcPrimType>::type; | ||
| 361 | #if __NPU_ARCH__ == 2201 | 401 | #if __NPU_ARCH__ == 2201 |
| 362 | if (g_coreType == AIC) { | 402 | if (g_coreType == AIC) { |
| 363 | return; | 403 | return; |
| 364 | } | 404 | } |
| 365 | #endif | 405 | #endif |
| 406 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 407 | + CheckVectorTensor("AddReluCast", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 408 | + CheckMaskArray<MaskCheckType, isSetMask>(mask, "AddReluCast"); | ||
| 409 | +#endif | ||
| 366 | #if ASCENDC_CPU_DEBUG | 410 | #if ASCENDC_CPU_DEBUG |
| 367 | MaskSetter::Instance().SetMask(isSetMask); | 411 | MaskSetter::Instance().SetMask(isSetMask); |
| 368 | if (!CheckFuncVecBinaryCmp(dst, src0, src1, mask, repeatTime, repeatParams, "AddReluCast")) { | 412 | if (!CheckFuncVecBinaryCmp(dst, src0, src1, mask, repeatTime, repeatParams, "AddReluCast")) { |
| @@ -372,8 +416,9 @@ __aicore__ inline void AddReluCast(const LocalTensor<T>& dst, const LocalTensor< | |||
| 372 | #ifdef __MSTX_DFX_REPORT__ | 416 | #ifdef __MSTX_DFX_REPORT__ |
| 373 | MstxTensor::GetMstxVecBinaryInfo(dst, src0, src1, mask[0], mask[1], repeatTime, repeatParams, isSetMask, "AddReluCast"); | 417 | MstxTensor::GetMstxVecBinaryInfo(dst, src0, src1, mask[0], mask[1], repeatTime, repeatParams, isSetMask, "AddReluCast"); |
| 374 | #endif | 418 | #endif |
| 375 | - AddReluCastImpl<PrimT<T>, PrimT<U>, isSetMask>((__ubuf__ PrimT<T>*)dst.GetPhyAddr(), (__ubuf__ PrimT<U>*)src0.GetPhyAddr(), | 419 | + AddReluCastImpl<DstPrimType, SrcPrimType, isSetMask>((__ubuf__ DstPrimType*)dst.GetPhyAddr(), |
| 376 | - (__ubuf__ PrimT<U>*)src1.GetPhyAddr(), mask, repeatTime, repeatParams); | 420 | + (__ubuf__ SrcPrimType*)src0.GetPhyAddr(), (__ubuf__ SrcPrimType*)src1.GetPhyAddr(), mask, repeatTime, |
| 421 | + repeatParams); | ||
| 377 | } | 422 | } |
| 378 | 423 | ||
| 379 | /* | 424 | /* |
| @@ -385,14 +430,18 @@ __aicore__ inline void AddReluCast(const LocalTensor<T>& dst, const LocalTensor< | |||
| 385 | * @param [in] count number Number of data involved in calculation | 430 | * @param [in] count number Number of data involved in calculation |
| 386 | */ | 431 | */ |
| 387 | template <typename T, typename U> | 432 | template <typename T, typename U> |
| 388 | -__aicore__ inline void AddReluCast(const LocalTensor<T>& dst, const LocalTensor<U>& src0, | 433 | +__aicore__ inline void AddReluCast(const LocalTensor<T>& dst, const LocalTensor<U>& src0, const LocalTensor<U>& src1, |
| 389 | - const LocalTensor<U>& src1, const uint32_t count) | 434 | + const uint32_t count) |
| 390 | { | 435 | { |
| 391 | #if __NPU_ARCH__ == 2201 | 436 | #if __NPU_ARCH__ == 2201 |
| 392 | if (g_coreType == AIC) { | 437 | if (g_coreType == AIC) { |
| 393 | return; | 438 | return; |
| 394 | } | 439 | } |
| 395 | #endif | 440 | #endif |
| 441 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 442 | + CheckVectorTensor("AddReluCast", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 443 | + CheckCalcount(static_cast<int32_t>(count), "count", "AddReluCast"); | ||
| 444 | +#endif | ||
| 396 | #if ASCENDC_CPU_DEBUG | 445 | #if ASCENDC_CPU_DEBUG |
| 397 | if (!CheckFuncVecBinaryCmp(dst, src0, src1, count, "AddReluCast")) { | 446 | if (!CheckFuncVecBinaryCmp(dst, src0, src1, count, "AddReluCast")) { |
| 398 | ASCENDC_REPORT_CHECK_ERROR("AddReluCast", KernelFuncType::CALCOUNT_MODE); | 447 | ASCENDC_REPORT_CHECK_ERROR("AddReluCast", KernelFuncType::CALCOUNT_MODE); |
| @@ -401,8 +450,8 @@ __aicore__ inline void AddReluCast(const LocalTensor<T>& dst, const LocalTensor< | |||
| 401 | #ifdef __MSTX_DFX_REPORT__ | 450 | #ifdef __MSTX_DFX_REPORT__ |
| 402 | MstxTensor::GetMstxVecBinaryInfo(dst, src0, src1, "AddReluCast", count); | 451 | MstxTensor::GetMstxVecBinaryInfo(dst, src0, src1, "AddReluCast", count); |
| 403 | #endif | 452 | #endif |
| 404 | - AddReluCastImpl((__ubuf__ PrimT<T>*)dst.GetPhyAddr(), (__ubuf__ PrimT<U>*)src0.GetPhyAddr(), | 453 | + AddReluCastImpl((__ubuf__ PrimT<T>*)dst.GetPhyAddr(), (__ubuf__ PrimT<U>*)src0.GetPhyAddr(), |
| 405 | - (__ubuf__ PrimT<U>*)src1.GetPhyAddr(), count); | 454 | + (__ubuf__ PrimT<U>*)src1.GetPhyAddr(), count); |
| 406 | } | 455 | } |
| 407 | 456 | ||
| 408 | /* ************************************************************************************************** | 457 | /* ************************************************************************************************** |
| @@ -423,18 +472,22 @@ __aicore__ inline void AddReluCast(const LocalTensor<T>& dst, const LocalTensor< | |||
| 423 | * @param [in] intriParams.src0RepStride src repeat stride | 472 | * @param [in] intriParams.src0RepStride src repeat stride |
| 424 | * @param [in] intriParams.src1RepStride src repeat stride | 473 | * @param [in] intriParams.src1RepStride src repeat stride |
| 425 | */ | 474 | */ |
| 426 | -// AddReluCast::Level 0 - mask count mode | ||
| 427 | template <typename T, typename U, bool isSetMask> | 475 | template <typename T, typename U, bool isSetMask> |
| 428 | -__aicore__ inline void SubReluCast(const LocalTensor<T>& dst, const LocalTensor<U>& src0, | 476 | +__aicore__ inline void SubReluCast(const LocalTensor<T>& dst, const LocalTensor<U>& src0, const LocalTensor<U>& src1, |
| 429 | - const LocalTensor<U>& src1, uint64_t mask, const uint8_t repeatTime, const BinaryRepeatParams& repeatParams) | 477 | + uint64_t mask, const uint8_t repeatTime, const BinaryRepeatParams& repeatParams) |
| 430 | { | 478 | { |
| 431 | - using DstPrimType = PrimT<T>; | 479 | + using DstPrimType = PrimT<T>; |
| 432 | using SrcPrimType = PrimT<U>; | 480 | using SrcPrimType = PrimT<U>; |
| 481 | + using MaskCheckType = typename Conditional<(sizeof(DstPrimType) >= sizeof(SrcPrimType)), DstPrimType, SrcPrimType>::type; | ||
| 433 | #if __NPU_ARCH__ == 2201 | 482 | #if __NPU_ARCH__ == 2201 |
| 434 | if (g_coreType == AIC) { | 483 | if (g_coreType == AIC) { |
| 435 | return; | 484 | return; |
| 436 | } | 485 | } |
| 437 | #endif | 486 | #endif |
| 487 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 488 | + CheckVectorTensor("SubReluCast", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 489 | + CheckMaskValue<MaskCheckType, isSetMask>(mask, "SubReluCast"); | ||
| 490 | +#endif | ||
| 438 | #if ASCENDC_CPU_DEBUG | 491 | #if ASCENDC_CPU_DEBUG |
| 439 | MaskSetter::Instance().SetMask(isSetMask); | 492 | MaskSetter::Instance().SetMask(isSetMask); |
| 440 | if (!CheckFuncVecBinaryCmp(dst, src0, src1, mask, repeatTime, repeatParams, "SubReluCast")) { | 493 | if (!CheckFuncVecBinaryCmp(dst, src0, src1, mask, repeatTime, repeatParams, "SubReluCast")) { |
| @@ -444,23 +497,27 @@ __aicore__ inline void SubReluCast(const LocalTensor<T>& dst, const LocalTensor< | |||
| 444 | #ifdef __MSTX_DFX_REPORT__ | 497 | #ifdef __MSTX_DFX_REPORT__ |
| 445 | MstxTensor::GetMstxVecBinaryInfo(dst, src0, src1, mask, repeatTime, repeatParams, isSetMask, "SubReluCast"); | 498 | MstxTensor::GetMstxVecBinaryInfo(dst, src0, src1, mask, repeatTime, repeatParams, isSetMask, "SubReluCast"); |
| 446 | #endif | 499 | #endif |
| 447 | - SubReluCastImpl<DstPrimType, SrcPrimType, isSetMask>((__ubuf__ DstPrimType*)dst.GetPhyAddr(), (__ubuf__ SrcPrimType*)src0.GetPhyAddr(), | 500 | + SubReluCastImpl<DstPrimType, SrcPrimType, isSetMask>((__ubuf__ DstPrimType*)dst.GetPhyAddr(), |
| 448 | - (__ubuf__ SrcPrimType*)src1.GetPhyAddr(), mask, repeatTime, repeatParams); | 501 | + (__ubuf__ SrcPrimType*)src0.GetPhyAddr(), (__ubuf__ SrcPrimType*)src1.GetPhyAddr(), mask, repeatTime, |
| 502 | + repeatParams); | ||
| 449 | } | 503 | } |
| 450 | 504 | ||
| 451 | -// SubReluCast::Level 0 - mask bit mode | ||
| 452 | template <typename T, typename U, bool isSetMask> | 505 | template <typename T, typename U, bool isSetMask> |
| 453 | -__aicore__ inline void SubReluCast(const LocalTensor<T>& dst, const LocalTensor<U>& src0, | 506 | +__aicore__ inline void SubReluCast(const LocalTensor<T>& dst, const LocalTensor<U>& src0, const LocalTensor<U>& src1, |
| 454 | - const LocalTensor<U>& src1, uint64_t mask[], const uint8_t repeatTime, | 507 | + uint64_t mask[], const uint8_t repeatTime, const BinaryRepeatParams& repeatParams) |
| 455 | - const BinaryRepeatParams& repeatParams) | ||
| 456 | { | 508 | { |
| 457 | - using DstPrimType = PrimT<T>; | ||
| 458 | using SrcPrimType = PrimT<U>; | 509 | using SrcPrimType = PrimT<U>; |
| 510 | + using DstPrimType = PrimT<T>; | ||
| 511 | + using MaskCheckType = typename Conditional<(sizeof(DstPrimType) >= sizeof(SrcPrimType)), DstPrimType, SrcPrimType>::type; | ||
| 459 | #if __NPU_ARCH__ == 2201 | 512 | #if __NPU_ARCH__ == 2201 |
| 460 | if (g_coreType == AIC) { | 513 | if (g_coreType == AIC) { |
| 461 | return; | 514 | return; |
| 462 | } | 515 | } |
| 463 | #endif | 516 | #endif |
| 517 | +#if defined(ASCENDC_DEBUG) || defined(ASCENDC_CPU_DEBUG) | ||
| 518 | + CheckVectorTensor("SubReluCast", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 519 | + CheckMaskArray<MaskCheckType, isSetMask>(mask, "SubReluCast"); | ||
| 520 | +#endif | ||
| 464 | #if ASCENDC_CPU_DEBUG | 521 | #if ASCENDC_CPU_DEBUG |
| 465 | MaskSetter::Instance().SetMask(isSetMask); | 522 | MaskSetter::Instance().SetMask(isSetMask); |
| 466 | if (!CheckFuncVecBinaryCmp(dst, src0, src1, mask, repeatTime, repeatParams, "SubReluCast")) { | 523 | if (!CheckFuncVecBinaryCmp(dst, src0, src1, mask, repeatTime, repeatParams, "SubReluCast")) { |
| @@ -470,8 +527,9 @@ __aicore__ inline void SubReluCast(const LocalTensor<T>& dst, const LocalTensor< | |||
| 470 | #ifdef __MSTX_DFX_REPORT__ | 527 | #ifdef __MSTX_DFX_REPORT__ |
| 471 | MstxTensor::GetMstxVecBinaryInfo(dst, src0, src1, mask[0], mask[1], repeatTime, repeatParams, isSetMask, "SubReluCast"); | 528 | MstxTensor::GetMstxVecBinaryInfo(dst, src0, src1, mask[0], mask[1], repeatTime, repeatParams, isSetMask, "SubReluCast"); |
| 472 | #endif | 529 | #endif |
| 473 | - SubReluCastImpl<DstPrimType, SrcPrimType, isSetMask>((__ubuf__ DstPrimType*)dst.GetPhyAddr(), (__ubuf__ SrcPrimType*)src0.GetPhyAddr(), | 530 | + SubReluCastImpl<DstPrimType, SrcPrimType, isSetMask>((__ubuf__ DstPrimType*)dst.GetPhyAddr(), |
| 474 | - (__ubuf__ SrcPrimType*)src1.GetPhyAddr(), mask, repeatTime, repeatParams); | 531 | + (__ubuf__ SrcPrimType*)src0.GetPhyAddr(), (__ubuf__ SrcPrimType*)src1.GetPhyAddr(), mask, repeatTime, |
| 532 | + repeatParams); | ||
| 475 | } | 533 | } |
| 476 | 534 | ||
| 477 | /* | 535 | /* |
| @@ -483,16 +541,20 @@ __aicore__ inline void SubReluCast(const LocalTensor<T>& dst, const LocalTensor< | |||
| 483 | * @param [in] count number Number of data involved in calculation | 541 | * @param [in] count number Number of data involved in calculation |
| 484 | */ | 542 | */ |
| 485 | template <typename T, typename U> | 543 | template <typename T, typename U> |
| 486 | -__aicore__ inline void SubReluCast(const LocalTensor<T>& dst, const LocalTensor<U>& src0, | 544 | +__aicore__ inline void SubReluCast(const LocalTensor<T>& dst, const LocalTensor<U>& src0, const LocalTensor<U>& src1, |
| 487 | - const LocalTensor<U>& src1, const uint32_t count) | 545 | + const uint32_t count) |
| 488 | { | 546 | { |
| 489 | - using DstPrimType = PrimT<T>; | 547 | + using DstPrimType = PrimT<T>; |
| 490 | using SrcPrimType = PrimT<U>; | 548 | using SrcPrimType = PrimT<U>; |
| 491 | #if __NPU_ARCH__ == 2201 | 549 | #if __NPU_ARCH__ == 2201 |
| 492 | if (g_coreType == AIC) { | 550 | if (g_coreType == AIC) { |
| 493 | return; | 551 | return; |
| 494 | } | 552 | } |
| 495 | #endif | 553 | #endif |
| 554 | +#if defined(ASCENDC_CPU_DEBUG) || defined(ASCENDC_DEBUG) | ||
| 555 | + CheckVectorTensor("SubReluCast", NamedTensor(dst, "dst"), NamedTensor(src0, "src0"), NamedTensor(src1, "src1")); | ||
| 556 | + CheckCalcount(static_cast<int32_t>(count), "count", "SubReluCast"); | ||
| 557 | +#endif | ||
| 496 | #if ASCENDC_CPU_DEBUG | 558 | #if ASCENDC_CPU_DEBUG |
| 497 | if (!CheckFuncVecBinaryCmp(dst, src0, src1, count, "SubReluCast")) { | 559 | if (!CheckFuncVecBinaryCmp(dst, src0, src1, count, "SubReluCast")) { |
| 498 | ASCENDC_REPORT_CHECK_ERROR("SubReluCast", KernelFuncType::CALCOUNT_MODE); | 560 | ASCENDC_REPORT_CHECK_ERROR("SubReluCast", KernelFuncType::CALCOUNT_MODE); |
Mtests/api/basic_api/ascendc_case_ascend910b1/ascendc_case_ascend910b1_aiv/test_operator_cast.cpp+2-2
| @@ -823,7 +823,7 @@ void MainVecBinaryCastDemo(__gm__ uint8_t* __restrict__ dstGm, __gm__ uint8_t* _ | |||
| 823 | uint8_t input0Gm[srcDataSize * sizeof(srcType)] = {0}; \ | 823 | uint8_t input0Gm[srcDataSize * sizeof(srcType)] = {0}; \ |
| 824 | uint8_t input1Gm[srcDataSize * sizeof(srcType)] = {0}; \ | 824 | uint8_t input1Gm[srcDataSize * sizeof(srcType)] = {0}; \ |
| 825 | uint8_t outputGm[dstDataSize * sizeof(dstType)] = {0}; \ | 825 | uint8_t outputGm[dstDataSize * sizeof(dstType)] = {0}; \ |
| 826 | - MOCKER(raise, int32_t (*)(int32_t)).times(1).will(invoke(RaiseStub)); \ | 826 | + MOCKER(raise, int32_t (*)(int32_t)).times(errorTimes).will(invoke(RaiseStub)); \ |
| 827 | MainVecBinaryCastDemo<dstType, srcType>(outputGm, input0Gm, input1Gm, dstDataSize, \ | 827 | MainVecBinaryCastDemo<dstType, srcType>(outputGm, input0Gm, input1Gm, dstDataSize, \ |
| 828 | srcDataSize, funcName, testMode); \ | 828 | srcDataSize, funcName, testMode); \ |
| 829 | \ | 829 | \ |
| @@ -936,4 +936,4 @@ VEC_CAST_FAILED_TESTCASE(bfloat16_t, int32_t, CAST_ODD, LEVEL2); | |||
| 936 | VEC_CAST_FAILED_TESTCASE(float, int16_t, CAST_NONE, LEVEL2); | 936 | VEC_CAST_FAILED_TESTCASE(float, int16_t, CAST_NONE, LEVEL2); |
| 937 | VEC_CAST_FAILED_TESTCASE(float, int16_t, CAST_ODD, LEVEL2); | 937 | VEC_CAST_FAILED_TESTCASE(float, int16_t, CAST_ODD, LEVEL2); |
| 938 | VEC_CAST_FAILED_TESTCASE(int64_t, float, CAST_NONE, LEVEL2); | 938 | VEC_CAST_FAILED_TESTCASE(int64_t, float, CAST_NONE, LEVEL2); |
| 939 | -VEC_CAST_FAILED_TESTCASE(int64_t, float, CAST_ODD, LEVEL2); | 939 | +VEC_CAST_FAILED_TESTCASE(int64_t, float, CAST_ODD, LEVEL2); |
| @@ -81,7 +81,7 @@ void MainVecUnary01(__gm__ uint8_t* __restrict__ srcGm, __gm__ uint8_t* __restri | |||
| 81 | CastDeq<uint8_t, int16_t, false, true>(outputLocal3, inputLocal2, dataSize); | 81 | CastDeq<uint8_t, int16_t, false, true>(outputLocal3, inputLocal2, dataSize); |
| 82 | CastDeq<int8_t, int16_t, true, false>(outputLocal2, inputLocal2, dataSize); | 82 | CastDeq<int8_t, int16_t, true, false>(outputLocal2, inputLocal2, dataSize); |
| 83 | CastDeq<uint8_t, int16_t, true, true>(outputLocal3, inputLocal2, dataSize); | 83 | CastDeq<uint8_t, int16_t, true, true>(outputLocal3, inputLocal2, dataSize); |
| 84 | - CastDeq<uint8_t, int16_t, true, true>(outputLocal3, inputLocal2, 1024); | 84 | + CastDeq<uint8_t, int16_t, true, true>(outputLocal3, inputLocal2, dataSize); |
| 85 | int maskCount = 32; | 85 | int maskCount = 32; |
| 86 | UnaryRepeatParams repeatParams; | 86 | UnaryRepeatParams repeatParams; |
| 87 | CastDeq<int8_t, int16_t, true, false, false>(outputLocal2, inputLocal2, maskCount, 2, repeatParams); | 87 | CastDeq<int8_t, int16_t, true, false, false>(outputLocal2, inputLocal2, maskCount, 2, repeatParams); |
| @@ -98,7 +98,7 @@ void MainVecUnary01(__gm__ uint8_t* __restrict__ srcGm, __gm__ uint8_t* __restri | |||
| 98 | CastDequant<uint8_t, int16_t, false, true>(outputLocal3, inputLocal2, dataSize); | 98 | CastDequant<uint8_t, int16_t, false, true>(outputLocal3, inputLocal2, dataSize); |
| 99 | CastDequant<int8_t, int16_t, true, false>(outputLocal2, inputLocal2, dataSize); | 99 | CastDequant<int8_t, int16_t, true, false>(outputLocal2, inputLocal2, dataSize); |
| 100 | CastDequant<uint8_t, int16_t, true, true>(outputLocal3, inputLocal2, dataSize); | 100 | CastDequant<uint8_t, int16_t, true, true>(outputLocal3, inputLocal2, dataSize); |
| 101 | - CastDequant<uint8_t, int16_t, true, true>(outputLocal3, inputLocal2, 1024); | 101 | + CastDequant<uint8_t, int16_t, true, true>(outputLocal3, inputLocal2, dataSize); |
| 102 | int maskCount = 32; | 102 | int maskCount = 32; |
| 103 | UnaryRepeatParams repeatParams; | 103 | UnaryRepeatParams repeatParams; |
| 104 | CastDequant<int8_t, int16_t, true, false, false>(outputLocal2, inputLocal2, maskCount, 2, repeatParams); | 104 | CastDequant<int8_t, int16_t, true, false, false>(outputLocal2, inputLocal2, maskCount, 2, repeatParams); |