-
Notifications
You must be signed in to change notification settings - Fork 7.1k
replace query_recursively with pytree implementation #6434
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
Conversation
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 @pmeier
@@ -361,7 +352,7 @@ def __init__( | |||
def forward(self, *inputs: Any) -> Any: | |||
sample = inputs if len(inputs) > 1 else inputs[0] | |||
|
|||
id, image = self._extract_image(sample) | |||
sample_flat, sample_spec, idx_flat, image = self._flatten(sample) |
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 appologize if I'm missing the context, If I understand correctly the code, you fetch the first image from sample with _flatten
and below in the code the image is transformed and written back to sample.
Why do we transform only the first image ?
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.
More generally question, why can't we restructure the implementation such that we use forward
to inspect sample and ensure that only images (and/or only one image in sample) go further into _transform
. In _transform
we do the necessary AA ops. What do you think ?
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.
LGTM, thanks!
Summary: * replace query_recursively with pytree implementation * simplify Reviewed By: datumbox Differential Revision: D39013677 fbshipit-source-id: ac63607513bb5457ead65e798a8704c6341c5c50 Co-authored-by: vfdev <[email protected]>
Addresses #6408 (comment).