<h3 dir="auto">Describe the problem</h3>
<p dir="auto">I want to load and run a single tensorflow model within another C++ project. To do this, I defined the <code class="notranslate">tensorflow_all</code> library in <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/BUILD"><code class="notranslate">tensorflow/BUILD</code></a> which should include all the necessary dependencies. (Details below)</p>
<p dir="auto">When loading the tensorflow model via the C++ API (<a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/cc/saved_model/loader.h#L50">LoadSavedModel</a>), the following runtime error occurs:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="2017-07-28 13:36:41.875493: I tensorflow/cc/saved_model/loader.cc:284] Loading SavedModel: fail. Took 43550 microseconds.
terminate called after throwing an instance of 'std::runtime_error'
  what():  Not found: Op type not registered 'BlockLSTM' in binary running on myMachine. 
  Make sure the Op and Kernel are registered in the binary running in this process."><pre class="notranslate"><code class="notranslate">2017-07-28 13:36:41.875493: I tensorflow/cc/saved_model/loader.cc:284] Loading SavedModel: fail. Took 43550 microseconds.
terminate called after throwing an instance of 'std::runtime_error'
  what():  Not found: Op type not registered 'BlockLSTM' in binary running on myMachine. 
  Make sure the Op and Kernel are registered in the binary running in this process.
</code></pre></div>
<p dir="auto">I found that the BlockLSTM Op is registered in <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/rnn/ops/lstm_ops.cc#L179"><code class="notranslate">tensorflow/contrib/rnn/ops/lstm_ops.cc</code></a>.<br>
However, I could not find a way to include the operation BlockLSTM in my C++ library <code class="notranslate">tensorflow_all</code>.</p>
<p dir="auto">Bear with me if this is actually not a bug (or even a feature request). I am still getting started with tensorflow.</p>
<p dir="auto">Since my implementation is part of another larger project, it is currently difficult for me to give an easy to reproduce example. However, if this is necessary, I will do it as soon as I find the time.</p>
<h3 dir="auto">System information</h3>
<ul dir="auto">
<li>
<p dir="auto"><strong>Have I written custom code (as opposed to using a stock example script provided in TensorFlow)</strong>:</p>
<p dir="auto">Yes, a colleague of mine trained a tensorflow graph which uses the BlockLSTM Op from <code class="notranslate">tensorflow/contrib/rnn/</code> using the python API.</p>
<p dir="auto">As mentioned before, I added code to the <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/BUILD"><code class="notranslate">tensorflow/BUILD</code></a> to create a library <code class="notranslate">tensorflow_all</code>. This library is used to load the graph externally.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content=" cc_binary(
 	name = &quot;libtensorflow_all.so&quot;,
 	linkshared = 1,
 	linkopts = [&quot;-Wl,--version-script=tensorflow/tf_version_script.lds&quot;],
 	deps = [
 		&quot;//tensorflow/cc:cc_ops&quot;,
 		&quot;//tensorflow/cc:client_session&quot;,
 		&quot;//tensorflow/cc/saved_model:loader&quot;,
 		&quot;//tensorflow/cc/saved_model:tag_constants&quot;,
 		&quot;//tensorflow/core:all_kernels&quot;,
 		&quot;//tensorflow/core:framework_internal&quot;,
 		&quot;//tensorflow/core:tensorflow&quot;,
 		&quot;//tensorflow/contrib:contrib_kernels&quot;,
 		&quot;//tensorflow/contrib:contrib_ops_op_lib&quot;,
 	],
 )"><pre class="notranslate"> <span class="pl-en">cc_binary</span>(
 	<span class="pl-s1">name</span> <span class="pl-c1">=</span> <span class="pl-s">"libtensorflow_all.so"</span>,
 	<span class="pl-s1">linkshared</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span>,
 	<span class="pl-s1">linkopts</span> <span class="pl-c1">=</span> [<span class="pl-s">"-Wl,--version-script=tensorflow/tf_version_script.lds"</span>],
 	<span class="pl-s1">deps</span> <span class="pl-c1">=</span> [
 		<span class="pl-s">"//tensorflow/cc:cc_ops"</span>,
 		<span class="pl-s">"//tensorflow/cc:client_session"</span>,
 		<span class="pl-s">"//tensorflow/cc/saved_model:loader"</span>,
 		<span class="pl-s">"//tensorflow/cc/saved_model:tag_constants"</span>,
 		<span class="pl-s">"//tensorflow/core:all_kernels"</span>,
 		<span class="pl-s">"//tensorflow/core:framework_internal"</span>,
 		<span class="pl-s">"//tensorflow/core:tensorflow"</span>,
 		<span class="pl-s">"//tensorflow/contrib:contrib_kernels"</span>,
 		<span class="pl-s">"//tensorflow/contrib:contrib_ops_op_lib"</span>,
 	],
 )</pre></div>
