| 32 | } |
| 33 | |
| 34 | af_err af_resize(af_array* out, const af_array in, const dim_t odim0, |
| 35 | const dim_t odim1, const af_interp_type method) { |
| 36 | try { |
| 37 | const ArrayInfo& info = getInfo(in); |
| 38 | af_dtype type = info.getType(); |
| 39 | |
| 40 | ARG_ASSERT(4, method == AF_INTERP_NEAREST || |
| 41 | method == AF_INTERP_BILINEAR || |
| 42 | method == AF_INTERP_BILINEAR_COSINE || |
| 43 | method == AF_INTERP_BICUBIC || |
| 44 | method == AF_INTERP_BICUBIC_SPLINE || |
| 45 | method == AF_INTERP_LOWER); |
| 46 | |
| 47 | DIM_ASSERT(2, odim0 > 0); |
| 48 | DIM_ASSERT(3, odim1 > 0); |
| 49 | |
| 50 | bool is_resize_supported = |
| 51 | (method == AF_INTERP_LOWER || method == AF_INTERP_NEAREST || |
| 52 | method == AF_INTERP_BILINEAR); |
| 53 | |
| 54 | if (!is_resize_supported) { |
| 55 | // Fall back to scale for additional methods |
| 56 | return af_scale(out, in, 0, 0, odim0, odim1, method); |
| 57 | } |
| 58 | |
| 59 | af_array output; |
| 60 | |
| 61 | switch (type) { |
| 62 | case f32: output = resize<float>(in, odim0, odim1, method); break; |
| 63 | case f64: output = resize<double>(in, odim0, odim1, method); break; |
| 64 | case c32: output = resize<cfloat>(in, odim0, odim1, method); break; |
| 65 | case c64: output = resize<cdouble>(in, odim0, odim1, method); break; |
| 66 | case s32: output = resize<int>(in, odim0, odim1, method); break; |
| 67 | case u32: output = resize<uint>(in, odim0, odim1, method); break; |
| 68 | case s64: output = resize<intl>(in, odim0, odim1, method); break; |
| 69 | case u64: output = resize<uintl>(in, odim0, odim1, method); break; |
| 70 | case s16: output = resize<short>(in, odim0, odim1, method); break; |
| 71 | case u16: output = resize<ushort>(in, odim0, odim1, method); break; |
| 72 | case s8: output = resize<schar>(in, odim0, odim1, method); break; |
| 73 | case u8: output = resize<uchar>(in, odim0, odim1, method); break; |
| 74 | case b8: output = resize<char>(in, odim0, odim1, method); break; |
| 75 | default: TYPE_ERROR(1, type); |
| 76 | } |
| 77 | std::swap(*out, output); |
| 78 | } |
| 79 | CATCHALL; |
| 80 | |
| 81 | return AF_SUCCESS; |
| 82 | } |
no test coverage detected