<p dir="auto"><em>Please make sure that this is a bug. As per our <a href="https://github.com/tensorflow/tensorflow/blob/master/ISSUES.md">GitHub Policy</a>, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template</em></p>
<p dir="auto"><strong>System information</strong></p>
<ul dir="auto">
<li>Have I written custom code (as opposed to using a stock example script provided in TensorFlow): YES</li>
<li>OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 16.04</li>
<li>Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: Internal Android 8.1 board</li>
<li>TensorFlow installed from (source or binary): source</li>
<li>TensorFlow version (use command below): 1.13.1</li>
<li>Python version: 2.7</li>
<li>Bazel version (if compiling from source): 0.22.0</li>
<li>GCC/Compiler version (if compiling from source):</li>
<li>CUDA/cuDNN version:</li>
<li>GPU model and memory: Mali-T864 GPU</li>
</ul>
<p dir="auto">You can collect some of this information using our environment capture<br>
<a href="https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh">script</a><br>
You can also obtain the TensorFlow version with: 1. TF 1.0: <code class="notranslate">python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"</code> 2. TF 2.0: <code class="notranslate">python -c "import tensorflow as tf; print(tf.version.GIT_VERSION, tf.version.VERSION)"</code></p>
<p dir="auto"><strong>Describe the current behavior</strong></p>
<p dir="auto">I wrote a simple demo using tflite opengles delegate to run deeplab models from <a href="https://github.com/tensorflow/models/blob/master/research/deeplab/g3doc/model_zoo.md">model zoo</a>.</p>
<p dir="auto">I have tried your hosted model <a href="https://storage.googleapis.com/download.tensorflow.org/models/tflite/gpu/deeplabv3_257_mv_gpu.tflite" rel="nofollow">deeplabv3_mv2_257_gpu.tflite</a>, It works perfect on my device on CPU and Opengles delegate.</p>
<p dir="auto">However, when I tried the <a href="http://download.tensorflow.org/models/deeplabv3_xception_ade20k_train_2018_05_29.tar.gz" rel="nofollow">deeplab mode with xception65 </a>, The tflite perform differently on CPU and Opengles delegate. My input layer is sub_7, output layer is ResizeBilinear_3.</p>
<p dir="auto">Here is my result:<br>
test image:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/43549654/59234008-b852b600-8b9f-11e9-8ce2-703664cadcf4.png"><img src="https://user-images.githubusercontent.com/43549654/59234008-b852b600-8b9f-11e9-8ce2-703664cadcf4.png" alt="two_human" style="max-width: 100%;"></a></p>
<p dir="auto">result from CPU (correct):<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/43549654/59234023-d02a3a00-8b9f-11e9-98f0-f17874fca671.png"><img src="https://user-images.githubusercontent.com/43549654/59234023-d02a3a00-8b9f-11e9-98f0-f17874fca671.png" alt="hp_nonflatten_cpu" style="max-width: 100%;"></a></p>
<p dir="auto">result from opengles delegate:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/43549654/59234034-dc15fc00-8b9f-11e9-9982-008d9f5064fa.png"><img src="https://user-images.githubusercontent.com/43549654/59234034-dc15fc00-8b9f-11e9-9982-008d9f5064fa.png" alt="hp_flatten2_gpu" style="max-width: 100%;"></a></p>
<p dir="auto">I believed that this issue is related to the operations(BATCH_TO_SPACE_ND, SPACE_TO_BATCH_ND)  that opengles not supporting thus fallback to CPU. Another <a href="https://github.com/tensorflow/tensorflow/issues/29509" data-hovercard-type="issue" data-hovercard-url="/tensorflow/tensorflow/issues/29509/hovercard">issue</a> of mine described more detail.</p>
<p dir="auto">Flatten the unsupported ops using graph_transforms also failed. It gives me the same inaccurate result or shows message like:<br>
<code class="notranslate">INFO: Initialized TensorFlow Lite runtime. INFO: Created TensorFlow Lite delegate for GPU. ERROR: TfLiteGpuDelegate Prepare: Program is not properly linked: L0005 The number of compute uniform components (1261) is greater than the maximum number allowed (1024). ERROR: Node number 199 (TfLiteGpuDelegate) failed to prepare. ERROR: Node number 199 (TfLiteGpuDelegate) failed to prepare. </code></p>
<p dir="auto"><strong>Describe the expected behavior</strong><br>
all models work as good as your hosted model</p>
<p dir="auto"><strong>Code to reproduce the issue</strong><br>
Provide a reproducible test case that is the bare minimum necessary to generate the problem.</p>
<p dir="auto"><strong>Other info / logs</strong><br>
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.</p>
<p dir="auto"><em>Please make sure that this is a bug. As per our <a href="https://github.com/tensorflow/tensorflow/blob/master/ISSUES.md">GitHub Policy</a>, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template</em></p>
<p dir="auto"><strong>System information</strong></p>
<ul dir="auto">
<li>Have I written custom code (as opposed to using a stock example script provided in TensorFlow):NO</li>
<li>OS Platform and Distribution (e.g., Linux Ubuntu 16.04):Linux Ubuntu 16.04</li>
<li>Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:NA</li>
<li>TensorFlow installed from (source or binary):source</li>
<li>TensorFlow version (use command below):1.13.1</li>
<li>Python version: 2.7</li>
<li>Bazel version (if compiling from source): 0.22.0</li>
<li>GCC/Compiler version (if compiling from source):</li>
<li>CUDA/cuDNN version:</li>
<li>GPU model and memory:</li>
</ul>
<p dir="auto">You can collect some of this information using our environment capture<br>
<a href="https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh">script</a><br>
You can also obtain the TensorFlow version with: 1. TF 1.0: <code class="notranslate">python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"</code> 2. TF 2.0: <code class="notranslate">python -c "import tensorflow as tf; print(tf.version.GIT_VERSION, tf.version.VERSION)"</code></p>
<p dir="auto"><strong>Describe the current behavior</strong><br>
I'm trying to train my own deeplab model using this <a href="https://github.com/tensorflow/models/tree/master/research/deeplab">code</a> and convert it to tflite.<br>
My target is to get a model similar to <a href="https://storage.googleapis.com/download.tensorflow.org/models/tflite/gpu/deeplabv3_257_mv_gpu.tflite" rel="nofollow">this</a></p>
<p dir="auto">However, the model is obtained contains operations like:<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/43549654/59057361-135a7500-884f-11e9-9546-e2bd20e69c95.png"><img src="https://user-images.githubusercontent.com/43549654/59057361-135a7500-884f-11e9-9546-e2bd20e69c95.png" alt="image" style="max-width: 100%;"></a><br>
SpaceToBatchND and BatchToSpaceND operations are not supported by tflite + opengles backend, they reduced the model's performance on my device.</p>
<p dir="auto">In your hosted deeplab model, those three ops are replaced by DEPTHWISE_CONV_2D v2, which has options to set dilation factor. This would be the best solution for me but I'm not sure how to convert SpaceToBatchND-Conv2D-BatchToSpaceND into a singe DEPTHWISE_CONV_2D v2(dilation=2).</p>
<p dir="auto">FYI, I have tried the graph_transforms tool under tensorflow/tools/graph_transforms to flatten the atrous conv. It upsampled the kernels instead of Space_To_Batch + Batch_To_Space. But this transform leads to much more computations that I cannot afford.</p>
<p dir="auto"><strong>Describe the expected behavior</strong></p>
<p dir="auto">convert SpaceToBatchND-Conv2D-BatchToSpaceND into a singe DEPTHWISE_CONV_2D v2(dilation=2)</p>
<p dir="auto"><strong>Code to reproduce the issue</strong><br>
Provide a reproducible test case that is the bare minimum necessary to generate the problem.</p>
<p dir="auto">You can try any model under deeplab model zoo for example <a href="url">http://download.tensorflow.org/models/deeplabv3_mnv2_ade20k_train_2018_12_03.tar.gz</a></p>
<p dir="auto"><strong>Other info / logs</strong><br>
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.</p>