Создание масок на основе евклидова расстояния с помощью pyopencl, arrayfire или другой библиотеки Python opencl ⇐ Python
Создание масок на основе евклидова расстояния с помощью pyopencl, arrayfire или другой библиотеки Python opencl
I am doing 2D or 3D binary masks around given coordinates and then identifying them as labels with scipy.ndimage.label. Now, I have a cupy solution, a numpy solution. Cupy is fast, numpy is very slow, both do their job. I'm trying to make it run on other non nvidia GPUs or CPUs with openCl or any other form that would be more "cross platform" such as pyopencl or numba, or tensorflow even (or all of the above)
This is my current function:
def make_labels_links(shape,j,radius=5,_algo="GPU"): import scipy.ndimage as ndi if _algo == "GPU": import cupy as cp if 'z' in j: pos = cp.dstack((j.z,j.y,j.x))[0]#.astype(int) print("3D",j) else: pos = cp.dstack((j.y,j.x))[0]#.astype(int) print("2D",j) ndim = len(shape) # radius = validate_tuple(radius, ndim) pos = cp.atleast_2d(pos) # if include_edge: in_mask = cp.array([cp.sum(((cp.indices(shape).T - p) / radius)**2, -1)
Источник: https://stackoverflow.com/questions/780 ... nother-pyt
I am doing 2D or 3D binary masks around given coordinates and then identifying them as labels with scipy.ndimage.label. Now, I have a cupy solution, a numpy solution. Cupy is fast, numpy is very slow, both do their job. I'm trying to make it run on other non nvidia GPUs or CPUs with openCl or any other form that would be more "cross platform" such as pyopencl or numba, or tensorflow even (or all of the above)
This is my current function:
def make_labels_links(shape,j,radius=5,_algo="GPU"): import scipy.ndimage as ndi if _algo == "GPU": import cupy as cp if 'z' in j: pos = cp.dstack((j.z,j.y,j.x))[0]#.astype(int) print("3D",j) else: pos = cp.dstack((j.y,j.x))[0]#.astype(int) print("2D",j) ndim = len(shape) # radius = validate_tuple(radius, ndim) pos = cp.atleast_2d(pos) # if include_edge: in_mask = cp.array([cp.sum(((cp.indices(shape).T - p) / radius)**2, -1)
Источник: https://stackoverflow.com/questions/780 ... nother-pyt
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение