How to use PAPI to measure FLOPs of a model compiled by TVM?

I have read Getting Started With PAPI — tvm 0.8.dev0 documentation (apache.org) and followed codes in the doc.

exe = relay.vm.compile(mod, target, params=params)
vm = profiler_vm.VirtualMachineProfiler(exe, dev)

data = tvm.nd.array(np.random.rand(1, 3, 384, 384).astype("float32"), device=dev)
report = vm.profile(
    [data],
    func_name="main",
    collectors=[tvm.runtime.profiling.PAPIMetricCollector()],
)
print(report)

But when I ran to the code above, it reported error (See in the picture below)

Are the “mod” and “params” wrong? In my code, the are the return value of the function “relay.frontend.from_pytorch”

mod, params = relay.frontend.from_pytorch(scripted_model, shape_list)

But in official doc, they are the return value of “mlp.get_workload(1)”

mod, params = mlp.get_workload(1)

How to use PAPI to measure FLOPs of a model compiled by TVM?

Hi @iwangyuezhang, this error normally indicates that PAPI is not configured correctly. Could you provide the output of papi_avail and papi_native_avail?