Skip to content

Commit

Permalink
Add random ops to opt guide tflite resolver
Browse files Browse the repository at this point in the history
(cherry picked from commit 053be58)

Bug: b/288504472
Change-Id: I35cb2d6d49481638aa3699495898180f80676593
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4639176
Reviewed-by: Robert Ogden <robertogden@chromium.org>
Commit-Queue: Sophie Chang <sophiechang@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1161590}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4678588
Commit-Queue: Michael Crouse <mcrouse@chromium.org>
Reviewed-by: Michael Crouse <mcrouse@chromium.org>
Auto-Submit: Sophie Chang <sophiechang@chromium.org>
Cr-Commit-Position: refs/branch-heads/5845@{#449}
Cr-Branched-From: 5a5dff6-refs/heads/main@{#1160321}
  • Loading branch information
Sophie Chang authored and Chromium LUCI CQ committed Jul 12, 2023
1 parent 6306c24 commit c95c2f0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/optimization_guide/core/prediction_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ void PredictionManager::FetchModels(bool is_first_model_fetch) {
proto::ModelInfo base_model_info;
// There should only be one supported model engine version at a time.
base_model_info.add_supported_model_engine_versions(
proto::MODEL_ENGINE_VERSION_TFLITE_2_14);
proto::MODEL_ENGINE_VERSION_TFLITE_2_14_1);
// This histogram is used for integration tests. Do not remove.
// Update this to be 10000 if/when we exceed 100 model engine versions.
LOCAL_HISTOGRAM_COUNTS_100(
Expand Down
4 changes: 4 additions & 0 deletions components/optimization_guide/core/tflite_op_resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ TFLiteOpResolver::TFLiteOpResolver() {
tflite::ops::builtin::Register_GELU(),
/* min_version = */ 1,
/* max_version = */ 2);
AddBuiltin(tflite::BuiltinOperator_RANDOM_STANDARD_NORMAL,
tflite::ops::builtin::Register_RANDOM_STANDARD_NORMAL());
AddBuiltin(tflite::BuiltinOperator_RANDOM_UNIFORM,
tflite::ops::builtin::Register_RANDOM_UNIFORM());

#if BUILDFLAG(BUILD_TFLITE_WITH_XNNPACK)
if (features::TFLiteXNNPACKDelegateEnabled()) {
Expand Down
6 changes: 5 additions & 1 deletion components/optimization_guide/proto/models.proto
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ enum ModelEngineVersion {
// A model using only operations that are supported by TensorflowLite 2.9.0.
MODEL_ENGINE_VERSION_TFLITE_2_9 = 7;
// A model using only operations that are supported by TensorflowLite 2.9.0.
// This adds GELU to the supported ops in Optimiziation Guide.
// This adds GELU to the supported ops in Optimization Guide.
MODEL_ENGINE_VERSION_TFLITE_2_9_0_1 = 8;
// A model using only operations that are supported by TensorflowLite 2.10.0.
MODEL_ENGINE_VERSION_TFLITE_2_10 = 9;
Expand All @@ -234,6 +234,10 @@ enum ModelEngineVersion {
MODEL_ENGINE_VERSION_TFLITE_2_13 = 12;
// A model using only operations that are supported by TensorflowLite 2.14.0.
MODEL_ENGINE_VERSION_TFLITE_2_14 = 13;
// A model using only operations that are supported by TensorflowLite 2.14.0.
// This adds RANDOM_UNIFORM and RANDOM_STANDARD_NORMAL to the supported opts
// in Optimization Guide.
MODEL_ENGINE_VERSION_TFLITE_2_14_1 = 14;
}

// The set of parameters that the server can use to vary the served model for
Expand Down
1 change: 1 addition & 0 deletions third_party/tflite/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ source_set("tflite_kernels") {
"src/tensorflow/lite/kernels/pooling.cc",
"src/tensorflow/lite/kernels/pow.cc",
"src/tensorflow/lite/kernels/quantize.cc",
"src/tensorflow/lite/kernels/random_ops.cc",
"src/tensorflow/lite/kernels/range.cc",
"src/tensorflow/lite/kernels/rank.cc",
"src/tensorflow/lite/kernels/read_variable.cc",
Expand Down

0 comments on commit c95c2f0

Please sign in to comment.