Skip to content

Commit

Permalink
Merge pull request #1260 from pavanky/where_fix
Browse files Browse the repository at this point in the history
BUGFIX: Fixing error in where for OpenCL backend
  • Loading branch information
pavanky committed Feb 4, 2016
2 parents 90ab8cd + f674cda commit 98ff1c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/backend/opencl/kernel/where.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ namespace kernel
out.info.strides[k] = total;
}

get_out_idx<T>(out.data, otmp, rtmp, in, threads_x, groups_x, groups_y);
if (total > 0) {
get_out_idx<T>(out.data, otmp, rtmp, in, threads_x, groups_x, groups_y);
}

bufferFree(rtmp.data);
bufferFree(otmp.data);
Expand Down
7 changes: 7 additions & 0 deletions test/where.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,10 @@ TYPED_TEST(Where, CPP)
<< std::endl;
}
}

TEST(Where, ISSUE_1259)
{
af::array a = af::randu(10, 10, 10);
af::array indices = af::where(a > 2);
ASSERT_EQ(indices.elements(), 0);
}

0 comments on commit 98ff1c0

Please sign in to comment.