diff options
author | dkazanc <dkazanc@hotmail.com> | 2019-12-09 14:08:21 +0000 |
---|---|---|
committer | dkazanc <dkazanc@hotmail.com> | 2019-12-09 14:08:21 +0000 |
commit | 970e82c7ee5fedab771480f42293963fdc32d17b (patch) | |
tree | a258214525adf239ecdc76952cc69fd4de801d16 /src/Python | |
parent | d1585fb280ead79b2bf3962c3e6d492b71acb723 (diff) | |
download | regularization-970e82c7ee5fedab771480f42293963fdc32d17b.tar.gz regularization-970e82c7ee5fedab771480f42293963fdc32d17b.tar.bz2 regularization-970e82c7ee5fedab771480f42293963fdc32d17b.tar.xz regularization-970e82c7ee5fedab771480f42293963fdc32d17b.zip |
fixes gpu issues with pdtv
Diffstat (limited to 'src/Python')
-rw-r--r-- | src/Python/ccpi/filters/regularisers.py | 8 | ||||
-rw-r--r-- | src/Python/src/cpu_regularisers.pyx | 18 | ||||
-rw-r--r-- | src/Python/src/gpu_regularisers.pyx | 16 |
3 files changed, 16 insertions, 26 deletions
diff --git a/src/Python/ccpi/filters/regularisers.py b/src/Python/ccpi/filters/regularisers.py index 5f4001a..e3a984e 100644 --- a/src/Python/ccpi/filters/regularisers.py +++ b/src/Python/ccpi/filters/regularisers.py @@ -53,7 +53,7 @@ def FGP_TV(inputData, regularisation_parameter,iterations, .format(device)) def PD_TV(inputData, regularisation_parameter, iterations, - tolerance_param, methodTV, nonneg, lipschitz_const, tau, device='cpu'): + tolerance_param, methodTV, nonneg, lipschitz_const, device='cpu'): if device == 'cpu': return TV_PD_CPU(inputData, regularisation_parameter, @@ -61,8 +61,7 @@ def PD_TV(inputData, regularisation_parameter, iterations, tolerance_param, methodTV, nonneg, - lipschitz_const, - tau) + lipschitz_const) elif device == 'gpu' and gpu_enabled: return TV_PD_GPU(inputData, regularisation_parameter, @@ -70,8 +69,7 @@ def PD_TV(inputData, regularisation_parameter, iterations, tolerance_param, methodTV, nonneg, - lipschitz_const, - tau) + lipschitz_const) else: if not gpu_enabled and device == 'gpu': raise ValueError ('GPU is not available') diff --git a/src/Python/src/cpu_regularisers.pyx b/src/Python/src/cpu_regularisers.pyx index 8de6aea..08e247c 100644 --- a/src/Python/src/cpu_regularisers.pyx +++ b/src/Python/src/cpu_regularisers.pyx @@ -20,7 +20,7 @@ cimport numpy as np cdef extern float TV_ROF_CPU_main(float *Input, float *Output, float *infovector, float *lambdaPar, int lambda_is_arr, int iterationsNumb, float tau, float epsil, int dimX, int dimY, int dimZ); cdef extern float TV_FGP_CPU_main(float *Input, float *Output, float *infovector, float lambdaPar, int iterationsNumb, float epsil, int methodTV, int nonneg, int dimX, int dimY, int dimZ); -cdef extern float PDTV_CPU_main(float *Input, float *U, float *infovector, float lambdaPar, int iterationsNumb, float epsil, float lipschitz_const, int methodTV, int nonneg, float tau, int dimX, int dimY, int dimZ); +cdef extern float PDTV_CPU_main(float *Input, float *U, float *infovector, float lambdaPar, int iterationsNumb, float epsil, float lipschitz_const, int methodTV, int nonneg, int dimX, int dimY, int dimZ); cdef extern float SB_TV_CPU_main(float *Input, float *Output, float *infovector, float mu, int iter, float epsil, int methodTV, int dimX, int dimY, int dimZ); cdef extern float LLT_ROF_CPU_main(float *Input, float *Output, float *infovector, float lambdaROF, float lambdaLLT, int iterationsNumb, float tau, float epsil, int dimX, int dimY, int dimZ); cdef extern float TGV_main(float *Input, float *Output, float *infovector, float lambdaPar, float alpha1, float alpha0, int iterationsNumb, float L2, float epsil, int dimX, int dimY, int dimZ); @@ -159,11 +159,11 @@ def TV_FGP_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData, #****************************************************************# #****************** Total-variation Primal-dual *****************# #****************************************************************# -def TV_PD_CPU(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, nonneg, lipschitz_const, tau): +def TV_PD_CPU(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, nonneg, lipschitz_const): if inputData.ndim == 2: - return TV_PD_2D(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, nonneg, lipschitz_const, tau) + return TV_PD_2D(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, nonneg, lipschitz_const) elif inputData.ndim == 3: - return TV_PD_3D(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, nonneg, lipschitz_const, tau) + return TV_PD_3D(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, nonneg, lipschitz_const) def TV_PD_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData, float regularisation_parameter, @@ -171,8 +171,7 @@ def TV_PD_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData, float tolerance_param, int methodTV, int nonneg, - float lipschitz_const, - float tau): + float lipschitz_const): cdef long dims[2] dims[0] = inputData.shape[0] @@ -191,7 +190,6 @@ def TV_PD_2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData, lipschitz_const, methodTV, nonneg, - tau, dims[1],dims[0], 1) return (outputData,infovec) @@ -200,9 +198,8 @@ def TV_PD_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData, int iterationsNumb, float tolerance_param, int methodTV, - int nonneg, - float lipschitz_const, - float tau): + int nonneg, + float lipschitz_const): cdef long dims[3] dims[0] = inputData.shape[0] @@ -221,7 +218,6 @@ def TV_PD_3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData, lipschitz_const, methodTV, nonneg, - tau, dims[2], dims[1], dims[0]) return (outputData,infovec) diff --git a/src/Python/src/gpu_regularisers.pyx b/src/Python/src/gpu_regularisers.pyx index b22d15e..8a4568e 100644 --- a/src/Python/src/gpu_regularisers.pyx +++ b/src/Python/src/gpu_regularisers.pyx @@ -22,7 +22,7 @@ CUDAErrorMessage = 'CUDA error' cdef extern int TV_ROF_GPU_main(float* Input, float* Output, float *infovector, float *lambdaPar, int lambda_is_arr, int iter, float tau, float epsil, int N, int M, int Z); cdef extern int TV_FGP_GPU_main(float *Input, float *Output, float *infovector, float lambdaPar, int iter, float epsil, int methodTV, int nonneg, int N, int M, int Z); -cdef extern int TV_PD_GPU_main(float *Input, float *Output, float *infovector, float lambdaPar, int iter, float epsil, float lipschitz_const, int methodTV, int nonneg, float tau, int dimX, int dimY, int dimZ); +cdef extern int TV_PD_GPU_main(float *Input, float *Output, float *infovector, float lambdaPar, int iter, float epsil, float lipschitz_const, int methodTV, int nonneg, int dimX, int dimY, int dimZ); cdef extern int TV_SB_GPU_main(float *Input, float *Output, float *infovector, float lambdaPar, int iter, float epsil, int methodTV, int N, int M, int Z); cdef extern int LLT_ROF_GPU_main(float *Input, float *Output, float *infovector, float lambdaROF, float lambdaLLT, int iterationsNumb, float tau, float epsil, int N, int M, int Z); cdef extern int TGV_GPU_main(float *Input, float *Output, float *infovector, float lambdaPar, float alpha1, float alpha0, int iterationsNumb, float L2, float epsil, int dimX, int dimY, int dimZ); @@ -72,11 +72,11 @@ def TV_FGP_GPU(inputData, methodTV, nonneg) # Total-variation Primal-Dual (PD) -def TV_PD_GPU(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, nonneg, lipschitz_const, tau): +def TV_PD_GPU(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, nonneg, lipschitz_const): if inputData.ndim == 2: - return TVPD2D(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, nonneg, lipschitz_const, tau) + return TVPD2D(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, nonneg, lipschitz_const) elif inputData.ndim == 3: - return TVPD3D(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, nonneg, lipschitz_const, tau) + return TVPD3D(inputData, regularisation_parameter, iterationsNumb, tolerance_param, methodTV, nonneg, lipschitz_const) def TVPD2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData, float regularisation_parameter, @@ -84,8 +84,7 @@ def TVPD2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData, float tolerance_param, int methodTV, int nonneg, - float lipschitz_const, - float tau): + float lipschitz_const): cdef long dims[2] dims[0] = inputData.shape[0] @@ -103,7 +102,6 @@ def TVPD2D(np.ndarray[np.float32_t, ndim=2, mode="c"] inputData, lipschitz_const, methodTV, nonneg, - tau, dims[1],dims[0], 1) ==0): return (outputData,infovec) else: @@ -115,8 +113,7 @@ def TVPD3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData, float tolerance_param, int methodTV, int nonneg, - float lipschitz_const, - float tau): + float lipschitz_const): cdef long dims[3] dims[0] = inputData.shape[0] @@ -134,7 +131,6 @@ def TVPD3D(np.ndarray[np.float32_t, ndim=3, mode="c"] inputData, lipschitz_const, methodTV, nonneg, - tau, dims[2], dims[1], dims[0]) ==0): return (outputData,infovec) else: |