[Frontend][IR] (1/N) Preparation for new IR builder - #570
Conversation
| @abc.abstractmethod | ||
| def type_hint(self) -> str: | ||
| """ | ||
| MLIR do not classify signed / unsigned, tag hint for correct lowering | ||
| """ |
There was a problem hiding this comment.
for mlir operation's type hint attribute construction
| @@ -60,10 +65,19 @@ def __init__(self, bits, fracs, name): | |||
| self.name = name | |||
| self.stateful = False | |||
| self.constexpr = False | |||
| if name not in _TYPE_REGISTRY: | |||
| _TYPE_REGISTRY[name] = self | |||
There was a problem hiding this comment.
use _TYPE_REGISTRY when 'reconstructing' allo type
| class MockCallResultTuple(MockOp): | ||
| def __init__(self, results): | ||
| self.res = results | ||
|
|
||
| @property | ||
| def results(self): | ||
| return self.res |
There was a problem hiding this comment.
for function call with multiple return value. (will be used in the new builder)
| mapping, | ||
| shape, | ||
| dtype, | ||
| spec_list, |
There was a problem hiding this comment.
we may support multiple refinement in the future?
| LogicalResult GlobalStreamGetOp::canonicalize(GlobalStreamGetOp op, | ||
| PatternRewriter &rewriter) { | ||
| return canonicalizeStreamAffineMap(op, rewriter); | ||
| } | ||
|
|
||
| LogicalResult GlobalStreamPutOp::canonicalize(GlobalStreamPutOp op, | ||
| PatternRewriter &rewriter) { | ||
| return canonicalizeStreamAffineMap(op, rewriter); | ||
| } |
There was a problem hiding this comment.
will be applied in mlir canonicalize
There was a problem hiding this comment.
Pull request overview
Prepares the frontend/IR stack for an upcoming “new IR builder” by introducing new frontend annotations/utilities, bolstering Python MLIR bindings, and extending IR/type/layout infrastructure.
Changes:
- Introduces
allo/spmw.pyand extends Python-side MLIR dialect wrappers (notablyGridMapOp). - Adds
mlir-python-extraas a submodule and wires it into builds/docs/CI. - Refactors
Layout/DTensorand Allo type utilities to better support new builder workflows.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_memory.py | Updates DTensor construction to new spec_list interface and checks updated string/local-shape behavior. |
| mlir/lib/Dialect/AlloOps.cpp | Adds canonicalization for GlobalStreamGet/Put affine maps. |
| mlir/include/allo/Dialect/AlloOps.td | Enables hasCanonicalizeMethod for GlobalStreamGet/Put ops. |
| mlir/include/allo/Dialect/AlloOps.h | Includes PatternMatch header to support canonicalize methods. |
| mlir/include/allo/Bindings/allo/dialects/allo.py | Adds custom Python wrapper for GridMapOp with region/block construction and helpers. |
| mlir/include/allo/Bindings/CMakeLists.txt | Vendors mlir-python-extra Python sources into the MLIR Python build. |
| externals/mlir-python-extra | Adds mlir-python-extra as a git submodule pin. |
| docs/source/setup/index.rst | Documents initializing the new submodule during install. |
| docs/source/backends/aie/env.rst | Documents initializing the new submodule for AIE environment setup. |
| allo/utils.py | Adds np_dtype_to_allo_dtype mapping using the central type registry. |
| allo/spmw.py | Adds function annotation utilities (kernel/unit/work) and AST discovery helper. |
| allo/memory.py | Adds Layout.shard, improves Layout repr, refactors DTensor to use spec_list and tile_shape. |
| allo/ir/utils.py | Adds MockCallResultTuple helper for multi-result call mocking. |
| allo/ir/types.py | Adds central _TYPE_REGISTRY, adds type_hint() abstraction, uses mlir-python-extra for integer type construction, adjusts Float init. |
| allo/ir/infer.py | Adapts DTensor creation and shape updates to new spec_list/tile_shape. |
| allo/backend/aie/README.md | Documents initializing the new submodule for AIE installs. |
| .gitmodules | Registers externals/mlir-python-extra submodule. |
| .github/workflows/sphinx_build.yml | Ensures submodule is initialized in docs CI. |
| .github/workflows/fpga_weekly.yml | Ensures submodule is initialized in FPGA weekly CI. |
| .github/workflows/config.yml | Ensures submodule is initialized in formatting CI. |
| .github/workflows/aie_ci.yml | Ensures submodule is initialized in AIE CI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Description
This PR introduces preparatory changes for a new IR builder.
Changes in this PR include:
spmw.pyfor new frontend interfaces that will be used by the upcoming IR builder.mlir-python-extraas a dependency, which provides python wrappers for MLIR in-tree dialects and utilities.allo/dialects/allo.py, add python wrappers for Allo's operations.DTensor,Layout, and Allo types to better support the new IR builder.These changes are intended to prepare the codebase for PRs that will introduce the new IR builder and some lowering pipeline.
Checklist
Please make sure to review and check all of these items: