fix(tf): initialize NVNMD map outputs#5847
Conversation
Correct the MapFltNvnmd four-input contract, validate its table metadata, and zero outputs that fall outside every mapping interval. Cover deterministic allocator reuse, gradient behavior, and malformed table-gradient shapes. Coding-Agent: Codex Codex-Version: codex-cli 0.144.4 Model: gpt-5.6-sol Reasoning-Effort: xhigh
📝 WalkthroughWalkthrough
ChangesMapFltNvnmd runtime behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
source/op/tf/map_flt_nvnmd.cc (1)
117-134: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueInterval metadata is parsed twice (validation loop here, then again in the main
ssloop below).Correctness looks solid —
n0>=0 && n1<=shT.dim_size(0)prevents the OOB table read, anddx>0/n1>n0avoid divide-by-zero and negative clamp indices. As an optional cleanup, consider extracting a small helper (e.g. astruct Interval { x0,x1,dx; int n0,n1; }parsed once perss) so the same five floats aren't decoded frominfoin two separate loops.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@source/op/tf/map_flt_nvnmd.cc` around lines 117 - 134, Extract the repeated interval metadata decoding into a small reusable representation, such as an Interval struct, and parse each five-value entry from info once per ss. Reuse the parsed x0, x1, dx, n0, and n1 values in both the validation loop and the main ss processing loop, preserving the existing validation and mapping behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@source/op/tf/map_flt_nvnmd.cc`:
- Around line 117-134: Extract the repeated interval metadata decoding into a
small reusable representation, such as an Interval struct, and parse each
five-value entry from info once per ss. Reuse the parsed x0, x1, dx, n0, and n1
values in both the validation loop and the main ss processing loop, preserving
the existing validation and mapping behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6ef6e5ae-b840-4092-ba06-c22e30fbfc19
📒 Files selected for processing (2)
source/op/tf/map_flt_nvnmd.ccsource/tests/tf/test_nvnmd_op.py
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5847 +/- ##
==========================================
- Coverage 78.58% 78.32% -0.27%
==========================================
Files 1050 1050
Lines 120637 120652 +15
Branches 4356 4358 +2
==========================================
- Hits 94801 94496 -305
- Misses 24278 24587 +309
- Partials 1558 1569 +11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
MapFltNvnmd's stale three-input check to its registered four-input contractWhy existing tests missed this
test_nvnmd_op.pydirectly covered the other NVNMD arithmetic primitives but notMapFltNvnmd. Normal descriptor and mapping-generation callers keep values inside generated table ranges, release builds compile out the staleDCHECK, and freshly allocated output pages often happen to contain zeros. Together those conditions hid both the invalid debug contract and skipped output writes.The regression warms a large same-shaped output with nonzero values before evaluating out-of-range inputs, making allocator reuse expose the old behavior reliably instead of depending on fresh memory contents.
Validation
cmake --build source/build --target deepmd_op -j2TestOpMapFltNvnmd(2 passed; inherited TensorFlow session helper skipped)ruff format .ruff check .--Werrorgit diff --checkFixes #5655
Coding agent: Codex
Codex version: codex-cli 0.144.4
Model: gpt-5.6-sol
Reasoning effort: xhigh
Summary by CodeRabbit
Bug Fixes
Tests