| 9 | namespace { |
| 10 | |
| 11 | void get_kernel_size( |
| 12 | uint32_t& kh, uint32_t& kw, megdnn::TensorND weight, ConvParam::Sparse sparse, |
| 13 | ConvParam::Format format) { |
| 14 | if (format == ConvParam::Format::NCHW) { |
| 15 | if (sparse == ConvParam::Sparse::DENSE) { |
| 16 | kh = weight.layout[2]; |
| 17 | kw = weight.layout[3]; |
| 18 | } else { |
| 19 | mgb_assert(sparse == ConvParam::Sparse::GROUP); |
| 20 | kh = weight.layout[3]; |
| 21 | kw = weight.layout[4]; |
| 22 | } |
| 23 | } else if ( |
| 24 | format == ConvParam::Format::NCHW44 || |
| 25 | format == ConvParam::Format::NCHW44_DOT) { |
| 26 | if (sparse == ConvParam::Sparse::DENSE) { |
| 27 | //! dense layout is oc/4, ic/4, fh, fw, 4, 4 |
| 28 | if (weight.layout.ndim == 6) { |
| 29 | kh = weight.layout[2]; |
| 30 | kw = weight.layout[3]; |
| 31 | } else { |
| 32 | //! hybrid first layout oc/4, fh, fw, ic, 4 |
| 33 | kh = weight.layout[1]; |
| 34 | kw = weight.layout[2]; |
| 35 | } |
| 36 | } |
| 37 | if (sparse == ConvParam::Sparse::GROUP) { |
| 38 | //! channel wise weight layout is g/4, 1, 1, fh, fw, 4 |
| 39 | if (weight.layout.ndim == 6) { |
| 40 | kh = weight.layout[3]; |
| 41 | kw = weight.layout[4]; |
| 42 | } else { |
| 43 | //! group conv with weight layout is g, ocpg/4, icpg/4, fh, fw, |
| 44 | //! 4, 4 |
| 45 | kh = weight.layout[3]; |
| 46 | kw = weight.layout[4]; |
| 47 | } |
| 48 | } |
| 49 | } else if (format == ConvParam::Format::NCHW88) { |
| 50 | if (sparse == ConvParam::Sparse::DENSE) { |
| 51 | //! dense layout is oc/8, ic/8, fh, fw, 8, 8 |
| 52 | if (weight.layout.ndim == 6) { |
| 53 | kh = weight.layout[2]; |
| 54 | kw = weight.layout[3]; |
| 55 | } else { |
| 56 | //! hybrid first layout oc/8, fh, fw, ic, 8 |
| 57 | kh = weight.layout[1]; |
| 58 | kw = weight.layout[2]; |
| 59 | } |
| 60 | } |
| 61 | if (sparse == ConvParam::Sparse::GROUP) { |
| 62 | //! channel wise weight layout is g/8, 1, 1, fh, fw, 8 |
| 63 | if (weight.layout.ndim == 6) { |
| 64 | kh = weight.layout[3]; |
| 65 | kw = weight.layout[4]; |
| 66 | } else { |
| 67 | //! group conv with weight layout is g, ocpg/8, icpg/8, fh, fw, |
| 68 | //! 8, 8 |
no outgoing calls
no test coverage detected