Skip to content

Count tensor variables at the source level in the test helper - #396

Merged
khatchad merged 1 commit into
masterfrom
371-source-level-tensor-variable-count
Jun 18, 2026
Merged

khatchad merged 1 commit into
masterfrom
371-source-level-tensor-variable-count

Conversation

@khatchad

Copy link
Copy Markdown
Member

What

Counts tensor variables at the source level in TestTensorflow2Model's test(...) 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 vn in 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:

  • Internal consistency. The helper's type assertion already unions per value number across contexts (the source-level framing on the type axis). The count axis was the last place still measuring context multiplicity.
  • Consumer alignment. The downstream consumer, @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.py shifts the old counts (testNeuralNetwork was 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 distinct TensorVariable objects; document the semantics in the helper Javadoc.
  • 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 own Javadocs document; testAutoencoder/testAutoencoder4 (22 to 11) match the "11 distinct vns" their prose already described.
  • Update each affected test's count prose to reflect source-level counting.

Testing

Full TestTensorflow2Model class green (800 tests, 0 failures). The change is confined to this test class (the test(...) 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

`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
Copilot AI review requested due to automatic review settings June 18, 2026 02:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)-backed TensorVariable entries” to “# of distinct vns 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

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.02%. Comparing base (5011312) to head (f150560).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@khatchad
khatchad added this pull request to the merge queue Jun 18, 2026
Merged via the queue into master with commit 8c4e3dd Jun 18, 2026
14 checks passed
@khatchad
khatchad deleted the 371-source-level-tensor-variable-count branch June 18, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tensor variable count semantics under k-CFA context sensitivity

2 participants