blob: 6957b1b60eab6d8da7a8bc86b20fd4b23e1d6681 [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001/*
Richard Burtondf88c5d2023-05-30 17:40:39 +01002 * SPDX-FileCopyrightText: Copyright 2021-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
alexander3c798932021-03-26 21:42:19 +00003 * 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"
alexander3c798932021-03-26 21:42:19 +000033 #pragma clang diagnostic pop
34#elif defined(__GNUC__)
35 #pragma GCC diagnostic push
36 #pragma GCC diagnostic ignored "-Wunused-parameter"
37 #include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
38 #include "tensorflow/lite/micro/micro_interpreter.h"
alexander3c798932021-03-26 21:42:19 +000039 #pragma GCC diagnostic pop
40#else
41 #include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
42 #include "tensorflow/lite/micro/micro_interpreter.h"
alexander3c798932021-03-26 21:42:19 +000043#endif
44
45#include "tensorflow/lite/c/common.h"
46#include "tensorflow/lite/micro/kernels/micro_ops.h"
47#include "tensorflow/lite/schema/schema_generated.h"
Cisco Cervellera02101092021-09-07 11:34:43 +010048#include "tensorflow/lite/schema/schema_utils.h"
alexander3c798932021-03-26 21:42:19 +000049
50#if defined (TESTS)
51 #include "tensorflow/lite/micro/test_helpers.h"
52#endif /* defined (TESTS) */
53
54namespace arm {
55namespace app {
56
Kshitij Sisodiadd6d07b2022-05-03 10:10:14 +010057 /** Struct for quantization parameters. */
alexander3c798932021-03-26 21:42:19 +000058 struct QuantParams {
59 float scale = 1.0;
60 int offset = 0;
61 };
62
Kshitij Sisodiadd6d07b2022-05-03 10:10:14 +010063 /**
64 * @brief Gets the quantization parameters from a tensor
65 * @param[in] tensor pointer to the tensor.
66 * @return QuantParams object.
67 */
alexander3c798932021-03-26 21:42:19 +000068 QuantParams GetTensorQuantParams(TfLiteTensor* tensor);
69
alexander3c798932021-03-26 21:42:19 +000070} /* namespace app */
71} /* namespace arm */
72
73/**
74 * @brief Prints the tensor flow version in use to stdout.
75 */
76void PrintTensorFlowVersion();
77
Kshitij Sisodia937052d2022-05-13 16:44:16 +010078/**
79 * @brief String logging functionality expected to be defined
80 * by TensorFlow Lite Micro's error reporter.
81 * @param[in] s Pointer to the string.
82 */
83extern "C" void DebugLog(const char* s) __attribute__((__weak__));
84
alexander3c798932021-03-26 21:42:19 +000085#endif /* TENSORFLOW_LITE_MICRO_LOCAL_HPP */