Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/backend/oneapi/kernel/index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ class indexKernel {
trimIndex(s3 ? gw * p.steps[3] + p.offs[3] : ptr3[gw],
inp.dims[3]);
// offset input and output pointers
const T* src = (const T*)in.get_pointer() + (i + j + k + l);
const T* src =
(const T*)in.get_pointer() + inp.offset + (i + j + k + l);
T* dst = (T*)out.get_pointer() +
(gx * outp.strides[0] + gy * outp.strides[1] +
gz * outp.strides[2] + gw * outp.strides[3]);
Expand Down
13 changes: 13 additions & 0 deletions test/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1622,6 +1622,19 @@ TEST(Indexing, SNIPPET_indexing_ref) {
// TODO: Confirm the outputs are correct. see #697
}

TEST(Indexing, IndexArrayOnSubarrayUsesSubarrayOffset) {
array data = iota(dim4(100)).as(s32);
array slice = data(seq(10, 29));

const uint h_indices[] = {0, 1, 2, 3};
array indices(4, h_indices);
array result = slice(indices);

int actual[4] = {};
result.host(actual);
for (int i = 0; i < 4; ++i) { ASSERT_EQ(10 + i, actual[i]); }
}

TEST(Indexing, IndexingCopy) {
array A = constant(0, 1, s32);
af::index s1;
Expand Down