I don’t know where this code is coming from and thus cannot guarantee what the author intended to do, but warmup iterations are needed for:

if I’m not mistaken, the JIT uses (a few) passes to optimize the graph and thus would need these warmup stage for a proper profiling
if you are using the GPU, the first CUDA operation will create the context, allocate memory and put it to the cache. The following CUDA operations would reuse the cache and avoid slow and blocking memory allocations (if possible)
if you are using cudnn.benchmark the first iteration for each new input shape will run internal profiling via cudnnFind in order to select the fastest kernel for this workload and will thus be slow