Repository navigation
Add version linter for files in torch/csrc/stable that use torch/csrc/stable/c/shim.h - #166996
mikaylagawarecki wants to merge 15 commits into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/166996
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New Failures, 1 Cancelled JobAs of commit 596a242 with merge base 3f09374 ( NEW FAILURES - The following jobs have failed:
CANCELLED JOB - The following job was cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…e/c/shim.h" This PR ensures that files in `torch/csrc/stable` that include from `torch/csrc/stable/shim.h` properly gate calls to the stable shim APIs with the appropriate `TORCH_FEATURE_VERSION` macros [ghstack-poisoned]
…e/c/shim.h" This PR ensures that files in `torch/csrc/stable` that include from `torch/csrc/stable/shim.h` properly gate calls to the stable shim APIs with the appropriate `TORCH_FEATURE_VERSION` macros [ghstack-poisoned]
…e/c/shim.h" This PR ensures that files in `torch/csrc/stable` that include from `torch/csrc/stable/shim.h` properly gate calls to the stable shim APIs with the appropriate `TORCH_FEATURE_VERSION` macros ### Examples 1. Commenting out the version guard in https://github.com/pytorch/pytorch/blob/a64c7d740428010d700b4bcd395af8a7b2d5c21f/torch/csrc/stable/ops.h#L265-L271 ``` Error (STABLE_SHIM_USAGE) unversioned-shim-call Call to versioned shim function 'torch_call_dispatcher' is not wrapped in a TORCH_FEATURE_VERSION block. This function requires: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 | // #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 | // #else 269 | // TORCH_ERROR_CODE_CHECK( ``` 2. Changing the first line to say #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_11_0 Doesn't error because this is still valid! 3. Change that line to #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 ``` Error (STABLE_SHIM_USAGE) insufficient-version-for-shim-call Call to 'torch_call_dispatcher' is wrapped in TORCH_VERSION_2_9_0, but this function requires at least TORCH_VERSION_2_10_0. The version guard must be at least the required version: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 |#if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 |#else 269 | TORCH_ERROR_CODE_CHECK( ``` 4. Nested ifdefs ``` #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // We expect this to be the stable version of the clone op. We will // add optional memory_format kwarg support in the future. inline torch::stable::Tensor clone(const torch::stable::Tensor& self) { const auto num_args = 2; std::array<StableIValue, num_args> stack{ torch::stable::detail::from(self), torch::stable::detail::from(std::nullopt)}; #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 #endif #ifdef FOO TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); #else TORCH_ERROR_CODE_CHECK( aoti_torch_call_dispatcher("aten::clone", "", stack.data())); #endif return torch::stable::detail::to<torch::stable::Tensor>(stack[0]); } #endif ``` No error! [ghstack-poisoned]
…e/c/shim.h" This PR ensures that files in `torch/csrc/stable` that include from `torch/csrc/stable/shim.h` properly gate calls to the stable shim APIs with the appropriate `TORCH_FEATURE_VERSION` macros ### Examples 1. Commenting out the version guard in https://github.com/pytorch/pytorch/blob/a64c7d740428010d700b4bcd395af8a7b2d5c21f/torch/csrc/stable/ops.h#L265-L271 ``` Error (STABLE_SHIM_USAGE) unversioned-shim-call Call to versioned shim function 'torch_call_dispatcher' is not wrapped in a TORCH_FEATURE_VERSION block. This function requires: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 | // #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 | // #else 269 | // TORCH_ERROR_CODE_CHECK( ``` 2. Changing the first line to say #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_11_0 Doesn't error because this is still valid! 3. Change that line to #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 ``` Error (STABLE_SHIM_USAGE) insufficient-version-for-shim-call Call to 'torch_call_dispatcher' is wrapped in TORCH_VERSION_2_9_0, but this function requires at least TORCH_VERSION_2_10_0. The version guard must be at least the required version: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 |#if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 |#else 269 | TORCH_ERROR_CODE_CHECK( ``` 4. Nested ifdefs ``` #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // We expect this to be the stable version of the clone op. We will // add optional memory_format kwarg support in the future. inline torch::stable::Tensor clone(const torch::stable::Tensor& self) { const auto num_args = 2; std::array<StableIValue, num_args> stack{ torch::stable::detail::from(self), torch::stable::detail::from(std::nullopt)}; #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 #endif #ifdef FOO TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); #else TORCH_ERROR_CODE_CHECK( aoti_torch_call_dispatcher("aten::clone", "", stack.data())); #endif return torch::stable::detail::to<torch::stable::Tensor>(stack[0]); } #endif ``` No error! [ghstack-poisoned]
…e/c/shim.h" This PR ensures that files in `torch/csrc/stable` that include from `torch/csrc/stable/shim.h` properly gate calls to the stable shim APIs with the appropriate `TORCH_FEATURE_VERSION` macros ### Examples 1. Commenting out the version guard in https://github.com/pytorch/pytorch/blob/a64c7d740428010d700b4bcd395af8a7b2d5c21f/torch/csrc/stable/ops.h#L265-L271 ``` Error (STABLE_SHIM_USAGE) unversioned-shim-call Call to versioned shim function 'torch_call_dispatcher' is not wrapped in a TORCH_FEATURE_VERSION block. This function requires: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 | // #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 | // #else 269 | // TORCH_ERROR_CODE_CHECK( ``` 2. Changing the first line to say #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_11_0 Doesn't error because this is still valid! 3. Change that line to #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 ``` Error (STABLE_SHIM_USAGE) insufficient-version-for-shim-call Call to 'torch_call_dispatcher' is wrapped in TORCH_VERSION_2_9_0, but this function requires at least TORCH_VERSION_2_10_0. The version guard must be at least the required version: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 |#if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 |#else 269 | TORCH_ERROR_CODE_CHECK( ``` 4. Nested ifdefs ``` #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // We expect this to be the stable version of the clone op. We will // add optional memory_format kwarg support in the future. inline torch::stable::Tensor clone(const torch::stable::Tensor& self) { const auto num_args = 2; std::array<StableIValue, num_args> stack{ torch::stable::detail::from(self), torch::stable::detail::from(std::nullopt)}; #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 #endif #ifdef FOO TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); #else TORCH_ERROR_CODE_CHECK( aoti_torch_call_dispatcher("aten::clone", "", stack.data())); #endif return torch::stable::detail::to<torch::stable::Tensor>(stack[0]); } #endif ``` No error! [ghstack-poisoned]
janeyx99
left a comment
There was a problem hiding this comment.
some nits + requests for clarity, but overall looks good! thanks for the tests and example files
| def __init__(self): | ||
| """Initialize the preprocessor tracker.""" | ||
| # Stack of (is_version_block, version_tuple) tuples | ||
| # is_version_block: True if this is a TORCH_FEATURE_VERSION >= TORCH_VERSION_X_Y_0 block |
There was a problem hiding this comment.
Not necessarily about this PR, but is the last 0 in TORCH_VERSION_X_Y_0 the ABI version? In the future that number may change, so we probably don't want to have our macro names be specialized to 0 prematurely.
| replacement=None, | ||
| description=( | ||
| f"Call to versioned shim function '{func_name}' is not wrapped " | ||
| f"in a TORCH_FEATURE_VERSION block. This function requires at least:\n" |
There was a problem hiding this comment.
phrasing is a bit weird, but thats ok
| #endif | ||
|
|
||
| // Function after #elif should not be versioned | ||
| #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 |
There was a problem hiding this comment.
just curious: we're not expecting any nested ifdefs right?
… torch/csrc/stable/c/shim.h" This PR ensures that files in `torch/csrc/stable` that include from `torch/csrc/stable/shim.h` properly gate calls to the stable shim APIs with the appropriate `TORCH_FEATURE_VERSION` macros ### Examples 1. Commenting out the version guard in https://github.com/pytorch/pytorch/blob/a64c7d740428010d700b4bcd395af8a7b2d5c21f/torch/csrc/stable/ops.h#L265-L271 ``` Error (STABLE_SHIM_USAGE) unversioned-shim-call Call to versioned shim function 'torch_call_dispatcher' is not wrapped in a TORCH_FEATURE_VERSION block. This function requires: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 | // #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 | // #else 269 | // TORCH_ERROR_CODE_CHECK( ``` 2. Changing the first line to say #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_11_0 Doesn't error because this is still valid! 3. Change that line to #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 ``` Error (STABLE_SHIM_USAGE) insufficient-version-for-shim-call Call to 'torch_call_dispatcher' is wrapped in TORCH_VERSION_2_9_0, but this function requires at least TORCH_VERSION_2_10_0. The version guard must be at least the required version: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 |#if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 |#else 269 | TORCH_ERROR_CODE_CHECK( ``` 4. Nested ifdefs ``` #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // We expect this to be the stable version of the clone op. We will // add optional memory_format kwarg support in the future. inline torch::stable::Tensor clone(const torch::stable::Tensor& self) { const auto num_args = 2; std::array<StableIValue, num_args> stack{ torch::stable::detail::from(self), torch::stable::detail::from(std::nullopt)}; #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 #endif #ifdef FOO TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); #else TORCH_ERROR_CODE_CHECK( aoti_torch_call_dispatcher("aten::clone", "", stack.data())); #endif return torch::stable::detail::to<torch::stable::Tensor>(stack[0]); } #endif ``` No error! [ghstack-poisoned]
| #endif | ||
|
|
||
| #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 | ||
| using StableIValue = uint64_t; |
There was a problem hiding this comment.
using StableIValue = uint64_t; is already in the aoti shim which is included in this file
(it also should not have minimum version 2.10)
hence removing
… torch/csrc/stable/c/shim.h" This PR ensures that files in `torch/csrc/stable` that include from `torch/csrc/stable/shim.h` properly gate calls to the stable shim APIs with the appropriate `TORCH_FEATURE_VERSION` macros ### Examples 1. Commenting out the version guard in https://github.com/pytorch/pytorch/blob/a64c7d740428010d700b4bcd395af8a7b2d5c21f/torch/csrc/stable/ops.h#L265-L271 ``` Error (STABLE_SHIM_USAGE) unversioned-shim-call Call to versioned shim function 'torch_call_dispatcher' is not wrapped in a TORCH_FEATURE_VERSION block. This function requires: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 | // #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 | // #else 269 | // TORCH_ERROR_CODE_CHECK( ``` 2. Changing the first line to say #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_11_0 Doesn't error because this is still valid! 3. Change that line to #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 ``` Error (STABLE_SHIM_USAGE) insufficient-version-for-shim-call Call to 'torch_call_dispatcher' is wrapped in TORCH_VERSION_2_9_0, but this function requires at least TORCH_VERSION_2_10_0. The version guard must be at least the required version: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 |#if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 |#else 269 | TORCH_ERROR_CODE_CHECK( ``` 4. Nested ifdefs ``` #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // We expect this to be the stable version of the clone op. We will // add optional memory_format kwarg support in the future. inline torch::stable::Tensor clone(const torch::stable::Tensor& self) { const auto num_args = 2; std::array<StableIValue, num_args> stack{ torch::stable::detail::from(self), torch::stable::detail::from(std::nullopt)}; #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 #endif #ifdef FOO TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); #else TORCH_ERROR_CODE_CHECK( aoti_torch_call_dispatcher("aten::clone", "", stack.data())); #endif return torch::stable::detail::to<torch::stable::Tensor>(stack[0]); } #endif ``` No error! [ghstack-poisoned]
… torch/csrc/stable/c/shim.h" This PR ensures that files in `torch/csrc/stable` that include from `torch/csrc/stable/shim.h` properly gate calls to the stable shim APIs with the appropriate `TORCH_FEATURE_VERSION` macros ### Examples 1. Commenting out the version guard in https://github.com/pytorch/pytorch/blob/a64c7d740428010d700b4bcd395af8a7b2d5c21f/torch/csrc/stable/ops.h#L265-L271 ``` Error (STABLE_SHIM_USAGE) unversioned-shim-call Call to versioned shim function 'torch_call_dispatcher' is not wrapped in a TORCH_FEATURE_VERSION block. This function requires: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 | // #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 | // #else 269 | // TORCH_ERROR_CODE_CHECK( ``` 2. Changing the first line to say #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_11_0 Doesn't error because this is still valid! 3. Change that line to #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 ``` Error (STABLE_SHIM_USAGE) insufficient-version-for-shim-call Call to 'torch_call_dispatcher' is wrapped in TORCH_VERSION_2_9_0, but this function requires at least TORCH_VERSION_2_10_0. The version guard must be at least the required version: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 |#if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 |#else 269 | TORCH_ERROR_CODE_CHECK( ``` 4. Nested ifdefs ``` #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // We expect this to be the stable version of the clone op. We will // add optional memory_format kwarg support in the future. inline torch::stable::Tensor clone(const torch::stable::Tensor& self) { const auto num_args = 2; std::array<StableIValue, num_args> stack{ torch::stable::detail::from(self), torch::stable::detail::from(std::nullopt)}; #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 #endif #ifdef FOO TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); #else TORCH_ERROR_CODE_CHECK( aoti_torch_call_dispatcher("aten::clone", "", stack.data())); #endif return torch::stable::detail::to<torch::stable::Tensor>(stack[0]); } #endif ``` No error! [ghstack-poisoned]
… torch/csrc/stable/c/shim.h" This PR ensures that files in `torch/csrc/stable` that include from `torch/csrc/stable/shim.h` properly gate calls to the stable shim APIs with the appropriate `TORCH_FEATURE_VERSION` macros ### Examples 1. Commenting out the version guard in https://github.com/pytorch/pytorch/blob/a64c7d740428010d700b4bcd395af8a7b2d5c21f/torch/csrc/stable/ops.h#L265-L271 ``` Error (STABLE_SHIM_USAGE) unversioned-shim-call Call to versioned shim function 'torch_call_dispatcher' is not wrapped in a TORCH_FEATURE_VERSION block. This function requires: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 | // #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 | // #else 269 | // TORCH_ERROR_CODE_CHECK( ``` 2. Changing the first line to say #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_11_0 Doesn't error because this is still valid! 3. Change that line to #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 ``` Error (STABLE_SHIM_USAGE) insufficient-version-for-shim-call Call to 'torch_call_dispatcher' is wrapped in TORCH_VERSION_2_9_0, but this function requires at least TORCH_VERSION_2_10_0. The version guard must be at least the required version: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 |#if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 |#else 269 | TORCH_ERROR_CODE_CHECK( ``` 4. Nested ifdefs ``` #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // We expect this to be the stable version of the clone op. We will // add optional memory_format kwarg support in the future. inline torch::stable::Tensor clone(const torch::stable::Tensor& self) { const auto num_args = 2; std::array<StableIValue, num_args> stack{ torch::stable::detail::from(self), torch::stable::detail::from(std::nullopt)}; #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 #endif #ifdef FOO TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); #else TORCH_ERROR_CODE_CHECK( aoti_torch_call_dispatcher("aten::clone", "", stack.data())); #endif return torch::stable::detail::to<torch::stable::Tensor>(stack[0]); } #endif ``` No error! [ghstack-poisoned]
… torch/csrc/stable/c/shim.h" This PR ensures that files in `torch/csrc/stable` that include from `torch/csrc/stable/shim.h` properly gate calls to the stable shim APIs with the appropriate `TORCH_FEATURE_VERSION` macros ### Examples 1. Commenting out the version guard in https://github.com/pytorch/pytorch/blob/a64c7d740428010d700b4bcd395af8a7b2d5c21f/torch/csrc/stable/ops.h#L265-L271 ``` Error (STABLE_SHIM_USAGE) unversioned-shim-call Call to versioned shim function 'torch_call_dispatcher' is not wrapped in a TORCH_FEATURE_VERSION block. This function requires: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 | // #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 | // #else 269 | // TORCH_ERROR_CODE_CHECK( ``` 2. Changing the first line to say #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_11_0 Doesn't error because this is still valid! 3. Change that line to #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 ``` Error (STABLE_SHIM_USAGE) insufficient-version-for-shim-call Call to 'torch_call_dispatcher' is wrapped in TORCH_VERSION_2_9_0, but this function requires at least TORCH_VERSION_2_10_0. The version guard must be at least the required version: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 |#if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 |#else 269 | TORCH_ERROR_CODE_CHECK( ``` 4. Nested ifdefs ``` #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // We expect this to be the stable version of the clone op. We will // add optional memory_format kwarg support in the future. inline torch::stable::Tensor clone(const torch::stable::Tensor& self) { const auto num_args = 2; std::array<StableIValue, num_args> stack{ torch::stable::detail::from(self), torch::stable::detail::from(std::nullopt)}; #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 #endif #ifdef FOO TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); #else TORCH_ERROR_CODE_CHECK( aoti_torch_call_dispatcher("aten::clone", "", stack.data())); #endif return torch::stable::detail::to<torch::stable::Tensor>(stack[0]); } #endif ``` No error! [ghstack-poisoned]
… torch/csrc/stable/c/shim.h" This PR ensures that files in `torch/csrc/stable` that include from `torch/csrc/stable/shim.h` properly gate calls to the stable shim APIs with the appropriate `TORCH_FEATURE_VERSION` macros ### Examples 1. Commenting out the version guard in https://github.com/pytorch/pytorch/blob/a64c7d740428010d700b4bcd395af8a7b2d5c21f/torch/csrc/stable/ops.h#L265-L271 ``` Error (STABLE_SHIM_USAGE) unversioned-shim-call Call to versioned shim function 'torch_call_dispatcher' is not wrapped in a TORCH_FEATURE_VERSION block. This function requires: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 | // #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 | // #else 269 | // TORCH_ERROR_CODE_CHECK( ``` 2. Changing the first line to say #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_11_0 Doesn't error because this is still valid! 3. Change that line to #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 ``` Error (STABLE_SHIM_USAGE) insufficient-version-for-shim-call Call to 'torch_call_dispatcher' is wrapped in TORCH_VERSION_2_9_0, but this function requires at least TORCH_VERSION_2_10_0. The version guard must be at least the required version: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 |#if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 |#else 269 | TORCH_ERROR_CODE_CHECK( ``` 4. Nested ifdefs ``` #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // We expect this to be the stable version of the clone op. We will // add optional memory_format kwarg support in the future. inline torch::stable::Tensor clone(const torch::stable::Tensor& self) { const auto num_args = 2; std::array<StableIValue, num_args> stack{ torch::stable::detail::from(self), torch::stable::detail::from(std::nullopt)}; #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 #endif #ifdef FOO TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); #else TORCH_ERROR_CODE_CHECK( aoti_torch_call_dispatcher("aten::clone", "", stack.data())); #endif return torch::stable::detail::to<torch::stable::Tensor>(stack[0]); } #endif ``` No error! [ghstack-poisoned]
… torch/csrc/stable/c/shim.h" This PR ensures that files in `torch/csrc/stable` that include from `torch/csrc/stable/shim.h` properly gate calls to the stable shim APIs with the appropriate `TORCH_FEATURE_VERSION` macros ### Examples 1. Commenting out the version guard in https://github.com/pytorch/pytorch/blob/a64c7d740428010d700b4bcd395af8a7b2d5c21f/torch/csrc/stable/ops.h#L265-L271 ``` Error (STABLE_SHIM_USAGE) unversioned-shim-call Call to versioned shim function 'torch_call_dispatcher' is not wrapped in a TORCH_FEATURE_VERSION block. This function requires: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 | // #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 | // #else 269 | // TORCH_ERROR_CODE_CHECK( ``` 2. Changing the first line to say #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_11_0 Doesn't error because this is still valid! 3. Change that line to #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 ``` Error (STABLE_SHIM_USAGE) insufficient-version-for-shim-call Call to 'torch_call_dispatcher' is wrapped in TORCH_VERSION_2_9_0, but this function requires at least TORCH_VERSION_2_10_0. The version guard must be at least the required version: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 |#if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 |#else 269 | TORCH_ERROR_CODE_CHECK( ``` 4. Nested ifdefs ``` #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // We expect this to be the stable version of the clone op. We will // add optional memory_format kwarg support in the future. inline torch::stable::Tensor clone(const torch::stable::Tensor& self) { const auto num_args = 2; std::array<StableIValue, num_args> stack{ torch::stable::detail::from(self), torch::stable::detail::from(std::nullopt)}; #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 #endif #ifdef FOO TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); #else TORCH_ERROR_CODE_CHECK( aoti_torch_call_dispatcher("aten::clone", "", stack.data())); #endif return torch::stable::detail::to<torch::stable::Tensor>(stack[0]); } #endif ``` No error! [ghstack-poisoned]
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 jobs have failed, first few of them are: docker-builds / docker-build (linux.12xlarge, pytorch-linux-noble-rocm-nightly-py3) Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 1 checks: docker-builds / docker-build (linux.12xlarge, pytorch-linux-noble-rocm-nightly-py3) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 jobs have failed, first few of them are: docker-builds / docker-build (linux.12xlarge, pytorch-linux-jammy-cuda13.0-cudnn9-py3-gcc11-inductor-benchmarks) Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 2 checks: docker-builds / docker-build (linux.12xlarge, pytorch-linux-jammy-cuda13.0-cudnn9-py3-gcc11-inductor-benchmarks), docker-builds / docker-build (linux.12xlarge, pytorch-linux-noble-rocm-nightly-py3) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 jobs have failed, first few of them are: linux-aarch64 / linux-jammy-aarch64-py3.10 / test (openreg, 1, 1, linux.arm64.m8g.4xlarge) Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 3 checks: docker-builds / docker-build (linux.12xlarge, pytorch-linux-jammy-cuda13.0-cudnn9-py3-gcc11-inductor-benchmarks), docker-builds / docker-build (linux.12xlarge, pytorch-linux-noble-rocm-nightly-py3), linux-aarch64 / linux-jammy-aarch64-py3.10 / test (openreg, 1, 1, linux.arm64.m8g.4xlarge) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…/stable/c/shim.h (pytorch#166996) This PR ensures that files in `torch/csrc/stable` that include from `torch/csrc/stable/shim.h` properly gate calls to the stable shim APIs with the appropriate `TORCH_FEATURE_VERSION` macros ### Examples 1. Commenting out the version guard in https://github.com/pytorch/pytorch/blob/a64c7d740428010d700b4bcd395af8a7b2d5c21f/torch/csrc/stable/ops.h#L265-L271 ``` Error (STABLE_SHIM_USAGE) unversioned-shim-call Call to versioned shim function 'torch_call_dispatcher' is not wrapped in a TORCH_FEATURE_VERSION block. This function requires: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 | // #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 | // #else 269 | // TORCH_ERROR_CODE_CHECK( ``` 2. Changing the first line to say #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_11_0 Doesn't error because this is still valid! 3. Change that line to #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 ``` Error (STABLE_SHIM_USAGE) insufficient-version-for-shim-call Call to 'torch_call_dispatcher' is wrapped in TORCH_VERSION_2_9_0, but this function requires at least TORCH_VERSION_2_10_0. The version guard must be at least the required version: #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // ... your code calling torch_call_dispatcher ... #endif // TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 263 | torch::stable::detail::from(self), 264 | torch::stable::detail::from(std::nullopt)}; 265 |#if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_9_0 >>> 266 | TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( 267 | "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); 268 |#else 269 | TORCH_ERROR_CODE_CHECK( ``` 4. Nested ifdefs ``` #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 // We expect this to be the stable version of the clone op. We will // add optional memory_format kwarg support in the future. inline torch::stable::Tensor clone(const torch::stable::Tensor& self) { const auto num_args = 2; std::array<StableIValue, num_args> stack{ torch::stable::detail::from(self), torch::stable::detail::from(std::nullopt)}; #if TORCH_FEATURE_VERSION >= TORCH_VERSION_2_10_0 #endif #ifdef FOO TORCH_ERROR_CODE_CHECK(torch_call_dispatcher( "aten::clone", "", stack.data(), TORCH_ABI_VERSION)); #else TORCH_ERROR_CODE_CHECK( aoti_torch_call_dispatcher("aten::clone", "", stack.data())); #endif return torch::stable::detail::to<torch::stable::Tensor>(stack[0]); } #endif ``` No error! Pull Request resolved: pytorch#166996 Approved by: https://github.com/janeyx99 ghstack dependencies: pytorch#166995
This PR ensures that files in
torch/csrc/stablethat include fromtorch/csrc/stable/shim.hproperly gate calls to the stable shim APIs with the appropriateTORCH_FEATURE_VERSIONmacrosExamples
pytorch/torch/csrc/stable/ops.h
Lines 265 to 271 in a64c7d7
Doesn't error because this is still valid!
No error!
Stack from ghstack (oldest at bottom):