lf1-io / padl

Functional deep learning
Apache License 2.0
106 stars 4 forks source link

Issue with saving `padl.identity` #390

Closed sjrl closed 2 years ago

sjrl commented 2 years ago

🐞 Bug

There is a saving issue when using padl.identity within a Compose transform.

import padl
t = padl.identity >> padl.identity
t.pd_save('test')

gives

Traceback (most recent call last):
  File "/venv/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3444, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-5-514864d1df52>", line 1, in <module>
    t.pd_save('test', True)
  File "/venv/lib/python3.8/site-packages/padl/transforms.py", line 386, in pd_save
    code, versions = self._pd_dumps(True, path=path)
  File "/venv/lib/python3.8/site-packages/padl/transforms.py", line 593, in _pd_dumps
    code = graph.dumps()
  File "/venv/lib/python3.8/site-packages/padl/dumptools/var2mod.py", line 857, in dumps
    return _dumps_unscoped(self._unscoped())
  File "/venv/lib/python3.8/site-packages/padl/dumptools/var2mod.py", line 772, in _dumps_unscoped
    sorted_ = _sort(unscoped_graph)
  File "/venv/lib/python3.8/site-packages/padl/dumptools/var2mod.py", line 754, in _sort
    top = _topsort({k: v.globals_ for k, v in unscoped_graph.items()})
  File "/venv/lib/python3.8/site-packages/padl/dumptools/var2mod.py", line 702, in _topsort
    raise RuntimeError('Graph has a circle or dangling roots.')
RuntimeError: Graph has a circle or dangling roots.

Environment/System