Skip to content

Allow NumPy data types as arguments - #2335

Open
ndgrigorian wants to merge 2 commits into
masterfrom
add-dpctl-dtypes
Open

ndgrigorian wants to merge 2 commits into
masterfrom
add-dpctl-dtypes

Conversation

@ndgrigorian

@ndgrigorian ndgrigorian commented Jul 9, 2026 •

Copy link
Copy Markdown
Collaborator

This PR proposes to let any NumPy data type whose values are plain bytes be used as a kernel argument type and wherever dpctl takes a data type. That includes structured data types and types other packages register with NumPy, notably ml_dtypes (bfloat16, complex32, bcomplex32, the float8 types, etc.)

Previously, complex scalars and float16 could not be passed to kernels, as ctypes lacks either of these constructs, and LocalAccessor, WorkGroupMemory, SyclQueue.copy and SyclQueue.fill each accepted only their own fixed list of type strings.

Additionally, dpctl4pybind11.hpp adds a type caster for sycl::ext::oneapi::bfloat16, defined when the compiler provides the appropriate extension.

Closes #72

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

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

@coveralls

coveralls commented Jul 9, 2026 •

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 75.218% (+0.2%) from 74.989% — add-dpctl-dtypes into master

Scalar kernel arguments are passed by size, so any numpy data type with
plain-byte values works, including ml_dtypes types. copy, fill,
LocalAccessor, WorkGroupMemory and SpecializationConstant accept any form
numpy.dtype does. Adds a bfloat16 pybind11 type caster.
@ndgrigorian ndgrigorian changed the title Add dpctl dtype objects Make dpctl kernels dtype-aware Nov 2, 2026
@ndgrigorian ndgrigorian changed the title Make dpctl kernels dtype-aware Allow NumPy data types as arguments Nov 2, 2026
@ndgrigorian
ndgrigorian marked this pull request as ready for review November 2, 2026 21:55

This branch has not been deployed

No deployments
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.

Design support for reduced precision types in dpctl

2 participants