[mlir][benchmark] Fix broken benchmark script (#68841)

The mbr script was broken, so this patch fixes it to follow the latest
python binding.
This commit is contained in:
Kohei Yamaguchi 2023-12-06 15:47:53 +09:00 committed by GitHub
parent 68f0bc6f2e
commit a05e20b972
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,10 +13,9 @@ def setup_passes(mlir_module):
"""Setup pass pipeline parameters for benchmark functions.""" """Setup pass pipeline parameters for benchmark functions."""
opt = ( opt = (
"parallelization-strategy=none" "parallelization-strategy=none"
" vectorization-strategy=none vl=1 enable-simd-index32=False"
) )
pipeline = f"sparsifier{{{opt}}}" pipeline = f"builtin.module(sparsifier{{{opt}}})"
PassManager.parse(pipeline).run(mlir_module) PassManager.parse(pipeline).run(mlir_module.operation)
def create_sparse_np_tensor(dimensions, number_of_elements): def create_sparse_np_tensor(dimensions, number_of_elements):
@ -73,7 +72,7 @@ def emit_benchmark_wrapped_main_func(kernel_func, timer_func):
create a "time measuring" variant of a function. create a "time measuring" variant of a function.
""" """
i64_type = ir.IntegerType.get_signless(64) i64_type = ir.IntegerType.get_signless(64)
memref_of_i64_type = ir.MemRefType.get([-1], i64_type) memref_of_i64_type = ir.MemRefType.get([ir.ShapedType.get_dynamic_size()], i64_type)
wrapped_func = func.FuncOp( wrapped_func = func.FuncOp(
# Same signature and an extra buffer of indices to save timings. # Same signature and an extra buffer of indices to save timings.
"main", "main",
@ -86,7 +85,7 @@ def emit_benchmark_wrapped_main_func(kernel_func, timer_func):
with ir.InsertionPoint(wrapped_func.add_entry_block()): with ir.InsertionPoint(wrapped_func.add_entry_block()):
timer_buffer = wrapped_func.arguments[-1] timer_buffer = wrapped_func.arguments[-1]
zero = arith.ConstantOp.create_index(0) zero = arith.ConstantOp.create_index(0)
n_iterations = memref.DimOp(ir.IndexType.get(), timer_buffer, zero) n_iterations = memref.DimOp(timer_buffer, zero)
one = arith.ConstantOp.create_index(1) one = arith.ConstantOp.create_index(1)
iter_args = list(wrapped_func.arguments[-num_results - 1 : -1]) iter_args = list(wrapped_func.arguments[-num_results - 1 : -1])
loop = scf.ForOp(zero, n_iterations, one, iter_args) loop = scf.ForOp(zero, n_iterations, one, iter_args)