Skip to content

Commit 57c0d51

Browse files
author
Diptorup Deb
committed
Add unbox box tests
1 parent f0526eb commit 57c0d51

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-FileCopyrightText: 2023 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# SPDX-FileCopyrightText: 2023 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
import pytest
6+
7+
from numba_dpex import NdRange, Range, dpjit
8+
9+
ranges = [(10,), (10, 10), (10, 10, 10)]
10+
11+
12+
@pytest.mark.parametrize("r", ranges)
13+
def test_range_unbox_box(r):
14+
@dpjit
15+
def _tester(r):
16+
return r
17+
18+
r_in = Range(*r)
19+
r_out = _tester(r_in)
20+
21+
assert r_out.ndim == r_in.ndim
22+
assert r_out.dim0 == r_in.dim0
23+
assert r_out.dim1 == r_in.dim1
24+
assert r_out.dim2 == r_in.dim2
25+
26+
27+
@pytest.mark.parametrize("r", ranges)
28+
def test_ndrange_unbox_box(r):
29+
@dpjit
30+
def _tester(r):
31+
return r
32+
33+
gr = lr = Range(*r)
34+
r_in = NdRange(gr, lr)
35+
r_out = _tester(r_in)
36+
37+
assert r_out.global_range.ndim == r_in.global_range.ndim
38+
assert r_out.local_range.ndim == r_in.local_range.ndim
39+
assert r_out.global_range.dim0 == r_in.global_range.dim0
40+
assert r_out.global_range.dim1 == r_in.global_range.dim1
41+
assert r_out.global_range.dim2 == r_in.global_range.dim2
42+
assert r_out.local_range.dim0 == r_in.local_range.dim0
43+
assert r_out.local_range.dim1 == r_in.local_range.dim1
44+
assert r_out.local_range.dim2 == r_in.local_range.dim2

0 commit comments

Comments
 (0)