Skip to content

Commit

Permalink
Remove uses of raise unimplemented (#122136)
Browse files Browse the repository at this point in the history
Summary:
`unimplemented` is a function that raises an error, so
`raise unimplemented(...)` never reaches the `raise`.
Another related issue is that `raise unimplemented(...) from e`
doesn't attach the exception cause correctly. I fix this by adding
a `from_exc` argument to `unimplemented`.

X-link: pytorch/pytorch#122136
Approved by: https://github.com/lezcano

Reviewed By: huydhn

Differential Revision: D55271689

fbshipit-source-id: a4ffcb1c72f966869af6dd87dfbecf0a324e41b7
  • Loading branch information
peterbell10 authored and facebook-github-bot committed Mar 23, 2024
1 parent d8fafe6 commit 40caaee
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions userbenchmark/dynamo/dynamobench/_dynamo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,10 @@ def proxy_args_kwargs(args, kwargs):
from .exc import unimplemented
from .variables.base import typestr

raise unimplemented(
f"call_function args: {typestr(*args)} {typestr(*list(kwargs.values()))}"
) from e
unimplemented(
f"call_function args: {typestr(*args)} {typestr(*list(kwargs.values()))}",
from_exc=e,
)


@dataclasses.dataclass
Expand Down Expand Up @@ -1211,7 +1212,7 @@ def wrap_fake_exception(fn):

msg = f"Unsupported: {e.reason} with fake tensor propagation."
log.warning(msg)
raise unimplemented(msg) from e
unimplemented(msg, from_exc=e)


def deepcopy_to_fake_tensor(obj, fake_mode):
Expand Down Expand Up @@ -1808,7 +1809,7 @@ def make_error_message(e):
# NB: mimic how wrap_fake_exception does it
from .exc import unimplemented

raise unimplemented(make_error_message(e)) from e
unimplemented(make_error_message(e), from_exc=e)
except Exception as e:
raise RuntimeError(make_error_message(e)).with_traceback(
e.__traceback__
Expand Down

0 comments on commit 40caaee

Please sign in to comment.