| 81 | |
| 82 | |
| 83 | class BNBNativeLibrary: |
| 84 | _lib: ct.CDLL |
| 85 | compiled_with_cuda = False |
| 86 | |
| 87 | def __init__(self, lib: ct.CDLL): |
| 88 | self._lib = lib |
| 89 | |
| 90 | @functools.cache # noqa: B019 |
| 91 | def __getattr__(self, name): |
| 92 | fn = getattr(self._lib, name, None) |
| 93 | |
| 94 | if fn is not None: |
| 95 | return fn |
| 96 | |
| 97 | def throw_on_call(*args, **kwargs): |
| 98 | raise RuntimeError( |
| 99 | f"Method '{name}' not available in CPU-only version of bitsandbytes.\n" |
| 100 | "Reinstall with GPU support or use CUDA-enabled hardware." |
| 101 | ) |
| 102 | |
| 103 | return throw_on_call |
| 104 | |
| 105 | def __getitem__(self, item): |
| 106 | return self.__getattr__(item) |
| 107 | |
| 108 | |
| 109 | class CudaBNBNativeLibrary(BNBNativeLibrary): |
no outgoing calls
no test coverage detected