Skip to content
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

fix benchmarks after bumping xdsl #298

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/dense_matmul/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ else
REMOVE_MEMREF_COPY=
endif

SNAXOPTFLAGS = -p convert-linalg-to-kernel,insert-accfg-op{accelerator=snax_gemmx},dispatch-kernels,convert-linalg-to-stream,fuse-streaming-regions,stream-bufferize,snax-bufferize,alloc-to-global,set-memory-space,set-memory-layout{gemm_layout=${LAYOUT}},realize-memref-casts,${REMOVE_MEMREF_COPY}insert-sync-barrier,dispatch-regions{nb_cores=3},convert-stream-to-snax-stream,convert-linalg-to-accfg,test-add-mcycle-around-launch,convert-accfg-to-csr,snax-copy-to-dma,memref-to-snax,snax-to-func,snax-lower-mcycle,clear-memory-space
SNAXOPTFLAGS = -p convert-linalg-to-kernel,insert-accfg-op{accelerator=snax_gemmx},dispatch-kernels,convert-linalg-to-stream,fuse-streaming-regions,stream-bufferize,snax-bufferize,alloc-to-global,set-memory-space,set-memory-layout{gemm_layout=${LAYOUT}},realize-memref-casts,${REMOVE_MEMREF_COPY}insert-sync-barrier,dispatch-regions{nb_cores=2},convert-stream-to-snax-stream,convert-linalg-to-accfg,test-add-mcycle-around-launch,convert-accfg-to-csr,snax-copy-to-dma,memref-to-snax,snax-to-func,snax-lower-mcycle,clear-memory-space

GEN_DATA_OPTS += --m=${SIZE_M}
GEN_DATA_OPTS += --n=${SIZE_N}
Expand Down
64 changes: 3 additions & 61 deletions benchmarks/dense_matmul/genbenchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def create_matrix_multiply(m, n, k, add_c: bool = False):

@Builder.implicit_region(arg_types)
def func_body(args: tuple[BlockArgument, ...]) -> None:
c0 = arith.Constant.from_int_and_width(0, 32)
c0 = arith.ConstantOp.from_int_and_width(0, 32)
empty_tensor = tensor.EmptyOp([], (arg_types[-1]))
result = linalg.QuantizedMatmulOp(
[args[0], args[1], c0.result, c0.result], [empty_tensor.tensor]
Expand All @@ -54,9 +54,9 @@ def func_body(args: tuple[BlockArgument, ...]) -> None:
newresult = linalg.AddOp(
[args[2], result.results[0]], [empty_tensor_2.tensor]
)
func.Return(newresult)
func.ReturnOp(newresult)
else:
func.Return(result)
func.ReturnOp(result)

function = func.FuncOp.from_region(
"streamer_matmul", arg_types, res_types, func_body
Expand Down Expand Up @@ -147,64 +147,6 @@ def output_log_benchmark(

sizes = list(itertools.product(selected_dims, repeat=3))

# some other relevant neural network sizes:
nn_size = [
# m, n, k
# tiled small matrix sizes from LSTM
[16, 32, 512],
# tiled small matrix sizes from MobileNetV2
[448, 32, 32],
[8, 192, 32],
[8, 16, 16],
[224, 16, 192],
[8, 96, 16],
[64, 24, 96],
[8, 48, 24],
[56, 48, 16],
[8, 32, 144],
[56, 32, 32],
[200, 48, 16],
[200, 32, 64],
[200, 96, 16],
[200, 8, 384],
[200, 8, 96],
[56, 576, 16],
[8, 160, 576],
[56, 48, 160],
[8, 960, 16],
[56, 64, 960],
[56, 64, 320],
[8, 40, 1280],
# tiled small matrix sizes from ResNet18
[8, 32, 152],
[8, 64, 576],
[8, 128, 576],
[112, 128, 128],
[56, 32, 64],
[40, 64, 1152],
[200, 64, 192],
[200, 32, 128],
[56, 8, 576],
[56, 8, 512],
[56, 128, 256],
[8, 200, 512],
# tiled small matrix sizes from Vision-Transformer
[40, 96, 768],
[40, 200, 64],
[200, 64, 200],
[40, 8, 768],
[8, 128, 192],
[8, 40, 768],
# tiled small matrix sizes from I-BERTBase
[32, 64, 768],
[8, 512, 64],
[32, 64, 512],
[128, 8, 768],
[128, 8, 792],
[128, 88, 192],
]
sizes += nn_size

output_report: dict[str, dict] = {}

for size, layout, add_c in itertools.product(
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/tiled_matmul/genbenchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def get_2d_memref_type(typ, dim_one, dim_two, transpose=False):
b = Block(arg_types=(input_types))

with ImplicitBuilder(b) as (arg0, arg1, arg2):
c0 = arith.Constant.from_int_and_width(0, 32)
c0 = arith.ConstantOp.from_int_and_width(0, 32)
linalg.QuantizedMatmulOp([arg0, arg1, c0.result, c0.result], [arg2])
func.Return()
func.ReturnOp()

region = Region(b)

Expand Down
Loading