mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-04-29 03:00:14 -04:00
remu bugfix with -0.0 negation (#10082)
This commit is contained in:
@@ -56,7 +56,7 @@ where
|
||||
fn negate(&self, pos: usize, modifier: usize) -> T {
|
||||
match (modifier >> pos) & 1 {
|
||||
1 => match self.is_zero() {
|
||||
true => *self,
|
||||
true => T::zero(),
|
||||
false => -*self,
|
||||
},
|
||||
_ => *self,
|
||||
@@ -123,6 +123,7 @@ mod tests {
|
||||
assert_eq!(0.3_f32.negate(0, 0b110), 0.3_f32);
|
||||
assert_eq!(0.3_f32.negate(1, 0b010), -0.3_f32);
|
||||
assert_eq!(0.0_f32.negate(0, 0b001).to_bits(), 0);
|
||||
assert_eq!((-0.0_f32).negate(0, 0b001).to_bits(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -3019,7 +3019,7 @@ mod test_vop3 {
|
||||
|
||||
#[test]
|
||||
fn test_v_cndmask_b32_e64_neg() {
|
||||
[[0.0f32, 0.0], [1.0f32, -1.0], [-1.0f32, 1.0]].iter().for_each(|[input, ret]| {
|
||||
[[0.0f32, 0.0], [-0.0f32, 0.0], [1.0f32, -1.0], [-1.0f32, 1.0]].iter().for_each(|[input, ret]| {
|
||||
let mut thread = _helper_test_thread();
|
||||
thread.scalar_reg[0] = false as u32;
|
||||
thread.vec_reg[3] = input.to_bits();
|
||||
|
||||
Reference in New Issue
Block a user