MCPcopy Create free account
hub / github.com/bitsandbytes-foundation/bitsandbytes / BNBNativeLibrary

Class BNBNativeLibrary

bitsandbytes/cextension.py:83–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81
82
83class 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
109class CudaBNBNativeLibrary(BNBNativeLibrary):

Callers 1

get_native_libraryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected