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

Method usable

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

Source from the content-addressed store, hash-verified

322}
323
324bool ConvBiasImpl::AlgoIm2col::usable(
325 const NCBKernSizeParam& param,
326 AlgoSelectionStrategy /*algo_selection_strategy*/) const {
327 MIDOUT_BEGIN(megdnn_fallback_im2col, 0, 2) {
328 auto format = param.filter_meta.format;
329 auto matmul_desc = m_matmul_algo->matmul_description();
330#if MEGDNN_AARCH64 || MEGDNN_ARMV7
331 if (format != param::ConvBias::Format::NCHW &&
332 format != param::ConvBias::Format::NCHW44 &&
333 format != param::ConvBias::Format::NCHW44_DOT &&
334 format != param::ConvBias::Format::NCHW88) {
335 return false;
336 }
337 if (format == param::ConvBias::Format::NCHW88) {
338 //! current NCHW88 im2col only support DEFAULT mode matmul
339 bool is_packmode_not_default = (matmul_desc.packmode != Pack_Mode::DEFAULT);
340 //! NCHW88 hybrid mode and channel wise is not support
341 bool is_hybrid_mode_or_channel_wise =
342 (param.filter_meta.icpg < 8_z || param.filter_meta.ocpg == 1);
343 if (is_packmode_not_default || is_hybrid_mode_or_channel_wise) {
344 return false;
345 }
346 }
347 if (format == param::ConvBias::Format::NCHW44 ||
348 format == param::ConvBias::Format::NCHW44_DOT) {
349 //! current NCHW44 im2col only support DEFAULT mode matmul
350 bool is_packmode_not_default = (matmul_desc.packmode != Pack_Mode::DEFAULT);
351 //! NCHW44 hybrid mode and channel wise is not support
352 bool is_hybrid_mode_or_channel_wise =
353 (param.filter_meta.icpg < 4_z || param.filter_meta.ocpg == 1);
354 if (is_packmode_not_default || is_hybrid_mode_or_channel_wise) {
355 return false;
356 }
357 }
358#else
359 if (format != param::ConvBias::Format::NCHW &&
360 format != param::ConvBias::Format::NCHW44) {
361 return false;
362 }
363 if (format == param::ConvBias::Format::NCHW44) {
364 //! current NCHW44 im2col only support DEFAULT mode matmul
365 bool is_packmode_not_default = (matmul_desc.packmode != Pack_Mode::DEFAULT);
366 //! NCHW44 hybrid mode and channel wise is not support
367 bool is_hybrid_mode_or_channel_wise =
368 (param.filter_meta.icpg < 4_z || param.filter_meta.ocpg == 1);
369 if (is_packmode_not_default || is_hybrid_mode_or_channel_wise) {
370 return false;
371 }
372 }
373#endif
374 if (param.src_type.enumv() != param.filter_type.enumv() ||
375 (param.src_type.enumv() != DTypeEnum::Int8 &&
376 param.src_type.enumv() != DTypeEnum::QuantizedS8 &&
377 param.src_type.enumv() != DTypeEnum::Quantized8Asymm &&
378#if !MEGDNN_DISABLE_FLOAT16
379 param.src_type.enumv() != DTypeEnum::Float16 &&
380#endif
381 param.src_type.enumv() != DTypeEnum::Float32)) {

Callers

nothing calls this directly

Calls 4

choice_ohw_oc_blockFunction · 0.85
get_matmul_kern_paramFunction · 0.70
MIDOUT_BEGINFunction · 0.50
enumvMethod · 0.45

Tested by

no test coverage detected