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

[Torch] Support bincount and scatter_add ops #6740

Merged
merged 4 commits into from
Oct 24, 2020

Conversation

masahi
Copy link
Member

@masahi masahi commented Oct 23, 2020

Add numpy style bincount op converter by combinations of existing ops.
https://pytorch.org/docs/stable/generated/torch.bincount.html

This is a part of supporting hummingbird project. Also add a scatter_add op conversion, as requested.

I hope performance would not be too bad, so that we don't have to implement a native bincount op.

please review @siju-samuel @t-vi
cc @interesaaat

Copy link
Contributor

@t-vi t-vi left a comment

Choose a reason for hiding this comment

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

I think the type for bincount would be good to improve, otherwise LGTM. Thank you @masahi

python/tvm/relay/frontend/pytorch.py Outdated Show resolved Hide resolved
tests/python/frontend/pytorch/test_forward.py Show resolved Hide resolved
Copy link
Contributor

@t-vi t-vi left a comment

Choose a reason for hiding this comment

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

Thank you @masahi.

@tqchen tqchen merged commit efe3a79 into apache:main Oct 24, 2020
@tqchen
Copy link
Member

tqchen commented Oct 24, 2020

Thanks @masahi for contributing! Thanks @t-vi for reviewing!

trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Oct 29, 2020
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Dec 2, 2020
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Dec 4, 2020
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Dec 4, 2020
@apivovarov
Copy link
Contributor

apivovarov commented Sep 7, 2022

Does the following code in _bincount() require relay.vm.compile()? Because _op.zeros() is called for a shape which is not known at the compilation

data = inputs[0]
maximum = _op.max(data)
dim = maximum + _expr.const(1, dtype="int64")
counts = _op.zeros(_op.reshape(dim, [1]), out_dtype)

@masahi
Copy link
Member Author

masahi commented Sep 7, 2022

Yes, bincount requires VM compile.

@apivovarov
Copy link
Contributor

apivovarov commented Sep 9, 2022

I'm working on adding TF bincount support. I found thattf.bincount internally uses tf.shape. But looks like tf.shape is not compatible with relay.vm. Instead of determining the shape at the runtime vm.compiler just creates new parameter which should be provided by user when calling vm.run(). https://discuss.tvm.apache.org/t/tf-shape-and-relay-vm-strange-result/13505

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants