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,46 @@
1
+ /* Copyright 2021 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
+ #ifndef SIGNAL_SRC_OVERLAP_ADD_H_
16
+ #define SIGNAL_SRC_OVERLAP_ADD_H_
17
+
18
+ #include <stddef.h>
19
+ #include <stdint.h>
20
+
21
+ namespace tflm_signal {
22
+ // Adds (with saturation) the contents of `input` to the contents of `buffer`,
23
+ // both of size `input_size`, then copies the first `output_size` elements of
24
+ // `buffer` to `output`, shifts the last `input_size`-`output_size` elements of
25
+ // `buffer` to the beginning of `buffer` and fills the trailing `output_size`
26
+ // samples in `buffer` with zeros.
27
+ // input: {input[0] ... input[input_size-1]}
28
+ // buffer: {buffer[0] ... buffer[input_size-1]}
29
+ // After invocation:
30
+ // output: {saturate(input[0] + buffer[0]),
31
+ // ... ,
32
+ // saturate(input[output_size-1] + buffer[output_size-1])}
33
+ // buffer: {saturate(input[output_size] + buffer[output_size]),
34
+ // ...
35
+ // saturate( input[input_size-output_size-1]
36
+ // + buffer[input_size-output_size-1]),
37
+ // zeros(output_size)}
38
+ void OverlapAdd(const int16_t* input, int16_t* buffer, int input_size,
39
+ int16_t* output, int output_size);
40
+
41
+ // The same as the int16_t variant above, but without saturation
42
+ void OverlapAdd(const float* input, float* buffer, int input_size,
43
+ float* output, int output_size);
44
+
45
+ } // namespace tflm_signal
46
+ #endif // SIGNAL_SRC_OVERLAP_ADD_H_
@@ -0,0 +1,41 @@
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_MICRO_KERNELS__SRC_PCAN_AGC_FIXED_H
17
+ #define SIGNAL_MICRO_KERNELS__SRC_PCAN_AGC_FIXED_H
18
+ #include <cstdint>
19
+
20
+ #include "msb.h"
21
+ #include "tensorflow/lite/kernels/internal/compatibility.h"
22
+
23
+ namespace tflite {
24
+ namespace tflm_signal {
25
+
26
+ #define kPcanSnrBits 12
27
+ #define kPcanOutputBits 6
28
+
29
+ int16_t WideDynamicFunction(const uint32_t x, const int16_t* lut);
30
+
31
+ uint32_t PcanShrink(const uint32_t x);
32
+
33
+ void ApplyPcanAutoGainControlFixed(const int16_t* gain_lut, int32_t snr_shift,
34
+ const uint32_t* noise_estimate,
35
+ uint32_t* filterbank_output,
36
+ int num_channels);
37
+
38
+ } // namespace tflm_signal
39
+ } // namespace tflite
40
+
41
+ #endif // SIGNAL_MICRO_KERNELS__PCAN_AGC_FIXED_H
@@ -0,0 +1,85 @@
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_RFFT_H_
17
+ #define SIGNAL_SRC_RFFT_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 tflm_signal {
26
+
27
+ // RFFT (Real Fast Fourier Transform)
28
+ // FFT for real valued time domain inputs.
29
+
30
+ // 16-bit Integer input/output
31
+
32
+ // Returns the size of the memory that an RFFT of `fft_length` needs
33
+ size_t RfftInt16GetNeededMemory(int32_t fft_length);
34
+
35
+ // Initialize the state of an RFFT of `fft_length`
36
+ // `state` points to an opaque state of size `state_size`, which
37
+ // must be greater or equal to the value returned by
38
+ // RfftGetNeededMemory(fft_length).
39
+ // Return the value of `state` on success or nullptr on failure
40
+ void* RfftInt16Init(int32_t fft_length, void* state, size_t state_size);
41
+
42
+ // Applies RFFT to `input` and writes the result to `output`
43
+ // * `input` must be of size `fft_length` elements (see RfftInit)
44
+ // * `output` must be of size (`fft_length` * 2) + 1 elements
45
+ void RfftInt16Apply(void* state, const int16_t* input,
46
+ Complex<int16_t>* output);
47
+
48
+ // 32-bit Integer input/output
49
+
50
+ // Returns the size of the memory that an RFFT of `fft_length` needs
51
+ size_t RfftInt32GetNeededMemory(int32_t fft_length);
52
+
53
+ // Initialize the state of an RFFT 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
+ // RfftGetNeededMemory(fft_length).
57
+ // Return the value of `state` on success or nullptr on failure
58
+ void* RfftInt32Init(int32_t fft_length, void* state, size_t state_size);
59
+
60
+ // Applies RFFT to `input` and writes the result to `output`
61
+ // * `input` must be of size `fft_length` elements (see RfftInit)
62
+ // * `output` must be of size (`fft_length` * 2) + 1 elements
63
+ void RfftInt32Apply(void* state, const int32_t* input,
64
+ Complex<int32_t>* output);
65
+
66
+ // Floating point input/output
67
+
68
+ // Returns the size of the memory that an RFFT of `fft_length` needs
69
+ size_t RfftFloatGetNeededMemory(int32_t fft_length);
70
+
71
+ // Initialize the state of an RFFT of `fft_length`
72
+ // `state` points to an opaque state of size `state_size`, which
73
+ // must be greater or equal to the value returned by
74
+ // RfftGetNeededMemory(fft_length).
75
+ // Return the value of `state` on success or nullptr on failure
76
+ void* RfftFloatInit(int32_t fft_length, void* state, size_t state_size);
77
+
78
+ // Applies RFFT to `input` and writes the result to `output`
79
+ // * `input` must be of size `fft_length` elements (see RfftInit)
80
+ // * `output` must be of size (`fft_length` * 2) + 1 elements
81
+ void RfftFloatApply(void* state, const float* input, Complex<float>* output);
82
+
83
+ } // namespace tflm_signal
84
+
85
+ #endif // SIGNAL_SRC_RFFT_H_
@@ -0,0 +1,32 @@
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_SQUARE_ROOT_H_
17
+ #define SIGNAL_SRC_SQUARE_ROOT_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
+ // Square root
26
+ uint16_t Sqrt32(uint32_t num);
27
+ uint32_t Sqrt64(uint64_t num);
28
+
29
+ } // namespace tflm_signal
30
+ } // namespace tflite
31
+
32
+ #endif // SIGNAL_SRC_SQUARE_ROOT_H_
@@ -12,22 +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_NUMPY_UTILS_H_
16
- #define TENSORFLOW_LITE_MICRO_TOOLS_PYTHON_INTERPRETER_NUMPY_UTILS_H_
17
15
 
18
- // Disallow Numpy 1.7 deprecated symbols.
19
- #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
20
- #include <numpy/ndarraytypes.h>
16
+ #ifndef SIGNAL_SRC_WINDOW_H_
17
+ #define SIGNAL_SRC_WINDOW_H_
21
18
 
22
- #include "tensorflow/lite/c/c_api_types.h"
19
+ #include <stdint.h>
23
20
 
24
- namespace tflite {
21
+ namespace tflm_signal {
25
22
 
26
- void* ImportNumpy();
27
- int TfLiteTypeToPyArrayType(TfLiteType tf_lite_type);
28
- TfLiteType TfLiteTypeFromPyType(int py_type);
29
- TfLiteType TfLiteTypeFromPyArray(const PyArrayObject* array);
30
-
31
- } // namespace tflite
32
-
33
- #endif
23
+ // Applies a window function to an input signal
24
+ //
25
+ // * `input` and `window` must be both of size `size` elements and are
26
+ // multiplied element-by element.
27
+ // * `shift` is a right shift to apply before writing the result to `output`.
28
+ void ApplyWindow(const int16_t* input, const int16_t* window, int size,
29
+ int shift, int16_t* output);
30
+ } // namespace tflm_signal
31
+ #endif // SIGNAL_SRC_WINDOW_H_
@@ -0,0 +1,48 @@
1
+ /* Copyright 2021 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
+ #ifndef SIGNAL_TESTDATA_FFT_TEST_DATA_H_
16
+ #define SIGNAL_TESTDATA_FFT_TEST_DATA_H_
17
+
18
+ #include <cstdint>
19
+
20
+ namespace tflite {
21
+
22
+ /* These arrays are generated using random data. They serve to detect changes
23
+ * in the kernels. They do not test correctness.
24
+ */
25
+ extern const int16_t kRfftInt16Length512Input[];
26
+ extern const int16_t kRfftInt16Length512Golden[];
27
+
28
+ extern const int32_t kRfftInt32Length512Input[];
29
+ extern const int32_t kRfftInt32Length512Golden[];
30
+
31
+ extern const float kRfftFloatLength512Input[];
32
+ extern const float kRfftFloatLength512Golden[];
33
+
34
+ extern const int16_t kIrfftInt16Length512Input[];
35
+ extern const int16_t kIrfftInt16Length512Golden[];
36
+
37
+ extern const int32_t kIrfftInt32Length512Input[];
38
+ extern const int32_t kIrfftInt32Length512Golden[];
39
+
40
+ extern const float kIrfftFloatLength512Input[];
41
+ extern const float kIrfftFloatLength512Golden[];
42
+
43
+ extern const int16_t kFftAutoScaleLength512Input[];
44
+ extern const int16_t kFftAutoScaleLength512Golden[];
45
+
46
+ } // namespace tflite
47
+
48
+ #endif // SIGNAL_TESTDATA_FFT_TEST_DATA_H_
@@ -0,0 +1,156 @@
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
+ #ifndef TENSORFLOW_LITE_ARRAY_H_
16
+ #define TENSORFLOW_LITE_ARRAY_H_
17
+
18
+ #include <cstring>
19
+ #include <initializer_list>
20
+ #include <memory>
21
+ #include <type_traits>
22
+ #include <vector>
23
+
24
+ #include "tensorflow/lite/core/c/common.h"
25
+
26
+ namespace tflite {
27
+
28
+ /// TfLite*Array helpers
29
+
30
+ namespace array_internal {
31
+
32
+ // Function object used as a deleter for unique_ptr holding TFLite*Array
33
+ // objects.
34
+ struct TfLiteArrayDeleter {
35
+ void operator()(TfLiteIntArray* a);
36
+ void operator()(TfLiteFloatArray* a);
37
+ };
38
+
39
+ // Maps T to the corresponding TfLiteArray type.
40
+ template <class T>
41
+ struct TfLiteArrayInfo;
42
+
43
+ template <>
44
+ struct TfLiteArrayInfo<int> {
45
+ using Type = TfLiteIntArray;
46
+ };
47
+
48
+ template <>
49
+ struct TfLiteArrayInfo<float> {
50
+ using Type = TfLiteFloatArray;
51
+ };
52
+
53
+ } // namespace array_internal
54
+
55
+ template <class T>
56
+ using TfLiteArrayUniquePtr =
57
+ std::unique_ptr<typename array_internal::TfLiteArrayInfo<T>::Type,
58
+ array_internal::TfLiteArrayDeleter>;
59
+
60
+ // `unique_ptr` wrapper for `TfLiteIntArray`s.
61
+ using IntArrayUniquePtr = TfLiteArrayUniquePtr<int>;
62
+
63
+ // `unique_ptr` wrapper for `TfLiteFloatArray`s.
64
+ using FloatArrayUniquePtr = TfLiteArrayUniquePtr<float>;
65
+
66
+ // Allocates a TfLiteArray of given size using malloc.
67
+ //
68
+ // This builds an int array by default as this is the overwhelming part of the
69
+ // use cases.
70
+ template <class T = int>
71
+ TfLiteArrayUniquePtr<T> BuildTfLiteArray(int size);
72
+
73
+ // Allocates a TfLiteIntArray of given size using malloc.
74
+ template <>
75
+ inline IntArrayUniquePtr BuildTfLiteArray<int>(const int size) {
76
+ return IntArrayUniquePtr(TfLiteIntArrayCreate(size));
77
+ }
78
+
79
+ // Allocates a TfLiteFloatArray of given size using malloc.
80
+ template <>
81
+ inline FloatArrayUniquePtr BuildTfLiteArray<float>(const int size) {
82
+ return FloatArrayUniquePtr(TfLiteFloatArrayCreate(size));
83
+ }
84
+
85
+ // Allocates a TFLiteArray of given size and initializes it with the given
86
+ // values.
87
+ //
88
+ // `values` is expected to holds `size` elements.
89
+ //
90
+ // If T is explicitely specified and the type of values is not the same as T,
91
+ // then a static_cast is performed.
92
+ template <class T = void, class U,
93
+ class Type = std::conditional_t<std::is_same<T, void>::value, U, T>>
94
+ TfLiteArrayUniquePtr<Type> BuildTfLiteArray(const int size,
95
+ const U* const values) {
96
+ TfLiteArrayUniquePtr<Type> array = BuildTfLiteArray<Type>(size);
97
+ // If size is 0, the array pointer may be null.
98
+ if (array && values) {
99
+ if (std::is_same<Type, U>::value) {
100
+ memcpy(array->data, values, size * sizeof(Type));
101
+ } else {
102
+ for (int i = 0; i < size; ++i) {
103
+ array->data[i] = static_cast<Type>(values[i]);
104
+ }
105
+ }
106
+ }
107
+ return array;
108
+ }
109
+
110
+ // Allocates a TFLiteArray and initializes it with the given array.
111
+ //
112
+ // `values` is expected to holds `size` elements.
113
+ template <class T, size_t N>
114
+ TfLiteArrayUniquePtr<T> BuildTfLiteArray(const T (&values)[N]) {
115
+ return BuildTfLiteArray<T>(static_cast<int>(N), values);
116
+ }
117
+
118
+ // Allocates a TFLiteArray and initializes it with the given values.
119
+ //
120
+ // This uses SFINAE to only be picked up by for types that implement `data()`
121
+ // and `size()` member functions. We cannot reuse detection facilities provided
122
+ // by Abseil in this code.
123
+ //
124
+ // To conform with the other overloads, we allow specifying the type of the
125
+ // array as well as deducing it from the container.
126
+ template <
127
+ class T = void, class Container,
128
+ class ElementType =
129
+ std::decay_t<decltype(*std::declval<Container>().data())>,
130
+ class SizeType = std::decay_t<decltype(std::declval<Container>().size())>,
131
+ class Type =
132
+ std::conditional_t<std::is_same<T, void>::value, ElementType, T>>
133
+ TfLiteArrayUniquePtr<Type> BuildTfLiteArray(const Container& values) {
134
+ return BuildTfLiteArray<Type>(static_cast<int>(values.size()), values.data());
135
+ }
136
+
137
+ // Allocates a TFLiteArray and initializes it with the given values.
138
+ template <class T>
139
+ TfLiteArrayUniquePtr<T> BuildTfLiteArray(
140
+ const std::initializer_list<T>& values) {
141
+ return BuildTfLiteArray(static_cast<int>(values.size()), values.begin());
142
+ }
143
+
144
+ // Allocates a TFLiteArray and initializes it with the given array.
145
+ inline IntArrayUniquePtr BuildTfLiteArray(const TfLiteIntArray& other) {
146
+ return BuildTfLiteArray(other.size, other.data);
147
+ }
148
+
149
+ // Allocates a TFLiteArray and initializes it with the given array.
150
+ inline FloatArrayUniquePtr BuildTfLiteArray(const TfLiteFloatArray& other) {
151
+ return BuildTfLiteArray(other.size, other.data);
152
+ }
153
+
154
+ } // namespace tflite
155
+
156
+ #endif // TENSORFLOW_LITE_ARRAY_H_
@@ -189,6 +189,50 @@ typedef enum {
189
189
  kTfLiteBuiltinBitcast = 159,
190
190
  kTfLiteBuiltinBitwiseXor = 160,
191
191
  kTfLiteBuiltinRightShift = 161,
192
+ kTfLiteBuiltinStablehloLogistic = 162,
193
+ kTfLiteBuiltinStablehloAdd = 163,
194
+ kTfLiteBuiltinStablehloDivide = 164,
195
+ kTfLiteBuiltinStablehloMultiply = 165,
196
+ kTfLiteBuiltinStablehloMaximum = 166,
197
+ kTfLiteBuiltinStablehloReshape = 167,
198
+ kTfLiteBuiltinStablehloClamp = 168,
199
+ kTfLiteBuiltinStablehloConcatenate = 169,
200
+ kTfLiteBuiltinStablehloBroadcastInDim = 170,
201
+ kTfLiteBuiltinStablehloConvolution = 171,
202
+ kTfLiteBuiltinStablehloSlice = 172,
203
+ kTfLiteBuiltinStablehloCustomCall = 173,
204
+ kTfLiteBuiltinStablehloReduce = 174,
205
+ kTfLiteBuiltinStablehloAbs = 175,
206
+ kTfLiteBuiltinStablehloAnd = 176,
207
+ kTfLiteBuiltinStablehloCosine = 177,
208
+ kTfLiteBuiltinStablehloExponential = 178,
209
+ kTfLiteBuiltinStablehloFloor = 179,
210
+ kTfLiteBuiltinStablehloLog = 180,
211
+ kTfLiteBuiltinStablehloMinimum = 181,
212
+ kTfLiteBuiltinStablehloNegate = 182,
213
+ kTfLiteBuiltinStablehloOr = 183,
214
+ kTfLiteBuiltinStablehloPower = 184,
215
+ kTfLiteBuiltinStablehloRemainder = 185,
216
+ kTfLiteBuiltinStablehloRsqrt = 186,
217
+ kTfLiteBuiltinStablehloSelect = 187,
218
+ kTfLiteBuiltinStablehloSubtract = 188,
219
+ kTfLiteBuiltinStablehloTanh = 189,
220
+ kTfLiteBuiltinStablehloScatter = 190,
221
+ kTfLiteBuiltinStablehloCompare = 191,
222
+ kTfLiteBuiltinStablehloConvert = 192,
223
+ kTfLiteBuiltinStablehloDynamicSlice = 193,
224
+ kTfLiteBuiltinStablehloDynamicUpdateSlice = 194,
225
+ kTfLiteBuiltinStablehloPad = 195,
226
+ kTfLiteBuiltinStablehloIota = 196,
227
+ kTfLiteBuiltinStablehloDotGeneral = 197,
228
+ kTfLiteBuiltinStablehloReduceWindow = 198,
229
+ kTfLiteBuiltinStablehloSort = 199,
230
+ kTfLiteBuiltinStablehloWhile = 200,
231
+ kTfLiteBuiltinStablehloGather = 201,
232
+ kTfLiteBuiltinStablehloTranspose = 202,
233
+ kTfLiteBuiltinDilate = 203,
234
+ kTfLiteBuiltinStablehloRngBitGenerator = 204,
235
+ kTfLiteBuiltinReduceWindow = 205,
192
236
  } TfLiteBuiltinOperator;
