Skip to content

Expanded doc-string of dpctl.tensor.usm_ndarray.to_device #990

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

Merged
merged 1 commit into from
Nov 16, 2022

Conversation

oleksandr-pavlyk
Copy link
Contributor

Expanded doc-string for to_device method of usm_ndarray class.

  • Have you provided a meaningful PR description?

@github-actions
Copy link

@coveralls
Copy link
Collaborator

coveralls commented Nov 15, 2022

Coverage Status

Coverage increased (+0.01%) to 81.963% when pulling 335afd5 on expand-to_device-docstring into ea4e009 on master.

@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.0rc2=py310h8c27c75_5 ran successfully.
Passed: 33
Failed: 801
Skipped: 3138

@oleksandr-pavlyk
Copy link
Contributor Author

The failure of pre-commit workflow is being addressed in #991

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the expand-to_device-docstring branch from 90646b6 to 0010e48 Compare November 15, 2022 23:58
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.0rc2=py310h8c27c75_7 ran successfully.
Passed: 33
Failed: 801
Skipped: 3138

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the expand-to_device-docstring branch from 0010e48 to bc58a9a Compare November 16, 2022 01:31
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.0rc2=py310h8c27c75_7 ran successfully.
Passed: 33
Failed: 801
Skipped: 3138

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the expand-to_device-docstring branch from bc58a9a to 00b333f Compare November 16, 2022 02:27
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.0rc2=py310h8c27c75_7 ran successfully.
Passed: 33
Failed: 801
Skipped: 3138

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the expand-to_device-docstring branch from 00b333f to 427c4e6 Compare November 16, 2022 02:57
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.0rc2=py310h8c27c75_7 ran successfully.
Passed: 33
Failed: 801
Skipped: 3138

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the expand-to_device-docstring branch from 427c4e6 to bd6700c Compare November 16, 2022 03:30
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.0rc2=py310h8c27c75_7 ran successfully.
Passed: 33
Failed: 801
Skipped: 3138

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the expand-to_device-docstring branch from bd6700c to 87fe6b2 Compare November 16, 2022 13:10
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.0rc2=py310h8c27c75_7 ran successfully.
Passed: 33
Failed: 801
Skipped: 3138

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the expand-to_device-docstring branch from 87fe6b2 to 0a44b81 Compare November 16, 2022 13:49
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.0rc2=py310h8c27c75_7 ran successfully.
Passed: 33
Failed: 801
Skipped: 3138

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the expand-to_device-docstring branch 2 times, most recently from 769675b to 3b66dc9 Compare November 16, 2022 15:45
@oleksandr-pavlyk oleksandr-pavlyk force-pushed the expand-to_device-docstring branch from 3b66dc9 to 335afd5 Compare November 16, 2022 15:54
@github-actions
Copy link

Array API standard conformance tests for dpctl=0.14.0rc2=py310h8c27c75_7 ran successfully.
Passed: 33
Failed: 801
Skipped: 3138

Copy link
Collaborator

@antonwolfy antonwolfy left a comment

Choose a reason for hiding this comment

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

I've checked the generated page and it looks that:

  1. The copyright year is not updated:
 Copyright 2020-21, Intel Corp..
  1. The link below from usm_ndarray.usm_type description isn't working:
USM type of underlying memory. Can be ‘device’, ‘shared’, or ‘host’.

See: https://docs.oneapi.com/versions/latest/dpcpp/iface/usm.html

y = x.to_device(q_prof)
timer = dpctl.SyclTimer()
with timer(q_prof):
z = y * y
Copy link
Collaborator

Choose a reason for hiding this comment

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

I've tried the example, but got an exception:

In [1]: import dpctl
   ...: import dpctl.tensor as dpt
   ...:
   ...: x = dpt.full(10**6, 2, dtype="int64")
   ...: q_prof = dpctl.SyclQueue(
   ...:     x.sycl_device, property="enable_profiling")
   ...: # return a view with profile-enabled queue
   ...: y = x.to_device(q_prof)
   ...: timer = dpctl.SyclTimer()
   ...: with timer(q_prof):
   ...:     z = y * y
   ...: print(timer.dt)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [1], in <cell line: 10>()
      9 timer = dpctl.SyclTimer()
     10 with timer(q_prof):
---> 11     z = y * y
     12 print(timer.dt)

TypeError: unsupported operand type(s) for *: 'dpctl.tensor._usmarray.usm_ndarray' and 'dpctl.tensor._usmarray.usm_ndarray'

but if I add import dpnp and run exactly the same code again, it will pass:

In [2]: import dpnp

In [3]: import dpctl
   ...: import dpctl.tensor as dpt
   ...:
   ...: x = dpt.full(10**6, 2, dtype="int64")
   ...: q_prof = dpctl.SyclQueue(
   ...:     x.sycl_device, property="enable_profiling")
   ...: # return a view with profile-enabled queue
   ...: y = x.to_device(q_prof)
   ...: timer = dpctl.SyclTimer()
   ...: with timer(q_prof):
   ...:     z = y * y
   ...: print(timer.dt)
(0.10838821064680815, 0.10794714400000001)

since, as I've got, dpctl will dispatch to dpnp.multiply then.
I believe import dpnp is missing in the example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this example presently requires dpnp, because dpctl.tensor.__mul__ falls back to dpnp if present or returns NotImplemented. This is transient and support for Python arithmetic operations is coming soon.

For the purpose of illustrating usm_ndarray.to_device I probably should have used z = foo(y) to emphasize that any offloading routine we want to time could be used.

@oleksandr-pavlyk
Copy link
Contributor Author

Merging. Will update copyright years with a tool in a separate commit.

@oleksandr-pavlyk oleksandr-pavlyk merged commit 29bc97d into master Nov 16, 2022
@oleksandr-pavlyk oleksandr-pavlyk deleted the expand-to_device-docstring branch November 16, 2022 21:31
@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.0rc2=py310h8c27c75_7 ran successfully.
Passed: 33
Failed: 801
Skipped: 3138

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.

4 participants