<p dir="auto">I was hoping that <code class="notranslate">BlockLSTM</code> was included in <code class="notranslate">"//tensorflow/contrib:contrib_ops_op_lib"</code>, but that appears not to be the case.</p>
</li>
<li>
<p dir="auto"><strong>OS Platform and Distribution (e.g., Linux Ubuntu 16.04)</strong>: Ubuntu 16.04.2 LTS</p>
</li>
<li>
<p dir="auto"><strong>TensorFlow installed from (source or binary)</strong>: source</p>
</li>
<li>
<p dir="auto"><strong>TensorFlow version</strong>: Master branch (commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/tensorflow/tensorflow/commit/bb88ec7ecc4dc7ba72548a5115fb86e20b14de5b/hovercard" href="https://github.com/tensorflow/tensorflow/commit/bb88ec7ecc4dc7ba72548a5115fb86e20b14de5b"><tt>bb88ec7</tt></a>)</p>
</li>
<li>
<p dir="auto"><strong>Python version</strong>: 3.5</p>
</li>
<li>
<p dir="auto"><strong>Bazel version (if compiling from source)</strong>: 0.4.5</p>
</li>
<li>
<p dir="auto"><strong>CUDA/cuDNN version</strong>: 5.1</p>
</li>
<li>
<p dir="auto"><strong>GPU model and memory</strong>: GeForce GTX 980, 4GB</p>
</li>
<li>
<p dir="auto"><strong>Exact command to reproduce</strong>: Sorry. Not that easy to reproduce.</p>
</li>
</ul>
<p dir="auto">I've trained the R-FCN model on my own training set. Now, I'd like to convert my frozen inference graph form the *.pb format to the *.tflite format to use it on an android mobile phone.</p>
<p dir="auto">After training, I exported the frozen inference graph with the following command:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="python3 export_inference_graph.py 
--pipeline_config_path=&quot;training/ckpt/rfcn-69/pipeline.config&quot; 
--trained_checkpoint_prefix=&quot;training/ckpt/rfcn-69/model.ckpt-300000&quot; 
--output_directory=&quot;training/ckpt/rfcn-69/&quot;"><pre class="notranslate"><code class="notranslate">python3 export_inference_graph.py 
--pipeline_config_path="training/ckpt/rfcn-69/pipeline.config" 
--trained_checkpoint_prefix="training/ckpt/rfcn-69/model.ckpt-300000" 
--output_directory="training/ckpt/rfcn-69/"
</code></pre></div>
<p dir="auto">Afterwards I run the transform_graph util to quantize the graph. I noticed that it doesn't matter wether I run the transform_graph or not. In the end I'm getting the same error with both of the graphs.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="bazel run tensorflow/tools/graph_transforms/transform_graph -- 
--in_graph=&quot;/git/bda/frozen_graphs/rfcn-69/frozen_inference_graph.pb&quot; 
--out_graph=&quot;/git/bda/frozen_graphs/rfcn-69/quantized_graph_2.pb&quot; 
--inputs=image_tensor 
--outputs=&quot;num_detections,detection_boxes,detection_scores,detection_classes&quot; 
--transforms='fold_old_batch_norms quantize_weights strip_unused_nodes sort_by_execution_order obfuscate_names merge_duplicate_nodes'"><pre class="notranslate"><code class="notranslate">bazel run tensorflow/tools/graph_transforms/transform_graph -- 
--in_graph="/git/bda/frozen_graphs/rfcn-69/frozen_inference_graph.pb" 
--out_graph="/git/bda/frozen_graphs/rfcn-69/quantized_graph_2.pb" 
--inputs=image_tensor 
--outputs="num_detections,detection_boxes,detection_scores,detection_classes" 
--transforms='fold_old_batch_norms quantize_weights strip_unused_nodes sort_by_execution_order obfuscate_names merge_duplicate_nodes'
</code></pre></div>
<p dir="auto">Finally, I try to convert the quantized graph to an tflite graph with the toco util.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="bazel run --config=opt  tensorflow/contrib/lite/toco:toco -- 
--input_file=/git/bda/frozen_graphs/rfcn-69/quantized_graph_2.pb 
--output_file=/git/bda/frozen_graphs/out.tflite --inference_type=FLOAT 
--input_shape=1,600,1024,3 
--input_array=image_tensor 
--output_arrays=num_detections,detection_boxes,detection_scores,detection_classes"><pre class="notranslate"><code class="notranslate">bazel run --config=opt  tensorflow/contrib/lite/toco:toco -- 
--input_file=/git/bda/frozen_graphs/rfcn-69/quantized_graph_2.pb 
--output_file=/git/bda/frozen_graphs/out.tflite --inference_type=FLOAT 
--input_shape=1,600,1024,3 
--input_array=image_tensor 
--output_arrays=num_detections,detection_boxes,detection_scores,detection_classes
</code></pre></div>
<p dir="auto">But, the operation fails with the following error.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="2018-04-11 13:19:58.364591: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: TensorArrayV3
2018-04-11 13:19:58.364606: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: TensorArrayV3
2018-04-11 13:19:58.364656: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: TensorArrayReadV3
2018-04-11 13:19:58.364753: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: Where
2018-04-11 13:19:58.364851: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: Where
2018-04-11 13:19:58.364969: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: Dequantize
2018-04-11 13:19:58.365001: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: TensorArraySizeV3
2018-04-11 13:19:58.365022: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: Dequantize
2018-04-11 13:19:58.366115: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: Where
2018-04-11 13:20:00.620101: F tensorflow/contrib/lite/toco/tooling_util.cc:821] Check failed: d &gt;= 1 (0 vs. 1)"><pre class="notranslate"><code class="notranslate">2018-04-11 13:19:58.364591: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: TensorArrayV3
2018-04-11 13:19:58.364606: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: TensorArrayV3
2018-04-11 13:19:58.364656: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: TensorArrayReadV3
2018-04-11 13:19:58.364753: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: Where
2018-04-11 13:19:58.364851: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: Where
2018-04-11 13:19:58.364969: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: Dequantize
2018-04-11 13:19:58.365001: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: TensorArraySizeV3
2018-04-11 13:19:58.365022: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: Dequantize
2018-04-11 13:19:58.366115: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1253] Converting unsupported operation: Where
2018-04-11 13:20:00.620101: F tensorflow/contrib/lite/toco/tooling_util.cc:821] Check failed: d &gt;= 1 (0 vs. 1)
</code></pre></div>
<p dir="auto">I've got no clue what could be the problem. Any help would be highly appreciated.</p>
<p dir="auto">Thanks in advance.</p>