-
Notifications
You must be signed in to change notification settings - Fork 15
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
[Transforms] Add constant_tensors_folding pass #74
base: main
Are you sure you want to change the base?
Conversation
acf3ae8
to
94f2813
Compare
a0ddebe
to
d7663a5
Compare
This reverts commit 22c3d76.
387523a
to
d8d2d79
Compare
void ConstantSubgraphAnalysis::runOnOperation() { | ||
Operation *op = getOperation(); | ||
auto &func = | ||
op->getRegions().front().getBlocks().front().getOperations().front(); |
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.
Is there any shortcut for this kind of operation?
@@ -53,6 +53,8 @@ void populateTensorPasses(mlir::OpPassManager &pm) { | |||
// todo: padding propagation pass | |||
// todo: layout propagation pass | |||
// todo: tensor constant propagation pass | |||
pm.addPass(createConstantSubgraphAnalysisPass()); | |||
pm.addPass(createConstantTensorFoldingPass()); |
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.
Shall we combine these two passes into one, and provide an option to do the analysis only is needed?
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.
I feel the same. Maybe we should put the analysis into the pass, unless the const-subgraph-analysis is needed by more than one pass.
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.
OK, I will put them into to one.
This PR implements constant_tensors_folding pass (RFC: PR #183) in issue #56 and issue #146:
entry
will be split into two functions:entry()
andruntime_fold()
. Theruntime_fold()
function contains the constant operations whose input tensors and output tensors are all constant. The newentry()
function contains other operations that depend on the variable values and folded constant tensors.compile_time_fold()
can be enabled to fold constant tensors during compile time.