tensorflow: [TransformGraph & TF2 SavedModel] - Missing API
Issue
When using the latest TF2 release and latest available container (2.3.1 at the time of writing), it appears that the following API is missing:
from tensorflow.tools.graph_transforms import TransformGraph # ModuleNotFoundError: No module named 'tensorflow.tools.graph_transforms'
from tensorflow.compat.v1.tools.graph_transforms import TransformGraph # ModuleNotFoundError: No module named 'tensorflow.compat.v1.tools'
Which used to be available in TF1 (https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/graph_transforms).
Though it doesn’t make much of a sense since Tensorflow 2 ship with the C++ library associated:
ls -al /usr/local/lib/python3.6/dist-packages/tensorflow/python/_pywrap_transform_graph.so
-rwxr-xr-x 1 root staff 1274144 Sep 29 00:25 /usr/local/lib/python3.6/dist-packages/tensorflow/python/_pywrap_transform_graph.so
Motivation
This function is very useful to pre-process and “clean” the graph before inference when using a SavedModel (namely for TF-TRT, could also maybe concerns TF Serving or TF Lite, I didn’t check).
Any chance to have this API (or a replacement) back in the TF API ? I understand that TF2 is eager mode oriented, though the SavedModel format is a graph format … So, would makes sense to keep this API in the mix since the SavedModel format is still actively used and supported in TF2.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 16 (7 by maintainers)
then how to use the transforms in grappler optimization?
@DEKHTIARJonathan I no longer work on this project, unfortunately. Good luck!
Sorry @DEKHTIARJonathan I am not the best person to answer this (I was looped in in the event this was a pybind export issue), but I’ll leave it to Pete and Rasmus to hopefully shed some more light.