Skip to content

Commit c97a1a0

Browse files
chudur-budurDiptorup Deb
authored andcommitted
No need for testing __getitem__ and __setitem__, and fix test parameters
1 parent 81ec5ce commit c97a1a0

File tree

1 file changed

+18
-28
lines changed

1 file changed

+18
-28
lines changed

numba_dpex/tests/experimental/test_strided_dpnp_array_in_kernel.py

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ def change_values_2d(x, v):
7070
"""
7171
i = numba_dpex.get_global_id(0)
7272
j = numba_dpex.get_global_id(1)
73-
p = x[i, j] # getitem
74-
p = v
75-
x[i, j] = p # setitem
73+
x[i, j] = v
7674

7775

7876
def change_values_2d_func(a, p):
@@ -98,9 +96,7 @@ def change_values_3d(x, v):
9896
i = numba_dpex.get_global_id(0)
9997
j = numba_dpex.get_global_id(1)
10098
k = numba_dpex.get_global_id(2)
101-
p = x[i, j, k] # getitem
102-
p = v
103-
x[i, j, k] = p # setitem
99+
x[i, j, k] = v
104100

105101

106102
def change_values_3d_func(a, p):
@@ -116,13 +112,13 @@ def change_values_3d_func(a, p):
116112
a[i, j, k] = p
117113

118114

119-
@pytest.mark.parametrize("N", [8, 16, 32, 64, 128, 256, 512])
120115
@pytest.mark.parametrize("s", [1, 2, 3, 4, 5, 6, 7])
121-
def test_1d_strided_dpnp_array_in_kernel(N, s):
116+
def test_1d_strided_dpnp_array_in_kernel(s):
122117
"""
123118
Tests if we can correctly handle a strided 1d dpnp array
124119
inside dpex kernel.
125120
"""
121+
N = 256
126122
k = -3
127123

128124
t = np.arange(0, N, dtype=dpnp.int64)
@@ -140,13 +136,13 @@ def test_1d_strided_dpnp_array_in_kernel(N, s):
140136
assert np.all(dpnp.asnumpy(u) == t)
141137

142138

143-
@pytest.mark.parametrize("N", [8, 16, 32, 64, 128])
144139
@pytest.mark.parametrize("s", [2, 3, 4, 5])
145-
def test_multievel_1d_strided_dpnp_array_in_kernel(N, s):
140+
def test_multievel_1d_strided_dpnp_array_in_kernel(s):
146141
"""
147142
Tests if we can correctly handle a multilevel strided 1d dpnp array
148143
inside dpex kernel.
149144
"""
145+
N = 256
150146
k = -3
151147

152148
t = dpnp.arange(0, N, dtype=dpnp.int64)
@@ -166,16 +162,15 @@ def test_multievel_1d_strided_dpnp_array_in_kernel(N, s):
166162
assert np.all(dpnp.asnumpy(u) == t)
167163

168164

169-
@pytest.mark.parametrize("M", [3, 5, 7, 9])
170-
@pytest.mark.parametrize("N", [2, 4, 6, 8])
171-
@pytest.mark.parametrize("s1", [2, 4, 6])
172-
@pytest.mark.parametrize("s2", [1, 3, 5])
165+
@pytest.mark.parametrize("s1", [2, 4, 6, 8])
166+
@pytest.mark.parametrize("s2", [1, 3, 5, 7])
173167
@pytest.mark.parametrize("order", ["C", "F"])
174-
def test_2d_strided_dpnp_array_in_kernel(M, N, s1, s2, order):
168+
def test_2d_strided_dpnp_array_in_kernel(s1, s2, order):
175169
"""
176170
Tests if we can correctly handle a strided 2d dpnp array
177171
inside dpex kernel.
178172
"""
173+
M, N = 13, 31
179174
k = -3
180175

181176
t = np.arange(0, M * N, dtype=np.int64).reshape(M, N, order=order)
@@ -196,16 +191,15 @@ def test_2d_strided_dpnp_array_in_kernel(M, N, s1, s2, order):
196191
assert np.all(dpnp.asnumpy(u) == t)
197192

198193

199-
@pytest.mark.parametrize("M", [5, 7, 9, 11])
200-
@pytest.mark.parametrize("N", [4, 6, 8, 10])
201-
@pytest.mark.parametrize("s1", [2, 4, 6])
202-
@pytest.mark.parametrize("s2", [3, 5, 7])
194+
@pytest.mark.parametrize("s1", [2, 4, 6, 8])
195+
@pytest.mark.parametrize("s2", [3, 5, 7, 9])
203196
@pytest.mark.parametrize("order", ["C", "F"])
204-
def test_multilevel_2d_strided_dpnp_array_in_kernel(M, N, s1, s2, order):
197+
def test_multilevel_2d_strided_dpnp_array_in_kernel(s1, s2, order):
205198
"""
206199
Tests if we can correctly handle a multilevel strided 2d dpnp array
207200
inside dpex kernel.
208201
"""
202+
M, N = 13, 31
209203
k = -3
210204

211205
t = np.arange(0, M * N, dtype=np.int64).reshape(M, N, order=order)
@@ -228,18 +222,16 @@ def test_multilevel_2d_strided_dpnp_array_in_kernel(M, N, s1, s2, order):
228222
assert np.all(dpnp.asnumpy(u) == t)
229223

230224

231-
@pytest.mark.parametrize("M", [2, 3, 4])
232-
@pytest.mark.parametrize("N", [5, 6, 7])
233-
@pytest.mark.parametrize("K", [8, 9, 10])
234225
@pytest.mark.parametrize("s1", [1, 2, 3])
235226
@pytest.mark.parametrize("s2", [2, 3, 4])
236227
@pytest.mark.parametrize("s3", [3, 4, 5])
237228
@pytest.mark.parametrize("order", ["C", "F"])
238-
def test_3d_strided_dpnp_array_in_kernel(M, N, K, s1, s2, s3, order):
229+
def test_3d_strided_dpnp_array_in_kernel(s1, s2, s3, order):
239230
"""
240231
Tests if we can correctly handle a strided 3d dpnp array
241232
inside dpex kernel.
242233
"""
234+
M, N, K = 13, 31, 11
243235
k = -3
244236

245237
t = np.arange(0, M * N * K, dtype=np.int64).reshape((M, N, K), order=order)
@@ -260,18 +252,16 @@ def test_3d_strided_dpnp_array_in_kernel(M, N, K, s1, s2, s3, order):
260252
assert np.all(dpnp.asnumpy(u) == t)
261253

262254

263-
@pytest.mark.parametrize("M", [5, 6, 7])
264-
@pytest.mark.parametrize("N", [8, 9, 10])
265-
@pytest.mark.parametrize("K", [11, 12, 13])
266255
@pytest.mark.parametrize("s1", [2, 3, 4])
267256
@pytest.mark.parametrize("s2", [3, 4, 5])
268257
@pytest.mark.parametrize("s3", [4, 5, 6])
269258
@pytest.mark.parametrize("order", ["C", "F"])
270-
def test_multilevel_3d_strided_dpnp_array_in_kernel(M, N, K, s1, s2, s3, order):
259+
def test_multilevel_3d_strided_dpnp_array_in_kernel(s1, s2, s3, order):
271260
"""
272261
Tests if we can correctly handle a multilevel strided 3d dpnp array
273262
inside dpex kernel.
274263
"""
264+
M, N, K = 13, 31, 11
275265
k = -3
276266

277267
t = np.arange(0, M * N * K, dtype=np.int64).reshape((M, N, K), order=order)

0 commit comments

Comments
 (0)