Introducing Hexagon backend

Can you show me the code implementation of Hexgon’s Codegen?

I have a question about Licensing. PR 3163 (Initial implementation of Hexagon runtime support) proposes to add new build option USE_HEXAGON_SDK which is required for Hexagon DSP support

tvm_option(USE_HEXAGON_SDK "Path to the Hexagon SDK root (required for Hexagon support)" /path/to/sdk)

Hexagon SDK is not open-source software. It has particular License

Question is: Can a company use TVM which is built with HEXAGON_SDK in a commercial publicly available web service?

That’s more of a legal question than technical. I took a look at the license and it seems that the exact terms of use depend on various conditions, but I can’t say that I understand it completely. Aside from not knowing the answer, I’m not qualified or authorized to answer such questions… Sorry.

@kparzysz Thank you for your reply. Can I ask you another question. Technical one. I’m trying to use haxagon_nnlib on unlocked Xiaomi Mi 9 phone (sm8150 aka SM855).

Hegaxon SDK docs says that “Unsigned PD” allows to load unsigned libs to CDSP startng from sm8150 SoC.

I’m trying to execute Hexagon_SDK/3.4.3/examples/hexagon_nn/tutorials example 001-nop. I added #pragma weak remote_session_control and call remote_session_control as a first line in main().

hexagon_nn_config, hexagon_nn_init, hexagon_nn_append_node, hexagon_nn_prepare work fine but the execution fails on hexagon_nn_execute.

Xiaomi/mace developer told me that it might be SDM855 SoC firmware bug and hexagon_nn lib may use some APIs that unsigned PD happens to reject to access.

Have you tried Hexagon_SDK/3.4.3/examples/hexagon_nn/tutorials with Unsigned PD on production sm8150 (SDM855) devices (not on dev kits)?

Other examples such as calculator , rpcperf and cornerApp are working fine with Unsigned PD.

I only have a test 8150 device, but I can run unsigned PDs on it, and if there is any “prohibited” call, it should fail there as well. I’m on vacation until the beginning of January, I’ll take a look when I go back to work.

Hi Krzysztof

Did you have a chance to try nexagon_nn on sm8150?

The issue might be related to multithreading and qurt. logcat with farf shows

01-12 23:22:52.896 13125 13128 V adsprpc : log.c:95:0x30d7:11: Arch_Version: 00000000
01-12 23:22:52.896 13125 13128 V adsprpc : log.c:107:0x30d7:11: WARN: ARCH-MISMATCH (compiled for v60 != actual v0)

https://source.codeaurora.org/quic/hexagon_nn/nnlib/tree/hexagon/src/prepare.c line 4796

I also tried queuetest from examples/common/asyncdspq_sample - it hangs as well.

Related discussion How to use hexagon_nn with unsigned PD?

Hi, Yes, I tried it, but I ran into issues much earlier than you did. The first call to NN (I think it was hexagon_nn_config) failed. I sent the link to your question above to some people around here, hopefully I’ll get some reply.

@kparzysz Did you add the call to hexnn_controller_request_unsigned_pd() to main()? It should be the first line in main() function of 001-nop.c.

incs/unsigned_pd.h

#pragma weak remote_session_control

int hexnn_controller_request_unsigned_pd() {
  int ret = -1;
  if (remote_session_control) {
    fprintf(stderr, "***************** remote_session_control is TRUE ****************\n");
    struct remote_rpc_control_unsigned_module data;
    data.enable = 1;
    data.domain = CDSP_DOMAIN_ID;
    ret = remote_session_control(DSPRPC_CONTROL_UNSIGNED_MODULE, (void *) &data, sizeof(data));
    fprintf(stderr, "***************** remote_session_control returned %d ****************\n", ret);
  } else {
    fprintf(stderr, "***************** remote_session_control is FALSE ****************\n");
  }
  return ret;
}

Yes.

… (fulfilling the 20 character obligation)

Ok, we found the workaround. The problem was in qurt_thread_set_priority which is called inside nn_os_set_current_thread_priority in file libs/hexagon_nn/2.6/hexagon/src/nn_os_qurt.c

Decided to just comment out qurt_thread_set_priority line.

We’re back.

2 Likes