Skip to content
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

remove duplicated offsets assignments #65

Merged
merged 3 commits into from
Feb 4, 2022
Merged

Conversation

wyli
Copy link
Contributor

@wyli wyli commented Jan 22, 2022

looks like the offsets are computed twice...

@wyli wyli marked this pull request as ready for review January 22, 2022 15:24
@balbasty
Copy link
Owner

balbasty commented Feb 3, 2022

Hi Wenqi,

Sorry, I'd missed this PR. Many thanks for raising this!

The only concern I have is that in grid_pull_backward, we have both do_push = true and do_grad = true.
I am afraid that if we compute offsets only once at the beginning, the push pass will use wrong offsets, since we'll enter in the first branch of the if/else statement. What do you think?

Currently, it goes:

- if (do_grad || do_pull || do_sgrad) { compute source offsets } else {compute out offsets }
- if (do_grad) { ... }
- if (do_pull) ... else if (do_sgrad) ... else if (do_push) ... else if (do_count) ...

I guess a solution would be to move the push/count offsets branch after if(do_grad):

- if (do_grad || do_pull || do_sgrad) { compute source offsets }
- if (do_grad) { ... }
- if (do_push || do_count) {compute out offsets }
- if (do_pull) ... else if (do_sgrad) ... else if (do_push) ... else if (do_count) ...

@wyli
Copy link
Contributor Author

wyli commented Feb 3, 2022

thanks @balbasty, I've updated the PR based on your suggestion.

Signed-off-by: Wenqi Li <wenqil@nvidia.com>
@balbasty
Copy link
Owner

balbasty commented Feb 3, 2022

Thanks!
This is minor, but you'll see that we now have a bunch of compilation warnings about uninitialized offsets.
We cover all cases so this won't be an issue at runtime. In MONAI, you may want to dummy-initialize these offsets to avoid warnings (I can take care of it here).
Thanks again :-)

Signed-off-by: Wenqi Li <wenqil@nvidia.com>
@wyli
Copy link
Contributor Author

wyli commented Feb 3, 2022

I guess I managed to mute the warning, I'll update MONAI for the same... @balbasty many thanks for the review!

@wyli wyli mentioned this pull request Feb 3, 2022
7 tasks
@balbasty balbasty merged commit 5a8448b into balbasty:master Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants