mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-06-24 02:14:17 +00:00
intiger div mod fix
This commit is contained in:
parent
ceb9d94eab
commit
d5d2f201bf
1 changed files with 5 additions and 1 deletions
|
|
@ -3471,7 +3471,11 @@ class Tensor(SimpleMathTrait):
|
|||
```
|
||||
"""
|
||||
numerator, denominator = self._broadcasted(x, reverse)
|
||||
d = numerator.cast(least_upper_float(numerator.dtype)) * denominator.cast(least_upper_float(denominator.dtype)).reciprocal()
|
||||
if dtypes.is_int(numerator.dtype) or dtypes.is_int(denominator.dtype):
|
||||
d = numerator.cast(dtypes.float64) * denominator.cast(dtypes.float64).reciprocal()
|
||||
d = d.cast(dtypes.float32)
|
||||
else:
|
||||
d = numerator * denominator.reciprocal()
|
||||
output_dtype = numerator.dtype if dtypes.is_int(numerator.dtype) else d.dtype
|
||||
if rounding_mode == "trunc": return d.trunc().cast(output_dtype)
|
||||
if rounding_mode == "floor": return d.floor().cast(output_dtype)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue