Skip to content

Commit 61dcea6

Browse files
authored
Merge pull request #241 from IntelPython/fix/flake8_exclusions
Fix complexity violations highlighted by flake8
2 parents dde8893 + 627cab7 commit 61dcea6

File tree

5 files changed

+18
-22
lines changed

5 files changed

+18
-22
lines changed

.flake8

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,4 @@ exclude =
88
__pycache__
99
./dist
1010
./setup.py
11-
./dpbench/benchmarks/l2_norm/l2_norm_numba_dpex_k.py
12-
./dpbench/benchmarks/pairwise_distance/pairwise_distance_numba_dpex_k.py
13-
./dpbench/benchmarks/pairwise_distance/pairwise_distance_numba_dpex_p.py
14-
./dpbench/benchmarks/pairwise_distance/pairwise_distance_numba_npr.py
1511
max-complexity = 10

dpbench/benchmarks/l2_norm/l2_norm_numba_dpex_k.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
@dpex.kernel
1010
def l2_norm_kernel(a, d):
1111
i = dpex.get_global_id(0)
12-
O = a.shape[1]
12+
a_rows = a.shape[1]
1313
d[i] = 0.0
14-
for k in range(O):
14+
for k in range(a_rows):
1515
d[i] += a[i, k] * a[i, k]
1616
d[i] = np.sqrt(d[i])
1717

dpbench/benchmarks/pairwise_distance/pairwise_distance_numba_dpex_k.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
def _pairwise_distance_kernel(X1, X2, D):
1111
i = dpex.get_global_id(0)
1212

13-
N = X2.shape[0]
14-
O = X1.shape[1]
15-
for j in range(N):
13+
X2_rows = X2.shape[0]
14+
X1_cols = X1.shape[1]
15+
for j in range(X2_rows):
1616
d = 0.0
17-
for k in range(O):
17+
for k in range(X1_cols):
1818
tmp = X1[i, k] - X2[j, k]
1919
d += tmp * tmp
2020
D[i, j] = np.sqrt(d)

dpbench/benchmarks/pairwise_distance/pairwise_distance_numba_dpex_p.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ def pairwise_distance(X1, X2, D):
1818
D : Outputted distance matrix
1919
"""
2020
# Size of inputs
21-
M = X1.shape[0]
22-
N = X2.shape[0]
23-
O = X1.shape[1]
21+
X1_rows = X1.shape[0]
22+
X2_rows = X2.shape[0]
23+
X1_cols = X1.shape[1]
2424

2525
# Outermost parallel loop over the matrix X1
26-
for i in nb.prange(M):
26+
for i in nb.prange(X1_rows):
2727
# Loop over the matrix X2
28-
for j in range(N):
28+
for j in range(X2_rows):
2929
d = 0.0
3030
# Compute exclidean distance
31-
for k in range(O):
31+
for k in range(X1_cols):
3232
tmp = X1[i, k] - X2[j, k]
3333
d += tmp * tmp
3434
# Write computed distance to distance matrix

dpbench/benchmarks/pairwise_distance/pairwise_distance_numba_npr.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
@nb.njit(parallel=True, fastmath=True)
1010
def pairwise_distance(X1, X2, D):
11-
M = X1.shape[0]
12-
N = X2.shape[0]
13-
O = X1.shape[1]
14-
for i in nb.prange(M):
15-
for j in range(N):
11+
X1_rows = X1.shape[0]
12+
X2_rows = X2.shape[0]
13+
X1_cols = X1.shape[1]
14+
for i in nb.prange(X1_rows):
15+
for j in range(X2_rows):
1616
d = 0.0
17-
for k in range(O):
17+
for k in range(X1_cols):
1818
tmp = X1[i, k] - X2[j, k]
1919
d += tmp * tmp
2020
D[i, j] = np.sqrt(d)

0 commit comments

Comments
 (0)