我有这个简单的MWE:
from numba import njit
@njit
def add(a, b):
return a + b
# Now let's inspect the assembly code for the 'add()' function.
for k, v in add.inspect_asm().items():
print(k)
当我运行它时,我没有得到任何输出.判断装配的正确方法是什么?
我有这个简单的MWE:
from numba import njit
@njit
def add(a, b):
return a + b
# Now let's inspect the assembly code for the 'add()' function.
for k, v in add.inspect_asm().items():
print(k)
当我运行它时,我没有得到任何输出.判断装配的正确方法是什么?
您需要首先通过调用该函数或指定签名来填充.inspect_asm()
.例如:
from numba import njit
@njit
def add(a, b):
return a + b
# first call add() to compile it
add(1, 2)
print(add.inspect_asm())
输出:
{(int64, int64): '\t.text\n\t.file\t"<string>"\n\t.globl\t_ZN8__main__3addB2v1B38c8tJTIcFKzyF2ILShI4CrgQElQb6HczSBAA_3dExx\n\t.p2align\t4, ...
-哦,不.
from numba import njit
# specify the signature first:
@njit("int64(int64, int64)")
def add(a, b):
return a + b
print(add.inspect_asm())