<p dir="auto">I am getting the following error when running the XLA service unit tests:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="duplicate symbol __ZN3xla7PrintToEPKNS_14HloInstructionEPNSt3__113basic_ostreamIcNS3_11char_traitsIcEEEE in:
    bazel-out/local-opt/bin/tensorflow/compiler/xla/service/_objs/user_computation_test/tensorflow/compiler/xla/service/user_computation_test.o
    bazel-out/local-opt/bin/tensorflow/compiler/xla/service/libhlo_matchers.a(hlo_matchers.o)"><pre class="notranslate"><code class="notranslate">duplicate symbol __ZN3xla7PrintToEPKNS_14HloInstructionEPNSt3__113basic_ostreamIcNS3_11char_traitsIcEEEE in:
    bazel-out/local-opt/bin/tensorflow/compiler/xla/service/_objs/user_computation_test/tensorflow/compiler/xla/service/user_computation_test.o
    bazel-out/local-opt/bin/tensorflow/compiler/xla/service/libhlo_matchers.a(hlo_matchers.o)
</code></pre></div>
<p dir="auto">Command line for running the tests is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="bazel test --test_env TF_CPP_MIN_VLOG_LEVEL=2 --test_size_filters=small,medium,large --config opt --verbose_failures --test_output=all --nocache_test_results tensorflow/compiler/xla/service/..."><pre class="notranslate"><code class="notranslate">bazel test --test_env TF_CPP_MIN_VLOG_LEVEL=2 --test_size_filters=small,medium,large --config opt --verbose_failures --test_output=all --nocache_test_results tensorflow/compiler/xla/service/...
</code></pre></div>
<p dir="auto">This is OS/X, head of the master branch, using bazel <code class="notranslate">0.5.4-homebrew</code>.</p>
<p dir="auto">Is this a known issue at the moment?</p>
<h3 dir="auto">System information</h3>
<ul dir="auto">
<li><strong>Have I written custom code (as opposed to using a stock example script provided in TensorFlow)</strong>:<br>
Only edited <code class="notranslate">ClassifierActivity.java</code> to suit a custom model</li>
<li><strong>OS Platform and Distribution (e.g., Linux Ubuntu 16.04)</strong>:<br>
Android smartphone / host machine: Ubuntu 16.04 LTS</li>
<li><strong>TensorFlow installed from (source or binary)</strong>: Source</li>
<li><strong>TensorFlow version (use command below)</strong>: 1.1</li>
<li><strong>Bazel version (if compiling from source)</strong>: 0.4.5</li>
<li><strong>CUDA/cuDNN version</strong>: 8.0/5.1</li>
<li><strong>GPU model and memory</strong>: GTX 860M</li>
</ul>
<h3 dir="auto">Describe the problem</h3>
<p dir="auto">I am currently following the guide in: <a href="http://nilhcem.com/android/custom-tensorflow-classifier" rel="nofollow">http://nilhcem.com/android/custom-tensorflow-classifier</a></p>
<p dir="auto">to train a custom classifier. However, I am using my own frozen graph that I obtained from my own training. What I noticed was when I used the quantized graph obtained through the <code class="notranslate">graph_transform</code> method, the app simply crashes without even running. In the guide, it is recommended to run this command on the inference graph:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="bazel-bin/tensorflow/python/tools/optimize_for_inference \
  --input=/tf_files/retrained_graph.pb \
  --output=/tf_files/retrained_graph_optimized.pb \
  --input_names=Mul \
  --output_names=final_result"><pre class="notranslate"><code class="notranslate">bazel-bin/tensorflow/python/tools/optimize_for_inference \
  --input=/tf_files/retrained_graph.pb \
  --output=/tf_files/retrained_graph_optimized.pb \
  --input_names=Mul \
  --output_names=final_result
</code></pre></div>
<p dir="auto">While I think it may be in conflict with the quantized graph transformations, I ran this command to test, and the app did crash. Here are the observations for all 4 permutations I tested:</p>
<ol dir="auto">
<li>quantization + optimize_for_inference = <strong>app crash</strong></li>
<li>quantization only = <strong>app crash</strong></li>
<li>optimize_for_inference on frozen graph = <strong>app works</strong></li>
<li>frozen_graph only = <strong>app works</strong></li>
</ol>
<p dir="auto">So my conclusion is the quantization operations within the quantized graph caused the app to fail.</p>
<p dir="auto">Here is the quantization command I ran:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/home/kwotsin/tensorflow-android/tensorflow/bazel-bin/tensorflow/tools/graph_transforms/transform_graph \
--in_graph=./frozen_model_mobilenet.pb \
--out_graph=./quantized_model_mobilenet.pb \
--inputs='Placeholder_only' \
--outputs='MobileNet/Predictions/Softmax' \
--transforms='
  add_default_attributes
  strip_unused_nodes(type=float, shape=&quot;1,299,299,3&quot;)
  remove_nodes(op=Identity, op=CheckNumerics)
  fold_constants(ignore_errors=true)
  fold_batch_norms
  fold_old_batch_norms
  quantize_weights
  quantize_nodes
  strip_unused_nodes
  sort_by_execution_order'"><pre class="notranslate"><code class="notranslate">/home/kwotsin/tensorflow-android/tensorflow/bazel-bin/tensorflow/tools/graph_transforms/transform_graph \
--in_graph=./frozen_model_mobilenet.pb \
--out_graph=./quantized_model_mobilenet.pb \
--inputs='Placeholder_only' \
--outputs='MobileNet/Predictions/Softmax' \
--transforms='
  add_default_attributes
  strip_unused_nodes(type=float, shape="1,299,299,3")
  remove_nodes(op=Identity, op=CheckNumerics)
  fold_constants(ignore_errors=true)
  fold_batch_norms
  fold_old_batch_norms
  quantize_weights
  quantize_nodes
  strip_unused_nodes
  sort_by_execution_order'
</code></pre></div>
<p dir="auto">And the java file I edited to build my APK:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  private static final int INPUT_SIZE = 224;
  private static final int IMAGE_MEAN = 128;
  private static final float IMAGE_STD = 128;
  private static final String INPUT_NAME = &quot;Placeholder_only&quot;;
  private static final String OUTPUT_NAME = &quot;MobileNet/Predictions/Softmax&quot;;

  private static final String MODEL_FILE = &quot;file:///android_asset/quantized_model_mobilenet.pb&quot;;
  private static final String LABEL_FILE =
      &quot;file:///android_asset/mobilenet_labels.txt&quot;;"><pre class="notranslate"><code class="notranslate">  private static final int INPUT_SIZE = 224;
  private static final int IMAGE_MEAN = 128;
  private static final float IMAGE_STD = 128;
  private static final String INPUT_NAME = "Placeholder_only";
  private static final String OUTPUT_NAME = "MobileNet/Predictions/Softmax";

  private static final String MODEL_FILE = "file:///android_asset/quantized_model_mobilenet.pb";
  private static final String LABEL_FILE =
      "file:///android_asset/mobilenet_labels.txt";
</code></pre></div>
<p dir="auto">Other than these edit, every other file is the same. I then imported this project in Android Studio, and ran the <code class="notranslate">build apk</code> option located on the top toolbar of Android Studio.</p>
<p dir="auto">So far, existing tutorials I've seen (e.g. those from Pete Warden) use the <code class="notranslate">quantize_graph</code> method to run on mobile devices. Is <code class="notranslate">graph_transform</code> compatible for quantizing models for mobile devices yet?</p>