Replace resize_dim() with set_sizes_and_strides() in (#15348)
authorRuiyang Liu <rayliu@fb.com>
Wed, 19 Dec 2018 00:28:14 +0000 (16:28 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 19 Dec 2018 00:38:36 +0000 (16:38 -0800)
commit5e977201006de429436c10a5c48155840025888f
tree7c72d6cb0bc2cabbc08a01cfe3281576f8043180
parent5667af3880af35663e5eee55b657e18e437f52e6
Replace resize_dim() with set_sizes_and_strides() in (#15348)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15348

We have a function resize_dim() on TensorImpl in c10/core/TensorImpl.h which lets you change the dimensionality of a tensor, resizing both sizes and strides. Unfortunately, this API is fairly easy to misuse, because it fills in the new entries with garbage when you size it larger. We want to refactor the call sites to use set_sizes_and_strides() instead, so that there is never an intermediate tensor state where the sizes/strides don't make sense. In this diff, resize_dim() is
replaced with set_sizes_and_strides() in aten/src/TH/THTensor.hpp.

Reviewed By: ezyang

Differential Revision: D13505512

fbshipit-source-id: 193bab89f0018c13ca07488be336d8e967746b76
aten/src/TH/THTensor.hpp