Skip to content

Commit f41c694

Browse files
[cherry-pick] Fix AArch64 segfaults by disabling strict-aliasing in GridSamplerKernel for GCC 12 and above (pytorch#158445)
Fix AArch64 grid sampler segfaults by disabling strict-aliasing gcc optimization See pytorch#157626 for more context (cherry picked from commit b62f4d0)
1 parent 1d51e69 commit f41c694

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

aten/src/ATen/native/cpu/GridSamplerKernel.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414

1515
namespace at::native { namespace {
1616

17+
// fixes segfaults for GCC >= 12 on some AArch64 cpus https://github.com/pytorch/pytorch/issues/157626
18+
#if defined(__GNUC__) && __GNUC__ >= 12 && defined(__aarch64__)
19+
#pragma GCC push_options
20+
#pragma GCC optimize ("no-strict-aliasing")
21+
#endif
22+
1723
/** NOTE [ Grid Sample CPU Kernels ]
1824
*
1925
* Implementation of vectorized grid sample CPU kernels is divided into three
@@ -1014,6 +1020,10 @@ struct ApplyGridSample<scalar_t, 2, GridSamplerInterpolation::Bicubic,
10141020
}
10151021
};
10161022

1023+
#if defined(__GNUC__) && __GNUC__ >= 12 && defined(__aarch64__)
1024+
#pragma GCC pop_options
1025+
#endif
1026+
10171027
// ~~~~~~~~~~~~~~~~~~ grid_sample_2d_grid_slice_iterator ~~~~~~~~~~~~~~~~~~~~~~
10181028
// Function to apply a vectorized function on a grid slice tensor (without batch
10191029
// dimension).

0 commit comments

Comments
 (0)