FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Ensure array is evaluated before reducing · arrayfire/arrayfire@3a081e9 · GitHub

Repository navigation

Commit 3a081e9

Browse files
Ensure array is evaluated before reducing
Added an eval() to the input array on the CPU back end for the ireduce method to ensure that the array has been evaluated before reducing.
1 parent e8561fb commit 3a081e9

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎src/backend/cpu/ireduce.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ void rreduce(Array<T> &out, Array<uint> &loc, const Array<T> &in, const int dim,
5858

5959
template<af_op_t op, typename T>
6060
T ireduce_all(unsigned *loc, const Array<T> &in) {
61+
in.eval();
6162
getQueue().sync();
6263

6364
af::dim4 dims = in.dims();

‎test/ireduce.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,3 +541,15 @@ TEST(IndexedReduce, min_subarray_1) {
541541
ASSERT_EQ(h_idx[i], gold_idx[i]);
542542
}
543543
}
544+
545+
//Ensure that array is evaluated before reducing
546+
TEST(IndexedReduce, reduce_jit_array) {
547+
af::array jit(af::dim4(2),{1.0f, 2.0f});
548+
jit += af::constant(1.0f, af::dim4(2));
549+
float val; unsigned idx;
550+
float gold_val = 2.0f;
551+
unsigned gold_idx = 0;
552+
af::min(&val, &idx, jit);
553+
ASSERT_EQ(val, gold_val);
554+
ASSERT_EQ(idx, gold_idx);
555+
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL