Issue 1:
System information

Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes

OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux centos 7

TensorFlow installed from (source or binary): with pip

TensorFlow version (use command below): 1.5.0 (vs 1.4.1)

Python version: 2.7.5

Bazel version (if compiling from source): No

GCC/Compiler version (if compiling from source): No

CUDA/cuDNN version: No

GPU model and memory: No

Exact command to reproduce:

Clone the tensorflow/models repo.

then

cd models/research/slim/
python export_inference_graph.py \
--model_name=inception_v1 \
--image_size=224 \
--output_file=/tmp/inception_v1.pb

Then freeze the graph :

cd tensorflow/tensorflow/python/tools/
python freeze_graph.py \
--input_graph /tmp/inception_v1.pb \
--input_checkpoint /tmp/inception_v1.ckpt \
--output_graph /tmp/inception_v1_frozen.pb \
--input_binary True \
--output_node_names "InceptionV1/Logits/Predictions/Reshape_1"

Then in python do :

import tensorflow as tf
from tensorflow.core.framework import graph_pb2
from tensorflow.python.platform import gfile
import tensorflow.tools.graph_transforms as graph_transforms
graph = graph_pb2.GraphDef()
with open("/tmp/inception_v1_frozen.pb", 'rb') as f:
s = f.read()
graph.ParseFromString(s)
graph = graph_transforms.TransformGraph(graph,
["input"], # inputs nodes
["InceptionV1/Logits/Predictions/Reshape_1"], # outputs nodes
['fold_constants()'])
with gfile.FastGFile("/tmp/inception_v1_frozen"+"_optimized.pbtxt", "w") as f:
f.write(str(graph))

Describe the problem

I am using the graph_transform to fold constants in by graph saved as .pb.

When I use the fold_constants() transformation, some inputs of some nodes are renamed but not the corresponding nodes in the whole graph. So the graph is no longer valid...

I have an "input" placeholder in the graph.

And the node connected to this placeholder as an input name "input:0" instead of "input".

With the version 1.4.1 of tensorflow, I didn't have this issue.

To reproduce, follow the instructions below, and take a look to the /tmp/inception_v1_frozen_optimized.pbtxt graph. And search le node named "input" it is the input placeholder. Then search node which has an input named "input:0". This name ("input:0") is node a node of the graph.

Issue 2:
System information

Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No

OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 16.04

TensorFlow installed from (source or binary): source

TensorFlow version (use command below): 1.12.0 (tensorflow-gpu, tensorflow-base)

Python version: 3.6.8

Bazel version (if compiling from source): 0.21.0

GCC/Compiler version (if compiling from source): 5.4.0 20160609

CUDA/cuDNN version: 7.1.2

GPU model and memory: GeForce GTX 1080, 8GB

Describe the current behavior

Following the https://gist.github.com/carlthome/6ae8a570e21069c60708017e3f96c9fd tutorial, which is based on https://www.tensorflow.org/xla/tfcompile, all the compilation steps succeed. I am also able to invoke the compiled graph, producing correct prediction results. A non-compiled predict of a single image using RestNet50 takes 5ms, a compiled version takes ~140ms.

Note: I have ran ./configure via a terminal to use force CUDA support (such option is not accepted in the example).

Describe the expected behavior

The compiled version prediction of a single image should be as fast as a non-compiled prediction. I suspect the compiled graph uses CPU for the inference.

Code to reproduce the issue

Follow the https://gist.github.com/carlthome/6ae8a570e21069c60708017e3f96c9fd tutorial. To evaluate the compiled and the non-compiled graph prediction of a single image duration, add these two lines to the end of the notebook:

%timeit -n 20 predict(x)

%timeit -n 20 model.predict(x)