# Creates a graph.
x = 2
y = 3
with tf.device('/cpu:1'):
add_op = tf.add(x, y,)
mul_op = tf.multiply(x, y)
pow_op = tf.pow(add_op, mul_op)
with tf.device('/cpu:2'):
useless = tf.multiply(x, add_op)
with tf.Session() as sess:
# Creates a session with allow_soft_placement and log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(
allow_soft_placement=True, log_device_placement=True))
z, not_useless = sess.run([pow_op, useless])
print(z)
print(not_useless)