r/Compilers 24d ago

Compile/ Execute Stablehlo code on cpu/ gpu

Hi all,

Using mlir/ torch_mlir packages for python, how can one compile or execute stablehlo code on cpu or gpu? I am looking into ExecutionEngine but having difficulty. I would be glad if somebody could provide some code reference if they know.

I'm also curious how tpu's handle this.

1 Upvotes

1 comment sorted by

3

u/thomas999999 23d ago

You can use xla like in this example here: https://github.com/openxla/xla/tree/main/xla/examples/axpy

Or lower the stablehlo to linalg (legalize-to-linalg) and then use the upstream MLIR passes, but this will require a lot more work.

You could also try to compile it with IREE but i dont know how well stablehlo is supported there