[Feature Request] Add a real async run method to onnxruntime-node
Describe the feature request
There should really be a true async version of run in onnxruntime-node, running computationally intensive things on the event loop will stop everything else from happening while it is running, e.g. a web server from answering requests.
This can be done by wrapping RunAsync behind a Napi::Promise and Napi::TypedThreadSafeFunction to run on the onnxruntime thread pool, or Napi::AsyncWorker for the Node.js/libuv thread pool.
See https://github.com/microsoft/onnxruntime/pull/19610
Describe scenario use case
Don't block the event loop while running inference, which is naturally computationally intensive.
Thank you for creating this feature request!
Possible discussions:
- not sure if we need a ENV flag or session option for this. Maybe some user still prefer the sync call?
- also need for session initAsync?
Note that the current run method returns a Promise so it's not really sync to begin with just pseudo async where it defers the work to a different phase of the event loop but still blocks it.
So maybe you will want to have a new RunSync method while making the existing Run truly async.