brainstate 0.1.0.post20250206__py2.py3-none-any.whl → 0.1.0.post20250208__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- brainstate/_state.py +13 -20
- brainstate/compile/_jit.py +1 -0
- brainstate/compile/_make_jaxpr.py +1 -1
- brainstate/compile/_util.py +1 -1
- brainstate/graph/_graph_operation.py +1 -1
- brainstate/nn/_module.py +2 -1
- {brainstate-0.1.0.post20250206.dist-info → brainstate-0.1.0.post20250208.dist-info}/METADATA +1 -1
- {brainstate-0.1.0.post20250206.dist-info → brainstate-0.1.0.post20250208.dist-info}/RECORD +11 -11
- {brainstate-0.1.0.post20250206.dist-info → brainstate-0.1.0.post20250208.dist-info}/LICENSE +0 -0
- {brainstate-0.1.0.post20250206.dist-info → brainstate-0.1.0.post20250208.dist-info}/WHEEL +0 -0
- {brainstate-0.1.0.post20250206.dist-info → brainstate-0.1.0.post20250208.dist-info}/top_level.txt +0 -0
brainstate/_state.py
CHANGED
@@ -261,8 +261,9 @@ class State(Generic[A], PrettyRepr):
|
|
261
261
|
"""
|
262
262
|
The data and its value.
|
263
263
|
"""
|
264
|
+
self.check_if_deleted()
|
264
265
|
record_state_value_read(self)
|
265
|
-
return self.
|
266
|
+
return self._value
|
266
267
|
|
267
268
|
@value.setter
|
268
269
|
def value(self, v) -> None:
|
@@ -272,14 +273,7 @@ class State(Generic[A], PrettyRepr):
|
|
272
273
|
Args:
|
273
274
|
v: The value.
|
274
275
|
"""
|
275
|
-
|
276
|
-
|
277
|
-
if isinstance(v, State): # value checking
|
278
|
-
raise ValueError('Cannot set value to a State, ' 'use `copy_from` method instead')
|
279
|
-
self._check_value_tree(v) # check the tree structure
|
280
|
-
record_state_value_write(self) # record the value by the stack (>= level)
|
281
|
-
self._been_writen = True # set the flag
|
282
|
-
self._write_value(v) # write the value
|
276
|
+
self.write_value(v)
|
283
277
|
|
284
278
|
@property
|
285
279
|
def stack_level(self):
|
@@ -301,18 +295,17 @@ class State(Generic[A], PrettyRepr):
|
|
301
295
|
"""
|
302
296
|
self._level = level
|
303
297
|
|
304
|
-
def
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
self.
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
"""
|
313
|
-
The interface to customize the value writing.
|
314
|
-
"""
|
298
|
+
def write_value(self, v) -> None:
|
299
|
+
# value checking
|
300
|
+
if isinstance(v, State):
|
301
|
+
raise ValueError('Cannot set value to a State, ' 'use `copy_from` method instead')
|
302
|
+
self._check_value_tree(v)
|
303
|
+
# write the value by the stack (>= level)
|
304
|
+
record_state_value_write(self)
|
305
|
+
# set the value
|
315
306
|
self._value = v
|
307
|
+
# set flag
|
308
|
+
self._been_writen = True
|
316
309
|
|
317
310
|
def restore_value(self, v) -> None:
|
318
311
|
"""
|
brainstate/compile/_jit.py
CHANGED
@@ -82,6 +82,7 @@ def _get_jitted_fun(
|
|
82
82
|
return fun.fun(*args, **params)
|
83
83
|
|
84
84
|
# compile the function and get the state trace
|
85
|
+
# print('Compiling ...')
|
85
86
|
state_trace = fun.compile_function_and_get_state_trace(*args, **params, return_only_write=True)
|
86
87
|
read_state_vals = state_trace.get_read_state_values(True)
|
87
88
|
|
@@ -499,7 +499,7 @@ class StatefulFunction(object):
|
|
499
499
|
state_vals, out = self.jaxpr_call([st.value for st in state_trace.states], *args, **kwargs)
|
500
500
|
for st, written, val in zip(state_trace.states, state_trace.been_writen, state_vals):
|
501
501
|
if written:
|
502
|
-
st.
|
502
|
+
st.write_value(val)
|
503
503
|
else:
|
504
504
|
st.restore_value(val)
|
505
505
|
return out
|
brainstate/compile/_util.py
CHANGED
@@ -31,7 +31,7 @@ def write_back_state_values(
|
|
31
31
|
assert len(state_trace.states) == len(state_trace.been_writen) == len(read_state_vals) == len(write_state_vals)
|
32
32
|
for st, write, val_r, val_w in zip(state_trace.states, state_trace.been_writen, read_state_vals, write_state_vals):
|
33
33
|
if write:
|
34
|
-
st.
|
34
|
+
st.write_value(val_w)
|
35
35
|
else:
|
36
36
|
st.restore_value(val_r)
|
37
37
|
|
@@ -609,7 +609,7 @@ def _get_children(graph_def, state_mapping, index_ref, index_ref_cache):
|
|
609
609
|
variable.update_from_ref(value)
|
610
610
|
elif isinstance(value, State):
|
611
611
|
if value._been_writen:
|
612
|
-
variable.value
|
612
|
+
variable.write_value(value.value)
|
613
613
|
else:
|
614
614
|
variable.restore_value(value.value)
|
615
615
|
else:
|
brainstate/nn/_module.py
CHANGED
@@ -294,7 +294,8 @@ class Sequential(Module):
|
|
294
294
|
# the input and output shape
|
295
295
|
if first.in_size is not None:
|
296
296
|
self.in_size = first.in_size
|
297
|
-
|
297
|
+
if in_size is not None:
|
298
|
+
self.out_size = tuple(in_size)
|
298
299
|
|
299
300
|
def update(self, x):
|
300
301
|
"""Update function of a sequential model.
|
{brainstate-0.1.0.post20250206.dist-info → brainstate-0.1.0.post20250208.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: brainstate
|
3
|
-
Version: 0.1.0.
|
3
|
+
Version: 0.1.0.post20250208
|
4
4
|
Summary: A ``State``-based Transformation System for Program Compilation and Augmentation.
|
5
5
|
Home-page: https://github.com/chaobrain/brainstate
|
6
6
|
Author: BrainState Developers
|
@@ -1,5 +1,5 @@
|
|
1
1
|
brainstate/__init__.py,sha256=AkZyyFkn4fB8g2aT6Rc2MO1xICPpUZuDtdze-eUQNc0,1496
|
2
|
-
brainstate/_state.py,sha256=
|
2
|
+
brainstate/_state.py,sha256=GZ46liHZSHbAHQEuELvOeoJ27P9xiZDz06G2AASjAjA,29142
|
3
3
|
brainstate/_state_test.py,sha256=rJUFRSXEqrrl4qANRewY9mnDlzSbtHwBIGeZ0ku-8Dg,1650
|
4
4
|
brainstate/_utils.py,sha256=uJ6WWKq3yb05ZdktCQGLWOXsOJveL1H9pR7eev70Jes,1693
|
5
5
|
brainstate/environ.py,sha256=PZnVFWPioUBuWmwCO8wwCKrHQfP3BR-5lYPRl5i5GDA,17698
|
@@ -24,17 +24,17 @@ brainstate/compile/_conditions.py,sha256=gApsHKGQrf1QBjoKXDVL7VsoeJ2zFtSc-hFz9nb
|
|
24
24
|
brainstate/compile/_conditions_test.py,sha256=s9LF6h9LvigvgxUIugTqvgCHBIU8TXS1Ar1OlIxXfrw,8389
|
25
25
|
brainstate/compile/_error_if.py,sha256=TFvhqITKkRO9m30GdlUP4eEjJvLWQUhjkujXO9zvrWs,2689
|
26
26
|
brainstate/compile/_error_if_test.py,sha256=OdJG483IIdOrCHxtHd49OHfOxCSnSkk7GdAUOzSt8bE,2044
|
27
|
-
brainstate/compile/_jit.py,sha256
|
27
|
+
brainstate/compile/_jit.py,sha256=itAWENKfJvnlaWl_uSy8lHTK8K1in89F_ZXXwp-EGRM,13944
|
28
28
|
brainstate/compile/_jit_test.py,sha256=zD7kck9SQJGmUDolh9P4luKwQ21fBGje1Z4STTEXIuA,4135
|
29
29
|
brainstate/compile/_loop_collect_return.py,sha256=TrKBZhtQecTtuiVz_HOeyepde-znzjlyk0Te53-AvOE,23492
|
30
30
|
brainstate/compile/_loop_collect_return_test.py,sha256=bA-_11E8A_0jR5umEO3e409y7bb5QYDTgSL-SBaX7kQ,1802
|
31
31
|
brainstate/compile/_loop_no_collection.py,sha256=qto2__Zt2PJntkjB9AXEgraGLvNUJS483BhCXjJyqv0,7495
|
32
32
|
brainstate/compile/_loop_no_collection_test.py,sha256=oStB1CSG_iLp9sHdXd1hJNFvlxbzjck9Iy4sABoJDj4,1419
|
33
|
-
brainstate/compile/_make_jaxpr.py,sha256=
|
33
|
+
brainstate/compile/_make_jaxpr.py,sha256=J4oWoPBwG-fdJvNhBEtNgmo3rXrIWCoajELhaIumgPU,33309
|
34
34
|
brainstate/compile/_make_jaxpr_test.py,sha256=3gwdiutn_PJyiweu3oPEXumxEVHKaE2xDGvkwZy2GEo,4367
|
35
35
|
brainstate/compile/_progress_bar.py,sha256=5pCMCEmbTO5XmKtzRUJGA178tuBznWKuh9Kw00wAL1I,7524
|
36
36
|
brainstate/compile/_unvmap.py,sha256=CJA6D9lUcBfvdLrpFVvC2AdTJqe9uY0Ht6PltQJyr4U,4228
|
37
|
-
brainstate/compile/_util.py,sha256=
|
37
|
+
brainstate/compile/_util.py,sha256=aCvkTV--g4NsqcodTdBAISt4EwgezCbKzNUV58n-Q_Y,6304
|
38
38
|
brainstate/functional/__init__.py,sha256=j6-3Er4fgqWpvntzYCZVB3e5hoz-Z3aqvapITCuDri0,1107
|
39
39
|
brainstate/functional/_activations.py,sha256=S0Ok7sq5FTbmJWSejpOCHo1jpKX0gYOLy_TO2IUXM8s,21726
|
40
40
|
brainstate/functional/_activations_test.py,sha256=T___RlSrIfXwlkw8dg5A9EZMTZGDzv3a2evUwq_nYFg,13034
|
@@ -44,7 +44,7 @@ brainstate/functional/_spikes.py,sha256=QY-2ayJkgkGELcq-bftPEaf_hJptVf_SP3fY36Qv
|
|
44
44
|
brainstate/graph/__init__.py,sha256=noo4TjBg6iEhjjwk0sAGUhR7Ge-z8Vnc2rLYUvnqttw,1295
|
45
45
|
brainstate/graph/_graph_node.py,sha256=swAokZLKswSTaq2WEhyLIs38sy_67C6maHI6T3e1hvY,8339
|
46
46
|
brainstate/graph/_graph_node_test.py,sha256=BFGfdzZFDHI0XK7hHotSVWKt3em1taGvn8FHF9NCXx8,2702
|
47
|
-
brainstate/graph/_graph_operation.py,sha256=
|
47
|
+
brainstate/graph/_graph_operation.py,sha256=cIwGo3ICgtce2fmdn917r81evMFjJIKeW9doaQK4DD8,64111
|
48
48
|
brainstate/graph/_graph_operation_test.py,sha256=zjvpKjQAFWtw8YZuqOk_jmlZNb_-E8oPyNx57dyc8jI,18556
|
49
49
|
brainstate/init/__init__.py,sha256=R1dHgub47o-WJM9QkFLc7x_Q7GsyaKKDtrRHTFPpC5g,1097
|
50
50
|
brainstate/init/_base.py,sha256=B_NLS9aKNrvuj5NAlSgBbQTVev7IRvzcx8vH0J-Gq2w,1671
|
@@ -57,7 +57,7 @@ brainstate/nn/__init__.py,sha256=rxURT8J1XfBn3Vh3Dx_WzVADWn9zVriIty5KZEG-x6o,162
|
|
57
57
|
brainstate/nn/_collective_ops.py,sha256=sSjIIs1MvZA30XFFmK7iL1D_sCeh7hFd3PanCH6kgZo,6779
|
58
58
|
brainstate/nn/_exp_euler.py,sha256=yjkfSllFxGWKEAlHo5AzBizzkFj6FEVDKmFV6E2g214,3521
|
59
59
|
brainstate/nn/_exp_euler_test.py,sha256=clwRD8QR71k1jn6NrACMDEUcFMh0J9RTosoPnlYWUkw,1242
|
60
|
-
brainstate/nn/_module.py,sha256=
|
60
|
+
brainstate/nn/_module.py,sha256=UzsnaTDh5F6Z8B7ou4RXmTdAWXbNkjf03bYP0kF3_fE,10872
|
61
61
|
brainstate/nn/_module_test.py,sha256=V4ZhiY_zYPvArkB2eeOTtZcgQrtlRyXKMbS1AJH4vC8,8893
|
62
62
|
brainstate/nn/metrics.py,sha256=iupHjSRTHYY-HmEPBC4tXWrZfF4zh1ek2NwSAA0gnwE,14738
|
63
63
|
brainstate/nn/_dyn_impl/__init__.py,sha256=Oazar7h89dp1WA2Vx4Tj7gCBhxJKH4LAUEABkBEG7vU,1462
|
@@ -117,8 +117,8 @@ brainstate/util/_others.py,sha256=jsPZwP-v_5HRV-LB5F0NUsiqr04y8bmGIsu_JMyVcbQ,14
|
|
117
117
|
brainstate/util/_pretty_repr.py,sha256=bDpU4gbkS4B8cXBkiN8kBQNmruxiJzDRF-eIqzyeYnM,5716
|
118
118
|
brainstate/util/_scaling.py,sha256=pc_eM_SZVwkY65I4tJh1ODiHNCoEhsfFXl2zBK0PLAg,7562
|
119
119
|
brainstate/util/_struct.py,sha256=KMMHcshOM20gYhSahNzWLxsTt-Rt3AeX3Uz26-rP9vI,17619
|
120
|
-
brainstate-0.1.0.
|
121
|
-
brainstate-0.1.0.
|
122
|
-
brainstate-0.1.0.
|
123
|
-
brainstate-0.1.0.
|
124
|
-
brainstate-0.1.0.
|
120
|
+
brainstate-0.1.0.post20250208.dist-info/LICENSE,sha256=VZe9u1jgUL2eCY6ZPOYgdb8KCblCHt8ECdbtJid6e1s,11550
|
121
|
+
brainstate-0.1.0.post20250208.dist-info/METADATA,sha256=bPJy4z_tBevWkxdyS5QXYtcXxvYwGYs44SuYIkqq4Ns,3585
|
122
|
+
brainstate-0.1.0.post20250208.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
|
123
|
+
brainstate-0.1.0.post20250208.dist-info/top_level.txt,sha256=eQbGgKn0ptx7FDWuua0V0wr4K1VHi2iOUCYo3fUQBRA,11
|
124
|
+
brainstate-0.1.0.post20250208.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{brainstate-0.1.0.post20250206.dist-info → brainstate-0.1.0.post20250208.dist-info}/top_level.txt
RENAMED
File without changes
|