The mxnet engine operates asynchronously which means that when ndarray operations are called in python, the functions return immediately before the computation is actually performed by the backend.
wait_to_read is essentially a blocking call to synchronize the execution and ensures that the result of the computation to produce an ndarray is completed by the backend engine.
For example let’s say you have to ndarrays
y declared. If you run
z = x + y, the operation is queued to the mxnet engine but in python the function returns immediately. If you say
z.wait_to_read() immediately after, this will ensure that
z is actually computed and the values are assigned to the variable before moving on to the next line.
wait_to_read is useful for benchmarking, when you want to actually measure how long it takes to compute the values in an ndarray. This is how it’s used in the tutorial you linked.
wait_to_read can be use to introduce synchronization in your training loop to prevent excessively queuing up more operations than the engine can allocate memory for.