Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print_corners #1187

Merged
merged 2 commits into from
Apr 27, 2023
Merged

print_corners #1187

merged 2 commits into from
Apr 27, 2023

Conversation

vtavana
Copy link
Collaborator

@vtavana vtavana commented Apr 24, 2023

In this PR, the recursive method used in dpctl.tensor._print._nd_corners function is replaced with an iterative method to improve performance.
x_dpt = dpt.reshape(dpt.arange(6*6*117*117, dtype='i4'),(6,117,117,6))
%timeit -r 20 dpt.usm_ndarray_repr(x_dpt)

New timing: 4.55 ms ± 645 µs per loop (mean ± std. dev. of 20 runs, 100 loops each)
Old timing: 6.43 ms ± 2.31 ms per loop (mean ± std. dev. of 20 runs, 100 loops each)

  • 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?

@vtavana vtavana self-assigned this Apr 24, 2023
@github-actions
Copy link

@oleksandr-pavlyk
Copy link
Collaborator

For array of rank r there are $2^r$ corners instead of $r^2$.

But in our case the r need not be the whole rank, we should only consider dimensions which size exceeds the threshold.

Also, instead of decoding integer to sequence of bits using a string, perhaps consider using itertools.outer.

@coveralls
Copy link
Collaborator

coveralls commented Apr 25, 2023

Coverage Status

Coverage: 83.336% (+0.02%) from 83.317% when pulling e153d77 on print_corners into e01e270 on master.

dpctl/tensor/_print.py Outdated Show resolved Hide resolved
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.3dev1=py310h76be34b_14 ran successfully.
Passed: 120
Failed: 887
Skipped: 109

@vtavana vtavana added the enhancement New feature or request label Apr 26, 2023
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.3dev1=py310h76be34b_14 ran successfully.
Passed: 120
Failed: 887
Skipped: 109

@vtavana vtavana force-pushed the print_corners branch 3 times, most recently from eaa63ee to e24fe4e Compare April 26, 2023 01:19
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.3dev1=py310h76be34b_14 ran successfully.
Passed: 120
Failed: 887
Skipped: 109

2 similar comments
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.3dev1=py310h76be34b_14 ran successfully.
Passed: 120
Failed: 887
Skipped: 109

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.3dev1=py310h76be34b_14 ran successfully.
Passed: 120
Failed: 887
Skipped: 109

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.3dev1=py310h76be34b_14 ran successfully.
Passed: 120
Failed: 887
Skipped: 109

Copy link
Collaborator

@oleksandr-pavlyk oleksandr-pavlyk left a comment

Choose a reason for hiding this comment

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

Before:


In [1]: import dpctl.tensor as dpt, dpctl

In [2]: m = dpt.ones((17, 15, 4, 31, 9, 4, 13), dtype="i2")

In [3]: from dpctl.tensor._print import _nd_corners

In [4]: %timeit -n 500 -r 12 dpt.asnumpy(_nd_corners(m, 3)).shape
14.2 ms ± 1.29 ms per loop (mean ± std. dev. of 12 runs, 500 loops each)

With changes from this PR:

In [1]: import dpctl.tensor as dpt, dpctl

In [2]: m = dpt.ones((17, 15, 4, 31, 9, 4, 13), dtype="i2")

In [3]: from dpctl.tensor._print import _nd_corners

In [4]: %timeit -n 500 -r 12 _nd_corners(m, 3).shape
4.72 ms ± 357 µs per loop (mean ± std. dev. of 12 runs, 500 loops each)

@vtavana vtavana merged commit 5707661 into master Apr 27, 2023
@vtavana vtavana deleted the print_corners branch April 27, 2023 14:09
@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.3dev1=py310h76be34b_14 ran successfully.
Passed: 120
Failed: 887
Skipped: 109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants