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

[BUG]: pybind11::format_descriptor<float16_t>::format() throws RuntimeError: NumPy type info missing for Dh but should return e #4998

Open
3 tasks done
dastrobu opened this issue Jan 2, 2024 · 2 comments
Labels
triage New bug, unverified

Comments

@dastrobu
Copy link

dastrobu commented Jan 2, 2024

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

2.11.1

Problem description

when constructing a buffer format for a dtype float16 array, I get:

RuntimeError: NumPy type info missing for Dh. Here is a full function to reproduce:

std::string float16_format() {
  return pybind11::format_descriptor<float16_t>::format();
}

float16_t is defined as typedef __fp16 float16_t in arm_fp16.h running on MacOS.

According to the python buffer protocol specs float16 should be represented as 'e'.

Numpy and tensor flow are following this convention:

>>> memoryview(np.ones(3, dtype=np.float16)).format
'e'
>>> memoryview(tf.ones(3, dtype=tf.float16)).format
'e'

Reproducible example code

std::string float16_format() {
  return pybind11::format_descriptor<float16_t>::format();
}

Is this a regression? Put the last known working version here if it is.

Not a regression

@dastrobu dastrobu added the triage New bug, unverified label Jan 2, 2024
@dastrobu
Copy link
Author

dastrobu commented Jan 2, 2024

relates to #1908

@swillisart
Copy link

Hello! Yes, it's true half floats are not currently available. You can see extra information here: #4627
and a workaround from the issue here: #1776

None of the core devs have responded to the discussion but I'm still very interested in bringing support of the half-float type from OpenEXR / Imath directly. The question is how they want to proceed with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage New bug, unverified
Projects
None yet
Development

No branches or pull requests

2 participants