Push metadata about a context switch onto the stack. A context switch can take any one of the two forms: installing a graph as the default graph, or entering the eager context. For each context switch, we record whether or not the entered context is building a function. Args:
(self, is_building_function, enter_context_fn, device_stack)
| 212 | device_stack=None) |
| 213 | |
| 214 | def push(self, is_building_function, enter_context_fn, device_stack): |
| 215 | """Push metadata about a context switch onto the stack. |
| 216 | |
| 217 | A context switch can take any one of the two forms: installing a graph as |
| 218 | the default graph, or entering the eager context. For each context switch, |
| 219 | we record whether or not the entered context is building a function. |
| 220 | |
| 221 | Args: |
| 222 | is_building_function: (bool.) Whether the context is building a function. |
| 223 | enter_context_fn: (function.) A callable that executes the context switch. |
| 224 | For example, `graph.as_default` or `eager_mode`. |
| 225 | device_stack: If applicable, the device function stack for this |
| 226 | graph. When breaking out of graphs in init_scope, the innermost nonempty |
| 227 | device stack is used. Eager contexts put `None` here and the value is |
| 228 | never used. |
| 229 | """ |
| 230 | |
| 231 | self.stack.append( |
| 232 | ContextSwitch(is_building_function, enter_context_fn, device_stack)) |
| 233 | |
| 234 | def pop(self): |
| 235 | """Pop the stack.""" |
no test coverage detected