-
Notifications
You must be signed in to change notification settings - Fork 16
Reduce from an identity held in a register #143
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
Open
vswagath1989
wants to merge
8
commits into
torch-spyre:main
Choose a base branch
from
vswagath1989:reduction-identity-in-a-register
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1f7b551
[ApplyDevicePatterns] Let a pattern take a template's precision from …
vswagath1989 f1ec6ac
[KTDFLowToDFIR] Load a buffer before storing it in a memref.copy
vswagath1989 29d8123
[MapReductionPartials] Reduce from an identity held in a register
vswagath1989 533d4ad
[KTDFLowToDFIR] Lower arith.minnumf to a min
vswagath1989 f92e951
[KTDFLowToDFIR] Lower a compare and a selection
vswagath1989 066a373
Address review on the compare, the copy and the precision helper
vswagath1989 f17cf05
[KTDFLowToDFIR] Lower maxnumf only as an abs-max, and not minnumf
vswagath1989 aaec52d
Follow the compute parameter getFlattenedVectorType now takes
vswagath1989 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
64 changes: 64 additions & 0 deletions
64
test/Conversion/backend/ScheduleIRToDFIR/KTDFLowToDFIR/linalg-cmpf-select-lowering.mlir
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // RUN: dataflow-scheduler-opt -pass-pipeline="builtin.module(ktdflowering-to-dfir)" %s | FileCheck %s | ||
|
|
||
| // Tests that a compare and a selection lower to their vectorchain counterparts. | ||
| // Neither had a lowering, so the four comparisons and the select of the bundle | ||
| // spec could not be expressed at all. | ||
| // | ||
| // The compare's result carries the operands' type rather than a boolean: it is | ||
| // what a selection takes as its condition. The i1 form of that op is its separate | ||
| // mask operand. | ||
|
|
||
| // CHECK-LABEL: func.func @cmpf_select | ||
| // CHECK: vectorchain.element_wise_compare | ||
| // CHECK-SAME: compare_op = #vectorchain<element_wise_compare_operator compare_lt> | ||
| // CHECK: vectorchain.element_wise_selection | ||
|
|
||
| #map_in = affine_map<(d0, d1, d2) -> (d0, d1, d2)> | ||
| #map_out = affine_map<(d0, d1, d2) -> (d0, d2)> | ||
|
|
||
| module { | ||
| ktdf_arch.device @sample_device attributes {} import("../../../../Dialect/KTDFArch/sample_device.mlir") | ||
|
|
||
| // ── a compare feeding a selection ────────────────────────────────────────── | ||
| func.func @cmpf_select() attributes {grid = [2]} { | ||
| %l1lu0 = dataflow.get_unit {core = 0 : i32, name = "C0-L1LU", type = "L1LU"} : index | ||
| %l1lu1 = dataflow.get_unit {core = 1 : i32, name = "C1-L1LU", type = "L1LU"} : index | ||
| %sfu0 = dataflow.get_unit {core = 0 : i32, name = "C0-SFU", type = "SFU"} : index | ||
| %sfu1 = dataflow.get_unit {core = 1 : i32, name = "C1-SFU", type = "SFU"} : index | ||
| %tile_id = ktdp.get_compute_tile_id : index | ||
| %c0 = arith.constant 0 : index | ||
| %c1 = arith.constant 1 : index | ||
| %c256 = arith.constant 256 : index | ||
| %map_l1lu = uniform.def_immutable_mapping([%c0 -> %l1lu0], [%c1 -> %l1lu1]) : index | ||
| %u_l1lu = uniform.query_map(map:%map_l1lu, key:%tile_id) : index | ||
| %map_sfu = uniform.def_immutable_mapping([%c0 -> %sfu0], [%c1 -> %sfu1]) : index | ||
| %u_sfu = uniform.query_map(map:%map_sfu, key:%tile_id) : index | ||
|
|
||
| %alloc_l1 = memref.alloc() : memref<1x256x64xf16, "L1"> | ||
| %fifo = ktdf.fifo.allocate() -> !ktdf.fifo.slot<"L1LU" -> "SFU", 64xf16> | ||
|
|
||
| ktdf_lowering.execute_on %u_l1lu { | ||
| scf.for %i = %c0 to %c256 step %c1 { | ||
| ktdf.data_transfer from %alloc_l1[%c0, %i, %c0] size [1, 1, 64] to %fifo size [64] : memref<1x256x64xf16, "L1">, !ktdf.fifo.slot<"L1LU" -> "SFU", 64xf16> | ||
| } | ||
| } | ||
| ktdf_lowering.execute_on %u_sfu { | ||
| %alloc = memref.alloc() : memref<1x64xf16, "SFU_REG"> | ||
| %neg_inf = arith.constant 0xFF80 : f16 | ||
| linalg.fill ins(%neg_inf : f16) outs(%alloc : memref<1x64xf16, "SFU_REG">) | ||
| scf.for %i = %c0 to %c256 step %c1 { | ||
| %input = ktdf.read_from_fifo %fifo : !ktdf.fifo.slot<"L1LU" -> "SFU", 64xf16> -> memref<1x1x64xf16> | ||
| linalg.generic { | ||
| indexing_maps = [#map_in, #map_out], | ||
| iterator_types = ["parallel", "reduction", "parallel"] | ||
| } ins(%input : memref<1x1x64xf16>) outs(%alloc : memref<1x64xf16, "SFU_REG">) { | ||
| ^bb0(%in: f16, %out: f16): | ||
| %cmp = arith.cmpf olt, %in, %out : f16 | ||
| %result = arith.select %cmp, %in, %out : f16 | ||
| linalg.yield %result : f16 | ||
| } | ||
| } {loop_type = #ktdf.loop_type<reduction_loop>} | ||
| } | ||
| return | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.