From 5001fa463936cc908ab649f86bcea5fae4e1e477 Mon Sep 17 00:00:00 2001 From: Ailing Zhang Date: Mon, 14 Dec 2020 15:42:05 -0800 Subject: [PATCH 1/2] Use size_and_strides_ data structure. --- torch_patches/.torch_pin | 1 + torch_xla/csrc/tensor_impl.cpp | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 torch_patches/.torch_pin diff --git a/torch_patches/.torch_pin b/torch_patches/.torch_pin new file mode 100644 index 00000000000..2c84a62c3f0 --- /dev/null +++ b/torch_patches/.torch_pin @@ -0,0 +1 @@ +#47508 diff --git a/torch_xla/csrc/tensor_impl.cpp b/torch_xla/csrc/tensor_impl.cpp index 8a6c9501a54..f718a97d774 100644 --- a/torch_xla/csrc/tensor_impl.cpp +++ b/torch_xla/csrc/tensor_impl.cpp @@ -132,15 +132,16 @@ void XLATensorImpl::SetupSizeProperties() { // Fill up the basic dimension data members which the base class // implementation uses in its APIs. auto shape = tensor_.shape(); - sizes_.clear(); + c10::SmallVector updated_sizes; numel_ = 1; for (auto dim : shape.get().dimensions()) { - sizes_.push_back(dim); + updated_sizes.push_back(dim); numel_ *= dim; } - strides_.clear(); - for (auto stride : ComputeArrayStrides(shape.get().dimensions())) { - strides_.push_back(stride); + sizes_and_strides_.set_sizes(updated_sizes); + auto updated_strides = ComputeArrayStrides(shape.get().dimensions()); + for (int i = 0; i < updated_strides.size(); i++) { + sizes_and_strides_.stride_at_unchecked(i) = updated_strides[i]; } generation_ = generation; } From aef39789aa2f9f3ba9490e91b61eb0e441ecde49 Mon Sep 17 00:00:00 2001 From: Ailing Date: Fri, 8 Jan 2021 09:32:29 -0800 Subject: [PATCH 2/2] Delete .torch_pin --- torch_patches/.torch_pin | 1 - 1 file changed, 1 deletion(-) delete mode 100644 torch_patches/.torch_pin diff --git a/torch_patches/.torch_pin b/torch_patches/.torch_pin deleted file mode 100644 index 2c84a62c3f0..00000000000 --- a/torch_patches/.torch_pin +++ /dev/null @@ -1 +0,0 @@ -#47508