Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add failing test case for multiple comparison test
  • Loading branch information
testhound committed Jul 7, 2022
commit da6016ad7cf509fee3637c73fafadd9a0d2c4315
20 changes: 19 additions & 1 deletion numba/cuda/tests/cudapy/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,23 @@ def test_multiple_float16_comparisons(self):
compiled[1, 1](ary, arg1, arg2, arg3)
self.assertTrue(ary[0])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to also test a case where the expected result is not true - a bug which manifests as multiple comparisons always results in True would not be caught by this test.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@testhound What are your thoughts on this comment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional test case added.


@skip_unless_cc_53
def test_multiple_float16_comparisons_false(self):
functions = (test_multiple_hcmp_1,
test_multiple_hcmp_2,
test_multiple_hcmp_3,
test_multiple_hcmp_4,
test_multiple_hcmp_5)
for fn in functions:
with self.subTest(fn=fn):
compiled = cuda.jit("void(b1[:], f2, f2, f2)")(fn)
ary = np.zeros(1, dtype=np.bool8)
arg1 = np.float16(2.)
arg2 = np.float16(3.)
arg3 = np.float16(1.)
compiled[1, 1](ary, arg1, arg2, arg3)
self.assertFalse(ary[0])

@skip_on_cudasim('Compilation unsupported in the simulator')
def test_fp16_comparison_ptx(self):
functions = (simple_fp16_gt, simple_fp16_ge,
Expand All @@ -183,12 +200,13 @@ def test_fp16_comparison_ptx(self):

@skip_on_cudasim('Compilation unsupported in the simulator')
def test_fp16_int8_comparison_ptx(self):
# Test that int8 can be safely converted to fp16
# in a comparison
functions = (simple_fp16_gt, simple_fp16_ge,
simple_fp16_lt, simple_fp16_le,
simple_fp16_eq, simple_fp16_ne)
ops = (operator.gt, operator.ge, operator.lt, operator.le,
operator.eq, operator.ne)
types_convert = (np.int8,)

opstring = {operator.gt:'setp.gt.f16',
operator.ge:'setp.ge.f16',
Expand Down