@@ -30,6 +30,7 @@ def __hash__(self) -> int:
3030 return hash (("Device" , self ._device ))
3131
3232 def _supported_dtypes (self ) -> list [DType ]:
33+ # XXX useful? Unused ATM
3334 return list (dt for dt in _all_dtypes if device_supports_dtype (self , dt ))
3435
3536
@@ -47,6 +48,9 @@ def check_device(device: Device | None) -> None:
4748 raise ValueError (f"Unsupported device { device !r} " )
4849
4950
51+ # Helpers for device-specific dtype support
52+
53+
5054def device_supports_dtype (device : Device | None , dtype : DType | None ) -> bool :
5155 """True if `device` supports `dtype`, False otherwise."""
5256 # special-case F32_device
@@ -57,9 +61,7 @@ def device_supports_dtype(device: Device | None, dtype: DType |None) -> bool:
5761 return True
5862
5963
60- # Device-specific dtype maps
61-
62- def _map_helper (dtypes : list [DType ], device : Device ) -> dict [str , DType ]:
64+ def _map_supported (dtypes : list [DType ], device : Device ) -> dict [str , DType ]:
6365 return {
6466 dt ._canonic_name : dt
6567 for dt in dtypes
@@ -81,29 +83,3 @@ def _map_helper(dtypes: list[DType], device: Device) -> dict[str, DType]:
8183 "numeric" : _numeric_dtypes
8284}
8385
84- _device_dtype_maps = {}
85-
86- for device in ALL_DEVICES :
87- _map = {}
88- for kind , dtypes in _kind_to_dtypes .items ():
89- _map [kind ] = {
90- dt ._canonic_name : dt
91- for dt in dtypes
92- if device_supports_dtype (device , dt )
93- }
94- _device_dtype_maps [device ] = _map
95-
96-
97-
98- '''
99- _kind_to_dtypes = {
100- None: {x._canonic_name:x for x in _all_dtypes},
101- "bool": {"bool": bool},
102- "signed integer": {x._canonic_name: x for x in _signed_integer_dtypes},
103- "unsigned integer": {x._canonic_name: x for x in _unsigned_integer_dtypes},
104- "integral": {x._canonic_name: x for x in _integer_dtypes},
105- "real floating": {x._canonic_name: x for x in _real_floating_dtypes},
106- "complex floating": {x._canonic_name: x for x in _complex_floating_dtypes},
107- "numeric": {x._canonic_name: x for x in _numeric_dtypes}
108- }
109- '''
0 commit comments