Skip to content

Conversation

@JohannesMessner
Copy link
Member

@JohannesMessner JohannesMessner commented Jun 20, 2023

Before this, DocVec equality checks that involved a tensor would fail by raising and Exception:

    class Text(BaseDoc):
        tens: TorchTensor

    da = DocVec[Text](
        [Text(tens=[1, 2, 3, 4]) for _ in range(10)], tensor_type=TorchTensor
    )
    da2 = DocVec[Text](
        [Text(tens=[1, 2, 3, 4]) for _ in range(10)], tensor_type=TorchTensor
    )
    assert da == da2  # would raise
RuntimeError: Boolean value of Tensor with more than one value is ambiguous

This is because checks of the form tens1 == tens2 return a boolean tensor, not a single bool, which breaks an assumption in the previous implementation.

This PR solved that by introducing a helper function that let's us compare tensors and get a single bool as output.

Signed-off-by: Johannes Messner <messnerjo@gmail.com>
Signed-off-by: Johannes Messner <messnerjo@gmail.com>
Signed-off-by: Johannes Messner <messnerjo@gmail.com>
Signed-off-by: Johannes Messner <messnerjo@gmail.com>
Signed-off-by: Johannes Messner <messnerjo@gmail.com>
Signed-off-by: Johannes Messner <messnerjo@gmail.com>
@github-actions github-actions bot added size/m and removed size/s labels Jun 20, 2023
Signed-off-by: Johannes Messner <messnerjo@gmail.com>
Signed-off-by: Johannes Messner <messnerjo@gmail.com>
@JohannesMessner JohannesMessner marked this pull request as ready for review June 20, 2023 09:46
Signed-off-by: Johannes Messner <messnerjo@gmail.com>
Signed-off-by: Johannes Messner <messnerjo@gmail.com>
@JohannesMessner JohannesMessner requested a review from samsja June 20, 2023 10:42
@github-actions
Copy link

📝 Docs are deployed on https://ft-fix-docvec-equality--jina-docs.netlify.app 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants