Skip to content

Improve dpctl.tensor.full error for invalid fill_value #1878

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 5 commits into from
Oct 24, 2024

Conversation

ndgrigorian
Copy link
Collaborator

This PR proposes adding a check to full when the value to construct the array with is not a scalar value, i.e., some type of object or a string.

Previously these cases would fail, but pybind11 would throw RuntimeError. Now, a TypeError is thrown from Python, and the result array is never allocated, preventing wasted memory allocation.

  • 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?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?
  • If this PR is a work in progress, are you opening the PR as a draft?

…type

pybind11 raises RuntimeError when a value cannot be cast to a type, i.e., a string to an integer. Now when scalar is not an array, a check is performed, and TypeError is raised
Copy link
Contributor

@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.

LGTM!

@ndgrigorian
Copy link
Collaborator Author

I've added this change to the changelog as well.

Copy link

github-actions bot commented Oct 23, 2024

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

Copy link

Array API standard conformance tests for dpctl=0.19.0dev0=py310hdf72452_150 ran successfully.
Passed: 894
Failed: 1
Skipped: 119

Copy link

Array API standard conformance tests for dpctl=0.19.0dev0=py310hdf72452_151 ran successfully.
Passed: 894
Failed: 1
Skipped: 119

NumPy bools do not subclass `numbers.Number` and therefore must be handled separately. Python bools do, so no logic is needed.
Copy link

Array API standard conformance tests for dpctl=0.19.0dev0=py310hdf72452_152 ran successfully.
Passed: 894
Failed: 1
Skipped: 119

@coveralls
Copy link
Collaborator

coveralls commented Oct 23, 2024

Coverage Status

coverage: 87.681% (+0.008%) from 87.673%
when pulling 7095358 on improve-full-error-for-invalid-scalar-type
into 2023622 on master.

Copy link

Array API standard conformance tests for dpctl=0.19.0dev0=py310hdf72452_158 ran successfully.
Passed: 894
Failed: 1
Skipped: 119

@ndgrigorian ndgrigorian merged commit 9b83bef into master Oct 24, 2024
46 of 48 checks passed
@ndgrigorian ndgrigorian deleted the improve-full-error-for-invalid-scalar-type branch October 24, 2024 02:23
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.

3 participants