blob: 944ed4a7b73e065eed2f77a6302f362d09a632de [file] [log] [blame]
alexander3c798932021-03-26 21:42:19 +00001/*
Richard Burton71f282e2022-12-01 12:31:23 +00002 * SPDX-FileCopyrightText: Copyright 2021-2022 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 #include "tensorflow/lite/micro/all_ops_resolver.h"
34 #pragma clang diagnostic pop
35#elif defined(__GNUC__)
36 #pragma GCC diagnostic push
37 #pragma GCC diagnostic ignored "-Wunused-parameter"
38 #include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
39 #include "tensorflow/lite/micro/micro_interpreter.h"
alexander3c798932021-03-26 21:42:19 +000040 #include "tensorflow/lite/micro/all_ops_resolver.h"
41 #pragma GCC diagnostic pop
42#else
43 #include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
44 #include "tensorflow/lite/micro/micro_interpreter.h"
alexander3c798932021-03-26 21:42:19 +000045 #include "tensorflow/lite/micro/all_ops_resolver.h"
46#endif
47
48#include "tensorflow/lite/c/common.h"
49#include "tensorflow/lite/micro/kernels/micro_ops.h"
Richard Burton71f282e2022-12-01 12:31:23 +000050#include "tensorflow/lite/micro/tflite_bridge/op_resolver_bridge.h"
alexander3c798932021-03-26 21:42:19 +000051#include "tensorflow/lite/schema/schema_generated.h"
Cisco Cervellera02101092021-09-07 11:34:43 +010052#include "tensorflow/lite/schema/schema_utils.h"
alexander3c798932021-03-26 21:42:19 +000053
54#if defined (TESTS)
55 #include "tensorflow/lite/micro/test_helpers.h"
56#endif /* defined (TESTS) */
57
58namespace arm {
59namespace app {
60
Kshitij Sisodiadd6d07b2022-05-03 10:10:14 +010061 /** Struct for quantization parameters. */
alexander3c798932021-03-26 21:42:19 +000062 struct QuantParams {
63 float scale = 1.0;
64 int offset = 0;
65 };
66
Kshitij Sisodiadd6d07b2022-05-03 10:10:14 +010067 /**
68 * @brief Gets the quantization parameters from a tensor
69 * @param[in] tensor pointer to the tensor.
70 * @return QuantParams object.
71 */
alexander3c798932021-03-26 21:42:19 +000072 QuantParams GetTensorQuantParams(TfLiteTensor* tensor);
73
alexander3c798932021-03-26 21:42:19 +000074} /* namespace app */
75} /* namespace arm */
76
77/**
78 * @brief Prints the tensor flow version in use to stdout.
79 */
80void PrintTensorFlowVersion();
81
Kshitij Sisodia937052d2022-05-13 16:44:16 +010082/**
83 * @brief String logging functionality expected to be defined
84 * by TensorFlow Lite Micro's error reporter.
85 * @param[in] s Pointer to the string.
86 */
87extern "C" void DebugLog(const char* s) __attribute__((__weak__));
88
alexander3c798932021-03-26 21:42:19 +000089#endif /* TENSORFLOW_LITE_MICRO_LOCAL_HPP */