[Transforms] Add constant_tensors_folding pass#74
Open
Conversation
acf3ae8 to
94f2813
Compare
a0ddebe to
d7663a5
Compare
This reverts commit 22c3d76.
387523a to
d8d2d79
Compare
ciyongch
reviewed
Sep 18, 2024
| void ConstantSubgraphAnalysis::runOnOperation() { | ||
| Operation *op = getOperation(); | ||
| auto &func = | ||
| op->getRegions().front().getBlocks().front().getOperations().front(); |
Contributor
There was a problem hiding this comment.
Is there any shortcut for this kind of operation?
| // todo: layout propagation pass | ||
| // todo: tensor constant propagation pass | ||
| pm.addPass(createConstantSubgraphAnalysisPass()); | ||
| pm.addPass(createConstantTensorFoldingPass()); |
Contributor
There was a problem hiding this comment.
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.
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.
Contributor
Author
There was a problem hiding this comment.
OK, I will put them into to one.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements constant_tensors_folding pass (RFC: PR #183) in issue #56 and issue #146:
entrywill 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.