This is an archive of the discontinued LLVM Phabricator instance.

Fix linalg.dot over boolean tensors.
ClosedPublic

Authored by jreiffers on Jul 7 2022, 7:30 AM.

Details

Summary

dot is currently miscompiled for booleans (uses add instead of or).

Diff Detail

Event Timeline

jreiffers created this revision.Jul 7 2022, 7:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2022, 7:30 AM
jreiffers requested review of this revision.Jul 7 2022, 7:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2022, 7:30 AM

Could you add a test case here?

Also please update the description to make it specific to the error being addressed: XLA is a downstream project and the command line option is specific to there but not relevant here, if there were a GitHub issue you could reference it in body or reference this commit there post, but for commit title it should be standalone in this context.

jreiffers updated this revision to Diff 443007.Jul 7 2022, 11:44 AM

Fix linalg.dot over boolean tensors.

For boolean tensors, this currently uses addi, which is inconsistent with numpy. Numpy uses saturating arithmetic.

>>> np.array([True]) + np.array([True])
array([ True])

<snip>

Done. Thanks.

jreiffers updated this revision to Diff 443169.Jul 8 2022, 1:50 AM

Fix clang-format.

bkramer accepted this revision.Jul 8 2022, 6:30 AM

Being compatible with numpy here seems fine to me.

This revision is now accepted and ready to land.Jul 8 2022, 6:30 AM
jreiffers retitled this revision from Fix linalg.dot over boolean tensors with --xla_cpu_enable_mlir_lowering=true. to Fix linalg.dot over boolean tensors..Jul 12 2022, 12:08 AM
This revision was automatically updated to reflect the committed changes.

Thanks for fixing!