Skip to content

Commit 2181d94

Browse files
leofangchainer-ci
authored andcommitted
Merge pull request #10003 from seberg/weak-old-fusion
BUG: Fix weak integer comparison logic in old fusion path
1 parent 6de78f4 commit 2181d94

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎cupy/_core/fusion.pyx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,10 +556,10 @@ class _FusionHistory(object):
556556
raise ValueError('non-broadcastable output operand')
557557

558558
# Typecast and add an operation
559-
in_sctypes = tuple([a.dtype.type for a in in_vars])
559+
in_dtypes = tuple([a.dtype for a in in_vars])
560560
weaks = tuple([getattr(a, 'is_weak', False) for a in in_vars])
561561

562-
op = ufunc._ops._guess_routine_from_in_types(in_sctypes, weaks)
562+
op = ufunc._ops._guess_routine_from_in_types(in_dtypes, weaks)
563563

564564
if op is not None:
565565
in_dtypes = [numpy.dtype(t) for t in op.in_types]

‎tests/cupy_tests/core_tests/fusion_tests/test_misc.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,3 +465,20 @@ def f(x):
465465
x = testing.shaped_random((3, 3), cupy, cupy.int64, seed=0)
466466
with pytest.raises(TypeError, match="Python scalar"):
467467
f(x)
468+
469+
470+
class TestOldFusionExplicit:
471+
def test_weak_int(self):
472+
count = 0
473+
474+
@cupy.fuse()
475+
def f(x, y):
476+
nonlocal count
477+
count += 1
478+
return cupy.equal(x, 1)
479+
480+
x = cupy.arange(10)
481+
fuse = cupy._core.fusion.Fusion(f, 'test_weak_int')
482+
fuse(x, 1)
483+
# Check that fusion only called f once (i.e. old fusion)
484+
assert count == 1

0 commit comments

Comments
 (0)