Skip to content

Conversation

@ndgrigorian
Copy link
Collaborator

This PR implements simplify_iteration_space_4 and indexers for offsets in 4 arrays to resolve #1170.
Additionally, implements contract_iter4 and simplifies calls to std::min in strided_iters.

The issue was caused by an oversight in the mapping of elements between arrays in the strided where kernel. As the destination array was not being simplified, there was not a guarantee that the nth element of the destination corresponded to the correct element in x1 or x2.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • If this PR is a work in progress, are you opening the PR as a draft?

- Implemented FourOffsets_StridedIndexer and FourOffsets
- Implemented simplify_iteration_space_4 and simplify_iteration_four_strides
- Made std::min calls in strided_iters more readable
- Added test case for #1170
- Matches other contract_iter functions
@github-actions
Copy link

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.3dev0=py310h76be34b_108 ran successfully.
Passed: 47
Failed: 787
Skipped: 282

@coveralls
Copy link
Collaborator

coveralls commented Apr 13, 2023

Coverage Status

Coverage: 83.224%. Remained the same when pulling 0fe5ac7 on where-fix-gh-1170 into 02d1f94 on master.

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.3dev0=py310h76be34b_108 ran successfully.
Passed: 47
Failed: 787
Skipped: 282

@oleksandr-pavlyk
Copy link
Contributor

I have added a test:

def test_where_invariants():
    test_sh = (6, 8,)
    mask = dpt.asarray(np.random.choice([True, False], size=test_sh))
    p = dpt.ones(test_sh, dtype=dpt.int16)
    m = dpt.full(test_sh, -1, dtype=dpt.int16)
    inds_list = [(np.s_[:3], np.s_[::2],), (np.s_[::2], np.s_[::2],), (np.s_[::-1], np.s_[:],),]
    for ind in inds_list:
        r1 = dpt.where(mask, p, m)[ind]
        r2 = dpt.where(mask[ind], p[ind], m[ind])
        assert (dpt.asnumpy(r1) == dpt.asnumpy(r2)).all()

py::ssize_t &,
py::ssize_t &);

void simplify_iteration_space_4(int &,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One day, it would be nice to figure out how to make this nicer, perhaps by packing data about src1, etc. into structs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And of course, this same comment applies to simplify_iteration_space_3 and others.

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.3dev0=py310h76be34b_109 ran successfully.
Passed: 47
Failed: 787
Skipped: 282

@oleksandr-pavlyk oleksandr-pavlyk merged commit 456f46f into master Apr 14, 2023
@oleksandr-pavlyk oleksandr-pavlyk deleted the where-fix-gh-1170 branch April 14, 2023 13:52
@github-actions
Copy link

Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.3dev0=py310h76be34b_109 ran successfully.
Passed: 47
Failed: 787
Skipped: 282

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dpct.tensor.where wrong results with different shapes

3 participants