[BE] Refactor: Modularize extract_source_mappings.py
for improved maintainability
#44
+845
−815
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
tritonparse/tritonparse/extract_source_mappings.py
script was a large, monolithic file containing logic for IR parsing, source mapping, event diffing, and file processing. This made it difficult to read, maintain, and extend.This pull request refactors the script by breaking it down into smaller, single-responsibility modules. This improves the overall code structure, enhances readability, and makes future development easier.
Description of Changes
The core logic of
extract_source_mappings.py
has been split into several new modules within thetritonparse/tritonparse/
directory:extract_source_mappings.py
(Modified): Now serves as a clean command-line entry point, containing only argument parsing and the main execution call.trace_processor.py
(New): The main orchestrator that handles the processing of trace files. It contains the core logic previously found inparse_single_file
andparse_single_trace_content
.ir_parser.py
(New): Contains all functions related to parsing Intermediate Representations (TTIR, TTGIR, PTX, AMDGCN), includingloc
directive extraction.mapper.py
(New): Responsible for creating the bidirectional source mappings between Python source and various IRs.event_diff.py
(New): Provides functionality to compare a list of events and generate a summary of their differences.sourcemap_utils.py
(New): A collection of general-purpose utility functions (e.g., dictionary flattening) used by the new modules.Test Plan: