From 86fbf17ba64f985a7d632576091a08f8344f7a24 Mon Sep 17 00:00:00 2001 From: Junjie Bai Date: Thu, 13 Dec 2018 12:31:38 -0800 Subject: [PATCH] Use std::vector instead of alloca to work around hcc crash Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/15175 Differential Revision: D13453708 Pulled By: bddppq fbshipit-source-id: f8c147ae9f679e395fee9d4c73ebcca052c9a752 --- aten/src/ATen/cuda/detail/IndexUtils.cu | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/aten/src/ATen/cuda/detail/IndexUtils.cu b/aten/src/ATen/cuda/detail/IndexUtils.cu index d5d3a21..c5fbe9f 100644 --- a/aten/src/ATen/cuda/detail/IndexUtils.cu +++ b/aten/src/ATen/cuda/detail/IndexUtils.cu @@ -1,4 +1,5 @@ #include +#include namespace at { namespace cuda { @@ -35,7 +36,7 @@ within the next one. */ bool maybeOverlappingIndices(const Tensor& t) { /* Extract size/stride arrays; only consider size >1 dims. */ - SizeAndStride *info = (SizeAndStride *)alloca(sizeof(SizeAndStride) * t.dim()); + std::vector info(t.dim()); int dims = t.dim(); int nonSize1Dims = 0; for (int i = 0; i < dims; ++i) { @@ -58,7 +59,7 @@ bool maybeOverlappingIndices(const Tensor& t) { } /* Ascending order (innermost dimension in sorted view is at [0]) */ - qsort(info, nonSize1Dims, sizeof(SizeAndStride), compareSizeAndStride); + qsort(info.data(), nonSize1Dims, sizeof(SizeAndStride), compareSizeAndStride); for (int i = 0; i < (nonSize1Dims - 1); ++i) { if (((info[i].size - 1) * info[i].stride) >= info[i + 1].stride) { -- 2.7.4