Skip to content

Conversation

ysiraichi
Copy link
Collaborator

@ysiraichi ysiraichi commented Jul 25, 2025

This PR refactors error handling for GetXlaTensor() and related functions (e.g. TryGetXlaTensor(), TryGetXlaTensors(), and ReplaceXlaTensor()), by incorporating status types. At this moment, these changes do not translate into better UX for the user. However, this PR lays the groundwork for improving that.

Key Changes

  • GetXlaTensor() returns a StatusOr<XLATensorPtr>
  • Deprecate TryGetXlaTensor() in favor of GetXlaTensor()
    • Removing it would be difficult, since the current codegen depends on it and there's no clear replacement
    • Replaced other call-sites with appropriate usage of GetXlaTensor()
  • Remove TryGetXlaTensors() (note the plural)
    • There was only one usage
    • Easily replaceable by GetXlaTensor()
  • Refactor ReplaceXlaTensor(), returning absl::Status
  • Replace all GetXlaTensor() calls with GetValueOrThrow(GetXlaTensor()) (same for GetXlaTensors() -- plural)
  • Replace all ReplaceXlaTensor() calls with MaybeThrow(ReplaceXlaTensor())

@ysiraichi ysiraichi marked this pull request as ready for review July 25, 2025 19:15
Copy link
Collaborator

@zhanyong-wan zhanyong-wan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@ysiraichi ysiraichi merged commit cd3bd91 into master Jul 29, 2025
23 of 24 checks passed
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.

2 participants