Replace deprecated AT_ERROR and AT_ASSERT macros#3979
Open
cyyever wants to merge 3 commits into
Open
Conversation
AT_ERROR becomes TORCH_CHECK(false, ...) and AT_ASSERT becomes TORCH_INTERNAL_ASSERT (or TORCH_CHECK where the upstream CUDA counterpart uses it), matching upstream where it has already modernized. Error messages and failure behavior are unchanged. Also drops two asserts that are trivially true at their call sites and folds two if + TORCH_CHECK(false, ...) blocks into single TORCH_CHECK(cond, ...) calls. Test: none (mechanical macro replacement; no behavior change) Authored with an AI assistant.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces all remaining uses of the deprecated
AT_ERRORandAT_ASSERTmacros (deprecated upstream inc10/util/Exception.h, see pytorch/pytorch#20287):AT_ERROR(...)->TORCH_CHECK(false, ...)(4 sites)AT_ASSERT(...)->TORCH_INTERNAL_ASSERT(...), orTORCH_CHECKinCopy.cppto match upstreamCopy.cu(9 sites)Each site was checked against its upstream CUDA counterpart; where upstream has already modernized (
Copy.cu,MaxUnpooling.cu,SummaryOps.cu, mklSpectralOps.cpp) the replacement matches it exactly. Where upstream still usesAT_ASSERT(Reduce.cuh,EmbeddingBag.cu,ReduceOps.cpp,AdaptiveAveragePooling.cu,SparseCUDATensorMath.cu), the documented replacementTORCH_INTERNAL_ASSERTis used instead of copying the deprecated macro; semantics are identical.Intentional divergences from upstream, beyond the macro rename:
TORCH_INTERNAL_ASSERT(grad_input_values.is_xpu())inSparseTensorMathKernels.cpp: trivially true, the tensor is created two lines above with XPU options.TORCH_INTERNAL_ASSERT(input_width > 0 && output_width > 0)inUpSampleLinear1dKernels.cpp: already enforced by the structured op meta check (upsample_1d_common_check).if (cond) { TORCH_CHECK(false, ...) }into singleTORCH_CHECK(!cond, ...)calls inSummaryOpsKernels.cppandMaxUnpoolingKernels.cpp; messages unchanged.Error messages and failure behavior are unchanged at every site.
Test: none (mechanical macro replacement; no behavior change)
Authored with an AI assistant.