Skip to content

Conversation

@copybara-service
Copy link

[MLIR] Fix construction of i1 attributes from numpy arrays and add tests.

This change fixes the construction of MLIR attributes from numpy arrays for a Boolean dtype. This happened when calling jax.mlir.ir_attribute and the problem occurred in _numpy_array_attribute: that function first bit-packed the Booleans and then determined the dtype from the result, which is uint8 at that point rather than bool. The fix thus consists of a simple swapping of lines. Note that the virtually equivalent _numpy_array_constant already used the right order.

The change also sets up tests for the MLIR component, which did not have any tests, and adds tests for some of the numpy-to-attribute conversions.

…tests.

This change fixes the construction of MLIR attributes from `numpy` arrays for a Boolean `dtype`. This happened when calling `jax.mlir.ir_attribute` and the problem occurred in `_numpy_array_attribute`: that function *first* bit-packed the Booleans and *then* determined the `dtype` from the result, which is `uint8` at that point rather than `bool`. The fix thus consists of a simple swapping of lines. Note that the virtually equivalent `_numpy_array_constant` already used the right order.

The change also sets up tests for the MLIR component, which did not have any tests, and adds tests for some of the numpy-to-attribute conversions.

PiperOrigin-RevId: 825955532
@ingomueller-net
Copy link

What do I have to do to have this PR reviewed? Since it was created by Copybara, I don't own the PR so I can't add reviewers...

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.

3 participants