Skip to content

Commit

Permalink
Add "device not supported" assert to inductor (#112001)
Browse files Browse the repository at this point in the history
Fixes #111999

Adds an assert that provides a more informative error message

For example, when running a compiled function with mps (currently unsupported):
```
...
  File "/Users/andrew.hu/Desktop/pytorch/torch/_inductor/graph.py", line 927, in init_wrapper_code
    assert wrapper_code_gen_cls is not None, f"Device {device_type} not supported"
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
torch._dynamo.exc.BackendCompilerFailed: backend='inductor' raised:
AssertionError: Device mps not supported
```

Pull Request resolved: #112001
Approved by: https://github.com/peterbell10
  • Loading branch information
andrewhu authored and pytorchmergebot committed Oct 25, 2023
1 parent 88244cd commit 8253e05
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions torch/_inductor/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,7 @@ def init_wrapper_code(self):
only_cpu = len(device_types) == 0
device_type = "cpu" if only_cpu else device_types.pop()
wrapper_code_gen_cls = get_wrapper_codegen_for_device(device_type)
assert wrapper_code_gen_cls is not None, f"Device {device_type} not supported"
self.wrapper_code = wrapper_code_gen_cls()

def codegen(self):
Expand Down

0 comments on commit 8253e05

Please sign in to comment.