Skip to content

Commit 59fb1b5

Browse files
Improved performance of floor/ceil/trunc tests
(dev_dpctl) opavlyk@opavlyk-mobl:~/repos/dpctl$ python -m pytest --durations=6 dpctl/tests/elementwise/test_floor_ceil_trunc.py ============================================================================ test session starts ============================================================================ platform linux -- Python 3.9.12, pytest-7.1.2, pluggy-1.0.0 rootdir: /home/opavlyk/repos/dpctl plugins: metadata-2.0.4, json-report-1.5.0, cov-4.0.0, hypothesis-6.75.3, scikit-learn-1.3.dev0 collected 186 items dpctl/tests/elementwise/test_floor_ceil_trunc.py ..............................sss.......................................sss.................................sss..... [ 62%] .........................sss..............................sss......sss [100%] ============================================================================ slowest 6 durations ============================================================================ 0.35s call dpctl/tests/elementwise/test_floor_ceil_trunc.py::test_floor_ceil_trunc_out_type[i1-UnaryElementwiseFunc0] 0.15s call dpctl/tests/elementwise/test_floor_ceil_trunc.py::test_floor_ceil_trunc_order[u8-trunc-UnaryElementwiseFunc] 0.14s call dpctl/tests/elementwise/test_floor_ceil_trunc.py::test_floor_ceil_trunc_order[u4-ceil-UnaryElementwiseFunc] 0.14s call dpctl/tests/elementwise/test_floor_ceil_trunc.py::test_floor_ceil_trunc_order[f2-floor-UnaryElementwiseFunc] 0.14s call dpctl/tests/elementwise/test_floor_ceil_trunc.py::test_floor_ceil_trunc_order[f4-trunc-UnaryElementwiseFunc] 0.14s call dpctl/tests/elementwise/test_floor_ceil_trunc.py::test_floor_ceil_trunc_order[u1-floor-UnaryElementwiseFunc] ====================================================================== 168 passed, 18 skipped in 9.74s ======================================================================
1 parent 72231d0 commit 59fb1b5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

dpctl/tests/elementwise/test_floor_ceil_trunc.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_floor_ceil_trunc_usm_type(np_call, dpt_call, usm_type):
5757
q = get_queue_or_skip()
5858

5959
arg_dt = np.dtype("f4")
60-
input_shape = (10, 10, 10, 10)
60+
input_shape = (2, 2, 2, 10)
6161
X = dpt.empty(input_shape, dtype=arg_dt, usm_type=usm_type, sycl_queue=q)
6262
X[..., 0::2] = -0.4
6363
X[..., 1::2] = 0.7
@@ -80,16 +80,16 @@ def test_floor_ceil_trunc_order(np_call, dpt_call, dtype):
8080
skip_if_dtype_not_supported(dtype, q)
8181

8282
arg_dt = np.dtype(dtype)
83-
input_shape = (10, 10, 10, 10)
83+
input_shape = (4, 4, 4, 4)
8484
X = dpt.empty(input_shape, dtype=arg_dt, sycl_queue=q)
8585
X[..., 0::2] = -0.4
8686
X[..., 1::2] = 0.7
8787

88-
for ord in ["C", "F", "A", "K"]:
89-
for perms in itertools.permutations(range(4)):
90-
U = dpt.permute_dims(X[:, ::-1, ::-1, :], perms)
88+
for perms in itertools.permutations(range(4)):
89+
U = dpt.permute_dims(X[:, ::-1, ::-1, :], perms)
90+
expected_Y = np_call(dpt.asnumpy(U))
91+
for ord in ["C", "F", "A", "K"]:
9192
Y = dpt_call(U, order=ord)
92-
expected_Y = np_call(dpt.asnumpy(U))
9393
assert_allclose(dpt.asnumpy(Y), expected_Y)
9494

9595

@@ -180,7 +180,7 @@ def test_floor_ceil_trunc_strided(np_call, dpt_call, dtype):
180180

181181
np.random.seed(42)
182182
strides = np.array([-4, -3, -2, -1, 1, 2, 3, 4])
183-
sizes = np.arange(2, 100)
183+
sizes = [2, 4, 6, 8, 24, 32, 72]
184184

185185
for ii in sizes:
186186
Xnp = np.random.uniform(low=-99.9, high=99.9, size=ii)

0 commit comments

Comments
 (0)