Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/docker/ci_commit_pins/pytorch.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
556fc09a9f67f24ca5591ec049c5d0c347c5f62a
b31bad1b8f1331bf43d47f46602cf6141db56844
6 changes: 5 additions & 1 deletion install_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ def install_optional_example_requirements(use_pytorch_nightly):
if use_pytorch_nightly
else "torchvision"
),
f"torchaudio==2.8.0.{NIGHTLY_VERSION}" if use_pytorch_nightly else "torchaudio",
(
f"torchaudio==2.10.0.{NIGHTLY_VERSION}"
if use_pytorch_nightly
else "torchaudio"
),
]
# Then install domain libraries
subprocess.run(
Expand Down
56 changes: 56 additions & 0 deletions runtime/core/portable_type/c10/torch/headeronly/macros/Macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -611,4 +611,60 @@ __host__ __device__
#define C10_RETURN_MOVE_IF_OLD_COMPILER 0
#endif

// The HIDDEN_NAMESPACE_BEGIN and HIDDEN_NAMESPACE_END below
// are needed for maintaining robustness in our header APIs in
// torch/headeronly and torch/csrc/stable under the namespaces
// torch::headeronly and torch::stable respectively. We enforce
// hidden visibility for these APIs because we want to enable
// loading custom extensions compiled against different libtorch
// versions where these APIs may have changed.

// Helper macros for nested namespace expansion
#define _EXPAND(...) __VA_ARGS__

// Macros to handle 1-3 hidden namespace levels when not windows
#define _HIDDEN_NS_GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _HIDDEN_NS_1(n1) namespace n1 __attribute__((visibility("hidden"))) {
#define _HIDDEN_NS_2(n1, n2) \
namespace n1 { \
namespace n2 __attribute__((visibility("hidden"))) {
#define _HIDDEN_NS_3(n1, n2, n3) \
namespace n1::n2 { \
namespace n3 __attribute__((visibility("hidden"))) {

// Macros to close namespaces when not windows
#define _HIDDEN_NS_END_1(n1) }
#define _HIDDEN_NS_END_N(n1, ...) \
} \
}

// Macros to join strs with :: (for win, where symbols are hidden by default)
#define _JOIN_GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _JOIN_NS1(a) a
#define _JOIN_NS2(a, b) a::b
#define _JOIN_NS3(a, b, c) a::b::c

#if !defined(HIDDEN_NAMESPACE_BEGIN)
#if defined(__GNUG__) && !defined(_WIN32)
#define HIDDEN_NAMESPACE_BEGIN(...) \
_EXPAND(_HIDDEN_NS_GET_MACRO( \
__VA_ARGS__, _HIDDEN_NS_3, _HIDDEN_NS_2, _HIDDEN_NS_1)(__VA_ARGS__))
#else
#define HIDDEN_NAMESPACE_BEGIN(...) \
namespace _EXPAND(_JOIN_GET_MACRO( \
__VA_ARGS__, _JOIN_NS3, _JOIN_NS2, _JOIN_NS1)(__VA_ARGS__)) {
#endif
#endif

#if !defined(HIDDEN_NAMESPACE_END)
#if defined(__GNUG__) && !defined(_WIN32)
#define HIDDEN_NAMESPACE_END(...) \
_EXPAND(_HIDDEN_NS_GET_MACRO( \
__VA_ARGS__, _HIDDEN_NS_END_N, _HIDDEN_NS_END_N, _HIDDEN_NS_END_1)( \
__VA_ARGS__))
#else
#define HIDDEN_NAMESPACE_END(...) }
#endif
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these changes brought in via some sync script?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, python .github/scripts/update_pytorch_pin.py


#endif // C10_MACROS_MACROS_H_
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ inline C10_HOST_DEVICE bool operator<(BFloat16& lhs, BFloat16& rhs) {
C10_CLANG_DIAGNOSTIC_POP()
} // namespace c10

namespace torch::headeronly {
HIDDEN_NAMESPACE_BEGIN(torch, headeronly)

namespace detail {
using c10::detail::bits_from_f32;
Expand All @@ -415,7 +415,7 @@ using c10::operator/=;
using c10::operator<;
using c10::operator>;
using c10::operator<<;
} // namespace torch::headeronly
HIDDEN_NAMESPACE_END(torch, headeronly)

namespace std {

Expand Down
4 changes: 2 additions & 2 deletions runtime/core/portable_type/c10/torch/headeronly/util/Half.h
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ C10_CLANG_DIAGNOSTIC_POP()

} // namespace c10

namespace torch::headeronly {
HIDDEN_NAMESPACE_BEGIN(torch, headeronly)

using c10::Half;
using c10::operator+;
Expand All @@ -724,7 +724,7 @@ using c10::detail::fp16_ieee_to_fp32_bits;
using c10::detail::fp16_ieee_to_fp32_value;
} // namespace detail

} // namespace torch::headeronly
HIDDEN_NAMESPACE_END(torch, headeronly)

namespace std {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ inline constexpr bool less_than_lowest(const T& x) {

C10_CLANG_DIAGNOSTIC_POP()

namespace torch::headeronly {
HIDDEN_NAMESPACE_BEGIN(torch, headeronly)
using c10::greater_than_max;
using c10::is_negative;
using c10::less_than_lowest;
using c10::signs_differ;
using c10::signum;
} // namespace torch::headeronly
HIDDEN_NAMESPACE_END(torch, headeronly)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#endif // __has_include(<bit>) && (__cplusplus >= 202002L ||
// (defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806L))

namespace torch::headeronly {
HIDDEN_NAMESPACE_BEGIN(torch, headeronly)

#if C10_HAVE_STD_BIT_CAST
using std::bit_cast;
Expand Down Expand Up @@ -43,7 +43,7 @@ bit_cast(const From& src) noexcept {
#endif // C10_HAVE_STD_BIT_CAST
#undef C10_HAVE_STD_BIT_CAST

} // namespace torch::headeronly
HIDDEN_NAMESPACE_END(torch, headeronly)

namespace c10 {
using torch::headeronly::bit_cast;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ struct alignas(4) complex<Half> {

} // namespace c10

namespace torch::headeronly {
HIDDEN_NAMESPACE_BEGIN(torch, headeronly)
using c10::complex;
using c10::operator+;
using c10::operator-;
Expand All @@ -611,6 +611,6 @@ using c10::complex_literals::operator""_if;
using c10::complex_literals::operator""_id;
} // namespace complex_literals

} // namespace torch::headeronly
HIDDEN_NAMESPACE_END(torch, headeronly)

C10_CLANG_DIAGNOSTIC_POP()
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <torch/headeronly/util/bit_cast.h>
#include <cstdint>

namespace torch::headeronly::detail {
HIDDEN_NAMESPACE_BEGIN(torch, headeronly, detail)

C10_HOST_DEVICE inline float fp32_from_bits(uint32_t w) {
#if defined(__OPENCL_VERSION__)
Expand All @@ -30,7 +30,7 @@ C10_HOST_DEVICE inline uint32_t fp32_to_bits(float f) {
#endif
}

} // namespace torch::headeronly::detail
HIDDEN_NAMESPACE_END(torch, headeronly, detail)

namespace c10::detail {
using torch::headeronly::detail::fp32_from_bits;
Expand Down
2 changes: 1 addition & 1 deletion torch_pin.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
TORCH_VERSION = "2.10.0"
NIGHTLY_VERSION = "dev20251017"
NIGHTLY_VERSION = "dev20251025"
Loading