op_test.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import tensorflow as tf
  2. import numpy as np
  3. from IPython import embed
  4. import sys
  5. sys.path.append('../hostLib/')
  6. from hostLib.layers.conv2d import Conv2D as Conv2DFPGA
  7. from hostLib import load_op
  8. class FPGALibTest(tf.test.TestCase):
  9. def testDummyOp(self):
  10. input = [1337, 42, 2**31-1, -1]
  11. with self.session():
  12. result = load_op.op_lib.MyDummy(input=input)
  13. self.assertAllEqual(result, input)
  14. def testDummyOp100(self):
  15. with self.session():
  16. for i in range(100):
  17. input = [i+1, 42, 2**31-1, -1]
  18. result = load_op.op_lib.MyDummy(input=input)
  19. self.assertAllEqual(result, input)
  20. def testDummyOpBig(self):
  21. input = [i+1 for i in range(1024)]
  22. with self.session():
  23. result = load_op.op_lib.MyDummyBig(input=input)
  24. self.assertAllEqual(result, input)
  25. def testDummyOpBig100(self):
  26. with self.session():
  27. for i in range(100):
  28. input = [i*100+k+1 for k in range(1024)]
  29. result = load_op.op_lib.MyDummyBig(input=input)
  30. self.assertAllEqual(result, input)
  31. if __name__ == "__main__":
  32. tf.test.main()