blob: f6639fd0b5ff365237674a20c48a7c6cba9926fc [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 TENSORFLOW_LITE_MICRO_LOCAL_HPP
18#define TENSORFLOW_LITE_MICRO_LOCAL_HPP
19
20/* We include all our TensorFlow Lite Micro headers here */
21
22/**
23 * TensorFlow Lite Micro sources can generate a lot of warnings from the usage
24 * of a single macro (TF_LITE_REMOVE_VIRTUAL_DELETE). Suppress the known ones
25 * here to prevent them from masking warnings that might be generated by our
26 * application sources.
27 */
28#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
29 #pragma clang diagnostic push
30 #pragma clang diagnostic ignored "-Wunused-parameter"
31 #include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
32 #include "tensorflow/lite/micro/micro_interpreter.h"
33 #include "tensorflow/lite/micro/micro_error_reporter.h"
34 #include "tensorflow/lite/micro/all_ops_resolver.h"
35 #pragma clang diagnostic pop
36#elif defined(__GNUC__)
37 #pragma GCC diagnostic push
38 #pragma GCC diagnostic ignored "-Wunused-parameter"
39 #include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
40 #include "tensorflow/lite/micro/micro_interpreter.h"
41 #include "tensorflow/lite/micro/micro_error_reporter.h"
42 #include "tensorflow/lite/micro/all_ops_resolver.h"
43 #pragma GCC diagnostic pop
44#else
45 #include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
46 #include "tensorflow/lite/micro/micro_interpreter.h"
47 #include "tensorflow/lite/micro/micro_error_reporter.h"
48 #include "tensorflow/lite/micro/all_ops_resolver.h"
49#endif
50
51#include "tensorflow/lite/c/common.h"
52#include "tensorflow/lite/micro/kernels/micro_ops.h"
53#include "tensorflow/lite/schema/schema_generated.h"
Cisco Cervellera02101092021-09-07 11:34:43 +010054#include "tensorflow/lite/schema/schema_utils.h"
alexander3c798932021-03-26 21:42:19 +000055
56#if defined (TESTS)
57 #include "tensorflow/lite/micro/test_helpers.h"
58#endif /* defined (TESTS) */
59
60namespace arm {
61namespace app {
62
Kshitij Sisodiadd6d07b2022-05-03 10:10:14 +010063 /** Struct for quantization parameters. */
alexander3c798932021-03-26 21:42:19 +000064 struct QuantParams {
65 float scale = 1.0;
66 int offset = 0;
67 };
68
Kshitij Sisodiadd6d07b2022-05-03 10:10:14 +010069 /**
70 * @brief Gets the quantization parameters from a tensor
71 * @param[in] tensor pointer to the tensor.
72 * @return QuantParams object.
73 */
alexander3c798932021-03-26 21:42:19 +000074 QuantParams GetTensorQuantParams(TfLiteTensor* tensor);
75
Kshitij Sisodiadd6d07b2022-05-03 10:10:14 +010076 /**
77 * @brief String logging functionality expected to be defined
78 * by TensorFlow Lite Micro's error reporter.
79 * @param[in] s Pointer to the string.
80 */
81 extern "C" void DebugLog(const char* s);
82
alexander3c798932021-03-26 21:42:19 +000083} /* namespace app */
84} /* namespace arm */
85
86/**
87 * @brief Prints the tensor flow version in use to stdout.
88 */
89void PrintTensorFlowVersion();
90
91#endif /* TENSORFLOW_LITE_MICRO_LOCAL_HPP */