summaryrefslogtreecommitdiff
path: root/thermal/virtualtemp_estimator/virtualtemp_estimator_data.h
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2024-03-06 09:30:01 -0800
committerXin Li <delphij@google.com>2024-03-06 09:30:01 -0800
commit7ce1bf3229894cf8792b17ebd25404f194ebb8a3 (patch)
tree6054814f4a387f298ba278c89ee779ffa6e67e82 /thermal/virtualtemp_estimator/virtualtemp_estimator_data.h
parente4127a7e5bb05096c138ae44a035f2bf52fecc2b (diff)
parent7f749634995ddf3820f404359c68f8456964ef22 (diff)
downloadpixel-7ce1bf3229894cf8792b17ebd25404f194ebb8a3.tar.gz
Merge Android 14 QPR2 to AOSP main
Bug: 319669529 Merged-In: I8f1863cbde90b5bba929629615d0b11d11961650 Change-Id: I6cb962702e9f1473287e1da429272399b3ca93bf
Diffstat (limited to 'thermal/virtualtemp_estimator/virtualtemp_estimator_data.h')
-rw-r--r--thermal/virtualtemp_estimator/virtualtemp_estimator_data.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/thermal/virtualtemp_estimator/virtualtemp_estimator_data.h b/thermal/virtualtemp_estimator/virtualtemp_estimator_data.h
new file mode 100644
index 00000000..935c753b
--- /dev/null
+++ b/thermal/virtualtemp_estimator/virtualtemp_estimator_data.h
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+#include <cstddef>
+#include <mutex>
+#include <string>
+
+#pragma once
+
+namespace thermal {
+namespace vtestimator {
+
+// Current version only supports single input/output tensors
+constexpr int kNumInputTensors = 1;
+constexpr int kNumOutputTensors = 1;
+
+typedef void *(*tflitewrapper_create)(int num_input_tensors, int num_output_tensors);
+typedef bool (*tflitewrapper_init)(void *handle, const char *model_path);
+typedef bool (*tflitewrapper_invoke)(void *handle, float *input_samples, int num_input_samples,
+ float *output_samples, int num_output_samples);
+typedef void (*tflitewrapper_destroy)(void *handle);
+
+struct TFLiteWrapperMethods {
+ tflitewrapper_create create;
+ tflitewrapper_init init;
+ tflitewrapper_invoke invoke;
+ tflitewrapper_destroy destroy;
+ mutable std::mutex mutex_;
+};
+
+struct VirtualTempEstimatorTFLiteData {
+ VirtualTempEstimatorTFLiteData(size_t num_input_samples) {
+ input_buffer = new float[num_input_samples];
+ input_buffer_size = num_input_samples;
+ is_initialized = false;
+ tflite_wrapper = nullptr;
+
+ tflite_methods.create = nullptr;
+ tflite_methods.init = nullptr;
+ tflite_methods.invoke = nullptr;
+ tflite_methods.destroy = nullptr;
+ }
+
+ void *tflite_wrapper;
+ float *input_buffer;
+ size_t input_buffer_size;
+ std::string model_path;
+ TFLiteWrapperMethods tflite_methods;
+ bool is_initialized;
+
+ ~VirtualTempEstimatorTFLiteData() {
+ if (tflite_wrapper && tflite_methods.destroy) {
+ tflite_methods.destroy(tflite_wrapper);
+ }
+
+ if (input_buffer) {
+ delete input_buffer;
+ }
+ }
+};
+
+} // namespace vtestimator
+} // namespace thermal