unreal.NeuralSynchronousMode

class unreal.NeuralSynchronousMode

Bases: EnumBase

Whether the operation (e.g., UNeuralNetwork::Run()) will run in the calling thread (Synchronous) or in a background thread (Asynchronous).

C++ Source:

  • Plugin: NeuralNetworkInference

  • Module: NeuralNetworkInference

  • File: NeuralEnumClasses.h

ASYNCHRONOUS: NeuralSynchronousMode

More complex but potentially more efficient. The operation will initialize a compute request on a background thread and return before its completion, not blocking the calling thread that called it. The user should register to a delegate which will notify them when the operation has finished asynchronously (e.g., UNeuralNetwork::GetOnAsyncRunCompletedDelegate() for asynchronous UNeuralNetwork::Run()).

Very important: It takes ~1 millisecond to start the background thread. If your operation (e.g., your network inference time) runs synchronously faster than 1-2 milliseconds, using asynchronous is not recommended because it’d slow down both the main and background threads.

Type:

1

SYNCHRONOUS: NeuralSynchronousMode

Safer and simpler to use. The operation will run in the calling thread thus blocking that thread until completed.

Type:

0