193
237
 
194
238
  #ifdef __cplusplus
@@ -15,6 +15,12 @@ limitations under the License.
15
15
  #ifndef TENSORFLOW_LITE_C_C_API_TYPES_H_
16
16
  #define TENSORFLOW_LITE_C_C_API_TYPES_H_
17
17
 
18
+ /// \file
19
+ ///
20
+ /// C API types for TensorFlow Lite.
21
+ ///
22
+ /// For documentation, see tensorflow/lite/core/c/c_api_types.h
23
+
18
24
  #include "tensorflow/lite/core/c/c_api_types.h"
19
25
 
20
26
  #endif // TENSORFLOW_LITE_C_C_API_TYPES_H_
@@ -13,35 +13,18 @@ See the License for the specific language governing permissions and
13
13
  limitations under the License.
14
14
  ==============================================================================*/
15
15
 
16
- // This file defines common C types and APIs for implementing operations,
17
- // delegates and other constructs in TensorFlow Lite. The actual operations and
18
- // delegates can be defined using C++, but the interface between the interpreter
19
- // and the operations are C.
20
- //
21
- // Summary of abstractions
22
- // TF_LITE_ENSURE - Self-sufficient error checking
23
- // TfLiteStatus - Status reporting
24
- // TfLiteIntArray - stores tensor shapes (dims),
25
- // TfLiteContext - allows an op to access the tensors
26
- // TfLiteTensor - tensor (a multidimensional array)
27
- // TfLiteNode - a single node or operation
28
- // TfLiteRegistration - the implementation of a conceptual operation.
29
- // TfLiteDelegate - allows delegation of nodes to alternative backends.
30
- //
31
- // Some abstractions in this file are created and managed by Interpreter.
32
- //
33
- // NOTE: The order of values in these structs are "semi-ABI stable". New values
34
- // should be added only to the end of structs and never reordered.
16
+ /// \file
17
+ ///
18
+ /// This file defines common C types and APIs for implementing operations,
19
+ /// delegates and other constructs in TensorFlow Lite. The actual operations and
20
+ /// delegates can be defined using C++, but the interface between the
21
+ /// interpreter and the operations are C.
22
+ ///
23
+ /// For documentation, see tensorflow/lite/core/c/common.h.
35
24
 
