-
Notifications
You must be signed in to change notification settings - Fork 8
[Mlir] Support buffer_at with SDist #62
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| --index-url https://gitlab.inria.fr/api/v4/groups/corse/-/packages/pypi/simple | ||
| mlir-sdist==21.1.2.2026012001 | ||
| mlir-sdist==21.1.2.2026030601 | ||
| mlir==21.1.2.2025091603 | ||
| xtc-mlir==21.1.2.2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| # SPDX-License-Identifier: BSD-3-Clause | ||
| # Copyright (c) 2024-2026 The XTC Project Authors | ||
| # | ||
| from typing import cast | ||
| from dataclasses import dataclass | ||
| from mlir.dialects import transform | ||
| from mlir.dialects.transform import ( | ||
|
|
@@ -312,6 +313,12 @@ def _generate_node_scheduling( | |
| schedule=schedule, | ||
| sched_state=sched_state, | ||
| ) | ||
| if loop_name in schedule.write_buffers: | ||
| self._write_buffer( | ||
| loop_name=loop_name, | ||
| schedule=schedule, | ||
| sched_state=sched_state, | ||
| ) | ||
|
|
||
| # Manage the strip-mining | ||
| if loop_name in schedule.vectorization: | ||
|
|
@@ -505,7 +512,6 @@ def _distribute_loops( | |
| mesh="processor_mesh", | ||
| axis=schedule.distribution[loop_name], | ||
| ) | ||
| assert len(distribute_command.results) == 1 | ||
| new_loop = distribute_command.results[0] | ||
| sched_state.all_loops[loop_name] = new_loop | ||
| # Annotate the resulting loop if successfully generated | ||
|
|
@@ -542,6 +548,28 @@ def _pack_buffer( | |
| input_idx=input_idx, | ||
| ) | ||
|
|
||
| def _write_buffer( | ||
| self, | ||
| loop_name: str, | ||
| schedule: MlirNodeSchedule, | ||
| sched_state: SchedulingState, | ||
| ): | ||
| from .MlirGraphBackend import MlirGraphBackend | ||
| from .MlirNodeBackend import MlirNodeBackend | ||
|
|
||
| assert self._mlir_schedule is not None | ||
| graph_backend = cast(MlirGraphBackend, self._mlir_schedule.scheduler.backend) | ||
| node_backend = cast(MlirNodeBackend, graph_backend.nodes[schedule.node_name]) | ||
| output_idx = len(node_backend.np_inputs_spec()) | ||
| with InsertionPoint(transform.ApplyPatternsOp(sched_state.handle).patterns): | ||
| memref.ApplyFoldMemrefAliasOpsPatternsOp() | ||
| if "sdist" in self._mlir_program.mlir_extensions: | ||
| assert sdist_transform is not None | ||
| sdist_transform.SDistLocalBufferAtOp( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does it do under the hood ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It uses the same SDist primitive as
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok could you test the pipeline at different levels, aka transform, then transformed ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not, but SDist is not tested in CI. Maybe We should ask @guillon how to test XTC also with SDist
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes if we use it for all targets we should test it |
||
| target=sched_state.handle, | ||
| input_idx=output_idx, | ||
| ) | ||
|
|
||
|
|
||
| class MlirProgramApplyTransformPass: | ||
| def __init__( | ||
|
|
||
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.
Why is it needed ?
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.
to pass the pyright type checks
Uh oh!
There was an error while loading. Please reload this page.
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.
Could you use
assert isinstance(var,type)instead ? Imhocastis ambiguous (in terms of intent)