Skip to content

Commit 6364119

Browse files
authored
[Wave] Remove unused code from iree/turbine/support (#44)
Also move used functions from the deleted files into where they are being used. Signed-off-by: Harsh Menon <[email protected]>
1 parent 11c4f4d commit 6364119

File tree

5 files changed

+27
-139
lines changed

5 files changed

+27
-139
lines changed

iree/turbine/runtime/device.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,27 @@
3636
torch_dtype_to_numpy,
3737
)
3838

39-
from ..support.exceptions import (
40-
NoCurrentDeviceError,
41-
MismatchedDeviceSetClearError,
42-
UnsupportedTorchDeviceError,
43-
)
39+
40+
class NoCurrentDeviceError(Exception):
41+
def __init__(self):
42+
super().__init__(
43+
"You accessed a method which requires a current device but none was set on this thread. "
44+
"Either pass an explicit 'device=' or set a current device via "
45+
"`with device:`"
46+
)
47+
48+
49+
class MismatchedDeviceSetClearError(AssertionError):
50+
def __init__(self):
51+
super().__init__("Calls to Device.set()/clear() are mismatched or unbalanced.")
52+
53+
54+
class UnsupportedTorchDeviceError(Exception):
55+
def __init__(self, torch_device):
56+
super().__init__(
57+
f"Attempt to use turbine with a torch.device that is not supported by this build: {torch_device}"
58+
)
59+
4460

4561
from ..support.logging import runtime_logger as logger
4662

iree/turbine/support/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@
66

77
# Debugging must be loaded first as other low level things depend on it.
88
from .debugging import *
9-
from .exceptions import *

iree/turbine/support/conversions.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818
TORCH_DTYPE_TO_MLIR_TYPE_ASM,
1919
)
2020

21-
from .exceptions import (
22-
UnknownDTypeError,
23-
)
21+
22+
class UnknownDTypeError(ValueError):
23+
def __init__(self, dtype):
24+
self.dtype = dtype
25+
super().__init__(f"Unable to map torch dtype {dtype} to Turbine")
26+
2427

2528
from .ir_imports import (
2629
Float8E4M3FNUZType,

iree/turbine/support/exceptions.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

iree/turbine/support/tools.py

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)