Skip to content

full: improve error handling and error messages. #9564

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ysiraichi
Copy link
Collaborator

This PR refactors the tensor_methods::full and tensor_methods::full_symint implementation by improving their error message, and returning a status type value.

Key Changes:

  • Make tensor_methods::full and tensor_methods::full_symint return StatusOr<absl_nonnull XLATensorPtr>
  • Improve error message on incompatible tensor shapes

Example:

torch.full((2, -2, 2), 1.5, device="xla")

Before:

Traceback (most recent call last):
  File "examples.py", line 5, in <module>
    torch.full((2, -2, 2), 1.5, device="xla")
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Check failed: std::all_of(size.begin(), size.end(), [](int64_t dim) { return dim >= 0; }): Dimensions cannot be negative numbers (at torch_xla/csrc/tensor_methods.cpp:208)

Exception raised from operator& at torch_xla/csrc/runtime/tf_logging.cpp:26 (most recent call first):

After:

Traceback (most recent call last):
  File "example.py", line 5, in <module>
    torch.full((2, -2, 2), 1.5, device="xla")
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: full(): expected concrete sizes (i.e. non-symbolic) to be positive values, however found negative ones: [2, -2, 2]

Status Propagation Trace:
    From: CheckSizesArePositiveImpl at torch_xla/csrc/tensor_methods.cpp:427 (error: full(): expected concrete sizes (i.e. non-symbolic) to be positive values, however found negative ones: [2, -2, 2])
    From: full at torch_xla/csrc/tensor_methods.cpp:1818

Exception raised from MaybeThrow at torch_xla/csrc/status.cpp:121 (most recent call first):

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