mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Enable more UBSAN checks (#138288)
Fixes #ISSUE_NUMBER Pull Request resolved: https://github.com/pytorch/pytorch/pull/138288 Approved by: https://github.com/ezyang
This commit is contained in:
@ -205,7 +205,8 @@ fi
|
||||
if [[ "$BUILD_ENVIRONMENT" == *-clang*-asan* ]]; then
|
||||
export USE_CUDA=0
|
||||
export USE_ASAN=1
|
||||
export UBSAN_FLAGS="-fno-sanitize-recover=all;-fno-sanitize=float-divide-by-zero;-fno-sanitize=float-cast-overflow"
|
||||
export REL_WITH_DEB_INFO=1
|
||||
export UBSAN_FLAGS="-fno-sanitize-recover=all"
|
||||
unset USE_LLVM
|
||||
fi
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <ATen/AccumulateType.h>
|
||||
#include <ATen/NumericUtils.h>
|
||||
#include <ATen/jiterator_macros.h>
|
||||
#include <c10/macros/Macros.h>
|
||||
#include <c10/util/BFloat16.h>
|
||||
#include <c10/util/Half.h>
|
||||
#include <c10/util/MathConstants.h>
|
||||
@ -3071,14 +3072,14 @@ inline C10_HOST_DEVICE T hermite_polynomial_h_forward(T x, int64_t n) {
|
||||
return r;
|
||||
} // hermite_polynomial_h_forward(T x, int64_t n)
|
||||
|
||||
template<typename T, bool is_cuda=false, std::enable_if_t<!std::is_floating_point<T>::value, int> = 0>
|
||||
template<typename T, bool is_cuda=false, std::enable_if_t<!std::is_floating_point_v<T>, int> = 0>
|
||||
inline C10_HOST_DEVICE T hermite_polynomial_h_forward(T x, T n) {
|
||||
return hermite_polynomial_h_forward(x, static_cast<int64_t>(n));
|
||||
} // hermite_polynomial_h_forward(T x, T n)
|
||||
|
||||
template<typename T, bool is_cuda=false, std::enable_if_t<std::is_floating_point<T>::value, int> = 0>
|
||||
inline C10_HOST_DEVICE T hermite_polynomial_h_forward(T x, T n) {
|
||||
return hermite_polynomial_h_forward(x, ((!std::isinf(n)) && (!std::isnan(n))) ? static_cast<int64_t>(n) : static_cast<int64_t>(-1));
|
||||
template<typename T, bool is_cuda=false, std::enable_if_t<std::is_floating_point_v<T>, int> = 0>
|
||||
__ubsan_ignore_float_cast_overflow__ inline C10_HOST_DEVICE T hermite_polynomial_h_forward(T x, T n) {
|
||||
return hermite_polynomial_h_forward(x, (!std::isinf(n) && !std::isnan(n)) ? static_cast<int64_t>(n) : static_cast<int64_t>(-1));
|
||||
} // hermite_polynomial_h_forward(T x, T n)
|
||||
|
||||
template<typename T>
|
||||
|
@ -33,12 +33,15 @@
|
||||
#define __ubsan_ignore_pointer_overflow__ \
|
||||
__attribute__((no_sanitize("pointer-overflow")))
|
||||
#define __ubsan_ignore_function__ __attribute__((no_sanitize("function")))
|
||||
#define __ubsan_ignore_float_cast_overflow__ \
|
||||
__attribute__((no_sanitize("float-cast-overflow")))
|
||||
#else
|
||||
#define __ubsan_ignore_float_divide_by_zero__
|
||||
#define __ubsan_ignore_undefined__
|
||||
#define __ubsan_ignore_signed_int_overflow__
|
||||
#define __ubsan_ignore_pointer_overflow__
|
||||
#define __ubsan_ignore_function__
|
||||
#define __ubsan_ignore_float_cast_overflow__
|
||||
#endif
|
||||
|
||||
// Detect address sanitizer as some stuff doesn't work with it
|
||||
|
Reference in New Issue
Block a user