Updated Python wrapper with new accumulate functions

pull/42/head
Christophe Favergeon 3 years ago
parent 7a8b3da85e
commit b416800e17

@ -1922,6 +1922,34 @@ cmsis_arm_entropy_f32(PyObject *obj, PyObject *args)
return(NULL);
}
static PyObject *
cmsis_arm_accumulate_f32(PyObject *obj, PyObject *args)
{
PyObject *pSrc=NULL; // input
float32_t *pSrc_converted=NULL; // input
uint32_t blockSize; // input
float32_t pResult; // output
if (PyArg_ParseTuple(args,"O",&pSrc))
{
GETARGUMENT(pSrc,NPY_DOUBLE,double,float32_t);
blockSize = arraySizepSrc ;
arm_accumulate_f32(pSrc_converted,blockSize,&pResult);
PyObject* pResultOBJ=Py_BuildValue("f",pResult);
PyObject *pythonResult = Py_BuildValue("O",pResultOBJ);
FREEARGUMENT(pSrc_converted);
Py_DECREF(pResultOBJ);
return(pythonResult);
}
return(NULL);
}
static PyObject *
cmsis_arm_entropy_f64(PyObject *obj, PyObject *args)
{
@ -1950,6 +1978,34 @@ cmsis_arm_entropy_f64(PyObject *obj, PyObject *args)
return(NULL);
}
static PyObject *
cmsis_arm_accumulate_f64(PyObject *obj, PyObject *args)
{
PyObject *pSrc=NULL; // input
float64_t *pSrc_converted=NULL; // input
uint32_t blockSize; // input
float64_t pResult; // output
if (PyArg_ParseTuple(args,"O",&pSrc))
{
GETARGUMENT(pSrc,NPY_DOUBLE,double,float64_t);
blockSize = arraySizepSrc ;
arm_accumulate_f64(pSrc_converted,blockSize,&pResult);
PyObject* pResultOBJ=Py_BuildValue("d",pResult);
PyObject *pythonResult = Py_BuildValue("O",pResultOBJ);
FREEARGUMENT(pSrc_converted);
Py_DECREF(pResultOBJ);
return(pythonResult);
}
return(NULL);
}
static PyObject *
cmsis_arm_kullback_leibler_f32(PyObject *obj, PyObject *args)
{
@ -2345,6 +2401,8 @@ static PyMethodDef CMSISDSPMethods[] = {
{"arm_mse_q31", cmsis_arm_mse_q31, METH_VARARGS,""},
{"arm_mse_f32", cmsis_arm_mse_f32, METH_VARARGS,""},
{"arm_mse_f64", cmsis_arm_mse_f64, METH_VARARGS,""},
{"arm_accumulate_f32", cmsis_arm_accumulate_f32, METH_VARARGS,""},
{"arm_accumulate_f64", cmsis_arm_accumulate_f64, METH_VARARGS,""},
{"error_out", (PyCFunction)error_out, METH_NOARGS, NULL},

@ -0,0 +1,23 @@
# New functions for version 1.5 of the Python wrapper
import cmsisdsp as dsp
import cmsisdsp.fixedpoint as f
import numpy as np
import math
import colorama
from colorama import init,Fore, Back, Style
from numpy.testing import assert_allclose
NBSAMPLES=256
data1=np.random.randn(NBSAMPLES)
ref = np.sum(data1)
#print(ref)
t = dsp.arm_accumulate_f64(data1)
#print(t)
assert_allclose(ref,t)
t = dsp.arm_accumulate_f32(data1)
#print(t)
assert_allclose(ref,t,rtol=2e-6)

@ -19,11 +19,11 @@ from cmsisdsp_svm import *
__version__ = cmsisdsp.version.__version__
# CMSIS-DSP Version used to build the wrapper
cmsis_dsp_version="1.10.2"
cmsis_dsp_version="1.12.0"
# CMSIS-DSP Commit hash used to build the wrapper
commit_hash="91f599c052d9790d55210981526e9f607bb85cd2"
commit_hash="7a8b3da85e97808b6b467377c93d447cfa6a6a6d"
# True if development version of CMSIS-DSP used
# (So several CMSIS-DSP versions may have same version number hence the commit hash)

@ -1 +1 @@
__version__ = "1.5.1"
__version__ = "1.6.0"

Loading…
Cancel
Save