Use temporary variable to store input parameters in loop. (#36288)
Summary:
The original implementation of maxpool and im2col kernels will fail if `gridSize` * `blockSize` is smaller than the `nthreads` in maxpool kernel or `n` in im2col kernel. Input parameters `bottom_data`, `data_col`, `data_im`, and loop index `index` are modified inside the loop body and the corrupted data will be carried to the second iteration.
This patch uses temporary variables to replace the input parameters and loop indices.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/36288
Differential Revision: D21189020
Pulled By: VitalyFedyunin
fbshipit-source-id: a8075a35e707e6cc99cffd0b2177369e8caea37c