Skip to content

Commit df837d0

Browse files
vorsfacebook-github-bot
authored andcommitted
Use the libc++ detection instead of clang detection around std:isinfinite (#52164)
Summary: Fixes #52163 The libc++ vs libstdc++ detection in the pre-processor is taken from https://stackoverflow.com/questions/31657499/how-to-detect-stdlib-libc-in-the-preprocessor Note that in our case `std:isinfinite` presents means that we don't need to import any additional headers to guarantee the `_LIBCPP_VERSION` presents for the `libc++`. Pull Request resolved: #52164 Reviewed By: albanD Differential Revision: D26413108 Pulled By: malfet fbshipit-source-id: 515e258d6758222c910ababf5172c3a275aff08f
1 parent cd46ee6 commit df837d0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ void multinomial_with_replacement_apply(
4747
for (int64_t j = 0; j < n_categories; j++) {
4848
val = self_ptr[i * self_stride_0 + j * self_stride_1];
4949
TORCH_CHECK(val >= 0, "invalid multinomial distribution (encountering probability entry < 0)");
50-
// NB: std::isfinite doesn't bode well with clang for half datatypes,
50+
// NB: std::isfinite doesn't bode well with libc++ for half datatypes,
5151
// so we manually cast it to a double and perform the check.
52-
#if defined(__clang__)
52+
#if defined(_LIBCPP_VERSION)
5353
TORCH_CHECK(std::isfinite(static_cast<double>(val)),
5454
"invalid multinomial distribution (encountering probability entry = infinity or NaN)");
5555
#else

0 commit comments

Comments
 (0)