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

[Fix] Ufuncs: Support float32 scalars for Add, Multply, and Divide #291

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

HannanNaeem
Copy link
Contributor

Our current implementation does not support float32 scalars for add, multiply, and divide. This PR introduces a simple fix in the logic to allow computation with float32 scalars.


Currently Pykokkos always casts scalars as pk.double which is equivalent to float64 in numpy terms. We also then enforce that both operands, for the aforementioned ufuncs, be the same type .e.g. either float32 or float64. This creates a problem when passing a float32 value as scalar with a float32 view. The scalar is casted as float64 and the type assertion fails by our own doing.

To fix this:

  • Scalar takes the type Float32 or float64 based on the view it is passed with (so they remain the same)
  • Tweak the float impls to use modulus indexing to support scalars

Quality tweak:

  • Updated error messages to be verbose about what types mismatched

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.

1 participant