2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 * @brief This file contains classes for testing correctess of implementation
20 * @ingroup COM_AI_RUNTIME
23 #ifndef __NNFW_TFLITE_DIFF_H__
24 #define __NNFW_TFLITE_DIFF_H__
26 #include "tensorflow/lite/interpreter.h"
28 #include "misc/RandomGenerator.h"
29 #include "misc/tensor/Index.h"
30 #include "misc/tensor/Diff.h"
31 #include "misc/tensor/Shape.h"
32 #include "misc/tensor/Comparator.h"
34 #include "tflite/TensorView.h"
40 * @brief Class to define TfLite interpreter match application
42 class TfLiteInterpMatchApp
46 * @brief Construct a new TfLiteInterpMatchApp object with Comparator
47 * @param[in] comparator Comparator object for tensor comparation
49 TfLiteInterpMatchApp(const nnfw::misc::tensor::Comparator &comparator)
50 : _verbose{false}, _comparator(comparator)
57 * @brief Get reference verbose for debugging information
58 * @return Reference of verbose value
60 int &verbose(void) { return _verbose; }
67 * @brief Run two interpreter and return the output matching
68 * @param[in] pure Interpreter object of expected(with TfLite)
69 * @param[in] nnapi Interpreter object of obtained(through NNAPI)
70 * @return @c true if two Interpreter results are same, otherwise @c false
72 bool run(::tflite::Interpreter &pure, ::tflite::Interpreter &nnapi) const;
74 * @brief Compare two TensorView values and return the match result
75 * @param[in] expected TensorView object to read expected values
76 * @param[in] obtained TensorView object to read obtained values
77 * @param[in] id Tensor ID value used for debug message
78 * @return @c true if two TensorView values are same, otherwise @c false
81 bool compareSingleTensorView(const nnfw::tflite::TensorView<T> &expected,
82 const nnfw::tflite::TensorView<T> &obtained, int id) const;
85 const nnfw::misc::tensor::Comparator &_comparator;
88 #endif // __NNFW_TFLITE_DIFF_H__