Skip to content

Commit 5248a7f

Browse files
committed
adds data validator cuda kernel
1 parent 6557f01 commit 5248a7f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
template <typename Type>
2+
__global__ void remove_nan_inf(Type *data, int Z, int M, int N, int *result) {
3+
const long i = blockDim.x * blockIdx.x + threadIdx.x;
4+
const long j = blockDim.y * blockIdx.y + threadIdx.y;
5+
const long k = blockDim.z * blockIdx.z + threadIdx.z;
6+
7+
if (i >= N || j >= M || k >= Z)
8+
return;
9+
10+
long long index = static_cast<long long>(i) + N * static_cast<long long>(j) + N * M * static_cast<long long>(k);
11+
12+
float val = float(data[index]); /*needs a cast to float for isnan isinf functions to work*/
13+
Type zero = 0;
14+
if (isnan(val) || isinf(val)) {
15+
result[0] = 1;
16+
data[index] = zero;
17+
}
18+
19+
}

0 commit comments

Comments
 (0)