Add back barrier after asserts#5043
Conversation
| // by an op that may trap if the assert condition is true. Since the | ||
| // tensor in those two operations may have different layout we need to | ||
| // make sure all the threads are done executing the assert before going to | ||
| // the next op. |
There was a problem hiding this comment.
btw this highlights an interesting thing I noticed a while back. Sometimes we do the same computation in multiple different layouts when there are assert statements because the assertion path doesn't have a data flow path to the next layout anchor operation.
It's not really the end of the world, but an interesting quirk of the remove layout conversion code.
There was a problem hiding this comment.
right, yes this is definitely a limitation as we haven't tried very hard to make assert efficient.
| // those two operations may have different layout we need to make sure all | ||
| // the threads are done executing the assert before going to the next op. | ||
| barrier(); | ||
| if (isa<RankedTensorType>(condition.getType())) { |
There was a problem hiding this comment.
Oh I think this should be
| if (isa<RankedTensorType>(condition.getType())) { | |
| if (isa<RankedTensorType>(op.getCondition().getType())) { |
35ce51a to
122d39d
Compare
|
Actually I realize now asserts should always take a tensor: I'm now wondering how it works within a reduction region. Do we have example somewhere? |
|
Hrm okay, an example can be the kernel in |
|
I guess the region verifier isn't strong enough, but really I don't think any op that has a |
|
yeah I agree, I don't think there is any reason why the condition has to be tensor. I'll try to fix that part |
122d39d to
bc9d292
Compare
support asserts with scalar condition and only emit barrier for assert of tensors. Thanks to @peterbell10 for the suggestion.
support asserts with scalar condition and only emit barrier for assert of tensors. Thanks to @peterbell10 for the suggestion.
support asserts with scalar condition and only emit barrier for assert of tensors. Thanks to @peterbell10 for the suggestion.
support asserts with scalar condition and only emit barrier for assert of tensors.
Thanks to @peterbell10 for the suggestion.