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 rounded_from_bits casting in float8.h #205

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

apivovarov
Copy link
Contributor

@apivovarov apivovarov commented Sep 23, 2024

Currently XLA bazel build //xla:literal_test fails with error (Clang 18)

In file included from xla/literal.cc:16:
In file included from ./xla/literal.h:41:
In file included from ./xla/array.h:36:
In file included from ./xla/types.h:27:
In file included from external/tsl/tsl/platform/ml_dtypes.h:19:
bazel-out/k8-opt/bin/external/ml_dtypes/_virtual_includes/float8/ml_dtypes/include/float8.h:1343:21: error: non-constant-expression cannot be narrowed from type 'WideBits' (aka 'unsigned short') to 'ToBits' (aka 'unsigned char') in initializer list [-Wc++11-narrowing]
 1343 |       bits = ToBits{rounded_from_bits};
      |                     ^~~~~~~~~~~~~~~~~

Solution:

Narrowing conversions in an initializer list, is not allowed in C++11 and later without an explicit cast.

We need to explicitly cast the value to the target type (ToBits) to indicate that we are aware of the potential narrowing

@jakevdp Can you have a look?

@apivovarov
Copy link
Contributor Author

Seems that it can be merged @jakevdp @hawkinsp

@apivovarov
Copy link
Contributor Author

apivovarov commented Sep 30, 2024

This issue impacts TensorFlow/JAX pull request CI builds, for example: tensorflow/tensorflow@f4b0b3e

Jake, Peter, Is it possible to merge it today? @hawkinsp @jakevdp

@copybara-service copybara-service bot merged commit c12281a into jax-ml:main Sep 30, 2024
13 checks passed
@apivovarov apivovarov deleted the fix_rounded_from_bits branch September 30, 2024 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants