Skip to content

Commit

Permalink
Snakemake: Add streamer matmul (#315)
Browse files Browse the repository at this point in the history
* Run streamer_matmul on snakemake ci

* Add streamer_matmul

* Remove makefile
  • Loading branch information
JosseVanDelm authored Dec 20, 2024
1 parent 18c12fc commit 23c92ab
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-run-kernel-snake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
working-directory: kernels/${{ matrix.kernel }}
strategy:
matrix:
kernel: [alloc, simple_copy, transform_copy, gemm, rescale, gemmini, streamer_alu]
kernel: [alloc, simple_copy, transform_copy, gemm, rescale, gemmini, streamer_alu, streamer_matmul]
2 changes: 1 addition & 1 deletion .github/workflows/build-run-kernel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
working-directory: kernels/${{ matrix.kernel }}
strategy:
matrix:
kernel: [tiled_add, streamer_matmul]
kernel: [tiled_add]
39 changes: 0 additions & 39 deletions kernels/streamer_matmul/Makefile

This file was deleted.

83 changes: 83 additions & 0 deletions kernels/streamer_matmul/Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
from util.snake.configs import get_snax_gemmx_config

config = get_snax_gemmx_config()
config["snaxoptflags"] = ",".join(
[
"convert-linalg-to-kernel",
"insert-accfg-op{accelerator=snax_gemmx}",
"dispatch-kernels",
"convert-linalg-to-stream",
"fuse-streaming-regions",
"snax-bufferize",
"alloc-to-global",
"set-memory-space",
"set-memory-layout",
"realize-memref-casts",
"insert-sync-barrier",
"dispatch-regions{nb_cores=2}",
"convert-stream-to-snax-stream",
"convert-linalg-to-accfg",
"convert-accfg-to-csr",
"snax-copy-to-dma",
"memref-to-snax",
"snax-to-func",
"clear-memory-space",
]
)

config["mlirtransformflags"] = [
"--pass-pipeline='builtin.module(transform-interpreter{debug-bind-trailing-args=linalg.quantized_matmul}, test-transform-dialect-erase-schedule)'"
]


module default_rules:
snakefile:
"../../util/snake/default_rules.smk"
config:
config


use rule * from default_rules as default_*


# Rules
rule all:
input:
"quantized_matmul.x",
"tiled_quantized_matmul.x",
run:
for item in input:
shell("{config[vltsim]} {item}")


rule generate_quantized_matmul:
output:
"quantized_matmul.mlir",
script:
"quantized_matmul.py"


rule generate_tiled_quantized_matmul:
output:
"tiled_quantized_matmul.transform.mlir",
script:
"tiled_quantized_matmul.py"


rule apply_transforms_mlir:
input:
"{file}.transform.mlir",
output:
"{file}.mlir",
shell:
"{config[mlir-opt]} {config[mlirtransformflags]} -o {output} {input}"


rule link_snax_binary:
input:
"{file}.o",
"main.o",
output:
"{file}.x",
shell:
"{config[ld]} {config[ldflags]} {input} -o {output}"

0 comments on commit 23c92ab

Please sign in to comment.