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

support equal and not_equal in topi #1373

Merged
merged 9 commits into from
Jul 4, 2018
Merged

support equal and not_equal in topi #1373

merged 9 commits into from
Jul 4, 2018

Conversation

liangfu
Copy link
Member

@liangfu liangfu commented Jul 2, 2018

Add support to count_nonzero in topi, works well for llvm. However, current cuda schudule for reduction don't work well with the proposed operator.

@tqchen
Copy link
Member

tqchen commented Jul 3, 2018

Can we compose this operator by having a equal operator then followed by a sum, if so, we should support equal and instead of this function instead

@tqchen tqchen added the status: need update need update based on feedbacks label Jul 3, 2018
@liangfu
Copy link
Member Author

liangfu commented Jul 3, 2018

I gave it a try, and test cases has been added.

@tqchen
Copy link
Member

tqchen commented Jul 3, 2018

what i mean instead is that we should not support count nonzero function, but instead support topi.equal and topi.not_equal, so we can compose count nonzero by equal then astype(int32) and the sum

@liangfu liangfu closed this Jul 3, 2018
@liangfu
Copy link
Member Author

liangfu commented Jul 3, 2018

i could do that, but my original intention is to estimate buffer size for topi.nonzero, which could be useful for converting dense matrices into sparse ones.

@liangfu liangfu reopened this Jul 3, 2018
Conflicts:
	topi/tests/python/test_topi_reduce.py
@tqchen
Copy link
Member

tqchen commented Jul 4, 2018

I agree, nevertheless these can be done in the composed fashion so we can express the same thing but much more flexibly

@liangfu
Copy link
Member Author

liangfu commented Jul 4, 2018

Okay, here is another update.
I think it's fine if we don't need count_nonzero in topi, but how about a topi.nonzero?
It could be a progressive step towards an introduction to sparse tensor.

@liangfu liangfu changed the title support count_nonzero in topi support equal and not_equal in topi Jul 4, 2018
@@ -79,6 +79,9 @@ def check_device(device):
out_npy = fnumpy(lhs_npy, rhs_npy)
out_nd = tvm.nd.array(np.empty(out_npy.shape).astype(C.dtype), ctx)
foo(lhs_nd, rhs_nd, out_nd)
if fnumpy==np.equal:
Copy link
Member

Choose a reason for hiding this comment

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

remove the print here

@tqchen
Copy link
Member

tqchen commented Jul 4, 2018

I agree that topi.nonzero is useful and can be supported in a separate PR. although it is unclear if we need additional gather primitive/hybrid script to support this operation

@tqchen tqchen added status: accepted and removed status: need update need update based on feedbacks labels Jul 4, 2018
@tqchen tqchen merged commit 05dae3f into apache:master Jul 4, 2018
tqchen pushed a commit to tqchen/tvm that referenced this pull request Jul 6, 2018
mnuyens pushed a commit to mnuyens/tvm that referenced this pull request Jul 10, 2018
sergei-mironov pushed a commit to sergei-mironov/tvm that referenced this pull request Aug 8, 2018
@liangfu liangfu deleted the patch-3 branch April 14, 2020 14:25
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.

None yet

2 participants