├── .clang-format ├── .gitignore ├── LICENSE.3-clause-bsd-clear ├── README.md ├── arduino-build.sh ├── arduino-win-build.bat ├── boards.local.txt ├── firmware-arduino-nano-33-ble-sense.ino └── src ├── edge-impulse-sdk ├── .gitignore ├── .mbedignore ├── CMSIS │ ├── Core │ │ └── Include │ │ │ ├── cachel1_armv7.h │ │ │ ├── cmsis_armcc.h │ │ │ ├── cmsis_armclang.h │ │ │ ├── cmsis_armclang_ltm.h │ │ │ ├── cmsis_compiler.h │ │ │ ├── cmsis_gcc.h │ │ │ ├── cmsis_iccarm.h │ │ │ ├── cmsis_version.h │ │ │ ├── core_armv81mml.h │ │ │ ├── core_armv8mbl.h │ │ │ ├── core_armv8mml.h │ │ │ ├── core_cm0.h │ │ │ ├── core_cm0plus.h │ │ │ ├── core_cm1.h │ │ │ ├── core_cm23.h │ │ │ ├── core_cm3.h │ │ │ ├── core_cm33.h │ │ │ ├── core_cm35p.h │ │ │ ├── core_cm4.h │ │ │ ├── core_cm55.h │ │ │ ├── core_cm7.h │ │ │ ├── core_cm85.h │ │ │ ├── core_sc000.h │ │ │ ├── core_sc300.h │ │ │ ├── core_starmc1.h │ │ │ ├── mpu_armv7.h │ │ │ ├── mpu_armv8.h │ │ │ ├── pac_armv81.h │ │ │ ├── pmu_armv8.h │ │ │ └── tz_context.h │ ├── DSP │ │ ├── Include │ │ │ ├── arm_common_tables.h │ │ │ ├── arm_common_tables_f16.h │ │ │ ├── arm_const_structs.h │ │ │ ├── arm_const_structs_f16.h │ │ │ ├── arm_helium_utils.h │ │ │ ├── arm_math.h │ │ │ ├── arm_math_f16.h │ │ │ ├── arm_math_memory.h │ │ │ ├── arm_math_types.h │ │ │ ├── arm_math_types_f16.h │ │ │ ├── arm_mve_tables.h │ │ │ ├── arm_mve_tables_f16.h │ │ │ ├── arm_sorting.h │ │ │ ├── arm_vec_fft.h │ │ │ ├── arm_vec_filtering.h │ │ │ ├── arm_vec_math.h │ │ │ ├── arm_vec_math_f16.h │ │ │ └── dsp │ │ │ │ ├── basic_math_functions.h │ │ │ │ ├── basic_math_functions_f16.h │ │ │ │ ├── bayes_functions.h │ │ │ │ ├── bayes_functions_f16.h │ │ │ │ ├── complex_math_functions.h │ │ │ │ ├── complex_math_functions_f16.h │ │ │ │ ├── controller_functions.h │ │ │ │ ├── controller_functions_f16.h │ │ │ │ ├── debug.h │ │ │ │ ├── distance_functions.h │ │ │ │ ├── distance_functions_f16.h │ │ │ │ ├── fast_math_functions.h │ │ │ │ ├── fast_math_functions_f16.h │ │ │ │ ├── filtering_functions.h │ │ │ │ ├── filtering_functions_f16.h │ │ │ │ ├── interpolation_functions.h │ │ │ │ ├── interpolation_functions_f16.h │ │ │ │ ├── matrix_functions.h │ │ │ │ ├── matrix_functions_f16.h │ │ │ │ ├── matrix_utils.h │ │ │ │ ├── none.h │ │ │ │ ├── quaternion_math_functions.h │ │ │ │ ├── statistics_functions.h │ │ │ │ ├── statistics_functions_f16.h │ │ │ │ ├── support_functions.h │ │ │ │ ├── support_functions_f16.h │ │ │ │ ├── svm_defines.h │ │ │ │ ├── svm_functions.h │ │ │ │ ├── svm_functions_f16.h │ │ │ │ ├── transform_functions.h │ │ │ │ ├── transform_functions_f16.h │ │ │ │ └── utils.h │ │ ├── PrivateInclude │ │ │ └── README.md │ │ └── Source │ │ │ ├── BasicMathFunctions │ │ │ ├── arm_abs_f16.c │ │ │ ├── arm_abs_f32.c │ │ │ ├── arm_abs_f64.c │ │ │ ├── arm_abs_q15.c │ │ │ ├── arm_abs_q31.c │ │ │ ├── arm_abs_q7.c │ │ │ ├── arm_add_f16.c │ │ │ ├── arm_add_f32.c │ │ │ ├── arm_add_f64.c │ │ │ ├── arm_add_q15.c │ │ │ ├── arm_add_q31.c │ │ │ ├── arm_add_q7.c │ │ │ ├── arm_and_u16.c │ │ │ ├── arm_and_u32.c │ │ │ ├── arm_and_u8.c │ │ │ ├── arm_clip_f16.c │ │ │ ├── arm_clip_f32.c │ │ │ ├── arm_clip_q15.c │ │ │ ├── arm_clip_q31.c │ │ │ ├── arm_clip_q7.c │ │ │ ├── arm_dot_prod_f16.c │ │ │ ├── arm_dot_prod_f32.c │ │ │ ├── arm_dot_prod_f64.c │ │ │ ├── arm_dot_prod_q15.c │ │ │ ├── arm_dot_prod_q31.c │ │ │ ├── arm_dot_prod_q7.c │ │ │ ├── arm_mult_f16.c │ │ │ ├── arm_mult_f32.c │ │ │ ├── arm_mult_f64.c │ │ │ ├── arm_mult_q15.c │ │ │ ├── arm_mult_q31.c │ │ │ ├── arm_mult_q7.c │ │ │ ├── arm_negate_f16.c │ │ │ ├── arm_negate_f32.c │ │ │ ├── arm_negate_f64.c │ │ │ ├── arm_negate_q15.c │ │ │ ├── arm_negate_q31.c │ │ │ ├── arm_negate_q7.c │ │ │ ├── arm_not_u16.c │ │ │ ├── arm_not_u32.c │ │ │ ├── arm_not_u8.c │ │ │ ├── arm_offset_f16.c │ │ │ ├── arm_offset_f32.c │ │ │ ├── arm_offset_f64.c │ │ │ ├── arm_offset_q15.c │ │ │ ├── arm_offset_q31.c │ │ │ ├── arm_offset_q7.c │ │ │ ├── arm_or_u16.c │ │ │ ├── arm_or_u32.c │ │ │ ├── arm_or_u8.c │ │ │ ├── arm_scale_f16.c │ │ │ ├── arm_scale_f32.c │ │ │ ├── arm_scale_f64.c │ │ │ ├── arm_scale_q15.c │ │ │ ├── arm_scale_q31.c │ │ │ ├── arm_scale_q7.c │ │ │ ├── arm_shift_q15.c │ │ │ ├── arm_shift_q31.c │ │ │ ├── arm_shift_q7.c │ │ │ ├── arm_sub_f16.c │ │ │ ├── arm_sub_f32.c │ │ │ ├── arm_sub_f64.c │ │ │ ├── arm_sub_q15.c │ │ │ ├── arm_sub_q31.c │ │ │ ├── arm_sub_q7.c │ │ │ ├── arm_xor_u16.c │ │ │ ├── arm_xor_u32.c │ │ │ └── arm_xor_u8.c │ │ │ ├── BayesFunctions │ │ │ ├── arm_gaussian_naive_bayes_predict_f16.c │ │ │ └── arm_gaussian_naive_bayes_predict_f32.c │ │ │ ├── CommonTables │ │ │ ├── arm_common_tables.c │ │ │ ├── arm_common_tables_f16.c │ │ │ ├── arm_const_structs.c │ │ │ ├── arm_const_structs_f16.c │ │ │ ├── arm_mve_tables.c │ │ │ └── arm_mve_tables_f16.c │ │ │ ├── ComplexMathFunctions │ │ │ ├── arm_cmplx_conj_f16.c │ │ │ ├── arm_cmplx_conj_f32.c │ │ │ ├── arm_cmplx_conj_q15.c │ │ │ ├── arm_cmplx_conj_q31.c │ │ │ ├── arm_cmplx_dot_prod_f16.c │ │ │ ├── arm_cmplx_dot_prod_f32.c │ │ │ ├── arm_cmplx_dot_prod_q15.c │ │ │ ├── arm_cmplx_dot_prod_q31.c │ │ │ ├── arm_cmplx_mag_f16.c │ │ │ ├── arm_cmplx_mag_f32.c │ │ │ ├── arm_cmplx_mag_f64.c │ │ │ ├── arm_cmplx_mag_fast_q15.c │ │ │ ├── arm_cmplx_mag_q15.c │ │ │ ├── arm_cmplx_mag_q31.c │ │ │ ├── arm_cmplx_mag_squared_f16.c │ │ │ ├── arm_cmplx_mag_squared_f32.c │ │ │ ├── arm_cmplx_mag_squared_f64.c │ │ │ ├── arm_cmplx_mag_squared_q15.c │ │ │ ├── arm_cmplx_mag_squared_q31.c │ │ │ ├── arm_cmplx_mult_cmplx_f16.c │ │ │ ├── arm_cmplx_mult_cmplx_f32.c │ │ │ ├── arm_cmplx_mult_cmplx_f64.c │ │ │ ├── arm_cmplx_mult_cmplx_q15.c │ │ │ ├── arm_cmplx_mult_cmplx_q31.c │ │ │ ├── arm_cmplx_mult_real_f16.c │ │ │ ├── arm_cmplx_mult_real_f32.c │ │ │ ├── arm_cmplx_mult_real_q15.c │ │ │ └── arm_cmplx_mult_real_q31.c │ │ │ ├── ControllerFunctions │ │ │ ├── arm_pid_init_f32.c │ │ │ ├── arm_pid_init_q15.c │ │ │ ├── arm_pid_init_q31.c │ │ │ ├── arm_pid_reset_f32.c │ │ │ ├── arm_pid_reset_q15.c │ │ │ ├── arm_pid_reset_q31.c │ │ │ ├── arm_sin_cos_f32.c │ │ │ └── arm_sin_cos_q31.c │ │ │ ├── DistanceFunctions │ │ │ ├── arm_boolean_distance.c │ │ │ ├── arm_boolean_distance_template.h │ │ │ ├── arm_braycurtis_distance_f16.c │ │ │ ├── arm_braycurtis_distance_f32.c │ │ │ ├── arm_canberra_distance_f16.c │ │ │ ├── arm_canberra_distance_f32.c │ │ │ ├── arm_chebyshev_distance_f16.c │ │ │ ├── arm_chebyshev_distance_f32.c │ │ │ ├── arm_chebyshev_distance_f64.c │ │ │ ├── arm_cityblock_distance_f16.c │ │ │ ├── arm_cityblock_distance_f32.c │ │ │ ├── arm_cityblock_distance_f64.c │ │ │ ├── arm_correlation_distance_f16.c │ │ │ ├── arm_correlation_distance_f32.c │ │ │ ├── arm_cosine_distance_f16.c │ │ │ ├── arm_cosine_distance_f32.c │ │ │ ├── arm_cosine_distance_f64.c │ │ │ ├── arm_dice_distance.c │ │ │ ├── arm_euclidean_distance_f16.c │ │ │ ├── arm_euclidean_distance_f32.c │ │ │ ├── arm_euclidean_distance_f64.c │ │ │ ├── arm_hamming_distance.c │ │ │ ├── arm_jaccard_distance.c │ │ │ ├── arm_jensenshannon_distance_f16.c │ │ │ ├── arm_jensenshannon_distance_f32.c │ │ │ ├── arm_kulsinski_distance.c │ │ │ ├── arm_minkowski_distance_f16.c │ │ │ ├── arm_minkowski_distance_f32.c │ │ │ ├── arm_rogerstanimoto_distance.c │ │ │ ├── arm_russellrao_distance.c │ │ │ ├── arm_sokalmichener_distance.c │ │ │ ├── arm_sokalsneath_distance.c │ │ │ └── arm_yule_distance.c │ │ │ ├── FastMathFunctions │ │ │ ├── arm_atan2_f16.c │ │ │ ├── arm_atan2_f32.c │ │ │ ├── arm_atan2_q15.c │ │ │ ├── arm_atan2_q31.c │ │ │ ├── arm_cos_f32.c │ │ │ ├── arm_cos_q15.c │ │ │ ├── arm_cos_q31.c │ │ │ ├── arm_divide_q15.c │ │ │ ├── arm_divide_q31.c │ │ │ ├── arm_sin_f32.c │ │ │ ├── arm_sin_q15.c │ │ │ ├── arm_sin_q31.c │ │ │ ├── arm_sqrt_q15.c │ │ │ ├── arm_sqrt_q31.c │ │ │ ├── arm_vexp_f16.c │ │ │ ├── arm_vexp_f32.c │ │ │ ├── arm_vexp_f64.c │ │ │ ├── arm_vinverse_f16.c │ │ │ ├── arm_vlog_f16.c │ │ │ ├── arm_vlog_f32.c │ │ │ ├── arm_vlog_f64.c │ │ │ ├── arm_vlog_q15.c │ │ │ └── arm_vlog_q31.c │ │ │ ├── FilteringFunctions │ │ │ ├── arm_biquad_cascade_df1_32x64_init_q31.c │ │ │ ├── arm_biquad_cascade_df1_32x64_q31.c │ │ │ ├── arm_biquad_cascade_df1_f16.c │ │ │ ├── arm_biquad_cascade_df1_f32.c │ │ │ ├── arm_biquad_cascade_df1_fast_q15.c │ │ │ ├── arm_biquad_cascade_df1_fast_q31.c │ │ │ ├── arm_biquad_cascade_df1_init_f16.c │ │ │ ├── arm_biquad_cascade_df1_init_f32.c │ │ │ ├── arm_biquad_cascade_df1_init_q15.c │ │ │ ├── arm_biquad_cascade_df1_init_q31.c │ │ │ ├── arm_biquad_cascade_df1_q15.c │ │ │ ├── arm_biquad_cascade_df1_q31.c │ │ │ ├── arm_biquad_cascade_df2T_f16.c │ │ │ ├── arm_biquad_cascade_df2T_f32.c │ │ │ ├── arm_biquad_cascade_df2T_f64.c │ │ │ ├── arm_biquad_cascade_df2T_init_f16.c │ │ │ ├── arm_biquad_cascade_df2T_init_f32.c │ │ │ ├── arm_biquad_cascade_df2T_init_f64.c │ │ │ ├── arm_biquad_cascade_stereo_df2T_f16.c │ │ │ ├── arm_biquad_cascade_stereo_df2T_f32.c │ │ │ ├── arm_biquad_cascade_stereo_df2T_init_f16.c │ │ │ ├── arm_biquad_cascade_stereo_df2T_init_f32.c │ │ │ ├── arm_conv_f32.c │ │ │ ├── arm_conv_fast_opt_q15.c │ │ │ ├── arm_conv_fast_q15.c │ │ │ ├── arm_conv_fast_q31.c │ │ │ ├── arm_conv_opt_q15.c │ │ │ ├── arm_conv_opt_q7.c │ │ │ ├── arm_conv_partial_f32.c │ │ │ ├── arm_conv_partial_fast_opt_q15.c │ │ │ ├── arm_conv_partial_fast_q15.c │ │ │ ├── arm_conv_partial_fast_q31.c │ │ │ ├── arm_conv_partial_opt_q15.c │ │ │ ├── arm_conv_partial_opt_q7.c │ │ │ ├── arm_conv_partial_q15.c │ │ │ ├── arm_conv_partial_q31.c │ │ │ ├── arm_conv_partial_q7.c │ │ │ ├── arm_conv_q15.c │ │ │ ├── arm_conv_q31.c │ │ │ ├── arm_conv_q7.c │ │ │ ├── arm_correlate_f16.c │ │ │ ├── arm_correlate_f32.c │ │ │ ├── arm_correlate_f64.c │ │ │ ├── arm_correlate_fast_opt_q15.c │ │ │ ├── arm_correlate_fast_q15.c │ │ │ ├── arm_correlate_fast_q31.c │ │ │ ├── arm_correlate_opt_q15.c │ │ │ ├── arm_correlate_opt_q7.c │ │ │ ├── arm_correlate_q15.c │ │ │ ├── arm_correlate_q31.c │ │ │ ├── arm_correlate_q7.c │ │ │ ├── arm_fir_decimate_f32.c │ │ │ ├── arm_fir_decimate_fast_q15.c │ │ │ ├── arm_fir_decimate_fast_q31.c │ │ │ ├── arm_fir_decimate_init_f32.c │ │ │ ├── arm_fir_decimate_init_q15.c │ │ │ ├── arm_fir_decimate_init_q31.c │ │ │ ├── arm_fir_decimate_q15.c │ │ │ ├── arm_fir_decimate_q31.c │ │ │ ├── arm_fir_f16.c │ │ │ ├── arm_fir_f32.c │ │ │ ├── arm_fir_f64.c │ │ │ ├── arm_fir_fast_q15.c │ │ │ ├── arm_fir_fast_q31.c │ │ │ ├── arm_fir_init_f16.c │ │ │ ├── arm_fir_init_f32.c │ │ │ ├── arm_fir_init_f64.c │ │ │ ├── arm_fir_init_q15.c │ │ │ ├── arm_fir_init_q31.c │ │ │ ├── arm_fir_init_q7.c │ │ │ ├── arm_fir_interpolate_f32.c │ │ │ ├── arm_fir_interpolate_init_f32.c │ │ │ ├── arm_fir_interpolate_init_q15.c │ │ │ ├── arm_fir_interpolate_init_q31.c │ │ │ ├── arm_fir_interpolate_q15.c │ │ │ ├── arm_fir_interpolate_q31.c │ │ │ ├── arm_fir_lattice_f32.c │ │ │ ├── arm_fir_lattice_init_f32.c │ │ │ ├── arm_fir_lattice_init_q15.c │ │ │ ├── arm_fir_lattice_init_q31.c │ │ │ ├── arm_fir_lattice_q15.c │ │ │ ├── arm_fir_lattice_q31.c │ │ │ ├── arm_fir_q15.c │ │ │ ├── arm_fir_q31.c │ │ │ ├── arm_fir_q7.c │ │ │ ├── arm_fir_sparse_f32.c │ │ │ ├── arm_fir_sparse_init_f32.c │ │ │ ├── arm_fir_sparse_init_q15.c │ │ │ ├── arm_fir_sparse_init_q31.c │ │ │ ├── arm_fir_sparse_init_q7.c │ │ │ ├── arm_fir_sparse_q15.c │ │ │ ├── arm_fir_sparse_q31.c │ │ │ ├── arm_fir_sparse_q7.c │ │ │ ├── arm_iir_lattice_f32.c │ │ │ ├── arm_iir_lattice_init_f32.c │ │ │ ├── arm_iir_lattice_init_q15.c │ │ │ ├── arm_iir_lattice_init_q31.c │ │ │ ├── arm_iir_lattice_q15.c │ │ │ ├── arm_iir_lattice_q31.c │ │ │ ├── arm_levinson_durbin_f16.c │ │ │ ├── arm_levinson_durbin_f32.c │ │ │ ├── arm_levinson_durbin_q31.c │ │ │ ├── arm_lms_f32.c │ │ │ ├── arm_lms_init_f32.c │ │ │ ├── arm_lms_init_q15.c │ │ │ ├── arm_lms_init_q31.c │ │ │ ├── arm_lms_norm_f32.c │ │ │ ├── arm_lms_norm_init_f32.c │ │ │ ├── arm_lms_norm_init_q15.c │ │ │ ├── arm_lms_norm_init_q31.c │ │ │ ├── arm_lms_norm_q15.c │ │ │ ├── arm_lms_norm_q31.c │ │ │ ├── arm_lms_q15.c │ │ │ └── arm_lms_q31.c │ │ │ ├── InterpolationFunctions │ │ │ ├── arm_bilinear_interp_f16.c │ │ │ ├── arm_bilinear_interp_f32.c │ │ │ ├── arm_bilinear_interp_q15.c │ │ │ ├── arm_bilinear_interp_q31.c │ │ │ ├── arm_bilinear_interp_q7.c │ │ │ ├── arm_linear_interp_f16.c │ │ │ ├── arm_linear_interp_f32.c │ │ │ ├── arm_linear_interp_q15.c │ │ │ ├── arm_linear_interp_q31.c │ │ │ ├── arm_linear_interp_q7.c │ │ │ ├── arm_spline_interp_f32.c │ │ │ └── arm_spline_interp_init_f32.c │ │ │ ├── MatrixFunctions │ │ │ ├── arm_householder_f16.c │ │ │ ├── arm_householder_f32.c │ │ │ ├── arm_householder_f64.c │ │ │ ├── arm_mat_add_f16.c │ │ │ ├── arm_mat_add_f32.c │ │ │ ├── arm_mat_add_q15.c │ │ │ ├── arm_mat_add_q31.c │ │ │ ├── arm_mat_cholesky_f16.c │ │ │ ├── arm_mat_cholesky_f32.c │ │ │ ├── arm_mat_cholesky_f64.c │ │ │ ├── arm_mat_cmplx_mult_f16.c │ │ │ ├── arm_mat_cmplx_mult_f32.c │ │ │ ├── arm_mat_cmplx_mult_q15.c │ │ │ ├── arm_mat_cmplx_mult_q31.c │ │ │ ├── arm_mat_cmplx_trans_f16.c │ │ │ ├── arm_mat_cmplx_trans_f32.c │ │ │ ├── arm_mat_cmplx_trans_q15.c │ │ │ ├── arm_mat_cmplx_trans_q31.c │ │ │ ├── arm_mat_init_f16.c │ │ │ ├── arm_mat_init_f32.c │ │ │ ├── arm_mat_init_q15.c │ │ │ ├── arm_mat_init_q31.c │ │ │ ├── arm_mat_inverse_f16.c │ │ │ ├── arm_mat_inverse_f32.c │ │ │ ├── arm_mat_inverse_f64.c │ │ │ ├── arm_mat_ldlt_f32.c │ │ │ ├── arm_mat_ldlt_f64.c │ │ │ ├── arm_mat_mult_f16.c │ │ │ ├── arm_mat_mult_f32.c │ │ │ ├── arm_mat_mult_f64.c │ │ │ ├── arm_mat_mult_fast_q15.c │ │ │ ├── arm_mat_mult_fast_q31.c │ │ │ ├── arm_mat_mult_opt_q31.c │ │ │ ├── arm_mat_mult_q15.c │ │ │ ├── arm_mat_mult_q31.c │ │ │ ├── arm_mat_mult_q7.c │ │ │ ├── arm_mat_qr_f16.c │ │ │ ├── arm_mat_qr_f32.c │ │ │ ├── arm_mat_qr_f64.c │ │ │ ├── arm_mat_scale_f16.c │ │ │ ├── arm_mat_scale_f32.c │ │ │ ├── arm_mat_scale_q15.c │ │ │ ├── arm_mat_scale_q31.c │ │ │ ├── arm_mat_solve_lower_triangular_f16.c │ │ │ ├── arm_mat_solve_lower_triangular_f32.c │ │ │ ├── arm_mat_solve_lower_triangular_f64.c │ │ │ ├── arm_mat_solve_upper_triangular_f16.c │ │ │ ├── arm_mat_solve_upper_triangular_f32.c │ │ │ ├── arm_mat_solve_upper_triangular_f64.c │ │ │ ├── arm_mat_sub_f16.c │ │ │ ├── arm_mat_sub_f32.c │ │ │ ├── arm_mat_sub_f64.c │ │ │ ├── arm_mat_sub_q15.c │ │ │ ├── arm_mat_sub_q31.c │ │ │ ├── arm_mat_trans_f16.c │ │ │ ├── arm_mat_trans_f32.c │ │ │ ├── arm_mat_trans_f64.c │ │ │ ├── arm_mat_trans_q15.c │ │ │ ├── arm_mat_trans_q31.c │ │ │ ├── arm_mat_trans_q7.c │ │ │ ├── arm_mat_vec_mult_f16.c │ │ │ ├── arm_mat_vec_mult_f32.c │ │ │ ├── arm_mat_vec_mult_q15.c │ │ │ ├── arm_mat_vec_mult_q31.c │ │ │ └── arm_mat_vec_mult_q7.c │ │ │ ├── QuaternionMathFunctions │ │ │ ├── arm_quaternion2rotation_f32.c │ │ │ ├── arm_quaternion_conjugate_f32.c │ │ │ ├── arm_quaternion_inverse_f32.c │ │ │ ├── arm_quaternion_norm_f32.c │ │ │ ├── arm_quaternion_normalize_f32.c │ │ │ ├── arm_quaternion_product_f32.c │ │ │ ├── arm_quaternion_product_single_f32.c │ │ │ └── arm_rotation2quaternion_f32.c │ │ │ ├── SVMFunctions │ │ │ ├── arm_svm_linear_init_f16.c │ │ │ ├── arm_svm_linear_init_f32.c │ │ │ ├── arm_svm_linear_predict_f16.c │ │ │ ├── arm_svm_linear_predict_f32.c │ │ │ ├── arm_svm_polynomial_init_f16.c │ │ │ ├── arm_svm_polynomial_init_f32.c │ │ │ ├── arm_svm_polynomial_predict_f16.c │ │ │ ├── arm_svm_polynomial_predict_f32.c │ │ │ ├── arm_svm_rbf_init_f16.c │ │ │ ├── arm_svm_rbf_init_f32.c │ │ │ ├── arm_svm_rbf_predict_f16.c │ │ │ ├── arm_svm_rbf_predict_f32.c │ │ │ ├── arm_svm_sigmoid_init_f16.c │ │ │ ├── arm_svm_sigmoid_init_f32.c │ │ │ ├── arm_svm_sigmoid_predict_f16.c │ │ │ └── arm_svm_sigmoid_predict_f32.c │ │ │ ├── StatisticsFunctions │ │ │ ├── arm_absmax_f16.c │ │ │ ├── arm_absmax_f32.c │ │ │ ├── arm_absmax_f64.c │ │ │ ├── arm_absmax_no_idx_f16.c │ │ │ ├── arm_absmax_no_idx_f32.c │ │ │ ├── arm_absmax_no_idx_f64.c │ │ │ ├── arm_absmax_no_idx_q15.c │ │ │ ├── arm_absmax_no_idx_q31.c │ │ │ ├── arm_absmax_no_idx_q7.c │ │ │ ├── arm_absmax_q15.c │ │ │ ├── arm_absmax_q31.c │ │ │ ├── arm_absmax_q7.c │ │ │ ├── arm_absmin_f16.c │ │ │ ├── arm_absmin_f32.c │ │ │ ├── arm_absmin_f64.c │ │ │ ├── arm_absmin_no_idx_f16.c │ │ │ ├── arm_absmin_no_idx_f32.c │ │ │ ├── arm_absmin_no_idx_f64.c │ │ │ ├── arm_absmin_no_idx_q15.c │ │ │ ├── arm_absmin_no_idx_q31.c │ │ │ ├── arm_absmin_no_idx_q7.c │ │ │ ├── arm_absmin_q15.c │ │ │ ├── arm_absmin_q31.c │ │ │ ├── arm_absmin_q7.c │ │ │ ├── arm_accumulate_f16.c │ │ │ ├── arm_accumulate_f32.c │ │ │ ├── arm_accumulate_f64.c │ │ │ ├── arm_entropy_f16.c │ │ │ ├── arm_entropy_f32.c │ │ │ ├── arm_entropy_f64.c │ │ │ ├── arm_kullback_leibler_f16.c │ │ │ ├── arm_kullback_leibler_f32.c │ │ │ ├── arm_kullback_leibler_f64.c │ │ │ ├── arm_logsumexp_dot_prod_f16.c │ │ │ ├── arm_logsumexp_dot_prod_f32.c │ │ │ ├── arm_logsumexp_f16.c │ │ │ ├── arm_logsumexp_f32.c │ │ │ ├── arm_max_f16.c │ │ │ ├── arm_max_f32.c │ │ │ ├── arm_max_f64.c │ │ │ ├── arm_max_no_idx_f16.c │ │ │ ├── arm_max_no_idx_f32.c │ │ │ ├── arm_max_no_idx_f64.c │ │ │ ├── arm_max_no_idx_q15.c │ │ │ ├── arm_max_no_idx_q31.c │ │ │ ├── arm_max_no_idx_q7.c │ │ │ ├── arm_max_q15.c │ │ │ ├── arm_max_q31.c │ │ │ ├── arm_max_q7.c │ │ │ ├── arm_mean_f16.c │ │ │ ├── arm_mean_f32.c │ │ │ ├── arm_mean_f64.c │ │ │ ├── arm_mean_q15.c │ │ │ ├── arm_mean_q31.c │ │ │ ├── arm_mean_q7.c │ │ │ ├── arm_min_f16.c │ │ │ ├── arm_min_f32.c │ │ │ ├── arm_min_f64.c │ │ │ ├── arm_min_no_idx_f16.c │ │ │ ├── arm_min_no_idx_f32.c │ │ │ ├── arm_min_no_idx_f64.c │ │ │ ├── arm_min_no_idx_q15.c │ │ │ ├── arm_min_no_idx_q31.c │ │ │ ├── arm_min_no_idx_q7.c │ │ │ ├── arm_min_q15.c │ │ │ ├── arm_min_q31.c │ │ │ ├── arm_min_q7.c │ │ │ ├── arm_mse_f16.c │ │ │ ├── arm_mse_f32.c │ │ │ ├── arm_mse_f64.c │ │ │ ├── arm_mse_q15.c │ │ │ ├── arm_mse_q31.c │ │ │ ├── arm_mse_q7.c │ │ │ ├── arm_power_f16.c │ │ │ ├── arm_power_f32.c │ │ │ ├── arm_power_f64.c │ │ │ ├── arm_power_q15.c │ │ │ ├── arm_power_q31.c │ │ │ ├── arm_power_q7.c │ │ │ ├── arm_rms_f16.c │ │ │ ├── arm_rms_f32.c │ │ │ ├── arm_rms_q15.c │ │ │ ├── arm_rms_q31.c │ │ │ ├── arm_std_f16.c │ │ │ ├── arm_std_f32.c │ │ │ ├── arm_std_f64.c │ │ │ ├── arm_std_q15.c │ │ │ ├── arm_std_q31.c │ │ │ ├── arm_var_f16.c │ │ │ ├── arm_var_f32.c │ │ │ ├── arm_var_f64.c │ │ │ ├── arm_var_q15.c │ │ │ └── arm_var_q31.c │ │ │ ├── SupportFunctions │ │ │ ├── arm_barycenter_f16.c │ │ │ ├── arm_barycenter_f32.c │ │ │ ├── arm_bitonic_sort_f32.c │ │ │ ├── arm_bubble_sort_f32.c │ │ │ ├── arm_copy_f16.c │ │ │ ├── arm_copy_f32.c │ │ │ ├── arm_copy_f64.c │ │ │ ├── arm_copy_q15.c │ │ │ ├── arm_copy_q31.c │ │ │ ├── arm_copy_q7.c │ │ │ ├── arm_f16_to_float.c │ │ │ ├── arm_f16_to_q15.c │ │ │ ├── arm_fill_f16.c │ │ │ ├── arm_fill_f32.c │ │ │ ├── arm_fill_f64.c │ │ │ ├── arm_fill_q15.c │ │ │ ├── arm_fill_q31.c │ │ │ ├── arm_fill_q7.c │ │ │ ├── arm_float_to_f16.c │ │ │ ├── arm_float_to_q15.c │ │ │ ├── arm_float_to_q31.c │ │ │ ├── arm_float_to_q7.c │ │ │ ├── arm_heap_sort_f32.c │ │ │ ├── arm_insertion_sort_f32.c │ │ │ ├── arm_merge_sort_f32.c │ │ │ ├── arm_merge_sort_init_f32.c │ │ │ ├── arm_q15_to_f16.c │ │ │ ├── arm_q15_to_float.c │ │ │ ├── arm_q15_to_q31.c │ │ │ ├── arm_q15_to_q7.c │ │ │ ├── arm_q31_to_float.c │ │ │ ├── arm_q31_to_q15.c │ │ │ ├── arm_q31_to_q7.c │ │ │ ├── arm_q7_to_float.c │ │ │ ├── arm_q7_to_q15.c │ │ │ ├── arm_q7_to_q31.c │ │ │ ├── arm_quick_sort_f32.c │ │ │ ├── arm_selection_sort_f32.c │ │ │ ├── arm_sort_f32.c │ │ │ ├── arm_sort_init_f32.c │ │ │ ├── arm_weighted_sum_f16.c │ │ │ └── arm_weighted_sum_f32.c │ │ │ └── TransformFunctions │ │ │ ├── arm_bitreversal.c │ │ │ ├── arm_bitreversal2.c │ │ │ ├── arm_bitreversal_f16.c │ │ │ ├── arm_cfft_f16.c │ │ │ ├── arm_cfft_f32.c │ │ │ ├── arm_cfft_f64.c │ │ │ ├── arm_cfft_init_f16.c │ │ │ ├── arm_cfft_init_f32.c │ │ │ ├── arm_cfft_init_f64.c │ │ │ ├── arm_cfft_init_q15.c │ │ │ ├── arm_cfft_init_q31.c │ │ │ ├── arm_cfft_q15.c │ │ │ ├── arm_cfft_q31.c │ │ │ ├── arm_cfft_radix2_f16.c │ │ │ ├── arm_cfft_radix2_f32.c │ │ │ ├── arm_cfft_radix2_init_f16.c │ │ │ ├── arm_cfft_radix2_init_f32.c │ │ │ ├── arm_cfft_radix2_init_q15.c │ │ │ ├── arm_cfft_radix2_init_q31.c │ │ │ ├── arm_cfft_radix2_q15.c │ │ │ ├── arm_cfft_radix2_q31.c │ │ │ ├── arm_cfft_radix4_f16.c │ │ │ ├── arm_cfft_radix4_f32.c │ │ │ ├── arm_cfft_radix4_init_f16.c │ │ │ ├── arm_cfft_radix4_init_f32.c │ │ │ ├── arm_cfft_radix4_init_q15.c │ │ │ ├── arm_cfft_radix4_init_q31.c │ │ │ ├── arm_cfft_radix4_q15.c │ │ │ ├── arm_cfft_radix4_q31.c │ │ │ ├── arm_cfft_radix8_f16.c │ │ │ ├── arm_cfft_radix8_f32.c │ │ │ ├── arm_dct4_f32.c │ │ │ ├── arm_dct4_init_f32.c │ │ │ ├── arm_dct4_init_q15.c │ │ │ ├── arm_dct4_init_q31.c │ │ │ ├── arm_dct4_q15.c │ │ │ ├── arm_dct4_q31.c │ │ │ ├── arm_mfcc_f16.c │ │ │ ├── arm_mfcc_f32.c │ │ │ ├── arm_mfcc_init_f16.c │ │ │ ├── arm_mfcc_init_f32.c │ │ │ ├── arm_mfcc_init_q15.c │ │ │ ├── arm_mfcc_init_q31.c │ │ │ ├── arm_mfcc_q15.c │ │ │ ├── arm_mfcc_q31.c │ │ │ ├── arm_rfft_f32.c │ │ │ ├── arm_rfft_fast_f16.c │ │ │ ├── arm_rfft_fast_f32.c │ │ │ ├── arm_rfft_fast_f64.c │ │ │ ├── arm_rfft_fast_init_f16.c │ │ │ ├── arm_rfft_fast_init_f32.c │ │ │ ├── arm_rfft_fast_init_f64.c │ │ │ ├── arm_rfft_init_f32.c │ │ │ ├── arm_rfft_init_q15.c │ │ │ ├── arm_rfft_init_q31.c │ │ │ ├── arm_rfft_q15.c │ │ │ └── arm_rfft_q31.c │ ├── NN │ │ ├── Include │ │ │ ├── arm_nn_math_types.h │ │ │ ├── arm_nn_tables.h │ │ │ ├── arm_nn_types.h │ │ │ ├── arm_nnfunctions.h │ │ │ └── arm_nnsupportfunctions.h │ │ └── Source │ │ │ ├── ActivationFunctions │ │ │ ├── arm_nn_activations_q15.c │ │ │ ├── arm_nn_activations_q7.c │ │ │ ├── arm_relu6_s8.c │ │ │ ├── arm_relu_q15.c │ │ │ └── arm_relu_q7.c │ │ │ ├── BasicMathFunctions │ │ │ ├── arm_elementwise_add_s16.c │ │ │ ├── arm_elementwise_add_s8.c │ │ │ ├── arm_elementwise_mul_s16.c │ │ │ └── arm_elementwise_mul_s8.c │ │ │ ├── ConcatenationFunctions │ │ │ ├── arm_concatenation_s8_w.c │ │ │ ├── arm_concatenation_s8_x.c │ │ │ ├── arm_concatenation_s8_y.c │ │ │ └── arm_concatenation_s8_z.c │ │ │ ├── ConvolutionFunctions │ │ │ ├── arm_convolve_1_x_n_s8.c │ │ │ ├── arm_convolve_1x1_HWC_q7_fast_nonsquare.c │ │ │ ├── arm_convolve_1x1_s8_fast.c │ │ │ ├── arm_convolve_HWC_q15_basic.c │ │ │ ├── arm_convolve_HWC_q15_fast.c │ │ │ ├── arm_convolve_HWC_q15_fast_nonsquare.c │ │ │ ├── arm_convolve_HWC_q7_RGB.c │ │ │ ├── arm_convolve_HWC_q7_basic.c │ │ │ ├── arm_convolve_HWC_q7_basic_nonsquare.c │ │ │ ├── arm_convolve_HWC_q7_fast.c │ │ │ ├── arm_convolve_HWC_q7_fast_nonsquare.c │ │ │ ├── arm_convolve_fast_s16.c │ │ │ ├── arm_convolve_s16.c │ │ │ ├── arm_convolve_s8.c │ │ │ ├── arm_convolve_wrapper_s16.c │ │ │ ├── arm_convolve_wrapper_s8.c │ │ │ ├── arm_depthwise_conv_3x3_s8.c │ │ │ ├── arm_depthwise_conv_fast_s16.c │ │ │ ├── arm_depthwise_conv_s16.c │ │ │ ├── arm_depthwise_conv_s8.c │ │ │ ├── arm_depthwise_conv_s8_opt.c │ │ │ ├── arm_depthwise_conv_u8_basic_ver1.c │ │ │ ├── arm_depthwise_conv_wrapper_s16.c │ │ │ ├── arm_depthwise_conv_wrapper_s8.c │ │ │ ├── arm_depthwise_separable_conv_HWC_q7.c │ │ │ ├── arm_depthwise_separable_conv_HWC_q7_nonsquare.c │ │ │ ├── arm_nn_depthwise_conv_s8_core.c │ │ │ ├── arm_nn_mat_mult_kernel_q7_q15.c │ │ │ ├── arm_nn_mat_mult_kernel_q7_q15_reordered.c │ │ │ ├── arm_nn_mat_mult_kernel_s8_s16.c │ │ │ └── arm_nn_mat_mult_s8.c │ │ │ ├── FullyConnectedFunctions │ │ │ ├── arm_fully_connected_mat_q7_vec_q15.c │ │ │ ├── arm_fully_connected_mat_q7_vec_q15_opt.c │ │ │ ├── arm_fully_connected_q15.c │ │ │ ├── arm_fully_connected_q15_opt.c │ │ │ ├── arm_fully_connected_q7.c │ │ │ ├── arm_fully_connected_q7_opt.c │ │ │ ├── arm_fully_connected_s16.c │ │ │ └── arm_fully_connected_s8.c │ │ │ ├── NNSupportFunctions │ │ │ ├── arm_nn_accumulate_q7_to_q15.c │ │ │ ├── arm_nn_add_q7.c │ │ │ ├── arm_nn_depthwise_conv_nt_t_padded_s8.c │ │ │ ├── arm_nn_depthwise_conv_nt_t_s16.c │ │ │ ├── arm_nn_depthwise_conv_nt_t_s8.c │ │ │ ├── arm_nn_mat_mul_core_1x_s8.c │ │ │ ├── arm_nn_mat_mul_core_4x_s8.c │ │ │ ├── arm_nn_mat_mul_kernel_s16.c │ │ │ ├── arm_nn_mat_mult_nt_t_s8.c │ │ │ ├── arm_nn_mult_q15.c │ │ │ ├── arm_nn_mult_q7.c │ │ │ ├── arm_nn_vec_mat_mult_t_s16.c │ │ │ ├── arm_nn_vec_mat_mult_t_s8.c │ │ │ ├── arm_nn_vec_mat_mult_t_svdf_s8.c │ │ │ ├── arm_nntables.c │ │ │ ├── arm_q7_to_q15_no_shift.c │ │ │ ├── arm_q7_to_q15_reordered_no_shift.c │ │ │ ├── arm_q7_to_q15_reordered_with_offset.c │ │ │ └── arm_q7_to_q15_with_offset.c │ │ │ ├── PoolingFunctions │ │ │ ├── arm_avgpool_s16.c │ │ │ ├── arm_avgpool_s8.c │ │ │ ├── arm_max_pool_s16.c │ │ │ ├── arm_max_pool_s8.c │ │ │ └── arm_pool_q7_HWC.c │ │ │ ├── ReshapeFunctions │ │ │ └── arm_reshape_s8.c │ │ │ ├── SVDFunctions │ │ │ ├── arm_svdf_s8.c │ │ │ └── arm_svdf_state_s16_s8.c │ │ │ └── SoftmaxFunctions │ │ │ ├── arm_nn_softmax_common_s8.c │ │ │ ├── arm_softmax_q15.c │ │ │ ├── arm_softmax_q7.c │ │ │ ├── arm_softmax_s16.c │ │ │ ├── arm_softmax_s8.c │ │ │ ├── arm_softmax_s8_s16.c │ │ │ ├── arm_softmax_u8.c │ │ │ └── arm_softmax_with_batch_q7.c │ └── sources.txt ├── LICENSE ├── LICENSE.3-clause-bsd-clear ├── README.md ├── classifier │ ├── ei_aligned_malloc.h │ ├── ei_classifier_config.h │ ├── ei_classifier_smooth.h │ ├── ei_classifier_types.h │ ├── ei_constants.h │ ├── ei_fill_result_struct.h │ ├── ei_model_types.h │ ├── ei_nms.h │ ├── ei_quantize.h │ ├── ei_run_classifier.h │ ├── ei_run_classifier_image.h │ ├── ei_run_dsp.h │ ├── ei_signal_with_axes.h │ ├── ei_signal_with_range.h │ ├── inferencing_engines │ │ ├── akida.h │ │ ├── anomaly.h │ │ ├── aton.h │ │ ├── ceva_npn.h │ │ ├── drpai.h │ │ ├── engines.h │ │ ├── ethos_linux.h │ │ ├── memryx.h │ │ ├── onnx_tidl.h │ │ ├── tensaiflow.h │ │ ├── tensorrt.h │ │ ├── tflite_eon.h │ │ ├── tflite_full.h │ │ ├── tflite_helper.h │ │ ├── tflite_micro.h │ │ └── tflite_tidl.h │ └── postprocessing │ │ ├── alignment │ │ ├── ei_alignment.hpp │ │ └── rectangular_lsap.hpp │ │ ├── ei_object_counting.h │ │ ├── ei_object_tracking.h │ │ ├── ei_performance_calibration.h │ │ ├── ei_postprocessing.h │ │ ├── ei_postprocessing_common.h │ │ └── tinyEKF │ │ ├── LICENSE.md │ │ ├── tinyekf.hpp │ │ └── tinyekf_custom.h ├── cmake │ ├── add_source.cmake │ ├── utils.cmake │ └── zephyr │ │ └── CMakeLists.txt ├── dsp │ ├── README.md │ ├── config.hpp │ ├── dct │ │ ├── .clang-format │ │ ├── fast-dct-fft.cpp │ │ └── fast-dct-fft.h │ ├── dsp_engines │ │ ├── ei_arm_cmsis_dsp.h │ │ ├── ei_ceva_dsp.h │ │ ├── ei_ceva_dsp_fixed.h │ │ └── ei_no_hw_dsp.h │ ├── ei_alloc.h │ ├── ei_dsp_handle.h │ ├── ei_flatten.h │ ├── ei_hr.hpp │ ├── ei_profiler.h │ ├── ei_utils.h │ ├── ei_vector.h │ ├── image │ │ ├── image.hpp │ │ ├── processing.cpp │ │ └── processing.hpp │ ├── kissfft │ │ ├── .clang-format │ │ ├── LICENSE │ │ ├── README.md │ │ ├── _kiss_fft_guts.h │ │ ├── kiss_fft.cpp │ │ ├── kiss_fft.h │ │ ├── kiss_fftr.cpp │ │ ├── kiss_fftr.h │ │ └── kissfft.h │ ├── memory.cpp │ ├── memory.hpp │ ├── numpy.hpp │ ├── numpy_types.h │ ├── returntypes.h │ ├── returntypes.hpp │ ├── spectral │ │ ├── feature.hpp │ │ ├── filters.hpp │ │ ├── fir_filter.hpp │ │ ├── processing.hpp │ │ ├── signal.hpp │ │ ├── spectral.hpp │ │ ├── wavelet.hpp │ │ └── wavelet_coeff.hpp │ └── speechpy │ │ ├── feature.hpp │ │ ├── functions.hpp │ │ ├── processing.hpp │ │ └── speechpy.hpp ├── porting │ ├── .clang-format │ ├── ambiq │ │ ├── debug_log.cpp │ │ └── ei_classifier_porting.cpp │ ├── android │ │ └── ei_classifier_porting.cpp │ ├── arduino │ │ ├── debug_log.cpp │ │ └── ei_classifier_porting.cpp │ ├── ceva-npn │ │ ├── debug_log.cpp │ │ └── ei_classifier_porting.cpp │ ├── clib │ │ ├── debug_log.cpp │ │ └── ei_classifier_porting.cpp │ ├── ei_classifier_porting.h │ ├── ei_logging.h │ ├── espressif │ │ ├── ESP-NN │ │ │ ├── CMakeLists.txt │ │ │ ├── CONTRIBUTING.md │ │ │ ├── Kconfig.projbuild │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── idf_component.yml │ │ │ ├── include │ │ │ │ ├── esp_nn.h │ │ │ │ ├── esp_nn_ansi_c.h │ │ │ │ ├── esp_nn_ansi_headers.h │ │ │ │ ├── esp_nn_defs.h │ │ │ │ ├── esp_nn_esp32p4.h │ │ │ │ ├── esp_nn_esp32s3.h │ │ │ │ └── esp_nn_generic_opt.h │ │ │ └── src │ │ │ │ ├── activation_functions │ │ │ │ ├── esp_nn_relu_ansi.c │ │ │ │ └── esp_nn_relu_s8_esp32s3.S │ │ │ │ ├── basic_math │ │ │ │ ├── esp_nn_add_ansi.c │ │ │ │ ├── esp_nn_add_s8_esp32s3.S │ │ │ │ ├── esp_nn_mul_ansi.c │ │ │ │ └── esp_nn_mul_s8_esp32s3.S │ │ │ │ ├── common │ │ │ │ ├── common_functions.h │ │ │ │ ├── esp_nn_common_functions_esp32s3.S │ │ │ │ ├── esp_nn_multiply_by_quantized_mult_esp32s3.S │ │ │ │ └── esp_nn_multiply_by_quantized_mult_ver1_esp32s3.S │ │ │ │ ├── convolution │ │ │ │ ├── esp_nn_conv_ansi.c │ │ │ │ ├── esp_nn_conv_esp32p4.c │ │ │ │ ├── esp_nn_conv_esp32s3.c │ │ │ │ ├── esp_nn_conv_opt.c │ │ │ │ ├── esp_nn_conv_s16_mult4_1x1_esp32s3.S │ │ │ │ ├── esp_nn_conv_s16_mult8_esp32s3.S │ │ │ │ ├── esp_nn_conv_s8_filter_aligned_input_padded_esp32s3.S │ │ │ │ ├── esp_nn_conv_s8_mult8_1x1_esp32s3.S │ │ │ │ ├── esp_nn_depthwise_conv_ansi.c │ │ │ │ ├── esp_nn_depthwise_conv_opt.c │ │ │ │ ├── esp_nn_depthwise_conv_s16_mult1_3x3_esp32s3.S │ │ │ │ ├── esp_nn_depthwise_conv_s16_mult1_3x3_no_pad_esp32s3.S │ │ │ │ ├── esp_nn_depthwise_conv_s16_mult1_esp32s3.S │ │ │ │ ├── esp_nn_depthwise_conv_s16_mult4_esp32s3.S │ │ │ │ ├── esp_nn_depthwise_conv_s16_mult8_3x3_esp32s3.S │ │ │ │ ├── esp_nn_depthwise_conv_s16_mult8_esp32s3.S │ │ │ │ ├── esp_nn_depthwise_conv_s8_esp32s3.c │ │ │ │ └── esp_nn_depthwise_conv_s8_mult1_3x3_padded_esp32s3.S │ │ │ │ ├── fully_connected │ │ │ │ ├── esp_nn_fully_connected_ansi.c │ │ │ │ └── esp_nn_fully_connected_s8_esp32s3.S │ │ │ │ ├── pooling │ │ │ │ ├── esp_nn_avg_pool_ansi.c │ │ │ │ ├── esp_nn_avg_pool_s8_esp32s3.S │ │ │ │ ├── esp_nn_max_pool_ansi.c │ │ │ │ └── esp_nn_max_pool_s8_esp32s3.S │ │ │ │ └── softmax │ │ │ │ ├── esp_nn_softmax_ansi.c │ │ │ │ ├── esp_nn_softmax_opt.c │ │ │ │ └── softmax_common.h │ │ ├── debug_log.cpp │ │ └── ei_classifier_porting.cpp │ ├── ethos-core-driver │ │ ├── CMakeLists.txt │ │ ├── LICENSE.txt │ │ ├── README.MD │ │ ├── SECURITY.md │ │ ├── include │ │ │ ├── ethosu_driver.h │ │ │ ├── ethosu_types.h │ │ │ └── pmu_ethosu.h │ │ ├── src │ │ │ ├── ehtosu_config_u65.h │ │ │ ├── ethosu55_interface.h │ │ │ ├── ethosu65_interface.h │ │ │ ├── ethosu85_interface.h │ │ │ ├── ethosu_config_u55.h │ │ │ ├── ethosu_config_u85.h │ │ │ ├── ethosu_device.h │ │ │ ├── ethosu_device_u55_u65.c │ │ │ ├── ethosu_device_u85.c │ │ │ ├── ethosu_driver.c │ │ │ ├── ethosu_interface.h │ │ │ ├── ethosu_log.h │ │ │ └── ethosu_pmu.c │ │ └── version.txt │ ├── himax-we2 │ │ ├── debug_log.cpp │ │ ├── ei_classifier_porting.cpp │ │ └── ethosu_driver.c │ ├── iar │ │ ├── debug_log.cpp │ │ └── ei_classifier_porting.cpp │ ├── infineon-psoc62 │ │ ├── debug_log.cpp │ │ └── ei_classifier_porting.cpp │ ├── particle │ │ ├── debug_log.cpp │ │ └── ei_classifier_porting.cpp │ └── seeed-vision-ai │ │ ├── debug_log.cpp │ │ └── ei_classifier_porting.cpp ├── sources.txt ├── tensorflow │ ├── LICENSE │ └── lite │ │ ├── builtin_op_data.h │ │ ├── builtin_ops.h │ │ ├── c │ │ ├── builtin_op_data.h │ │ ├── c_api_types.h │ │ ├── common.c │ │ └── common.h │ │ ├── context_util.h │ │ ├── core │ │ ├── api │ │ │ ├── common.cpp │ │ │ ├── error_reporter.cpp │ │ │ ├── error_reporter.h │ │ │ ├── flatbuffer_conversions.cpp │ │ │ ├── flatbuffer_conversions.h │ │ │ ├── op_resolver.cpp │ │ │ ├── op_resolver.h │ │ │ ├── tensor_utils.cpp │ │ │ └── tensor_utils.h │ │ └── c │ │ │ ├── builtin_op_data.h │ │ │ ├── c_api_types.h │ │ │ └── common.h │ │ ├── kernels │ │ ├── custom │ │ │ ├── tree_ensemble_classifier.cpp │ │ │ └── tree_ensemble_classifier.h │ │ ├── internal │ │ │ ├── common.h │ │ │ ├── compatibility.h │ │ │ ├── cppmath.h │ │ │ ├── max.h │ │ │ ├── min.h │ │ │ ├── optimized │ │ │ │ └── neon_check.h │ │ │ ├── portable_tensor.h │ │ │ ├── portable_tensor_utils.cpp │ │ │ ├── portable_tensor_utils.h │ │ │ ├── quantization_util.cpp │ │ │ ├── quantization_util.h │ │ │ ├── reduce_common.h │ │ │ ├── reference │ │ │ │ ├── add.h │ │ │ │ ├── add_n.h │ │ │ │ ├── arg_min_max.h │ │ │ │ ├── batch_matmul.h │ │ │ │ ├── batch_to_space_nd.h │ │ │ │ ├── binary_function.h │ │ │ │ ├── broadcast_args.h │ │ │ │ ├── broadcast_to.h │ │ │ │ ├── ceil.h │ │ │ │ ├── comparisons.h │ │ │ │ ├── concatenation.h │ │ │ │ ├── conv.h │ │ │ │ ├── cumsum.h │ │ │ │ ├── depth_to_space.h │ │ │ │ ├── depthwiseconv_float.h │ │ │ │ ├── depthwiseconv_uint8.h │ │ │ │ ├── dequantize.h │ │ │ │ ├── div.h │ │ │ │ ├── elu.h │ │ │ │ ├── exp.h │ │ │ │ ├── fill.h │ │ │ │ ├── floor.h │ │ │ │ ├── floor_div.h │ │ │ │ ├── floor_mod.h │ │ │ │ ├── fully_connected.h │ │ │ │ ├── hard_swish.h │ │ │ │ ├── integer_ops │ │ │ │ │ ├── add.h │ │ │ │ │ ├── conv.h │ │ │ │ │ ├── depthwise_conv.h │ │ │ │ │ ├── fully_connected.h │ │ │ │ │ ├── l2normalization.h │ │ │ │ │ ├── logistic.h │ │ │ │ │ ├── mean.h │ │ │ │ │ ├── mul.h │ │ │ │ │ ├── pooling.h │ │ │ │ │ ├── tanh.h │ │ │ │ │ └── transpose_conv.h │ │ │ │ ├── l2normalization.h │ │ │ │ ├── leaky_relu.h │ │ │ │ ├── log_softmax.h │ │ │ │ ├── logistic.h │ │ │ │ ├── lstm_cell.h │ │ │ │ ├── maximum_minimum.h │ │ │ │ ├── mul.h │ │ │ │ ├── neg.h │ │ │ │ ├── pad.h │ │ │ │ ├── pooling.h │ │ │ │ ├── prelu.h │ │ │ │ ├── process_broadcast_shapes.h │ │ │ │ ├── quantize.h │ │ │ │ ├── reduce.h │ │ │ │ ├── requantize.h │ │ │ │ ├── resize_bilinear.h │ │ │ │ ├── resize_nearest_neighbor.h │ │ │ │ ├── round.h │ │ │ │ ├── scatter_nd.h │ │ │ │ ├── select.h │ │ │ │ ├── slice.h │ │ │ │ ├── softmax.h │ │ │ │ ├── space_to_batch_nd.h │ │ │ │ ├── space_to_depth.h │ │ │ │ ├── strided_slice.h │ │ │ │ ├── sub.h │ │ │ │ ├── tanh.h │ │ │ │ ├── transpose.h │ │ │ │ └── transpose_conv.h │ │ │ ├── reference_portable_tensor_utils.cpp │ │ │ ├── reference_portable_tensor_utils.h │ │ │ ├── reference_portable_tensor_utils_impl.h │ │ │ ├── runtime_shape.h │ │ │ ├── strided_slice_logic.h │ │ │ ├── tensor_ctypes.h │ │ │ ├── tensor_utils.cpp │ │ │ └── types.h │ │ ├── kernel_util.h │ │ ├── kernel_util_lite.cpp │ │ ├── op_macros.h │ │ └── padding.h │ │ ├── micro │ │ ├── all_ops_resolver.cpp │ │ ├── all_ops_resolver.h │ │ ├── compatibility.h │ │ ├── debug_log.h │ │ ├── fake_micro_context.cpp │ │ ├── fake_micro_context.h │ │ ├── flatbuffer_conversions_bridge.cpp │ │ ├── flatbuffer_conversions_bridge.h │ │ ├── flatbuffer_utils.cpp │ │ ├── flatbuffer_utils.h │ │ ├── ibuffer_allocator.h │ │ ├── kernels │ │ │ ├── activation_utils.h │ │ │ ├── activations.cpp │ │ │ ├── activations.h │ │ │ ├── activations_common.cpp │ │ │ ├── add.cpp │ │ │ ├── add.h │ │ │ ├── add_common.cpp │ │ │ ├── add_n.cpp │ │ │ ├── arg_min_max.cpp │ │ │ ├── assign_variable.cpp │ │ │ ├── batch_matmul.cpp │ │ │ ├── batch_to_space_nd.cpp │ │ │ ├── broadcast_args.cpp │ │ │ ├── broadcast_to.cpp │ │ │ ├── call_once.cpp │ │ │ ├── cast.cpp │ │ │ ├── ceil.cpp │ │ │ ├── circular_buffer.cpp │ │ │ ├── circular_buffer.h │ │ │ ├── circular_buffer_common.cpp │ │ │ ├── circular_buffer_flexbuffers_generated_data.h │ │ │ ├── comparisons.cpp │ │ │ ├── complex_abs.cpp │ │ │ ├── concatenation.cpp │ │ │ ├── conv.cpp │ │ │ ├── conv.h │ │ │ ├── conv_common.cpp │ │ │ ├── conv_test.h │ │ │ ├── cumsum.cpp │ │ │ ├── depth_to_space.cpp │ │ │ ├── depthwise_conv.cpp │ │ │ ├── depthwise_conv.h │ │ │ ├── depthwise_conv_common.cpp │ │ │ ├── dequantize.cpp │ │ │ ├── dequantize.h │ │ │ ├── dequantize_common.cpp │ │ │ ├── detection_postprocess.cpp │ │ │ ├── detection_postprocess_flexbuffers_generated_data.h │ │ │ ├── div.cpp │ │ │ ├── elementwise.cpp │ │ │ ├── elu.cpp │ │ │ ├── ethosu.cpp │ │ │ ├── ethosu.h │ │ │ ├── exp.cpp │ │ │ ├── expand_dims.cpp │ │ │ ├── fill.cpp │ │ │ ├── floor.cpp │ │ │ ├── floor_div.cpp │ │ │ ├── floor_mod.cpp │ │ │ ├── fully_connected.cpp │ │ │ ├── fully_connected.h │ │ │ ├── fully_connected_common.cpp │ │ │ ├── gather.cpp │ │ │ ├── gather_nd.cpp │ │ │ ├── hard_swish.cpp │ │ │ ├── hard_swish.h │ │ │ ├── hard_swish_common.cpp │ │ │ ├── if.cpp │ │ │ ├── kernel_runner.cpp │ │ │ ├── kernel_runner.h │ │ │ ├── kernel_util.h │ │ │ ├── kernel_util_micro.cpp │ │ │ ├── l2_pool_2d.cpp │ │ │ ├── l2norm.cpp │ │ │ ├── leaky_relu.cpp │ │ │ ├── leaky_relu.h │ │ │ ├── leaky_relu_common.cpp │ │ │ ├── log_softmax.cpp │ │ │ ├── logical.cpp │ │ │ ├── logical.h │ │ │ ├── logical_common.cpp │ │ │ ├── logistic.cpp │ │ │ ├── logistic.h │ │ │ ├── logistic_common.cpp │ │ │ ├── lstm_eval.cpp │ │ │ ├── lstm_eval.h │ │ │ ├── lstm_eval_test.h │ │ │ ├── lstm_shared.h │ │ │ ├── maximum_minimum.cpp │ │ │ ├── micro_ops.h │ │ │ ├── micro_tensor_utils.cpp │ │ │ ├── micro_tensor_utils.h │ │ │ ├── mirror_pad.cpp │ │ │ ├── mli_function_specializations.h │ │ │ ├── mli_interface.cpp │ │ │ ├── mli_interface.h │ │ │ ├── mli_slicers.cpp │ │ │ ├── mli_slicers.h │ │ │ ├── mli_tf_utils.h │ │ │ ├── mul.cpp │ │ │ ├── mul.h │ │ │ ├── mul_common.cpp │ │ │ ├── neg.cpp │ │ │ ├── pack.cpp │ │ │ ├── pad.cpp │ │ │ ├── pad.h │ │ │ ├── pooling.cpp │ │ │ ├── pooling.h │ │ │ ├── pooling_common.cpp │ │ │ ├── prelu.cpp │ │ │ ├── prelu.h │ │ │ ├── prelu_common.cpp │ │ │ ├── quantize.cpp │ │ │ ├── quantize.h │ │ │ ├── quantize_common.cpp │ │ │ ├── read_variable.cpp │ │ │ ├── real.cpp │ │ │ ├── reduce.cpp │ │ │ ├── reduce.h │ │ │ ├── reduce_common.cpp │ │ │ ├── reshape.cpp │ │ │ ├── resize_bilinear.cpp │ │ │ ├── resize_nearest_neighbor.cpp │ │ │ ├── rfft2d.cpp │ │ │ ├── round.cpp │ │ │ ├── scatter_nd.cpp │ │ │ ├── scratch_buf_mgr.cpp │ │ │ ├── scratch_buf_mgr.h │ │ │ ├── scratch_buffers.cpp │ │ │ ├── scratch_buffers.h │ │ │ ├── select.cpp │ │ │ ├── shape.cpp │ │ │ ├── slice.cpp │ │ │ ├── softmax.cpp │ │ │ ├── softmax.h │ │ │ ├── softmax_common.cpp │ │ │ ├── space_to_batch_nd.cpp │ │ │ ├── space_to_depth.cpp │ │ │ ├── split.cpp │ │ │ ├── split_v.cpp │ │ │ ├── squared_difference.cpp │ │ │ ├── squeeze.cpp │ │ │ ├── strided_slice.cpp │ │ │ ├── sub.cpp │ │ │ ├── sub.h │ │ │ ├── sub_common.cpp │ │ │ ├── svdf.cpp │ │ │ ├── svdf.h │ │ │ ├── svdf_common.cpp │ │ │ ├── tanh.cpp │ │ │ ├── tile.cpp │ │ │ ├── topk_v2.cpp │ │ │ ├── transpose.cpp │ │ │ ├── transpose_conv.cpp │ │ │ ├── tree_ensemble_classifier.cpp │ │ │ ├── tree_ensemble_classifier.h │ │ │ ├── unidirectional_sequence_lstm.cpp │ │ │ ├── unpack.cpp │ │ │ ├── var_handle.cpp │ │ │ ├── while.cpp │ │ │ └── zeros_like.cpp │ │ ├── memory_helpers.cpp │ │ ├── memory_helpers.h │ │ ├── memory_planner │ │ │ ├── greedy_memory_planner.cpp │ │ │ ├── greedy_memory_planner.h │ │ │ ├── linear_memory_planner.cpp │ │ │ ├── linear_memory_planner.h │ │ │ ├── memory_plan_struct.h │ │ │ ├── micro_memory_planner.h │ │ │ ├── non_persistent_buffer_planner_shim.cpp │ │ │ └── non_persistent_buffer_planner_shim.h │ │ ├── micro_allocation_info.cpp │ │ ├── micro_allocation_info.h │ │ ├── micro_allocator.cpp │ │ ├── micro_allocator.h │ │ ├── micro_arena_constants.h │ │ ├── micro_context.cpp │ │ ├── micro_context.h │ │ ├── micro_error_reporter.cpp │ │ ├── micro_error_reporter.h │ │ ├── micro_graph.cpp │ │ ├── micro_graph.h │ │ ├── micro_interpreter.cpp │ │ ├── micro_interpreter.h │ │ ├── micro_log.cpp │ │ ├── micro_log.h │ │ ├── micro_mutable_op_resolver.h │ │ ├── micro_op_resolver.h │ │ ├── micro_profiler.cpp │ │ ├── micro_profiler.h │ │ ├── micro_profiler_interface.h │ │ ├── micro_resource_variable.cpp │ │ ├── micro_resource_variable.h │ │ ├── micro_string.cpp │ │ ├── micro_string.h │ │ ├── micro_time.cpp │ │ ├── micro_time.h │ │ ├── micro_utils.cpp │ │ ├── micro_utils.h │ │ ├── mock_micro_graph.cpp │ │ ├── mock_micro_graph.h │ │ ├── non_persistent_arena_buffer_allocator.cpp │ │ ├── non_persistent_arena_buffer_allocator.h │ │ ├── op_resolver_bridge.cpp │ │ ├── op_resolver_bridge.h │ │ ├── persistent_arena_buffer_allocator.cpp │ │ ├── persistent_arena_buffer_allocator.h │ │ ├── recording_micro_allocator.cpp │ │ ├── recording_micro_allocator.h │ │ ├── recording_micro_interpreter.h │ │ ├── recording_single_arena_buffer_allocator.cpp │ │ ├── recording_single_arena_buffer_allocator.h │ │ ├── schema_utils.cpp │ │ ├── single_arena_buffer_allocator.cpp │ │ ├── single_arena_buffer_allocator.h │ │ ├── system_setup.cpp │ │ ├── system_setup.h │ │ ├── test_helper_custom_ops.cpp │ │ ├── test_helper_custom_ops.h │ │ ├── test_helpers.cpp │ │ └── test_helpers.h │ │ ├── portable_type_to_tflitetype.h │ │ └── schema │ │ ├── schema_generated.h │ │ ├── schema_generated_full.h │ │ └── schema_utils.h └── third_party │ ├── flatbuffers │ ├── LICENSE.txt │ └── include │ │ └── flatbuffers │ │ ├── fb_allocator.h │ │ ├── fb_array.h │ │ ├── fb_base.h │ │ ├── fb_buffer.h │ │ ├── fb_buffer_ref.h │ │ ├── fb_default_allocator.h │ │ ├── fb_detached_buffer.h │ │ ├── fb_flatbuffer_builder.h │ │ ├── fb_stl_emulation.h │ │ ├── fb_string.h │ │ ├── fb_struct.h │ │ ├── fb_table.h │ │ ├── fb_util.h │ │ ├── fb_vector.h │ │ ├── fb_vector_downward.h │ │ ├── fb_verifier.h │ │ ├── flatbuffers.h │ │ └── flexbuffers.h │ ├── gemmlowp │ ├── LICENSE │ ├── fixedpoint │ │ ├── fixedpoint.h │ │ ├── fixedpoint_neon.h │ │ └── fixedpoint_sse.h │ └── internal │ │ └── detect_platform.h │ ├── incbin │ └── incbin.h │ └── ruy │ └── ruy │ └── profiler │ └── instrumentation.h ├── firmware-sdk ├── .gitignore ├── CHANGELOG.md ├── CMakeLists.txt ├── QCBOR │ ├── inc │ │ ├── UsefulBuf.h │ │ └── qcbor.h │ └── src │ │ ├── UsefulBuf.c │ │ ├── ieee754.c │ │ ├── ieee754.h │ │ ├── qcbor_decode.c │ │ └── qcbor_encode.c ├── README.md ├── at-server │ ├── ei_at_command_set.cpp │ ├── ei_at_command_set.h │ ├── ei_at_history.h │ ├── ei_at_parser.cpp │ ├── ei_at_parser.h │ ├── ei_at_server.cpp │ ├── ei_at_server.h │ ├── ei_at_server_singleton.cpp │ └── ei_line_buffer.h ├── at_base64_lib.cpp ├── at_base64_lib.h ├── ei_camera_interface.h ├── ei_config_types.h ├── ei_device_info_lib.h ├── ei_device_interface.h ├── ei_device_lib.cpp ├── ei_device_lib.h ├── ei_device_memory.h ├── ei_fusion.cpp ├── ei_fusion.h ├── ei_image_lib.cpp ├── ei_image_lib.h ├── ei_image_nn.h ├── jpeg │ ├── JPEGENC.cpp │ ├── JPEGENC.h │ ├── encode_as_jpg.h │ └── jpeg.h ├── remote-mgmt.cpp ├── remote-mgmt.h ├── sensor-aq │ ├── sensor_aq.cpp │ ├── sensor_aq.h │ ├── sensor_aq_none.cpp │ └── sensor_aq_none.h └── tools │ ├── README.md │ └── test_inference.py ├── ingestion-sdk-c ├── ei_run_impulse.cpp ├── ei_run_impulse.h ├── ei_sampler.cpp ├── ei_sampler.h └── inc │ └── signing │ ├── sensor_aq_mbedtls_hs256.cpp │ └── sensor_aq_mbedtls_hs256.h ├── ingestion-sdk-platform └── nano-ble33 │ ├── ei_at_handlers.cpp │ ├── ei_at_handlers.h │ ├── ei_device_nano_ble33.cpp │ ├── ei_device_nano_ble33.h │ ├── ei_flash_nano_ble33.cpp │ └── ei_flash_nano_ble33.h ├── mbedtls_hmac_sha256_sw └── ei_mbedtls_md.h ├── model-parameters ├── anomaly_metadata.h ├── model_metadata.h └── model_variables.h ├── sensors ├── ei_bm270_bmm150.cpp ├── ei_bm270_bmm150.h ├── ei_camera.cpp ├── ei_camera.h ├── ei_environmental_rev2.cpp ├── ei_environmental_rev2.h ├── ei_environmentsensor.cpp ├── ei_environmentsensor.h ├── ei_fusion_sensors_config.h ├── ei_inertialsensor.cpp ├── ei_inertialsensor.h ├── ei_inertialsensor_rev2.cpp ├── ei_inertialsensor_rev2.h ├── ei_interactionsensor.cpp ├── ei_interactionsensor.h ├── ei_lsm9ds1.cpp ├── ei_lsm9ds1.h ├── ei_microphone.cpp └── ei_microphone.h ├── setup.cpp ├── setup.h └── tflite-model ├── tflite_learn_3_compiled.cpp ├── tflite_learn_3_compiled.h └── trained_model_ops_define.h /.clang-format: -------------------------------------------------------------------------------- 1 | "DisableFormat": true 2 | "SortIncludes": false 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | create-arduino-library.sh 2 | *.bin 3 | *.elf 4 | *.hex 5 | *.map 6 | .DS_Store 7 | .vscode/ 8 | -------------------------------------------------------------------------------- /LICENSE.3-clause-bsd-clear: -------------------------------------------------------------------------------- 1 | The Clear BSD License 2 | 3 | Copyright (c) 2025 EdgeImpulse Inc. 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted (subject to the limitations in the disclaimer 8 | below) provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /boards.local.txt: -------------------------------------------------------------------------------- 1 | nano33ble.build.extra_flags=-I{build.source.path}/src -I{build.source.path}/src/model-parameters -I{build.source.path}/src/repl -I{build.source.path}/src/ingestion-sdk-c/ -I{build.source.path}/src/ingestion-sdk-c/inc -I{build.source.path}/src/ingestion-sdk-c/inc/signing -I{build.source.path}/src/ingestion-sdk-platform/nano-ble33 -I{build.source.path}/src/sensors -I{build.source.path}/src/mbedtls_hmac_sha256_sw/ -I{build.source.path}/src/firmware-sdk/ -I{build.source.path}/src/edge-impulse-sdk/ -DARDUINOSTL_M_H -DMBED_HEAP_STATS_ENABLED=1 -DMBED_STACK_STATS_ENABLED=1 -O3 -g3 -DEI_SENSOR_AQ_STREAM=FILE -DEIDSP_QUANTIZE_FILTERBANK=0 -DEI_CLASSIFIER_SLICES_PER_MODEL_WINDOW=4 2 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/.gitignore: -------------------------------------------------------------------------------- 1 | utensor/CTestTestfile.cmake 2 | utensor/cmake_install.cmake 3 | utensor/CMakeFiles/ 4 | utensor/Makefile 5 | utensor/CMakeCache.txt 6 | utensor.lib 7 | utensor/libutensor.a 8 | *.o 9 | *.d 10 | doc/ 11 | node_modules/ 12 | package-lock.json 13 | package.json -------------------------------------------------------------------------------- /src/edge-impulse-sdk/.mbedignore: -------------------------------------------------------------------------------- 1 | utensor/CMakeFiles/ 2 | tensorflow/lite/micro/mbed/ 3 | porting/arduino/ 4 | porting/espressif/ 5 | porting/himax/ 6 | porting/posix/ 7 | porting/silabs/ 8 | porting/stm32-cubeai/ 9 | porting/zephyr/ 10 | classifier/ei_run_classifier_c* 11 | third_party/arc_mli_package/ 12 | tensorflow-lite/ 13 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/Core/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.5 5 | * @date 02. February 2022 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2022 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 6U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/Include/dsp/controller_functions_f16.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file controller_functions_f16.h 3 | * @brief Public header file for CMSIS DSP Library 4 | * @version V1.10.0 5 | * @date 08 July 2021 6 | * Target Processor: Cortex-M and Cortex-A cores 7 | ******************************************************************************/ 8 | /* 9 | * Copyright (c) 2010-2020 Arm Limited or its affiliates. All rights reserved. 10 | * 11 | * SPDX-License-Identifier: Apache-2.0 12 | * 13 | * Licensed under the Apache License, Version 2.0 (the License); you may 14 | * not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at 16 | * 17 | * www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 21 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | */ 25 | 26 | 27 | #ifndef _CONTROLLER_FUNCTIONS_F16_H_ 28 | #define _CONTROLLER_FUNCTIONS_F16_H_ 29 | 30 | #ifdef __cplusplus 31 | extern "C" 32 | { 33 | #endif 34 | 35 | #if defined(ARM_FLOAT16_SUPPORTED) 36 | #endif /*defined(ARM_FLOAT16_SUPPORTED)*/ 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif /* ifndef _CONTROLLER_FUNCTIONS_F16_H_ */ 42 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/Include/dsp/svm_defines.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file svm_defines.h 3 | * @brief Public header file for CMSIS DSP Library 4 | * @version V1.10.0 5 | * @date 08 July 2021 6 | * 7 | * Target Processor: Cortex-M and Cortex-A cores 8 | ******************************************************************************/ 9 | /* 10 | * Copyright (c) 2010-2020 Arm Limited or its affiliates. All rights reserved. 11 | * 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the License); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at 17 | * 18 | * www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | */ 26 | 27 | 28 | #ifndef _SVM_DEFINES_H_ 29 | #define _SVM_DEFINES_H_ 30 | 31 | /** 32 | * @brief Struct for specifying SVM Kernel 33 | */ 34 | typedef enum 35 | { 36 | ARM_ML_KERNEL_LINEAR = 0, 37 | /**< Linear kernel */ 38 | ARM_ML_KERNEL_POLYNOMIAL = 1, 39 | /**< Polynomial kernel */ 40 | ARM_ML_KERNEL_RBF = 2, 41 | /**< Radial Basis Function kernel */ 42 | ARM_ML_KERNEL_SIGMOID = 3 43 | /**< Sigmoid kernel */ 44 | } arm_ml_kernel_type; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/PrivateInclude/README.md: -------------------------------------------------------------------------------- 1 | Note: All files have been moved from this folder into Include to simplify build management 2 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/Source/ControllerFunctions/arm_pid_reset_f32.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/dsp/config.hpp" 2 | #if EIDSP_LOAD_CMSIS_DSP_SOURCES 3 | /* ---------------------------------------------------------------------- 4 | * Project: CMSIS DSP Library 5 | * Title: arm_pid_reset_f32.c 6 | * Description: Floating-point PID Control reset function 7 | * 8 | * $Date: 23 April 2021 9 | * $Revision: V1.9.0 10 | * 11 | * Target Processor: Cortex-M and Cortex-A cores 12 | * -------------------------------------------------------------------- */ 13 | /* 14 | * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. 15 | * 16 | * SPDX-License-Identifier: Apache-2.0 17 | * 18 | * Licensed under the Apache License, Version 2.0 (the License); you may 19 | * not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at 21 | * 22 | * www.apache.org/licenses/LICENSE-2.0 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 26 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | */ 30 | 31 | #include "edge-impulse-sdk/CMSIS/DSP/Include/dsp/controller_functions.h" 32 | 33 | /** 34 | @addtogroup PID 35 | @{ 36 | */ 37 | 38 | /** 39 | @brief Reset function for the floating-point PID Control. 40 | @param[in,out] S points to an instance of the floating-point PID structure 41 | @return none 42 | 43 | @par Details 44 | The function resets the state buffer to zeros. 45 | */ 46 | 47 | void arm_pid_reset_f32( 48 | arm_pid_instance_f32 * S) 49 | { 50 | /* Reset state to zero, The size will be always 3 samples */ 51 | memset(S->state, 0, 3U * sizeof(float32_t)); 52 | } 53 | 54 | /** 55 | @} end of PID group 56 | */ 57 | 58 | #endif // EIDSP_LOAD_CMSIS_DSP_SOURCES 59 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/Source/ControllerFunctions/arm_pid_reset_q15.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/dsp/config.hpp" 2 | #if EIDSP_LOAD_CMSIS_DSP_SOURCES 3 | /* ---------------------------------------------------------------------- 4 | * Project: CMSIS DSP Library 5 | * Title: arm_pid_reset_q15.c 6 | * Description: Q15 PID Control reset function 7 | * 8 | * $Date: 23 April 2021 9 | * $Revision: V1.9.0 10 | * 11 | * Target Processor: Cortex-M and Cortex-A cores 12 | * -------------------------------------------------------------------- */ 13 | /* 14 | * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. 15 | * 16 | * SPDX-License-Identifier: Apache-2.0 17 | * 18 | * Licensed under the Apache License, Version 2.0 (the License); you may 19 | * not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at 21 | * 22 | * www.apache.org/licenses/LICENSE-2.0 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 26 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | */ 30 | 31 | #include "edge-impulse-sdk/CMSIS/DSP/Include/dsp/controller_functions.h" 32 | 33 | /** 34 | @addtogroup PID 35 | @{ 36 | */ 37 | 38 | /** 39 | @brief Reset function for the Q15 PID Control. 40 | @param[in,out] S points to an instance of the Q15 PID structure 41 | @return none 42 | 43 | @par Details 44 | The function resets the state buffer to zeros. 45 | */ 46 | 47 | void arm_pid_reset_q15( 48 | arm_pid_instance_q15 * S) 49 | { 50 | /* Reset state to zero, The size will be always 3 samples */ 51 | memset(S->state, 0, 3U * sizeof(q15_t)); 52 | } 53 | 54 | /** 55 | @} end of PID group 56 | */ 57 | 58 | #endif // EIDSP_LOAD_CMSIS_DSP_SOURCES 59 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/Source/ControllerFunctions/arm_pid_reset_q31.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/dsp/config.hpp" 2 | #if EIDSP_LOAD_CMSIS_DSP_SOURCES 3 | /* ---------------------------------------------------------------------- 4 | * Project: CMSIS DSP Library 5 | * Title: arm_pid_reset_q31.c 6 | * Description: Q31 PID Control reset function 7 | * 8 | * $Date: 23 April 2021 9 | * $Revision: V1.9.0 10 | * 11 | * Target Processor: Cortex-M and Cortex-A cores 12 | * -------------------------------------------------------------------- */ 13 | /* 14 | * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. 15 | * 16 | * SPDX-License-Identifier: Apache-2.0 17 | * 18 | * Licensed under the Apache License, Version 2.0 (the License); you may 19 | * not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at 21 | * 22 | * www.apache.org/licenses/LICENSE-2.0 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 26 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | */ 30 | 31 | #include "edge-impulse-sdk/CMSIS/DSP/Include/dsp/controller_functions.h" 32 | 33 | /** 34 | @addtogroup PID 35 | @{ 36 | */ 37 | 38 | /** 39 | @brief Reset function for the Q31 PID Control. 40 | @param[in,out] S points to an instance of the Q31 PID structure 41 | @return none 42 | 43 | @par Details 44 | The function resets the state buffer to zeros. 45 | */ 46 | 47 | void arm_pid_reset_q31( 48 | arm_pid_instance_q31 * S) 49 | { 50 | /* Reset state to zero, The size will be always 3 samples */ 51 | memset(S->state, 0, 3U * sizeof(q31_t)); 52 | } 53 | 54 | /** 55 | @} end of PID group 56 | */ 57 | 58 | #endif // EIDSP_LOAD_CMSIS_DSP_SOURCES 59 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/Source/DistanceFunctions/arm_cityblock_distance_f64.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/dsp/config.hpp" 2 | #if EIDSP_LOAD_CMSIS_DSP_SOURCES 3 | 4 | /* ---------------------------------------------------------------------- 5 | * Project: CMSIS DSP Library 6 | * Title: arm_cityblock_distance_f64.c 7 | * Description: Cityblock (Manhattan) distance between two vectors 8 | * 9 | * $Date: 13 September 2021 10 | * $Revision: V1.10.0 11 | * 12 | * Target Processor: Cortex-M and Cortex-A cores 13 | * -------------------------------------------------------------------- */ 14 | /* 15 | * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. 16 | * 17 | * SPDX-License-Identifier: Apache-2.0 18 | * 19 | * Licensed under the Apache License, Version 2.0 (the License); you may 20 | * not use this file except in compliance with the License. 21 | * You may obtain a copy of the License at 22 | * 23 | * www.apache.org/licenses/LICENSE-2.0 24 | * 25 | * Unless required by applicable law or agreed to in writing, software 26 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 27 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 28 | * See the License for the specific language governing permissions and 29 | * limitations under the License. 30 | */ 31 | 32 | #include "edge-impulse-sdk/CMSIS/DSP/Include/dsp/distance_functions.h" 33 | #include 34 | #include 35 | 36 | /** 37 | @addtogroup Manhattan 38 | @{ 39 | */ 40 | 41 | 42 | /** 43 | * @brief Cityblock (Manhattan) distance between two vectors 44 | * @param[in] pA First vector 45 | * @param[in] pB Second vector 46 | * @param[in] blockSize vector length 47 | * @return distance 48 | * 49 | */ 50 | float64_t arm_cityblock_distance_f64(const float64_t *pA,const float64_t *pB, uint32_t blockSize) 51 | { 52 | float64_t accum,tmpA, tmpB; 53 | 54 | accum = 0.; 55 | while(blockSize > 0) 56 | { 57 | tmpA = *pA++; 58 | tmpB = *pB++; 59 | accum += fabs(tmpA - tmpB); 60 | 61 | blockSize --; 62 | } 63 | 64 | return(accum); 65 | } 66 | 67 | /** 68 | * @} end of Manhattan group 69 | */ 70 | 71 | #endif // EIDSP_LOAD_CMSIS_DSP_SOURCES 72 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/Source/DistanceFunctions/arm_cosine_distance_f64.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/dsp/config.hpp" 2 | #if EIDSP_LOAD_CMSIS_DSP_SOURCES 3 | 4 | /* ---------------------------------------------------------------------- 5 | * Project: CMSIS DSP Library 6 | * Title: arm_cosine_distance_f64.c 7 | * Description: Cosine distance between two vectors 8 | * 9 | * $Date: 13 September 2021 10 | * $Revision: V1.10.0 11 | * 12 | * Target Processor: Cortex-M and Cortex-A cores 13 | * -------------------------------------------------------------------- */ 14 | /* 15 | * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. 16 | * 17 | * SPDX-License-Identifier: Apache-2.0 18 | * 19 | * Licensed under the Apache License, Version 2.0 (the License); you may 20 | * not use this file except in compliance with the License. 21 | * You may obtain a copy of the License at 22 | * 23 | * www.apache.org/licenses/LICENSE-2.0 24 | * 25 | * Unless required by applicable law or agreed to in writing, software 26 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 27 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 28 | * See the License for the specific language governing permissions and 29 | * limitations under the License. 30 | */ 31 | 32 | #include "edge-impulse-sdk/CMSIS/DSP/Include/dsp/distance_functions.h" 33 | #include 34 | #include 35 | 36 | 37 | /** 38 | @addtogroup CosineDist 39 | @{ 40 | */ 41 | 42 | 43 | 44 | /** 45 | * @brief Cosine distance between two vectors 46 | * 47 | * @param[in] pA First vector 48 | * @param[in] pB Second vector 49 | * @param[in] blockSize vector length 50 | * @return distance 51 | * 52 | */ 53 | 54 | float64_t arm_cosine_distance_f64(const float64_t *pA,const float64_t *pB, uint32_t blockSize) 55 | { 56 | float64_t pwra,pwrb,dot,tmp; 57 | 58 | arm_power_f64(pA, blockSize, &pwra); 59 | arm_power_f64(pB, blockSize, &pwrb); 60 | 61 | arm_dot_prod_f64(pA,pB,blockSize,&dot); 62 | 63 | tmp = sqrt(pwra * pwrb); 64 | return(1. - dot / tmp); 65 | 66 | } 67 | 68 | 69 | 70 | /** 71 | * @} end of CosineDist group 72 | */ 73 | 74 | #endif // EIDSP_LOAD_CMSIS_DSP_SOURCES 75 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/Source/DistanceFunctions/arm_euclidean_distance_f64.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/dsp/config.hpp" 2 | #if EIDSP_LOAD_CMSIS_DSP_SOURCES 3 | 4 | /* ---------------------------------------------------------------------- 5 | * Project: CMSIS DSP Library 6 | * Title: arm_euclidean_distance_f64.c 7 | * Description: Euclidean distance between two vectors 8 | * 9 | * $Date: 13 September 2021 10 | * $Revision: V1.10.0 11 | * 12 | * Target Processor: Cortex-M and Cortex-A cores 13 | * -------------------------------------------------------------------- */ 14 | /* 15 | * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. 16 | * 17 | * SPDX-License-Identifier: Apache-2.0 18 | * 19 | * Licensed under the Apache License, Version 2.0 (the License); you may 20 | * not use this file except in compliance with the License. 21 | * You may obtain a copy of the License at 22 | * 23 | * www.apache.org/licenses/LICENSE-2.0 24 | * 25 | * Unless required by applicable law or agreed to in writing, software 26 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 27 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 28 | * See the License for the specific language governing permissions and 29 | * limitations under the License. 30 | */ 31 | 32 | #include "edge-impulse-sdk/CMSIS/DSP/Include/dsp/distance_functions.h" 33 | #include 34 | #include 35 | 36 | 37 | 38 | /** 39 | @addtogroup Euclidean 40 | @{ 41 | */ 42 | 43 | 44 | /** 45 | * @brief Euclidean distance between two vectors 46 | * @param[in] pA First vector 47 | * @param[in] pB Second vector 48 | * @param[in] blockSize vector length 49 | * @return distance 50 | * 51 | */ 52 | float64_t arm_euclidean_distance_f64(const float64_t *pA,const float64_t *pB, uint32_t blockSize) 53 | { 54 | float64_t accum=0.,tmp; 55 | 56 | while(blockSize > 0) 57 | { 58 | tmp = *pA++ - *pB++; 59 | accum += SQ(tmp); 60 | blockSize --; 61 | } 62 | tmp = sqrt(accum); 63 | return(tmp); 64 | } 65 | 66 | /** 67 | * @} end of Euclidean group 68 | */ 69 | 70 | #endif // EIDSP_LOAD_CMSIS_DSP_SOURCES 71 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/Source/FastMathFunctions/arm_vexp_f64.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/dsp/config.hpp" 2 | #if EIDSP_LOAD_CMSIS_DSP_SOURCES 3 | /* ---------------------------------------------------------------------- 4 | * Project: CMSIS DSP Library 5 | * Title: arm_vlog_f64.c 6 | * Description: Fast vectorized log 7 | * 8 | * $Date: 13 September 2021 9 | * $Revision: V1.10.0 10 | * 11 | * Target Processor: Cortex-M and Cortex-A cores 12 | * -------------------------------------------------------------------- */ 13 | /* 14 | * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. 15 | * 16 | * SPDX-License-Identifier: Apache-2.0 17 | * 18 | * Licensed under the Apache License, Version 2.0 (the License); you may 19 | * not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at 21 | * 22 | * www.apache.org/licenses/LICENSE-2.0 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 26 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | */ 30 | 31 | #include "edge-impulse-sdk/CMSIS/DSP/Include/dsp/fast_math_functions.h" 32 | #include "edge-impulse-sdk/CMSIS/DSP/Include/arm_common_tables.h" 33 | 34 | /** 35 | @addtogroup vexp 36 | @{ 37 | */ 38 | 39 | /** 40 | @brief Floating-point vector of exp values. 41 | @param[in] pSrc points to the input vector 42 | @param[out] pDst points to the output vector 43 | @param[in] blockSize number of samples in each vector 44 | @return none 45 | */ 46 | void arm_vexp_f64( 47 | const float64_t * pSrc, 48 | float64_t * pDst, 49 | uint32_t blockSize) 50 | { 51 | uint32_t blkCnt; 52 | 53 | blkCnt = blockSize; 54 | 55 | while (blkCnt > 0U) 56 | { 57 | /* C = log(A) */ 58 | 59 | /* Calculate log and store result in destination buffer. */ 60 | *pDst++ = exp(*pSrc++); 61 | 62 | /* Decrement loop counter */ 63 | blkCnt--; 64 | } 65 | } 66 | 67 | /** 68 | @} end of vexp group 69 | */ 70 | #endif // EIDSP_LOAD_CMSIS_DSP_SOURCES 71 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/Source/FastMathFunctions/arm_vlog_f64.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/dsp/config.hpp" 2 | #if EIDSP_LOAD_CMSIS_DSP_SOURCES 3 | /* ---------------------------------------------------------------------- 4 | * Project: CMSIS DSP Library 5 | * Title: arm_vlog_f64.c 6 | * Description: Fast vectorized log 7 | * 8 | * $Date: 13 September 2021 9 | * $Revision: V1.10.0 10 | * 11 | * Target Processor: Cortex-M and Cortex-A cores 12 | * -------------------------------------------------------------------- */ 13 | /* 14 | * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. 15 | * 16 | * SPDX-License-Identifier: Apache-2.0 17 | * 18 | * Licensed under the Apache License, Version 2.0 (the License); you may 19 | * not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at 21 | * 22 | * www.apache.org/licenses/LICENSE-2.0 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 26 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | */ 30 | 31 | #include "edge-impulse-sdk/CMSIS/DSP/Include/dsp/fast_math_functions.h" 32 | #include "edge-impulse-sdk/CMSIS/DSP/Include/arm_common_tables.h" 33 | 34 | void arm_vlog_f64( 35 | const float64_t * pSrc, 36 | float64_t * pDst, 37 | uint32_t blockSize) 38 | { 39 | uint32_t blkCnt; 40 | 41 | blkCnt = blockSize; 42 | 43 | while (blkCnt > 0U) 44 | { 45 | /* C = log(A) */ 46 | 47 | /* Calculate log and store result in destination buffer. */ 48 | *pDst++ = log(*pSrc++); 49 | 50 | /* Decrement loop counter */ 51 | blkCnt--; 52 | } 53 | } 54 | 55 | #endif // EIDSP_LOAD_CMSIS_DSP_SOURCES 56 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/Source/MatrixFunctions/arm_mat_init_q15.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/dsp/config.hpp" 2 | #if EIDSP_LOAD_CMSIS_DSP_SOURCES 3 | /* ---------------------------------------------------------------------- 4 | * Project: CMSIS DSP Library 5 | * Title: arm_mat_init_q15.c 6 | * Description: Q15 matrix initialization 7 | * 8 | * $Date: 23 April 2021 9 | * $Revision: V1.9.0 10 | * 11 | * Target Processor: Cortex-M and Cortex-A cores 12 | * -------------------------------------------------------------------- */ 13 | /* 14 | * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. 15 | * 16 | * SPDX-License-Identifier: Apache-2.0 17 | * 18 | * Licensed under the Apache License, Version 2.0 (the License); you may 19 | * not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at 21 | * 22 | * www.apache.org/licenses/LICENSE-2.0 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 26 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | */ 30 | 31 | #include "edge-impulse-sdk/CMSIS/DSP/Include/dsp/matrix_functions.h" 32 | 33 | /** 34 | @ingroup groupMatrix 35 | */ 36 | 37 | /** 38 | @addtogroup MatrixInit 39 | @{ 40 | */ 41 | 42 | /** 43 | @brief Q15 matrix initialization. 44 | @param[in,out] S points to an instance of the floating-point matrix structure 45 | @param[in] nRows number of rows in the matrix 46 | @param[in] nColumns number of columns in the matrix 47 | @param[in] pData points to the matrix data array 48 | @return none 49 | */ 50 | 51 | void arm_mat_init_q15( 52 | arm_matrix_instance_q15 * S, 53 | uint16_t nRows, 54 | uint16_t nColumns, 55 | q15_t * pData) 56 | { 57 | /* Assign Number of Rows */ 58 | S->numRows = nRows; 59 | 60 | /* Assign Number of Columns */ 61 | S->numCols = nColumns; 62 | 63 | /* Assign Data pointer */ 64 | S->pData = pData; 65 | } 66 | 67 | /** 68 | @} end of MatrixInit group 69 | */ 70 | 71 | #endif // EIDSP_LOAD_CMSIS_DSP_SOURCES 72 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/Source/MatrixFunctions/arm_mat_init_q31.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/dsp/config.hpp" 2 | #if EIDSP_LOAD_CMSIS_DSP_SOURCES 3 | /* ---------------------------------------------------------------------- 4 | * Project: CMSIS DSP Library 5 | * Title: arm_mat_init_q31.c 6 | * Description: Q31 matrix initialization 7 | * 8 | * $Date: 23 April 2021 9 | * $Revision: V1.9.0 10 | * 11 | * Target Processor: Cortex-M and Cortex-A cores 12 | * -------------------------------------------------------------------- */ 13 | /* 14 | * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. 15 | * 16 | * SPDX-License-Identifier: Apache-2.0 17 | * 18 | * Licensed under the Apache License, Version 2.0 (the License); you may 19 | * not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at 21 | * 22 | * www.apache.org/licenses/LICENSE-2.0 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 26 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | */ 30 | 31 | #include "edge-impulse-sdk/CMSIS/DSP/Include/dsp/matrix_functions.h" 32 | 33 | /** 34 | @ingroup groupMatrix 35 | */ 36 | 37 | 38 | 39 | /** 40 | @addtogroup MatrixInit 41 | @{ 42 | */ 43 | 44 | /** 45 | @brief Q31 matrix initialization. 46 | @param[in,out] S points to an instance of the Q31 matrix structure 47 | @param[in] nRows number of rows in the matrix 48 | @param[in] nColumns number of columns in the matrix 49 | @param[in] pData points to the matrix data array 50 | @return none 51 | */ 52 | 53 | void arm_mat_init_q31( 54 | arm_matrix_instance_q31 * S, 55 | uint16_t nRows, 56 | uint16_t nColumns, 57 | q31_t * pData) 58 | { 59 | /* Assign Number of Rows */ 60 | S->numRows = nRows; 61 | 62 | /* Assign Number of Columns */ 63 | S->numCols = nColumns; 64 | 65 | /* Assign Data pointer */ 66 | S->pData = pData; 67 | } 68 | 69 | /** 70 | @} end of MatrixInit group 71 | */ 72 | 73 | #endif // EIDSP_LOAD_CMSIS_DSP_SOURCES 74 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/Source/StatisticsFunctions/arm_entropy_f64.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/dsp/config.hpp" 2 | #if EIDSP_LOAD_CMSIS_DSP_SOURCES 3 | /* ---------------------------------------------------------------------- 4 | * Project: CMSIS DSP Library 5 | * Title: arm_logsumexp_f64.c 6 | * Description: LogSumExp 7 | * 8 | * $Date: 23 April 2021 9 | * $Revision: V1.9.0 10 | * 11 | * Target Processor: Cortex-M and Cortex-A cores 12 | * -------------------------------------------------------------------- */ 13 | /* 14 | * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. 15 | * 16 | * SPDX-License-Identifier: Apache-2.0 17 | * 18 | * Licensed under the Apache License, Version 2.0 (the License); you may 19 | * not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at 21 | * 22 | * www.apache.org/licenses/LICENSE-2.0 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 26 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | */ 30 | 31 | #include "edge-impulse-sdk/CMSIS/DSP/Include/dsp/statistics_functions.h" 32 | #include 33 | #include 34 | 35 | /** 36 | * @addtogroup Entropy 37 | * @{ 38 | */ 39 | 40 | /** 41 | * @brief Entropy 42 | * 43 | * @param[in] pSrcA Array of input values. 44 | * @param[in] blockSize Number of samples in the input array. 45 | * @return Entropy -Sum(p ln p) 46 | * 47 | */ 48 | 49 | float64_t arm_entropy_f64(const float64_t * pSrcA, uint32_t blockSize) 50 | { 51 | const float64_t *pIn; 52 | uint32_t blkCnt; 53 | float64_t accum, p; 54 | 55 | pIn = pSrcA; 56 | blkCnt = blockSize; 57 | 58 | accum = 0.0; 59 | 60 | while(blkCnt > 0) 61 | { 62 | p = *pIn++; 63 | 64 | accum += p * log(p); 65 | 66 | blkCnt--; 67 | 68 | } 69 | 70 | return(-accum); 71 | } 72 | 73 | /** 74 | * @} end of Entropy group 75 | */ 76 | 77 | #endif // EIDSP_LOAD_CMSIS_DSP_SOURCES 78 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/Source/StatisticsFunctions/arm_std_f16.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/dsp/config.hpp" 2 | #if EIDSP_LOAD_CMSIS_DSP_SOURCES 3 | /* ---------------------------------------------------------------------- 4 | * Project: CMSIS DSP Library 5 | * Title: arm_std_f16.c 6 | * Description: Standard deviation of the elements of a floating-point vector 7 | * 8 | * $Date: 23 April 2021 9 | * $Revision: V1.9.0 10 | * 11 | * Target Processor: Cortex-M and Cortex-A cores 12 | * -------------------------------------------------------------------- */ 13 | /* 14 | * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. 15 | * 16 | * SPDX-License-Identifier: Apache-2.0 17 | * 18 | * Licensed under the Apache License, Version 2.0 (the License); you may 19 | * not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at 21 | * 22 | * www.apache.org/licenses/LICENSE-2.0 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 26 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | */ 30 | 31 | #include "edge-impulse-sdk/CMSIS/DSP/Include/dsp/statistics_functions_f16.h" 32 | 33 | #if defined(ARM_FLOAT16_SUPPORTED) 34 | 35 | 36 | /** 37 | @ingroup groupStats 38 | */ 39 | 40 | 41 | 42 | /** 43 | @addtogroup STD 44 | @{ 45 | */ 46 | 47 | /** 48 | @brief Standard deviation of the elements of a floating-point vector. 49 | @param[in] pSrc points to the input vector 50 | @param[in] blockSize number of samples in input vector 51 | @param[out] pResult standard deviation value returned here 52 | @return none 53 | */ 54 | void arm_std_f16( 55 | const float16_t * pSrc, 56 | uint32_t blockSize, 57 | float16_t * pResult) 58 | { 59 | float16_t var; 60 | arm_var_f16(pSrc,blockSize,&var); 61 | arm_sqrt_f16(var, pResult); 62 | } 63 | 64 | /** 65 | @} end of STD group 66 | */ 67 | 68 | #endif /* #if defined(ARM_FLOAT16_SUPPORTED) */ 69 | 70 | 71 | #endif // EIDSP_LOAD_CMSIS_DSP_SOURCES 72 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/Source/StatisticsFunctions/arm_std_f64.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/dsp/config.hpp" 2 | #if EIDSP_LOAD_CMSIS_DSP_SOURCES 3 | /* ---------------------------------------------------------------------- 4 | * Project: CMSIS DSP Library 5 | * Title: arm_std_f64.c 6 | * Description: Standard deviation of the elements of a floating-point vector 7 | * 8 | * $Date: 13 September 2021 9 | * $Revision: V1.10.0 10 | * 11 | * Target Processor: Cortex-M and Cortex-A cores 12 | * -------------------------------------------------------------------- */ 13 | /* 14 | * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. 15 | * 16 | * SPDX-License-Identifier: Apache-2.0 17 | * 18 | * Licensed under the Apache License, Version 2.0 (the License); you may 19 | * not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at 21 | * 22 | * www.apache.org/licenses/LICENSE-2.0 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 26 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | */ 30 | 31 | #include "edge-impulse-sdk/CMSIS/DSP/Include/dsp/statistics_functions.h" 32 | 33 | /** 34 | @ingroup groupStats 35 | */ 36 | 37 | /** 38 | @addtogroup STD 39 | @{ 40 | */ 41 | 42 | /** 43 | @brief Standard deviation of the elements of a floating-point vector. 44 | @param[in] pSrc points to the input vector 45 | @param[in] blockSize number of samples in input vector 46 | @param[out] pResult standard deviation value returned here 47 | @return none 48 | */ 49 | void arm_std_f64( 50 | const float64_t * pSrc, 51 | uint32_t blockSize, 52 | float64_t * pResult) 53 | { 54 | float64_t var; 55 | arm_var_f64(pSrc,blockSize,&var); 56 | *pResult = sqrt(var); 57 | } 58 | 59 | /** 60 | @} end of STD group 61 | */ 62 | 63 | #endif // EIDSP_LOAD_CMSIS_DSP_SOURCES 64 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/Source/SupportFunctions/arm_merge_sort_init_f32.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/dsp/config.hpp" 2 | #if EIDSP_LOAD_CMSIS_DSP_SOURCES 3 | /* ---------------------------------------------------------------------- 4 | * Project: CMSIS DSP Library 5 | * Title: arm_merge_sort_init_f32.c 6 | * Description: Floating point merge sort initialization function 7 | * 8 | * $Date: 23 April 2021 9 | * $Revision: V1.9.0 10 | * 11 | * Target Processor: Cortex-M and Cortex-A cores 12 | * -------------------------------------------------------------------- */ 13 | /* 14 | * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. 15 | * 16 | * SPDX-License-Identifier: Apache-2.0 17 | * 18 | * Licensed under the Apache License, Version 2.0 (the License); you may 19 | * not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at 21 | * 22 | * www.apache.org/licenses/LICENSE-2.0 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 26 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | */ 30 | 31 | #include "edge-impulse-sdk/CMSIS/DSP/Include/dsp/support_functions.h" 32 | 33 | /** 34 | @ingroup groupSupport 35 | */ 36 | 37 | /** 38 | @addtogroup Sorting 39 | @{ 40 | */ 41 | 42 | 43 | /** 44 | * @param[in,out] S points to an instance of the sorting structure. 45 | * @param[in] dir Sorting order. 46 | * @param[in] buffer Working buffer. 47 | */ 48 | void arm_merge_sort_init_f32(arm_merge_sort_instance_f32 * S, arm_sort_dir dir, float32_t * buffer) 49 | { 50 | S->dir = dir; 51 | S->buffer = buffer; 52 | } 53 | /** 54 | @} end of Sorting group 55 | */ 56 | 57 | #endif // EIDSP_LOAD_CMSIS_DSP_SOURCES 58 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/DSP/Source/SupportFunctions/arm_sort_init_f32.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/dsp/config.hpp" 2 | #if EIDSP_LOAD_CMSIS_DSP_SOURCES 3 | /* ---------------------------------------------------------------------- 4 | * Project: CMSIS DSP Library 5 | * Title: arm_sort_init_f32.c 6 | * Description: Floating point sort initialization function 7 | * 8 | * $Date: 23 April 2021 9 | * $Revision: V1.9.0 10 | * 11 | * Target Processor: Cortex-M and Cortex-A cores 12 | * -------------------------------------------------------------------- */ 13 | /* 14 | * Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. 15 | * 16 | * SPDX-License-Identifier: Apache-2.0 17 | * 18 | * Licensed under the Apache License, Version 2.0 (the License); you may 19 | * not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at 21 | * 22 | * www.apache.org/licenses/LICENSE-2.0 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 26 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | */ 30 | 31 | #include "edge-impulse-sdk/CMSIS/DSP/Include/arm_sorting.h" 32 | 33 | /** 34 | @ingroup groupSupport 35 | */ 36 | 37 | /** 38 | @addtogroup Sorting 39 | @{ 40 | */ 41 | 42 | 43 | /** 44 | * @param[in,out] S points to an instance of the sorting structure. 45 | * @param[in] alg Selected algorithm. 46 | * @param[in] dir Sorting order. 47 | */ 48 | void arm_sort_init_f32(arm_sort_instance_f32 * S, arm_sort_alg alg, arm_sort_dir dir) 49 | { 50 | S->alg = alg; 51 | S->dir = dir; 52 | } 53 | 54 | /** 55 | @} end of Sorting group 56 | */ 57 | 58 | #endif // EIDSP_LOAD_CMSIS_DSP_SOURCES 59 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/NN/Include/arm_nn_tables.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------- 2 | * Project: CMSIS NN Library 3 | * Title: arm_nn_tables.h 4 | * Description: Extern declaration for NN tables 5 | * 6 | * $Date: 17. August 2021 7 | * $Revision: V.1.0.2 8 | * 9 | * Target Processor: Cortex-M cores 10 | * -------------------------------------------------------------------- */ 11 | /* 12 | * Copyright (C) 2010-2018 Arm Limited or its affiliates. All rights reserved. 13 | * 14 | * SPDX-License-Identifier: Apache-2.0 15 | * 16 | * Licensed under the Apache License, Version 2.0 (the License); you may 17 | * not use this file except in compliance with the License. 18 | * You may obtain a copy of the License at 19 | * 20 | * www.apache.org/licenses/LICENSE-2.0 21 | * 22 | * Unless required by applicable law or agreed to in writing, software 23 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 24 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | * See the License for the specific language governing permissions and 26 | * limitations under the License. 27 | */ 28 | 29 | #ifndef _ARM_NN_TABLES_H 30 | #define _ARM_NN_TABLES_H 31 | 32 | #include "edge-impulse-sdk/CMSIS/NN/Include/arm_nn_math_types.h" 33 | 34 | /** 35 | * @brief tables for various activation functions 36 | * 37 | */ 38 | 39 | extern const q15_t sigmoidTable_q15[256]; 40 | extern const q7_t sigmoidTable_q7[256]; 41 | 42 | extern const q7_t tanhTable_q7[256]; 43 | extern const q15_t tanhTable_q15[256]; 44 | 45 | /** 46 | * @brief 2-way tables for various activation functions 47 | * 48 | * 2-way table, H table for value larger than 1/4 49 | * L table for value smaller than 1/4, H table for remaining 50 | * We have this only for the q15_t version. It does not make 51 | * sense to have it for q7_t type 52 | */ 53 | extern const q15_t sigmoidHTable_q15[192]; 54 | extern const q15_t sigmoidLTable_q15[128]; 55 | 56 | #endif /* ARM_NN_TABLES_H */ 57 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/NN/Source/ActivationFunctions/arm_relu6_s8.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/classifier/ei_classifier_config.h" 2 | #if EI_CLASSIFIER_TFLITE_LOAD_CMSIS_NN_SOURCES 3 | /* 4 | * Copyright (C) 2010-2019 Arm Limited or its affiliates. All rights reserved. 5 | * 6 | * SPDX-License-Identifier: Apache-2.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the License); you may 9 | * not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 16 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | /* ---------------------------------------------------------------------- 22 | * Project: CMSIS NN Library 23 | * Title: arm_relu6_s8.c 24 | * Description: Basic s8 version of ReLU6 25 | * 26 | * $Date: 09. October 2020 27 | * $Revision: V.1.0.1 28 | * 29 | * Target Processor: Cortex-M cores 30 | * 31 | * -------------------------------------------------------------------- */ 32 | 33 | #include "edge-impulse-sdk/CMSIS/NN/Include/arm_nnfunctions.h" 34 | #include "edge-impulse-sdk/CMSIS/NN/Include/arm_nnsupportfunctions.h" 35 | 36 | /** 37 | * @ingroup groupNN 38 | */ 39 | 40 | /** 41 | * @addtogroup Acti 42 | * @{ 43 | */ 44 | 45 | /* 46 | * Basic ReLU6 function 47 | * 48 | * Refer to header file for details. 49 | * 50 | */ 51 | 52 | void arm_relu6_s8(q7_t *data, uint16_t size) 53 | { 54 | int32_t i; 55 | 56 | for (i = 0; i < size; i++) 57 | { 58 | int32_t ip = data[i]; 59 | 60 | ip = MAX(ip, 0); 61 | data[i] = MIN(ip, 6); 62 | } 63 | } 64 | 65 | /** 66 | * @} end of Acti group 67 | */ 68 | 69 | #endif // EI_CLASSIFIER_TFLITE_LOAD_CMSIS_NN_SOURCES 70 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/NN/Source/ReshapeFunctions/arm_reshape_s8.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/classifier/ei_classifier_config.h" 2 | #if EI_CLASSIFIER_TFLITE_LOAD_CMSIS_NN_SOURCES 3 | /* 4 | * SPDX-FileCopyrightText: Copyright 2010-2022 Arm Limited and/or its affiliates 5 | * 6 | * SPDX-License-Identifier: Apache-2.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the License); you may 9 | * not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 16 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | /* ---------------------------------------------------------------------- 22 | * Project: CMSIS NN Library 23 | * Title: arm_reshape_s8.c 24 | * Description: Reshape a s8 vector 25 | * 26 | * $Date: 4 Aug 2022 27 | * $Revision: V.1.0.1 28 | * 29 | * Target Processor: Cortex-M cores 30 | * 31 | * -------------------------------------------------------------------- */ 32 | 33 | #include "edge-impulse-sdk/CMSIS/NN/Include/arm_nnfunctions.h" 34 | #include "edge-impulse-sdk/CMSIS/NN/Include/arm_nnsupportfunctions.h" 35 | 36 | /** 37 | * @ingroup groupNN 38 | */ 39 | 40 | /** 41 | * @addtogroup Reshape 42 | * @{ 43 | */ 44 | 45 | /* 46 | * Basic s8 reshape function. 47 | * 48 | * Refer header file for details. 49 | * 50 | */ 51 | 52 | void arm_reshape_s8(const int8_t *input, int8_t *output, const uint32_t total_size) 53 | { 54 | arm_memcpy_q7(output, input, total_size); 55 | } 56 | 57 | /** 58 | * @} end of Reshape group 59 | */ 60 | 61 | #endif // EI_CLASSIFIER_TFLITE_LOAD_CMSIS_NN_SOURCES 62 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/NN/Source/SoftmaxFunctions/arm_softmax_s8_s16.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/classifier/ei_classifier_config.h" 2 | #if EI_CLASSIFIER_TFLITE_LOAD_CMSIS_NN_SOURCES 3 | /* 4 | * Copyright (C) 2022 Arm Limited or its affiliates. 5 | * 6 | * SPDX-License-Identifier: Apache-2.0 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the License); you may 9 | * not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 16 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | /* ---------------------------------------------------------------------- 22 | * Project: CMSIS NN Library 23 | * Title: arm_softmax_s8_s16.c 24 | * Description: S8 to s16 softmax function 25 | * 26 | * $Date: 7 January 2022 27 | * $Revision: V.1.0.0 28 | * 29 | * Target Processor: Cortex-M cores 30 | * 31 | * -------------------------------------------------------------------- */ 32 | 33 | #include "edge-impulse-sdk/CMSIS/NN/Include/arm_nnfunctions.h" 34 | #include "edge-impulse-sdk/CMSIS/NN/Include/arm_nnsupportfunctions.h" 35 | 36 | /** 37 | * @ingroup groupNN 38 | */ 39 | 40 | /** 41 | * @addtogroup Softmax 42 | * @{ 43 | */ 44 | 45 | void arm_softmax_s8_s16(const int8_t *input, 46 | const int32_t num_rows, 47 | const int32_t row_size, 48 | const int32_t mult, 49 | const int32_t shift, 50 | const int32_t diff_min, 51 | int16_t *output) 52 | { 53 | arm_nn_softmax_common_s8(input, num_rows, row_size, mult, shift, diff_min, true, (void *)output); 54 | } 55 | /** 56 | * @} end of Softmax group 57 | */ 58 | 59 | #endif // EI_CLASSIFIER_TFLITE_LOAD_CMSIS_NN_SOURCES 60 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/CMSIS/sources.txt: -------------------------------------------------------------------------------- 1 | Created by update_tflite.sh 2 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/LICENSE: -------------------------------------------------------------------------------- 1 | Unless specifically indicated otherwise in a file, files are licensed under the BSD 3-Clause Clear license, as can be found in: LICENSE.3-clause-bsd-clear 2 | 3 | Folders containing third party code and libraries are listed below. Each folder contains its own license specified for its files. 4 | 5 | * CMSIS - Apache 2.0 6 | * dsp/kissfft - BSD-3-Clause 7 | * porting/espressif/ESP-NN - Apache 2.0 8 | * porting/ethos-core-driver - Apache 2.0 9 | * tensorflow - Apache 2.0 10 | * third_party/arc_mli_package - BSD-3-Clause 11 | * third_party/flatbuffers - Apache 2.0 12 | * third_party/gemmlowp - Apache 2.0 13 | * third_party/incbin - Public domain 14 | * third_party/ruy - Apache 2.0 15 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/LICENSE.3-clause-bsd-clear: -------------------------------------------------------------------------------- 1 | The Clear BSD License 2 | 3 | Copyright (c) 2025 EdgeImpulse Inc. 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted (subject to the limitations in the disclaimer 8 | below) provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /src/edge-impulse-sdk/README.md: -------------------------------------------------------------------------------- 1 | # Edge Impulse DSP and Inferencing SDK 2 | 3 | Portable library for digital signal processing and machine learning inferencing. This repository contains the device implementation in C++ for both processing and learning blocks in [Edge Impulse](https://www.edgeimpulse.com). 4 | 5 | [Documentation](https://docs.edgeimpulse.com/reference#inferencing-sdk) 6 | 7 | ## Develop locally 8 | 9 | If you want to develop locally the easiest is to grab the [example-standalone-inferencing](https://github.com/edgeimpulse/example-standalone-inferencing) (Desktop) or [example-standalone-inferencing-mbed](https://github.com/edgeimpulse/example-standalone-inferencing-mbed) (ST IoT Discovery Kit, f.e. to test CMSIS-DSP / CMSIS-NN integration) example applications, add your Edge Impulse project (use the C++ Library export option), then symlink this repository in. 10 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/classifier/ei_constants.h: -------------------------------------------------------------------------------- 1 | #ifndef __EI_CONSTANTS__H__ 2 | #define __EI_CONSTANTS__H__ 3 | 4 | #define EI_CLASSIFIER_RESIZE_NONE 0 5 | #define EI_CLASSIFIER_RESIZE_FIT_SHORTEST 1 6 | #define EI_CLASSIFIER_RESIZE_FIT_LONGEST 2 7 | #define EI_CLASSIFIER_RESIZE_SQUASH 3 8 | 9 | // This exists for linux runner, etc 10 | __attribute__((unused)) static const char *EI_RESIZE_STRINGS[] = { "none", "fit-shortest", "fit-longest", "squash" }; 11 | 12 | #endif //!__EI_CONSTANTS__H__ -------------------------------------------------------------------------------- /src/edge-impulse-sdk/classifier/ei_run_classifier_image.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _EDGE_IMPULSE_RUN_CLASSIFIER_IMAGE_H_ 36 | #define _EDGE_IMPULSE_RUN_CLASSIFIER_IMAGE_H_ 37 | 38 | #include "ei_run_classifier.h" 39 | 40 | 41 | 42 | #endif // _EDGE_IMPULSE_RUN_CLASSIFIER_IMAGE_H_ 43 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/classifier/postprocessing/tinyEKF/LICENSE.md: -------------------------------------------------------------------------------- 1 | TinyEKF 2 | 3 | Copyright (c) Simon D. Levy 4 | 5 | All rights reserved. 6 | 7 | MIT License 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy of 10 | this software and associated documentation files (the ""Software""), to deal in 11 | the Software without restriction, including without limitation the rights to 12 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 13 | of the Software, and to permit persons to whom the Software is furnished to do 14 | so, subject to the following conditions: The above copyright notice and this 15 | permission notice shall be included in all copies or substantial portions of 16 | the Software. THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO 19 | EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES 20 | OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/cmake/zephyr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13.1) 2 | 3 | if(NOT TARGET app) 4 | message(FATAL_ERROR "Please create a target named 'app' (ex: add_executable(app)) before adding this file") 5 | endif() 6 | 7 | set(CMAKE_CXX_STANDARD 11) 8 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 9 | 10 | set(EI_SDK_FOLDER ../../) 11 | 12 | include(${EI_SDK_FOLDER}/cmake/utils.cmake) 13 | 14 | target_include_directories(app PRIVATE 15 | ${EI_SDK_FOLDER} 16 | ) 17 | 18 | RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES "${EI_SDK_FOLDER}" "*.cpp") 19 | RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES "${EI_SDK_FOLDER}" "*.cc") 20 | RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES "${EI_SDK_FOLDER}" "*.s") 21 | RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES "${EI_SDK_FOLDER}/CMSIS/DSP/Source/TransformFunctions" "*.c") 22 | RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES "${EI_SDK_FOLDER}/CMSIS/DSP/Source/CommonTables" "*.c") 23 | RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES "${EI_SDK_FOLDER}/CMSIS/DSP/Source/BasicMathFunctions" "*.c") 24 | RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES "${EI_SDK_FOLDER}/CMSIS/DSP/Source/ComplexMathFunctions" "*.c") 25 | RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES "${EI_SDK_FOLDER}/CMSIS/DSP/Source/FastMathFunctions" "*.c") 26 | RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES "${EI_SDK_FOLDER}/CMSIS/DSP/Source/SupportFunctions" "*.c") 27 | RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES "${EI_SDK_FOLDER}/CMSIS/DSP/Source/MatrixFunctions" "*.c") 28 | RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES "${EI_SDK_FOLDER}/CMSIS/DSP/Source/StatisticsFunctions" "*.c") 29 | RECURSIVE_FIND_FILE_APPEND(EI_SOURCE_FILES "${EI_SDK_FOLDER}/CMSIS/NN/Source" "*.c") 30 | LIST(APPEND EI_SOURCE_FILES "${EI_SDK_FOLDER}/tensorflow/lite/c/common.c") 31 | 32 | target_sources(app PRIVATE ${EI_SOURCE_FILES}) -------------------------------------------------------------------------------- /src/edge-impulse-sdk/dsp/README.md: -------------------------------------------------------------------------------- 1 | See notes in the various block folders in studio/dsp-pipeline 2 | 3 | studio/dsp-pipeline/mfcc/README.md -------------------------------------------------------------------------------- /src/edge-impulse-sdk/dsp/dct/.clang-format: -------------------------------------------------------------------------------- 1 | "DisableFormat": true 2 | "SortIncludes": false 3 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/dsp/dct/fast-dct-fft.cpp: -------------------------------------------------------------------------------- 1 | // This file intentinally left blank 2 | // Function moved to numpy.hpp -------------------------------------------------------------------------------- /src/edge-impulse-sdk/dsp/dct/fast-dct-fft.h: -------------------------------------------------------------------------------- 1 | #ifndef __FAST_DCT_FFT__H__ 2 | #define __FAST_DCT_FFT__H__ 3 | 4 | // This file intentinally left blank 5 | // Function moved to numpy.hpp 6 | 7 | #endif //!__FAST-DCT-FFT__H__ -------------------------------------------------------------------------------- /src/edge-impulse-sdk/dsp/ei_vector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 EdgeImpulse Inc. 3 | * 4 | * Generated by Edge Impulse and licensed under the applicable Edge Impulse 5 | * Terms of Service. Community and Professional Terms of Service 6 | * (https://edgeimpulse.com/legal/terms-of-service) or Enterprise Terms of 7 | * Service (https://edgeimpulse.com/legal/enterprise-terms-of-service), 8 | * according to your product plan subscription (the “License”). 9 | * 10 | * This software, documentation and other associated files (collectively referred 11 | * to as the “Software”) is a single SDK variation generated by the Edge Impulse 12 | * platform and requires an active paid Edge Impulse subscription to use this 13 | * Software for any purpose. 14 | * 15 | * You may NOT use this Software unless you have an active Edge Impulse subscription 16 | * that meets the eligibility requirements for the applicable License, subject to 17 | * your full and continued compliance with the terms and conditions of the License, 18 | * including without limitation any usage restrictions under the applicable License. 19 | * 20 | * If you do not have an active Edge Impulse product plan subscription, or if use 21 | * of this Software exceeds the usage limitations of your Edge Impulse product plan 22 | * subscription, you are not permitted to use this Software and must immediately 23 | * delete and erase all copies of this Software within your control or possession. 24 | * Edge Impulse reserves all rights and remedies available to enforce its rights. 25 | * 26 | * Unless required by applicable law or agreed to in writing, the Software is 27 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 28 | * either express or implied. See the License for the specific language governing 29 | * permissions, disclaimers and limitations under the License. 30 | */ 31 | #ifndef __EI_VECTOR__H__ 32 | #define __EI_VECTOR__H__ 33 | 34 | #include "ei_alloc.h" 35 | #include 36 | 37 | template 38 | using ei_vector = std::vector>; 39 | 40 | #endif //!__EI_VECTOR__H__ -------------------------------------------------------------------------------- /src/edge-impulse-sdk/dsp/image/image.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 EdgeImpulse Inc. 3 | * 4 | * Generated by Edge Impulse and licensed under the applicable Edge Impulse 5 | * Terms of Service. Community and Professional Terms of Service 6 | * (https://edgeimpulse.com/legal/terms-of-service) or Enterprise Terms of 7 | * Service (https://edgeimpulse.com/legal/enterprise-terms-of-service), 8 | * according to your product plan subscription (the “License”). 9 | * 10 | * This software, documentation and other associated files (collectively referred 11 | * to as the “Software”) is a single SDK variation generated by the Edge Impulse 12 | * platform and requires an active paid Edge Impulse subscription to use this 13 | * Software for any purpose. 14 | * 15 | * You may NOT use this Software unless you have an active Edge Impulse subscription 16 | * that meets the eligibility requirements for the applicable License, subject to 17 | * your full and continued compliance with the terms and conditions of the License, 18 | * including without limitation any usage restrictions under the applicable License. 19 | * 20 | * If you do not have an active Edge Impulse product plan subscription, or if use 21 | * of this Software exceeds the usage limitations of your Edge Impulse product plan 22 | * subscription, you are not permitted to use this Software and must immediately 23 | * delete and erase all copies of this Software within your control or possession. 24 | * Edge Impulse reserves all rights and remedies available to enforce its rights. 25 | * 26 | * Unless required by applicable law or agreed to in writing, the Software is 27 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 28 | * either express or implied. See the License for the specific language governing 29 | * permissions, disclaimers and limitations under the License. 30 | */ 31 | #ifndef _EIDSP_IMAGE_H_ 32 | #define _EIDSP_IMAGE_H_ 33 | 34 | #include "edge-impulse-sdk/dsp/image/processing.hpp" 35 | 36 | #endif -------------------------------------------------------------------------------- /src/edge-impulse-sdk/dsp/kissfft/.clang-format: -------------------------------------------------------------------------------- 1 | "DisableFormat": true 2 | "SortIncludes": false 3 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/dsp/kissfft/LICENSE: -------------------------------------------------------------------------------- 1 | Revised BSD License, see COPYING for verbiage. 2 | Basically, "free to use&change, give credit where due, no guarantees" 3 | Note this license is compatible with GPL at one end of the spectrum and closed, commercial software at 4 | the other end. See http://www.fsf.org/licensing/licenses 5 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/dsp/kissfft/README.md: -------------------------------------------------------------------------------- 1 | # KissFFT 2 | 3 | Software FFT library used for devices that do not have hardware accelerated RFFT, or where we want to use mixed-radix FFT. Based off of https://github.com/mborgerding/kissfft. 4 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/dsp/kissfft/kiss_fftr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003-2010, Mark Borgerding. All rights reserved. 3 | * This file is part of KISS FFT - https://github.com/mborgerding/kissfft 4 | * 5 | * SPDX-License-Identifier: BSD-3-Clause 6 | * See COPYING file for more information. 7 | */ 8 | 9 | #ifndef KISS_FTR_H 10 | #define KISS_FTR_H 11 | 12 | #include "kiss_fft.h" 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | 18 | /* 19 | 20 | Real optimized version can save about 45% cpu time vs. complex fft of a real seq. 21 | 22 | 23 | 24 | */ 25 | 26 | typedef struct kiss_fftr_state *kiss_fftr_cfg; 27 | 28 | 29 | kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem, size_t * memallocated = NULL); 30 | /* 31 | nfft must be even 32 | 33 | If you don't care to allocate space, use mem = lenmem = NULL 34 | */ 35 | 36 | 37 | void kiss_fftr(kiss_fftr_cfg cfg,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata); 38 | /* 39 | input timedata has nfft scalar points 40 | output freqdata has nfft/2+1 complex points 41 | */ 42 | 43 | void kiss_fftri(kiss_fftr_cfg cfg,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata); 44 | /* 45 | input freqdata has nfft/2+1 complex points 46 | output timedata has nfft scalar points 47 | */ 48 | 49 | #define kiss_fftr_free KISS_FFT_FREE 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | #endif 55 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/dsp/memory.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 EdgeImpulse Inc. 3 | * 4 | * Generated by Edge Impulse and licensed under the applicable Edge Impulse 5 | * Terms of Service. Community and Professional Terms of Service 6 | * (https://edgeimpulse.com/legal/terms-of-service) or Enterprise Terms of 7 | * Service (https://edgeimpulse.com/legal/enterprise-terms-of-service), 8 | * according to your product plan subscription (the “License”). 9 | * 10 | * This software, documentation and other associated files (collectively referred 11 | * to as the “Software”) is a single SDK variation generated by the Edge Impulse 12 | * platform and requires an active paid Edge Impulse subscription to use this 13 | * Software for any purpose. 14 | * 15 | * You may NOT use this Software unless you have an active Edge Impulse subscription 16 | * that meets the eligibility requirements for the applicable License, subject to 17 | * your full and continued compliance with the terms and conditions of the License, 18 | * including without limitation any usage restrictions under the applicable License. 19 | * 20 | * If you do not have an active Edge Impulse product plan subscription, or if use 21 | * of this Software exceeds the usage limitations of your Edge Impulse product plan 22 | * subscription, you are not permitted to use this Software and must immediately 23 | * delete and erase all copies of this Software within your control or possession. 24 | * Edge Impulse reserves all rights and remedies available to enforce its rights. 25 | * 26 | * Unless required by applicable law or agreed to in writing, the Software is 27 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 28 | * either express or implied. See the License for the specific language governing 29 | * permissions, disclaimers and limitations under the License. 30 | */ 31 | #include "memory.hpp" 32 | 33 | size_t ei_memory_in_use = 0; 34 | size_t ei_memory_peak_use = 0; 35 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/dsp/spectral/spectral.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 EdgeImpulse Inc. 3 | * 4 | * Generated by Edge Impulse and licensed under the applicable Edge Impulse 5 | * Terms of Service. Community and Professional Terms of Service 6 | * (https://edgeimpulse.com/legal/terms-of-service) or Enterprise Terms of 7 | * Service (https://edgeimpulse.com/legal/enterprise-terms-of-service), 8 | * according to your product plan subscription (the “License”). 9 | * 10 | * This software, documentation and other associated files (collectively referred 11 | * to as the “Software”) is a single SDK variation generated by the Edge Impulse 12 | * platform and requires an active paid Edge Impulse subscription to use this 13 | * Software for any purpose. 14 | * 15 | * You may NOT use this Software unless you have an active Edge Impulse subscription 16 | * that meets the eligibility requirements for the applicable License, subject to 17 | * your full and continued compliance with the terms and conditions of the License, 18 | * including without limitation any usage restrictions under the applicable License. 19 | * 20 | * If you do not have an active Edge Impulse product plan subscription, or if use 21 | * of this Software exceeds the usage limitations of your Edge Impulse product plan 22 | * subscription, you are not permitted to use this Software and must immediately 23 | * delete and erase all copies of this Software within your control or possession. 24 | * Edge Impulse reserves all rights and remedies available to enforce its rights. 25 | * 26 | * Unless required by applicable law or agreed to in writing, the Software is 27 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 28 | * either express or implied. See the License for the specific language governing 29 | * permissions, disclaimers and limitations under the License. 30 | */ 31 | #ifndef _EIDSP_SPECTRAL_SPECTRAL_H_ 32 | #define _EIDSP_SPECTRAL_SPECTRAL_H_ 33 | 34 | #include "../config.hpp" 35 | #include "processing.hpp" 36 | #include "feature.hpp" 37 | 38 | #endif // _EIDSP_SPECTRAL_SPECTRAL_H_ 39 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/dsp/speechpy/speechpy.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 EdgeImpulse Inc. 3 | * 4 | * Generated by Edge Impulse and licensed under the applicable Edge Impulse 5 | * Terms of Service. Community and Professional Terms of Service 6 | * (https://edgeimpulse.com/legal/terms-of-service) or Enterprise Terms of 7 | * Service (https://edgeimpulse.com/legal/enterprise-terms-of-service), 8 | * according to your product plan subscription (the “License”). 9 | * 10 | * This software, documentation and other associated files (collectively referred 11 | * to as the “Software”) is a single SDK variation generated by the Edge Impulse 12 | * platform and requires an active paid Edge Impulse subscription to use this 13 | * Software for any purpose. 14 | * 15 | * You may NOT use this Software unless you have an active Edge Impulse subscription 16 | * that meets the eligibility requirements for the applicable License, subject to 17 | * your full and continued compliance with the terms and conditions of the License, 18 | * including without limitation any usage restrictions under the applicable License. 19 | * 20 | * If you do not have an active Edge Impulse product plan subscription, or if use 21 | * of this Software exceeds the usage limitations of your Edge Impulse product plan 22 | * subscription, you are not permitted to use this Software and must immediately 23 | * delete and erase all copies of this Software within your control or possession. 24 | * Edge Impulse reserves all rights and remedies available to enforce its rights. 25 | * 26 | * Unless required by applicable law or agreed to in writing, the Software is 27 | * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 28 | * either express or implied. See the License for the specific language governing 29 | * permissions, disclaimers and limitations under the License. 30 | */ 31 | #ifndef _EIDSP_SPEECHPY_SPEECHPY_H_ 32 | #define _EIDSP_SPEECHPY_SPEECHPY_H_ 33 | 34 | #include "../config.hpp" 35 | #include "feature.hpp" 36 | #include "functions.hpp" 37 | #include "processing.hpp" 38 | 39 | #endif // _EIDSP_SPEECHPY_SPEECHPY_H_ 40 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/porting/.clang-format: -------------------------------------------------------------------------------- 1 | "DisableFormat": true 2 | "SortIncludes": false 3 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/porting/clib/debug_log.cpp: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #include "../ei_classifier_porting.h" 36 | #if EI_PORTING_CLIB == 1 37 | 38 | #include 39 | #include 40 | 41 | // Redirect TFLite DebugLog to ei_printf 42 | #if defined(__cplusplus) && EI_C_LINKAGE == 1 43 | extern "C" 44 | #endif // defined(__cplusplus) && EI_C_LINKAGE == 1 45 | void DebugLog(const char* s) { 46 | ei_printf("%s", s); 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/porting/espressif/ESP-NN/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions to ESP-NN project in the form of pull requests, bug reports, and feature requests are welcome! 4 | 5 | This document covers various topics related to contributions to the ESP-NN projects. Please read it if you plan to submit a PR! 6 | 7 | ## CLA 8 | 9 | We require accepting the contributor's license agreement for all pull requests. When opening a pull request the first time you will be prompted to sign the CLA by the [CLA Assistant](https://cla-assistant.io/) service. 10 | 11 | ## Large-scale Changes 12 | 13 | If you'd like to propose a change to the existing APIs or a large-scale refactoring of the implementation, we recommend opening an issue first to discuss this. 14 | 15 | ## Updating the Benchmarks Table 16 | 17 | The benchmarks table in [README.md](README.md) contains benchmarks for ESP32-S3. The benchmarks are collected by running the app in [test_app](test_app/) directory. Please update this table if you have changed the implementations of some of the functions or added the new ones. 18 | 19 | ## Releasing a new version 20 | 21 | Maintainers should follow the steps below to release a new version of ESP-NN component. Assuming the new version is `vX.Y.Z`: 22 | 23 | 1. Ensure you are on the latest `master` branch: 24 | ```bash 25 | git checkout master 26 | git pull --ff-only origin master 27 | ``` 28 | 1. Create the new tag: 29 | ```bash 30 | git tag -s -a -m "vX.Y.Z" vX.Y.Z 31 | ``` 32 | 1. Push the tag and the branch to the internal repository: 33 | ```bash 34 | git push origin vX.Y.Z 35 | ``` 36 | 1. CI will automatically push the tag to Github and will upload the new version to the IDF Component Registry. 37 | 1. Go to https://github.com/espressif/esp-nn/releases and create a release from the tag vX.Y.Z. 38 | 1. Write the release notes and publish the release. 39 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/porting/espressif/ESP-NN/Kconfig.projbuild: -------------------------------------------------------------------------------- 1 | menu "ESP-NN" 2 | 3 | choice NN_OPTIMIZATIONS 4 | bool "Optimization for nn functions" 5 | default NN_OPTIMIZED 6 | help 7 | Use ANSI-C versions for verification and debug purpose. 8 | Optimisations are automatically picked up for a chipset. 9 | For ESP32-S3, assembly optimisations are selected. 10 | For other platforms(viz., ESP32, ESP32-C3), generic optimisations are used. 11 | 12 | config NN_ANSI_C 13 | bool "ANSI C" 14 | help 15 | ANSI C versions for verification and debug purposes. 16 | config NN_OPTIMIZED 17 | bool "Optimized versions" 18 | help 19 | Optimisations are automatically picked up for a chipset. 20 | For ESP32-S3, assembly optimisations are selected. 21 | For other platforms(viz., ESP32, ESP32-C3), generic optimisations are used. 22 | endchoice 23 | 24 | config NN_OPTIMIZATIONS 25 | int 26 | default 0 if NN_ANSI_C 27 | default 1 if NN_OPTIMIZED 28 | 29 | endmenu 30 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/porting/espressif/ESP-NN/README.md: -------------------------------------------------------------------------------- 1 | Internal Edge Impulse fork of ESP-NN. Derived from https://github.com/edgeimpulse/esp-nn/commit/6b3ef8e226a05554a6d874f6456f5ca1771c01c2. 2 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/porting/espressif/ESP-NN/idf_component.yml: -------------------------------------------------------------------------------- 1 | description: Optimized NN (Neural Network) functions for Espressif chips 2 | url: https://github.com/espressif/esp-nn 3 | repository: https://github.com/espressif/esp-nn.git 4 | issues: https://github.com/espressif/esp-nn/issues 5 | dependencies: 6 | idf: 7 | version: ">=4.2" 8 | files: 9 | exclude: 10 | - test_app 11 | - tests 12 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/porting/espressif/ESP-NN/include/esp_nn.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2021 Espressif Systems (Shanghai) PTE LTD 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 | #pragma once 16 | 17 | #if defined(EI_CLASSIFIER_TFLITE_ENABLE_ESP_NN) 18 | // select apt optimisations 19 | #ifdef CONFIG_IDF_TARGET_ESP32P4 20 | #define ARCH_ESP32_P4 1 21 | #endif 22 | #ifdef CONFIG_IDF_TARGET_ESP32S3 23 | #define ARCH_ESP32_S3 1 24 | #endif 25 | #ifdef CONFIG_IDF_TARGET_ESP32 26 | #define ARCH_ESP32 1 27 | #endif 28 | #endif 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /* reference kernels included by default */ 35 | #include "esp_nn_ansi_headers.h" 36 | 37 | #if defined(EI_CLASSIFIER_TFLITE_ENABLE_ESP_NN) 38 | #if defined(ARCH_ESP32_P4) 39 | #include "esp_nn_esp32p4.h" 40 | #elif defined(ARCH_ESP32_S3) 41 | #include "esp_nn_esp32s3.h" 42 | #else // for other platforms use generic optimisations 43 | #include "esp_nn_generic_opt.h" 44 | #endif // #if defined(ARCH_ESP32_S3) 45 | #else 46 | #include "esp_nn_ansi_c.h" 47 | #endif 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/porting/espressif/ESP-NN/include/esp_nn_ansi_c.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2021 Espressif Systems (Shanghai) PTE LTD 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 | * @file Header definitions to include for ANSI C versions. 17 | * These are just typedefs to pick up ANSI versions. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "esp_nn_defs.h" 23 | #include "esp_nn_ansi_headers.h" 24 | 25 | #define esp_nn_add_elementwise_s8 esp_nn_add_elementwise_s8_ansi 26 | #define esp_nn_mul_elementwise_s8 esp_nn_mul_elementwise_s8_ansi 27 | 28 | #define esp_nn_depthwise_conv_s8 esp_nn_depthwise_conv_s8_ansi 29 | 30 | #define esp_nn_conv_s8 esp_nn_conv_s8_ansi 31 | 32 | #define esp_nn_get_conv_scratch_size esp_nn_get_conv_scratch_size_ansi 33 | #define esp_nn_set_conv_scratch_buf esp_nn_set_conv_scratch_buf_ansi 34 | 35 | #define esp_nn_get_depthwise_conv_scratch_size esp_nn_get_depthwise_conv_scratch_size_ansi 36 | #define esp_nn_set_depthwise_conv_scratch_buf esp_nn_set_depthwise_conv_scratch_buf_ansi 37 | 38 | #define esp_nn_relu6_s8 esp_nn_relu6_s8_ansi 39 | 40 | #define esp_nn_avg_pool_s8 esp_nn_avg_pool_s8_ansi 41 | #define esp_nn_max_pool_s8 esp_nn_max_pool_s8_ansi 42 | 43 | #define esp_nn_fully_connected_s8 esp_nn_fully_connected_s8_ansi 44 | 45 | #define esp_nn_get_softmax_scratch_size esp_nn_get_softmax_scratch_size_ansi 46 | #define esp_nn_set_softmax_scratch_buf esp_nn_set_softmax_scratch_buf_ansi 47 | #define esp_nn_softmax_s8 esp_nn_softmax_s8_ansi 48 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/porting/espressif/ESP-NN/include/esp_nn_defs.h: -------------------------------------------------------------------------------- 1 | // Copyright 2022 Espressif Systems (Shanghai) PTE LTD 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 | #pragma once 16 | 17 | #include 18 | 19 | /** 20 | * @brief structure to club data dims 21 | * this structure can be used for input, output and filter 22 | */ 23 | typedef struct data_dims { 24 | int32_t width; 25 | int32_t height; 26 | int32_t channels; 27 | 28 | int32_t extra; // can be used as batch or any other param 29 | } data_dims_t; 30 | 31 | /** 32 | * @brief 2d data structure (width, height) 33 | * 34 | */ 35 | typedef struct data_2d { 36 | int32_t width; 37 | int32_t height; 38 | } data_2d_t; 39 | 40 | /** 41 | * @brief min/max activation 42 | */ 43 | typedef struct act_params { 44 | int32_t min; 45 | int32_t max; 46 | } act_params_t; 47 | 48 | /** 49 | * @brief per channel quant data 50 | * 51 | * @note number of shift and mult elements are equal to output channels 52 | */ 53 | typedef struct quant_data { 54 | int32_t *shift; 55 | int32_t *mult; 56 | } quant_data_t; 57 | 58 | /** 59 | * @brief params specific to convolution 2d 60 | * 61 | */ 62 | typedef struct conv_params { 63 | int32_t in_offset; 64 | int32_t out_offset; 65 | data_2d_t stride; 66 | data_2d_t padding; 67 | data_2d_t dilation; 68 | act_params_t activation; 69 | } conv_params_t; 70 | 71 | /** 72 | * @brief params specific to depthwise convolution 2d 73 | * 74 | */ 75 | typedef struct dw_conv_params { 76 | int32_t in_offset; 77 | int32_t out_offset; 78 | int32_t ch_mult; // channel multiplier. (in_ch * ch_mult = out_ch) 79 | data_2d_t stride; 80 | data_2d_t padding; 81 | data_2d_t dilation; 82 | act_params_t activation; 83 | } dw_conv_params_t; 84 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/porting/espressif/ESP-NN/include/esp_nn_generic_opt.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2021 Espressif Systems (Shanghai) PTE LTD 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 | * @file Header definitions to include for esp_nn generic optimisations 17 | * For functions which not having optimisations, _ansi versions are picked. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "esp_nn_defs.h" 23 | #include "esp_nn_ansi_headers.h" 24 | 25 | #define esp_nn_add_elementwise_s8 esp_nn_add_elementwise_s8_ansi 26 | #define esp_nn_mul_elementwise_s8 esp_nn_mul_elementwise_s8_ansi 27 | 28 | #define esp_nn_depthwise_conv_s8 esp_nn_depthwise_conv_s8_opt 29 | 30 | #define esp_nn_conv_s8 esp_nn_conv_s8_opt 31 | 32 | #define esp_nn_get_conv_scratch_size esp_nn_get_conv_scratch_size_opt 33 | #define esp_nn_set_conv_scratch_buf esp_nn_set_conv_scratch_buf_opt 34 | 35 | #define esp_nn_get_depthwise_conv_scratch_size esp_nn_get_depthwise_conv_scratch_size_opt 36 | #define esp_nn_set_depthwise_conv_scratch_buf esp_nn_set_depthwise_conv_scratch_buf_opt 37 | 38 | #define esp_nn_relu6_s8 esp_nn_relu6_s8_ansi 39 | 40 | #define esp_nn_avg_pool_s8 esp_nn_avg_pool_s8_ansi 41 | #define esp_nn_max_pool_s8 esp_nn_max_pool_s8_ansi 42 | 43 | #define esp_nn_fully_connected_s8 esp_nn_fully_connected_s8_ansi 44 | 45 | #define esp_nn_get_softmax_scratch_size esp_nn_get_softmax_scratch_size_opt 46 | #define esp_nn_set_softmax_scratch_buf esp_nn_set_softmax_scratch_buf_opt 47 | #define esp_nn_softmax_s8 esp_nn_softmax_s8_opt 48 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/porting/espressif/ESP-NN/src/activation_functions/esp_nn_relu_ansi.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/classifier/ei_classifier_config.h" 2 | #if EI_CLASSIFIER_TFLITE_ENABLE_ESP_NN 3 | // Copyright 2020-2021 Espressif Systems (Shanghai) PTE LTD 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 | #include 18 | #include 19 | 20 | #include 21 | 22 | void esp_nn_relu6_s8_ansi(int8_t *data, uint16_t size) 23 | { 24 | int32_t i; 25 | 26 | for (i = 0; i < size; i++) { 27 | int32_t ip = data[i]; 28 | 29 | ip = max(ip, 0); 30 | data[i] = min(ip, 6); 31 | } 32 | } 33 | 34 | #endif // EI_CLASSIFIER_TFLITE_ENABLE_ESP_NN 35 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/porting/espressif/ESP-NN/src/basic_math/esp_nn_mul_ansi.c: -------------------------------------------------------------------------------- 1 | #include "edge-impulse-sdk/classifier/ei_classifier_config.h" 2 | #if EI_CLASSIFIER_TFLITE_ENABLE_ESP_NN 3 | // Copyright 2020-2021 Espressif Systems (Shanghai) PTE LTD 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 | #include 18 | 19 | #include 20 | 21 | void esp_nn_mul_elementwise_s8_ansi(const int8_t *input1_data, 22 | const int8_t *input2_data, 23 | const int32_t input1_offset, 24 | const int32_t input2_offset, 25 | int8_t *output, 26 | const int32_t out_offset, 27 | const int32_t out_mult, 28 | const int32_t out_shift, 29 | const int32_t activation_min, 30 | const int32_t activation_max, 31 | const int32_t size) 32 | { 33 | for (int i = 0; i < size; i++) { 34 | int32_t tmp1 = input1_data[i] + input1_offset; 35 | int32_t tmp2 = input2_data[i] + input2_offset; 36 | 37 | int32_t out = tmp1 * tmp2; 38 | out = esp_nn_multiply_by_quantized_mult(out, out_mult, out_shift); 39 | out = out + out_offset; 40 | 41 | out = max(activation_min, min(out, activation_max)); 42 | output[i] = (int8_t) out; 43 | } 44 | } 45 | 46 | #endif // EI_CLASSIFIER_TFLITE_ENABLE_ESP_NN 47 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/porting/ethos-core-driver/src/ethosu_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2021 Arm Limited. All rights reserved. 3 | * 4 | * SPDX-License-Identifier: Apache-2.0 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the License); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | // clang-format off 19 | #ifndef ETHOSU_INTERFACE_WRAPPER_ 20 | #define ETHOSU_INTERFACE_WRAPPER_ 21 | 22 | #define xstr(a) str(a) 23 | #define str(a) #a 24 | 25 | #define catm(a, b) catm_(a, b) 26 | #define catm_(a, b) a##b 27 | 28 | #define ETHOSU_INTERFACE_FILE xstr(catm(ethos, ETHOSU_ARCH)_interface.h) 29 | 30 | #include ETHOSU_INTERFACE_FILE 31 | 32 | #endif // ETHOSU_INTERFACE_WRAPPER_ 33 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/porting/ethos-core-driver/version.txt: -------------------------------------------------------------------------------- 1 | v1.24.11 -------------------------------------------------------------------------------- /src/edge-impulse-sdk/porting/himax-we2/ethosu_driver.c: -------------------------------------------------------------------------------- 1 | #include "../ei_classifier_porting.h" 2 | #if EI_PORTING_HIMAX_WE2 == 1 3 | #include "WE2_core.h" 4 | 5 | // Impelements weak functions from edge-impulse-sdk/porting/ethos-core-driver/src/ethosu_driver.c 6 | void ethosu_flush_dcache(uint32_t *p, size_t bytes) 7 | { 8 | hx_CleanDCache_by_Addr((volatile void *)p, bytes); 9 | } 10 | 11 | void ethosu_invalidate_dcache(uint32_t *p, size_t bytes) 12 | { 13 | hx_InvalidateDCache_by_Addr((volatile void *)p, bytes); 14 | } 15 | 16 | #endif // #if EI_PORTING_HIMAX_WE2 == 1 -------------------------------------------------------------------------------- /src/edge-impulse-sdk/sources.txt: -------------------------------------------------------------------------------- 1 | tensorflow and third_party folders based on: https://github.com/tensorflow/tensorflow/#c903b4607821a03c36c17b0befa2535c7dd0e066 2 | TensorFlow source was prepared using `make -f tensorflow/lite/micro/tools/make/Makefile generate_projects` 3 | The folders were taken from `tensorflow/lite/micro/tools/make/gen/osx_x86_64/prj/hello_world/make` 4 | These files and directories were then deleted: 5 | - `tensorflow/lite/micro/debug_log.cc` 6 | - `tensorflow/lite/micro/examples/hello_world` 7 | CMSIS-DSP based on: https://github.com/ARM-software/CMSIS_5/tree/4d378e81968c6bec5441a42885b24db7cf189bca 8 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/builtin_op_data.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | // Compatibility shim for new location of interface definitions. 16 | 17 | #ifndef TENSORFLOW_LITE_BUILTIN_OP_DATA_H_ 18 | #define TENSORFLOW_LITE_BUILTIN_OP_DATA_H_ 19 | 20 | #include "edge-impulse-sdk/tensorflow/lite/core/c/builtin_op_data.h" 21 | 22 | #endif // TENSORFLOW_LITE_BUILTIN_OP_DATA_H_ 23 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/c/builtin_op_data.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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_C_BUILTIN_OP_DATA_H_ 16 | #define TENSORFLOW_LITE_C_BUILTIN_OP_DATA_H_ 17 | 18 | /// For documentation, see 19 | /// third_party/tensorflow/lite/core/c/builtin_op_data.h. 20 | #include "edge-impulse-sdk/tensorflow/lite/core/c/builtin_op_data.h" // IWYU pragma: export 21 | 22 | #endif // TENSORFLOW_LITE_C_BUILTIN_OP_DATA_H_ 23 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/c/c_api_types.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | // This file declares types used by the pure C inference API defined in c_api.h, 17 | // some of which are also used in the C++ and C kernel and interpreter APIs. 18 | 19 | #ifndef TENSORFLOW_LITE_C_C_API_TYPES_H_ 20 | #define TENSORFLOW_LITE_C_C_API_TYPES_H_ 21 | 22 | /// For documentation, see 23 | /// third_party/tensorflow/lite/core/c/c_api_types.h. 24 | #include "edge-impulse-sdk/tensorflow/lite/core/c/c_api_types.h" // IWYU pragma: export 25 | 26 | #endif // TENSORFLOW_LITE_C_C_API_TYPES_H_ 27 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/c/common.c: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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 | // Dummy file for backwards compatibility. 16 | // See core/api/common.cc 17 | 18 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/c/common.h: -------------------------------------------------------------------------------- 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 | // 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. 35 | 36 | #ifndef TENSORFLOW_LITE_C_COMMON_H_ 37 | #define TENSORFLOW_LITE_C_COMMON_H_ 38 | 39 | /// For documentation, see 40 | /// third_party/tensorflow/lite/core/c/common.h. 41 | #include "edge-impulse-sdk/tensorflow/lite/core/c/common.h" // IWYU pragma: export 42 | 43 | #endif // TENSORFLOW_LITE_C_COMMON_H_ 44 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/context_util.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | /// \file 16 | /// 17 | /// This provides a few C++ helpers that are useful for manipulating C 18 | /// structures in C++. 19 | #ifndef TENSORFLOW_LITE_CONTEXT_UTIL_H_ 20 | #define TENSORFLOW_LITE_CONTEXT_UTIL_H_ 21 | 22 | #include 23 | 24 | #include "edge-impulse-sdk/tensorflow/lite/core/c/common.h" 25 | 26 | namespace tflite { 27 | 28 | /// Provides a range iterable wrapper for TfLiteIntArray* (C lists) that TfLite 29 | /// C api uses. 30 | // Can't use the google array_view, since we can't depend on even 31 | // absl for embedded device reasons. 32 | class TfLiteIntArrayView { 33 | public: 34 | /// Construct a view of a TfLiteIntArray*. Note, `int_array` should be 35 | /// non-null and this view does not take ownership of it. 36 | explicit TfLiteIntArrayView(const TfLiteIntArray* int_array) 37 | : int_array_(int_array) {} 38 | 39 | TfLiteIntArrayView(const TfLiteIntArrayView&) = default; 40 | TfLiteIntArrayView& operator=(const TfLiteIntArrayView& rhs) = default; 41 | 42 | typedef const int* const_iterator; 43 | const_iterator begin() const { return int_array_->data; } 44 | const_iterator end() const { return &int_array_->data[int_array_->size]; } 45 | size_t size() const { return end() - begin(); } 46 | int operator[](size_t pos) const { return int_array_->data[pos]; } 47 | 48 | private: 49 | const TfLiteIntArray* int_array_; 50 | }; 51 | 52 | } // namespace tflite 53 | 54 | #endif // TENSORFLOW_LITE_CONTEXT_UTIL_H_ 55 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/core/api/error_reporter.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | #include "edge-impulse-sdk/tensorflow/lite/core/api/error_reporter.h" 16 | #include 17 | 18 | namespace tflite { 19 | 20 | int ErrorReporter::Report(const char* format, ...) { 21 | va_list args; 22 | va_start(args, format); 23 | int code = Report(format, args); 24 | va_end(args); 25 | return code; 26 | } 27 | 28 | // TODO(aselle): Make the name of ReportError on context the same, so 29 | // we can use the ensure functions w/o a context and w/ a reporter. 30 | int ErrorReporter::ReportError(void*, const char* format, ...) { 31 | va_list args; 32 | va_start(args, format); 33 | int code = Report(format, args); 34 | va_end(args); 35 | return code; 36 | } 37 | 38 | } // namespace tflite 39 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/core/api/tensor_utils.cpp: -------------------------------------------------------------------------------- 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 | #include "edge-impulse-sdk/tensorflow/lite/core/api/tensor_utils.h" 17 | 18 | #include 19 | 20 | #include "edge-impulse-sdk/tensorflow/lite/core/c/common.h" 21 | 22 | namespace tflite { 23 | 24 | TfLiteStatus ResetVariableTensor(TfLiteTensor* tensor) { 25 | if (!tensor->is_variable) { 26 | return kTfLiteOk; 27 | } 28 | // TODO(b/115961645): Implement - If a variable tensor has a buffer, reset it 29 | // to the value of the buffer. 30 | int value = 0; 31 | if (tensor->type == kTfLiteInt8) { 32 | value = tensor->params.zero_point; 33 | } 34 | // TODO(b/139446230): Provide a platform header to better handle these 35 | // specific scenarios. 36 | #if __ANDROID__ || defined(__x86_64__) || defined(__i386__) || \ 37 | defined(__i386) || defined(__x86__) || defined(__X86__) || \ 38 | defined(_X86_) || defined(_M_IX86) || defined(_M_X64) 39 | memset(tensor->data.raw, value, tensor->bytes); 40 | #else 41 | char* raw_ptr = tensor->data.raw; 42 | for (size_t i = 0; i < tensor->bytes; ++i) { 43 | *raw_ptr = value; 44 | raw_ptr++; 45 | } 46 | #endif 47 | return kTfLiteOk; 48 | } 49 | 50 | } // namespace tflite 51 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/core/api/tensor_utils.h: -------------------------------------------------------------------------------- 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 TENSORFLOW_LITE_CORE_API_TENSOR_UTILS_H_ 17 | #define TENSORFLOW_LITE_CORE_API_TENSOR_UTILS_H_ 18 | 19 | #include "edge-impulse-sdk/tensorflow/lite/core/c/common.h" 20 | 21 | namespace tflite { 22 | 23 | // Resets a variable tensor to the default value. 24 | TfLiteStatus ResetVariableTensor(TfLiteTensor* tensor); 25 | 26 | } // namespace tflite 27 | 28 | #endif // TENSORFLOW_LITE_CORE_API_TENSOR_UTILS_H_ 29 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/kernels/internal/cppmath.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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_KERNELS_INTERNAL_CPPMATH_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_CPPMATH_H_ 17 | 18 | #include 19 | 20 | namespace tflite { 21 | 22 | #if defined(TF_LITE_USE_GLOBAL_CMATH_FUNCTIONS) || \ 23 | (defined(__ANDROID__) && !defined(__NDK_MAJOR__)) || defined(__ZEPHYR__) 24 | #define TF_LITE_GLOBAL_STD_PREFIX 25 | #else 26 | #define TF_LITE_GLOBAL_STD_PREFIX std 27 | #endif 28 | 29 | #define DECLARE_STD_GLOBAL_SWITCH1(tf_name, std_name) \ 30 | template \ 31 | inline T tf_name(const T x) { \ 32 | return TF_LITE_GLOBAL_STD_PREFIX::std_name(x); \ 33 | } 34 | 35 | DECLARE_STD_GLOBAL_SWITCH1(TfLiteRound, round); 36 | DECLARE_STD_GLOBAL_SWITCH1(TfLiteExpm1, expm1); 37 | 38 | } // namespace tflite 39 | 40 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_CPPMATH_H_ 41 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/kernels/internal/max.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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_KERNELS_INTERNAL_MAX_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_MAX_H_ 17 | 18 | #include 19 | 20 | namespace tflite { 21 | 22 | // Patched by Edge Impulse, remove std::fmax 23 | template 24 | inline T TfLiteMax(const T& x, const T& y) { 25 | return std::max(x, y); 26 | } 27 | 28 | } // namespace tflite 29 | 30 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_MAX_H_ 31 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/kernels/internal/min.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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_KERNELS_INTERNAL_MIN_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_MIN_H_ 17 | 18 | #include 19 | 20 | namespace tflite { 21 | 22 | // Patched by Edge Impulse, remove std::fmin 23 | template 24 | inline T TfLiteMin(const T& x, const T& y) { 25 | return std::min(x, y); 26 | } 27 | 28 | } // namespace tflite 29 | 30 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_MIN_H_ 31 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/kernels/internal/optimized/neon_check.h: -------------------------------------------------------------------------------- 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_OPTIMIZED_NEON_CHECK_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_OPTIMIZED_NEON_CHECK_H_ 17 | 18 | // TFLM does not need to utilize any Neon optimizations. 19 | 20 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_OPTIMIZED_NEON_CHECK_H_ 21 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/kernels/internal/reduce_common.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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_KERNELS_INTERNAL_REDUCE_COMMON_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REDUCE_COMMON_H_ 17 | 18 | namespace tflite { 19 | namespace ops { 20 | namespace builtin { 21 | namespace reduce { 22 | 23 | enum ReduceType { 24 | kSum, 25 | kProd, 26 | kMax, 27 | kMin, 28 | kAny, 29 | kAll, 30 | }; 31 | 32 | } // namespace reduce 33 | } // namespace builtin 34 | } // namespace ops 35 | } // namespace tflite 36 | 37 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REDUCE_COMMON_H_ 38 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/ceil.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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_KERNELS_INTERNAL_REFERENCE_CEIL_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_CEIL_H_ 17 | 18 | #include 19 | 20 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/types.h" 21 | 22 | namespace tflite { 23 | 24 | namespace reference_ops { 25 | 26 | inline void Ceil(const RuntimeShape& input_shape, const float* input_data, 27 | const RuntimeShape& output_shape, float* output_data) { 28 | const int flat_size = MatchingFlatSize(input_shape, output_shape); 29 | 30 | for (int i = 0; i < flat_size; ++i) { 31 | output_data[i] = std::ceil(input_data[i]); 32 | } 33 | } 34 | 35 | } // namespace reference_ops 36 | } // namespace tflite 37 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_CEIL_H_ 38 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/elu.h: -------------------------------------------------------------------------------- 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 TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_ELU_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_ELU_H_ 17 | 18 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/cppmath.h" 19 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/types.h" 20 | 21 | namespace tflite { 22 | 23 | namespace reference_ops { 24 | 25 | inline void Elu(const RuntimeShape& input_shape, const float* input_data, 26 | const RuntimeShape& output_shape, float* output_data) { 27 | const int flat_size = MatchingFlatSize(input_shape, output_shape); 28 | for (int i = 0; i < flat_size; ++i) { 29 | const float val = input_data[i]; 30 | output_data[i] = val < 0.0f ? TfLiteExpm1(val) : val; 31 | } 32 | } 33 | 34 | } // namespace reference_ops 35 | } // namespace tflite 36 | 37 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_ELU_H_ 38 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/exp.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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_KERNELS_INTERNAL_REFERENCE_EXP_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_EXP_H_ 17 | 18 | #include 19 | 20 | #include "edge-impulse-sdk/third_party/ruy/ruy/profiler/instrumentation.h" // from @ruy 21 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/types.h" 22 | 23 | namespace tflite { 24 | namespace reference_ops { 25 | 26 | template 27 | inline void Exp(const T* input_data, const size_t num_elements, 28 | T* output_data) { 29 | ruy::profiler::ScopeLabel label("Exp"); 30 | for (size_t idx = 0; idx < num_elements; ++idx) { 31 | output_data[idx] = std::exp(input_data[idx]); 32 | } 33 | } 34 | 35 | } // namespace reference_ops 36 | } // namespace tflite 37 | 38 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_EXP_H_ 39 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/fill.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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_KERNELS_INTERNAL_REFERENCE_FILL_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FILL_H_ 17 | 18 | #include 19 | 20 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/types.h" 21 | 22 | namespace tflite { 23 | namespace reference_ops { 24 | 25 | template 26 | void Fill(const RuntimeShape& value_shape, const T* value_data, 27 | const RuntimeShape& output_shape, T* output_data) { 28 | TFLITE_DCHECK_EQ(value_shape.DimensionsCount(), 0); 29 | const int flat_size = output_shape.FlatSize(); 30 | for (int i = 0; i < flat_size; ++i) { 31 | output_data[i] = *value_data; 32 | } 33 | } 34 | 35 | } // namespace reference_ops 36 | } // namespace tflite 37 | 38 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FILL_H_ 39 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/floor.h: -------------------------------------------------------------------------------- 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_H_ 17 | 18 | #include 19 | 20 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/types.h" 21 | 22 | namespace tflite { 23 | 24 | namespace reference_ops { 25 | 26 | inline void Floor(const RuntimeShape& input_shape, const float* input_data, 27 | const RuntimeShape& output_shape, float* output_data) { 28 | const int flat_size = MatchingFlatSize(input_shape, output_shape); 29 | 30 | for (int i = 0; i < flat_size; i++) { 31 | int offset = i; 32 | output_data[offset] = std::floor(input_data[offset]); 33 | } 34 | } 35 | 36 | } // namespace reference_ops 37 | } // namespace tflite 38 | 39 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_H_ 40 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/floor_div.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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_KERNELS_INTERNAL_REFERENCE_FLOOR_DIV_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_DIV_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/types.h" 22 | 23 | namespace tflite { 24 | namespace reference_ops { 25 | 26 | template 27 | T FloorDiv(T input1, T input2) { 28 | return std::floor(std::divides()(static_cast(input1), 29 | static_cast(input2))); 30 | } 31 | 32 | } // namespace reference_ops 33 | } // namespace tflite 34 | 35 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_DIV_H_ 36 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/floor_mod.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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_KERNELS_INTERNAL_REFERENCE_FLOOR_MOD_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_MOD_H_ 17 | 18 | #include 19 | #include 20 | 21 | namespace tflite { 22 | 23 | namespace reference_ops { 24 | 25 | template 26 | T FloorMod(T input1, T input2) { 27 | struct FloatMod { 28 | float operator()(const float lhs, const float rhs) const { 29 | return std::fmod(lhs, rhs); 30 | } 31 | }; 32 | using ModFunc = typename std::conditional::value, 33 | std::modulus, FloatMod>::type; 34 | ModFunc mod_func; 35 | T trunc_mod = mod_func(input1, input2); 36 | return (trunc_mod != 0) && ((input2 < 0) != (trunc_mod < 0)) 37 | ? (trunc_mod + input2) 38 | : trunc_mod; 39 | } 40 | 41 | } // namespace reference_ops 42 | } // namespace tflite 43 | 44 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_MOD_H_ 45 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/neg.h: -------------------------------------------------------------------------------- 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_NEG_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_NEG_H_ 17 | 18 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/types.h" 19 | 20 | namespace tflite { 21 | 22 | namespace reference_ops { 23 | 24 | template 25 | inline void Negate(const RuntimeShape& input_shape, const T* input_data, 26 | const RuntimeShape& output_shape, T* output_data) { 27 | const int flat_size = MatchingFlatSize(input_shape, output_shape); 28 | 29 | for (int i = 0; i < flat_size; ++i) { 30 | output_data[i] = -input_data[i]; 31 | } 32 | } 33 | 34 | } // namespace reference_ops 35 | } // namespace tflite 36 | 37 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_NEG_H_ 38 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/round.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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_KERNELS_INTERNAL_REFERENCE_ROUND_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_ROUND_H_ 17 | 18 | #include 19 | 20 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/types.h" 21 | 22 | namespace tflite { 23 | 24 | namespace reference_ops { 25 | 26 | inline float RoundToNearest(float value) { 27 | auto floor_val = std::floor(value); 28 | auto diff = value - floor_val; 29 | if ((diff < 0.5f) || 30 | ((diff == 0.5f) && (static_cast(floor_val) % 2 == 0))) { 31 | return floor_val; 32 | } else { 33 | return floor_val = floor_val + 1.0f; 34 | } 35 | } 36 | 37 | inline void Round(const RuntimeShape& input_shape, const float* input_data, 38 | const RuntimeShape& output_shape, float* output_data) { 39 | const int flat_size = MatchingFlatSize(input_shape, output_shape); 40 | for (int i = 0; i < flat_size; ++i) { 41 | // Note that this implementation matches that of tensorFlow tf.round 42 | // and corresponds to the bankers rounding method. 43 | // cfenv (for fesetround) is not yet supported universally on Android, so 44 | // using a work around. 45 | output_data[i] = RoundToNearest(input_data[i]); 46 | } 47 | } 48 | 49 | } // namespace reference_ops 50 | } // namespace tflite 51 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_ROUND_H_ 52 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/kernels/internal/tensor_ctypes.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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_KERNELS_INTERNAL_TENSOR_CTYPES_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_TENSOR_CTYPES_H_ 17 | 18 | #include "edge-impulse-sdk/tensorflow/lite/core/c/common.h" 19 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/types.h" 20 | 21 | namespace tflite { 22 | 23 | template 24 | inline T* GetTensorData(TfLiteTensor* tensor) { 25 | return tensor != nullptr ? reinterpret_cast(tensor->data.raw) : nullptr; 26 | } 27 | 28 | template 29 | inline const T* GetTensorData(const TfLiteTensor* tensor) { 30 | return tensor != nullptr ? reinterpret_cast(tensor->data.raw) 31 | : nullptr; 32 | } 33 | 34 | inline RuntimeShape GetTensorShape(const TfLiteTensor* tensor) { 35 | if (tensor == nullptr) { 36 | return RuntimeShape(); 37 | } 38 | 39 | TfLiteIntArray* dims = tensor->dims; 40 | const int dims_size = dims->size; 41 | const int32_t* dims_data = reinterpret_cast(dims->data); 42 | return RuntimeShape(dims_size, dims_data); 43 | } 44 | 45 | } // namespace tflite 46 | 47 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_TENSOR_CTYPES_H_ 48 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/kernels/internal/tensor_utils.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | 17 | // internal/reference_portable_tensor_utils.h has the implementation of the 18 | // functions declared in internal/portable_tensor_utils.h. This somewhat 19 | // confusing setup is derived from how the code is organized in TfLite where it 20 | // is used to select between NEON, SSE and portable implementaitons. See 21 | // https://github.com/tensorflow/tensorflow/blob/d76c23975c4a3a0d7987cfe3f45c76566df06180/tensorflow/lite/kernels/internal/tensor_utils.cc 22 | // for how the code is written in TfLite. 23 | 24 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/portable_tensor_utils.h" 25 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/reference_portable_tensor_utils.h" 26 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/kernels/op_macros.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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_KERNELS_OP_MACROS_H_ 16 | #define TENSORFLOW_LITE_KERNELS_OP_MACROS_H_ 17 | 18 | #include "edge-impulse-sdk/tensorflow/lite/micro/debug_log.h" 19 | 20 | #if !defined(TF_LITE_MCU_DEBUG_LOG) 21 | #include 22 | #define TFLITE_ABORT abort() 23 | #else 24 | inline void AbortImpl() { 25 | DebugLog("HALTED\n"); 26 | while (1) { 27 | } 28 | } 29 | #define TFLITE_ABORT AbortImpl(); 30 | #endif 31 | 32 | #if defined(NDEBUG) 33 | #define TFLITE_ASSERT_FALSE (static_cast(0)) 34 | #else 35 | #define TFLITE_ASSERT_FALSE TFLITE_ABORT 36 | #endif 37 | 38 | #endif // TENSORFLOW_LITE_KERNELS_OP_MACROS_H_ 39 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/all_ops_resolver.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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_MICRO_ALL_OPS_RESOLVER_H_ 16 | #define TENSORFLOW_LITE_MICRO_ALL_OPS_RESOLVER_H_ 17 | 18 | #include "edge-impulse-sdk/tensorflow/lite/micro/compatibility.h" 19 | #include "edge-impulse-sdk/tensorflow/lite/micro/micro_mutable_op_resolver.h" 20 | 21 | namespace tflite { 22 | 23 | // The magic number in the template parameter is the maximum number of ops that 24 | // can be added to AllOpsResolver. It can be increased if needed. And most 25 | // applications that care about the memory footprint will want to directly use 26 | // MicroMutableOpResolver and have an application specific template parameter. 27 | // The examples directory has sample code for this. 28 | class AllOpsResolver : public MicroMutableOpResolver<128> { 29 | public: 30 | AllOpsResolver(); 31 | 32 | private: 33 | TF_LITE_REMOVE_VIRTUAL_DELETE 34 | }; 35 | 36 | } // namespace tflite 37 | 38 | #endif // TENSORFLOW_LITE_MICRO_ALL_OPS_RESOLVER_H_ 39 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/compatibility.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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_MICRO_COMPATIBILITY_H_ 16 | #define TENSORFLOW_LITE_MICRO_COMPATIBILITY_H_ 17 | 18 | // C++ will automatically create class-specific delete operators for virtual 19 | // objects, which by default call the global delete function. For embedded 20 | // applications we want to avoid this, and won't be calling new/delete on these 21 | // objects, so we need to override the default implementation with one that does 22 | // nothing to avoid linking in ::delete(). 23 | // This macro needs to be included in all subclasses of a virtual base class in 24 | // the private section. 25 | 26 | // Patched by Edge Impulse, 27 | // actually declaring `void operator delete(void* p) {}` 28 | // yields compiler errors on some compilers 29 | #define TF_LITE_REMOVE_VIRTUAL_DELETE 30 | 31 | #endif // TENSORFLOW_LITE_MICRO_COMPATIBILITY_H_ 32 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/debug_log.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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_MICRO_DEBUG_LOG_H_ 16 | #define TENSORFLOW_LITE_MICRO_DEBUG_LOG_H_ 17 | 18 | // This function should be implemented by each target platform, and provide a 19 | // way for strings to be output to some text stream. For more information, see 20 | // tensorflow/lite/micro/debug_log.cc. 21 | #if defined(__cplusplus) && EI_C_LINKAGE == 1 22 | extern "C" void DebugLog(const char* s); 23 | #else 24 | void DebugLog(const char* s); 25 | #endif // defined(__cplusplus) && EI_C_LINKAGE == 1 26 | 27 | #endif // TENSORFLOW_LITE_MICRO_DEBUG_LOG_H_ 28 | 29 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/fake_micro_context.h: -------------------------------------------------------------------------------- 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 | 16 | #ifndef TENSORFLOW_LITE_MICRO_FAKE_MICRO_CONTEXT_H_ 17 | #define TENSORFLOW_LITE_MICRO_FAKE_MICRO_CONTEXT_H_ 18 | 19 | #include "edge-impulse-sdk/tensorflow/lite/micro/micro_context.h" 20 | #include "edge-impulse-sdk/tensorflow/lite/micro/micro_graph.h" 21 | 22 | namespace tflite { 23 | // A fake of MicroContext for kernel util tests. 24 | class FakeMicroContext : public MicroContext { 25 | public: 26 | FakeMicroContext(TfLiteTensor* tensors, SingleArenaBufferAllocator* allocator, 27 | MicroGraph* micro_graph); 28 | 29 | void* AllocatePersistentBuffer(size_t bytes) override; 30 | TfLiteStatus RequestScratchBufferInArena(size_t bytes, 31 | int* buffer_index) override; 32 | void* GetScratchBuffer(int buffer_index) override; 33 | 34 | TfLiteTensor* AllocateTempTfLiteTensor(int tensor_index) override; 35 | void DeallocateTempTfLiteTensor(TfLiteTensor* tensor) override; 36 | bool IsAllTempTfLiteTensorDeallocated(); 37 | 38 | TfLiteEvalTensor* GetEvalTensor(int tensor_index) override; 39 | 40 | private: 41 | static constexpr int kNumScratchBuffers_ = 12; 42 | 43 | int scratch_buffer_count_ = 0; 44 | uint8_t* scratch_buffers_[kNumScratchBuffers_]; 45 | 46 | TfLiteTensor* tensors_; 47 | int allocated_tensor_count_ = 0; 48 | 49 | SingleArenaBufferAllocator* allocator_; 50 | 51 | TF_LITE_REMOVE_VIRTUAL_DELETE 52 | }; 53 | 54 | } // namespace tflite 55 | 56 | #endif // TENSORFLOW_LITE_MICRO_FAKE_MICRO_CONTEXT_H_ 57 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/flatbuffer_conversions_bridge.cpp: -------------------------------------------------------------------------------- 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 | #include "edge-impulse-sdk/tensorflow/lite/micro/flatbuffer_conversions_bridge.h" 16 | 17 | #include "edge-impulse-sdk/tensorflow/lite/c/c_api_types.h" 18 | #include "edge-impulse-sdk/tensorflow/lite/core/api/error_reporter.h" 19 | #include "edge-impulse-sdk/tensorflow/lite/core/api/flatbuffer_conversions.h" 20 | #include "edge-impulse-sdk/tensorflow/lite/micro/micro_error_reporter.h" 21 | #include "edge-impulse-sdk/tensorflow/lite/schema/schema_generated.h" 22 | 23 | namespace tflite { 24 | TfLiteStatus ConvertTensorType(TensorType tensor_type, TfLiteType* type) { 25 | return ConvertTensorType(tensor_type, type, tflite::GetMicroErrorReporter()); 26 | } 27 | 28 | TfLiteStatus CallBuiltinParseFunction(TfLiteBridgeBuiltinParseFunction parser, 29 | const Operator* op, 30 | BuiltinDataAllocator* allocator, 31 | void** builtin_data) { 32 | return parser(op, tflite::GetMicroErrorReporter(), allocator, builtin_data); 33 | } 34 | } // namespace tflite 35 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/flatbuffer_conversions_bridge.h: -------------------------------------------------------------------------------- 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 TENSORFLOW_LITE_MICRO_TFLITE_BRIDGE_FLATBUFFER_CONVERSIONS_BRIDGE_H_ 16 | #define TENSORFLOW_LITE_MICRO_TFLITE_BRIDGE_FLATBUFFER_CONVERSIONS_BRIDGE_H_ 17 | 18 | #include "edge-impulse-sdk/tensorflow/lite/c/c_api_types.h" 19 | #include "edge-impulse-sdk/tensorflow/lite/core/api/flatbuffer_conversions.h" 20 | #include "edge-impulse-sdk/tensorflow/lite/schema/schema_generated.h" 21 | 22 | namespace tflite { 23 | 24 | // Forward declaration of the ErrorReporter class to hide it from the TFLM code. 25 | class ErrorReporter; 26 | 27 | using TfLiteBridgeBuiltinDataAllocator = BuiltinDataAllocator; 28 | 29 | using TfLiteBridgeBuiltinParseFunction = 30 | TfLiteStatus (*)(const Operator* op, ErrorReporter* error_reporter, 31 | BuiltinDataAllocator* allocator, void** builtin_data); 32 | 33 | // Converts the tensor data type used in the flatbuffer to the representation 34 | // used by the runtime. 35 | TfLiteStatus ConvertTensorType(TensorType tensor_type, TfLiteType* type); 36 | 37 | // CallBuiltinParseFunction is a wrapper function to wrap the parser function 38 | // calls to Call parser(op, allocator, builtin_data) 39 | TfLiteStatus CallBuiltinParseFunction(TfLiteBridgeBuiltinParseFunction parser, 40 | const Operator* op, 41 | BuiltinDataAllocator* allocator, 42 | void** builtin_data); 43 | } // namespace tflite 44 | 45 | #endif // TENSORFLOW_LITE_MICRO_TFLITE_BRIDGE_FLATBUFFER_CONVERSIONS_BRIDGE_H_ 46 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/activation_utils.h: -------------------------------------------------------------------------------- 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 TENSORFLOW_LITE_MICRO_KERNELS_ACTIVATION_UTILS_H_ 17 | #define TENSORFLOW_LITE_MICRO_KERNELS_ACTIVATION_UTILS_H_ 18 | 19 | #include 20 | #include 21 | 22 | #include "edge-impulse-sdk/tensorflow/lite/c/builtin_op_data.h" 23 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/cppmath.h" 24 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/max.h" 25 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/min.h" 26 | 27 | namespace tflite { 28 | namespace ops { 29 | namespace micro { 30 | 31 | // Returns the floating point value for a fused activation: 32 | inline float ActivationValFloat(TfLiteFusedActivation act, float a) { 33 | switch (act) { 34 | case kTfLiteActNone: 35 | return a; 36 | case kTfLiteActRelu: 37 | return TfLiteMax(0.0f, a); 38 | case kTfLiteActReluN1To1: 39 | return TfLiteMax(-1.0f, TfLiteMin(a, 1.0f)); 40 | case kTfLiteActRelu6: 41 | return TfLiteMax(0.0f, TfLiteMin(a, 6.0f)); 42 | case kTfLiteActTanh: 43 | return std::tanh(a); 44 | case kTfLiteActSignBit: 45 | return std::signbit(a); 46 | case kTfLiteActSigmoid: 47 | return 1.0f / (1.0f + std::exp(-a)); 48 | } 49 | return 0.0f; // To indicate an unsupported activation (i.e. when a new fused 50 | // activation is added to the enum and not handled here). 51 | } 52 | 53 | } // namespace micro 54 | } // namespace ops 55 | } // namespace tflite 56 | 57 | #endif // TENSORFLOW_LITE_MICRO_KERNELS_ACTIVATION_UTILS_H_ 58 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/circular_buffer.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 TENSORFLOW_LITE_MICRO_KERNELS_CIRCULAR_BUFFER_H_ 17 | #define TENSORFLOW_LITE_MICRO_KERNELS_CIRCULAR_BUFFER_H_ 18 | 19 | #include "edge-impulse-sdk/tensorflow/lite/c/builtin_op_data.h" 20 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 21 | 22 | namespace tflite { 23 | 24 | // The CircularBuffer op has one input and one output tensor. 25 | extern const int kCircularBufferInputTensor; 26 | extern const int kCircularBufferOutputTensor; 27 | 28 | // Indices into the init flexbuffer's vector. 29 | // The parameter's name is in the comment that follows. 30 | // Elements in the vectors are ordered alphabetically by parameter name. 31 | extern const int kCircularBufferCyclesMaxIndex; // 'cycles_max' 32 | 33 | // TODO(b/149795762): Add this to TfLiteStatus enum. 34 | extern const TfLiteStatus kTfLiteAbort; 35 | 36 | // These fields control the stride period of a strided streaming model. This op 37 | // returns kTfLiteAbort until cycles_until_run-- is zero. At this time, 38 | // cycles_until_run is reset to cycles_max. 39 | struct OpDataCircularBuffer { 40 | int cycles_until_run; 41 | int cycles_max; 42 | }; 43 | 44 | TfLiteStatus CircularBufferPrepare(TfLiteContext* context, TfLiteNode* node); 45 | 46 | } // namespace tflite 47 | 48 | #endif // TENSORFLOW_LITE_MICRO_KERNELS_CIRCULAR_BUFFER_H_ 49 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/circular_buffer_flexbuffers_generated_data.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 TENSORFLOW_LITE_MICRO_KERNELS_FLEXBUFFERS_GENERATED_DATA_H 17 | #define TENSORFLOW_LITE_MICRO_KERNELS_FLEXBUFFERS_GENERATED_DATA_H 18 | 19 | extern const int g_gen_data_size_circular_buffer_config; 20 | extern const unsigned char g_gen_data_circular_buffer_config[]; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/dequantize.h: -------------------------------------------------------------------------------- 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 | 16 | #ifndef TENSORFLOW_LITE_MICRO_KERNELS_DEQUANTIZE_H_ 17 | #define TENSORFLOW_LITE_MICRO_KERNELS_DEQUANTIZE_H_ 18 | 19 | #include "edge-impulse-sdk/tensorflow/lite/c/builtin_op_data.h" 20 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 21 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/types.h" 22 | 23 | namespace tflite { 24 | 25 | struct DequantizeOpData { 26 | tflite::DequantizationParams quantization_params; 27 | // The scaling factor from input to output (aka the 'real multiplier') can 28 | // be represented as a fixed point multiplier plus a left shift. 29 | int32_t output_multiplier; 30 | int output_shift; 31 | int32_t output_zero_point; 32 | }; 33 | 34 | TfLiteStatus DequantizePrepare(TfLiteContext* context, TfLiteNode* node); 35 | 36 | } // namespace tflite 37 | 38 | #endif // TENSORFLOW_LITE_MICRO_KERNELS_DEQUANTIZE_H_ 39 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/detection_postprocess_flexbuffers_generated_data.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 TENSORFLOW_LITE_MICRO_KERNELS_FLEXBUFFERS_GENERATED_DATA_H 17 | #define TENSORFLOW_LITE_MICRO_KERNELS_FLEXBUFFERS_GENERATED_DATA_H 18 | 19 | extern const int g_gen_data_size_none_regular_nms; 20 | extern const unsigned char g_gen_data_none_regular_nms[]; 21 | 22 | extern const int g_gen_data_size_regular_nms; 23 | extern const unsigned char g_gen_data_regular_nms[]; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/ethosu.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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_MICRO_KERNELS_ETHOSU_H_ 16 | #define TENSORFLOW_LITE_MICRO_KERNELS_ETHOSU_H_ 17 | 18 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 19 | 20 | namespace tflite { 21 | 22 | TfLiteRegistration* Register_ETHOSU(); 23 | 24 | const char* GetString_ETHOSU(); 25 | 26 | } // namespace tflite 27 | 28 | #endif // TENSORFLOW_LITE_MICRO_KERNELS_ETHOSU_H_ 29 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/floor.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/floor.h" 17 | 18 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 19 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/tensor_ctypes.h" 20 | #include "edge-impulse-sdk/tensorflow/lite/micro/kernels/kernel_util.h" 21 | 22 | namespace tflite { 23 | 24 | namespace { 25 | 26 | constexpr int kInputTensor = 0; 27 | constexpr int kOutputTensor = 0; 28 | 29 | TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { 30 | const TfLiteEvalTensor* input = 31 | tflite::micro::GetEvalInput(context, node, kInputTensor); 32 | TF_LITE_ENSURE_TYPES_EQ(context, input->type, kTfLiteFloat32); 33 | TfLiteEvalTensor* output = 34 | tflite::micro::GetEvalOutput(context, node, kOutputTensor); 35 | reference_ops::Floor(tflite::micro::GetTensorShape(input), 36 | tflite::micro::GetTensorData(input), 37 | tflite::micro::GetTensorShape(output), 38 | tflite::micro::GetTensorData(output)); 39 | return kTfLiteOk; 40 | } 41 | 42 | } // namespace 43 | 44 | TfLiteRegistration Register_FLOOR() { 45 | return tflite::micro::RegisterOp(nullptr, nullptr, Eval); 46 | } 47 | 48 | } // namespace tflite 49 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/hard_swish.h: -------------------------------------------------------------------------------- 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 | 16 | #ifndef TENSORFLOW_LITE_MICRO_KERNELS_HARD_SWISH_H_ 17 | #define TENSORFLOW_LITE_MICRO_KERNELS_HARD_SWISH_H_ 18 | 19 | #include "edge-impulse-sdk/tensorflow/lite/c/builtin_op_data.h" 20 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 21 | 22 | namespace tflite { 23 | 24 | extern const int kHardSwishInputTensor; 25 | extern const int kHardSwishOutputTensor; 26 | 27 | TfLiteStatus HardSwishPrepare(TfLiteContext* context, TfLiteNode* node); 28 | } // namespace tflite 29 | 30 | #endif // TENSORFLOW_LITE_MICRO_KERNELS_HARD_SWISH_H_ 31 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/leaky_relu.h: -------------------------------------------------------------------------------- 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 | 16 | #ifndef TENSORFLOW_LITE_MICRO_KERNELS_LEAKY_RELU_H_ 17 | #define TENSORFLOW_LITE_MICRO_KERNELS_LEAKY_RELU_H_ 18 | 19 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 20 | 21 | namespace tflite { 22 | 23 | // Input/output tensor index. 24 | extern const int kInputTensor; 25 | extern const int kOutputTensor; 26 | 27 | struct LeakyReluOpData { 28 | // quantization parameters 29 | int32_t output_multiplier_alpha; 30 | int32_t output_shift_alpha; 31 | int32_t output_multiplier_identity; 32 | int32_t output_shift_identity; 33 | int32_t input_zero_point; 34 | int32_t output_zero_point; 35 | }; 36 | 37 | TfLiteStatus CalculateOpDataLeakyRelu(TfLiteContext* context, TfLiteNode* node); 38 | 39 | TfLiteStatus LeakyReluPrepare(TfLiteContext* context, TfLiteNode* node); 40 | 41 | } // namespace tflite 42 | 43 | #endif // TENSORFLOW_LITE_MICRO_KERNELS_LEAKY_RELU_H_ 44 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/logical.cpp: -------------------------------------------------------------------------------- 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 | #include "edge-impulse-sdk/tensorflow/lite/micro/kernels/logical.h" 16 | 17 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 18 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/binary_function.h" 19 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/tensor_ctypes.h" 20 | #include "edge-impulse-sdk/tensorflow/lite/kernels/op_macros.h" 21 | #include "edge-impulse-sdk/tensorflow/lite/micro/kernels/kernel_util.h" 22 | 23 | namespace tflite { 24 | namespace { 25 | 26 | TfLiteStatus LogicalOrEval(TfLiteContext* context, TfLiteNode* node) { 27 | return LogicalImpl(context, node, LogicalOr); 28 | } 29 | 30 | TfLiteStatus LogicalAndEval(TfLiteContext* context, TfLiteNode* node) { 31 | return LogicalImpl(context, node, LogicalAnd); 32 | } 33 | 34 | } // namespace 35 | 36 | TfLiteRegistration Register_LOGICAL_OR() { 37 | return tflite::micro::RegisterOp(nullptr, nullptr, LogicalOrEval); 38 | } 39 | 40 | TfLiteRegistration Register_LOGICAL_AND() { 41 | return tflite::micro::RegisterOp(nullptr, nullptr, LogicalAndEval); 42 | } 43 | 44 | } // namespace tflite 45 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/logical.h: -------------------------------------------------------------------------------- 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 TENSORFLOW_LITE_MICRO_KERNELS_LOGICAL_H_ 16 | #define TENSORFLOW_LITE_MICRO_KERNELS_LOGICAL_H_ 17 | 18 | #include "edge-impulse-sdk/tensorflow/lite/c/builtin_op_data.h" 19 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 20 | 21 | namespace tflite { 22 | // Input/output tensor index. 23 | extern const int kLogicalInputTensor1; 24 | extern const int kLogicalInputTensor2; 25 | extern const int kLogicalOutputTensor; 26 | 27 | TfLiteStatus LogicalImpl(TfLiteContext* context, TfLiteNode* node, 28 | bool (*func)(bool, bool)); 29 | 30 | bool LogicalOr(bool x, bool y); 31 | bool LogicalAnd(bool x, bool y); 32 | 33 | } // namespace tflite 34 | 35 | #endif // TENSORFLOW_LITE_MICRO_KERNELS_LOGICAL_H_ 36 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/logistic.h: -------------------------------------------------------------------------------- 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 | 16 | #ifndef TENSORFLOW_LITE_MICRO_KERNELS_LOGISTIC_H_ 17 | #define TENSORFLOW_LITE_MICRO_KERNELS_LOGISTIC_H_ 18 | 19 | #include 20 | 21 | #include "edge-impulse-sdk/tensorflow/lite/c/builtin_op_data.h" 22 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 23 | 24 | namespace tflite { 25 | extern const int kLogisticInputTensor; 26 | extern const int kLogisticOutputTensor; 27 | 28 | struct OpDataLogistic { 29 | int32_t input_zero_point; 30 | int32_t input_range_radius; 31 | int32_t input_multiplier; 32 | int input_left_shift; 33 | }; 34 | 35 | TfLiteStatus CalculateArithmeticOpDataLogistic(TfLiteContext* context, 36 | TfLiteNode* node, 37 | OpDataLogistic* data); 38 | 39 | TfLiteStatus LogisticPrepare(TfLiteContext* context, TfLiteNode* node); 40 | 41 | } // namespace tflite 42 | #endif // TENSORFLOW_LITE_MICRO_KERNELS_LOGISTIC_H_ 43 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/mli_slicers.h: -------------------------------------------------------------------------------- 1 | // Patched by Edge Impulse to include reference and hardware-accelerated kernels 2 | #include "../../../../classifier/ei_classifier_config.h" 3 | #if EI_CLASSIFIER_TFLITE_ENABLE_ARC == 1 4 | /* Copyright 2020 The TensorFlow Authors. All Rights Reserved. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | ==============================================================================*/ 18 | 19 | #ifndef TENSORFLOW_LITE_MICRO_KERNELS_ARC_MLI_SLICERS_H_ 20 | #define TENSORFLOW_LITE_MICRO_KERNELS_ARC_MLI_SLICERS_H_ 21 | 22 | #include "mli_api.h" // NOLINT 23 | namespace tflite { 24 | namespace ops { 25 | namespace micro { 26 | 27 | class TensorSlicer { 28 | public: 29 | TensorSlicer(const mli_tensor* full_tensor, int slice_dim, int slice_size, 30 | int padding_pre = 0, int padding_post = 0, int overlap = 0, 31 | bool interleave_mode = false); 32 | ~TensorSlicer() = default; 33 | 34 | void Next(); 35 | bool Done(); 36 | int GetPaddingPre(); 37 | int GetPaddingPost(); 38 | 39 | mli_tensor* Sub(); 40 | 41 | // Default constructor is deleted 42 | TensorSlicer() = delete; 43 | 44 | private: 45 | const mli_tensor* full_tensor_; 46 | mli_tensor sub_tensor_; 47 | mli_sub_tensor_cfg sub_cfg_; 48 | bool done_; 49 | int sliceDim_; 50 | int pad_pre_, pad_post_, overlap_; 51 | int actual_padding_pre, actual_padding_post; 52 | 53 | void ComputeSubTensor(); 54 | }; 55 | 56 | } // namespace micro 57 | } // namespace ops 58 | } // namespace tflite 59 | #endif // TENSORFLOW_LITE_MICRO_KERNELS_ARC_MLI_SLICERS_H_ 60 | 61 | #endif // EI_CLASSIFIER_TFLITE_ENABLE_ARC == 1 62 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/neg.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/reference/neg.h" 17 | 18 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 19 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/tensor_ctypes.h" 20 | #include "edge-impulse-sdk/tensorflow/lite/micro/kernels/kernel_util.h" 21 | #include "edge-impulse-sdk/tensorflow/lite/micro/micro_log.h" 22 | 23 | namespace tflite { 24 | 25 | namespace { 26 | 27 | constexpr int kInputTensor = 0; 28 | constexpr int kOutputTensor = 0; 29 | 30 | TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { 31 | const TfLiteEvalTensor* input = 32 | tflite::micro::GetEvalInput(context, node, kInputTensor); 33 | TfLiteEvalTensor* output = 34 | tflite::micro::GetEvalOutput(context, node, kOutputTensor); 35 | switch (input->type) { 36 | // TODO(wangtz): handle for kTfLiteInt8 37 | case kTfLiteFloat32: 38 | reference_ops::Negate(tflite::micro::GetTensorShape(input), 39 | tflite::micro::GetTensorData(input), 40 | tflite::micro::GetTensorShape(output), 41 | tflite::micro::GetTensorData(output)); 42 | break; 43 | default: 44 | MicroPrintf("Type %s (%d) not supported.", TfLiteTypeGetName(input->type), 45 | input->type); 46 | return kTfLiteError; 47 | } 48 | return kTfLiteOk; 49 | } 50 | 51 | } // namespace 52 | 53 | TfLiteRegistration Register_NEG() { 54 | return tflite::micro::RegisterOp(nullptr, nullptr, Eval); 55 | } 56 | 57 | } // namespace tflite 58 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/pad.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 TENSORFLOW_LITE_MICRO_KERNELS_PAD_H_ 17 | #define TENSORFLOW_LITE_MICRO_KERNELS_PAD_H_ 18 | 19 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 20 | 21 | namespace tflite { 22 | 23 | TfLiteStatus PadPrepare(TfLiteContext* context, TfLiteNode* node); 24 | 25 | } // namespace tflite 26 | 27 | #endif // TENSORFLOW_LITE_MICRO_KERNELS_PAD_H_ 28 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/prelu.h: -------------------------------------------------------------------------------- 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 | 16 | #ifndef TENSORFLOW_LITE_MICRO_KERNELS_PRELU_H_ 17 | #define TENSORFLOW_LITE_MICRO_KERNELS_PRELU_H_ 18 | 19 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 20 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/types.h" 21 | 22 | namespace tflite { 23 | 24 | TfLiteStatus CalculatePreluParams(const TfLiteTensor* input, 25 | const TfLiteTensor* alpha, 26 | TfLiteTensor* output, PreluParams* params); 27 | 28 | void BroadcastPrelu4DSlowFloat(const RuntimeShape& unextended_input1_shape, 29 | const float* input1_data, 30 | const RuntimeShape& unextended_input2_shape, 31 | const float* input2_data, 32 | const RuntimeShape& unextended_output_shape, 33 | float* output_data); 34 | 35 | TfLiteStatus PreluPrepare(TfLiteContext* context, TfLiteNode* node); 36 | 37 | } // namespace tflite 38 | 39 | #endif // TENSORFLOW_LITE_MICRO_KERNELS_PRELU_H_ 40 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/quantize.cpp: -------------------------------------------------------------------------------- 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 | #include "edge-impulse-sdk/tensorflow/lite/micro/kernels/quantize.h" 17 | 18 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 19 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/quantization_util.h" 20 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/tensor_ctypes.h" 21 | #include "edge-impulse-sdk/tensorflow/lite/kernels/kernel_util.h" 22 | #include "edge-impulse-sdk/tensorflow/lite/micro/kernels/kernel_util.h" 23 | #include "edge-impulse-sdk/tensorflow/lite/micro/micro_utils.h" 24 | 25 | namespace tflite { 26 | namespace { 27 | 28 | void* Init(TfLiteContext* context, const char* buffer, size_t length) { 29 | TFLITE_DCHECK(context->AllocatePersistentBuffer != nullptr); 30 | return context->AllocatePersistentBuffer(context, 31 | sizeof(OpDataQuantizeReference)); 32 | } 33 | 34 | } // namespace 35 | 36 | TfLiteRegistration Register_QUANTIZE() { 37 | return tflite::micro::RegisterOp(Init, PrepareQuantizeReference, 38 | EvalQuantizeReference); 39 | } 40 | 41 | } // namespace tflite 42 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/quantize.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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_MICRO_KERNELS_QUANTIZE_H_ 16 | #define TENSORFLOW_LITE_MICRO_KERNELS_QUANTIZE_H_ 17 | 18 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 19 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/types.h" 20 | 21 | namespace tflite { 22 | 23 | struct OpDataQuantizeReference { 24 | tflite::QuantizationParams quantization_params; 25 | // The scaling factor from input to output (aka the 'real multiplier') can 26 | // be represented as a fixed point multiplier plus a left shift. 27 | int32_t requantize_output_multiplier; 28 | int requantize_output_shift; 29 | 30 | int32_t input_zero_point; 31 | }; 32 | 33 | TfLiteStatus EvalQuantizeReference(TfLiteContext* context, TfLiteNode* node); 34 | TfLiteStatus PrepareQuantizeReference(TfLiteContext* context, TfLiteNode* node); 35 | } // namespace tflite 36 | 37 | #endif // TENSORFLOW_LITE_MICRO_KERNELS_QUANTIZE_H_ 38 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/kernels/sub.h: -------------------------------------------------------------------------------- 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 | 16 | #ifndef TENSORFLOW_LITE_MICRO_KERNELS_SUB_H_ 17 | #define TENSORFLOW_LITE_MICRO_KERNELS_SUB_H_ 18 | 19 | #include 20 | 21 | #include "edge-impulse-sdk/tensorflow/lite/c/builtin_op_data.h" 22 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 23 | 24 | namespace tflite { 25 | 26 | extern const int kSubInputTensor1; 27 | extern const int kSubInputTensor2; 28 | extern const int kSubOutputTensor; 29 | 30 | struct OpDataSub { 31 | bool requires_broadcast; 32 | 33 | // These fields are used in both the general 8-bit -> 8bit quantized path, 34 | // and the special 16-bit -> 16bit quantized path 35 | int input1_shift; 36 | int input2_shift; 37 | int32_t output_activation_min; 38 | int32_t output_activation_max; 39 | 40 | // These fields are used only in the general 8-bit -> 8bit quantized path 41 | int32_t input1_multiplier; 42 | int32_t input2_multiplier; 43 | int32_t output_multiplier; 44 | int output_shift; 45 | int left_shift; 46 | int32_t input1_offset; 47 | int32_t input2_offset; 48 | int32_t output_offset; 49 | }; 50 | 51 | TfLiteStatus CalculateOpDataSub(TfLiteContext* context, TfLiteSubParams* params, 52 | const TfLiteTensor* input1, 53 | const TfLiteTensor* input2, 54 | TfLiteTensor* output, OpDataSub* data); 55 | 56 | TfLiteStatus SubPrepare(TfLiteContext* context, TfLiteNode* node); 57 | 58 | } // namespace tflite 59 | 60 | #endif // TENSORFLOW_LITE_MICRO_KERNELS_SUB_H_ 61 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/memory_planner/linear_memory_planner.h: -------------------------------------------------------------------------------- 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 TENSORFLOW_LITE_MICRO_MEMORY_PLANNER_LINEAR_MEMORY_PLANNER_H_ 17 | #define TENSORFLOW_LITE_MICRO_MEMORY_PLANNER_LINEAR_MEMORY_PLANNER_H_ 18 | 19 | #include "edge-impulse-sdk/tensorflow/lite/micro/compatibility.h" 20 | #include "edge-impulse-sdk/tensorflow/lite/micro/memory_planner/micro_memory_planner.h" 21 | 22 | namespace tflite { 23 | 24 | // The simplest possible memory planner that just lays out all buffers at 25 | // increasing offsets without trying to reuse memory. 26 | class LinearMemoryPlanner : public MicroMemoryPlanner { 27 | public: 28 | LinearMemoryPlanner(); 29 | ~LinearMemoryPlanner() override; 30 | 31 | TfLiteStatus AddBuffer(int size, int first_time_used, 32 | int last_time_used) override; 33 | 34 | size_t GetMaximumMemorySize() override; 35 | int GetBufferCount() override; 36 | TfLiteStatus GetOffsetForBuffer(int buffer_index, int* offset) override; 37 | 38 | private: 39 | static constexpr int kMaxBufferCount = 1024; 40 | size_t buffer_offsets_[kMaxBufferCount]; 41 | int current_buffer_count_; 42 | size_t next_free_offset_; 43 | 44 | TF_LITE_REMOVE_VIRTUAL_DELETE 45 | }; 46 | 47 | } // namespace tflite 48 | 49 | #endif // TENSORFLOW_LITE_MICRO_MEMORY_PLANNER_LINEAR_MEMORY_PLANNER_H_ 50 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/micro_arena_constants.h: -------------------------------------------------------------------------------- 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 | 16 | #ifndef TENSORFLOW_LITE_MICRO_MICRO_ARENA_CONSTANTS_H_ 17 | #define TENSORFLOW_LITE_MICRO_MICRO_ARENA_CONSTANTS_H_ 18 | 19 | namespace tflite { 20 | 21 | // The default buffer alignment requirement. 22 | // We align tensor buffers to 16-byte boundaries, since this is a common 23 | // requirement for SIMD extensions. 24 | constexpr int MicroArenaBufferAlignment() { return 16; } 25 | 26 | } // namespace tflite 27 | 28 | #endif // TENSORFLOW_LITE_MICRO_MICRO_ARENA_CONSTANTS_H_ 29 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/micro_error_reporter.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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 | #include "edge-impulse-sdk/tensorflow/lite/micro/micro_error_reporter.h" 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "edge-impulse-sdk/tensorflow/lite/micro/micro_log.h" 23 | 24 | namespace { 25 | uint8_t micro_error_reporter_buffer[sizeof(tflite::MicroErrorReporter)]; 26 | tflite::MicroErrorReporter* error_reporter_ = nullptr; 27 | 28 | } // namespace 29 | 30 | namespace tflite { 31 | ErrorReporter* GetMicroErrorReporter() { 32 | if (error_reporter_ == nullptr) { 33 | error_reporter_ = new (micro_error_reporter_buffer) MicroErrorReporter(); 34 | } 35 | return error_reporter_; 36 | } 37 | 38 | int MicroErrorReporter::Report(const char* format, va_list args) { 39 | Log(format, args); 40 | return 0; 41 | } 42 | 43 | } // namespace tflite 44 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/micro_error_reporter.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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_MICRO_TFLITE_BRIDGE_MICRO_ERROR_REPORTER_H_ 16 | #define TENSORFLOW_LITE_MICRO_TFLITE_BRIDGE_MICRO_ERROR_REPORTER_H_ 17 | 18 | #include 19 | 20 | #include "edge-impulse-sdk/tensorflow/lite/core/api/error_reporter.h" 21 | #include "edge-impulse-sdk/tensorflow/lite/micro/compatibility.h" 22 | 23 | namespace tflite { 24 | // Get a pointer to a singleton global error reporter. 25 | ErrorReporter* GetMicroErrorReporter(); 26 | class MicroErrorReporter : public ErrorReporter { 27 | public: 28 | ~MicroErrorReporter() override {} 29 | int Report(const char* format, va_list args) override; 30 | 31 | private: 32 | TF_LITE_REMOVE_VIRTUAL_DELETE 33 | }; 34 | 35 | } // namespace tflite 36 | 37 | #endif // TENSORFLOW_LITE_MICRO_TFLITE_BRIDGE_MICRO_ERROR_REPORTER_H_ 38 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/micro_log.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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 | #include "edge-impulse-sdk/tensorflow/lite/micro/micro_log.h" 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #if !defined(TF_LITE_STRIP_ERROR_STRINGS) 23 | #include "edge-impulse-sdk/tensorflow/lite/micro/debug_log.h" 24 | #include "edge-impulse-sdk/tensorflow/lite/micro/micro_string.h" 25 | #endif 26 | 27 | void Log(const char* format, va_list args) { 28 | #if !defined(TF_LITE_STRIP_ERROR_STRINGS) 29 | // Only pulling in the implementation of this function for builds where we 30 | // expect to make use of it to be extra cautious about not increasing the code 31 | // size. 32 | static constexpr int kMaxLogLen = 256; 33 | char log_buffer[kMaxLogLen]; 34 | MicroVsnprintf(log_buffer, kMaxLogLen, format, args); 35 | DebugLog(log_buffer); 36 | DebugLog("\r\n"); 37 | #endif 38 | } 39 | 40 | #if !defined(TF_LITE_STRIP_ERROR_STRINGS) 41 | void MicroPrintf(const char* format, ...) { 42 | va_list args; 43 | va_start(args, format); 44 | Log(format, args); 45 | va_end(args); 46 | } 47 | #endif 48 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/micro_log.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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_MICRO_MICRO_LOG_H_ 16 | #define TENSORFLOW_LITE_MICRO_MICRO_LOG_H_ 17 | 18 | #include 19 | 20 | // do this by default except when running EON compiler 21 | #ifndef EON_COMPILER_RUN 22 | #define TF_LITE_STRIP_ERROR_STRINGS 23 | #endif 24 | 25 | // This is a free function used to perform the actual logging. 26 | // This function will be used by MicroPrintf and MicroErrorReporter::Report() 27 | void Log(const char* format, va_list args); 28 | 29 | #if !defined(TF_LITE_STRIP_ERROR_STRINGS) 30 | // This function can be used independent of the MicroErrorReporter to get 31 | // printf-like functionalitys and are common to all target platforms. 32 | void MicroPrintf(const char* format, ...); 33 | #else 34 | // We use a #define to ensure that the strings are completely stripped, to 35 | // prevent an unnecessary increase in the binary size. 36 | #define MicroPrintf(...) 37 | #endif 38 | 39 | #endif // TENSORFLOW_LITE_MICRO_MICRO_LOG_H_ 40 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/micro_profiler_interface.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 TENSORFLOW_LITE_MICRO_MICRO_PROFILER_INTERFACE_H_ 17 | #define TENSORFLOW_LITE_MICRO_MICRO_PROFILER_INTERFACE_H_ 18 | 19 | #include 20 | 21 | namespace tflite { 22 | 23 | // Interface class that the TFLM framework relies on for profiling. 24 | class MicroProfilerInterface { 25 | public: 26 | virtual ~MicroProfilerInterface() {} 27 | 28 | // Marks the start of a new event and returns an event handle that can be used 29 | // to mark the end of the event via EndEvent. 30 | virtual uint32_t BeginEvent(const char* tag) = 0; 31 | 32 | // Marks the end of an event associated with event_handle. 33 | virtual void EndEvent(uint32_t event_handle) = 0; 34 | }; 35 | 36 | } // namespace tflite 37 | 38 | #endif // TENSORFLOW_LITE_MICRO_MICRO_PROFILER_INTERFACE_H_ 39 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/micro_string.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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_MICRO_MICRO_STRING_H_ 16 | #define TENSORFLOW_LITE_MICRO_MICRO_STRING_H_ 17 | 18 | #include 19 | 20 | // Implements simple string formatting for numeric types. Returns the number of 21 | // bytes written to output. 22 | extern "C" { 23 | // Functionally equivalent to vsnprintf, trimmed down for TFLite Micro. 24 | // MicroSnprintf() is implemented using MicroVsnprintf(). 25 | int MicroVsnprintf(char* output, int len, const char* format, va_list args); 26 | // Functionally equavalent to snprintf, trimmed down for TFLite Micro. 27 | // For example, MicroSnprintf(buffer, 10, "int %d", 10) will put the string 28 | // "int 10" in the buffer. 29 | // Floating point values are logged in exponent notation (1.XXX*2^N). 30 | int MicroSnprintf(char* output, int len, const char* format, ...); 31 | } 32 | 33 | #endif // TENSORFLOW_LITE_MICRO_MICRO_STRING_H_ 34 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/micro_time.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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_MICRO_MICRO_TIME_H_ 16 | #define TENSORFLOW_LITE_MICRO_MICRO_TIME_H_ 17 | 18 | #include 19 | 20 | namespace tflite { 21 | 22 | // These functions should be implemented by each target platform, and provide an 23 | // accurate tick count along with how many ticks there are per second. 24 | uint32_t ticks_per_second(); 25 | 26 | // Return time in ticks. The meaning of a tick varies per platform. 27 | uint32_t GetCurrentTimeTicks(); 28 | 29 | inline uint32_t TicksToMs(int32_t ticks) { 30 | return static_cast(1000.0f * static_cast(ticks) / 31 | static_cast(ticks_per_second())); 32 | } 33 | 34 | } // namespace tflite 35 | 36 | #endif // TENSORFLOW_LITE_MICRO_MICRO_TIME_H_ 37 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/op_resolver_bridge.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 | #include "edge-impulse-sdk/tensorflow/lite/micro/op_resolver_bridge.h" 17 | 18 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 19 | #include "edge-impulse-sdk/tensorflow/lite/core/api/error_reporter.h" 20 | #include "edge-impulse-sdk/tensorflow/lite/core/api/op_resolver.h" 21 | #include "edge-impulse-sdk/tensorflow/lite/micro/micro_error_reporter.h" 22 | #include "edge-impulse-sdk/tensorflow/lite/schema/schema_utils.h" 23 | 24 | namespace tflite { 25 | 26 | TfLiteStatus GetRegistrationFromOpCode( 27 | const OperatorCode* opcode, const OpResolver& op_resolver, 28 | const TfLiteRegistration** registration) { 29 | return GetRegistrationFromOpCode( 30 | opcode, op_resolver, tflite::GetMicroErrorReporter(), registration); 31 | } 32 | } // namespace tflite 33 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/op_resolver_bridge.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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_MICRO_TFLITE_BRIDGE_OP_RESOLVER_BRIDGE_H_ 16 | #define TENSORFLOW_LITE_MICRO_TFLITE_BRIDGE_OP_RESOLVER_BRIDGE_H_ 17 | 18 | #include "edge-impulse-sdk/tensorflow/lite/c/c_api_types.h" 19 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 20 | #include "edge-impulse-sdk/tensorflow/lite/core/api/op_resolver.h" // needed for the Using declarative 21 | 22 | namespace tflite { 23 | 24 | // Forward declaration of the classes and structs used here. 25 | struct OperatorCode; 26 | 27 | using TfLiteBridgeOpResolver = OpResolver; 28 | 29 | // Handles the logic for converting between an OperatorCode structure extracted 30 | // from a flatbuffer and information about a registered operator 31 | // implementation. 32 | TfLiteStatus GetRegistrationFromOpCode(const OperatorCode* opcode, 33 | const OpResolver& op_resolver, 34 | const TfLiteRegistration** registration); 35 | 36 | } // namespace tflite 37 | 38 | #endif // TENSORFLOW_LITE_MICRO_TFLITE_BRIDGE_OP_RESOLVER_BRIDGE_H_ 39 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/persistent_arena_buffer_allocator.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 | #include "edge-impulse-sdk/tensorflow/lite/micro/persistent_arena_buffer_allocator.h" 16 | 17 | #include "edge-impulse-sdk/tensorflow/lite/micro/memory_helpers.h" 18 | #include "edge-impulse-sdk/tensorflow/lite/micro/micro_log.h" 19 | 20 | namespace tflite { 21 | 22 | PersistentArenaBufferAllocator::PersistentArenaBufferAllocator( 23 | uint8_t* buffer, size_t buffer_size) 24 | : buffer_head_(buffer), 25 | buffer_tail_(buffer + buffer_size), 26 | tail_temp_(buffer_tail_) {} 27 | 28 | PersistentArenaBufferAllocator::~PersistentArenaBufferAllocator() {} 29 | 30 | uint8_t* PersistentArenaBufferAllocator::AllocatePersistentBuffer( 31 | size_t size, size_t alignment) { 32 | uint8_t* const aligned_result = 33 | AlignPointerDown(tail_temp_ - size, alignment); 34 | if (aligned_result < buffer_head_) { 35 | #ifndef TF_LITE_STRIP_ERROR_STRINGS 36 | const size_t missing_memory = buffer_head_ - aligned_result; 37 | MicroPrintf( 38 | "Failed to allocate tail memory. Requested: %u, " 39 | "available %u, missing: %u", 40 | size, size - missing_memory, missing_memory); 41 | #endif 42 | return nullptr; 43 | } 44 | tail_temp_ = aligned_result; 45 | return aligned_result; 46 | } 47 | 48 | size_t PersistentArenaBufferAllocator::GetPersistentUsedBytes() const { 49 | return buffer_tail_ - tail_temp_; 50 | } 51 | 52 | } // namespace tflite 53 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/system_setup.cpp: -------------------------------------------------------------------------------- 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 | 16 | #include "edge-impulse-sdk/tensorflow/lite/micro/system_setup.h" 17 | 18 | namespace tflite { 19 | 20 | // To add an equivalent function for your own platform, create your own 21 | // implementation file, and place it in a subfolder named after the target. See 22 | // tensorflow/lite/micro/debug_log.cc for a similar example. 23 | void InitializeTarget() {} 24 | 25 | } // namespace tflite 26 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/system_setup.h: -------------------------------------------------------------------------------- 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 TENSORFLOW_LITE_MICRO_SYSTEM_SETUP_H_ 16 | #define TENSORFLOW_LITE_MICRO_SYSTEM_SETUP_H_ 17 | 18 | namespace tflite { 19 | 20 | // This should called during initialization of TFLM binaries and tests. It can 21 | // be specialized if there is a need for custom target-specific intialization. 22 | // For more information, see tensorflow/lite/micro/system_setup.cc. 23 | void InitializeTarget(); 24 | 25 | } // namespace tflite 26 | 27 | #endif // TENSORFLOW_LITE_MICRO_SYSTEM_SETUP_H_ 28 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/micro/test_helper_custom_ops.h: -------------------------------------------------------------------------------- 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 | 16 | #ifndef TENSORFLOW_LITE_MICRO_TEST_HELPER_CUSTOM_OPS_H_ 17 | #define TENSORFLOW_LITE_MICRO_TEST_HELPER_CUSTOM_OPS_H_ 18 | 19 | #include 20 | #include 21 | 22 | #include "edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/flatbuffers.h" // from @flatbuffers 23 | #include "edge-impulse-sdk/tensorflow/lite/c/common.h" 24 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/compatibility.h" 25 | #include "edge-impulse-sdk/tensorflow/lite/kernels/internal/tensor_ctypes.h" 26 | #include "edge-impulse-sdk/tensorflow/lite/micro/all_ops_resolver.h" 27 | #include "edge-impulse-sdk/tensorflow/lite/micro/micro_utils.h" 28 | #include "edge-impulse-sdk/tensorflow/lite/portable_type_to_tflitetype.h" 29 | #include "edge-impulse-sdk/tensorflow/lite/schema/schema_generated.h" 30 | 31 | namespace tflite { 32 | namespace testing { 33 | 34 | class PackerOp { 35 | public: 36 | static const TfLiteRegistration* getRegistration(); 37 | static TfLiteRegistration* GetMutableRegistration(); 38 | static void* Init(TfLiteContext* context, const char* buffer, size_t length); 39 | static void Free(TfLiteContext* context, void* buffer); 40 | static TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node); 41 | static TfLiteStatus Invoke(TfLiteContext* context, TfLiteNode* node); 42 | 43 | private: 44 | static bool freed_; 45 | }; 46 | 47 | } // namespace testing 48 | } // namespace tflite 49 | 50 | #endif // TENSORFLOW_LITE_MICRO_TEST_HELPER_CUSTOM_OPS_H_ 51 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/tensorflow/lite/schema/schema_utils.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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_SCHEMA_SCHEMA_UTILS_H_ 16 | #define TENSORFLOW_LITE_SCHEMA_SCHEMA_UTILS_H_ 17 | 18 | #include "edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/flatbuffers.h" 19 | #include "edge-impulse-sdk/tensorflow/lite/schema/schema_generated.h" 20 | 21 | namespace tflite { 22 | 23 | // The following methods are introduced to resolve op builtin code shortage 24 | // problem. The new builtin operator will be assigned to the extended builtin 25 | // code field in the flatbuffer schema. Those methods helps to hide builtin code 26 | // details. 27 | BuiltinOperator GetBuiltinCode(const OperatorCode *op_code); 28 | 29 | BuiltinOperator GetBuiltinCode(const OperatorCodeT *op_code); 30 | 31 | } // namespace tflite 32 | 33 | #endif // TENSORFLOW_LITE_SCHEMA_SCHEMA_UTILS_H_ 34 | -------------------------------------------------------------------------------- /src/edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/fb_buffer_ref.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef FLATBUFFERS_BUFFER_REF_H_ 18 | #define FLATBUFFERS_BUFFER_REF_H_ 19 | 20 | #include "edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/fb_base.h" 21 | #include "edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/fb_verifier.h" 22 | 23 | namespace flatbuffers { 24 | 25 | // Convenient way to bundle a buffer and its length, to pass it around 26 | // typed by its root. 27 | // A BufferRef does not own its buffer. 28 | struct BufferRefBase {}; // for std::is_base_of 29 | 30 | template struct BufferRef : BufferRefBase { 31 | BufferRef() : buf(nullptr), len(0), must_free(false) {} 32 | BufferRef(uint8_t *_buf, uoffset_t _len) 33 | : buf(_buf), len(_len), must_free(false) {} 34 | 35 | ~BufferRef() { 36 | if (must_free) free(buf); 37 | } 38 | 39 | const T *GetRoot() const { return flatbuffers::GetRoot(buf); } 40 | 41 | bool Verify() { 42 | Verifier verifier(buf, len); 43 | return verifier.VerifyBuffer(nullptr); 44 | } 45 | 46 | uint8_t *buf; 47 | uoffset_t len; 48 | bool must_free; 49 | }; 50 | 51 | } // namespace flatbuffers 52 | 53 | #endif // FLATBUFFERS_BUFFER_REF_H_ -------------------------------------------------------------------------------- /src/edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/fb_struct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef FLATBUFFERS_STRUCT_H_ 18 | #define FLATBUFFERS_STRUCT_H_ 19 | 20 | #include "edge-impulse-sdk/third_party/flatbuffers/include/flatbuffers/fb_base.h" 21 | 22 | namespace flatbuffers { 23 | 24 | // "structs" are flat structures that do not have an offset table, thus 25 | // always have all members present and do not support forwards/backwards 26 | // compatible extensions. 27 | 28 | class Struct FLATBUFFERS_FINAL_CLASS { 29 | public: 30 | template T GetField(uoffset_t o) const { 31 | return ReadScalar(&data_[o]); 32 | } 33 | 34 | template T GetStruct(uoffset_t o) const { 35 | return reinterpret_cast(&data_[o]); 36 | } 37 | 38 | const uint8_t *GetAddressOf(uoffset_t o) const { return &data_[o]; } 39 | uint8_t *GetAddressOf(uoffset_t o) { return &data_[o]; } 40 | 41 | private: 42 | // private constructor & copy constructor: you obtain instances of this 43 | // class by pointing to existing data only 44 | Struct(); 45 | Struct(const Struct &); 46 | Struct &operator=(const Struct &); 47 | 48 | uint8_t data_[1]; 49 | }; 50 | 51 | } // namespace flatbuffers 52 | 53 | #endif // FLATBUFFERS_STRUCT_H_ -------------------------------------------------------------------------------- /src/firmware-sdk/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | -------------------------------------------------------------------------------- /src/firmware-sdk/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `firmware-sdk` will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [Unreleased] 9 | ### Added 10 | - 11 | - Added `CMakeLists.txt` for CMake based build systems (#4459) 12 | - `ei_device_info_lib`: new `init_device_id` method to force developers to implement such a functionality (#4459) 13 | - `ei_device_info_lib`: now device has a default `device_id` value (#4459) 14 | - `EiDeviceMemory`: new `flush_data` method (#4152) 15 | - `at_base64_lib`: new API allowing for chunked data to be encoded and processed by UART (#4678) 16 | - `jpeg`: new API to encode and send in the base64 images from RAW RGB888, RGB565 or Grayscale buffers (#3579) 17 | 18 | ### Changed 19 | - Global define of `EI_SENSOR_AQ_STREAM=FILE` is not needed anymore (#4459) 20 | - Adding all `QCBOR` directories to include path is not needed anymore (#4459) 21 | - extended `set_*` methods of the `EiDeviceInfo` allowing to not save config after changeing value (#4543) 22 | - remove all references to old `ei_config_t` struct from `ei_fusion` module and use a new `EiDeviceInfo` interface (#4426) 23 | - Removed `const` qualifier from some of `EiDeviceMemory` fields (#4459) 24 | - Small fixes and code clean-up 25 | -------------------------------------------------------------------------------- /src/firmware-sdk/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13.1) 2 | 3 | if(NOT TARGET app) 4 | message(FATAL_ERROR "Please create a target named 'app' (ex: add_executable(app)) before adding this file") 5 | endif() 6 | 7 | target_include_directories(app PRIVATE .) 8 | 9 | # add all sources to the project 10 | RECURSIVE_FIND_FILE_APPEND(MODEL_SOURCE "." "*.cpp") 11 | RECURSIVE_FIND_FILE_APPEND(MODEL_C_SOURCE "." "*.c") 12 | target_sources(app PRIVATE ${MODEL_SOURCE} ${MODEL_C_SOURCE}) 13 | -------------------------------------------------------------------------------- /src/firmware-sdk/README.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | The firmware-sdk provides portable code for commonly needed processing tasks. It in turn relies on drivers provided for specific targets. 4 | 5 | # Core functions 6 | Chip specific implementations must be provided for the following header files: 7 | - ei_classifier_porting.h 8 | - ei_device_info_lib.h 9 | - ei_device_interface.h 10 | 11 | # Sensors 12 | 13 | ## Camera 14 | 15 | - Ingestion (snapshot, snapshot_stream) format: 16 | The daemon (and the frame-to-jpeg debug tool) expect packed RGB 17 | (3B per pixel, as opposed to 4B with high B to 0 for inference) 18 | - Big endian format (uint8_t image[i] is R, image[i+1] is G, ... 19 | 20 | - Inference format: 21 | - The "get_data" function expects RGB encoded into floats, respecting the endianness of the platform 22 | - If you encode with bit shifting, you'll encode with the endianness of the chip 23 | - something like: static_cast((r << 16) + (g << 8 ) + b)) 24 | - The encoding is 4B, so there's a pad byte in the MSB of the float 25 | 26 | ### Porting 27 | 28 | - The top level of all firmware is chip specific. ei_image_lib provides portable, convenient functions for binding to AT commands. 29 | ``` 30 | config_ctx.take_snapshot = &ei_camera_take_snapshot_output_on_serial; 31 | config_ctx.start_snapshot_stream = &ei_camera_start_snapshot_stream; 32 | ``` 33 | - To support these two functions, one must provide a driver implementation for the following interface class: ei_camera_interface.h 34 | - This is a singleton class pattern with a port provided factory. All needed functions are prototyped in ei_camera_interface.h 35 | - (The "core" functions must also be present, see "Core functions" above) 36 | - Other support functions exist in ei_image_lib 37 | - YUV422 to RGB conversion 38 | - ei_image_nn.h supports inference, but does not need to be touched. It calls the camera factory. 39 | 40 | ### Interface notes 41 | 42 | at_get_snapshot_list : Return possible resolutions, greyscale, etc 43 | - const char **color_depth >-should be-> "Greyscale" or "RGB" -------------------------------------------------------------------------------- /src/ingestion-sdk-c/ei_run_impulse.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef EI_RUN_IMPULSE_H 36 | #define EI_RUN_IMPULSE_H 37 | 38 | /* Prototypes -------------------------------------------------------------- */ 39 | void run_nn_debug(const char *baudrate_s); 40 | void run_nn_normal(void); 41 | void run_nn_continuous_normal(void); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/ingestion-sdk-c/ei_sampler.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _EI_SAMPLER_H 36 | #define _EI_SAMPLER_H 37 | 38 | #include "ei_config_types.h" 39 | 40 | /* Function prototypes ----------------------------------------------------- */ 41 | bool ei_sampler_start_sampling(void *v_ptr_payload, starter_callback ei_sample_start, uint32_t sample_size); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/ingestion-sdk-platform/nano-ble33/ei_at_handlers.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef EI_AT_HANDLERS_H 36 | #define EI_AT_HANDLERS_H 37 | 38 | #include "firmware-sdk/at-server/ei_at_server.h" 39 | #include "ei_device_nano_ble33.h" 40 | 41 | ATServer *ei_at_init(EiDeviceNanoBle33 *device); 42 | 43 | #endif /* EI_AT_HANDLERS_H */ -------------------------------------------------------------------------------- /src/setup.h: -------------------------------------------------------------------------------- 1 | /* The Clear BSD License 2 | * 3 | * Copyright (c) 2025 EdgeImpulse Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted (subject to the limitations in the disclaimer 8 | * below) provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright notice, 11 | * this list of conditions and the following disclaimer. 12 | * 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from this 19 | * software without specific prior written permission. 20 | * 21 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _EI_ARDUINO_NANO_33_BLE_SETUP_H_ 36 | #define _EI_ARDUINO_NANO_33_BLE_SETUP_H_ 37 | 38 | #include "mbed.h" 39 | 40 | using namespace rtos; 41 | using namespace events; 42 | 43 | extern void ei_write_string(char *data, int length); 44 | int ei_get_serial_available(void); 45 | char ei_get_serial_byte(void); 46 | 47 | void print_memory_info(); 48 | void ei_main_init(void); 49 | void ei_main(void); 50 | 51 | #endif // _EI_ARDUINO_NANO_33_BLE_SETUP_H_ 52 | --------------------------------------------------------------------------------