This is an archive of the discontinued LLVM Phabricator instance.

[mlir][benchmark] Fix import in sparse benchmark.
ClosedPublic

Authored by ingomueller-net on Jul 14 2022, 1:07 AM.

Details

Summary

The benchmark currently fails to run because it cannot find the func
symbol when using a FuncOp. I suppose that the breakage was introduced
by the extraction of the func dialect from the builtin dialect that
wasn't reflected in the benchmark yet.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2022, 1:07 AM
ingomueller-net requested review of this revision.Jul 14 2022, 1:07 AM

Hold on, I am not sure whether this fixes all problems :S

Updating D129738: [mlir][benchmark] Fix import in sparse benchmark.

The update also fixes problems in common.py, which I had not seen
previously. Those must have been introduced in an attempt to port the
file to the new organization of the func dialect, but that attempt
introduced a name clash on the name func.

Also, the benchmark only runs with the following work-around, which I
assume to be a bug in the python bindings of BlockArgumentList:

patch
diff --git a/mlir/benchmark/python/common.py b/mlir/benchmark/python/common.py
index 3d80892b0fb8..864b456fe817 100644
--- a/mlir/benchmark/python/common.py
+++ b/mlir/benchmark/python/common.py
@@ -94,10 +94,9 @@ def emit_benchmark_wrapped_main_func(kernel_func, timer_func):
         loop = scf.ForOp(zero, n_iterations, one, iter_args)
         with ir.InsertionPoint(loop.body):
             start = func.CallOp(timer_func, [])
-            call = func.CallOp(
-                kernel_func,
-                wrapped_func.arguments[:-num_results - 1] + loop.inner_iter_args
-            )
+            args = [a for a in wrapped_func.arguments[:-num_results - 1]] + \
+                [a for a in loop.inner_iter_args]
+            call = func.CallOp(kernel_func, args)
             end = func.CallOp(timer_func, [])
             time_taken = arith.SubIOp(end, start)
             memref.StoreOp(time_taken, timer_buffer, [loop.induction_variable])
aartbik accepted this revision.Jul 14 2022, 2:41 PM

Thanks for fixing. At the moment, this code is not look at by many but I plan to change that. It explains why nobody had seen this yet ;-)

This revision is now accepted and ready to land.Jul 14 2022, 2:41 PM
This revision was automatically updated to reflect the committed changes.