-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MetaBackend #172
MetaBackend #172
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments. It looks perfect.
Co-authored-by: Alessandro Candido <[email protected]>
for more information, see https://pre-commit.ci
src/qibojit/backends/__init__.py
Outdated
if platform == "numba": | ||
return NumbaBackend() | ||
elif platform == "cupy": | ||
return CupyBackend() | ||
elif platform == "cuquantum": | ||
return CuQuantumBackend() | ||
else: | ||
raise_error( | ||
ValueError, | ||
f"Unsupported platform, please use one among {PLATFORMS}.", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In principle, you could even implement this with a dict
. Or, even better, an Enum
.
if platform == "numba": | |
return NumbaBackend() | |
elif platform == "cupy": | |
return CupyBackend() | |
elif platform == "cuquantum": | |
return CuQuantumBackend() | |
else: | |
raise_error( | |
ValueError, | |
f"Unsupported platform, please use one among {PLATFORMS}.", | |
) | |
return Platforms[platform].value() |
and above, changing the constant to:
class Platforms(Enum):
numpy = NumpyBackend
...
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #172 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 12 12
Lines 1085 1112 +27
=========================================
+ Hits 1085 1112 +27
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving so that you can merge if needed.
This PR implements a
MetaBackend
to load eachqibojit
backend and list the available ones.