Skip to content

Commit dfdcd0b

Browse files
Luke Iwanskirmlarsen
authored andcommitted
[OpenCL] Extends matmul_benchmark.py to cover SYCL (#11697)
* [OpenCL] Extends matmul_benchmark.py to cover SYCL * Fixed typo * /gpu:0 -> /device:GPU:0 * Fixes control_flow_ops_py_test * /gpu: -> /device:GPU: * Fixes //tensorflow/python/profiler/internal:run_metadata_test * gpu: -> GPU: * Fixes tfprof_node * [OpenCL] Fixes device path to name with many colons (#123) The device path is constructed from a device name by replacing all colons with underscores. Some device names contain more than one colon, for example 'device:SYCL:0' which gives a path 'device_SYCL_0'. The previous code would not convert this back to the original device name, but rather to 'device:SYCL_0'. An alternative fix would be to convert all underscores to colons in the device name (i.e. remove the restriction inside `replace("_", ":", 1)`), however I'm not sure if there are any device names which contain underscores. * If no gpu device aviable fake one * gpu: -> device:GPU * Fixes profiler test * /gpu:x -> /device:GPU:x * Fixes debug_io_utils_test.cc test * Fixes device_name_utils_test.cc
1 parent da573b9 commit dfdcd0b

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

api_guides/python/contrib.seq2seq.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ other wrappers and the dynamic decoder described below. For example, one can
7373
write:
7474

7575
```python
76-
cell = tf.contrib.rnn.DeviceWrapper(LSTMCell(512), "/gpu:0")
76+
cell = tf.contrib.rnn.DeviceWrapper(LSTMCell(512), "/device:GPU:0")
7777
attention_mechanism = tf.contrib.seq2seq.LuongAttention(512, encoder_outputs)
7878
attn_cell = tf.contrib.seq2seq.AttentionWrapper(
7979
cell, attention_mechanism, attention_size=256)
80-
attn_cell = tf.contrib.rnn.DeviceWrapper(attn_cell, "/gpu:1")
81-
top_cell = tf.contrib.rnn.DeviceWrapper(LSTMCell(512), "/gpu:1")
80+
attn_cell = tf.contrib.rnn.DeviceWrapper(attn_cell, "/device:GPU:1")
81+
top_cell = tf.contrib.rnn.DeviceWrapper(LSTMCell(512), "/device:GPU:1")
8282
multi_cell = MultiRNNCell([attn_cell, top_cell])
8383
```
8484

programmers_guide/variables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ devices. For example, the following snippet creates a variable named `v` and
110110
places it on the second GPU device:
111111

112112
``` python
113-
with tf.device("/gpu:1"):
113+
with tf.device("/device:GPU:1"):
114114
v = tf.get_variable("v", [1])
115115
```
116116

tutorials/deep_cnn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ the first tower are prepended with `tower_0`, e.g. `tower_0/conv1/Conv2D`.
411411

412412
* A preferred hardware device to run the operation within a tower.
413413
@{tf.device} specifies this. For
414-
instance, all operations in the first tower reside within `device('/gpu:0')`
414+
instance, all operations in the first tower reside within `device('/device:GPU:0')`
415415
scope indicating that they should be run on the first GPU.
416416

417417
All variables are pinned to the CPU and accessed via

tutorials/using_gpu.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ supported device types are `CPU` and `GPU`. They are represented as `strings`.
77
For example:
88

99
* `"/cpu:0"`: The CPU of your machine.
10-
* `"/gpu:0"`: The GPU of your machine, if you have one.
11-
* `"/gpu:1"`: The second GPU of your machine, etc.
10+
* `"/device:GPU:0"`: The GPU of your machine, if you have one.
11+
* `"/device:GPU:1"`: The second GPU of your machine, etc.
1212

1313
If a TensorFlow operation has both CPU and GPU implementations, the GPU devices
1414
will be given priority when the operation is assigned to a device. For example,
@@ -35,11 +35,11 @@ You should see the following output:
3535

3636
```
3737
Device mapping:
38-
/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: Tesla K40c, pci bus
38+
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: Tesla K40c, pci bus
3939
id: 0000:05:00.0
40-
b: /job:localhost/replica:0/task:0/gpu:0
41-
a: /job:localhost/replica:0/task:0/gpu:0
42-
MatMul: /job:localhost/replica:0/task:0/gpu:0
40+
b: /job:localhost/replica:0/task:0/device:GPU:0
41+
a: /job:localhost/replica:0/task:0/device:GPU:0
42+
MatMul: /job:localhost/replica:0/task:0/device:GPU:0
4343
[[ 22. 28.]
4444
[ 49. 64.]]
4545
@@ -71,11 +71,11 @@ example) and automatically copy tensors between devices if required.
7171

7272
```
7373
Device mapping:
74-
/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: Tesla K40c, pci bus
74+
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: Tesla K40c, pci bus
7575
id: 0000:05:00.0
7676
b: /job:localhost/replica:0/task:0/cpu:0
7777
a: /job:localhost/replica:0/task:0/cpu:0
78-
MatMul: /job:localhost/replica:0/task:0/gpu:0
78+
MatMul: /job:localhost/replica:0/task:0/device:GPU:0
7979
[[ 22. 28.]
8080
[ 49. 64.]]
8181
```
@@ -127,7 +127,7 @@ to specify the preference explicitly:
127127

128128
```python
129129
# Creates a graph.
130-
with tf.device('/gpu:2'):
130+
with tf.device('/device:GPU:2'):
131131
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
132132
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
133133
c = tf.matmul(a, b)
@@ -142,9 +142,9 @@ If the device you have specified does not exist, you will get
142142

143143
```
144144
InvalidArgumentError: Invalid argument: Cannot assign a device to node 'b':
145-
Could not satisfy explicit device specification '/gpu:2'
145+
Could not satisfy explicit device specification '/device:GPU:2'
146146
[[Node: b = Const[dtype=DT_FLOAT, value=Tensor<type: float shape: [3,2]
147-
values: 1 2 3...>, _device="/gpu:2"]()]]
147+
values: 1 2 3...>, _device="/device:GPU:2"]()]]
148148
```
149149

150150
If you would like TensorFlow to automatically choose an existing and supported
@@ -154,7 +154,7 @@ the session.
154154

155155
```python
156156
# Creates a graph.
157-
with tf.device('/gpu:2'):
157+
with tf.device('/device:GPU:2'):
158158
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
159159
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
160160
c = tf.matmul(a, b)
@@ -175,7 +175,7 @@ For example:
175175
```
176176
# Creates a graph.
177177
c = []
178-
for d in ['/gpu:2', '/gpu:3']:
178+
for d in ['/device:GPU:2', '/device:GPU:3']:
179179
with tf.device(d):
180180
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3])
181181
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2])
@@ -192,20 +192,20 @@ You will see the following output.
192192

