Created
October 20, 2021 18:24
-
-
Save Gcav66/eaeb8002b473ef277d6cac2cdc30812b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numba import cuda | |
import numpy as np | |
import cupy | |
def gather_from_detector(): | |
return cupy.random.random((1000, 1000), dtype="float32") | |
@cuda.jit | |
def smooth_gpu(x, out): | |
i, j = cuda.grid(2) | |
n, m = x.shape | |
if 1 <= i < n - 1 and 1 <= j < m - 1: | |
out[i, j] = (x[i - 1, j - 1] + x[i - 1, j] + x[i - 1, j + 1] + | |
x[i , j - 1] + x[i , j] + x[i , j + 1] + | |
x[i + 1, j - 1] + x[i + 1, j] + x[i + 1, j + 1]) // 9 | |
def smooth(x): | |
out = cupy.empty_like(x) | |
smooth_gpu[2, 32](x, out) | |
return out | |
def save(x, filename): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment