Add optional graph-modification report to optimize() - #324
Open
take-cheeze wants to merge 1 commit into
Open
Conversation
The optimization passes already compute how many positive transforms each pass applies to the graph (CountBasedPassAnalysis), but every layer discarded this information, so optimize() only returned the optimized model. This threads a per-pass modification report through the whole stack: - PassManagerAnalysis now carries a transform_counts map (pass name -> total positive transforms); both GeneralPassManager::run and FixedPointPassManager::run populate it instead of returning an empty analysis. - Optimizer::optimize / Optimize / OptimizeFixed accept an optional report out-parameter (defaults to nullptr, fully backward compatible). - New nanobind bindings optimize_report / optimize_fixedpoint_report and the path-based optimize_from_path_report / optimize_fixedpoint_from_path_report return the report alongside the model. - Python optimize() gains a return_report keyword. When True it returns a (model, report) tuple where report is a dict mapping pass name to the number of graph modifications; the default return type is unchanged. Add tests covering the tuple return, the counted transform, and the zero-count (pass ran but matched nothing) case. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TSYXLexqD5r4Lkg3KfeGZj Signed-off-by: take-cheeze <takechi101010@gmail.com>
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.
The optimization passes already compute how many positive transforms each pass applies to the graph (CountBasedPassAnalysis), but every layer discarded this information, so optimize() only returned the optimized model.
This threads a per-pass modification report through the whole stack:
Add tests covering the tuple return, the counted transform, and the zero-count (pass ran but matched nothing) case.
Claude-Session: https://claude.ai/code/session_01TSYXLexqD5r4Lkg3KfeGZj