Refactor the code to introduce new Trace object.#307
Draft
BBBela wants to merge 4 commits intofacebookresearch:mainfrom
Draft
Refactor the code to introduce new Trace object.#307BBBela wants to merge 4 commits intofacebookresearch:mainfrom
BBBela wants to merge 4 commits intofacebookresearch:mainfrom
Conversation
Rename Trace class to TraceCollection and its file trace.py to trace_collection.py. Adjusted the whole code to work with changed names. Signed-off-by: Benedykt Bela <benedykt.bela@intel.com>
Signed-off-by: Benedykt Bela <benedykt.bela@intel.com>
The approach is to get the trace DataFrame directly from TraceCollection object instead of getting Trace object first and then accessing its DataFrame attribute. My current approach is to use the Trace objects directly when: - A method has more than one argument that is aggregated by Trace object. This way we reduce the number of parameters in that method. - A method passes the whole Trace object to another method. - A method returns more than one attribute that is aggregated by Trace object. This way we reduce the number of return values. With this approach we don't need to modify all the methods that use pd.DataFrame as input/output parameters. When there is a need to pass the Trace object to use its methods or attributes, we can simply adjust the methods that need it. Signed-off-by: Benedykt Bela <benedykt.bela@intel.com>
Signed-off-by: Benedykt Bela <benedykt.bela@intel.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.
What does this PR do?
This PR refactors the code to make future changes to enable vendor-specific behavior easier.
Traces from Intel XPU differ from those from CUDA. To enable using HTA to analyze traces from XPU, there is a need to introduce vendor-specific code in several places of the code.
This PR introduces possibility to create a trace class object, representing single trace file. Such object contains vendor-specific behaviors and data. It can be inherited and adjusted for other vendors in a clean way.
This way we have a list of Trace objects (from several trace files) and each of them is child class adjusted for specific vendor. All have the same API, but they perform vendor-specific computing where needed.
Main stages of refactoring:
Traceobject toTraceCollectionwith all the needed imports and name changes. In this approach the meaning of trace is the trace data from one JSON file and theTraceCollectionis collection of several traces from several files.singletracemodule that contain vendor-specificTraceclasses.With this approach it is much easier to add vendor-specific code to the Trace objects. With this solution we basically create one if-else statement when creating the Trace object when parsing trace file. Everywhere else in the code we use the Trace object's methods and attributes no matter what vendor it came from.
Before submitting
This PR is refactoring. HTA tests were adjusted to introduced changes and all pass.
Went through all the changed functions and their descriptions to adjust docstrings to introduced changes.