-
Notifications
You must be signed in to change notification settings - Fork 555
Expand file tree
/
Copy pathireduce.cpp
More file actions
83 lines (74 loc) · 2.53 KB
/
Copy pathireduce.cpp
File metadata and controls
83 lines (74 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*******************************************************
* Copyright (c) 2014, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#include <ireduce.hpp>
#include <kernel/ireduce.hpp>
#include <Array.hpp>
#include <common/half.hpp>
#include <err_opencl.hpp>
#include <optypes.hpp>
#include <af/dim4.hpp>
#include <complex>
using af::dim4;
using arrayfire::common::half;
namespace arrayfire {
namespace opencl {
template<af_op_t op, typename T>
void ireduce(Array<T> &out, Array<uint> &loc, const Array<T> &in,
const int dim) {
Array<uint> rlen = createEmptyArray<uint>(af::dim4(0));
kernel::ireduce<T, op>(out, loc.get(), in, dim, rlen);
}
template<af_op_t op, typename T>
void rreduce(Array<T> &out, Array<uint> &loc, const Array<T> &in, const int dim,
const Array<uint> &rlen) {
kernel::ireduce<T, op>(out, loc.get(), in, dim, rlen);
}
template<af_op_t op, typename T>
T ireduce_all(unsigned *loc, const Array<T> &in) {
return kernel::ireduceAll<T, op>(loc, in);
}
#define INSTANTIATE(ROp, T) \
template void ireduce<ROp, T>(Array<T> & out, Array<uint> & loc, \
const Array<T> &in, const int dim); \
template void rreduce<ROp, T>(Array<T> & out, Array<uint> & loc, \
const Array<T> &in, const int dim, \
const Array<uint> &rlen); \
template T ireduce_all<ROp, T>(unsigned *loc, const Array<T> &in);
// min
INSTANTIATE(af_min_t, float)
INSTANTIATE(af_min_t, double)
INSTANTIATE(af_min_t, cfloat)
INSTANTIATE(af_min_t, cdouble)
INSTANTIATE(af_min_t, int)
INSTANTIATE(af_min_t, uint)
INSTANTIATE(af_min_t, intl)
INSTANTIATE(af_min_t, uintl)
INSTANTIATE(af_min_t, char)
INSTANTIATE(af_min_t, schar)
INSTANTIATE(af_min_t, uchar)
INSTANTIATE(af_min_t, short)
INSTANTIATE(af_min_t, ushort)
INSTANTIATE(af_min_t, half)
// max
INSTANTIATE(af_max_t, float)
INSTANTIATE(af_max_t, double)
INSTANTIATE(af_max_t, cfloat)
INSTANTIATE(af_max_t, cdouble)
INSTANTIATE(af_max_t, int)
INSTANTIATE(af_max_t, uint)
INSTANTIATE(af_max_t, intl)
INSTANTIATE(af_max_t, uintl)
INSTANTIATE(af_max_t, char)
INSTANTIATE(af_max_t, schar)
INSTANTIATE(af_max_t, uchar)
INSTANTIATE(af_max_t, short)
INSTANTIATE(af_max_t, ushort)
INSTANTIATE(af_max_t, half)
} // namespace opencl
} // namespace arrayfire