Error using VM to profile : Downcast from runtime.ADT to runtime.NDArray failed

Hi, I am starting a new thread following this discussion, I need to profile my TVM model.

I followed the PAPI Tutorial and adapted the code to my model.

I keep on encountering the same error : Check failed: (ref->template IsInstance<typename SubRef::ContainerType>()) is false: Downcast from runtime.ADT to runtime.NDArray failed.

I went and checked the source code (object.h) of where this error is coming from, but I did not find any hint.

Last but not least, I only tried to run the Tutorial code, with the mlp.get_workload() instead of my model, but I get the same error ! Without changing anything in the code. I was using tvm.10.dev0 but downgraded it to 0.9.0 because I thought it was maybe coming from here, but nothing.

This is the error stack, I checked every files but I cannot find why the tutorial won’t work.

Traceback (most recent call last):
  File "tutorial_papi_profile.py", line 43, in <module>
    report = vm.profile(
  File ".../tvm/python/tvm/runtime/profiler_vm.py", line 91, in profile
    return self._profile(func_name, collectors)
  File ".../tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 237, in __call__
    raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
  5: TVMFuncCall
  4: _ZN3tvm7runtime13PackedFuncObj9ExtractorINS0_16PackedFuncSubObjIZNS0_15TypedPackedFuncIFNS0_9profiling6ReportENS0_6StringENS0_5ArrayINS5_15MetricCollectorEvEEEE17AssignTypedLambdaIZNS0_2vm19VirtualMachineDebug11GetFunctionERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS0_9ObjectPtrINS0_6ObjectEEEEUlS7_SA_E_EEvT_EUlRKNS0_7TVMArgsEPNS0_11TVMRetValueEE_EEE4CallEPKS1_SV_SZ_
  3: tvm::runtime::vm::VirtualMachine::GetFunction(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, tvm::runtime::ObjectPtr<tvm::runtime::Object> const&)::{lambda(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)#1}::operator()(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*) const [clone .isra.536]
  2: _ZN3tvm7runtime2vm14VirtualMachine6InvokeERKNS1_10VMFunctionERKSt
  1: tvm::runtime::vm::VirtualMachine::RunLoop()
  0: tvm::runtime::NDArray tvm::runtime::Downcast<tvm::runtime::NDArray, tvm::runtime::ObjectRef>(tvm::runtime::ObjectRef)
  File ".../tvm/include/tvm/runtime/object.h", line 893
TVMError: 
---------------------------------------------------------------
An error occurred during the execution of TVM.
For more information, please see: https://tvm.apache.org/docs/errors.html
---------------------------------------------------------------
  Check failed: (ref->template IsInstance<typename SubRef::ContainerType>()) is false: Downcast from runtime.ADT to runtime.NDArray failed.

Any help or hint is welcome

Sorry, there is a bug in the script.

Change

report = vm.profile(
    [data],
    func_name="main",
    collectors=[tvm.runtime.profiling.PAPIMetricCollector()],
)

to

report = vm.profile(
    data, # removed the brackets here
    func_name="main",
    collectors=[tvm.runtime.profiling.PAPIMetricCollector()],
)

It works now ! Thank you !