iree-llvm-sandbox icon indicating copy to clipboard operation
iree-llvm-sandbox copied to clipboard

Can we pass to the harness a partially transformed file and execute only a partial pipeline?

Open giuseros opened this issue 3 years ago • 2 comments

This stemmed from the discussion here: https://github.com/google/iree-llvm-sandbox/pull/83#discussion_r763689396

Basically, the situation I often find myself in is that I manually apply some transformation to the MLIR textual code produced by the first N transformations of the pipeline. Then I pass the modified textual code to the last part of the pipeline.

I.e., , if the pipeline is [P0, P1, P2, P3, P4, P5] a) I apply P0->P1->P2 and generate intermediate.mlir b) I modify intermediate.mlir to improve things c) I apply P3->P4->P5 to see if performance got better

Is this doable in the current status?

giuseros avatar Dec 08 '21 12:12 giuseros

This should be very easy to do today. We've used https://github.com/google/iree-llvm-sandbox/blob/main/python/examples/core/transforms.py#L60 for the same purpose; you just want the string to be read from a file rather than pasted inline.

f = open ("foo.mlir", "r")
ir = f.readlines()

adding @ftynse to ensure recent refactorings are mindful of Inject / TransformationList interplay.

nicolasvasilache avatar Dec 08 '21 12:12 nicolasvasilache

Test harness is ultimately about running the code, so we cannot just instruct it to produce unrunnable code. If you want human-in-the-loop, you can do something like print(P0.then(P1).then(P2)(your-module)), modify the code manually, parse it back and have an "expert" that does P3.then(P4).then(P5) on it passed to the harness. This should be fine as long as the ABI of the entry point remains the same.

For adventurous ones, it is possible to have a "transform" that prints the IR into a file and then popen's $EDITOR with that file for the user to edit before parsing it back.

ftynse avatar Dec 08 '21 13:12 ftynse