已合并
C API新增l0c2l1矩阵搬出接口 #5091
UFOunder创建于 8月14日
C API新增l0c2l1矩阵搬出接口 #5091
已合并
共 4 个文件变更+121-0
| @@ -2591,6 +2591,33 @@ __aicore__ inline void asc_copy_l0c2l1_sync( | |||
| 2591 | eltwise_op, eltwise_antq_en, c0_pad_en, broadcast_en, enable_nz2dn); | 2591 | eltwise_op, eltwise_antq_en, c0_pad_en, broadcast_en, enable_nz2dn); |
| 2592 | } | 2592 | } |
| 2593 | 2593 | ||
| 2594 | +// half float | ||
W | |||
| 2595 | +__aicore__ inline void asc_copy_l0c2l1( | ||
| 2596 | + __cbuf__ half* dst, __cc__ float* src, uint16_t n_size, uint16_t m_size, uint32_t dst_stride, uint16_t src_stride, | ||
| 2597 | + uint8_t l2_cache_mode, uint8_t enable_clip_relu_pre, uint8_t unit_flag_mode, uint64_t quant_pre_mode, | ||
| 2598 | + uint8_t relu_pre_mode, bool enable_channel_split, bool enable_nz2nd, uint64_t quant_post, uint8_t relu_post, | ||
| 2599 | + bool clip_relu_post, uint8_t eltwise_op, bool eltwise_antq_en, bool c0_pad_en, bool broadcast_en, bool enable_nz2dn) | ||
| 2600 | +{ | ||
| 2601 | + asc_copy_l0c2l1_impl( | ||
| 2602 | + dst, src, n_size, m_size, dst_stride, src_stride, l2_cache_mode, enable_clip_relu_pre, unit_flag_mode, | ||
| 2603 | + quant_pre_mode, relu_pre_mode, enable_channel_split, enable_nz2nd, quant_post, relu_post, clip_relu_post, | ||
| 2604 | + eltwise_op, eltwise_antq_en, c0_pad_en, broadcast_en, enable_nz2dn); | ||
| 2605 | +} | ||
| 2606 | + | ||
| 2607 | +// bfloat16_t float | ||
| 2608 | +__aicore__ inline void asc_copy_l0c2l1( | ||
| 2609 | + __cbuf__ bfloat16_t* dst, __cc__ float* src, uint16_t n_size, uint16_t m_size, uint32_t dst_stride, | ||
| 2610 | + uint16_t src_stride, uint8_t l2_cache_mode, uint8_t enable_clip_relu_pre, uint8_t unit_flag_mode, | ||
| 2611 | + uint64_t quant_pre_mode, uint8_t relu_pre_mode, bool enable_channel_split, bool enable_nz2nd, uint64_t quant_post, | ||
| 2612 | + uint8_t relu_post, bool clip_relu_post, uint8_t eltwise_op, bool eltwise_antq_en, bool c0_pad_en, bool broadcast_en, | ||
| 2613 | + bool enable_nz2dn) | ||
| 2614 | +{ | ||
| 2615 | + asc_copy_l0c2l1_impl( | ||
| 2616 | + dst, src, n_size, m_size, dst_stride, src_stride, l2_cache_mode, enable_clip_relu_pre, unit_flag_mode, | ||
| 2617 | + quant_pre_mode, relu_pre_mode, enable_channel_split, enable_nz2nd, quant_post, relu_post, clip_relu_post, | ||
| 2618 | + eltwise_op, eltwise_antq_en, c0_pad_en, broadcast_en, enable_nz2dn); | ||
| 2619 | +} | ||
| 2620 | + | ||
| 2594 | // ==========asc_copy_l0c2gm=========== | 2621 | // ==========asc_copy_l0c2gm=========== |
| 2595 | // bfloat16_t float | 2622 | // bfloat16_t float |
| 2596 | __aicore__ inline void asc_copy_l0c2gm( | 2623 | __aicore__ inline void asc_copy_l0c2gm( |
| @@ -226,6 +226,39 @@ __aicore__ inline void asc_copy_l0c2l1_sync_impl( | |||
| 226 | asc_sync_post_process(); | 226 | asc_sync_post_process(); |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | +// half float | ||
| 230 | +__aicore__ inline void asc_copy_l0c2l1_impl( | ||
| 231 | + __cbuf__ half* dst, __cc__ float* src, uint16_t n_size, uint16_t m_size, uint32_t dst_stride, uint16_t src_stride, | ||
| 232 | + uint8_t l2_cache_mode, uint8_t enable_clip_relu_pre, uint8_t unit_flag_mode, uint64_t quant_pre_mode, | ||
| 233 | + uint8_t relu_pre_mode, bool enable_channel_split, bool enable_nz2nd, uint64_t quant_post, uint8_t relu_post, | ||
| 234 | + bool clip_relu_post, uint8_t eltwise_op, bool eltwise_antq_en, bool c0_pad_en, bool broadcast_en, bool enable_nz2dn) | ||
| 235 | +{ | ||
| 236 | + if ASC_IS_AIC { | ||
| 237 | + copy_matrix_cc_to_cbuf( | ||
| 238 | + dst, src, 0, n_size, m_size, dst_stride, src_stride, l2_cache_mode, enable_clip_relu_pre, unit_flag_mode, | ||
| 239 | + static_cast<QuantMode_t>(quant_pre_mode), relu_pre_mode, enable_channel_split, enable_nz2nd, | ||
| 240 | + static_cast<QuantMode_post>(quant_post), relu_post, clip_relu_post, false, eltwise_op, eltwise_antq_en, | ||
| 241 | + false, c0_pad_en, false, broadcast_en, enable_nz2dn); | ||
| 242 | + } | ||
| 243 | +} | ||
| 244 | + | ||
| 245 | +// bfloat16_t float | ||
| 246 | +__aicore__ inline void asc_copy_l0c2l1_impl( | ||
| 247 | + __cbuf__ bfloat16_t* dst, __cc__ float* src, uint16_t n_size, uint16_t m_size, uint32_t dst_stride, | ||
| 248 | + uint16_t src_stride, uint8_t l2_cache_mode, uint8_t enable_clip_relu_pre, uint8_t unit_flag_mode, | ||
| 249 | + uint64_t quant_pre_mode, uint8_t relu_pre_mode, bool enable_channel_split, bool enable_nz2nd, uint64_t quant_post, | ||
| 250 | + uint8_t relu_post, bool clip_relu_post, uint8_t eltwise_op, bool eltwise_antq_en, bool c0_pad_en, bool broadcast_en, | ||
| 251 | + bool enable_nz2dn) | ||
| 252 | +{ | ||
| 253 | + if ASC_IS_AIC { | ||
| 254 | + copy_matrix_cc_to_cbuf( | ||
| 255 | + dst, src, 0, n_size, m_size, dst_stride, src_stride, l2_cache_mode, enable_clip_relu_pre, unit_flag_mode, | ||
| 256 | + static_cast<QuantMode_t>(quant_pre_mode), relu_pre_mode, enable_channel_split, enable_nz2nd, | ||
| 257 | + static_cast<QuantMode_post>(quant_post), relu_post, clip_relu_post, false, eltwise_op, eltwise_antq_en, | ||
| 258 | + false, c0_pad_en, false, broadcast_en, enable_nz2dn); | ||
| 259 | + } | ||
| 260 | +} | ||
| 261 | + | ||
| 229 | 262 | ||
| 230 | 263 | ||
| 231 | 264 | ||
| @@ -1886,6 +1886,22 @@ __aicore__ inline void asc_copy_l0c2l1_sync( | |||
| 1886 | uint8_t relu_post, bool clip_relu_post, uint8_t eltwise_op, bool eltwise_antq_en, bool c0_pad_en, bool broadcast_en, | 1886 | uint8_t relu_post, bool clip_relu_post, uint8_t eltwise_op, bool eltwise_antq_en, bool c0_pad_en, bool broadcast_en, |
| 1887 | bool enable_nz2dn); | 1887 | bool enable_nz2dn); |
| 1888 | 1888 | ||
| 1889 | +// half float | ||
| 1890 | +__aicore__ inline void asc_copy_l0c2l1( | ||
| 1891 | + __cbuf__ half* dst, __cc__ float* src, uint16_t n_size, uint16_t m_size, uint32_t dst_stride, uint16_t src_stride, | ||
| 1892 | + uint8_t l2_cache_mode, uint8_t enable_clip_relu_pre, uint8_t unit_flag_mode, uint64_t quant_pre_mode, | ||
| 1893 | + uint8_t relu_pre_mode, bool enable_channel_split, bool enable_nz2nd, uint64_t quant_post, uint8_t relu_post, | ||
| 1894 | + bool clip_relu_post, uint8_t eltwise_op, bool eltwise_antq_en, bool c0_pad_en, bool broadcast_en, | ||
| 1895 | + bool enable_nz2dn); | ||
| 1896 | + | ||
| 1897 | +// bfloat16_t float | ||
| 1898 | +__aicore__ inline void asc_copy_l0c2l1( | ||
| 1899 | + __cbuf__ bfloat16_t* dst, __cc__ float* src, uint16_t n_size, uint16_t m_size, uint32_t dst_stride, | ||
| 1900 | + uint16_t src_stride, uint8_t l2_cache_mode, uint8_t enable_clip_relu_pre, uint8_t unit_flag_mode, | ||
| 1901 | + uint64_t quant_pre_mode, uint8_t relu_pre_mode, bool enable_channel_split, bool enable_nz2nd, uint64_t quant_post, | ||
| 1902 | + uint8_t relu_post, bool clip_relu_post, uint8_t eltwise_op, bool eltwise_antq_en, bool c0_pad_en, bool broadcast_en, | ||
| 1903 | + bool enable_nz2dn); | ||
| 1904 | + | ||
| 1889 | // ==========asc_copy_l0c2gm=========== | 1905 | // ==========asc_copy_l0c2gm=========== |
| 1890 | // bfloat16_t float | 1906 | // bfloat16_t float |
| 1891 | __aicore__ inline void asc_copy_l0c2gm( | 1907 | __aicore__ inline void asc_copy_l0c2gm( |
| @@ -142,6 +142,44 @@ | |||
| 142 | GlobalMockObject::verify(); \ | 142 | GlobalMockObject::verify(); \ |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | +class TestCubeDatamoveL0C2L1Full : public testing::Test { | ||
| 146 | +protected: | ||
| 147 | + void SetUp() { g_coreType = C_API_AIC_TYPE; } | ||
| 148 | + void TearDown() { g_coreType = C_API_AIV_TYPE; } | ||
| 149 | +}; | ||
| 150 | + | ||
| 151 | +template <typename DstType> | ||
| 152 | +void TestAscCopyL0C2L1FullParams() | ||
| 153 | +{ | ||
| 154 | + __cbuf__ DstType* dst = reinterpret_cast<__cbuf__ DstType*>(1); | ||
| 155 | + __cc__ float* src = reinterpret_cast<__cc__ float*>(2); | ||
| 156 | + uint16_t n_size = 3; | ||
| 157 | + uint16_t m_size = 4; | ||
| 158 | + uint32_t dst_stride = 6; | ||
| 159 | + uint16_t src_stride = 7; | ||
| 160 | + uint8_t l2_cache_mode = 0; | ||
| 161 | + uint8_t enable_clip_relu_pre = 8; | ||
| 162 | + uint8_t unit_flag_mode = 10; | ||
| 163 | + uint64_t quant_pre_mode = 11; | ||
| 164 | + uint8_t relu_pre_mode = 12; | ||
| 165 | + bool enable_channel_split = false; | ||
| 166 | + bool enable_nz2nd = false; | ||
| 167 | + uint64_t quant_post = 13; | ||
| 168 | + uint8_t relu_post = 14; | ||
| 169 | + bool clip_relu_post = true; | ||
| 170 | + uint8_t eltwise_op = 15; | ||
| 171 | + bool eltwise_antq_en = true; | ||
| 172 | + bool c0_pad_en = true; | ||
| 173 | + bool broadcast_en = false; | ||
| 174 | + bool enable_nz2dn = true; | ||
| 175 | + | ||
| 176 | + asc_copy_l0c2l1( | ||
| 177 | + dst, src, n_size, m_size, dst_stride, src_stride, l2_cache_mode, enable_clip_relu_pre, unit_flag_mode, | ||
| 178 | + quant_pre_mode, relu_pre_mode, enable_channel_split, enable_nz2nd, quant_post, relu_post, clip_relu_post, | ||
| 179 | + eltwise_op, eltwise_antq_en, c0_pad_en, broadcast_en, enable_nz2dn); | ||
| 180 | + GlobalMockObject::verify(); | ||
| 181 | +} | ||
| 182 | + | ||
| 145 | 183 | ||
| 146 | 184 | ||
| 147 | TEST_CUBE_COMPUTE_FIXPIPE_L0C2L1_INSTR(L0C2L1, asc_copy_l0c2l1, copy_matrix_cc_to_cbuf, half, float); | 185 | TEST_CUBE_COMPUTE_FIXPIPE_L0C2L1_INSTR(L0C2L1, asc_copy_l0c2l1, copy_matrix_cc_to_cbuf, half, float); |
| @@ -156,3 +194,10 @@ TEST_CUBE_COMPUTE_FIXPIPE_L0C2L1_INSTR(L0C2L1, asc_copy_l0c2l1, copy_matrix_cc_t | |||
| 156 | 194 | ||
| 157 | TEST_CUBE_COMPUTE_FIXPIPE_L0C2L1_S4_INSTR(L0C2L1, asc_copy_l0c2l1, copy_matrix_cc_to_cbuf_s4, int4b_t, float); | 195 | TEST_CUBE_COMPUTE_FIXPIPE_L0C2L1_S4_INSTR(L0C2L1, asc_copy_l0c2l1, copy_matrix_cc_to_cbuf_s4, int4b_t, float); |
| 158 | TEST_CUBE_COMPUTE_FIXPIPE_L0C2L1_S4_INSTR(L0C2L1, asc_copy_l0c2l1, copy_matrix_cc_to_cbuf_s4, int4b_t, int32_t); | 196 | TEST_CUBE_COMPUTE_FIXPIPE_L0C2L1_S4_INSTR(L0C2L1, asc_copy_l0c2l1, copy_matrix_cc_to_cbuf_s4, int4b_t, int32_t); |
| 197 | + | ||
| 198 | +TEST_F(TestCubeDatamoveL0C2L1Full, asc_copy_l0c2l1_half_float_full_params_Succ) { TestAscCopyL0C2L1FullParams<half>(); } | ||
| 199 | + | ||
| 200 | +TEST_F(TestCubeDatamoveL0C2L1Full, asc_copy_l0c2l1_bfloat16_t_float_full_params_Succ) | ||
| 201 | +{ | ||
| 202 | + TestAscCopyL0C2L1FullParams<bfloat16_t>(); | ||
| 203 | +} | ||


这个注释没有真实意义,建议删掉,添加有效注释