add dtype checking for gather and scatter (#38025)
Summary:
Fixed https://github.com/pytorch/pytorch/issues/37996
in the `cpu_scatter_gather_base_kernel`, it interpret a pointer as `int64_t` regardless the actual dtype.
https://github.com/pytorch/pytorch/blob/2b41b9bceb01851df83d40c1280b3d3b09e1395b/aten/src/ATen/native/cpu/ScatterGatherKernel.cpp#L106
add a index dtype checking will avoid the nasty index out of bound error. As using `int64_t` is convention in ATen code (a.k.a, a limitation), no further fix is needed at the moment.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/38025
Differential Revision: D21498146
Pulled By: ezyang
fbshipit-source-id: b1f96f394a460c4bc63d21ec8d4a2cfbf3e97b03