From b1823656605033c71e15fda7cdfe0b1859629662 Mon Sep 17 00:00:00 2001 From: Bob Ren Date: Tue, 23 Sep 2025 11:02:11 -0700 Subject: [PATCH] [ez] use list initializer syntax in fill_diagonal_ (#163607) Pull Request resolved: https://github.com/pytorch/pytorch/pull/163607 Approved by: https://github.com/Skylion007 ghstack dependencies: #163485 --- aten/src/ATen/native/Fill.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/aten/src/ATen/native/Fill.cpp b/aten/src/ATen/native/Fill.cpp index ef43ac83ffbd..8e04a7490e87 100644 --- a/aten/src/ATen/native/Fill.cpp +++ b/aten/src/ATen/native/Fill.cpp @@ -109,26 +109,22 @@ Tensor& fill_diagonal_(Tensor& self, const Scalar& fill_value, bool wrap) { } auto storage_offset = self.sym_storage_offset(); - std::vector sizes; - std::vector strides; auto size = std::min(height, width); int64_t stride = 0; for (const auto i : c10::irange(nDims)) { stride += self.stride(i); } - strides.push_back(stride); - sizes.push_back(size); + std::vector strides{stride}; + std::vector sizes{size}; auto main_diag = self.as_strided_symint(sizes, strides, storage_offset); main_diag.fill_(fill_value); if (wrap && nDims == 2 && height > width + 1) { - std::vector wrap_sizes; - auto step = width + 1; auto wrap_size = ((self.numel() + step - 1) / step) - size; - wrap_sizes.push_back(wrap_size); + std::vector wrap_sizes{wrap_size}; auto offset = self.stride(0) * (width + 1);