Skip to content

Commit

Permalink
Unit tests for Range/NdRange constructor overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
Diptorup Deb committed Sep 29, 2023
1 parent 8c58224 commit f3b7d26
Showing 1 changed file with 45 additions and 0 deletions.
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

0 comments on commit f3b7d26

Please sign in to comment.