aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-03-01 14:35:44 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-03-01 14:39:39 -0800
commita8bcf9c5b2ea7c88c3034d1b4c5d62c209a6b431 (patch)
tree39cb7a59501436bbaac269dcfeb749f5eb80e4af
parent759da7754a708f1f64e4b4b2e17cd4d8c42e3ed3 (diff)
Expose native inference latency via TFlite interpreter.
PiperOrigin-RevId: 187535695
-rw-r--r--tensorflow/contrib/lite/java/src/main/java/org/tensorflow/lite/Interpreter.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/tensorflow/contrib/lite/java/src/main/java/org/tensorflow/lite/Interpreter.java b/tensorflow/contrib/lite/java/src/main/java/org/tensorflow/lite/Interpreter.java
index 9286814b74..b071cda5df 100644
--- a/tensorflow/contrib/lite/java/src/main/java/org/tensorflow/lite/Interpreter.java
+++ b/tensorflow/contrib/lite/java/src/main/java/org/tensorflow/lite/Interpreter.java
@@ -167,6 +167,19 @@ public final class Interpreter implements AutoCloseable {
return wrapper.getOutputIndex(opName);
}
+
+ /**
+ * Returns native inference timing.
+ * <p>IllegalArgumentException will be thrown if the model is not initialized by the
+ * {@link Interpreter}.
+ */
+ public Long getLastNativeInferenceDurationNanoseconds() {
+ if (wrapper == null) {
+ throw new IllegalStateException("The interpreter has already been closed.");
+ }
+ return wrapper.getLastNativeInferenceDurationNanoseconds();
+ }
+
/** Release resources associated with the {@code Interpreter}. */
@Override
public void close() {