-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always build the CPU variant of controller_wrappers such that CUDA bu…
…ild can still run on CPU
- Loading branch information
1 parent
c533946
commit 4590c10
Showing
4 changed files
with
67 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import importlib | ||
|
||
_loaded_backend_module = None | ||
|
||
|
||
def try_import_backend(backend_module_suffix): | ||
module_name = f".controller_wrappers_{backend_module_suffix}" | ||
try: | ||
return importlib.import_module(module_name, "qiskit_aer.backends") | ||
except ImportError: | ||
return None | ||
|
||
|
||
BACKENDS = ["cuda", "rocm", "cpu"] | ||
|
||
for backend_suffix in BACKENDS: | ||
_loaded_backend_module = try_import_backend(backend_suffix) | ||
if _loaded_backend_module: | ||
break | ||
|
||
if _loaded_backend_module is None: | ||
raise ImportError("No backend found for qiskit-aer.") | ||
|
||
|
||
def __getattr__(name): | ||
return getattr(_loaded_backend_module, name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters