<p dir="auto">i predict image with python api<br>
only need 15ms,<br>
but with the same model,java api need 500+ms</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):</li>
</ul>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="//create session, this pb come from python
        ConfigProto config=ConfigProto.newBuilder()
                .setAllowSoftPlacement(true)
                .setLogDevicePlacement(false)
                .clearLogDevicePlacement()
                //.setGpuOptions(GPUOptions.newBuilder().setAllowGrowth(true))
                //.setInterOpParallelismThreads(1)
                .build();
        sess=new Session( graph, config.toByteArray() );"><pre class="notranslate"><span class="pl-c">//create session, this pb come from python</span>
        <span class="pl-smi">ConfigProto</span> <span class="pl-s1">config</span>=<span class="pl-smi">ConfigProto</span>.<span class="pl-en">newBuilder</span>()
                .<span class="pl-en">setAllowSoftPlacement</span>(<span class="pl-c1">true</span>)
                .<span class="pl-en">setLogDevicePlacement</span>(<span class="pl-c1">false</span>)
                .<span class="pl-en">clearLogDevicePlacement</span>()
                <span class="pl-c">//.setGpuOptions(GPUOptions.newBuilder().setAllowGrowth(true))</span>
                <span class="pl-c">//.setInterOpParallelismThreads(1)</span>
                .<span class="pl-en">build</span>();
        <span class="pl-s1">sess</span>=<span class="pl-k">new</span> <span class="pl-smi">Session</span>( <span class="pl-s1">graph</span>, <span class="pl-s1">config</span>.<span class="pl-en">toByteArray</span>() );</pre></div>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="        AnjosLog log=new AnjosLog();
        log.begin();
        log.begin2Series(&quot;create data&quot;);
        float[][][] X=new float[1][this.audio_len][this.audio_feat_len];
        X[0]=data;
        log.stop2Series();
        log.begin2Series(&quot;create tensor&quot;);
        Tensor x= Tensor.create(X);
        log.stop2Series();
        log.begin2Series(&quot;use model&quot;);
        Tensor  y = sess.runner().feed(input_var, x).fetch(label_var).run().get(0);
        log.stop2Series();
        log.begin2Series(&quot;take result&quot;);
        float[][][] result = new float[ (int)y.shape()[0] ][ (int)y.shape()[1] ][ (int)y.shape()[2] ];
        y.copyTo(result);
        log.stop2Series();
        log.stop();"><pre class="notranslate">        <span class="pl-smi">AnjosLog</span> <span class="pl-s1">log</span>=<span class="pl-k">new</span> <span class="pl-smi">AnjosLog</span>();
        <span class="pl-s1">log</span>.<span class="pl-en">begin</span>();
        <span class="pl-s1">log</span>.<span class="pl-en">begin2Series</span>(<span class="pl-s">"create data"</span>);
        <span class="pl-smi">float</span>[][][] <span class="pl-s1">X</span>=<span class="pl-k">new</span> <span class="pl-smi">float</span>[<span class="pl-c1">1</span>][<span class="pl-smi">this</span>.<span class="pl-s1">audio_len</span>][<span class="pl-smi">this</span>.<span class="pl-s1">audio_feat_len</span>];
        <span class="pl-s1">X</span>[<span class="pl-c1">0</span>]=<span class="pl-s1">data</span>;
        <span class="pl-s1">log</span>.<span class="pl-en">stop2Series</span>();
        <span class="pl-s1">log</span>.<span class="pl-en">begin2Series</span>(<span class="pl-s">"create tensor"</span>);
        <span class="pl-smi">Tensor</span> <span class="pl-s1">x</span>= <span class="pl-smi">Tensor</span>.<span class="pl-en">create</span>(<span class="pl-s1">X</span>);
        <span class="pl-s1">log</span>.<span class="pl-en">stop2Series</span>();
        <span class="pl-s1">log</span>.<span class="pl-en">begin2Series</span>(<span class="pl-s">"use model"</span>);
        <span class="pl-smi">Tensor</span>  <span class="pl-s1">y</span> = <span class="pl-s1">sess</span>.<span class="pl-en">runner</span>().<span class="pl-en">feed</span>(<span class="pl-s1">input_var</span>, <span class="pl-s1">x</span>).<span class="pl-en">fetch</span>(<span class="pl-s1">label_var</span>).<span class="pl-en">run</span>().<span class="pl-en">get</span>(<span class="pl-c1">0</span>);
        <span class="pl-s1">log</span>.<span class="pl-en">stop2Series</span>();
        <span class="pl-s1">log</span>.<span class="pl-en">begin2Series</span>(<span class="pl-s">"take result"</span>);
        <span class="pl-smi">float</span>[][][] <span class="pl-s1">result</span> = <span class="pl-k">new</span> <span class="pl-smi">float</span>[ (<span class="pl-smi">int</span>)<span class="pl-s1">y</span>.<span class="pl-en">shape</span>()[<span class="pl-c1">0</span>] ][ (<span class="pl-smi">int</span>)<span class="pl-s1">y</span>.<span class="pl-en">shape</span>()[<span class="pl-c1">1</span>] ][ (<span class="pl-smi">int</span>)<span class="pl-s1">y</span>.<span class="pl-en">shape</span>()[<span class="pl-c1">2</span>] ];
        <span class="pl-s1">y</span>.<span class="pl-en">copyTo</span>(<span class="pl-s1">result</span>);
        <span class="pl-s1">log</span>.<span class="pl-en">stop2Series</span>();
        <span class="pl-s1">log</span>.<span class="pl-en">stop</span>();</pre></div>
