Add `val` to the current context and its outer context recursively.
(self, val)
| 492 | self._outer_context.AddInnerOp(op) |
| 493 | |
| 494 | def AddValue(self, val): |
| 495 | """Add `val` to the current context and its outer context recursively.""" |
| 496 | if val.name in self._values: |
| 497 | # Use the real value if it comes from outer context. |
| 498 | result = self._external_values.get(val.name) |
| 499 | return val if result is None else result |
| 500 | |
| 501 | result = val |
| 502 | self._values.add(val.name) |
| 503 | if self._outer_context: |
| 504 | result = self._outer_context.AddValue(val) |
| 505 | self._values.add(result.name) |
| 506 | |
| 507 | self._external_values[val.name] = result |
| 508 | |
| 509 | return result |
| 510 | |
| 511 | def AddInnerOp(self, op): |
| 512 | self.AddOp(op) |