MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / dispatch_kerns

Method dispatch_kerns

dnn/src/fallback/conv_bias/im2col/algos.cpp:230–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228}
229
230SmallVector<ConvBiasImpl::NCBKern> ConvBiasImpl::AlgoIm2col::dispatch_kerns(
231 const NCBKernSizeParam& param) const {
232 MIDOUT_BEGIN(megdnn_fallback_im2col, 0, 1) {
233 size_t OH = param.osz[0];
234 size_t OW = param.osz[1];
235 size_t OC = param.filter_meta.ocpg;
236 size_t ohw = OH * OW;
237 size_t oc_tile_size = 0, ohw_tile_size = 0;
238
239 auto matmul_desc = m_matmul_algo->matmul_description();
240
241 bool default_pack = matmul_desc.packmode == Pack_Mode::DEFAULT;
242 bool no_pack = matmul_desc.packmode == Pack_Mode::NO_PACK;
243 bool only_packA = matmul_desc.packmode == Pack_Mode::ONLY_PACKA;
244 bool enable_filter_preprocess = is_enable_filter_preprocess(param);
245 choice_ohw_oc_block(
246 param, oc_tile_size, ohw_tile_size, matmul_desc.innerblocksize.m,
247 matmul_desc.innerblocksize.n, m_ohw_tile_size, matmul_desc.packmode);
248
249 size_t packa_parallel_times = 0;
250 size_t pack_oc_size = pack_size(param.filter_meta.format);
251 if (only_packA) {
252 packa_parallel_times = div_ceil<size_t>(OC, oc_tile_size);
253 } else if (default_pack) {
254 packa_parallel_times = div_ceil<size_t>(OC, matmul_desc.innerblocksize.m);
255 }
256
257 auto matmul_param = get_matmul_kern_param(
258 param, ohw_tile_size, default_pack ? OC : oc_tile_size);
259
260 WorkspaceBundle bundle =
261 get_bundle(param, m_matmul_algo, oc_tile_size, ohw_tile_size);
262 WorkspaceBundle bundle_thread = get_thread_bundle(
263 param, m_matmul_algo, matmul_param, matmul_desc, oc_tile_size,
264 ohw_tile_size);
265
266 StrategyParam strategyparam;
267 strategyparam.ohw = ohw;
268 strategyparam.is_dst_8bit =
269 (param.src_type.enumv() == DTypeEnum::QuantizedS8 &&
270 param.dst_type.enumv() == DTypeEnum::QuantizedS8) ||
271 (param.src_type.enumv() == DTypeEnum::Quantized8Asymm &&
272 param.dst_type.enumv() == DTypeEnum::Quantized8Asymm);
273 strategyparam.is_ohw_size_bigger = (ohw_tile_size >= ohw);
274 strategyparam.skip_copy_dst =
275 strategyparam.is_ohw_size_bigger && !strategyparam.is_dst_8bit;
276 strategyparam.oc_tile_size = oc_tile_size;
277 strategyparam.pack_oc_size = pack_oc_size;
278 strategyparam.enable_filter_preprocess = enable_filter_preprocess;
279 strategyparam.packA_group_size = packA_group_size(
280 m_matmul_algo, matmul_param, matmul_desc, packa_parallel_times);
281
282 SmallVector<ConvBiasImpl::NCBKern> ret_kern;
283 StrategyBase* im2colstrategy =
284 Factory::get_im2col_strategy(param, m_matmul_algo);
285 if (default_pack) {
286 MIDOUT_BEGIN(
287 megdnn_fallback_im2col,

Callers

nothing calls this directly

Calls 9

choice_ohw_oc_blockFunction · 0.85
packA_group_sizeFunction · 0.85
get_matmul_kern_paramFunction · 0.70
get_bundleFunction · 0.70
get_thread_bundleFunction · 0.70
MIDOUT_BEGINFunction · 0.50
enumvMethod · 0.45
get_kernsMethod · 0.45

Tested by

no test coverage detected