How to generate LLVM IR from the pytorch code

(Ritesh Gupta) #1

I’ve seen in forums that people used -dump-ir command on the command line to get it. Have no idea where to specify it. Can anyone explain? or give a sample code to generate the IR?

(Jordan Fix) #2

-dump-ir is a command line option specified in lib/Optimizer/IROptimizer.cpp. It should be available on the command line for any binary that links against the Optimizer lib. For example, you can specify it when running the image-classifier. There are examples of running the image-classifier at tests/images/run.sh, so you could append it to any of those. It also should work when running unit tests that link against Optimizer, e.g. ./tests/OperatorTest -dump-ir.

(Ritesh Gupta) #3

Thanks @jfix. I’ll try to execute and get back to you. If you have some good tutorial on this please share I need it.

(Jordan Fix) #4

I would suggest reading our doc on Testing.