| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- #include "SVMF16.h"
- #include <stdio.h>
- #include "Error.h"
- void SVMF16::test_svm_linear_predict_f16()
- {
- int32_t result;
- arm_svm_linear_predict_f16(&this->linear,inp,&result);
-
- }
- void SVMF16::test_svm_polynomial_predict_f16()
- {
- int32_t result;
- arm_svm_polynomial_predict_f16(&this->poly,inp,&result);
-
- }
- void SVMF16::test_svm_rbf_predict_f16()
- {
- int32_t result;
- arm_svm_rbf_predict_f16(&this->rbf,inp,&result);
-
- }
- void SVMF16::test_svm_sigmoid_predict_f16()
- {
- int32_t result;
- arm_svm_sigmoid_predict_f16(&this->sigmoid,inp,&result);
-
- }
- void SVMF16::setUp(Testing::testID_t id,std::vector<Testing::param_t>& testparams,Client::PatternMgr *mgr)
- {
-
- int kind;
- int nbp,nbi;
- const float16_t *paramsp;
- std::vector<Testing::param_t>::iterator it = testparams.begin();
- this->vecDim = *it++;
- this->nbSupportVectors = *it++;
- switch(id)
- {
- case SVMF16::TEST_SVM_LINEAR_PREDICT_F16_1:
- {
- samples.reload(SVMF16::INPUT_F16_ID,mgr,this->vecDim);
- params.reload(SVMF16::PARAMS_LINEAR_F16_ID,mgr);
- dims.reload(SVMF16::DIMS_LINEAR_S16_ID,mgr);
- int16_t *dimsp=dims.ptr();
- nbi = dimsp[2*this->nbLinear];
- nbp = dimsp[2*this->nbLinear + 1];
- paramsp = params.ptr() + nbp;
- inp=samples.ptr() + nbi;
- kind = SVMF16::LINEAR;
- }
- break;
- case SVMF16::TEST_SVM_POLYNOMIAL_PREDICT_F16_2:
- {
-
- samples.reload(SVMF16::INPUT_F16_ID,mgr,this->vecDim);
- params.reload(SVMF16::PARAMS_POLY_F16_ID,mgr);
- dims.reload(SVMF16::DIMS_POLY_S16_ID,mgr);
- int16_t *dimsp=dims.ptr();
- nbi = dimsp[2*this->nbPoly];
- nbp = dimsp[2*this->nbPoly + 1];
- paramsp = params.ptr() + nbp;
- inp=samples.ptr() + nbi;
- kind = SVMF16::POLY;
- }
- break;
- case SVMF16::TEST_SVM_RBF_PREDICT_F16_3:
- {
-
- samples.reload(SVMF16::INPUT_F16_ID,mgr,this->vecDim);
- params.reload(SVMF16::PARAMS_RBF_F16_ID,mgr);
- dims.reload(SVMF16::DIMS_RBF_S16_ID,mgr);
- int16_t *dimsp=dims.ptr();
- nbi = dimsp[2*this->nbRBF];
- nbp = dimsp[2*this->nbRBF + 1];
- paramsp = params.ptr() + nbp;
- inp=samples.ptr() + nbi;
- kind = SVMF16::RBF;
- }
- break;
- case SVMF16::TEST_SVM_SIGMOID_PREDICT_F16_4:
- {
- samples.reload(SVMF16::INPUT_F16_ID,mgr,this->vecDim);
- params.reload(SVMF16::PARAMS_SIGMOID_F16_ID,mgr);
- dims.reload(SVMF16::DIMS_SIGMOID_S16_ID,mgr);
- int16_t *dimsp=dims.ptr();
- nbi = dimsp[2*this->nbSigmoid];
- nbp = dimsp[2*this->nbSigmoid + 1];
- paramsp = params.ptr() + nbp;
- inp=samples.ptr() + nbi;
- kind = SVMF16::SIGMOID;
- }
- break;
- }
-
-
- this->classes[0] = 0;
- this->classes[1] = 1;
- this->intercept=paramsp[this->vecDim*this->nbSupportVectors + this->nbSupportVectors];
- this->supportVectors=paramsp;
- this->dualCoefs=paramsp + (this->vecDim*this->nbSupportVectors);
- switch(kind)
- {
-
- case SVMF16::POLY:
- this->coef0 =paramsp[this->vecDim*this->nbSupportVectors + this->nbSupportVectors + 1] ;
- this->gamma=paramsp[this->vecDim*this->nbSupportVectors + this->nbSupportVectors + 2];
- this->degree=(int)paramsp[this->vecDim*this->nbSupportVectors + this->nbSupportVectors + 3];
- break;
- case SVMF16::RBF:
- this->gamma=paramsp[this->vecDim*this->nbSupportVectors + this->nbSupportVectors + 1];
- break;
- case SVMF16::SIGMOID:
- this->coef0 =paramsp[this->vecDim*this->nbSupportVectors + this->nbSupportVectors + 1] ;
- this->gamma=paramsp[this->vecDim*this->nbSupportVectors + this->nbSupportVectors + 2];
- break;
- }
-
- switch(id)
- {
- case SVMF16::TEST_SVM_LINEAR_PREDICT_F16_1:
- {
-
- arm_svm_linear_init_f16(&linear,
- this->nbSupportVectors,
- this->vecDim,
- this->intercept,
- this->dualCoefs,
- this->supportVectors,
- this->classes);
- }
- break;
- case SVMF16::TEST_SVM_POLYNOMIAL_PREDICT_F16_2:
- {
-
- arm_svm_polynomial_init_f16(&poly,
- this->nbSupportVectors,
- this->vecDim,
- this->intercept,
- this->dualCoefs,
- this->supportVectors,
- this->classes,
- this->degree,
- this->coef0,
- this->gamma
- );
- }
- break;
- case SVMF16::TEST_SVM_RBF_PREDICT_F16_3:
- {
-
- arm_svm_rbf_init_f16(&rbf,
- this->nbSupportVectors,
- this->vecDim,
- this->intercept,
- this->dualCoefs,
- this->supportVectors,
- this->classes,
- this->gamma
- );
- }
- break;
- case SVMF16::TEST_SVM_SIGMOID_PREDICT_F16_4:
- {
-
- arm_svm_sigmoid_init_f16(&sigmoid,
- this->nbSupportVectors,
- this->vecDim,
- this->intercept,
- this->dualCoefs,
- this->supportVectors,
- this->classes,
- this->coef0,
- this->gamma
- );
- }
- break;
- }
-
- }
- void SVMF16::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
- {
- (void)mgr;
- switch(id)
- {
- case SVMF16::TEST_SVM_LINEAR_PREDICT_F16_1:
- nbLinear++;
- break;
- case SVMF16::TEST_SVM_POLYNOMIAL_PREDICT_F16_2:
- nbPoly++;
- break;
- case SVMF16::TEST_SVM_RBF_PREDICT_F16_3:
- nbRBF++;
- break;
- case SVMF16::TEST_SVM_SIGMOID_PREDICT_F16_4:
- nbSigmoid++;
- break;
- }
- }
|