mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 00:20:18 +01:00
Add TORCH_TARGET_VERSION for stable ABI (#164356)
And update it so comparisons can be done by the preprocessor **Note: We also need to gate in shim.h and figure out how to enforce this** Differential Revision: [D85683549](https://our.internmc.facebook.com/intern/diff/D85683549) Pull Request resolved: https://github.com/pytorch/pytorch/pull/164356 Approved by: https://github.com/janeyx99
This commit is contained in:
parent
d6d6fa26f5
commit
fefb546b91
|
|
@ -245,4 +245,10 @@ inline torch::stable::Tensor clone(const torch::stable::Tensor& self) {
|
|||
return torch::stable::detail::to<torch::stable::Tensor>(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)
|
||||
|
|
|
|||
29
torch/csrc/stable/version.h
Normal file
29
torch/csrc/stable/version.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
#include <torch/headeronly/version.h>
|
||||
|
||||
// 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 <torch/csrc/stable/library.h>
|
||||
//
|
||||
// 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 <torch/csrc/stable/library.h>
|
||||
|
||||
#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))
|
||||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user