36
25
  #ifndef TENSORFLOW_LITE_C_COMMON_H_
37
26
  #define TENSORFLOW_LITE_C_COMMON_H_
38
27
 
39
28
  #include "tensorflow/lite/core/c/common.h"
40
29
 
41
- // TfLiteOpaqueDelegate: allows delegation of nodes to alternative backends.
42
- // TfLiteOpaqueDelegate is an abstract type that is intended to have the same
43
- // role as TfLiteDelegate, but without necessarily exposing the implementation
44
- // details of how delegates are implemented.
45
- typedef TfLiteDelegate TfLiteOpaqueDelegate;
46
-
47
30
  #endif // TENSORFLOW_LITE_C_COMMON_H_
@@ -61,9 +61,9 @@ class ErrorReporter {
61
61
  // reduce binary size, define TF_LITE_STRIP_ERROR_STRINGS when compiling and
62
62
  // every call will be stubbed out, taking no memory.
63
63
  #ifndef TF_LITE_STRIP_ERROR_STRINGS
64
- #define TF_LITE_REPORT_ERROR(reporter, ...) \
65
- do { \
66
- static_cast<tflite::ErrorReporter*>(reporter)->Report(__VA_ARGS__); \
64
+ #define TF_LITE_REPORT_ERROR(reporter, ...) \
65
+ do { \
66
+ static_cast<::tflite::ErrorReporter*>(reporter)->Report(__VA_ARGS__); \
67
67
  } while (false)
68
68
  #else // TF_LITE_STRIP_ERROR_STRINGS
69
69
  #define TF_LITE_REPORT_ERROR(reporter, ...)
@@ -420,6 +420,21 @@ TfLiteStatus ParseRightShift(const Operator* op, ErrorReporter* error_reporter,
420
420
  BuiltinDataAllocator* allocator,
421
421
  void** builtin_data);
422
422
 
423
+ TfLiteStatus ParseStablehloScatter(const Operator* op,
424
+ ErrorReporter* error_reporter,
425
+ BuiltinDataAllocator* allocator,
426
+ void** builtin_data);
427
+
428
+ TfLiteStatus ParseStablehloRngBitGenerator(const Operator* op,
429
+ ErrorReporter* error_reporter,
430
+ BuiltinDataAllocator* allocator,
431
+ void** builtin_data);
432
+
433
+ TfLiteStatus ParseStablehloGather(const Operator* op,
434
+ ErrorReporter* error_reporter,
435
+ BuiltinDataAllocator* allocator,
436
+ void** builtin_data);
437
+
423
438
  } // namespace tflite
424
439
 
425
440
  #endif // TENSORFLOW_LITE_CORE_API_FLATBUFFER_CONVERSIONS_H_