-
Notifications
You must be signed in to change notification settings - Fork 76
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
[FEATURE] TensorDictModule in_keys allowed as Dict[str, tuple | list] to enable multi use of a sample feature #1101
base: main
Are you sure you want to change the base?
Conversation
Hi @bachdj-px! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, thanks for this PR!
IIUC your change is to allow one element of the input tensordict to be used multiple times within the module inputs.
That would be a good addition.
I think the tests would need to be a bit more extensive. We also need to check this works with other TD modules, like ProbabilisticTensorDictModule
.
test/test_nn.py
Outdated
def test_tuple_input_keys(self): | ||
in_keys = {"1": "first", "2": ("second", "third")} | ||
fn = lambda x, y, z: x + y + z | ||
module = TensorDictModule(fn, in_keys=in_keys, out_keys=["out"]) | ||
|
||
kword_in_keys = sorted(zip(module._kwargs, module.in_keys)) | ||
assert kword_in_keys == [("first", "1"), ("second", "2"), ("third", "2")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really get this example:
the modue is not run, what would the input tensordict look like?
Could the example be a bit more extensive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, it's a good point - I updated that test. I also added another test that tests the integration of TensorDictModule within a ProbabilisticTensorDictSequential.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vmoens Thanks for your feedback.
Could you clarify how you would see the change with ProbabilisticTensorDictModule
? It seems to me that this feature will only impact TensorDictModule
. ProbabilisticTensorDictModule
inherits from TensorDictModuleBase
and is not affected. Also I don't see the use of implementing my suggested feature in ProbabilisticTensorDictModule
- its input have to be unique as far I see it.
Please let me know your thoughts
… flexible input key dispatching
0af7100
to
198404e
Compare
Description
See feature request #1099
Motivation and Context
Close issue #1099
Types of changes
Checklist