<ul dir="auto">
<li>OS Platform and Distribution (e.g., Linux Ubuntu 16.04): win7 CPU</li>
<li>Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:</li>
<li>TensorFlow installed from (source or binary):</li>
<li>TensorFlow version (use command below):1.8.0 java</li>
<li>Python version: 3.5.6</li>
<li>Bazel version (if compiling from source): none</li>
<li>GCC/Compiler version (if compiling from source): none</li>
<li>CUDA/cuDNN version: none</li>
<li>GPU model and memory: none</li>
</ul>
<p dir="auto">You can collect some of this information using our environment capture <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<br>
python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"</p>
<p dir="auto"><strong>Describe the current behavior</strong></p>
<p dir="auto">I use python3.5 predict the same one sample speed:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="series start　　　　　　　　　　　　　　　　 2019-04-20 13:06:18
series end　　　　　　　　　　　　　　　　 2019-04-20 13:06:18
total time　　　　　　　　　　　　　　　　 0.24s       0.00min      2019-04-20 13:06:18"><pre class="notranslate"><code class="notranslate">series start　　　　　　　　　　　　　　　　 2019-04-20 13:06:18
series end　　　　　　　　　　　　　　　　 2019-04-20 13:06:18
total time　　　　　　　　　　　　　　　　 0.24s       0.00min      2019-04-20 13:06:18
</code></pre></div>
<p dir="auto">I use java1.8 predict the same one sample speed:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="start time　　　　　　　　　　　　　　　　2019-04-20 12:57:43 924
 series start　　　　　　　　　　　　　　　　 create data 2019-04-20 12:57:43 925
 series end　　　　　　　　　　　　　　　　         0.00s         0.00min
 series start　　　　　　　　　　　　　　　　 create tensor 2019-04-20 12:57:43 927
 series end　　　　　　　　　　　　　　　　         0.09s         0.00min
 series start　　　　　　　　　　　　　　　　 use model 2019-04-20 12:57:44 015
  series end　　　　　　　　　　　　　　　　         0.69s         0.01min
 series start　　　　　　　　　　　　　　　　 take result 2019-04-20 12:57:44 710
  series end　　　　　　　　　　　　　　　　         0.03s         0.00min
 end time　　　　　　　　　　　　　　　　 2019-04-20 12:57:44 738
 total time　　　　　　　　　　　　　　　　         0.81s         0.01min"><pre class="notranslate"><code class="notranslate">start time　　　　　　　　　　　　　　　　2019-04-20 12:57:43 924
 series start　　　　　　　　　　　　　　　　 create data 2019-04-20 12:57:43 925
 series end　　　　　　　　　　　　　　　　         0.00s         0.00min
 series start　　　　　　　　　　　　　　　　 create tensor 2019-04-20 12:57:43 927
 series end　　　　　　　　　　　　　　　　         0.09s         0.00min
 series start　　　　　　　　　　　　　　　　 use model 2019-04-20 12:57:44 015
  series end　　　　　　　　　　　　　　　　         0.69s         0.01min
 series start　　　　　　　　　　　　　　　　 take result 2019-04-20 12:57:44 710
  series end　　　　　　　　　　　　　　　　         0.03s         0.00min
 end time　　　　　　　　　　　　　　　　 2019-04-20 12:57:44 738
 total time　　　　　　　　　　　　　　　　         0.81s         0.01min
</code></pre></div>
<p dir="auto"><strong>Describe the expected behavior</strong><br>
<strong>I understand that java should be faster than Python. But not like this.</strong></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>