已合并
for kirin:修复float场景的cube类api编译报错 #136
zengjuan创建于 1月15日
for kirin:修复float场景的cube类api编译报错 #136
已合并
zengjuan创建于 1月15日
已删除 :master合入到cann/asc-devkitmaster
11 个文件变更+179-16
@@ -25,6 +25,8 @@ asc-devkit:
25 - tests25 - tests
26 - include/**/*.h26 - include/**/*.h
27 - tools/**/*.h27 - tools/**/*.h
28+ - impl/**/dav_l300/*.h
29+ - impl/**/dav_l311/*.h
28 llt:30 llt:
29 ut_check: true31 ut_check: true
30 st_check: false32 st_check: false
@@ -79,7 +79,7 @@ public:
79#if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 3003 || __NPU_ARCH__ == 3113)79#if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 3003 || __NPU_ARCH__ == 3113)
80 if constexpr (std::is_same_v<BiasT, half>) {80 if constexpr (std::is_same_v<BiasT, half>) {
81 DataCopy(biasC2, bias, {1, lenBurst, 0, 0});81 DataCopy(biasC2, bias, {1, lenBurst, 0, 0});
82- } else {82+ } else if constexpr (!std::is_same_v<BiasT, float>) {
83 if ((dataLen * sizeof(BiasT) % ONE_BLOCK_SIZE) != 0) {83 if ((dataLen * sizeof(BiasT) % ONE_BLOCK_SIZE) != 0) {
84 dataLen = CeilAlign(dataLen, ONE_BLOCK_SIZE / sizeof(BiasT));84 dataLen = CeilAlign(dataLen, ONE_BLOCK_SIZE / sizeof(BiasT));
85 }85 }
@@ -297,13 +297,18 @@ __aicore__ inline void FixpipeL0cToOut(__gm__ DstT* dst, __cc__ SrcT* src,
297 uint64_t gmLen = GetGMLen<config>(intriParams, calNSize, dstEleSize);297 uint64_t gmLen = GetGMLen<config>(intriParams, calNSize, dstEleSize);
298 AscendCUtils::CheckGmMemOverflow((__gm__ DstT*)(dst + dstOffset), isSrc, gmLen);298 AscendCUtils::CheckGmMemOverflow((__gm__ DstT*)(dst + dstOffset), isSrc, gmLen);
299 }299 }
300+ 
300 // LOC -> GM only n direction need fixpipeTiling, m no need fixpipeTiling301 // LOC -> GM only n direction need fixpipeTiling, m no need fixpipeTiling
301- return copy_matrix_cc_to_gm((__gm__ DstT *)(dst + dstOffset), (__cc__ SrcT *)(src + srcOffset),302+ if constexpr (!(IsSameType<SrcT, float>::value || IsSameType<DstT, float>::value)) {
302- 0, calNSize, intriParams.mSize, intriParams.dstStride, intriParams.srcStride,303+ return copy_matrix_cc_to_gm((__gm__ DstT *)(dst + dstOffset), (__cc__ SrcT *)(src + srcOffset),
303- 0, intriParams.unitFlag, static_cast<uint64_t>(intriParams.quantPre),304+ 0, calNSize, intriParams.mSize, intriParams.dstStride, intriParams.srcStride,
304- static_cast<uint64_t>(QuantMode_post::NoConv), 0, false, false, 0, false, false, false,305+ 0, intriParams.unitFlag, static_cast<uint64_t>(intriParams.quantPre),
305- static_cast<uint8_t>(intriParams.reluEn), intriParams.isChannelSplit, nz2ndEn,306+ static_cast<uint8_t>(intriParams.reluEn), intriParams.isChannelSplit, nz2ndEn,
306- false);307+ static_cast<uint64_t>(QuantMode_post::NoConv), 0, false, false, 0, false, false, false,
308+ false);
309+ }
310+ ASCENDC_DEBUG_ASSERT(!(IsSameType<SrcT, float>::value || IsSameType<DstT, float>::value), KERNEL_LOG_INTERNAL(KERNEL_ERROR,
311+ "unsupported float L0c 2 GM "));
307}312}
308 313 
309template <typename DstT, typename SrcT, const FixpipeConfig& config>314template <typename DstT, typename SrcT, const FixpipeConfig& config>
@@ -234,6 +234,13 @@ __aicore__ inline void LoadData3DV2L12L0BCal(__cb__ half* dst, __cbuf__ half* sr
234/* **************************************************************************************************234/* **************************************************************************************************
235 * LoadData 3dv2Pro *235 * LoadData 3dv2Pro *
236 * ************************************************************************************************* */236 * ************************************************************************************************* */
237+__aicore__ inline void LoadData3DV2L12L0ACal(__ca__ float* dst, __cbuf__ float* src,
238+ const LoadData3DParamsV2Pro& loadDataParams)
239+{
240+ ASCENDC_ASSERT((false),
241+ { KERNEL_LOG(KERNEL_ERROR, "unsupported float load data from A1/B1 to A2/B2"); });
242+}
243+ 
237template <typename T>244template <typename T>
238__aicore__ inline void LoadData3DV2L12L0ACal(__ca__ T* dst, __cbuf__ T* src,245__aicore__ inline void LoadData3DV2L12L0ACal(__ca__ T* dst, __cbuf__ T* src,
239 const LoadData3DParamsV2Pro& loadDataParams)246 const LoadData3DParamsV2Pro& loadDataParams)
@@ -247,6 +254,13 @@ __aicore__ inline void LoadData3DV2L12L0ACal(__ca__ T* dst, __cbuf__ T* src,
247 loadDataParams.channelSize, BM_DISABLE);254 loadDataParams.channelSize, BM_DISABLE);
248}255}
249 256 
257+__aicore__ inline void LoadData3DV2L12L0BCal(__cb__ float* dst, __cbuf__ float* src,
258+ const LoadData3DParamsV2Pro& loadDataParams)
259+{
260+ ASCENDC_ASSERT((false),
261+ { KERNEL_LOG(KERNEL_ERROR, "unsupported float load data from A1/B1 to A2/B2"); });
262+}
263+ 
250template <typename T>264template <typename T>
251__aicore__ inline void LoadData3DV2L12L0BCal(__cb__ T* dst, __cbuf__ T* src,265__aicore__ inline void LoadData3DV2L12L0BCal(__cb__ T* dst, __cbuf__ T* src,
252 const LoadData3DParamsV2Pro& loadDataParams)266 const LoadData3DParamsV2Pro& loadDataParams)
@@ -289,6 +303,13 @@ __aicore__ inline void LoadData3DV2L12L0BCal(__cb__ int8_t* dst, __cbuf__ int8_t
289/* **************************************************************************************************303/* **************************************************************************************************
290 * Mmad *304 * Mmad *
291 * ************************************************************************************************* */305 * ************************************************************************************************* */
306+__aicore__ inline void MmadCal(__cc__ float* c, __ca__ float* a, __cb__ float* b, const MmadParams& mmadParams)
307+{
308+ ASCENDC_ASSERT((false), {
309+ KERNEL_LOG(KERNEL_ERROR, "unsupported float mmad");
310+ });
311+}
312+ 
292template <typename DstT, typename Src0T, typename Src1T>313template <typename DstT, typename Src0T, typename Src1T>
293__aicore__ inline void MmadCal(__cc__ DstT* c, __ca__ Src0T* a, __cb__ Src1T* b, const MmadParams& mmadParams)314__aicore__ inline void MmadCal(__cc__ DstT* c, __ca__ Src0T* a, __cb__ Src1T* b, const MmadParams& mmadParams)
294{315{
@@ -303,6 +324,14 @@ __aicore__ inline void MmadCal(__cc__ DstT* c, __ca__ Src0T* a, __cb__ Src1T* b,
303 mad(c, a, b, config);324 mad(c, a, b, config);
304}325}
305 326 
327+__aicore__ inline void MmadCal(__cc__ float* c, __ca__ float* a, __cb__ float* b, uint64_t bias,
328+ const MmadParams& mmadParams, bool cmatrixSource)
329+{
330+ ASCENDC_ASSERT((false), {
331+ KERNEL_LOG(KERNEL_ERROR, "unsupported float mmad");
332+ });
333+}
334+ 
306template <typename DstT, typename Src0T, typename Src1T>335template <typename DstT, typename Src0T, typename Src1T>
307__aicore__ inline void MmadCal(__cc__ DstT* c, __ca__ Src0T* a, __cb__ Src1T* b, uint64_t bias,336__aicore__ inline void MmadCal(__cc__ DstT* c, __ca__ Src0T* a, __cb__ Src1T* b, uint64_t bias,
308 const MmadParams& mmadParams, bool cmatrixSource)337 const MmadParams& mmadParams, bool cmatrixSource)
@@ -305,13 +305,18 @@ __aicore__ inline void FixpipeL0cToOut(__gm__ DstT* dst, __cc__ SrcT* src,
305 uint64_t gmLen = GetGMLen<config>(intriParams, calNSize, dstEleSize);305 uint64_t gmLen = GetGMLen<config>(intriParams, calNSize, dstEleSize);
306 AscendCUtils::CheckGmMemOverflow((__gm__ DstT*)(dst + dstOffset), isSrc, gmLen);306 AscendCUtils::CheckGmMemOverflow((__gm__ DstT*)(dst + dstOffset), isSrc, gmLen);
307 }307 }
308+ 
308 // LOC -> GM only n direction need fixpipeTiling, m no need fixpipeTiling309 // LOC -> GM only n direction need fixpipeTiling, m no need fixpipeTiling
309- return copy_matrix_cc_to_gm((__gm__ DstT *)(dst + dstOffset), (__cc__ SrcT *)(src + srcOffset),310+ if constexpr (!(IsSameType<SrcT, float>::value || IsSameType<DstT, float>::value)) {
310- 0, calNSize, intriParams.mSize, intriParams.dstStride, intriParams.srcStride,311+ return copy_matrix_cc_to_gm((__gm__ DstT *)(dst + dstOffset), (__cc__ SrcT *)(src + srcOffset),
311- 0, intriParams.unitFlag, static_cast<uint64_t>(intriParams.quantPre),312+ 0, calNSize, intriParams.mSize, intriParams.dstStride, intriParams.srcStride,
312- static_cast<uint8_t>(intriParams.reluEn), intriParams.isChannelSplit, nz2ndEn,313+ 0, intriParams.unitFlag, static_cast<uint64_t>(intriParams.quantPre),
313- static_cast<uint64_t>(QuantMode_post::NoConv), 0, false, false, 0, false, false, false,314+ static_cast<uint8_t>(intriParams.reluEn), intriParams.isChannelSplit, nz2ndEn,
314- false, false, nz2dnEn);315+ static_cast<uint64_t>(QuantMode_post::NoConv), 0, false, false, 0, false, false, false,
316+ false);
317+ }
318+ ASCENDC_DEBUG_ASSERT(!(IsSameType<SrcT, float>::value || IsSameType<DstT, float>::value), KERNEL_LOG_INTERNAL(KERNEL_ERROR,
319+ "unsupported float L0c 2 GM "));
315}320}
316 321 
317template <typename DstT, typename SrcT, const FixpipeConfig& config>322template <typename DstT, typename SrcT, const FixpipeConfig& config>
@@ -270,6 +270,13 @@ __aicore__ inline void LoadData3DV2L12L0BCal(__cb__ int8_t* dst, __cbuf__ int8_t
270/* **************************************************************************************************270/* **************************************************************************************************
271 * Mmad *271 * Mmad *
272 * ************************************************************************************************* */272 * ************************************************************************************************* */
273+__aicore__ inline void MmadCal(__cc__ float* c, __ca__ float* a, __cb__ float* b, const MmadParams& mmadParams)
274+{
275+ ASCENDC_ASSERT((false), {
276+ KERNEL_LOG(KERNEL_ERROR, "unsupported float mmad");
277+ });
278+}
279+ 
273template <typename T, typename U, typename S>280template <typename T, typename U, typename S>
274__aicore__ inline void MmadCal(__cc__ T* c, __ca__ U* a, __cb__ S* b, const MmadParams& mmadParams)281__aicore__ inline void MmadCal(__cc__ T* c, __ca__ U* a, __cb__ S* b, const MmadParams& mmadParams)
275{282{
@@ -289,6 +296,14 @@ __aicore__ inline void MmadCal(__cc__ T* c, __ca__ U* a, __cb__ S* b, const Mmad
289 mad(c, a, b, config);296 mad(c, a, b, config);
290}297}
291 298 
299+__aicore__ inline void MmadCal(__cc__ float* c, __ca__ float* a, __cb__ float* b, uint64_t bias,
300+ const MmadParams& mmadParams, bool cmatrixSource)
301+{
302+ ASCENDC_ASSERT((false), {
303+ KERNEL_LOG(KERNEL_ERROR, "unsupported float mmad");
304+ });
305+}
306+ 
292template <typename T, typename U, typename S>307template <typename T, typename U, typename S>
293__aicore__ inline void MmadCal(__cc__ T* c, __ca__ U* a, __cb__ S* b, uint64_t bias,308__aicore__ inline void MmadCal(__cc__ T* c, __ca__ U* a, __cb__ S* b, uint64_t bias,
294 const MmadParams& mmadParams, bool cmatrixSource)309 const MmadParams& mmadParams, bool cmatrixSource)
@@ -721,6 +721,19 @@ __simd_callee__ inline void DataCopyImpl(MaskReg &mask, __ubuf__ T *&srcUbAddr,
721 plds(mask, (__ubuf__ uint32_t *&)srcUbAddr, offset, distValue, postValue);721 plds(mask, (__ubuf__ uint32_t *&)srcUbAddr, offset, distValue, postValue);
722}722}
723 723 
724+template <typename T = DefaultType, typename U>
725+__simd_callee__ inline void LoadImpl(U& dstReg, __ubuf__ T* srcAddr)
726+{
727+ using ActualT = typename U::ActualT;
728+ static_assert(std::is_same_v<T, DefaultType> || std::is_same_v<T, ActualT>, "T type is not correct!");
729+ static_assert(SupportBytes<ActualT, 1, 2, 4, 8>(),
730+ "Load only support type b8/b16/b32/b64 on current device");
731+ static_assert(CheckRegTrait<U, RegTraitNumOne>(), "RegTensor only suppoort RegTraitNumOne on current device!");
732+ UnalignRegForLoad ureg;
733+ DataCopyUnAlignPreImpl<T>(ureg, srcAddr);
734+ DataCopyUnAlignImpl<T, U>(dstReg, ureg, srcAddr);
735+}
736+ 
724// pst737// pst
725template <typename T, MaskDist dist = MaskDist::DIST_NORM>738template <typename T, MaskDist dist = MaskDist::DIST_NORM>
726__simd_callee__ inline void DataCopyImpl(__ubuf__ T *dstUbAddr, MaskReg &mask, AddrReg offset)739__simd_callee__ inline void DataCopyImpl(__ubuf__ T *dstUbAddr, MaskReg &mask, AddrReg offset)
@@ -759,6 +772,18 @@ __simd_callee__ inline void DataCopyUnAlignImpl(__ubuf__ T *&dstUbAddr, MaskReg
759{772{
760 ASCENDC_ASSERT(false, { KERNEL_LOG(KERNEL_ERROR, "StoreUnAlign is not supported on current device!"); });773 ASCENDC_ASSERT(false, { KERNEL_LOG(KERNEL_ERROR, "StoreUnAlign is not supported on current device!"); });
761}774}
775+ 
776+template <typename T = DefaultType, typename U>
777+__simd_callee__ inline void StoreImpl(__ubuf__ T* dstAddr, U& srcReg)
778+{
779+ ASCENDC_ASSERT(false, { KERNEL_LOG(KERNEL_ERROR, "StoreUnAlign is not supported on current device!"); });
780+}
781+ 
782+template <typename T = DefaultType, typename U>
783+__simd_callee__ inline void StoreImpl(__ubuf__ T* dstAddr, U& srcReg, uint32_t count)
784+{
785+ ASCENDC_ASSERT(false, { KERNEL_LOG(KERNEL_ERROR, "StoreUnAlign is not supported on current device!"); });
786+}
762} // namespace MicroAPI787} // namespace MicroAPI
763} // namespace AscendC788} // namespace AscendC
764#endif // ASCENDC_MODULE_MICRO_DATACOPY_IMPL_H789#endif // ASCENDC_MODULE_MICRO_DATACOPY_IMPL_H
@@ -725,6 +725,19 @@ __simd_callee__ inline void DataCopyImpl(MaskReg &mask, __ubuf__ T *&srcUbAddr,
725 plds(mask, (__ubuf__ uint32_t *&)srcUbAddr, offset, distValue, postValue);725 plds(mask, (__ubuf__ uint32_t *&)srcUbAddr, offset, distValue, postValue);
726}726}
727 727 
728+template <typename T = DefaultType, typename U>
729+__simd_callee__ inline void LoadImpl(U& dstReg, __ubuf__ T* srcAddr)
730+{
731+ using ActualT = typename U::ActualT;
732+ static_assert(std::is_same_v<T, DefaultType> || std::is_same_v<T, ActualT>, "T type is not correct!");
733+ static_assert(SupportBytes<ActualT, 1, 2, 4, 8>(),
734+ "Load only support type b8/b16/b32/b64 on current device");
735+ static_assert(CheckRegTrait<U, RegTraitNumOne>(), "RegTensor only suppoort RegTraitNumOne on current device!");
736+ UnalignRegForLoad ureg;
737+ DataCopyUnAlignPreImpl<T>(ureg, srcAddr);
738+ DataCopyUnAlignImpl<T, U>(dstReg, ureg, srcAddr);
739+}
740+ 
728// pst741// pst
729template <typename T, MaskDist dist = MaskDist::DIST_NORM>742template <typename T, MaskDist dist = MaskDist::DIST_NORM>
730__simd_callee__ inline void DataCopyImpl(__ubuf__ T *dstUbAddr, MaskReg &mask, AddrReg offset)743__simd_callee__ inline void DataCopyImpl(__ubuf__ T *dstUbAddr, MaskReg &mask, AddrReg offset)
@@ -763,6 +776,18 @@ __simd_callee__ inline void DataCopyUnAlignImpl(__ubuf__ T *&dstUbAddr, MaskReg
763{776{
764 ASCENDC_ASSERT(false, { KERNEL_LOG(KERNEL_ERROR, "StoreUnAlign is not supported on current device!"); });777 ASCENDC_ASSERT(false, { KERNEL_LOG(KERNEL_ERROR, "StoreUnAlign is not supported on current device!"); });
765}778}
779+ 
780+template <typename T = DefaultType, typename U>
781+__simd_callee__ inline void StoreImpl(__ubuf__ T* dstAddr, U& srcReg)
782+{
783+ ASCENDC_ASSERT(false, { KERNEL_LOG(KERNEL_ERROR, "StoreUnAlign is not supported on current device!"); });
784+}
785+ 
786+template <typename T = DefaultType, typename U>
787+__simd_callee__ inline void StoreImpl(__ubuf__ T* dstAddr, U& srcReg, uint32_t count)
788+{
789+ ASCENDC_ASSERT(false, { KERNEL_LOG(KERNEL_ERROR, "StoreUnAlign is not supported on current device!"); });
790+}
766} // namespace MicroAPI791} // namespace MicroAPI
767} // namespace AscendC792} // namespace AscendC
768#endif // ASCENDC_MODULE_MICRO_DATACOPY_IMPL_H793#endif // ASCENDC_MODULE_MICRO_DATACOPY_IMPL_H
@@ -171,7 +171,9 @@ SocVersion PlatformAscendC::GetSocVersion(void) const
171 {"Hi3796CV300ES", SocVersion::HI3796CV300ES},171 {"Hi3796CV300ES", SocVersion::HI3796CV300ES},
172 {"MC61AM21A", SocVersion::MC61AM21A},172 {"MC61AM21A", SocVersion::MC61AM21A},
173 {"MC62CM12A", SocVersion::MC62CM12A},173 {"MC62CM12A", SocVersion::MC62CM12A},
174- {"SD3403", SocVersion::SD3403}174+ {"SD3403", SocVersion::SD3403},
175+ {"KirinX90", SocVersion::KIRINX90},
176+ {"Kirin9030", SocVersion::KIRIN9030}
175 };177 };
176 auto it = convertMap.find(socVersionStr);178 auto it = convertMap.find(socVersionStr);
177 if (it != convertMap.end()) {179 if (it != convertMap.end()) {
@@ -258,7 +260,9 @@ SocVersion PlatformAscendCManager::SocVersionMap(const char *socVersionStr)
258 {"Ascend310B", SocVersion::ASCEND310B},260 {"Ascend310B", SocVersion::ASCEND310B},
259 {"Ascend910_95", SocVersion::ASCEND910_95},261 {"Ascend910_95", SocVersion::ASCEND910_95},
260 {"Ascend910_55", SocVersion::ASCEND910_55},262 {"Ascend910_55", SocVersion::ASCEND910_55},
261- {"MC62CM12A", SocVersion::MC62CM12A}263+ {"MC62CM12A", SocVersion::MC62CM12A},
264+ {"KirinX90", SocVersion::KIRINX90},
265+ {"Kirin9030", SocVersion::KIRIN9030}
262 };266 };
263 const auto &iter = convertMap.find(socVersionStr);267 const auto &iter = convertMap.find(socVersionStr);
264 if (iter != convertMap.end()) {268 if (iter != convertMap.end()) {
@@ -324,7 +328,9 @@ const static std::map<std::string, std::string> convertMapInAicpu = {
324 {"Ascend910_957d", "Ascend910_95"},328 {"Ascend910_957d", "Ascend910_95"},
325 {"Ascend910_957c", "Ascend910_95"},329 {"Ascend910_957c", "Ascend910_95"},
326 {"Ascend910_9589", "Ascend910_95"}, // ascend910_95_list330 {"Ascend910_9589", "Ascend910_95"}, // ascend910_95_list
327- {"MC62CM12AA", "MC62CM12A"}331+ {"MC62CM12AA", "MC62CM12A"},
332+ {"KirinX90", "KirinX90"},
333+ {"Kirin9030", "Kirin9030"}
328};334};
329bool SwitchIntoShortSocVersion(const char *socVersionStr, std::string &shortSocVersion)335bool SwitchIntoShortSocVersion(const char *socVersionStr, std::string &shortSocVersion)
330{336{
@@ -385,6 +385,32 @@ class CommonUtility:
385 return False385 return False
386 386 
387 387 
388+ @staticmethod
389+ def is_l300():
390+ """return if current soc version is l300
391+ 
392+ Returns:
393+ res: True means l300
394+ """
395+ short_soc_version = global_var_storage.get_variable("ascendc_short_soc_version")
396+ if short_soc_version in ["KirinX90"]:
397+ return True
398+ return False
399+ 
400+ 
401+ @staticmethod
402+ def is_l311():
403+ """return if current soc version is l311
404+ 
405+ Returns:
406+ res: True means l311
407+ """
408+ short_soc_version = global_var_storage.get_variable("ascendc_short_soc_version")
409+ if short_soc_version in ["Kirin9030"]:
410+ return True
411+ return False
412+ 
413+ 
388 @staticmethod414 @staticmethod
389 def is_support_super_kernel():415 def is_support_super_kernel():
390 """return if current soc version support super kernel416 """return if current soc version support super kernel
@@ -474,6 +474,31 @@ class CommonUtility:
474 return False474 return False
475 475 
476 476 
477+ @staticmethod
478+ def is_l300():
479+ """return if current soc version is l300
480+ 
481+ Returns:
482+ res: True means l300
483+ """
484+ short_soc_version = global_var_storage.get_variable("ascendc_short_soc_version")
485+ if short_soc_version in ["KirinX90"]:
486+ return True
487+ return False
488+ 
489+ @staticmethod
490+ def is_l311():
491+ """return if current soc version is l311
492+ 
493+ Returns:
494+ res: True means l311
495+ """
496+ short_soc_version = global_var_storage.get_variable("ascendc_short_soc_version")
497+ if short_soc_version in ["Kirin9030"]:
498+ return True
499+ return False
500+ 
501+ 
477 @staticmethod502 @staticmethod
478 def is_has_ffts_mode():503 def is_has_ffts_mode():
479 """return if current soc version is has ffts mode504 """return if current soc version is has ffts mode