diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2017-06-27 16:33:00 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-06-27 16:37:09 -0700 |
commit | 50b999a8336d19400ab75aea66fe46eca2f5fe0b (patch) | |
tree | 7cba4f4af6b131c253b65ff9f2923e851184668c /tensorflow/contrib/android | |
parent | d6d58a3a1785785679af56c0f8f131e7312b8226 (diff) |
Merge changes from github.
PiperOrigin-RevId: 160344052
Diffstat (limited to 'tensorflow/contrib/android')
-rw-r--r-- | tensorflow/contrib/android/java/org/tensorflow/contrib/android/TensorFlowInferenceInterface.java | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/tensorflow/contrib/android/java/org/tensorflow/contrib/android/TensorFlowInferenceInterface.java b/tensorflow/contrib/android/java/org/tensorflow/contrib/android/TensorFlowInferenceInterface.java index 1f180429b2..b1d18d2faf 100644 --- a/tensorflow/contrib/android/java/org/tensorflow/contrib/android/TensorFlowInferenceInterface.java +++ b/tensorflow/contrib/android/java/org/tensorflow/contrib/android/TensorFlowInferenceInterface.java @@ -17,6 +17,7 @@ package org.tensorflow.contrib.android; import android.content.res.AssetManager; import android.os.Trace; +import android.os.Build.VERSION; import android.text.TextUtils; import android.util.Log; import java.io.FileInputStream; @@ -370,9 +371,11 @@ public class TensorFlowInferenceInterface { private void loadGraph(InputStream is, Graph g) throws IOException { final long startMs = System.currentTimeMillis(); - Trace.beginSection("initializeTensorFlow"); + if (VERSION.SDK_INT >= 18) { + Trace.beginSection("initializeTensorFlow"); + Trace.beginSection("readGraphDef"); + } - Trace.beginSection("readGraphDef"); // TODO(ashankar): Can we somehow mmap the contents instead of copying them? byte[] graphDef = new byte[is.available()]; final int numBytesRead = is.read(graphDef); @@ -383,17 +386,22 @@ public class TensorFlowInferenceInterface { + " of the graph, expected to read " + graphDef.length); } - Trace.endSection(); - Trace.beginSection("importGraphDef"); + if (VERSION.SDK_INT >= 18) { + Trace.endSection(); // readGraphDef. + Trace.beginSection("importGraphDef"); + } + try { g.importGraphDef(graphDef); } catch (IllegalArgumentException e) { throw new IOException("Not a valid TensorFlow Graph serialization: " + e.getMessage()); } - Trace.endSection(); - Trace.endSection(); // initializeTensorFlow. + if (VERSION.SDK_INT >= 18) { + Trace.endSection(); // importGraphDef. + Trace.endSection(); // initializeTensorFlow. + } final long endMs = System.currentTimeMillis(); Log.i( |