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

fixes nanval substitution on new keys by syurkevi · Pull Request #3261 · arrayfire/arrayfire · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cpp  (1) .hpp  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 1 addition & 0 deletions src/backend/cpu/kernel/reduce.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ struct reduce_dim_by_key<op, Ti, Tk, To, 0> {

current_key = keyval;
out_val = transform(inValsPtr[vOffset + (i * istride)]);
if (change_nan) out_val = IS_NAN(out_val) ? nanval : out_val;
++keyidx;
}

Expand Down
25 changes: 25 additions & 0 deletions test/reduce.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2285,3 +2285,28 @@ TEST(Reduce, Test_Sum_Global_Array_nanval) {
ASSERT_NEAR(res, full_reduce.scalar<float>(), max_error);
freeHost(h_a);
}

TEST(Reduce, nanval_issue_3255) {
char *info_str;
af_array ikeys, ivals, okeys, ovals;
dim_t dims[1] = {8};

int ikeys_src[8] = {0, 0, 1, 1, 1, 2, 2, 0};
af_create_array(&ikeys, ikeys_src, 1, dims, u32);

int i;
for (i=0; i<8; i++) {
double ivals_src[8] = {1, 2, 3, 4, 5, 6, 7, 8};
ivals_src[i] = NAN;
af_create_array(&ivals, ivals_src, 1, dims, f64);

af_product_by_key_nan(&okeys, &ovals, ikeys, ivals, 0, 1.0);
af::array ovals_cpp(ovals);
ASSERT_FALSE(af::anyTrue<bool>(af::isNaN(ovals_cpp)));

af_sum_by_key_nan(&okeys, &ovals, ikeys, ivals, 0, 1.0);
ovals_cpp = af::array(ovals);

ASSERT_FALSE(af::anyTrue<bool>(af::isNaN(ovals_cpp)));
}
}

Back | FazBrowse Home | New Git URL