-
Notifications
You must be signed in to change notification settings - Fork 15
Add common pattern fusion #135
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4fc5a92
add pattern matching
HobbitQia f320274
fix format
HobbitQia 4f64088
Merge branch 'main' of https://github.com/coredac/dataflow
HobbitQia 471fdff
update test and format
HobbitQia 3650762
Merge branch 'main' of https://github.com/HobbitQia/dataflow
HobbitQia f592456
fix test
HobbitQia c3e93f6
fix test
HobbitQia 31c69a4
Merge branch 'main' into main
HobbitQia 90cf73a
Merge branch 'coredac:main' into main
HobbitQia 4e83ddb
fix building error
HobbitQia 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
|
|
||
| #define NTAPS 1024 | ||
|
|
||
| int A[NTAPS][NTAPS]; | ||
| int s[NTAPS]; | ||
| int q[NTAPS]; | ||
| int p[NTAPS]; | ||
| int r[NTAPS]; | ||
HobbitQia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| void kernel(int A[][NTAPS], int s[], int q[], int p[], int r[]) { | ||
| int i, j; | ||
|
|
||
| for (i = 0; i < NTAPS; i++) { | ||
| for (j = 0; j < NTAPS; j++) { | ||
| s[j] = s[j] + r[i] * A[i][j]; | ||
| q[i] = q[i] + A[i][j] * p[j]; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| int main() { | ||
| kernel(A, s, q, p, r); | ||
| } | ||
|
|
||
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,24 @@ | ||
| # RUN: clang++ -S -emit-llvm -O3 -fno-unroll-loops -fno-vectorize -o %t-kernel.ll kernel.cpp | ||
tancheng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # RUN: mlir-translate --import-llvm %t-kernel.ll -o %t-kernel.mlir | ||
| # RUN: mlir-neura-opt --assign-accelerator \ | ||
| # RUN: --lower-llvm-to-neura \ | ||
| # RUN: --canonicalize-live-in \ | ||
| # RUN: --leverage-predicated-value \ | ||
| # RUN: --fold-constant \ | ||
| # RUN: --transform-ctrl-to-data-flow \ | ||
| # RUN: --fold-constant \ | ||
| # RUN: --fuse-pattern \ | ||
| # RUN: --view-op-graph \ | ||
| # RUN: --insert-data-mov %t-kernel.mlir -o %t-kernel_dataflow.mlir | FileCheck %s --check-prefix=CHECK-FUSED --input-file=%t-kernel_dataflow.mlir | ||
|
|
||
| # RUN: mlir-neura-opt --map-to-accelerator="mapping-strategy=heuristic backtrack-config=customized" %t-kernel_dataflow.mlir | FileCheck %s --check-prefix=CHECK-MAPPING | ||
|
|
||
| # CHECK-FUSED: func.func | ||
| # CHECK-FUSED: accelerator = "neura" | ||
| # CHECK-FUSED: %102 = neura.load_indexed %100[%101 : !neura.data<i64, i1>] !neura.data<!llvm.ptr, i1> : !neura.data<i32, i1> | ||
| # CHECK-FUSED: %33 = "neura.mul_add"(%30, %31, %32) : (i32, i32, i32) -> i32 | ||
| # CHECK-FUSED: %42 = "neura.mul_add"(%39, %40, %41) : (i32, i32, i32) -> i32 | ||
|
|
||
| # CHECK-MAPPING: mapping_info | ||
| # CHECK-MAPPING: mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 9 : i32, res_mii = 5 : i32, x_tiles = 4 : i32, y_tiles = 4 : i32 | ||
HobbitQia marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # CHECK-MAPPING: mapping_locs | ||
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.