-
Notifications
You must be signed in to change notification settings - Fork 7.1k
[feature request] Derive all transforms classes from nn.Module? #5236
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
Comments
@vadimkantorov You are right to say that. There is a handful of them that don't derive from it and the reason is mainly that they might not be JIT-scriptable and that might break BC. I think there is a lot of merit to make all classes inherit from nn.Module. The new Transforms API is the place to address it (see here). |
T.Compose probably is scriptable, the rest probably too if we migrate from |
@vadimkantorov have you seen discussion from this PR (#2645), why classes like |
Thanks for the reference! I tried to understand why deriving from nn.Sequential would existing some code, but I couldn't since the discussion is quite dispersed there. What are concrete examples you had in mind in that PR? Is it because you worry of the code that's directly modifying internal
|
First point is that we can not do basic thing like: Next, if we wrap these custom functions by something then user can lose the access to its possible attributes etc. Imagine, |
Thanks for explaining! Now I see! My proposal would be:
|
Maybe RandomChoice is more safe for conversion to nn.ModuleList, as it's not as old class |
Proto transforms now all derive from nn.Module |
Is there now a nn.Sequential/nn.ModuleList-derived TupleSequential? Or what is the format of instances in proto? Are they now all dicts? Is there now also a nn.Module-derived T.Lambda wrapper? |
🚀 The feature
Currently it's already the case for most transform classes, except T.Compose / T.RandomChoice (these could probably be derived from nn.Sequential / nn.ModuleList). This also would not break any compat, and improve consistency and composability (sometimes only nn.Modules are accepted as parts of other existing models)
Motivation, pitch
N/A
Alternatives
No response
Additional context
No response
cc @vfdev-5 @datumbox @bjuncek
The text was updated successfully, but these errors were encountered: