Skip to content
New issue

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

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

Already on GitHub? # to your account

[Feature Request] Support propagation of in-place modifications to masked tensordict to the parent tensordict. #298

Open
1 task done
benoitdescamps opened this issue Jul 19, 2022 · 0 comments · May be fixed by pytorch/tensordict#132
Assignees
Labels
enhancement New feature or request

Comments

@benoitdescamps
Copy link
Contributor

benoitdescamps commented Jul 19, 2022

Motivation

For tensors, the following apply,

x = torch.randn(3,4)
mask = [True, False, True]
y = torch.randn(2,4)
x[mask] = y

torch.testing.assert_allclose(x[mask],y)

on the other hand for tensordict

    td = TensorDict({"a": torch.randn(3, 4, 2), "b": torch.randn(3, 4)}, [3, 4])

    mask = torch.tensor([True, False, True])
    x = torch.randn(2, 4, 2)
    td[mask]["a"] = x
    torch.testing.assert_allclose(td[mask]["a"], x)

returns error AssertionError: Tensor-likes are not close!

Solution

Instead of return a new Tensordict using mask-select, we can return instead a SubTensorDict.

Checklist

  • I have checked that there is no similar issue in the repo (required)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants