BayesF16.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #include "BayesF16.h"
  2. #include <stdio.h>
  3. #include "Error.h"
  4. #include "Test.h"
  5. void BayesF16::test_gaussian_naive_bayes_predict_f16()
  6. {
  7. (void)arm_gaussian_naive_bayes_predict_f16(&bayes,
  8. inp,
  9. bufp,tempp);
  10. }
  11. void BayesF16::setUp(Testing::testID_t id,std::vector<Testing::param_t>& paramsArgs,Client::PatternMgr *mgr)
  12. {
  13. std::vector<Testing::param_t>::iterator it = paramsArgs.begin();
  14. this->vecDim = *it++;
  15. this->classNb = *it++;
  16. switch(id)
  17. {
  18. case BayesF16::TEST_GAUSSIAN_NAIVE_BAYES_PREDICT_F16_1:
  19. {
  20. int nbp,nbi;
  21. input.reload(BayesF16::INPUTS2_F16_ID,mgr);
  22. params.reload(BayesF16::PARAMS2_F16_ID,mgr);
  23. dims.reload(BayesF16::DIMS2_S16_ID,mgr);
  24. int16_t *dimsp=dims.ptr();
  25. nbi = dimsp[2*this->nb];
  26. nbp = dimsp[2*this->nb + 1];
  27. const float16_t *paramsp = params.ptr() + nbp;
  28. this->theta=paramsp ;
  29. this->sigma=paramsp + (this->classNb * this->vecDim);
  30. this->classPrior=paramsp + 2*(this->classNb * this->vecDim);
  31. this->epsilon=paramsp[this->classNb + 2*(this->classNb * this->vecDim)];
  32. //printf("%f %f %f\n",this->theta[0],this->sigma[0],this->classPrior[0]);
  33. // Reference patterns are not loaded when we are in dump mode
  34. predicts.reload(BayesF16::PREDICTS2_S16_ID,mgr);
  35. outputProbas.create(this->classNb,BayesF16::OUT_PROBA_F16_ID,mgr);
  36. temp.create(this->classNb,BayesF16::OUT_PROBA_F16_ID,mgr);
  37. bayes.vectorDimension=this->vecDim;
  38. bayes.numberOfClasses=this->classNb;
  39. bayes.theta=this->theta;
  40. bayes.sigma=this->sigma;
  41. bayes.classPriors=this->classPrior;
  42. bayes.epsilon=this->epsilon;
  43. this->inp = input.ptr() + nbi;
  44. this->bufp = outputProbas.ptr();
  45. this->tempp = temp.ptr();
  46. }
  47. break;
  48. }
  49. }
  50. void BayesF16::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  51. {
  52. (void)id;
  53. (void)mgr;
  54. this->nb++;
  55. }