blob: de18aa850fc6794a64626d9c36d2857b5b927c12 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001/*
2 * Copyright (c) 2021 Arm Limited. All rights reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17#ifndef ASR_CLASSIFIER_HPP
18#define ASR_CLASSIFIER_HPP
19
20#include "Classifier.hpp"
21
22namespace arm {
23namespace app {
24
25 class AsrClassifier : public Classifier {
26 public:
27 /**
28 * @brief Gets the top N classification results from the
29 * output vector.
30 * @param[in] outputTensor Inference output tensor from an NN model.
31 * @param[out] vecResults A vector of classification results
32 * populated by this function.
33 * @param[in] labels Labels vector to match classified classes
34 * @param[in] topNCount Number of top classifications to pick.
35 * @return true if successful, false otherwise.
36 **/
37 bool GetClassificationResults(
38 TfLiteTensor* outputTensor,
39 std::vector<ClassificationResult>& vecResults,
40 const std::vector <std::string>& labels, uint32_t topNCount) override;
41
42 private:
43
44 /**
45 * @brief Utility function that gets the top 1 classification results from the
46 * output tensor (vector of vector).
47 * @param[in] tensor Inference output tensor from an NN model.
48 * @param[out] vecResults A vector of classification results
49 * populated by this function.
50 * @param[in] labels Labels vector to match classified classes.
51 * @param[in] scale Quantization scale.
52 * @param[in] zeroPoint Quantization zero point.
53 * @return true if successful, false otherwise.
54 **/
55 template<typename T>
56 bool _GetTopResults(TfLiteTensor* tensor,
57 std::vector<ClassificationResult>& vecResults,
58 const std::vector <std::string>& labels, double scale, double zeroPoint);
59 };
60
61} /* namespace app */
62} /* namespace arm */
63
64#endif /* ASR_CLASSIFIER_HPP */