Repository navigation
Count tensor variables at the source level in the test helper - #396
Merged
Merged
Conversation
`TestTensorflow2Model`'s `test(...)` helper counted tensor variables by distinct `(CGNode, vn)` pair, so under k-CFA the same source-level IR variable appeared once per calling context and the expected count was coupled to the context-sensitivity depth. Switch the count to distinct value numbers, deduplicated across contexts (wala#371, Option 2). This makes the count axis consistent with the helper's type assertion, which already unions per value number across contexts, and with the downstream consumer (`@tf.function(input_signature=...)`), which is indexed by source-level parameter position. Context multiplicity is analysis bookkeeping, not a source-level property, so the count no longer shifts when the targeted k-CFA depth changes. Re-baseline the 13 affected counts to their source-level totals; `testNeuralNetwork2` (10 to 5) and `testNeuralNetwork4` (14 to 7) now land exactly on the rule-based counts their Javadocs document. Update the per-test count prose and the helper Javadoc accordingly. Closes wala#371. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_017edqsk5QRAvD2QebWZiysP
There was a problem hiding this comment.
Pull request overview
Updates TestTensorflow2Model’s test(...) helper so tensor-variable counts are computed at the source level (distinct SSA value numbers per function), deduplicated across k-CFA calling contexts. This makes expected counts stable across context-sensitivity depth and aligns the count axis with the existing per-parameter type union semantics.
Changes:
- Change the helper’s count check from “# of
(CGNode, vn)-backedTensorVariableentries” to “# of distinctvns for the function signature”. - Re-baseline affected expected counts in tests to the new source-level totals and update the associated explanatory prose/Javadocs.
- Document the new source-level semantics in the core helper Javadoc and inline comment near the assertion.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #396 +/- ##
=========================================
Coverage 72.02% 72.02%
Complexity 2879 2879
=========================================
Files 274 274
Lines 20949 20951 +2
Branches 3456 3456
=========================================
+ Hits 15089 15091 +2
Misses 4462 4462
Partials 1398 1398 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
What
Counts tensor variables at the source level in
TestTensorflow2Model'stest(...)helper: one per distinct value number, deduplicated across calling contexts, instead of one per(CGNode, vn)pair. This resolves wala#371 in favor of Option 2.Why
Under k-CFA the same source-level IR variable (same
vnin the same method) appears once per calling context, so the old(CGNode, vn)count coupled every expected count to the context-sensitivity depth. Two things make source-level counting the right semantics:@tf.function(input_signature=...), is indexed by source-level parameter position. Context multiplicity is analysis bookkeeping the consumer never sees.A concrete demonstration of the coupling: changing only the targeted k-CFA depth (2 to 4) on
neural_network.pyshifts the old counts (testNeuralNetworkwas 24) without changing the source structure. Under source-level counting the count is stable across depth, and depth correctly affects only the per-parameter type union.Changes
test(...)helper: count distinct value numbers rather than distinctTensorVariableobjects; document the semantics in the helper Javadoc.testNeuralNetwork2(10 to 5) andtestNeuralNetwork4(14 to 7) now land exactly on the rule-based counts their own Javadocs document;testAutoencoder/testAutoencoder4(22 to 11) match the "11 distinct vns" their prose already described.Testing
Full
TestTensorflow2Modelclass green (800 tests, 0 failures). The change is confined to this test class (thetest(...)helper lives only here; no production or front-end code changed), so sibling modules are unaffected; CI runs the full multi-module suite.🤖 Generated with Claude Code
https://claude.ai/code/session_017edqsk5QRAvD2QebWZiysP