-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit tests for Range/NdRange constructir overloads
- Loading branch information
Diptorup Deb
committed
Sep 29, 2023
1 parent
8c58224
commit 69330d8
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
numba_dpex/tests/core/types/range_types/test_constructor_overloads.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# SPDX-FileCopyrightText: 2023 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import pytest | ||
|
||
from numba_dpex import NdRange, Range, dpjit | ||
|
||
ranges = [(10,), (10, 10), (10, 10, 10)] | ||
|
||
|
||
@pytest.mark.parametrize("r", ranges) | ||
def test_range_ctor(r): | ||
@dpjit | ||
def _tester(r): | ||
return Range(*r) | ||
|
||
r_expected = Range(*r) | ||
r_out = _tester(r) | ||
|
||
assert r_out.ndim == r_expected.ndim | ||
assert r_out.dim0 == r_expected.dim0 | ||
assert r_out.dim1 == r_expected.dim1 | ||
assert r_out.dim2 == r_expected.dim2 | ||
|
||
|
||
@pytest.mark.parametrize("r", ranges) | ||
def test_ndrange_unbox_box(r): | ||
@dpjit | ||
def _tester(r): | ||
gr = lr = Range(*r) | ||
return NdRange(gr, lr) | ||
|
||
gr = lr = Range(*r) | ||
r_expected = NdRange(gr, lr) | ||
r_out = _tester(r) | ||
|
||
assert r_out.global_range.ndim == r_expected.global_range.ndim | ||
assert r_out.local_range.ndim == r_expected.local_range.ndim | ||
assert r_out.global_range.dim0 == r_expected.global_range.dim0 | ||
assert r_out.global_range.dim1 == r_expected.global_range.dim1 | ||
assert r_out.global_range.dim2 == r_expected.global_range.dim2 | ||
assert r_out.local_range.dim0 == r_expected.local_range.dim0 | ||
assert r_out.local_range.dim1 == r_expected.local_range.dim1 | ||
assert r_out.local_range.dim2 == r_expected.local_range.dim2 |