I want to check the task’s flop.
So I run tutorials/autotvm/tune_simple_template.py and then print the task flop. the result is 268435456
But I think the result sholud be (512+511) x 512 x 512 = 268173312. Maybe I’m wrong, who can help me. thank you.
@kevinthesun
Did you call cfg.add_flop to add flops number?
No, just print the task’s flop
As follows:
import sys
import numpy as np
import tvm
from tvm import autotvm
@autotvm.template
def matmul(N, L, M, dtype):
A = tvm.placeholder((N, L), name=‘A’, dtype=dtype)
B = tvm.placeholder((L, M), name=‘B’, dtype=dtype)
k = tvm.reduce_axis((0, L), name='k')
C = tvm.compute((N, M), lambda i, j: tvm.sum(A[i, k] * B[k, j], axis=k), name='C')
s = tvm.create_schedule(C.op)
#schedule
y, x = s[C].op.axis
k = s[C].op.reduce_axis[0]
##### define space begin #####
cfg = autotvm.get_config()
cfg.define_split("tile_y", y, num_outputs=2)
cfg.define_split("tile_x", x, num_outputs=2)
##### define space end #####
# schedule according to config
yo, yi = cfg["tile_y"].apply(s, C, y)
xo, xi = cfg["tile_x"].apply(s, C, x)
s[C].reorder(yo, xo, k, yi, xi)
return s, [A, B, C]
N, L, M = 512, 512, 512
task = autotvm.task.create(matmul, args=(N, L, M, ‘float32’), target=‘llvm’)
print("task flop : " , task.flop)
The code from tutorials/autotvm/tune_simple_template.py
Am I getting it wrong?
You can take a look at topi conv2d schedule and use cfg.add_flop.
我想你估计没有get到我的点。我运行tvm中这个例子 :tutorials/autotvm/tune_simple_template.py
这个例子是个矩阵相乘(512, 512)X (512, 512).。我认为这个操作的flop应该是(512+511) x 512 x 512 = 268173312, 但是我打印task的flop属性,发现task的flop数是 (512+512) x 512 x 512 = 268435456。所以我认为autotvm中计算task的flop这个是有问题。
I think you can manually add_flop instead of using default task flop calculator in this case. I’m not quite sure about the robustness of the generic task flop calculator.
Well, Thank you, I just want you to confirm if there is a problem with this. If there is a problem, I suggest you to modify it.