Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remainder method not working correctly #2787

Open
akshitgaur2005 opened this issue Feb 8, 2025 · 3 comments
Open

Remainder method not working correctly #2787

akshitgaur2005 opened this issue Feb 8, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@akshitgaur2005
Copy link
Contributor

Describe the bug
Remainder sometimes giving wrong output

To Reproduce

let lhs: Tensor<MyBackend, 1> =
        Tensor::from_floats([-1.4843, 1.1350, -2.1563, 1.0862, 0.5034, 3.6587], &device);
    let rhs: Tensor<MyBackend, 1> =
        Tensor::from_floats([-1.4843, 1.1350, -2.1563, 1.0862, 0.5034, 3.6587], &device);

    let output = lhs.remainder(rhs);
    // Output: [-1.4843, 0.0, 0.0, 0.0, 0.5034, 0.0]

Expected behavior

let expected = TensorData::from([0., 0., 0., 0., 0., 0.]);
@laggui
Copy link
Member

laggui commented Feb 10, 2025

So this unit test is failing on your machine?

#[test]
fn should_have_no_remainder() {
let device = Default::default();
let lhs = Tensor::<TestBackend, 1>::from_data(
TensorData::from([-1.4843, 1.1350, -2.1563, 1.0862, 0.5034, 3.6587]),
&device,
);
let rhs = Tensor::<TestBackend, 1>::from_data(
TensorData::from([1.4843, 1.1350, 2.1563, 1.0862, 0.5034, 3.6587]),
&device,
);
let output = lhs.remainder(rhs);
let expected = TensorData::from([-0., 0., -0., 0., 0., 0.]);
output.into_data().assert_approx_eq(&expected, 3);
}

For what backend? If it's a GPU backend, what GPU do you have?

@akshitgaur2005
Copy link
Contributor Author

Yes, atleast in the example that I used, Wgpu. GTX 1650

@maxtremblay
Copy link
Contributor

Same here on Wgpu with a Nvidia GeForce RTX 4060. I don't know what is special with the value 0.5034.

@akshitgaur2005 akshitgaur2005 mentioned this issue Mar 1, 2025
2 tasks
@antimora antimora added the bug Something isn't working label Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants