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

Gather: broadcast + expand #83

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

justinchiu
Copy link
Contributor

@justinchiu justinchiu commented Feb 25, 2019

Adds broadcasting support for gather by adding dimensions (unsqueezing through _force_order using an overlapping order) and expanding.

# Gather will move "b" and "c" to the front for t and index respectively
# so we must force the order in order to compare to the original
# torch.gather.
ntensor = ntorch.gather(t, "b", index, "c")._force_order(("a", "c"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a good unit test. It shouldn't call any _ functions.

Copy link
Contributor Author

@justinchiu justinchiu Feb 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High level question: Since we don't assume any ordering, is the right approach to try all permutations of the output ntensor and pass if any of them succeed (equal base)? Or should wer try to keep the underlying order the same as torch.* (although this may be unclear for ntorch.gather since broadcasting isn't defined in torch.gather).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the ntorch.equal function will now do this automatically. But either way isn't the function you want just .transpose? More importantly does this test prove to me that your change works?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks. I agree that the unit test doesn't test anything, but I wanted to ask about how to compare first. I can write a better test.

@srush
Copy link
Contributor

srush commented Mar 1, 2019

Any updates?

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