xmos-ai-tools 1.1.2.dev216__py3-none-macosx_11_0_arm64.whl → 1.1.2.dev236__py3-none-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. xmos_ai_tools/runtime/include/lib_nn/api/nn_layers.h +16 -0
  2. xmos_ai_tools/runtime/include/lib_nn/api/quadratic_approximation.h +80 -0
  3. xmos_ai_tools/runtime/include/lib_nn/api/quadratic_interpolation.h +23 -0
  4. xmos_ai_tools/runtime/include/lib_tflite_micro/src/tflite-xcore-kernels/xcore_ops.h +15 -15
  5. xmos_ai_tools/runtime/include/{tensorflow/lite/micro/examples/micro_speech/simple_features/model.h → signal/micro/kernels/delay_flexbuffers_generated_data.h} +7 -9
  6. xmos_ai_tools/runtime/include/signal/micro/kernels/energy_flexbuffers_generated_data.h +28 -0
  7. xmos_ai_tools/runtime/include/signal/micro/kernels/fft_flexbuffers_generated_data.h +37 -0
  8. xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_flexbuffers_generated_data.h +25 -0
  9. xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_log_flexbuffers_generated_data.h +27 -0
  10. xmos_ai_tools/runtime/include/signal/micro/kernels/filter_bank_spectral_subtraction_flexbuffers_generated_data.h +26 -0
  11. xmos_ai_tools/runtime/include/signal/micro/kernels/framer_flexbuffers_generated_data.h +25 -0
  12. xmos_ai_tools/runtime/include/{tensorflow/lite/micro/examples/micro_speech/simple_features/no_simple_features_data.h → signal/micro/kernels/irfft.h} +15 -7
  13. xmos_ai_tools/runtime/include/signal/micro/kernels/overlap_add_flexbuffers_generated_data.h +25 -0
  14. xmos_ai_tools/runtime/include/signal/micro/kernels/pcan_flexbuffers_generated_data.h +7 -0
  15. xmos_ai_tools/runtime/include/signal/micro/kernels/rfft.h +31 -0
  16. xmos_ai_tools/runtime/include/signal/micro/kernels/stacker_flexbuffers_generated_data.h +25 -0
  17. xmos_ai_tools/runtime/include/signal/micro/kernels/window_flexbuffers_generated_data.h +25 -0
  18. xmos_ai_tools/runtime/include/signal/src/circular_buffer.h +118 -0
  19. xmos_ai_tools/runtime/include/signal/src/complex.h +29 -0
  20. xmos_ai_tools/runtime/include/signal/src/energy.h +38 -0
  21. xmos_ai_tools/runtime/include/signal/src/fft_auto_scale.h +35 -0
  22. xmos_ai_tools/runtime/include/signal/src/filter_bank.h +69 -0
  23. xmos_ai_tools/runtime/include/signal/src/filter_bank_log.h +38 -0
  24. xmos_ai_tools/runtime/include/signal/src/filter_bank_spectral_subtraction.h +73 -0
  25. xmos_ai_tools/runtime/include/{tensorflow/lite/micro/examples/micro_speech/main_functions.h → signal/src/filter_bank_square_root.h} +14 -17
  26. xmos_ai_tools/runtime/include/signal/src/irfft.h +84 -0
  27. xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_common.h +49 -0
  28. xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_float.h +31 -0
  29. xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_int16.h +30 -0
  30. xmos_ai_tools/runtime/include/signal/src/kiss_fft_wrappers/kiss_fft_int32.h +31 -0
  31. xmos_ai_tools/runtime/include/{tensorflow/lite/micro/examples/micro_speech/micro_features/no_micro_features_data.h → signal/src/log.h} +13 -6
  32. xmos_ai_tools/runtime/include/{tensorflow/lite/micro/python/interpreter/src/python_utils.h → signal/src/max_abs.h} +11 -11
  33. xmos_ai_tools/runtime/include/{tensorflow/lite/micro/examples/micro_speech/micro_features/yes_micro_features_data.h → signal/src/msb.h} +15 -6
  34. xmos_ai_tools/runtime/include/signal/src/overlap_add.h +46 -0
  35. xmos_ai_tools/runtime/include/signal/src/pcan_argc_fixed.h +41 -0
  36. xmos_ai_tools/runtime/include/signal/src/rfft.h +85 -0
  37. xmos_ai_tools/runtime/include/signal/src/square_root.h +32 -0
  38. xmos_ai_tools/runtime/include/{tensorflow/lite/micro/python/interpreter/src/numpy_utils.h → signal/src/window.h} +13 -15
  39. xmos_ai_tools/runtime/include/signal/testdata/fft_test_data.h +48 -0
  40. xmos_ai_tools/runtime/include/tensorflow/lite/array.h +156 -0
  41. xmos_ai_tools/runtime/include/tensorflow/lite/builtin_ops.h +44 -0
  42. xmos_ai_tools/runtime/include/tensorflow/lite/c/c_api_types.h +6 -0
  43. xmos_ai_tools/runtime/include/tensorflow/lite/c/common.h +8 -25
  44. xmos_ai_tools/runtime/include/tensorflow/lite/core/api/error_reporter.h +3 -3
  45. xmos_ai_tools/runtime/include/tensorflow/lite/core/api/flatbuffer_conversions.h +15 -0
  46. xmos_ai_tools/runtime/include/tensorflow/lite/core/c/builtin_op_data.h +92 -3
  47. xmos_ai_tools/runtime/include/tensorflow/lite/core/c/c_api_types.h +61 -51
  48. xmos_ai_tools/runtime/include/tensorflow/lite/core/c/common.h +302 -1
  49. xmos_ai_tools/runtime/include/tensorflow/lite/core/macros.h +78 -0
  50. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/common.h +129 -43
  51. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/cppmath.h +2 -2
  52. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/portable_tensor.h +23 -4
  53. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/add.h +210 -151
  54. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/comparisons.h +9 -18
  55. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/conv.h +2 -0
  56. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/add.h +103 -72
  57. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/conv.h +2 -0
  58. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/mean.h +2 -63
  59. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/integer_ops/mul.h +87 -26
  60. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/mul.h +129 -80
  61. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/reduce.h +42 -93
  62. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/resize_bilinear.h +5 -0
  63. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/reference/sub.h +249 -263
  64. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/runtime_shape.h +11 -1
  65. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/strided_slice_logic.h +5 -1
  66. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/tensor_ctypes.h +5 -10
  67. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/internal/types.h +4 -2
  68. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/kernel_util.h +25 -14
  69. xmos_ai_tools/runtime/include/tensorflow/lite/kernels/op_macros.h +14 -3
  70. xmos_ai_tools/runtime/include/tensorflow/lite/micro/debug_log.h +10 -3
  71. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/micro_model_settings.h +37 -0
  72. xmos_ai_tools/runtime/include/tensorflow/lite/micro/fake_micro_context.h +7 -0
  73. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/add.h +6 -5
  74. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/circular_buffer.h +0 -3
  75. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/conv.h +19 -20
  76. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/conv_test.h +8 -31
  77. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/depthwise_conv.h +8 -8
  78. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/ethosu.h +1 -1
  79. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/fully_connected.h +9 -9
  80. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/kernel_runner.h +14 -9
  81. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/kernel_util.h +9 -4
  82. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/micro_ops.h +119 -100
  83. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/mul.h +4 -4
  84. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/pooling.h +8 -8
  85. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/reduce.h +4 -4
  86. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/reshape.h +26 -0
  87. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/softmax.h +12 -16
  88. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/strided_slice.h +40 -0
  89. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/svdf.h +8 -7
  90. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/unidirectional_sequence_lstm.h +5 -5
  91. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa.h +2 -2
  92. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_conv.h +26 -21
  93. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_depthwise_conv.h +4 -4
  94. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_reshape.h +2 -4
  95. xmos_ai_tools/runtime/include/tensorflow/lite/micro/kernels/xtensa/xtensa_softmax.h +2 -2
  96. xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/greedy_memory_planner.h +5 -0
  97. xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/linear_memory_planner.h +4 -0
  98. xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/micro_memory_planner.h +4 -0
  99. xmos_ai_tools/runtime/include/tensorflow/lite/micro/memory_planner/non_persistent_buffer_planner_shim.h +4 -0
  100. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_allocator.h +23 -8
  101. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_common.h +38 -0
  102. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_context.h +23 -65
  103. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_graph.h +15 -57
  104. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter.h +16 -5
  105. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter_context.h +125 -0
  106. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_interpreter_graph.h +110 -0
  107. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_log.h +6 -8
  108. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_mutable_op_resolver.h +114 -32
  109. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_op_resolver.h +6 -5
  110. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_profiler.h +1 -1
  111. xmos_ai_tools/runtime/include/tensorflow/lite/micro/mock_micro_graph.h +1 -1
  112. xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/interpreter/src/python_ops_resolver.h +21 -0
  113. xmos_ai_tools/runtime/include/tensorflow/lite/micro/test_helper_custom_ops.h +3 -4
  114. xmos_ai_tools/runtime/include/tensorflow/lite/micro/test_helpers.h +28 -12
  115. xmos_ai_tools/runtime/include/tensorflow/lite/micro/testing/micro_test.h +1 -0
  116. xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/log_utils.h +273 -0
  117. xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/metrics.h +41 -0
  118. xmos_ai_tools/runtime/include/tensorflow/lite/micro/tools/benchmarking/op_resolver.h +127 -0
  119. xmos_ai_tools/runtime/include/tensorflow/lite/schema/schema_generated.h +9139 -5010
  120. xmos_ai_tools/runtime/lib/libhost_xtflitemicro.a +0 -0
  121. xmos_ai_tools/runtime/lib/libxtflitemicro.a +0 -0
  122. xmos_ai_tools/xinterpreters/libs/macos/xtflm_python.1.0.1.dylib +0 -0
  123. xmos_ai_tools/xinterpreters/libs/macos/xtflm_python.dylib +0 -0
  124. {xmos_ai_tools-1.1.2.dev216.data → xmos_ai_tools-1.1.2.dev236.data}/data/bin/xcore-opt +0 -0
  125. {xmos_ai_tools-1.1.2.dev216.dist-info → xmos_ai_tools-1.1.2.dev236.dist-info}/METADATA +3 -4
  126. {xmos_ai_tools-1.1.2.dev216.dist-info → xmos_ai_tools-1.1.2.dev236.dist-info}/RECORD +128 -105
  127. {xmos_ai_tools-1.1.2.dev216.dist-info → xmos_ai_tools-1.1.2.dev236.dist-info}/WHEEL +1 -1
  128. xmos_ai_tools/runtime/include/tensorflow/lite/core/api/op_resolver.h +0 -129
  129. xmos_ai_tools/runtime/include/tensorflow/lite/micro/all_ops_resolver.h +0 -38
  130. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/audio_provider.h +0 -44
  131. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/command_responder.h +0 -30
  132. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/feature_provider.h +0 -50
  133. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/micro_features/micro_features_generator.h +0 -30
  134. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/micro_features/micro_model_settings.h +0 -43
  135. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/micro_features/no_feature_data_slice.h +0 -29
  136. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/micro_features/yes_feature_data_slice.h +0 -29
  137. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/recognize_commands.h +0 -151
  138. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/simple_features/no_power_spectrum_data.h +0 -29
  139. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/simple_features/simple_features_generator.h +0 -29
  140. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/simple_features/simple_model_settings.h +0 -43
  141. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/simple_features/yes_power_spectrum_data.h +0 -29
  142. xmos_ai_tools/runtime/include/tensorflow/lite/micro/examples/micro_speech/simple_features/yes_simple_features_data.h +0 -23
  143. xmos_ai_tools/runtime/include/tensorflow/lite/micro/micro_string.h +0 -33
  144. xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/interpreter/src/interpreter_wrapper.h +0 -51
  145. xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/interpreter/src/pybind11_lib.h +0 -64
  146. xmos_ai_tools/runtime/include/tensorflow/lite/micro/python/interpreter/src/shared_library.h +0 -40
  147. {xmos_ai_tools-1.1.2.dev216.dist-info → xmos_ai_tools-1.1.2.dev236.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,29 @@
1
+ /* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef SIGNAL_SRC_COMPLEX_H_
17
+ #define SIGNAL_SRC_COMPLEX_H_
18
+
19
+ #include <stdint.h>
20
+
21
+ // We would use the standard complex type in complex.h, but there's
22
+ // no guarantee that all architectures will support it.
23
+ template <typename T>
24
+ struct Complex {
25
+ T real;
26
+ T imag;
27
+ };
28
+
29
+ #endif // SIGNAL_SRC_COMPLEX_H_
@@ -0,0 +1,38 @@
1
+ /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef SIGNAL_ENERGY_H_
17
+ #define SIGNAL_ENERGY_H_
18
+
19
+ #include <stdint.h>
20
+
21
+ #include "signal/src/complex.h"
22
+
23
+ namespace tflite {
24
+ namespace tflm_signal {
25
+ // TODO(b/286250473): remove namespace once de-duped libraries above
26
+
27
+ // Calculates the power spectrum from a DFT output between start and end indices
28
+ //
29
+ // * `start_index` and `end_index` must valid indices into `input`
30
+ // * `output` must be the same size as `input`. Only the values at indices
31
+ // `start_index` and `end_index` inclusive should be considered valid.
32
+ void SpectrumToEnergy(const Complex<int16_t>* input, int start_index,
33
+ int end_index, uint32_t* output);
34
+
35
+ } // namespace tflm_signal
36
+ } // namespace tflite
37
+
38
+ #endif // SIGNAL_ENERGY_H_
@@ -0,0 +1,35 @@
1
+ /* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef SIGNAL_SRC_FFT_AUTO_SCALE_H_
17
+ #define SIGNAL_SRC_FFT_AUTO_SCALE_H_
18
+
19
+ #include <stddef.h>
20
+ #include <stdint.h>
21
+
22
+ // TODO(b/286250473): remove namespace once de-duped libraries
23
+ namespace tflite {
24
+ namespace tflm_signal {
25
+
26
+ // Auto scales `input` and write the result to `output`
27
+ // Elements in `input` are left shifted to maximize the amplitude without
28
+ // clipping,
29
+ // * both `input` and `output` must be of size `size`
30
+ int FftAutoScale(const int16_t* input, int size, int16_t* output);
31
+
32
+ } // namespace tflm_signal
33
+ } // namespace tflite
34
+
35
+ #endif // SIGNAL_SRC_FFT_AUTO_SCALE_H_
@@ -0,0 +1,69 @@
1
+ /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef SIGNAL_SRC_FILTER_BANK_H_
17
+ #define SIGNAL_SRC_FILTER_BANK_H_
18
+
19
+ #include <stdint.h>
20
+
21
+ namespace tflite {
22
+ namespace tflm_signal {
23
+ // TODO(b/286250473): remove namespace once de-duped libraries above
24
+
25
+ struct FilterbankConfig {
26
+ // Number of filterbank channels
27
+ int32_t num_channels;
28
+
29
+ // Each of the following three arrays is of size num_channels + 1
30
+ // An extra channel is needed for scratch. See implementation of
31
+ // FilterbankAccumulateChannels() for more details
32
+
33
+ // For each channel, the index in the input (spectrum) where its band starts
34
+ const int16_t* channel_frequency_starts;
35
+ // For each channel, the index in the weights/unweights arrays where
36
+ // it filter weights start
37
+ const int16_t* channel_weight_starts;
38
+ // For each channel, the number of bins in the input (spectrum) that span
39
+ // its band
40
+ const int16_t* channel_widths;
41
+
42
+ // The weights array holds the triangular filter weights of all the filters
43
+ // in the bank. The output of each filter in the bank is caluclated by
44
+ // multiplying the elements in the input spectrum that are in its band
45
+ // (see above: channel_frequency_starts, channel_widths) by the filter weights
46
+ // then accumulating. Each element in the unweights array holds the 1 minus
47
+ // corresponding elements in the weights array and is used to make this
48
+ // operation more efficient. For more details, see documnetation in
49
+ // FilterbankAccumulateChannels()
50
+ const int16_t* weights;
51
+ const int16_t* unweights;
52
+ int32_t output_scale;
53
+
54
+ int32_t input_correction_bits;
55
+ };
56
+
57
+ // Accumulate the energy spectrum bins in `input` into filter bank channels
58
+ // contained in `output`.
59
+ // * `input` - Spectral energy array
60
+ // * `output` - of size `config.num_channels` + 1.
61
+ // Elements [1:num_channels] contain the filter bank channels.
62
+ // Element 0 is used as scratch and should be ignored
63
+ void FilterbankAccumulateChannels(const FilterbankConfig* config,
64
+ const uint32_t* input, uint64_t* output);
65
+
66
+ } // namespace tflm_signal
67
+ } // namespace tflite
68
+
69
+ #endif // SIGNAL_SRC_FILTER_BANK_H_
@@ -0,0 +1,38 @@
1
+ /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef SIGNAL_SRC_FILTER_BANK_LOG_H_
17
+ #define SIGNAL_SRC_FILTER_BANK_LOG_H_
18
+
19
+ #include <stdint.h>
20
+
21
+ namespace tflite {
22
+ namespace tflm_signal {
23
+ // TODO(b/286250473): remove namespace once de-duped libraries above
24
+
25
+ // Apply natural log to each element in array `input` of size `num_channels`
26
+ // with pre-shift and post scaling.
27
+ // The operation is roughly equivalent to:
28
+ // `output` = min(Log(`input` << `correction_bits`) * `output_scale`, INT16_MAX)
29
+ // Where:
30
+ // If (input << `correction_bits`) is 1 or 0, the function returns 0
31
+ void FilterbankLog(const uint32_t* input, int num_channels,
32
+ int32_t output_scale, uint32_t correction_bits,
33
+ int16_t* output);
34
+
35
+ } // namespace tflm_signal
36
+ } // namespace tflite
37
+
38
+ #endif // SIGNAL_SRC_FILTER_BANK_LOG_H_
@@ -0,0 +1,73 @@
1
+ /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef SIGNAL_SRC_FILTER_BANK_SPECTRAL_SUBTRACTION_H_
17
+ #define SIGNAL_SRC_FILTER_BANK_SPECTRAL_SUBTRACTION_H_
18
+
19
+ #include <stdint.h>
20
+
21
+ namespace tflite {
22
+ namespace tflm_signal {
23
+ // TODO(b/286250473): remove namespace once de-duped libraries above
24
+
25
+ struct SpectralSubtractionConfig {
26
+ // Number of filterbank channels in input and output
27
+ int32_t num_channels;
28
+ // The constant used for the lowpass filter for finding the noise.
29
+ // Higher values correspond to more aggressively adapting estimates
30
+ // of the noise.
31
+ // Scale is 1 << spectral_subtraction_bits
32
+ uint32_t smoothing;
33
+ // One minus smoothing constant for low pass filter.
34
+ // Scale is 1 << spectral_subtraction_bits
35
+ uint32_t one_minus_smoothing;
36
+ // The maximum cap to subtract away from the signal (ie, if this is
37
+ // 0.2, then the result of spectral subtraction will not go below
38
+ // 0.2 * signal).
39
+ // Scale is 1 << spectral_subtraction_bits
40
+ uint32_t min_signal_remaining;
41
+ // If positive, specifies the filter coefficient for odd-index
42
+ // channels, while 'smoothing' is used as the coefficient for even-
43
+ // index channels. Otherwise, the same filter coefficient is
44
+ // used on all channels.
45
+ // Scale is 1 << spectral_subtraction_bits
46
+ uint32_t alternate_smoothing;
47
+ // Alternate One minus smoothing constant for low pass filter.
48
+ // Scale is 1 << spectral_subtraction_bits
49
+ uint32_t alternate_one_minus_smoothing;
50
+ // Extra fractional bits for the noise_estimate smoothing filter.
51
+ uint32_t smoothing_bits;
52
+ // Scaling bits for some members of this struct
53
+ uint32_t spectral_subtraction_bits;
54
+ // If true, when the filterbank level drops below the output,
55
+ // the noise estimate will be forced down to the new noise level.
56
+ // If false, the noise estimate will remain above the current
57
+ // filterbank output (but the subtraction will still keep the
58
+ // output non negative).
59
+ bool clamping;
60
+ };
61
+
62
+ // Apply spectral subtraction to each element in `input`, then write the result
63
+ // to `output` and `noise_estimate`. `input`, `output` and `noise estimate`
64
+ // must all be of size `config.num_channels`. `config` holds the
65
+ // parameters of the spectral subtraction algorithm.
66
+ void FilterbankSpectralSubtraction(const SpectralSubtractionConfig* config,
67
+ const uint32_t* input, uint32_t* output,
68
+ uint32_t* noise_estimate);
69
+
70
+ } // namespace tflm_signal
71
+ } // namespace tflite
72
+
73
+ #endif // SIGNAL_SRC_FILTER_BANK_SPECTRAL_SUBTRACTION_H_
@@ -13,25 +13,22 @@ See the License for the specific language governing permissions and
13
13
  limitations under the License.
14
14
  ==============================================================================*/
15
15
 
16
- #ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MAIN_FUNCTIONS_H_
17
- #define TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MAIN_FUNCTIONS_H_
16
+ #ifndef SIGNAL_SRC_FILTER_BANK_SQUARE_ROOT_H_
17
+ #define SIGNAL_SRC_FILTER_BANK_SQUARE_ROOT_H_
18
18
 
19
- // Expose a C friendly interface for main functions.
20
- #ifdef __cplusplus
21
- extern "C" {
22
- #endif
19
+ #include <stdint.h>
23
20
 
24
- // Initializes all data needed for the example. The name is important, and needs
25
- // to be setup() for Arduino compatibility.
26
- void setup();
21
+ namespace tflite {
22
+ namespace tflm_signal {
23
+ // TODO(b/286250473): remove namespace once de-duped libraries above
27
24
 
28
- // Runs one iteration of data gathering and inference. This should be called
29
- // repeatedly from the application code. The name needs to be loop() for Arduino
30
- // compatibility.
31
- void loop();
25
+ // Apply square root to each element in `input`, then shift right by
26
+ // `scale_down_bits` before writing the result to `output`,
27
+ // `input` and `output` must both be of size `num_channels`
28
+ void FilterbankSqrt(const uint64_t* input, int num_channels,
29
+ int scale_down_bits, uint32_t* output);
32
30
 
33
- #ifdef __cplusplus
34
- }
35
- #endif
31
+ } // namespace tflm_signal
32
+ } // namespace tflite
36
33
 
37
- #endif // TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MAIN_FUNCTIONS_H_
34
+ #endif // SIGNAL_SRC_FILTER_BANK_SQUARE_ROOT_H_
@@ -0,0 +1,84 @@
1
+ /* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef SIGNAL_SRC_IRFFT_H_
17
+ #define SIGNAL_SRC_IRFFT_H_
18
+
19
+ #include <stddef.h>
20
+ #include <stdint.h>
21
+
22
+ #include "signal/src/complex.h"
23
+
24
+ // TODO(b/286250473): remove namespace once de-duped libraries
25
+ namespace tflite {
26
+ namespace tflm_signal {
27
+
28
+ // IRFFT (Inverse Real Fast Fourier Transform)
29
+ // IFFT for real valued time domain outputs.
30
+
31
+ // 16-bit Integer input/output
32
+
33
+ // Returns the size of the memory that an IRFFT of `fft_length` needs
34
+ size_t IrfftInt16GetNeededMemory(int32_t fft_length);
35
+
36
+ // Initialize the state of an IRFFT of `fft_length`
37
+ // `state` points to an opaque state of size `state_size`, which
38
+ // must be greater or equal to the value returned by
39
+ // IrfftGetNeededMemory(fft_length). Fails if it isn't.
40
+ void* IrfftInt16Init(int32_t fft_length, void* state, size_t state_size);
41
+
42
+ // Applies IRFFT to `input` and writes the result to `output`
43
+ // * `input` must be of size `fft_length` elements (see IRfftInit)
44
+ // * `output` must be of size output
45
+ void IrfftInt16Apply(void* state, const Complex<int16_t>* input,
46
+ int16_t* output);
47
+
48
+ // 32-bit Integer input/output
49
+
50
+ // Returns the size of the memory that an IRFFT of `fft_length` needs
51
+ size_t IrfftInt32GetNeededMemory(int32_t fft_length);
52
+
53
+ // Initialize the state of an IRFFT of `fft_length`
54
+ // `state` points to an opaque state of size `state_size`, which
55
+ // must be greater or equal to the value returned by
56
+ // IrfftGetNeededMemory(fft_length). Fails if it isn't.
57
+ void* IrfftInt32Init(int32_t fft_length, void* state, size_t state_size);
58
+
59
+ // Applies IRFFT to `input` and writes the result to `output`
60
+ // * `input` must be of size `fft_length` elements (see IRfftInit)
61
+ // * `output` must be of size output
62
+ void IrfftInt32Apply(void* state, const Complex<int32_t>* input,
63
+ int32_t* output);
64
+
65
+ // Floating point input/output
66
+
67
+ // Returns the size of the memory that an IRFFT of `fft_length` needs
68
+ size_t IrfftFloatGetNeededMemory(int32_t fft_length);
69
+
70
+ // Initialize the state of an IRFFT of `fft_length`
71
+ // `state` points to an opaque state of size `state_size`, which
72
+ // must be greater or equal to the value returned by
73
+ // IrfftGetNeededMemory(fft_length). Fails if it isn't.
74
+ void* IrfftFloatInit(int32_t fft_length, void* state, size_t state_size);
75
+
76
+ // Applies IRFFT to `input` and writes the result to `output`
77
+ // * `input` must be of size `fft_length` elements (see IRfftInit)
78
+ // * `output` must be of size output
79
+ void IrfftFloatApply(void* state, const Complex<float>* input, float* output);
80
+
81
+ } // namespace tflm_signal
82
+ } // namespace tflite
83
+
84
+ #endif // SIGNAL_SRC_IRFFT_H_
@@ -0,0 +1,49 @@
1
+ /* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef SIGNAL_SRC_KISS_FFT_WRAPPERS_KISS_FFT_COMMON_H_
17
+ #define SIGNAL_SRC_KISS_FFT_WRAPPERS_KISS_FFT_COMMON_H_
18
+
19
+ // This header file should be included in all variants of kiss_fft_$type.{h,cc}
20
+ // so that their sub-included source files do not mistakenly wrap libc header
21
+ // files within their kissfft_$type namespaces.
22
+ // E.g., This header avoids kissfft_int16.h containing:
23
+ // namespace kiss_fft_int16 {
24
+ // #include "kiss_fft.h"
25
+ // }
26
+ // where kiss_fft_.h contains:
27
+ // #include <math.h>
28
+ //
29
+ // TRICK: By including the following header files here, their preprocessor
30
+ // header guards prevent them being re-defined inside of the kiss_fft_$type
31
+ // namespaces declared within the kiss_fft_$type.{h,cc} sources.
32
+ // Note that the original kiss_fft*.h files are untouched since they
33
+ // may be used in libraries that include them directly.
34
+
35
+ #include <limits.h>
36
+ #include <math.h>
37
+ #include <stdio.h>
38
+ #include <stdlib.h>
39
+ #include <string.h>
40
+
41
+ #ifdef FIXED_POINT
42
+ #include <sys/types.h>
43
+ #endif
44
+
45
+ #ifdef USE_SIMD
46
+ #include <xmmintrin.h>
47
+ #endif
48
+
49
+ #endif // SIGNAL_SRC_KISS_FFT_WRAPPERS_KISS_FFT_COMMON_H_
@@ -0,0 +1,31 @@
1
+ /* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef SIGNAL_SRC_KISS_FFT_WRAPPERS_KISS_FFT_FLOAT_H_
17
+ #define SIGNAL_SRC_KISS_FFT_WRAPPERS_KISS_FFT_FLOAT_H_
18
+
19
+ #include "signal/src/kiss_fft_wrappers/kiss_fft_common.h"
20
+
21
+ // Wrap floating point kiss fft in its own namespace. Enables us to link an
22
+ // application with different kiss fft resolutions
23
+ // (16/32 bit integer, float, double) without getting a linker error.
24
+ #undef FIXED_POINT
25
+ namespace kiss_fft_float {
26
+ #include "kiss_fft.h"
27
+ #include "tools/kiss_fftr.h"
28
+ } // namespace kiss_fft_float
29
+ #undef FIXED_POINT
30
+
31
+ #endif // SIGNAL_SRC_KISS_FFT_WRAPPERS_KISS_FFT_FLOAT_H_
@@ -0,0 +1,30 @@
1
+ /* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef SIGNAL_SRC_KISS_FFT_WRAPPERS_KISS_FFT_INT16_H_
17
+ #define SIGNAL_SRC_KISS_FFT_WRAPPERS_KISS_FFT_INT16_H_
18
+
19
+ #include "signal/src/kiss_fft_wrappers/kiss_fft_common.h"
20
+ // Wrap floating point kiss fft in its own namespace. Enables us to link an
21
+ // application with different kiss fft resolutions
22
+ // (16/32 bit integer, float, double) without getting a linker error.
23
+ #define FIXED_POINT 16
24
+ namespace kiss_fft_fixed16 {
25
+ #include "kiss_fft.h"
26
+ #include "tools/kiss_fftr.h"
27
+ } // namespace kiss_fft_fixed16
28
+ #undef FIXED_POINT
29
+
30
+ #endif // SIGNAL_SRC_KISS_FFT_WRAPPERS_KISS_FFT_INT16_H_
@@ -0,0 +1,31 @@
1
+ /* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+ ==============================================================================*/
15
+
16
+ #ifndef SIGNAL_SRC_KISS_FFT_WRAPPERS_KISS_FFT_INT32_H_
17
+ #define SIGNAL_SRC_KISS_FFT_WRAPPERS_KISS_FFT_INT32_H_
18
+
19
+ #include "signal/src/kiss_fft_wrappers/kiss_fft_common.h"
20
+
21
+ // Wrap floating point kiss fft in its own namespace. Enables us to link an
22
+ // application with different kiss fft resolutions
23
+ // (16/32 bit integer, float, double) without getting a linker error.
24
+ #define FIXED_POINT 32
25
+ namespace kiss_fft_fixed32 {
26
+ #include "kiss_fft.h"
27
+ #include "tools/kiss_fftr.h"
28
+ } // namespace kiss_fft_fixed32
29
+ #undef FIXED_POINT
30
+
31
+ #endif // SIGNAL_SRC_KISS_FFT_WRAPPERS_KISS_FFT_INT32_H_
@@ -13,11 +13,18 @@ See the License for the specific language governing permissions and
13
13
  limitations under the License.
14
14
  ==============================================================================*/
15
15
 
16
- #ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MICRO_FEATURES_NO_MICRO_FEATURES_DATA_H_
17
- #define TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MICRO_FEATURES_NO_MICRO_FEATURES_DATA_H_
16
+ #ifndef SIGNAL_SRC_LOG_H_
17
+ #define SIGNAL_SRC_LOG_H_
18
18
 
19
- extern const int g_no_micro_f9643d42_nohash_4_width;
20
- extern const int g_no_micro_f9643d42_nohash_4_height;
21
- extern const signed char g_no_micro_f9643d42_nohash_4_data[];
19
+ #include <stdint.h>
22
20
 
23
- #endif // TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MICRO_FEATURES_NO_MICRO_FEATURES_DATA_H_
21
+ namespace tflite {
22
+ namespace tflm_signal {
23
+ // TODO(b/286250473): remove namespace once de-duped libraries above
24
+
25
+ // Natural logarithm of an integer. The result is multiplied by out_scale
26
+ uint32_t Log32(uint32_t x, uint32_t out_scale);
27
+
28
+ } // namespace tflm_signal
29
+ } // namespace tflite
30
+ #endif // SIGNAL_SRC_LOG_H_
@@ -1,4 +1,4 @@
1
- /* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
1
+ /* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
@@ -12,20 +12,20 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  See the License for the specific language governing permissions and
13
13
  limitations under the License.
14
14
  ==============================================================================*/
15
- #ifndef TENSORFLOW_LITE_MICRO_TOOLS_PYTHON_INTERPRETER_PYTHON_UTILS_H_
16
- #define TENSORFLOW_LITE_MICRO_TOOLS_PYTHON_INTERPRETER_PYTHON_UTILS_H_
17
15
 
18
- #include <Python.h>
16
+ #ifndef SIGNAL_SRC_MAX_ABS_H_
17
+ #define SIGNAL_SRC_MAX_ABS_H_
19
18
 
20
- namespace tflite {
19
+ #include <stdint.h>
21
20
 
22
- struct PyDecrefDeleter {
23
- void operator()(PyObject* p) const { Py_DECREF(p); }
24
- };
21
+ // TODO(b/286250473): remove namespace once de-duped libraries
22
+ namespace tflite {
23
+ namespace tflm_signal {
25
24
 
26
- int ConvertFromPyString(PyObject* obj, char** data, Py_ssize_t* length);
27
- PyObject* ConvertToPyString(const char* data, size_t length);
25
+ // Returns the maximum absolute value of the `size` elements in `input`
26
+ int16_t MaxAbs16(const int16_t* input, int size);
28
27
 
28
+ } // namespace tflm_signal
29
29
  } // namespace tflite
30
30
 
31
- #endif
31
+ #endif // SIGNAL_SRC_MAX_ABS_H_
@@ -13,11 +13,20 @@ See the License for the specific language governing permissions and
13
13
  limitations under the License.
14
14
  ==============================================================================*/
15
15
 
16
- #ifndef TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MICRO_FEATURES_YES_MICRO_FEATURES_DATA_H_
17
- #define TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MICRO_FEATURES_YES_MICRO_FEATURES_DATA_H_
16
+ #ifndef SIGNAL_SRC_MSB_H_
17
+ #define SIGNAL_SRC_MSB_H_
18
18
 
19
- extern const int g_yes_micro_f2e59fea_nohash_1_width;
20
- extern const int g_yes_micro_f2e59fea_nohash_1_height;
21
- extern const signed char g_yes_micro_f2e59fea_nohash_1_data[];
19
+ #include <stdint.h>
22
20
 
23
- #endif // TENSORFLOW_LITE_MICRO_EXAMPLES_MICRO_SPEECH_MICRO_FEATURES_YES_MICRO_FEATURES_DATA_H_
21
+ namespace tflite {
22
+ namespace tflm_signal {
23
+ // TODO(b/286250473): remove namespace once de-duped libraries above
24
+
25
+ // Index of the most significant bit
26
+ uint32_t MostSignificantBit32(uint32_t x);
27
+ uint32_t MostSignificantBit64(uint64_t x);
28
+
29
+ } // namespace tflm_signal
30
+ } // namespace tflite
31
+
32
+ #endif // SIGNAL_SRC_MSB_H_