Skip to content

Add device-aware output dtype for dpt.round() with boolean input#2851

Merged
vlad-perevezentsev merged 4 commits intoinclude-dpctl-tensorfrom
update_tensor_round
Apr 15, 2026
Merged

Add device-aware output dtype for dpt.round() with boolean input#2851
vlad-perevezentsev merged 4 commits intoinclude-dpctl-tensorfrom
update_tensor_round

Conversation

@vlad-perevezentsev
Copy link
Copy Markdown
Contributor

@vlad-perevezentsev vlad-perevezentsev commented Apr 14, 2026

This PR proposes device-aware output dtype resolution for dpnp.tensor.round() with boolean input to handle devices that do not support float16

Boolean support for round() was originally added in #2817 6f5a792 to match NumPy behavior where numpy.round(bool) returns float16 rather than an integral type like int8.
However on devices without fp16 support, returning float16 is not viable.

The bool type mapping was removed from the round kernel and an acceptance
function _acceptance_fn_round was added to ensure the fallback in _find_buf_dtype
prefers floating-point output over integral types for boolean input

result
fp16 devices: round(bool) -> float16
non-fp16 devices: round(bool) -> float32

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

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Apr 14, 2026

Coverage Status

Coverage is 77.876%update_tensor_round into include-dpctl-tensor. No base build found for include-dpctl-tensor.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

Array API standard conformance tests for dpnp=0.20.0dev6=py313h509198e_58 ran successfully.
Passed: 1357
Failed: 3
Skipped: 16

Comment thread dpnp/tensor/_type_utils.py Outdated
Comment thread dpnp/tensor/_type_utils.py Outdated
ndgrigorian
ndgrigorian previously approved these changes Apr 15, 2026
Copy link
Copy Markdown
Collaborator

@ndgrigorian ndgrigorian left a comment

Choose a reason for hiding this comment

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

aside from above points LGTM

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 15, 2026

View rendered docs @ https://intelpython.github.io/dpnp/index.html

Copy link
Copy Markdown
Contributor

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

LGTM
Thank you @vlad-perevezentsev

@vlad-perevezentsev vlad-perevezentsev merged commit 549e940 into include-dpctl-tensor Apr 15, 2026
67 of 71 checks passed
@vlad-perevezentsev vlad-perevezentsev deleted the update_tensor_round branch April 15, 2026 12:48
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