Change number of threads at runtime

TVM runtime automatically determines number of threads to use based on number of Big cores. Also number of threads to use can be specified by env var TVM_NUM_THREADS.
But I’m not sure we can change number of threads while the program is running.

That is different from TFLite. TFLite Interpreter API allows to set number of threads at any time while the inference is running.

Would this help?

BTW, what is a typical use case that requires one changes the number of threads on the fly instead of restarting the program?

1 Like

We have Android app which uses TVM runtime
One of the control on the form allows to change number of threads.
It works fine for TFLite runtime but not for TVM Runtime
See Example:

I think @yidawang’s answer should work, because we have done similar things through that api.

Not sure what API are you talking about.
What the app should do after user clicks + or -? Terminate itself, set env var and relaunch?

When you click - +, you should reconfigure the thread nums via config_threadpool and then reload the .so again. That is to say, you doesn’t need relauch app /, but you should reconfigure the threads firstly and then reload