[2/N] Enable UBSAN tests (#141740)

Apply c10::load in more places. The function was introduced to cast a byte to valid boolean values, thus fixing the UBSAN errors.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/141740
Approved by: https://github.com/ezyang
This commit is contained in:
cyy
2024-12-03 20:52:23 +00:00
committed by PyTorch MergeBot
parent 28efc17d2c
commit 7c1d5db1f3
12 changed files with 45 additions and 52 deletions

View File

@ -26,12 +26,12 @@ struct LoadImpl<bool> {
} // namespace detail
template <typename T>
C10_HOST_DEVICE T load(const void* src) {
C10_HOST_DEVICE constexpr T load(const void* src) {
return c10::detail::LoadImpl<T>::apply(src);
}
template <typename scalar_t>
C10_HOST_DEVICE scalar_t load(const scalar_t* src) {
C10_HOST_DEVICE constexpr scalar_t load(const scalar_t* src) {
return c10::detail::LoadImpl<scalar_t>::apply(src);
}