Use std::vector instead of alloca to work around hcc crash
authorJunjie Bai <bai@in.tum.de>
Thu, 13 Dec 2018 20:31:38 +0000 (12:31 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 13 Dec 2018 20:34:36 +0000 (12:34 -0800)
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

index d5d3a21..c5fbe9f 100644 (file)
@@ -1,4 +1,5 @@
 #include <ATen/cuda/detail/IndexUtils.cuh>
+#include <vector>
 
 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<SizeAndStride> 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) {