Creates or finds a child frame, and makes `data` available to it. The unique `frame_name` is used by the `Executor` to identify frames. If `is_constant` is true, `data` is a constant in the child frame; otherwise it may be changed in the child frame. At most `parallel_iterations` iterations
(data,
frame_name,
is_constant=False,
parallel_iterations=10,
use_ref=True,
use_input_shape=True,
name=None)
| 212 | |
| 213 | |
| 214 | def _Enter(data, |
| 215 | frame_name, |
| 216 | is_constant=False, |
| 217 | parallel_iterations=10, |
| 218 | use_ref=True, |
| 219 | use_input_shape=True, |
| 220 | name=None): |
| 221 | """Creates or finds a child frame, and makes `data` available to it. |
| 222 | |
| 223 | The unique `frame_name` is used by the `Executor` to identify frames. If |
| 224 | `is_constant` is true, `data` is a constant in the child frame; otherwise |
| 225 | it may be changed in the child frame. At most `parallel_iterations` |
| 226 | iterations are run in parallel in the child frame. |
| 227 | |
| 228 | Args: |
| 229 | data: The tensor to be made available to the child frame. |
| 230 | frame_name: The name of the child frame. |
| 231 | is_constant: If true, the output is constant within the child frame. |
| 232 | parallel_iterations: The number of iterations allowed to run in parallel. |
| 233 | use_ref: If true, use ref_enter if data is of ref type. |
| 234 | use_input_shape: If true, set the result's shape based on data's shape. |
| 235 | name: A name for this operation (optional). |
| 236 | |
| 237 | Returns: |
| 238 | The same tensor as `data`. |
| 239 | """ |
| 240 | data = ops.internal_convert_to_tensor_or_composite(data, as_ref=True) |
| 241 | if isinstance(data, ops.Tensor): |
| 242 | if data.dtype._is_ref_dtype and use_ref: # pylint: disable=protected-access |
| 243 | result = gen_control_flow_ops.ref_enter( |
| 244 | data, frame_name, is_constant, parallel_iterations, name=name) |
| 245 | else: |
| 246 | result = gen_control_flow_ops.enter( |
| 247 | data, frame_name, is_constant, parallel_iterations, name=name) |
| 248 | if use_input_shape: |
| 249 | result.set_shape(data.get_shape()) |
| 250 | return result |
| 251 | elif isinstance(data, composite_tensor.CompositeTensor): |
| 252 | |
| 253 | def enter_component(t): |
| 254 | return _Enter(t, frame_name, is_constant, parallel_iterations, use_ref, |
| 255 | use_input_shape) |
| 256 | |
| 257 | return nest.map_structure(enter_component, data, expand_composites=True) |
| 258 | else: |
| 259 | raise TypeError("Type %s not supported" % type(data)) |
| 260 | |
| 261 | |
| 262 | def exit(data, name=None): # pylint: disable=redefined-builtin |
no test coverage detected