-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Snakemake: Add mlperf tiny benchmarks (#321)
It puts all mlperf tiny benchmarks in one folder, since this is actually possible, and should make it easier to make multiple benchmarks in parallel if desired at any point.
- Loading branch information
1 parent
1c12f05
commit 5c448e6
Showing
11 changed files
with
149 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from util.get_model import get_model | ||
from util.snake.configs import get_mlperf_tiny_config | ||
|
||
config = get_mlperf_tiny_config() | ||
|
||
|
||
module default_rules: | ||
snakefile: | ||
"../../util/snake/default_rules.smk" | ||
config: | ||
config | ||
|
||
|
||
module tf_rules: | ||
snakefile: | ||
"../../util/snake/tensorflow.smk" | ||
config: | ||
config | ||
|
||
|
||
use rule * from default_rules exclude compile_llvm_module, snax_opt_mlir as default_* | ||
|
||
|
||
use rule * from tf_rules as tf_* | ||
|
||
|
||
nets = ["pretrainedResnet_quant", "kws_ref_model", "vww_96_int8", "ad01_int8"] | ||
extensions = [".o", ".no-snax-opt.o"] | ||
|
||
|
||
rule all: | ||
input: | ||
expand("{network}{extension}", network=nets, extension=extensions), | ||
|
||
|
||
rule get_mlperf_tiny_model: | ||
output: | ||
"{network}.tflite", | ||
# We need to constrain this wildcard to inform snakemake of the limited | ||
# possibilties this function can make | ||
wildcard_constraints: | ||
network="|".join(nets), | ||
run: | ||
get_model(wildcards.network, output[0]) | ||
|
||
|
||
rule snax_opt_mlir: | ||
""" | ||
Similar to snax_opt_mlir, but with print-op-generic | ||
""" | ||
input: | ||
"{file}.preprocfinal.mlir", | ||
output: | ||
temp("{file}.snax-opt.mlir"), | ||
shell: | ||
"{config[snax-opt]} -p {config[snaxoptflags]} --print-op-generic -o {output} {input}" | ||
|
||
|
||
# Override default rule, for output not to be temporary | ||
rule compile_llvm_module: | ||
input: | ||
"{file}.ll12", | ||
output: | ||
"{file}.o", | ||
shell: | ||
"{config[cc]} {config[clangflags]} -x ir -c {input} -o {output}" | ||
|
||
|
||
# Special preprocessing for anomaly detection | ||
rule preprocess_anomaly_detection: | ||
input: | ||
"ad01_int8.mlir", | ||
output: | ||
"ad01_int8.preprocfinal.mlir", | ||
shell: | ||
"{config[snax-opt]} -p preprocess-mlperftiny --print-op-generic --allow-unregistered-dialect -o {output} {input}" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
rule convert_tflite_to_tosa: | ||
input: | ||
"{file}.tflite", | ||
output: | ||
temp("{file}.mlir.bc"), | ||
shell: | ||
"../../runtime/tflite_to_tosa.py -c {input} -o {output} " | ||
|
||
|
||
rule convert_mlir_bytecode_to_text: | ||
input: | ||
"{file}.mlir.bc", | ||
output: | ||
temp("{file}.mlir"), | ||
shell: | ||
"{config[mlir-opt]} --mlir-print-op-generic --mlir-print-local-scope -o {output} {input}" |