-
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.
[running] fix multiprocessing bugs (#547)
* [running] fix multiprocessing bugs * fix tests
- Loading branch information
1 parent
20c1f40
commit d8d5793
Showing
4 changed files
with
52 additions
and
3 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,41 @@ | ||
import sys | ||
|
||
import jax | ||
import pytest | ||
from absl.testing import parameterized | ||
|
||
import brainpy as bp | ||
import brainpy.math as bm | ||
|
||
if sys.platform == 'win32' and sys.version_info.minor >= 11: | ||
pytest.skip('python 3.11 does not support.', allow_module_level=True) | ||
else: | ||
pytest.skip('Cannot pass tests.', allow_module_level=True) | ||
|
||
|
||
class TestParallel(parameterized.TestCase): | ||
@parameterized.product( | ||
duration=[1e2, 1e3, 1e4, 1e5] | ||
) | ||
def test_cpu_unordered_parallel_v1(self, duration): | ||
@jax.jit | ||
def body(inp): | ||
return bm.for_loop(lambda x: x + 1e-9, inp) | ||
|
||
input_long = bm.random.randn(1, int(duration / bm.dt), 3) / 100 | ||
|
||
r = bp.running.cpu_ordered_parallel(body, {'inp': [input_long, input_long]}, num_process=2) | ||
assert bm.allclose(r[0], r[1]) | ||
|
||
@parameterized.product( | ||
duration=[1e2, 1e3, 1e4, 1e5] | ||
) | ||
def test_cpu_unordered_parallel_v2(self, duration): | ||
@jax.jit | ||
def body(inp): | ||
return bm.for_loop(lambda x: x + 1e-9, inp) | ||
|
||
input_long = bm.random.randn(1, int(duration / bm.dt), 3) / 100 | ||
|
||
r = bp.running.cpu_unordered_parallel(body, {'inp': [input_long, input_long]}, num_process=2) | ||
assert bm.allclose(r[0], r[1]) |
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 |
---|---|---|
|
@@ -4,8 +4,8 @@ msgpack | |
numba | ||
jax | ||
jaxlib | ||
matplotlib>=3.4 | ||
scipy>=1.1.0 | ||
matplotlib | ||
scipy | ||
numba | ||
|
||
# document requirements | ||
|