brainpy/BrainPy

Support to trace ``Variable``s inside of a brainpy transformation

chaoming0625 opened this issue · 1 comments

Please:

  • Check for duplicate requests.
  • Describe your goal, and if possible provide a code snippet with a motivating example.

The current brainpy transformations can only trace Variable outside these transformation functions. For example,

class A():
  def __init__(self):
     self.a  = bm.Variable(1)  # can be traced
  
  @bm.cls_jit
  def f(self):
     self.b = bm.Variable(1)   # cannot be traced
     self.a += self.b

This is in contrast to the OO transformations in Flax, which supports to trace Variables inside of a transformation function.

It may be essential to support Variable tracing during a computation.

Has been solved in #472.