(self, optimizer, g)
| 139 | return self._v._ref() # pylint: disable=protected-access |
| 140 | |
| 141 | def update_op(self, optimizer, g): |
| 142 | if isinstance(g, ops.Tensor): |
| 143 | update_op = optimizer._apply_dense(g, self._v) # pylint: disable=protected-access |
| 144 | if self._v.constraint is not None: |
| 145 | with ops.control_dependencies([update_op]): |
| 146 | return self._v.assign(self._v.constraint(self._v)) |
| 147 | else: |
| 148 | return update_op |
| 149 | else: |
| 150 | assert isinstance(g, ops.IndexedSlices), ("Gradient ", g, " is neither a " |
| 151 | "tensor nor IndexedSlices.") |
| 152 | if self._v.constraint is not None: |
| 153 | raise RuntimeError( |
| 154 | "Cannot use a constraint function on a sparse variable.") |
| 155 | # pylint: disable=protected-access |
| 156 | return optimizer._apply_sparse_duplicate_indices(g, self._v) |
| 157 | |
| 158 | |
| 159 | class _DenseReadResourceVariableProcessor(_OptimizableVariable): |
nothing calls this directly
no test coverage detected