-
Notifications
You must be signed in to change notification settings - Fork 14
Lower Affine Dialect to Nerua Dialect #31
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
tancheng
left a comment
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.
Done half of the review, will continue later..
include/NeuraDialect/NeuraOps.td
Outdated
| // NeuraOps.td - Custom operation definitions. | ||
|
|
||
| include "NeuraDialect/NeuraDialect.td" | ||
| include "mlir/IR/CommonTypeConstraints.td" |
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.
What is this used for?
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.
Used for AnySignlessIntegerOrIndex, which was used before.
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.
So you mean now we can remove this header?
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.
Removed in latest commit
include/NeuraDialect/NeuraPasses.td
Outdated
| //=========================================================// | ||
| // Passes for the CGRA Mapping | ||
| //=========================================================// | ||
| // def GenerateDFG : Pass<"generate-dfg", "ModuleOp"> { | ||
| // let summary = "Generates a Data Flow Graph (DFG) for the Neura dialect"; | ||
| // let description = | ||
| // [{This pass generates a DFG from the Neura dialect operations.}]; | ||
| // let constructor = "neura::createGenerateDFGPass()"; | ||
| // } | ||
|
|
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.
These are for what? Or remove?
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.
They are for the ongoing neura-compiler. I just comment them because they are under development.
| auto memref = loadOp.getMemref(); | ||
| AffineMap map = loadOp.getAffineMap(); | ||
| ValueRange mapOperands = loadOp.getMapOperands(); | ||
| // Get the indices for the load operation |
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.
"// Get the indices for the load operation" -> "// Gets the indices for the load operation."
| # # Set include paths for TableGen | ||
| # set(MLIR_TABLEGEN_INCLUDES | ||
| # "-I${PROJECT_SOURCE_DIR}/include" | ||
| # "-I${PROJECT_SOURCE_DIR}/include/NeuraDialect" | ||
| # "-I${CMAKE_CURRENT_BINARY_DIR}/include/NeuraDialect") | ||
|
|
||
| # Generate TableGen files | ||
| set(LLVM_TARGET_DEFINITIONS ${PROJECT_SOURCE_DIR}/include/NeuraDialect/Neura.td) | ||
| mlir_tablegen(Neura.h.inc -gen-op-decls ${MLIR_TABLEGEN_INCLUDES}) | ||
| mlir_tablegen(Neura.cpp.inc -gen-op-defs ${MLIR_TABLEGEN_INCLUDES}) | ||
| mlir_tablegen(NeuraDialect.h.inc -gen-dialect-decls ${MLIR_TABLEGEN_INCLUDES}) | ||
| mlir_tablegen(NeuraDialect.cpp.inc -gen-dialect-defs ${MLIR_TABLEGEN_INCLUDES}) | ||
| mlir_tablegen(NeuraTypes.h.inc -gen-typedef-decls ${MLIR_TABLEGEN_INCLUDES}) | ||
| mlir_tablegen(NeuraTypes.cpp.inc -gen-typedef-defs ${MLIR_TABLEGEN_INCLUDES}) | ||
| add_public_tablegen_target(MLIRNeuraDialectIncGen) | ||
| # # Generate TableGen files | ||
| # set(LLVM_TARGET_DEFINITIONS ${PROJECT_SOURCE_DIR}/include/NeuraDialect/Neura.td) | ||
| # mlir_tablegen(Neura.h.inc -gen-op-decls ${MLIR_TABLEGEN_INCLUDES}) | ||
| # mlir_tablegen(Neura.cpp.inc -gen-op-defs ${MLIR_TABLEGEN_INCLUDES}) | ||
| # mlir_tablegen(NeuraDialect.h.inc -gen-dialect-decls ${MLIR_TABLEGEN_INCLUDES}) | ||
| # mlir_tablegen(NeuraDialect.cpp.inc -gen-dialect-defs ${MLIR_TABLEGEN_INCLUDES}) | ||
| # mlir_tablegen(NeuraTypes.h.inc -gen-typedef-decls ${MLIR_TABLEGEN_INCLUDES}) | ||
| # mlir_tablegen(NeuraTypes.cpp.inc -gen-typedef-defs ${MLIR_TABLEGEN_INCLUDES}) | ||
| # add_public_tablegen_target(MLIRNeuraDialectIncGen) |
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.
Thanks for the cleanup, we can remove these commented out code then?
| # set(MLIR_TABLEGEN_INCLUDES | ||
| # ${PROJECT_SOURCE_DIR}/include | ||
| # ${PROJECT_SOURCE_DIR}/include/NeuraDialect | ||
| # ${CMAKE_CURRENT_BINARY_DIR}/include/NeuraDialect | ||
| # ${MLIR_MAIN_INCLUDE_DIR} | ||
| # ${MLIR_INCLUDE_DIR}) |
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.
Remove?
| @@ -0,0 +1,32 @@ | |||
| // neura-compiler.cpp | |||
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.
Can we implement this compiler in another standalone PR? We prefer tiny PR. I personally prefer per commit PR actually, though not that easy in most cases. But it would be much easier for reviewer.
| @@ -0,0 +1,3 @@ | |||
| /home/lucas/Project/NeuraCompiler/thirdparty/Polygeist/build/bin/cgeist ./simple.cpp -S --raise-scf-to-affine -o ./simple.mlir | |||
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.
We don't have lucas in github action. Can't we follow https://github.com/coredac/dataflow/blob/main/test/c2llvm2mlir/test.mlir?
And I don't understand what your are trying to verify, it seems you just compile the .cpp and lower the corresponding .mlir, as long as there is no error, you are fine? We can at least CHECK sth in a .mlir test.
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.
After updating with the newest commit in the main branch, it seems I can not trigger the actions automatically.
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.
no idea, change the yml and try again?
|
Thanks @ShangkunLi for the effort! Awesome work. Most of my comments are about coding style. And I think you also need to
Thanks~! |
|
Hi @ShangkunLi, this PR is ready to review again? After fixing the comments, plz briefly reply in the conversation box about how you fix it (just briefly summarize, or simply "Done" or "Fixed"), so I got notification and I will click the "resolved" button. Thanks~! |
Hi~ Cheng, I am trying to convert the |
Sure~ |
In this PR, the following tasks are finished:
neura.loop_iter: Used for loop iteration organization, you can treat it like a combination ofphi-add-cmpin llvmneura.loop_control: Used for loop iteration and control, you can treat it like a combination ofphi-add-cmp-brin llvmneura.load_indexed: An operation used for fast array memory access, you can treat it like a combination ofgep-loadin llvmneura.store_indexed: An operation used for fast array memory access, you can treat it like a combination ofgep-storein llvmSource
Affinemlir generated by Polygeist from.cppLowered
Neuramlir by applying this pass:To Do: