Remove dead code#2256
Open
ricardoV94 wants to merge 18 commits into
Open
Conversation
The except branch reached into the caller's frame locals to print a validation-failure message. It was a no-op for every in-tree caller and the real message comes from replace_all_validate.
The class-level gxx_support_openmp cache already disables OpenMP on every op when the compiler lacks support, so the global write was redundant.
The 'Sum of all printed profiles at exit' path referenced a nonexistent attribute and called .items() on a string, so it raised whenever more than one profile was summed; it never worked.
Delete the dead 'traverse' helper (only its GPU branch did anything, and nothing called it) and the unreachable gpudata else-branches in perform; scan outputs are always TensorVariable (asserted in make_thunk).
No Type overrode filter_inplace; it only ever raised NotImplementedError, so Container.__set__ raised and caught it on every container value set (e.g. shared.set_value) before falling back to filter. Call filter directly.
gcc_llvm() had no callers (along with its GCCLLVMType typing scaffold); EXT_SUFFIX is always present on supported Python versions, so the 'SO' fallback in _get_ext_suffix is dead. PyPy branch left untouched.
Delete unused scalar helpers (int_out_nocomplex, float_out_nocomplex, unary_out_lookup, as_common_dtype, Cast.clone_float32 from the old float16/GPU codegen protocol) and the dead printing trio (var_descriptor/position_independent_str/hex_digest), which only called each other and were referenced nowhere.
Neither was wired up: _warn_default (the only reader of warn__ignore_bug_before) had no callers, metaopt__verbose was never registered, and the cast_policy 'numpy' branch was unreachable since that enum value is disabled. Drop the helpers, annotations, the dead cast branch, and the stale docs.
They were deprecated in July 2024 (gh pymc-devs#748) and have no in-repo callers; drop the end/steps parameters, the _check_deprecated_inputs helper, and the related docstrings/tests.
register() cleared self.cached_default_query (a junk attribute) instead of self._cached_default_query, so rewrites registered after the first default_query access were silently dropped from the cached query.
The >32-operand guard called the no-op super().perform() without returning, so execution fell through to the ufunc path that segfaults or raises with that many operands. Raise NotImplementedError instead.
fast_run_linkers_to_mode['vm'] wrapped the Mode in a 1-tuple, so
get_mode('FAST_RUN') with linker=vm returned a tuple.
It was defined as 'fiter_variable', so the base Type.filter_variable ran instead of the intended guard that rejects assigning to a DisconnectedType.
The second isinstance check used 'if' instead of 'elif', so an OpPattern (already handled) also fell into the tracked_instances branch.
print(..., file=destination_file) passed the destination string instead of the open file handle f.
is_same_graph ran two graph-comparison implementations (a deepcopy + MergeOptimizer path and equal_computations) and asserted they agree, with a docstring noting one should eventually be dropped. It was test-only; replace its call sites with equal_computations and delete the function, its merge-based twin, and the dedicated TestIsSameGraph tests.
full_tree was documented 'Used for debugging only' and read solely by a commented-out debug block; drop the parameter and the dead block.
local_Unique_Alloc_lift/Repeat_lift/second were structurally identical (same flag bail-out + make_node/as_tensor tail), differing only in the producer op checked and which input to unwrap. Merge into local_Unique_lift and update the test rewrite-name references.
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.
I told the bots to grab a mop and get to work, then walked with it through all the "findings". This is what we ended up with: