-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates for OO transformations and surrogate functions (#519)
Updates for OO transforma and surrogate functions
- Loading branch information
Showing
20 changed files
with
273 additions
and
70 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
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
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,29 @@ | ||
from jax.lib import xla_client | ||
|
||
# Register the CPU XLA custom calls | ||
try: | ||
import brainpylib | ||
from brainpylib import cpu_ops | ||
|
||
for _name, _value in cpu_ops.registrations().items(): | ||
xla_client.register_custom_call_target(_name, _value, platform="cpu") | ||
except ImportError: | ||
cpu_ops = None | ||
brainpylib = None | ||
|
||
# Register the GPU XLA custom calls | ||
try: | ||
from brainpylib import gpu_ops | ||
|
||
for _name, _value in gpu_ops.registrations().items(): | ||
xla_client.register_custom_call_target(_name, _value, platform="gpu") | ||
except ImportError: | ||
gpu_ops = None | ||
|
||
# check brainpy and brainpylib version consistency | ||
_minimal_brainpylib_version = '0.1.10' | ||
if brainpylib is not None: | ||
if brainpylib.__version__ < _minimal_brainpylib_version: | ||
raise SystemError(f'This version of brainpy needs brainpylib >= {_minimal_brainpylib_version}.') | ||
if hasattr(brainpylib, 'check_brainpy_version'): | ||
brainpylib.check_brainpy_version() |
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
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
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
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
Oops, something went wrong.