PR #124233
tensorflow/tensorflow · Core · Approved · 2 files changed
Training optimizer kernels lacked dtype validation against the locked resource variable, risking silent type mismatches before kernel dispatch. I added explicit dtype checks in training_op_helpers.h.
Checkout Pull Request
Inspect the full commit history and diff locally from upstream tensorflow/tensorflow.
$gh pr checkout 124233 --repo tensorflow/tensorflowTraining optimizer kernels lacked dtype validation against the locked resource variable, risking silent type mismatches before kernel dispatch. I added explicit dtype checks in training_op_helpers.h.
File-by-File Modification Breakdown (2)
- +24 / -4
tensorflow/core/kernels/training_op_helpers.h
Core C++ Eigen kernel implementation and boundary guards
- +15 / -0
tensorflow/python/training/training_ops_test.py
Python/XLA regression test suite verifying edge-case behavior
Changed Files (2)
1. Introduction & Motivation
In TensorFlow's C++ training kernels, optimizer updates mutate Var resource buffers directly in memory. If a caller supplies gradient or learning-rate tensors whose DataType differs from the underlying resource variable's stored dtype, missing validation can cause silent data corruption or undefined kernel behavior.
2. Type-Safety Invariant
First-order optimizer steps compute in-place updates of the form:
Sound in-place memory updates require strict dtype equivalence across the locked resource buffer and every input tensor:
3. References
- TensorFlow Core Runtime Architecture,
ResourceMgr&VarLocking Semantics in Training Kernels.