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

Create a util function BuildGetTupleElementsForTupleResults with proper processing on the shardings. #64462

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

copybara-service[bot]
Copy link

Create a util function BuildGetTupleElementsForTupleResults with proper processing on the shardings.

Issue 1.
The following code snippet is widely used in mlir_hlo_to_hlo.cc when exporting to a XlaOp if the op has multiple results, such as RngBitGeneratorOp and OptimizationBarrierOp. We create a util function to replace the repeating code snippets.

for (auto [index, result] : llvm::enumerate(op.getResults())) {
    value_map[result] = xla::GetTupleElement(tuple, index);
}

Issue 2.
When we build xla::GetTupleElement in the code snippet, we inherit the tuple sharding (if any) and assign the tuple sharding to the xla::GetTupleElement. This triggers a mismatching error on shape and sharding in XlaBuilder. This cl uses XlaScopedShardingAssignment to process it appropriately.

Enhance the test cases accordingly.

…oper processing on the shardings.

**Issue 1.**
The following code snippet is widely used in `mlir_hlo_to_hlo.cc` when exporting to a XlaOp if the op has multiple results, such as RngBitGeneratorOp and OptimizationBarrierOp. We create a util function to replace the repeating code snippets.
```
for (auto [index, result] : llvm::enumerate(op.getResults())) {
    value_map[result] = xla::GetTupleElement(tuple, index);
}
```

**Issue 2.**
When we build `xla::GetTupleElement` in the code snippet, we inherit the tuple sharding (if any) and assign the tuple sharding to the `xla::GetTupleElement`. This triggers a mismatching error on shape and sharding in XlaBuilder. This cl uses `XlaScopedShardingAssignment` to process it appropriately.

Enhance the test cases accordingly.

PiperOrigin-RevId: 619009107
@copybara-service copybara-service bot merged commit 5e77560 into master Mar 26, 2024
@copybara-service copybara-service bot deleted the exported_pr_617634865 branch March 26, 2024 01:29
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.

None yet

1 participant