Skip to content

Commit

Permalink
add run_unary_op.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hughperkins committed May 10, 2017
1 parent 025b258 commit 64dde0a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tensorflow/stream_executor/cl/test/run_unary_op.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from __future__ import print_function

import tensorflow as tf
import numpy as np
import argparse


def run_op(op):
graph = tf.Graph()
with graph.as_default():
a = tf.constant([1, 3, 5, 2, 4, 7], dtype=tf.float32, shape=[2, 3], name='a')
# b = tf.constant([3, 4, 4, 6, 6, 5], dtype=tf.float32, shape=[2, 3], name='b')
c = eval('tf.%s(a, name="c")' % op)
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
with sess.as_default():
with tf.device('/gpu:0'):
print('running sess.run a')
try:
# print(sess.run(a))
print(sess.run(c))
except Exception as e:
print('exception')
print(e)
print('done')


if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--op', type=str, default='tanh')
args = parser.parse_args()
run_op(**args.__dict__)

0 comments on commit 64dde0a

Please sign in to comment.