-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Conversation
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 |
I gave it a try, and test cases has been added. |
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 |
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. |
Conflicts: topi/tests/python/test_topi_reduce.py
I agree, nevertheless these can be done in the composed fashion so we can express the same thing but much more flexibly |
Okay, here is another update. |
@@ -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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the print here
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 |
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.