google / tangent

Source-to-Source Debuggable Derivatives in Pure Python
Apache License 2.0
2.32k stars 434 forks source link

The newly released tf-nightly is incompatible with 'gast=0.2.2' #100

Closed Sijie-L closed 3 years ago

Sijie-L commented 4 years ago

In the environment.yml, it require that 'tf-nightly == 1.5.0.dev20171026'. The tf-nightly 1.x is no longer available. And the newest released tf-nightly 2.2.0 is only compatible with 'gast==0.3.3', which gives rise to the problem of #97 . But the solution 'pinning the gast < 0.3.0' disables tf-nightly 2.2.0.

I tried install the gast 0.2.2, and used tensorflow 2.1.0 instead of tf-nightly 2.2.0. But it then occured the problem #95 and then #99 , which causes failure while importing tangent.

Thus I wonder if there is any simpler and executable way to solve this problem.

mdanatg commented 4 years ago

I think the simplest way is to upgrade the code of tangent to use gast 0.3. It's not terribly complicated, because only a few types of nodes change, and it's quite mechanical. This PR shows examples of how to upgrade various elements. In most cases, gast.Str, gast.Num need to change to gast.Constant. A few other nodes including gast.Name need extra arguments that can be set to None.

Sijie-L commented 4 years ago

Thank you. I replaced gast.Num, gast.Str, gast.Bytes, gast.Ellipsis, gast.NameConstant with gast.Constant. And then replaced the tf.shape with tf.size. But then it poped up the old problem #99 ,with the error message as below.

`import tangent Traceback (most recent call last):

File "", line 1, in import tangent

File "/home/tf942902/Documents/Applications/Anaconda/anaconda3/envs/tangent/lib/python3.7/site-packages/tangent/init.py", line 46, in from tangent.tf_extensions import *

File "/home/tf942902/Documents/Applications/Anaconda/anaconda3/envs/tangent/lib/python3.7/site-packages/tangent/tf_extensions.py", line 55, in register_shape_function(ops.EagerTensor, shape_as_list)

File "/home/tf942902/Documents/Applications/Anaconda/anaconda3/envs/tangent/lib/python3.7/site-packages/tangent/utils.py", line 229, in register_shape_function assert t not in shape_functions

AssertionError`

I read the link you mentioned [https://github.com/google/tangent/blob/master/tangent/utils.py] before carefully but I still couldn't figure out why the function gets called repeatly. Could you please make a further suggestion about how to deal with this problem?

mdanatg commented 4 years ago

@TREiop I left a comment on #99, can you see if that helps? I'm not sure that the assert needs to be raised, but it would be good to debug why it's called repeatedly and whether it's called with the same arguments or not.

dvicini commented 4 years ago

Hi,

This problem still persists and I wonder if there is a solution to somehow still be able to use tangent? It seems to be a useful library and it would be a shame if it basically became unusable due to some dependency issues, even if the development is not continuing.

Delio

mdanatg commented 4 years ago

@dvicini I think the only viable solution is to upgrade the code of tangent to be compatible with the new TF release. It's not terribly complicated to do, and I'd be happy to provide guidance; we just need a volunteer to do the upgrade (or help @TREiop finish it, if still working on it).

dvicini commented 4 years ago

Thanks for the quick reply! That makes sense. I unfortunately don't have time right now to look into that, otherwise I would be glad to help. Again, I think this library would be very useful to have running again, as there does not seem to be anything comparable. Other source-to-source tools, as you know, are all pretty old or have pretty restrictive licenses :)