Skip to content

Commit b0c5182

Browse files
Change TF Lite Tasks library to use the TF Lite stable API
rather than depending on experimental APIs. This required also updating the version of TF used by the TF Support Library. PiperOrigin-RevId: 399708233
1 parent 1523b16 commit b0c5182

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

WORKSPACE

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ http_archive(
5151
],
5252
)
5353

54-
# TF on 2021-08-02.
55-
TENSORFLOW_COMMIT = "b1b4548b3e37c245d7de671aae5b827abde9ba29"
56-
TENSORFLOW_SHA256 = "5d941518f93eb0fbfb56312f6f32b096ac769068504ff103df582304c86b3a17"
54+
# TF on 2021-09-29.
55+
TENSORFLOW_COMMIT = "a221f72e69fea7a46977e35961e5cdb1e51fec36"
56+
TENSORFLOW_SHA256 = "d0e57bcf455df772cfdf65fdf59a94dfef7547c6aafd50b382dab3a182b0c5b3"
5757
http_archive(
5858
name = "org_tensorflow",
5959
sha256 = TENSORFLOW_SHA256,

tensorflow_lite_support/java/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ filegroup(
2424
# Lite runtime (tensorflow/lite/java:tensorflowlite). If you don't want to
2525
# introduce the native library into dependencies, use
2626
# "tensorflowlite_support_java" instead, which depends on
27-
# tensorflow/lite/java:tensorflowlite_java.
27+
# tensorflow/lite/java:tensorflowlite_java_stable.
2828
android_library(
2929
name = "tensorflowlite_support",
3030
srcs = [],
@@ -50,7 +50,7 @@ android_library(
5050
"@maven//:androidx_annotation_annotation",
5151
"@maven//:com_google_android_odml_image",
5252
"@org_checkerframework_qual",
53-
"@org_tensorflow//tensorflow/lite/java:tensorflowlite_java", # TODO(b/198734357): Use api when TF dep catches up.
53+
"@org_tensorflow//tensorflow/lite/java:tensorflowlite_java_stable", # TODO(b/198734357): Use api when TF dep catches up.
5454
],
5555
# LINT.ThenChange(<INTERNAL>/release/build_support_api_pom.sh:dep)
5656
)

tensorflow_lite_support/java/src/java/org/tensorflow/lite/support/model/Model.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
import java.util.Map;
2222
import org.checkerframework.checker.nullness.qual.NonNull;
2323
import org.checkerframework.checker.nullness.qual.Nullable;
24-
import org.tensorflow.lite.Interpreter;
24+
import org.tensorflow.lite.InterpreterApi;
25+
import org.tensorflow.lite.InterpreterFactory;
2526
import org.tensorflow.lite.Tensor;
2627
import org.tensorflow.lite.support.common.FileUtil;
2728
import org.tensorflow.lite.support.common.SupportPreconditions;
@@ -83,7 +84,7 @@ private Options(Builder builder) {
8384
}
8485

8586
/** An instance of the driver class to run model inference with Tensorflow Lite. */
86-
private final Interpreter interpreter;
87+
private final InterpreterApi interpreter;
8788

8889
/** Path to tflite model file in asset folder. */
8990
private final String modelPath;
@@ -186,7 +187,7 @@ public static Model createModel(
186187
*/
187188
public static Model createModel(
188189
@NonNull MappedByteBuffer byteModel, @NonNull String modelPath, @NonNull Options options) {
189-
Interpreter.Options interpreterOptions = new Interpreter.Options();
190+
InterpreterApi.Options interpreterOptions = new InterpreterApi.Options();
190191
GpuDelegateProxy gpuDelegateProxy = null;
191192
switch (options.device) {
192193
case NNAPI:
@@ -203,7 +204,7 @@ public static Model createModel(
203204
break;
204205
}
205206
interpreterOptions.setNumThreads(options.numThreads);
206-
Interpreter interpreter = new Interpreter(byteModel, interpreterOptions);
207+
InterpreterApi interpreter = new InterpreterFactory().create(byteModel, interpreterOptions);
207208
return new Model(modelPath, byteModel, interpreter, gpuDelegateProxy);
208209
}
209210

@@ -275,7 +276,7 @@ public void close() {
275276
private Model(
276277
@NonNull String modelPath,
277278
@NonNull MappedByteBuffer byteModel,
278-
@NonNull Interpreter interpreter,
279+
@NonNull InterpreterApi interpreter,
279280
@Nullable GpuDelegateProxy gpuDelegateProxy) {
280281
this.modelPath = modelPath;
281282
this.byteModel = byteModel;

tensorflow_lite_support/java/src/java/org/tensorflow/lite/task/audio/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ android_library(
2525
"//tensorflow_lite_support/java/src/java/org/tensorflow/lite/task/core:base_task_api",
2626
"//tensorflow_lite_support/java/src/native/task/audio:task_audio_native",
2727
"@com_google_auto_value",
28-
"@org_tensorflow//tensorflow/lite/java:tensorflowlite_java",
28+
"@org_tensorflow//tensorflow/lite/java:tensorflowlite_java_stable",
2929
],
3030
# LINT.ThenChange(<INTERNAL>/release/build_task_pom.sh:dep)
3131
)

tensorflow_lite_support/java/src/java/org/tensorflow/lite/task/audio/classifier/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ android_library(
3232
"//tensorflow_lite_support/java:tensorflowlite_support_java",
3333
"//tensorflow_lite_support/java/src/java/org/tensorflow/lite/task/core:base_task_api",
3434
"@com_google_auto_value",
35-
"@org_tensorflow//tensorflow/lite/java:tensorflowlite_java",
35+
"@org_tensorflow//tensorflow/lite/java:tensorflowlite_java_stable",
3636
],
3737
)

tensorflow_lite_support/java/src/java/org/tensorflow/lite/task/vision/detector/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ android_library(
4343
"//tensorflow_lite_support/java/src/java/org/tensorflow/lite/task/core:base_task_api",
4444
"@com_google_auto_value",
4545
"@maven//:com_google_android_odml_image",
46-
"@org_tensorflow//tensorflow/lite/java:tensorflowlite_java",
46+
"@org_tensorflow//tensorflow/lite/java:tensorflowlite_java_stable",
4747
],
4848
)
4949

0 commit comments

Comments
 (0)