diff options
Diffstat (limited to 'thermal/virtualtemp_estimator/virtualtemp_estimator.h')
-rw-r--r-- | thermal/virtualtemp_estimator/virtualtemp_estimator.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/thermal/virtualtemp_estimator/virtualtemp_estimator.h b/thermal/virtualtemp_estimator/virtualtemp_estimator.h new file mode 100644 index 00000000..0ae37f9e --- /dev/null +++ b/thermal/virtualtemp_estimator/virtualtemp_estimator.h @@ -0,0 +1,58 @@ +/* + * 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. + */ +#pragma once + +#include <vector> + +#include "virtualtemp_estimator_data.h" + +namespace thermal { +namespace vtestimator { + +enum VtEstimatorStatus { + kVtEstimatorOk = 0, + kVtEstimatorInvalidArgs = 1, + kVtEstimatorInitFailed = 2, + kVtEstimatorInvokeFailed = 3, + kVtEstimatorUnSupported = 4, +}; + +// Class to estimate virtual temperature based on a model +class VirtualTempEstimator { + public: + // Implicit copy-move headers. + VirtualTempEstimator(const VirtualTempEstimator &) = delete; + VirtualTempEstimator(VirtualTempEstimator &&) = default; + VirtualTempEstimator &operator=(const VirtualTempEstimator &) = delete; + VirtualTempEstimator &operator=(VirtualTempEstimator &&) = default; + + VirtualTempEstimator(size_t num_input_samples); + ~VirtualTempEstimator(); + + // Initializes the model provided by model_path. + VtEstimatorStatus Initialize(const char *model_path); + + // Performs the inference on the loaded VT model. + // Output of the inference is returned in output argument + VtEstimatorStatus Estimate(const std::vector<float> &thermistors, float *output); + + private: + void LoadTFLiteWrapper(); + std::unique_ptr<VirtualTempEstimatorTFLiteData> data_; +}; + +} // namespace vtestimator +} // namespace thermal |