-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
32 lines (23 loc) · 816 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import tensorflow as tf
from tensorflow.python.framework import ops
import numpy as np
try:
_tutorial = tf.load_op_library('./build/libtutorial.so')
except Exception as e:
_tutorial = tf.load_op_library('./libtutorial.so')
custom_add = _tutorial.custom_add
shape = (1,1000,1000,30)
a_data = np.random.random(shape)
b_data = np.random.random(shape)
a = tf.placeholder(tf.float32, shape=shape, name="a")
b = tf.placeholder(tf.float32, shape=shape, name="b")
c_cust = custom_add(a,b)
print(c_cust)
c = a + b
config = tf.ConfigProto(log_device_placement = True)
config.graph_options.optimizer_options.opt_level = -1
with tf.Session(config=config) as sess:
feed = {a: a_data, b: b_data}
expected = sess.run(c, feed_dict=feed)
result = sess.run(c_cust, feed_dict=feed)
print(np.array_equal(expected,result))