| 47 | |
| 48 | template<af_op_t op, typename Ti, typename To> |
| 49 | Array<To> reduce(const Array<Ti> &in, const int dim, bool change_nan, |
| 50 | double nanval) { |
| 51 | dim4 odims = in.dims(); |
| 52 | odims[dim] = 1; |
| 53 | |
| 54 | Array<To> out = createEmptyArray<To>(odims); |
| 55 | static const reduce_dim_func<op, Ti, To> reduce_funcs[4] = { |
| 56 | kernel::reduce_dim<op, Ti, To, 1>(), |
| 57 | kernel::reduce_dim<op, Ti, To, 2>(), |
| 58 | kernel::reduce_dim<op, Ti, To, 3>(), |
| 59 | kernel::reduce_dim<op, Ti, To, 4>()}; |
| 60 | |
| 61 | getQueue().enqueue(reduce_funcs[in.ndims() - 1], out, 0, in, 0, dim, |
| 62 | change_nan, nanval); |
| 63 | |
| 64 | return out; |
| 65 | } |
| 66 | |
| 67 | template<af_op_t op, typename Ti, typename Tk, typename To> |
| 68 | using reduce_dim_func_by_key = |
no test coverage detected