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

Replace uses of deprecated Shape::rank() in OpenXLA with Shape::dimensions_size(), as we decided to stop using the "rank" term to mean the number of array dimensions. #23944

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Mar 19, 2025

Replace uses of deprecated Shape::rank() in OpenXLA with Shape::dimensions_size(), as we decided to stop using the "rank" term to mean the number of array dimensions.

Initially I tried to replace rank() with dimensions().size(). However, I found that the change is unsafe in some cases as it changes the signedness of the value (from signed to unsigned). For example, due to C++ integer promotion, assuming the number of dimensions is 2,

rank() > -1 will be true (expected), but dimensions().size() > -1 will be false (as -1 is converted to unsigned first).

Therefore I decided to be safe and replace rank() with dimensions_size() instead.

@copybara-service copybara-service bot force-pushed the test_738479217 branch 6 times, most recently from 6965376 to 3f747e4 Compare March 20, 2025 17:45
@copybara-service copybara-service bot changed the title Replace uses of deprecated Shape::rank() in OpenXLA. Replace uses of deprecated Shape::rank() in OpenXLA with Shape::dimensions_size(), as we decided to stop using the "rank" term to mean the number of array dimensions. Mar 20, 2025
…mensions_size()`, as we decided to stop using the "rank" term to mean the number of array dimensions.

Initially I tried to replace `rank()` with `dimensions().size()`. However, I found that the change is unsafe in some cases as it changes the signedness of the value (from signed to unsigned). For example, due to C++ integer promotion, assuming the number of dimensions is 2,

`rank() > -1` will be true (expected), but `dimensions().size() > -1` will be false (as -1 is converted to unsigned first).

Therefore I decided to be safe and replace `rank()` with `dimensions_size()` instead.

PiperOrigin-RevId: 738479217
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