-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[samples] Add
big_matvec
sample with pre-existing lowering config (#…
…126) Used to be part of an experiment but likely also useful as a sample for others.
- Loading branch information
Showing
8 changed files
with
352 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
include(quidditch_module) | ||
|
||
add_subdirectory(big_matvec) | ||
add_subdirectory(nsnet2) | ||
add_subdirectory(util) | ||
add_subdirectory(vec_multiply) |
This file contains 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,12 @@ | ||
quidditch_module(SRC big_matvec.mlir ASSERT_XDSL) | ||
|
||
add_executable(big_matvec_sample main.c) | ||
target_link_libraries( | ||
big_matvec_sample | ||
PRIVATE | ||
samples_util | ||
big_matvec | ||
snRuntime | ||
Quidditch::dispatch::dispatch | ||
) | ||
|
This file contains 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,126 @@ | ||
builtin.module @big_matvec { | ||
func.func @test32(%arg0: tensor<1x400xf64>, %arg1: tensor<320x400xf64>) -> tensor<1x320xf64> { | ||
%init = tensor.empty() : tensor<1x320xf64> | ||
%out = linalg.matmul_transpose_b { | ||
lowering_config = #quidditch_snitch.lowering_config< | ||
l1_tiles = [0, 32, 80], | ||
l1_tiles_interchange = [2, 0, 1], | ||
dual_buffer = true | ||
> | ||
} | ||
ins(%arg0, %arg1 : tensor<1x400xf64>, tensor<320x400xf64>) | ||
outs(%init : tensor<1x320xf64>) -> tensor<1x320xf64> | ||
%out2 = linalg.generic { | ||
indexing_maps = [ | ||
affine_map<(d0, d1) -> (d0, d1)>, | ||
affine_map<(d0, d1) -> (d0, d1)> | ||
], iterator_types = ["parallel", "parallel"] | ||
} ins(%out : tensor<1x320xf64>) outs(%out : tensor<1x320xf64>) { | ||
^bb0(%element : f64, %outs : f64): | ||
%bias = arith.constant 5.0 : f64 | ||
%added = arith.addf %element, %bias : f64 | ||
linalg.yield %added : f64 | ||
} -> tensor<1x320xf64> | ||
func.return %out2 : tensor<1x320xf64> | ||
} | ||
|
||
func.func @test40(%arg0: tensor<1x400xf64>, %arg1: tensor<320x400xf64>) -> tensor<1x320xf64> { | ||
%init = tensor.empty() : tensor<1x320xf64> | ||
%out = linalg.matmul_transpose_b { | ||
lowering_config = #quidditch_snitch.lowering_config< | ||
l1_tiles = [0, 40, 80], | ||
l1_tiles_interchange = [2, 0, 1], | ||
dual_buffer = true | ||
> | ||
} | ||
ins(%arg0, %arg1 : tensor<1x400xf64>, tensor<320x400xf64>) | ||
outs(%init : tensor<1x320xf64>) -> tensor<1x320xf64> | ||
%out2 = linalg.generic { | ||
indexing_maps = [ | ||
affine_map<(d0, d1) -> (d0, d1)>, | ||
affine_map<(d0, d1) -> (d0, d1)> | ||
], iterator_types = ["parallel", "parallel"] | ||
} ins(%out : tensor<1x320xf64>) outs(%out : tensor<1x320xf64>) { | ||
^bb0(%element : f64, %outs : f64): | ||
%bias = arith.constant 5.0 : f64 | ||
%added = arith.addf %element, %bias : f64 | ||
linalg.yield %added : f64 | ||
} -> tensor<1x320xf64> | ||
func.return %out2 : tensor<1x320xf64> | ||
} | ||
|
||
func.func @test64(%arg0: tensor<1x400xf64>, %arg1: tensor<320x400xf64>) -> tensor<1x320xf64> { | ||
%init = tensor.empty() : tensor<1x320xf64> | ||
%out = linalg.matmul_transpose_b { | ||
lowering_config = #quidditch_snitch.lowering_config< | ||
l1_tiles = [0, 64, 80], | ||
l1_tiles_interchange = [2, 0, 1], | ||
dual_buffer = true | ||
> | ||
} | ||
ins(%arg0, %arg1 : tensor<1x400xf64>, tensor<320x400xf64>) | ||
outs(%init : tensor<1x320xf64>) -> tensor<1x320xf64> | ||
%out2 = linalg.generic { | ||
indexing_maps = [ | ||
affine_map<(d0, d1) -> (d0, d1)>, | ||
affine_map<(d0, d1) -> (d0, d1)> | ||
], iterator_types = ["parallel", "parallel"] | ||
} ins(%out : tensor<1x320xf64>) outs(%out : tensor<1x320xf64>) { | ||
^bb0(%element : f64, %outs : f64): | ||
%bias = arith.constant 5.0 : f64 | ||
%added = arith.addf %element, %bias : f64 | ||
linalg.yield %added : f64 | ||
} -> tensor<1x320xf64> | ||
func.return %out2 : tensor<1x320xf64> | ||
} | ||
|
||
func.func @test32_100(%arg0: tensor<1x400xf64>, %arg1: tensor<320x400xf64>) -> tensor<1x320xf64> { | ||
%init = tensor.empty() : tensor<1x320xf64> | ||
%out = linalg.matmul_transpose_b { | ||
lowering_config = #quidditch_snitch.lowering_config< | ||
l1_tiles = [0, 32, 100], | ||
l1_tiles_interchange = [2, 0, 1], | ||
dual_buffer = true | ||
> | ||
} | ||
ins(%arg0, %arg1 : tensor<1x400xf64>, tensor<320x400xf64>) | ||
outs(%init : tensor<1x320xf64>) -> tensor<1x320xf64> | ||
%out2 = linalg.generic { | ||
indexing_maps = [ | ||
affine_map<(d0, d1) -> (d0, d1)>, | ||
affine_map<(d0, d1) -> (d0, d1)> | ||
], iterator_types = ["parallel", "parallel"] | ||
} ins(%out : tensor<1x320xf64>) outs(%out : tensor<1x320xf64>) { | ||
^bb0(%element : f64, %outs : f64): | ||
%bias = arith.constant 5.0 : f64 | ||
%added = arith.addf %element, %bias : f64 | ||
linalg.yield %added : f64 | ||
} -> tensor<1x320xf64> | ||
func.return %out2 : tensor<1x320xf64> | ||
} | ||
|
||
func.func @test40_100(%arg0: tensor<1x400xf64>, %arg1: tensor<320x400xf64>) -> tensor<1x320xf64> { | ||
%init = tensor.empty() : tensor<1x320xf64> | ||
%out = linalg.matmul_transpose_b { | ||
lowering_config = #quidditch_snitch.lowering_config< | ||
l1_tiles = [0, 40, 100], | ||
l1_tiles_interchange = [2, 0, 1], | ||
dual_buffer = true | ||
> | ||
} | ||
ins(%arg0, %arg1 : tensor<1x400xf64>, tensor<320x400xf64>) | ||
outs(%init : tensor<1x320xf64>) -> tensor<1x320xf64> | ||
%out2 = linalg.generic { | ||
indexing_maps = [ | ||
affine_map<(d0, d1) -> (d0, d1)>, | ||
affine_map<(d0, d1) -> (d0, d1)> | ||
], iterator_types = ["parallel", "parallel"] | ||
} ins(%out : tensor<1x320xf64>) outs(%out : tensor<1x320xf64>) { | ||
^bb0(%element : f64, %outs : f64): | ||
%bias = arith.constant 5.0 : f64 | ||
%added = arith.addf %element, %bias : f64 | ||
linalg.yield %added : f64 | ||
} -> tensor<1x320xf64> | ||
func.return %out2 : tensor<1x320xf64> | ||
} | ||
} |
Oops, something went wrong.