This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Use sparse-compiler pass in sparse benchmark
ClosedPublic

Authored by SaurabhJha on Jan 30 2022, 9:49 PM.

Details

Summary

This patch uses sparse-compiler option in mlir sparse tensor benchmark

Diff Detail

Event Timeline

SaurabhJha created this revision.Jan 30 2022, 9:49 PM
SaurabhJha requested review of this revision.Jan 30 2022, 9:49 PM

Rename variable pipeline_new -> pipeline

SaurabhJha added inline comments.Jan 30 2022, 10:01 PM
mlir/benchmark/python/common.py
21–22

@wrengr @aartbik I need some help here. I haven't been able to get this to work.

If I do pipeline = f"sparse-compiler{{{opt}}}", I get Can't add pass 'LinalgBufferize' restricted to 'builtin.func' on a PassManager intended to run on 'builtin.module', did you intend to nest?.

If I wrap this in builtin.func like pipeline = f"builtin.func(sparse-compiler{{{opt}}})", I get Can't add pass 'Sparsification' restricted to 'builtin.module' on a PassManager intended to run on 'builtin.func', did you intend to nest?

If I do pipeline = f"builtin.module(sparse-compiler{{{opt}}})", I get Can't add pass 'LinalgBufferize' restricted to 'builtin.func' on a PassManager intended to run on 'builtin.module', did you intend to nest?

And finally, if I do pipeline = f"builtin.module(builtin.func(sparse-compiler{{{opt}}}))", I get Can't add pass 'Sparsification' restricted to 'builtin.module' on a PassManager intended to run on 'builtin.func', did you intend to nest?.

I tried looking at examples in the common pipeline patch but couldn't get it to work. Could you please help me set this correctly?

rriddle added inline comments.
mlir/benchmark/python/common.py
21–22

I added a comment to D117919, but it looks like the pipeline is relying on an implicitly nesting pass manager.

wrengr added inline comments.Jan 31 2022, 12:22 PM
mlir/benchmark/python/common.py
21–22

I tried a few different approaches re nesting (prior to submitting D117919), but couldn't get any of them to work for the cpu-integration tests except for the version that landed. Afaict the python bindings for pipeline parsing differ somehow from what mlir-opt uses; but it's hard to say since both the python bindings and the pipeline stuff are poorly documented. I'll take another look this week and see if I can't figure out how to fix it

SaurabhJha added inline comments.Jan 31 2022, 1:11 PM
mlir/benchmark/python/common.py
21–22

Great, thanks Wren.

SaurabhJha retitled this revision from Use [mlir] sparse-compiler ler pass in sparse benchmark to [mlir] Use sparse-compiler pass in sparse benchmark.Jan 31 2022, 1:12 PM
wrengr added inline comments.Jan 31 2022, 2:47 PM
mlir/benchmark/python/common.py
21–22

I just uploaded D118658 which should fix this

aartbik added inline comments.Feb 1 2022, 1:49 PM
mlir/benchmark/python/common.py
19–20

we disable all, which basically means you could do without opt at all if that makes things simpler for the first version

SaurabhJha added inline comments.Feb 1 2022, 2:11 PM
mlir/benchmark/python/common.py
19–20

Unfortunately, even if I remove opt and run it like

pipeline = f"builtin.module(sparse-compiler))"
PassManager.parse(pipeline).run(mlir_module)

I still face the same issues.

wrengr added inline comments.Feb 3 2022, 12:25 PM
mlir/benchmark/python/common.py
19–20

With D118658 you should be able to use pipeline = f'sparse-compiler' (i.e., no builtin.module nesting), which is what all the python integration tests use after that differential

SaurabhJha added inline comments.Feb 3 2022, 1:12 PM
mlir/benchmark/python/common.py
19–20

Great, I will rebase my changes once your changes are in.

wrengr added inline comments.Feb 4 2022, 11:51 AM
mlir/benchmark/python/common.py
19–20

Just landed it :)

aartbik added inline comments.Feb 7 2022, 6:19 PM
mlir/benchmark/python/common.py
19–20

@SaurabhJha what is the status of this revision?

SaurabhJha added inline comments.Feb 8 2022, 12:34 AM
mlir/benchmark/python/common.py
19–20

Sorry for the delay, the last few days have been quite busy for me. I will update this today pacific time morning.

Integrating fixes in sparse-compiler pass. It works now.

Mistakenly pushed the previous version before. Fixed it now.

aartbik accepted this revision.Feb 9 2022, 11:36 AM
This revision is now accepted and ready to land.Feb 9 2022, 11:36 AM
This revision was automatically updated to reflect the committed changes.