openxla / xla

A machine learning compiler for GPUs, CPUs, and ML accelerators
Apache License 2.0
2.4k stars 361 forks source link

Test for reduction indexing maps being bijections. #14388

Closed copybara-service[bot] closed 2 days ago

copybara-service[bot] commented 2 days ago

Test for reduction indexing maps being bijections.

Currently, we often test exact indexing map strings. This is not useful for a couple of reasons:

This change modifies some of these tests to instead verify that the indexing maps are bijections. Together with a test that verifies the actual reduction output against the interpreter, this gives us good test coverage, while bening less brittle.

For example, when adding vectorization to an emitter, but with an incorrect indexing, the test will tell you that multiple points map to the same element, or to an element that is out of bounds, or some elements aren't mapped to at all.