Skip to content

Commit e39a62c

Browse files
janselpytorchmergebot
authored andcommitted
Fix warnings in triton_helpers.py (pytorch#159719)
``` /home/jansel/pytorch/torch/_inductor/runtime/triton_helpers.py:152: UserWarning: Logical operators 'and' and 'or' are deprecated for non-scalar tensors; please use '&' or '|' instead equal |= a_isnan and b_isnan ``` Pull Request resolved: pytorch#159719 Approved by: https://github.com/Skylion007
1 parent 978e3a9 commit e39a62c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

torch/_inductor/runtime/triton_helpers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def div_floor_integer(a, b):
8080
def remainder_integer(a, b):
8181
# NOTE: a % b matches C division, not floor division
8282
remainder = a % b
83-
return tl.where(remainder != 0 and ((a < 0) != (b < 0)), remainder + b, remainder)
83+
return tl.where((remainder != 0) & ((a < 0) != (b < 0)), remainder + b, remainder)
8484

8585

8686
@triton.jit
@@ -131,9 +131,9 @@ def minimum_with_index(a_value, a_index, b_value, b_index):
131131
if is_floating(a_value):
132132
a_isnan = a_value != a_value
133133
b_isnan = b_value != b_value
134-
mask |= a_isnan and not b_isnan
134+
mask |= a_isnan & (not b_isnan)
135135
# Consider NaNs as equal
136-
equal |= a_isnan and b_isnan
136+
equal |= a_isnan & b_isnan
137137

138138
# Prefer lowest index if values are equal
139139
mask |= equal & (a_index < b_index)
@@ -147,9 +147,9 @@ def maximum_with_index(a_value, a_index, b_value, b_index):
147147
if is_floating(a_value):
148148
a_isnan = a_value != a_value
149149
b_isnan = b_value != b_value
150-
mask |= a_isnan and not b_isnan
150+
mask |= a_isnan & (not b_isnan)
151151
# Consider NaNs as equal
152-
equal |= a_isnan and b_isnan
152+
equal |= a_isnan & b_isnan
153153

154154
# Prefer lowest index if values are equal
155155
mask |= equal & (a_index < b_index)

0 commit comments

Comments
 (0)