Skip to content

remove duplicated offsets assignments#65

Merged
balbasty merged 3 commits intobalbasty:masterfrom
wyli:patch-2
Feb 4, 2022
Merged

remove duplicated offsets assignments#65
balbasty merged 3 commits intobalbasty:masterfrom
wyli:patch-2

Conversation

@wyli
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

wyli commented Feb 3, 2022

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

@balbasty
Copy link
Copy Markdown
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 :-)

@wyli
Copy link
Copy Markdown
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