Commit
…on_ops (#1064) * [skip ci] add any and all operators to Matrix * [skip ci] add test * [skip ci] move __ti_int__ and __ti_float__ to common_ops * [skip ci] overload builtin any and all ops * [skip ci] enforce code format * [skip ci] update doc Co-authored-by: Kenneth Lozes <klozes@system76-pc.localdomain> Co-authored-by: Taichi Gardener <taichigardener@gmail.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -482,6 +482,20 @@ def min(self): | |||
ret = impl.min(ret, self.entries[i]) | ||||
return ret | ||||
|
||||
def any(self): | ||||
import taichi as ti | ||||
ret = (self.entries[0] != ti.expr_init(0)) | ||||
for i in range(1, len(self.entries)): | ||||
ret = ret + (self.entries[i] != ti.expr_init(0)) | ||||
return -(ret < ti.expr_init(0)) | ||||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
yuanming-hu
Member
|
llvm_val[stmt] = builder->CreateSExt(cmp, llvm_type(DataType::i32)); |
This comment has been minimized.
This comment has been minimized.
Sorry, something went wrong.
yuanming-hu
May 29, 2020
Member
Yes, I used signed extension instead of unsigned to make it consistent with future vectorized versions.
I think the source of all evil is that cmp
in llvm gives you i1
but we don't support that in Taichi.
This comment has been minimized.
This comment has been minimized.
Sorry, something went wrong.
archibate
May 29, 2020
•
edited
Collaborator
edited
Interesting, currently OpenGL also return 1 on true, but I didn't see any error in test yet.And I failed the test on OpenGL too.
This comment has been minimized.
This comment has been minimized.
Sorry, something went wrong.
k-ye
May 29, 2020
Member
Interesting, currently OpenGL also return 1 on true, but I didn't see any error in test yet.
Indeed. What happens if you negate 1 to -1 in OpenGL and run the test again?
This comment has been minimized.
This comment has been minimized.
Sorry, something went wrong.
Can you explain why we are comparing if
ret < 0
? Shouldn'tret
always be>= 0
? Also why the negation..?