Skip to content

Commit

Permalink
Aggregate all results to a pandas dataframe (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
JosseVanDelm authored Feb 5, 2025
1 parent 4e9daa2 commit 672ee4e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
14 changes: 11 additions & 3 deletions kernels/streamer_matmul/Snakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from util.snake.configs import get_snax_gemmx_config
from quantized_matmul import main as get_quantized_matmul
from aggregate import aggregate_results

config = get_snax_gemmx_config(snax_mlir_path="../../snax-mlir")
config["snaxoptflags"] = ",".join(
Expand Down Expand Up @@ -53,10 +54,17 @@ values = [16,32]
# Rules
rule all:
input:
expand("{file}_{m}_{n}_{k}_traces.json", file=files, m=values, n=values, k=values),
"tiled_quantized_matmul_traces.json"
"tiled_quantized_matmul_traces.json",
"quantized_matmul_results.csv"

#rule get_cycles:
rule get_dataframe:
input:
expand("{file}_{m}_{n}_{k}_traces.json", file=files, m=values, n=values, k=values),
output:
"{file}_results.csv"
run:
aggregate_results(wildcards.file)


rule generate_quantized_matmul:
output:
Expand Down
25 changes: 25 additions & 0 deletions kernels/streamer_matmul/aggregate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import json
import pandas as pd
import re
import glob

def aggregate_results(filename: str):
FILENAME_PATTERN = filename + r"_(\d+)_(\d+)_(\d+)_traces\.json"
json_files = glob.glob(f"{filename}_*_traces.json") # Adjust the path
data_list = []
for file in json_files:
match = re.search(FILENAME_PATTERN, file)
if match:
n, m, k = map(int, match.groups()) # Extract n, m, k as integers
with open(file, "r") as f:
json_data = json.load(f)
extracted_cycles = json_data[0][0][2]["cycles"]
data_list.append({"n": n, "m": m, "k": k, "cycles": extracted_cycles })
df = pd.DataFrame(data_list)
df.to_csv(f"{filename}_results.csv", index=False)
return df

if __name__ == "__main__":
df = aggregate_results("quantized_matmul")
print(df)

0 comments on commit 672ee4e

Please sign in to comment.