bayes_functions_f16.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /******************************************************************************
  2. * @file bayes_functions_f16.h
  3. * @brief Public header file for NMSIS DSP Library
  4. * @version V1.10.0
  5. * @date 08 July 2021
  6. * Target Processor: RISC-V Cores
  7. ******************************************************************************/
  8. /*
  9. * Copyright (c) 2010-2020 Arm Limited or its affiliates. All rights reserved.
  10. * Copyright (c) 2019 Nuclei Limited. 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. #ifndef BAYES_FUNCTIONS_F16_H_
  27. #define BAYES_FUNCTIONS_F16_H_
  28. #include "riscv_math_types_f16.h"
  29. #include "riscv_math_memory.h"
  30. #include "dsp/none.h"
  31. #include "dsp/utils.h"
  32. #include "dsp/statistics_functions_f16.h"
  33. #ifdef __cplusplus
  34. extern "C"
  35. {
  36. #endif
  37. #if defined(RISCV_FLOAT16_SUPPORTED)
  38. /**
  39. * @brief Instance structure for Naive Gaussian Bayesian estimator.
  40. */
  41. typedef struct
  42. {
  43. uint32_t vectorDimension; /**< Dimension of vector space */
  44. uint32_t numberOfClasses; /**< Number of different classes */
  45. const float16_t *theta; /**< Mean values for the Gaussians */
  46. const float16_t *sigma; /**< Variances for the Gaussians */
  47. const float16_t *classPriors; /**< Class prior probabilities */
  48. float16_t epsilon; /**< Additive value to variances */
  49. } riscv_gaussian_naive_bayes_instance_f16;
  50. /**
  51. * @brief Naive Gaussian Bayesian Estimator
  52. *
  53. * @param[in] S points to a naive bayes instance structure
  54. * @param[in] in points to the elements of the input vector.
  55. * @param[out] *pOutputProbabilities points to a buffer of length numberOfClasses containing estimated probabilities
  56. * @param[out] *pBufferB points to a temporary buffer of length numberOfClasses
  57. * @return The predicted class
  58. */
  59. uint32_t riscv_gaussian_naive_bayes_predict_f16(const riscv_gaussian_naive_bayes_instance_f16 *S,
  60. const float16_t * in,
  61. float16_t *pOutputProbabilities,
  62. float16_t *pBufferB);
  63. #endif /*defined(RISCV_FLOAT16_SUPPORTED)*/
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67. #endif /* ifndef _BAYES_FUNCTIONS_F16_H_ */