Skip to content

Commit 255591f

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

File tree

1 file changed

+6
-44
lines changed

1 file changed

+6
-44
lines changed

arrayfire_wrapper/_backend.py

+6-44
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
from pathlib import Path
1212
from typing import Iterator
1313

14-
from arrayfire_wrapper.defines import AFArray
15-
1614
from .version import ARRAYFIRE_VER_MAJOR
1715

1816
VERBOSE_LOADS = os.environ.get("AF_VERBOSE_LOADS", "") == "1"
@@ -37,7 +35,7 @@ def is_cygwin(cls, name: str) -> bool:
3735
class _BackendPathConfig:
3836
lib_prefix: str
3937
lib_postfix: str
40-
af_path: Path
38+
af_path: Path | None
4139
af_is_user_path: bool
4240
cuda_found: bool
4341

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

176174

177175
class Backend:
178-
_backend_type: BackendType
176+
_backend_type: BackendType | None
179177
_clibs: dict[BackendType, ctypes.CDLL]
180178

181179
def __init__(self) -> None:
@@ -297,51 +295,15 @@ def _find_nvrtc_builtins_lib_name(self, search_path: Path) -> str | None:
297295
return f.name
298296
return None
299297

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-
338298
@property
339-
def backend_type(self) -> BackendType:
299+
def backend_type(self) -> BackendType | None:
340300
return self._backend_type
341301

342302
@property
343303
def clib(self) -> ctypes.CDLL:
344-
return self._clibs[self._backend_type]
304+
if self._backend_type:
305+
return self._clibs[self._backend_type]
306+
raise RuntimeError("No valid _backend_type")
345307

346308

347309
# Initialize the backend

0 commit comments

Comments
 (0)