tch-rs icon indicating copy to clipboard operation
tch-rs copied to clipboard

Tensor "equal" comparison is incorrect in version 0.7.2

Open dbsxdbsx opened this issue 3 years ago • 0 comments

On win10, torch 1.11 and tch-rs 0.7.2:

 let tensor_to_transform = Tensor::try_from(array![
            [0.2f32, 1.0, 0.0],
            [0.0, 0.9, -0.14],
            [0.0, -0.2, 1.0]
        ])
        .unwrap();

        let mut tensor_to_transform_2 = Tensor::try_from(array![
            [0.2f32, 1.0, 0.0],
            [0.0, 0.9, -0.14],
            [0.0, -0.2, 1.0]
        ])
        .unwrap();

        tensor_to_transform_2 = tensor_to_transform_2 - 2;
        tensor_to_transform_2 = tensor_to_transform_2 + 2;

        // let  x = &tensor_to_transform.equal(&tensor_to_transform_2);
        // let y = bool::from(Tensor::all(
        //     &tensor_to_transform.eq_tensor(&tensor_to_transform_2),
        // ));
        // let z = bool::from(Tensor::all(
        //     &tensor_to_transform.eq_tensor_out(&tensor_to_transform, &tensor_to_transform_2),
        // ));

        let w = bool::from(Tensor::all(
            &tensor_to_transform.eq_tensor(&tensor_to_transform_2),
        ));

Here,x,y,z,w are all false, which should be true.

By the way, what does eq_tensor_out used for?

dbsxdbsx avatar Aug 17 '22 05:08 dbsxdbsx