Last active
August 29, 2015 14:05
-
-
Save sklam/c3e575197af9cbf4e2f1 to your computer and use it in GitHub Desktop.
Getting Numba compiler internal structures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from numba import bytecode, interpreter, ir | |
| def foo(a, b): | |
| c = 0 | |
| for i in range(a): | |
| for j in range(b): | |
| c += i + j | |
| return c | |
| bc = bytecode.ByteCode(func=foo) | |
| intrp =interpreter.Interpreter(bytecode=bc) | |
| intrp.interpret() | |
| print("CFG info".center(80, '=')) | |
| intrp.cfa.dump() # CFG | |
| print("DFG info".center(80, '=')) | |
| intrp.dfa.dump() | |
| intrp.dump() # Dump the Numba IR | |
| print("Getting the entry block".center(80, '=')) | |
| firstblock = intrp.blocks[intrp.cfa.blockseq[0]] # entry block | |
| firstblock.dump() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment