-
Notifications
You must be signed in to change notification settings - Fork 15
feat: Implement TOSA to Taskflow lowering pipeline #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a new TOSA→Taskflow lowering pipeline and wires it into the mlir-neura-opt tool, along with the necessary dialect/extension registrations and tests.
Changes:
- Introduces
MLIRTosaToTaskflowPipelineandregisterTosaToTaskflowPipeline()to lower TOSA through Linalg, bufferization, and Affine to Taskflow. - Updates
mlir-neura-optto register TOSA/bufferization dialects, bufferization interfaces, MLIR extensions, and the new pipeline, and links in the required MLIR libraries. - Adds conversion tests for full TOSA→Taskflow lowering and direct Affine→Taskflow lowering, plus updates a CGRA-Bench submodule reference.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/mlir-neura-opt/mlir-neura-opt.cpp | Registers new dialects, bufferization interfaces, MLIR extensions, passes, and the TOSA→Taskflow pipeline in the optimization tool. |
| tools/mlir-neura-opt/CMakeLists.txt | Links additional MLIR dialect, transform, bufferization, and extension libraries required by the tool. |
| test/benchmark/CGRA-Bench | Updates submodule commit for CGRA benchmark data. |
| test/Conversion/TosaToTaskflow/tosa-to-taskflow.mlir | Adds an end-to-end test for the new TOSA→Taskflow pipeline. |
| test/Conversion/TosaToTaskflow/affine-to-taskflow.mlir | Adds a focused test for the Affine→Taskflow conversion pass. |
| lib/Conversion/TosaToTaskflow/TosaToTaskflowPipeline.cpp | Implements the TOSA→Taskflow pass pipeline (TOSA→Linalg/Arith/Tensor, bufferization, Linalg→Affine, Affine→Taskflow). |
| lib/Conversion/TosaToTaskflow/CMakeLists.txt | Builds and links the new MLIRTosaToTaskflowPipeline library with required MLIR components. |
| lib/Conversion/CMakeLists.txt | Integrates the new TOSA→Taskflow pipeline library into the Conversion CMake hierarchy and interface library. |
| include/Conversion/ConversionPasses.h | Declares registerTosaToTaskflowPipeline() for external registration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e041bd9 to
0199b8d
Compare
This PR introduces a new pipeline to lower TOSA operations to the Taskflow dialect through Linalg and Affine conversions. Key changes include:
1. **New Pipeline**: Added that orchestrates:
* TOSA -> Linalg/Arith/Tensor conversion.
* Linalg optimizations (elementwise fusion).
* One-Shot Bufferization with for deterministic results.
* Linalg -> Affine conversion.
* Affine -> Taskflow conversion.
2. **Tooling Support**:
* Updated to register TOSA, Bufferization, and related Dialects.
* Explicitly registered Bufferization interfaces for Linalg, Tensor, Arith, and SCF to prevent runtime crashes.
* Added and links.
3. **Tests**:
* Added to verify the full pipeline.
* Added for direct affine lowering verification.
* Ensured compatibility with existing Taskflow tests (e.g. ).
0199b8d to
609d337
Compare
|
Thanks for this great job~ I think we should enable a progressive lowering process from And could you please help investigate if we can perform some graph-level optimization in |
Split the TosaToTaskflow pipeline into two distinct pipelines: 1. : Lowers TOSA to Linalg (with optimizations and bufferization) and then to Affine. This serves as a foundational pipeline for inspection or further affine transformations. 2. : A composite pipeline that runs followed by . Key changes: - Refactored to expose . - Registered both pipelines in and . - Added test case to verify the intermediate affine stage.
I have split the pipeline and added a test accordingly. Perhaps I could perform optimizations in a subsequent pr? |
Enabled TOSA standard optimization passes (InferShapes, MakeBroadcastable, LayerwiseConstantFold) in the pipeline. Added 'tosa-fusion.mlir' to verify Linalg elementwise fusion and 'tosa-opt.mlir' to benchmark TOSA constant folding (currently a known limitation).
done some of the optimizations, will present here |
Summary for optimizations
|
This PR introduces a new pipeline to lower TOSA operations to the Taskflow dialect through Linalg and Affine conversions. Key changes include:
New Pipeline: Added
TosaToTaskflowPipeline.cppthat orchestrates:infer-shapes,make-broadcastable) and structure. Note: Constant folding has limited impact currently (see Issue [P1] Enhance TOSA constant folding effectivenes #246 ).elementwise-fusion, which proved critical for merging operation chains into single kernels.IdentityLayoutMapfor deterministic results.Tests:
tosa-to-taskflow.mlirto verify the full end-to-end pipeline.tosa-to-affine.mlirfor inspecting the intermediate structural lowering.tosa-fusion.mlirto verify that operator chains are correctly fused into single loops.