We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1f5e3f9 commit 72952edCopy full SHA for 72952ed
2 files changed
src/api/cpp/array.cpp
@@ -299,6 +299,14 @@ namespace af
299
array array::operator()(const array& idx) const
300
{
301
eval();
302
+
303
+ // Special case of indexing linearly
304
+ // Flatten the current array and index accordingly
305
+ if (this->numdims() > 1) {
306
+ array tmp = flat(*this);
307
+ return tmp(idx);
308
+ }
309
310
af_array out = 0;
311
AF_THROW(af_lookup(&out, this->get(), idx.get(), 0));
312
return array(out);
@@ -307,6 +315,14 @@ namespace af
315
array array::operator()(const seq &s0) const
316
317
318
319
320
321
322
323
+ return tmp(s0);
324
325
326
327
seq indices[] = {s0, span, span, span};
328
//FIXME: check if this->s has same dimensions as numdims
test/index.cpp
@@ -29,6 +29,7 @@ using std::endl;
29
using std::ostream_iterator;
30
using af::dtype_traits;
31
32
33
template<typename T, typename OP>
34
void
35
checkValues(const af_seq &seq, const T* data, const T* indexed_data, OP compair_op) {
@@ -627,7 +628,7 @@ TEST(lookup, CPP)
627
628
629
array input(dims0, &(in[0].front()));
630
array indices(dims1, &(in[1].front()));
- array output = input(indices);
631
+ array output = af::lookup(input, indices, 0);
632
633
vector<float> currGoldBar = tests[0];
634
size_t nElems = currGoldBar.size();
@@ -728,7 +729,7 @@ TEST(SeqIndex, CPPLarge)
728
729
730
731
732
733
734
735
0 commit comments