Skip to content

Commit

Permalink
Fixing assign for empty indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanky authored and umar456 committed Aug 2, 2017
1 parent a6cbbb8 commit db2eed9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/api/c/assign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ void assign(Array<Tout> &out, const unsigned &ndims, const af_seq *index, const
dim4 const outDs = out.dims();
dim4 const iDims = in_.dims();

// Nothing to do for empty arrays
if (iDims.elements() == 0) return;

DIM_ASSERT(0, (outDs.ndims()>=iDims.ndims()));
DIM_ASSERT(0, (outDs.ndims()>=(dim_t)ndims));

Expand Down
15 changes: 15 additions & 0 deletions test/assign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1002,3 +1002,18 @@ TEST(Assign, ISSUE_1764)
}
}
}

TEST(Assign, ISSUE_1677)
{
try {
dim_t sz = 1;
af::array a = af::constant(1.0f, 3, sz, f32);
af::array b = af::constant(2.0f, 3, sz, f32);
af::array cond = af::constant(0, sz, b8); // all false
a(af::span, cond) = b(af::span, cond);
} catch(af::exception &ex) {
FAIL() << "ArrayFire exception: " << ex.what();
} catch(...) {
FAIL() << "Unknown exception thrown";
}
}

0 comments on commit db2eed9

Please sign in to comment.