diff --git a/torch/csrc/stable/ops.h b/torch/csrc/stable/ops.h index 467bbabb501..df7ddefa84b 100644 --- a/torch/csrc/stable/ops.h +++ b/torch/csrc/stable/ops.h @@ -245,4 +245,10 @@ inline torch::stable::Tensor clone(const torch::stable::Tensor& self) { return torch::stable::detail::to(stack[0]); } +#if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 + +// New ops should be added here if they use a brand new shim API + +#endif + HIDDEN_NAMESPACE_END(torch, stable) diff --git a/torch/csrc/stable/version.h b/torch/csrc/stable/version.h new file mode 100644 index 00000000000..22c9076a3a1 --- /dev/null +++ b/torch/csrc/stable/version.h @@ -0,0 +1,29 @@ +#pragma once + +#include + +// Stable ABI Version Targeting +// +// This header provides version targeting capabilities for the PyTorch Stable +// ABI. Users can define TORCH_TARGET_VERSION to target a specific stable ABI +// version instead of using the current TORCH_ABI_VERSION of libtorch at +// compile time. +// +// Usage: +// Default behavior (uses current ABI version): +// #include +// +// Target a specific stable version (major.minor) (e.g. PyTorch 2.9): +// (1) Pass a compiler flag -DTORCH_TARGET_VERSION=0x0209000000000000 +// (2) Alternatively, define TORCH_TARGET_VERSION in the source code before +// including any header files: +// #define TORCH_TARGET_VERSION (((0ULL + 2) << 56) | ((0ULL + 9) << 48)) +// #include + +#ifdef TORCH_TARGET_VERSION +#define TORCH_FEATURE_VERSION TORCH_TARGET_VERSION +#else +#define TORCH_FEATURE_VERSION TORCH_ABI_VERSION +#endif + +#define TORCH_VERSION_2_10_0 (((0ULL + 2) << 56) | ((0ULL + 10) << 48)) diff --git a/torch/headeronly/version.h.in b/torch/headeronly/version.h.in index 7b9059d9186..61efa246134 100644 --- a/torch/headeronly/version.h.in +++ b/torch/headeronly/version.h.in @@ -19,8 +19,8 @@ /// Indicates the ABI version of LibTorch as a single uint64. /// [ byte ][ byte ][ byte ][ byte ][ byte ][ byte ][ byte ][ byte ] /// [ MAJ ][ MIN ][ PATCH][ ABI TAG ] -#define TORCH_ABI_VERSION \ - (uint64_t)TORCH_VERSION_MAJOR << 56 | \ - (uint64_t)TORCH_VERSION_MINOR << 48 | \ - (uint64_t)TORCH_VERSION_PATCH << 40 | \ - TORCH_VERSION_ABI_TAG << 0 +#define TORCH_ABI_VERSION ( \ + ((0ULL + TORCH_VERSION_MAJOR) << 56) | \ + ((0ULL + TORCH_VERSION_MINOR) << 48) | \ + ((0ULL + TORCH_VERSION_PATCH) << 40) | \ + ((0ULL + TORCH_VERSION_ABI_TAG) << 0))