CODAIT / graph_def_editor

GraphDef Editor: A port of the TensorFlow contrib.graph_editor package that operates over serialized graphs
Apache License 2.0
31 stars 16 forks source link

added support for rewriting function graphs in TF2.x models #43

Closed vlasenkoalexey closed 3 years ago

vlasenkoalexey commented 3 years ago

I did some refactoring to extract common functionality from graph.py into base_graph.py and added logic to to work with functions into function_graph.py.

Work was done internally in Google, I first wanted to setup automated integration, but then decided that it is not worth it.

Tested change on TF1.15.3, 2.3 and 2.5 all tests are passing.

If you think change is too big, can move it to a separate branch.

vlasenkoalexey commented 3 years ago

Hi guys,

Could you please take a look at this PR. It basically adds support for rewriting functions. Technically graph_def_editor already supports TF2.x models, but it is not very useful in this case since normally TF2.x models have majority of computation graph encapsulated in functions.

This PR adds following:

I added good unit test coverage for the new functionality, and used it for multiple models. As far as I can tell everything works as expected.