MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / af_accum

Function af_accum

src/api/c/scan.cpp:118–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118af_err af_accum(af_array* out, const af_array in, const int dim) {
119 try {
120 ARG_ASSERT(2, dim >= 0);
121 ARG_ASSERT(2, dim < 4);
122
123 const ArrayInfo& in_info = getInfo(in);
124
125 if (dim >= static_cast<int>(in_info.ndims())) {
126 *out = retain(in);
127 return AF_SUCCESS;
128 }
129
130 af_dtype type = in_info.getType();
131 af_array res;
132
133 switch (type) {
134 case f32: res = scan<af_add_t, float, float>(in, dim); break;
135 case f64: res = scan<af_add_t, double, double>(in, dim); break;
136 case c32: res = scan<af_add_t, cfloat, cfloat>(in, dim); break;
137 case c64: res = scan<af_add_t, cdouble, cdouble>(in, dim); break;
138 case u32: res = scan<af_add_t, uint, uint>(in, dim); break;
139 case s32: res = scan<af_add_t, int, int>(in, dim); break;
140 case u64: res = scan<af_add_t, uintl, uintl>(in, dim); break;
141 case s64: res = scan<af_add_t, intl, intl>(in, dim); break;
142 case u16: res = scan<af_add_t, ushort, uint>(in, dim); break;
143 case s16: res = scan<af_add_t, short, int>(in, dim); break;
144 case u8: res = scan<af_add_t, uchar, uint>(in, dim); break;
145 case s8: res = scan<af_add_t, schar, int>(in, dim); break;
146 // Make sure you are adding only "1" for every non zero value, even
147 // if op == af_add_t
148 case b8: res = scan<af_notzero_t, char, uint>(in, dim); break;
149 default: TYPE_ERROR(1, type);
150 }
151
152 std::swap(*out, res);
153 }
154 CATCHALL;
155
156 return AF_SUCCESS;
157}
158
159af_err af_scan(af_array* out, const af_array in, const int dim, af_binary_op op,
160 bool inclusive_scan) {

Callers 1

accumFunction · 0.85

Calls 4

retainFunction · 0.85
swapFunction · 0.85
ndimsMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected