Skip to content

Fix sort comparison type selection - #2995

Open
GodlyDonuts wants to merge 1 commit into
openxla:mainfrom
GodlyDonuts:codex/fix-sort-comparison-type
Open

Fix sort comparison type selection#2995
GodlyDonuts wants to merge 1 commit into
openxla:mainfrom
GodlyDonuts:codex/fix-sort-comparison-type

Conversation

@GodlyDonuts

Copy link
Copy Markdown

TensorFlow's tf.RandomShuffle lowering exposed a mismatch in createSortOp: the helper compares only the first operand (the sort key), but selected TOTALORDER when any payload type was floating-point. With i32 keys and an f32 payload, that produces an invalid integer comparison.

This change:

  • selects TOTALORDER only when the first element type is floating-point;
  • adds direct helper-level regression coverage for an integer key with a float payload; and
  • verifies that float keys still use TOTALORDER.

This is the upstream prerequisite for tensorflow/tensorflow#125279. The equivalent MHLO helper was corrected by openxla/xla#40531.

Tested: bazel test //:stablehlo_ops_test --test_output=errors.

Choose TOTALORDER from the sort key type rather than any payload type. Add direct coverage for integer keys with float payloads and preserve total ordering for float keys.
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.

1 participant