193193
```
194194
Device mapping:
195-
/job:localhost/replica:0/task:0/gpu:0 -> device: 0, name: Tesla K20m, pci bus
195+
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: Tesla K20m, pci bus
196196
id: 0000:02:00.0
197-
/job:localhost/replica:0/task:0/gpu:1 -> device: 1, name: Tesla K20m, pci bus
197+
/job:localhost/replica:0/task:0/device:GPU:1 -> device: 1, name: Tesla K20m, pci bus
198198
id: 0000:03:00.0
199-
/job:localhost/replica:0/task:0/gpu:2 -> device: 2, name: Tesla K20m, pci bus
199+
/job:localhost/replica:0/task:0/device:GPU:2 -> device: 2, name: Tesla K20m, pci bus
200200
id: 0000:83:00.0
201-
/job:localhost/replica:0/task:0/gpu:3 -> device: 3, name: Tesla K20m, pci bus
201+
/job:localhost/replica:0/task:0/device:GPU:3 -> device: 3, name: Tesla K20m, pci bus
202202
id: 0000:84:00.0
203-
Const_3: /job:localhost/replica:0/task:0/gpu:3
204-
Const_2: /job:localhost/replica:0/task:0/gpu:3
205-
MatMul_1: /job:localhost/replica:0/task:0/gpu:3
206-
Const_1: /job:localhost/replica:0/task:0/gpu:2
207-
Const: /job:localhost/replica:0/task:0/gpu:2
208-
MatMul: /job:localhost/replica:0/task:0/gpu:2
203+
Const_3: /job:localhost/replica:0/task:0/device:GPU:3
204+
Const_2: /job:localhost/replica:0/task:0/device:GPU:3
205+
MatMul_1: /job:localhost/replica:0/task:0/device:GPU:3
206+
Const_1: /job:localhost/replica:0/task:0/device:GPU:2
207+
Const: /job:localhost/replica:0/task:0/device:GPU:2
208+
MatMul: /job:localhost/replica:0/task:0/device:GPU:2
209209
AddN: /job:localhost/replica:0/task:0/cpu:0
210210
[[ 44. 56.]
211211
[ 98. 128.]]

0 commit comments

Comments
 (0)