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

Function device_v2

tensorflow/python/framework/ops.py:5211–5240  ·  view source on GitHub ↗

Specifies the device for ops created/executed in this context. `device_name` can be fully specified, as in "/job:worker/task:1/device:cpu:0", or partially specified, containing only a subset of the "/"-separated fields. Any fields which are specified override device annotations from outer s

(device_name)

Source from the content-addressed store, hash-verified

5209
5210@tf_export("device", v1=[])
5211def device_v2(device_name):
5212 """Specifies the device for ops created/executed in this context.
5213
5214 `device_name` can be fully specified, as in "/job:worker/task:1/device:cpu:0",
5215 or partially specified, containing only a subset of the "/"-separated
5216 fields. Any fields which are specified override device annotations from outer
5217 scopes. For example:
5218
5219 ```python
5220 with tf.device('/job:foo'):
5221 # ops created here have devices with /job:foo
5222 with tf.device('/job:bar/task:0/device:gpu:2'):
5223 # ops created here have the fully specified device above
5224 with tf.device('/device:gpu:1'):
5225 # ops created here have the device '/job:foo/device:gpu:1'
5226 ```
5227
5228 Args:
5229 device_name: The device name to use in the context.
5230
5231 Returns:
5232 A context manager that specifies the default device to use for newly
5233 created ops.
5234
5235 Raises:
5236 RuntimeError: If a function is passed in.
5237 """
5238 if callable(device_name):
5239 raise RuntimeError("tf.device does not support functions.")
5240 return device(device_name)
5241
5242@tf_export(v1=["stream"])
5243def stream(stream_idx=0):

Callers

nothing calls this directly

Calls 1

deviceFunction · 0.70

Tested by

no test coverage detected