Skip to content

Commit d6f1261

Browse files
committed
temporarily remove unified functions, fix typing for _backend
1 parent 93b88b6 commit d6f1261

File tree

1 file changed

+6
-42
lines changed

1 file changed

+6
-42
lines changed

arrayfire_wrapper/_backend.py

+6-42
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def is_cygwin(cls, name: str) -> bool:
3737
class _BackendPathConfig:
3838
lib_prefix: str
3939
lib_postfix: str
40-
af_path: Path
40+
af_path: Path | None
4141
af_is_user_path: bool
4242
cuda_found: bool
4343

@@ -175,7 +175,7 @@ def __iter__(self) -> Iterator:
175175

176176

177177
class Backend:
178-
_backend_type: BackendType
178+
_backend_type: BackendType | None
179179
_clibs: dict[BackendType, ctypes.CDLL]
180180

181181
def __init__(self) -> None:
@@ -297,51 +297,15 @@ def _find_nvrtc_builtins_lib_name(self, search_path: Path) -> str | None:
297297
return f.name
298298
return None
299299

300-
# unified backend functions
301-
def get_active_backend(self) -> str:
302-
if self._backend_type == BackendType.unified:
303-
from arrayfire_wrapper.lib.unified_api_functions import get_active_backend as unified_get_active_backend
304-
305-
return unified_get_active_backend()
306-
raise RuntimeError("Using unified function on non-unified backend")
307-
308-
def get_available_backends(self) -> list[int]:
309-
if self._backend_type == BackendType.unified:
310-
from arrayfire_wrapper.lib.unified_api_functions import (
311-
get_available_backends as unified_get_available_backends,
312-
)
313-
314-
return unified_get_available_backends()
315-
raise RuntimeError("Using unified function on non-unified backend")
316-
317-
def get_backend_count(self) -> int:
318-
if self._backend_type == BackendType.unified:
319-
from arrayfire_wrapper.lib.unified_api_functions import get_backend_count as unified_get_backend_count
320-
321-
return unified_get_backend_count()
322-
raise RuntimeError("Using unified function on non-unified backend")
323-
324-
def get_backend_id(self, arr: AFArray, /) -> int:
325-
if self._backend_type == BackendType.unified:
326-
from arrayfire_wrapper.lib.unified_api_functions import get_backend_id as unified_get_backend_id
327-
328-
return unified_get_backend_id(arr)
329-
raise RuntimeError("Using unified function on non-unified backend")
330-
331-
def get_device_id(self, arr: AFArray, /) -> int:
332-
if self._backend_type == BackendType.unified:
333-
from arrayfire_wrapper.lib.unified_api_functions import get_device_id as unified_get_device_id
334-
335-
return unified_get_device_id(arr)
336-
raise RuntimeError("Using unified function on non-unified backend")
337-
338300
@property
339-
def backend_type(self) -> BackendType:
301+
def backend_type(self) -> BackendType | None:
340302
return self._backend_type
341303

342304
@property
343305
def clib(self) -> ctypes.CDLL:
344-
return self._clibs[self._backend_type]
306+
if self._backend_type:
307+
return self._clibs[self._backend_type]
308+
raise RuntimeError("No valid _backend_type")
345309

346310

347311
# Initialize the backend

0 commit comments

Comments
 (0)