MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _apply_device_functions

Method _apply_device_functions

tensorflow/python/framework/ops.py:4398–4421  ·  view source on GitHub ↗

Applies the current device function stack to the given operation.

(self, op)

Source from the content-addressed store, hash-verified

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):

Callers 5

_create_op_helperMethod · 0.95
_ProcessNewOpsFunction · 0.80
currentFunction · 0.80
_get_current_tf_deviceFunction · 0.80

Calls 4

peek_objsMethod · 0.80
string_mergeMethod · 0.80

Tested by

no test coverage detected