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

**URL:** <https://discuss.tvm.apache.org/t/error-using-vm-to-profile-downcast-from-runtime-adt-to-runtime-ndarray-failed/13557>\
**Category:** Questions\
**Created:** [September 21, 2022, 1:20pm UTC](https://discuss.tvm.apache.org/t/error-using-vm-to-profile-downcast-from-runtime-adt-to-runtime-ndarray-failed/13557 "2022-09-21T13:20:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aympab](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/aympab/32/4213_2.png) [@Aympab](https://discuss.tvm.apache.org/u/Aympab)\
**Post date:** [September 21, 2022, 1:20pm UTC](https://discuss.tvm.apache.org/t/error-using-vm-to-profile-downcast-from-runtime-adt-to-runtime-ndarray-failed/13557/1 "2022-09-21T13:20:07Z")

</div>

Hi, I am starting a new thread following [this discussion](https://discuss.tvm.apache.org/t/good-use-of-the-c-tvm-runtime/13546), I need to profile my TVM model.

I followed the [PAPI Tutorial](https://tvm.apache.org/docs/how_to/profile/papi.html) 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)](https://github.com/apache/tvm/blob/main/include/tvm/runtime/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.

```auto
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

---

<div class="post-metadata">

**Author:** ![tkonolige](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/tkonolige/32/1972_2.png) [@tkonolige](https://discuss.tvm.apache.org/u/tkonolige)\
**Post date:** [September 21, 2022, 4:19pm UTC](https://discuss.tvm.apache.org/t/error-using-vm-to-profile-downcast-from-runtime-adt-to-runtime-ndarray-failed/13557/2 "2022-09-21T16:19:01Z")

</div>

Sorry, there is a bug in the script.

Change

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

```

to

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

```

---

<div class="post-metadata">

**Author:** ![Aympab](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/aympab/32/4213_2.png) [@Aympab](https://discuss.tvm.apache.org/u/Aympab)\
**Post date:** [September 22, 2022, 6:18am UTC](https://discuss.tvm.apache.org/t/error-using-vm-to-profile-downcast-from-runtime-adt-to-runtime-ndarray-failed/13557/3 "2022-09-22T06:18:26Z")

</div>

It works now ! Thank you !
