Add TOSA Operation Characteristics for Cost Functions#2
Open
erdalmutlu wants to merge 2 commits intopnnl:mainfrom
Open
Add TOSA Operation Characteristics for Cost Functions#2erdalmutlu wants to merge 2 commits intopnnl:mainfrom
erdalmutlu wants to merge 2 commits intopnnl:mainfrom
Conversation
This commit adds a new pass for analyzing TOSA operations and enhances the graph visualization with edge weights based on memory sizes. New Features: - Add sodap-annotate-tosa-ops pass: Analyzes TOSA operations by lowering them to linalg.generic and collecting performance metrics. The metrics are annotated as attributes on the original TOSA operations: * numArithmeticOpsEstimative: Estimated total arithmetic operations * numMemoryOpsEstimative: Estimated total memory operations * numArithmeticOpsInKernel: Arithmetic operations in the kernel body * numMemoryOpsInKernel: Memory operations in the kernel body - Enhance soda-view-op-graph pass: Add memory size-based edge weights to the graphviz output for TOSA operations. Weights are computed from the memory footprint of tensor values flowing between TOSA operations and displayed as raw byte counts. Refactoring: - Extract LinalgOpInfo struct and analysis utilities from GenerateLinalgSummary.cpp into AnalysisPasses.h for reuse across multiple passes - Refactor GenerateLinalgSummary.cpp to use shared analysis utilities Documentation: - Update README.md with documentation for the new sodap-annotate-tosa-ops pass and examples of running multiple passes in sequence - Reorganize README with clearer sections for available passes Build System: - Add AnnotateTosaOps.cpp to CMakeLists.txt - Update SODAPPasses.td with new pass definition - Update SODAPPasses.h with new pass registration
Add comprehensive tests for the new TOSA-related features:
- annotate-tosa-ops.mlir: Test for sodap-annotate-tosa-ops pass
* Verifies that TOSA operations are annotated with performance metrics
* Checks for numArithmeticOpsEstimative, numMemoryOpsEstimative,
numArithmeticOpsInKernel, and numMemoryOpsInKernel attributes
* Tests both tosa.add and tosa.matmul operations
- view-op-graph-tosa.mlir: Test for enhanced soda-view-op-graph pass
* Verifies that edge weights are added to Graphviz output for TOSA ops
* Checks that memory size-based weights (in bytes) are correctly
computed and displayed for edges between TOSA operations
* Tests with tensor<4x4xf32> (64 bytes) and tensor<2x3xf32> (24 bytes)
These tests ensure the new features work correctly and maintain
backward compatibility with existing functionality.
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.
Add TOSA Operation Characteristics for Cost Functions
Summary
This PR introduces a new pass for analyzing TOSA operations and adds TOSA operation characteristics that can be used in cost functions. The pass annotates TOSA operations with performance metrics and memory characteristics, enabling cost-based analysis and optimization. It also includes comprehensive tests to ensure the new features work correctly.
New Features
1. TOSA Operation Analysis Pass (
sodap-annotate-tosa-ops)linalg.genericand collecting performance metricsnumArithmeticOpsEstimative: Estimated total arithmetic operationsnumMemoryOpsEstimative: Estimated total memory operationsnumArithmeticOpsInKernel: Arithmetic operations in the kernel bodynumMemoryOpsInKernel: Memory operations in the kernel body2. TOSA Operation Characteristics for Cost Functions (
soda-view-op-graph)tensor<4x4xf32>, 24 bytes fortensor<2x3xf32>) that can be used in cost calculationsRefactoring
LinalgOpInfostruct and analysis utilities fromGenerateLinalgSummary.cppintoAnalysisPasses.hfor reuse across multiple passesGenerateLinalgSummary.cppto use shared analysis utilitiesTesting
Added comprehensive tests for the new features:
annotate-tosa-ops.mlir: Tests for
sodap-annotate-tosa-opspasstosa.addandtosa.matmuloperationsview-op-graph-tosa.mlir: Tests for
soda-view-op-graphpass with TOSA characteristicsDocumentation
sodap-annotate-tosa-opspassBuild System Updates
AnnotateTosaOps.cppto CMakeLists.txtSODAPPasses.tdwith new pass definitionSODAPPasses.hwith new pass registrationBackward Compatibility
All changes maintain backward compatibility with existing functionality.