Add `val` to the current context and its outer context recursively.
(self, val)
| 254 | self._outer_context.AddInnerOp(op) |
| 255 | |
| 256 | def AddValue(self, val): |
| 257 | """Add `val` to the current context and its outer context recursively.""" |
| 258 | if val.name in self._values: |
| 259 | # Use the real value if it comes from outer context. |
| 260 | result = self._external_values.get(val.name) |
| 261 | return val if result is None else result |
| 262 | |
| 263 | result = val |
| 264 | self._values.add(val.name) |
| 265 | if self._outer_context: |
| 266 | result = self._outer_context.AddValue(val) |
| 267 | self._values.add(result.name) |
| 268 | |
| 269 | self._external_values[val.name] = result |
| 270 | |
| 271 | return result |
| 272 | |
| 273 | def AddInnerOp(self, op): |
| 274 | self.AddOp(op) |