Skip to content

Commit

Permalink
[Frontend] Improve the error when doing tensor[uint32] * -3 (#4667)
Browse files Browse the repository at this point in the history
as per title
  • Loading branch information
lezcano authored Sep 7, 2024
1 parent 3104056 commit 0557336
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/triton/language/semantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ def binary_op_type_checking_impl(lhs: tl.tensor | numbers.Number, rhs: tl.tensor
check_ptr_type_impl(rhs_sca_ty, lhs_sca_ty, allow_rhs_ptr)
if arithmetic_check and not lhs_sca_ty.is_ptr() and not rhs_sca_ty.is_ptr():
ret_sca_ty = computation_type_impl(lhs_sca_ty, lhs_is_scalar, rhs_sca_ty, rhs_is_scalar, div_or_mod)
if (lhs_is_scalar and lhs_scalar < 0 and ret_sca_ty.is_int_unsigned()
or rhs_is_scalar and rhs_scalar < 0 and ret_sca_ty.is_int_unsigned()):
raise ValueError("Cannot perform a binary operation between an unsigned tensor and a negative scalar. "
"Perform a explicit cast on one of them.")
lhs = full(
(), lhs_scalar, dtype=ret_sca_ty, builder=builder) if lhs_is_scalar else cast(lhs, ret_sca_ty, builder)
rhs = full(
Expand Down

0 comments on commit 0557336

Please sign in to comment.