Applies the current device function stack to the given operation.
(self, op)
| 4396 | self._device_function_stack.pop_obj() |
| 4397 | |
| 4398 | def _apply_device_functions(self, op): |
| 4399 | """Applies the current device function stack to the given operation.""" |
| 4400 | # Apply any device functions in LIFO order, so that the most recently |
| 4401 | # pushed function has the first chance to apply a device to the op. |
| 4402 | # We apply here because the result can depend on the Operation's |
| 4403 | # signature, which is computed in the Operation constructor. |
| 4404 | # pylint: disable=protected-access |
| 4405 | prior_device_string = None |
| 4406 | for device_spec in self._device_function_stack.peek_objs(): |
| 4407 | if device_spec.is_null_merge: |
| 4408 | continue |
| 4409 | |
| 4410 | if device_spec.function is None: |
| 4411 | break |
| 4412 | |
| 4413 | device_string = device_spec.string_merge(op) |
| 4414 | |
| 4415 | # Take advantage of the fact that None is a singleton and Python interns |
| 4416 | # strings, since identity checks are faster than equality checks. |
| 4417 | if device_string is not prior_device_string: |
| 4418 | op._set_device_from_string(device_string) |
| 4419 | prior_device_string = device_string |
| 4420 | op._device_code_locations = self._snapshot_device_function_stack_metadata() |
| 4421 | # pylint: enable=protected-access |
| 4422 | |
| 4423 | @tf_contextlib.contextmanager |
| 4424 | def stream(self, stream_idx=0): |
no test coverage detected