Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64f0a59c authored by Philip Quinn's avatar Philip Quinn Committed by Automerger Merge Worker
Browse files

Merge "Move MotionPredictor config to an XML file alongside the model." into...

Merge "Move MotionPredictor config to an XML file alongside the model." into udc-qpr-dev am: 15cebeda

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/23815729



Change-Id: Ia65ff5abbcbeef09e538a6ca45ab4e4681724ba3
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 34370a4f 15cebeda
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -3,12 +3,21 @@ package {
}

filegroup {
    name: "motion_predictor_model.fb",
    srcs: ["motion_predictor_model.fb"],
    name: "motion_predictor_model",
    srcs: [
        "motion_predictor_model.tflite",
        "motion_predictor_config.xml",
    ],
}

prebuilt_etc {
    name: "motion_predictor_model_prebuilt",
    filename_from_src: true,
    src: "motion_predictor_model.fb",
    src: "motion_predictor_model.tflite",
}

prebuilt_etc {
    name: "motion_predictor_model_config",
    filename_from_src: true,
    src: "motion_predictor_config.xml",
}
+20 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2023 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<motion-predictor>
  <!-- The time interval (ns) between the model's predictions. -->
  <prediction-interval>4166666</prediction-interval>  <!-- 4.167 ms = ~240 Hz -->
</motion-predictor>
+8 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@

#include <android-base/mapped_file.h>
#include <input/RingBuffer.h>
#include <utils/Timers.h>

#include <tensorflow/lite/core/api/error_reporter.h>
#include <tensorflow/lite/interpreter.h>
@@ -109,6 +110,9 @@ public:
    // Returns the length of the model's output buffers.
    size_t outputLength() const;

    // Returns the time interval between predictions.
    nsecs_t predictionInterval() const { return mPredictionInterval; }

    // Executes the model.
    // Returns true if the model successfully executed and the output tensors can be read.
    bool invoke();
@@ -127,7 +131,8 @@ public:
    std::span<const float> outputPressure() const;

private:
    explicit TfLiteMotionPredictorModel(std::unique_ptr<android::base::MappedFile> model);
    explicit TfLiteMotionPredictorModel(std::unique_ptr<android::base::MappedFile> model,
                                        nsecs_t predictionInterval);

    void allocateTensors();
    void attachInputTensors();
@@ -148,6 +153,8 @@ private:
    std::unique_ptr<tflite::FlatBufferModel> mModel;
    std::unique_ptr<tflite::Interpreter> mInterpreter;
    tflite::SignatureRunner* mRunner = nullptr;

    const nsecs_t mPredictionInterval = 0;
};

} // namespace android
+2 −0
Original line number Diff line number Diff line
@@ -215,6 +215,7 @@ cc_library {
        "libcutils",
        "liblog",
        "libPlatformProperties",
        "libtinyxml2",
        "libvintf",
    ],

@@ -271,6 +272,7 @@ cc_library {

            required: [
                "motion_predictor_model_prebuilt",
                "motion_predictor_model_config",
            ],
        },
        host: {
Loading