| 13 | namespace arm_common { |
| 14 | |
| 15 | void ResizeImpl::exec( |
| 16 | _megdnn_tensor_in src, _megdnn_tensor_in dst, _megdnn_workspace workspace) { |
| 17 | check_exec(src.layout, dst.layout, workspace.size); |
| 18 | |
| 19 | bool is_contiguous = src.layout.is_contiguous() && dst.layout.is_contiguous(); |
| 20 | bool is_dtype_same = src.layout.dtype == dst.layout.dtype; |
| 21 | bool is_dtype_fp16 = |
| 22 | DNN_FLOAT16_SELECT(src.layout.dtype == dtype::Float16(), false); |
| 23 | bool is_dtype_supported = is_dtype_same && is_dtype_fp16; |
| 24 | |
| 25 | #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 26 | bool is_nchw = param().format == param::Resize::Format::NCHW && is_dtype_fp16; |
| 27 | bool is_nchw88_fp16 = |
| 28 | param().format == param::Resize::Format::NCHW88 && is_dtype_fp16; |
| 29 | bool is_upsample2 = src.layout.shape[2] * 2 == dst.layout.shape[2] && |
| 30 | src.layout.shape[3] * 2 == dst.layout.shape[3]; |
| 31 | #endif |
| 32 | |
| 33 | bool is_imode_nearest = |
| 34 | param().imode == param::Resize::InterpolationMode::INTER_NEAREST; |
| 35 | bool is_imode_linear = |
| 36 | param().imode == param::Resize::InterpolationMode::INTER_LINEAR; |
| 37 | bool is_imode_supported = is_imode_nearest || is_imode_linear; |
| 38 | |
| 39 | bool usable = is_contiguous && is_dtype_supported && is_imode_supported; |
| 40 | |
| 41 | if (param().format == param::Resize::Format::NHWC && |
| 42 | (src.layout[3] == 1 || src.layout[3] == 3) && is_nhwc_contig_wc(src.layout)) { |
| 43 | MEGDNN_DISPATCH_CPU_KERN_OPR(resize_cv_exec(src, dst, param().imode)); |
| 44 | } else if (!usable) { |
| 45 | fallback::ResizeImpl::exec(src, dst, workspace); |
| 46 | #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC |
| 47 | } else if (is_dtype_fp16) { |
| 48 | auto kern_param = KernParam<dt_float16>::from_tensors( |
| 49 | param().format, param().imode, src, dst, workspace); |
| 50 | if (is_nchw88_fp16) { |
| 51 | if (is_upsample2) { |
| 52 | if (is_imode_nearest) { |
| 53 | MIDOUT_BEGIN(megdnn_arm_resize, midout_iv(6)) { |
| 54 | MEGDNN_DISPATCH_CPU_KERN_OPR( |
| 55 | resize_nearest_upsample2_nchw88_fp16(kern_param)); |
| 56 | } |
| 57 | MIDOUT_END(); |
| 58 | } else { |
| 59 | megdnn_assert(is_imode_linear, "invalid imode"); |
| 60 | MIDOUT_BEGIN(megdnn_arm_resize, midout_iv(7)) { |
| 61 | MEGDNN_DISPATCH_CPU_KERN_OPR( |
| 62 | resize_linear_upsample2_nchw88_fp16(kern_param)); |
| 63 | } |
| 64 | MIDOUT_END(); |
| 65 | } |
| 66 | } else { |
| 67 | if (is_imode_nearest) { |
| 68 | MIDOUT_BEGIN(megdnn_arm_resize, midout_iv(8)) { |
| 69 | MEGDNN_DISPATCH_CPU_KERN_OPR( |
| 70 | resize_direct_nearest_nchw88_fp16(kern_param)); |
| 71 | } |
| 72 | MIDOUT_END(); |
nothing calls this directly
no test coverage detected