Repository navigation
[DT] Improve encoding hoisting pass. - #21275
Conversation
The revision runs ConstExprHoistingPolicy and hoist the chain ops outside dispatch if they are const-exprs. Furthermore, it allows hoisting tensor.extract_slice ops when they are mappable into Flow ops. The linalg and LinalgExt ops are disallowed because it requires new dispatches. Signed-off-by: hanhanW <[email protected]>
|
cc @egebeysel who might be interested in it. |
Signed-off-by: hanhanW <[email protected]>
There was a problem hiding this comment.
Thank you for the ping and the PR :) I think it looks good! One thing I was curious about: we're unable to do const evaluation after dispatch creation. Why was that exactly and does/could these changes maybe relate to that?
P.S.: I tagged this on another issue but on a second look, didn't look at the other one carefully at first, so it's irrelevant.
| strides, srcShape); | ||
| } | ||
|
|
||
| // Compute ops are not hoistable after dispatch formation. |
There was a problem hiding this comment.
nit: might make sense to have a utility function isComputeOp and use it here as well, so that we're also sure they're aligned.
There was a problem hiding this comment.
I'd like to be careful about it because global utils could make it harder for dialects/phases to change independently, and that can be a good thing, especially when the function is simple. E.g., we can incrementally add support in different dialects under a flag without plumbing through the whole stack. Different backends can support the case in their timeline; it won't become a blocker if any backend can't support the feature and we don't have resources for it.
For the compute op, I think the assumption is that it is a compute op if it implements TilingInterface. There could be outliers like ukernel ops, but it is codegen specific.
| return !isa<linalg::LinalgDialect, IREE::LinalgExt::IREELinalgExtDialect>( | ||
| op->getDialect()); |
There was a problem hiding this comment.
Is it safe to hoist all non linalg/linalg_ext ops like this? Would it be better to check for specific dialects that we want to hoist rather than dialects that we don't want to hoist?
Maybe it is okay because of some assumptions we can make about dispatch formation, but we should be careful about leaking the dispatch formation assumptions into other passes (at the very least I think we should document the assumptions in the comments).
There was a problem hiding this comment.
Yeah, maybe it should be an allow-list because people may add more operations that we don't expect, e.g., tensor_ext.bitcast ops. Let me run an experiment in #21181, and I'll circle back.
There was a problem hiding this comment.
The current allow-list is okay for integration tests, I think we can go with the current version. PTAL
One of the answers is that they will be hoisted into initializers; we'll run it only once when we start the execution, e.g., IMHO, we should be able to support const-eval after dispatch creation in the future, but I'm not sure how the layering'd look like atm. |
Signed-off-by: hanhanW <[email protected]>
Signed-off-by: hanhanW <[email protected]>
|
cc @jtuyls who recently looks at hoisting and propagation as well. |
The revision runs ConstExprHoistingPolicy and hoist the chain ops outside dispatch if they are const-exprs. Furthermore, it allows hoisting tensor.extract_slice ops when they are mappable into Flow ops. It also allows constant-like ops because the ConstExpr analysis has an assumption that any root op is already hoisted to initializers. The rest of operations are not allowed to be hoisted out atm. The hoistEncodingsForConstExpr is dropped because it is no longer needed. It was created for padding strategy. The pass is changed to ModuleOp scope because it requires the analysis for const-exprs. Otherwise, it causes a thread race condition. Fixes #21100 --------- Signed-off-by: hanhanW <[email protected]>
The revision runs ConstExprHoistingPolicy and hoist the chain ops outside dispatch if they are const-exprs. Furthermore, it allows hoisting tensor.extract_slice ops when they are mappable into Flow ops. It also allows constant-like ops because the ConstExpr analysis has an assumption that any root op is already hoisted to initializers. The rest of operations are not allowed to be hoisted out atm.
The hoistEncodingsForConstExpr is dropped because it is no longer needed. It was created for padding strategy.
The pass is changed to ModuleOp scope because it requires the analysis for const-exprs. Otherwise, it causes a thread race condition.
Fixes #21100