Compile error with "USE_HEXAGON_DEVICE sim"

Sorry for the late reply.

Could you add

#include <iterator>

at the beginning of hexagon_device_sim.cc?

This worked. Thanks!

Then I met another problem:

hexagon_device_sim.cc:146:33: error: no matching function for call to ‘tvm::runtime::hexagon::detail::Optional<long int>::Optional()’

And I fixed it by modifying the struct Optional

@@ -89,6 +90,7 @@ template <typename T>
 struct Optional : public dmlc::optional<T> {
   using dmlc::optional<T>::optional;
   using dmlc::optional<T>::operator=;
+  Optional() {}
   Optional(const T& val) : dmlc::optional<T>(val) {}  // NOLINT(*)


After that, I ran the test_target_codegen_hexagon, but got segmentation fault:

python tests/python/unittest/test_target_codegen_hexagon.py
enabled targets: llvm; llvm -device=arm_cpu; cuda; hexagon
pytest marker: 
=============================================== test session starts ===============================================
platform linux -- Python 3.8.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: my home/Projects/Coder_tvm/tvm
collected 5 items                                                                                                 

tests/python/unittest/test_target_codegen_hexagon.py ....Fatal Python error: Segmentation fault

Current thread 0x00007fb3c6a31700 (most recent call first):
  File "my home//Projects/Coder_tvm/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 227 in __call__
  File "my home//Projects/Coder_tvm/tvm/python/tvm/relay/build_module.py", line 172 in build
  File "my home//Projects/Coder_tvm/tvm/python/tvm/relay/build_module.py", line 357 in build
  File "my home//Projects/Coder_tvm/tvm/tests/python/unittest/test_target_codegen_hexagon.py", line 136 in test_linked_params_codegen

By the way, I didn’t change any other codes except:

$ git diff

diff --git a/src/runtime/hexagon/sim/hexagon_device_sim.cc b/src/runtime/hexagon/sim/hexagon_device_sim.cc
index 14ab4c3..a1c9b8f 100644
--- a/src/runtime/hexagon/sim/hexagon_device_sim.cc
+++ b/src/runtime/hexagon/sim/hexagon_device_sim.cc
@@ -24,6 +24,7 @@
 
 #include <algorithm>
 #include <deque>
+#include <iterator>
 #include <iomanip>
 #include <locale>
 #include <memory>
@@ -89,6 +90,7 @@ template <typename T>
 struct Optional : public dmlc::optional<T> {
   using dmlc::optional<T>::optional;
   using dmlc::optional<T>::operator=;
+  Optional() {}
   Optional(const T& val) : dmlc::optional<T>(val) {}  // NOLINT(*)
 
   T* operator->() { return &this->operator*(); 

My config.cmake is:

$ diff cmake/config.cmake config.cmake 

49c49
< set(USE_CUDA OFF)
---
> set(USE_CUDA ON)
125c125
< set(USE_LLVM OFF)
---
> set(USE_LLVM /usr/bin/llvm-config-10)
255c255
< set(USE_RELAY_DEBUG OFF)
---
> set(USE_RELAY_DEBUG ON)
276,277c276,277
< set(USE_HEXAGON_DEVICE OFF)
< set(USE_HEXAGON_SDK /path/to/sdk)
---
> set(USE_HEXAGON_DEVICE sim)
> set(USE_HEXAGON_SDK /home/SENSETIME/mupei/Qualcomm/Hexagon_SDK/3.5.4)
287c287
< set(USE_TARGET_ONNX OFF)
---
> set(USE_TARGET_ONNX ON)


Have you met this error before? Or maybe I have the wrong config?

My cmake command line is:

cd build
cmake ..
make -j8

Thanks again @kparzysz