From cb5f7b3f72bd113ffa8a5179ce289e3ec90fb908 Mon Sep 17 00:00:00 2001 From: gracehoney <31743510+aaroey@users.noreply.github.com> Date: Thu, 19 Jul 2018 12:06:19 -0700 Subject: Fix python formatting issues. --- tensorflow/contrib/tensorrt/BUILD | 8 +++---- .../contrib/tensorrt/test/batch_matmul_test.py | 10 ++++---- .../contrib/tensorrt/test/biasadd_matmul_test.py | 4 ++-- .../test/binary_tensor_weight_broadcast_test.py | 28 ++++++++-------------- .../contrib/tensorrt/test/concatenation_test.py | 4 ++-- .../contrib/tensorrt/test/const_broadcast_test.py | 13 ++++------ .../test/multi_connection_neighbor_engine_test.py | 20 +++++----------- .../tensorrt/test/neighboring_engine_test.py | 12 ++++------ .../tensorrt/test/tf_trt_integration_test_base.py | 3 ++- tensorflow/contrib/tensorrt/test/unary_test.py | 5 ++-- .../contrib/tensorrt/test/vgg_block_nchw_test.py | 7 +++--- tensorflow/contrib/tensorrt/test/vgg_block_test.py | 7 +++--- 12 files changed, 47 insertions(+), 74 deletions(-) diff --git a/tensorflow/contrib/tensorrt/BUILD b/tensorflow/contrib/tensorrt/BUILD index fa47f51b66..dea9c0a4ae 100644 --- a/tensorflow/contrib/tensorrt/BUILD +++ b/tensorflow/contrib/tensorrt/BUILD @@ -337,16 +337,16 @@ cuda_py_tests( name = "tf_trt_integration_test", srcs = [ "test/base_test.py", - #"test/batch_matmul_test.py", - #"test/biasadd_matmul_test.py", + # "test/batch_matmul_test.py", + # "test/biasadd_matmul_test.py", "test/binary_tensor_weight_broadcast_test.py", "test/concatenation_test.py", "test/const_broadcast_test.py", "test/multi_connection_neighbor_engine_test.py", "test/neighboring_engine_test.py", "test/unary_test.py", - #"test/vgg_block_nchw_test.py", - #"test/vgg_block_test.py", + # "test/vgg_block_nchw_test.py", + # "test/vgg_block_test.py", ], additional_deps = [ ":tf_trt_integration_test_base", diff --git a/tensorflow/contrib/tensorrt/test/batch_matmul_test.py b/tensorflow/contrib/tensorrt/test/batch_matmul_test.py index 163af54184..e47daae3ee 100644 --- a/tensorflow/contrib/tensorrt/test/batch_matmul_test.py +++ b/tensorflow/contrib/tensorrt/test/batch_matmul_test.py @@ -45,13 +45,10 @@ class BatchMatMulTest(trt_test.TfTrtIntegrationTestBase): with g.as_default(): inp = array_ops.placeholder( dtype=dtype, shape=[None] + input_dims[1:], name=input_name) - w1 = array_ops.placeholder( - dtype=dtype, shape=w1_dims, name=w1_name) - w2 = array_ops.placeholder( - dtype=dtype, shape=w2_dims, name=w2_name) + w1 = array_ops.placeholder(dtype=dtype, shape=w1_dims, name=w1_name) + w2 = array_ops.placeholder(dtype=dtype, shape=w2_dims, name=w2_name) with g.device("/GPU:0"): - b = constant_op.constant( - np.random.randn(12, 5, 12, 7), dtype=dtype) + b = constant_op.constant(np.random.randn(12, 5, 12, 7), dtype=dtype) c = constant_op.constant(np.random.randn(5, 1, 1), dtype=dtype) d = constant_op.constant(np.random.randn(5, 1, 1), dtype=dtype) x1 = math_ops.matmul(inp, b) @@ -74,5 +71,6 @@ class BatchMatMulTest(trt_test.TfTrtIntegrationTestBase): allclose_atol=1.e-03, allclose_rtol=1.e-03) + if __name__ == "__main__": test.main() diff --git a/tensorflow/contrib/tensorrt/test/biasadd_matmul_test.py b/tensorflow/contrib/tensorrt/test/biasadd_matmul_test.py index 9b153ada05..2de99c5d5c 100644 --- a/tensorflow/contrib/tensorrt/test/biasadd_matmul_test.py +++ b/tensorflow/contrib/tensorrt/test/biasadd_matmul_test.py @@ -40,8 +40,7 @@ class BiasaddMatMulTest(trt_test.TfTrtIntegrationTestBase): input_dims = [48, 12] g = ops.Graph() with g.as_default(): - x = array_ops.placeholder( - dtype=dtype, shape=input_dims, name=input_name) + x = array_ops.placeholder(dtype=dtype, shape=input_dims, name=input_name) b = constant_op.constant(np.random.randn(12, 4), dtype=dtype) x1 = math_ops.matmul(x, b) @@ -108,5 +107,6 @@ class BiasaddMatMulTest(trt_test.TfTrtIntegrationTestBase): allclose_atol=1.e-03, allclose_rtol=1.e-03) + if __name__ == "__main__": test.main() diff --git a/tensorflow/contrib/tensorrt/test/binary_tensor_weight_broadcast_test.py b/tensorflow/contrib/tensorrt/test/binary_tensor_weight_broadcast_test.py index e80712731d..0a3e00afb0 100644 --- a/tensorflow/contrib/tensorrt/test/binary_tensor_weight_broadcast_test.py +++ b/tensorflow/contrib/tensorrt/test/binary_tensor_weight_broadcast_test.py @@ -39,8 +39,7 @@ class BinaryTensorWeightBroadcastTest(trt_test.TfTrtIntegrationTestBase): input_dims = [10, 24, 24, 20] g = ops.Graph() with g.as_default(): - x = array_ops.placeholder( - dtype=dtype, shape=input_dims, name=input_name) + x = array_ops.placeholder(dtype=dtype, shape=input_dims, name=input_name) # scale a = constant_op.constant(np.random.randn(1), dtype=dtype) f = x + a @@ -58,13 +57,11 @@ class BinaryTensorWeightBroadcastTest(trt_test.TfTrtIntegrationTestBase): f = a + x x = math_ops.sigmoid(f) # scale - a = constant_op.constant( - np.random.randn(24, 24, 20), dtype=dtype) + a = constant_op.constant(np.random.randn(24, 24, 20), dtype=dtype) f = a + x x = math_ops.sigmoid(f) # scale - a = constant_op.constant( - np.random.randn(24, 24, 20), dtype=dtype) + a = constant_op.constant(np.random.randn(24, 24, 20), dtype=dtype) f = x + a x = math_ops.sigmoid(f) # elementwise @@ -76,33 +73,27 @@ class BinaryTensorWeightBroadcastTest(trt_test.TfTrtIntegrationTestBase): f = a + x x = math_ops.sigmoid(f) # elementwise - a = constant_op.constant( - np.random.randn(1, 24, 1, 1), dtype=dtype) + a = constant_op.constant(np.random.randn(1, 24, 1, 1), dtype=dtype) f = a + x x = math_ops.sigmoid(f) # elementwise - a = constant_op.constant( - np.random.randn(1, 24, 1, 1), dtype=dtype) + a = constant_op.constant(np.random.randn(1, 24, 1, 1), dtype=dtype) f = x + a x = math_ops.sigmoid(f) # elementwise - a = constant_op.constant( - np.random.randn(1, 24, 24, 1), dtype=dtype) + a = constant_op.constant(np.random.randn(1, 24, 24, 1), dtype=dtype) f = a + x x = math_ops.sigmoid(f) # elementwise - a = constant_op.constant( - np.random.randn(1, 24, 24, 1), dtype=dtype) + a = constant_op.constant(np.random.randn(1, 24, 24, 1), dtype=dtype) f = x + a x = math_ops.sigmoid(f) # elementwise - a = constant_op.constant( - np.random.randn(1, 24, 24, 20), dtype=dtype) + a = constant_op.constant(np.random.randn(1, 24, 24, 20), dtype=dtype) f = a + x x = math_ops.sigmoid(f) # elementwise - a = constant_op.constant( - np.random.randn(1, 24, 24, 20), dtype=dtype) + a = constant_op.constant(np.random.randn(1, 24, 24, 20), dtype=dtype) f = x + a x = math_ops.sigmoid(f) # elementwise @@ -123,5 +114,6 @@ class BinaryTensorWeightBroadcastTest(trt_test.TfTrtIntegrationTestBase): allclose_atol=1.e-03, allclose_rtol=1.e-03) + if __name__ == "__main__": test.main() diff --git a/tensorflow/contrib/tensorrt/test/concatenation_test.py b/tensorflow/contrib/tensorrt/test/concatenation_test.py index cf0bfeeb00..222167f8d5 100644 --- a/tensorflow/contrib/tensorrt/test/concatenation_test.py +++ b/tensorflow/contrib/tensorrt/test/concatenation_test.py @@ -39,8 +39,7 @@ class ConcatenationTest(trt_test.TfTrtIntegrationTestBase): input_dims = [2, 3, 3, 1] g = ops.Graph() with g.as_default(): - x = array_ops.placeholder( - dtype=dtype, shape=input_dims, name=input_name) + x = array_ops.placeholder(dtype=dtype, shape=input_dims, name=input_name) # scale a = constant_op.constant(np.random.randn(3, 1, 1), dtype=dtype) r1 = x / a @@ -79,5 +78,6 @@ class ConcatenationTest(trt_test.TfTrtIntegrationTestBase): allclose_atol=1.e-03, allclose_rtol=1.e-03) + if __name__ == "__main__": test.main() diff --git a/tensorflow/contrib/tensorrt/test/const_broadcast_test.py b/tensorflow/contrib/tensorrt/test/const_broadcast_test.py index 97f5580ac0..6e5f546fc7 100644 --- a/tensorflow/contrib/tensorrt/test/const_broadcast_test.py +++ b/tensorflow/contrib/tensorrt/test/const_broadcast_test.py @@ -34,21 +34,17 @@ class ConstBroadcastTest(trt_test.TfTrtIntegrationTestBase): def GetParams(self): """unit test for Constant broadcasting in TF-TRT""" dtype = dtypes.float32 - input_name = "input" + input_name = 'input' input_dims = [5, 12, 12, 2] g = ops.Graph() with g.as_default(): - x = array_ops.placeholder( - dtype=dtype, shape=input_dims, name=input_name) + x = array_ops.placeholder(dtype=dtype, shape=input_dims, name=input_name) filt1 = constant_op.constant( 0.3, shape=(3, 3, 2, 1), dtype=dtype, name='filt1') y1 = nn.conv2d(x, filt1, strides=[1, 1, 1, 1], padding='SAME', name='y1') z1 = nn.relu(y1, name='z1') filt2 = constant_op.constant( - np.random.randn(9), - shape=(3, 3, 1, 1), - dtype=dtype, - name='filt2') + np.random.randn(9), shape=(3, 3, 1, 1), dtype=dtype, name='filt2') y2 = nn.conv2d(z1, filt2, strides=[1, 1, 1, 1], padding='SAME', name='y2') z2 = nn.relu(y2, name='z') filt3 = constant_op.constant( @@ -67,5 +63,6 @@ class ConstBroadcastTest(trt_test.TfTrtIntegrationTestBase): allclose_atol=1.e-02, allclose_rtol=1.e-02) -if __name__ == "__main__": + +if __name__ == '__main__': test.main() diff --git a/tensorflow/contrib/tensorrt/test/multi_connection_neighbor_engine_test.py b/tensorflow/contrib/tensorrt/test/multi_connection_neighbor_engine_test.py index e62f9e479e..7fa798fb45 100644 --- a/tensorflow/contrib/tensorrt/test/multi_connection_neighbor_engine_test.py +++ b/tensorflow/contrib/tensorrt/test/multi_connection_neighbor_engine_test.py @@ -40,8 +40,7 @@ class MultiConnectionNeighborEngineTest(trt_test.TfTrtIntegrationTestBase): input_dims = [2, 3, 7, 5] g = ops.Graph() with g.as_default(): - x = array_ops.placeholder( - dtype=dtype, shape=input_dims, name=input_name) + x = array_ops.placeholder(dtype=dtype, shape=input_dims, name=input_name) e = constant_op.constant( np.random.normal(.05, .005, [3, 2, 3, 4]), name="weights", @@ -54,29 +53,21 @@ class MultiConnectionNeighborEngineTest(trt_test.TfTrtIntegrationTestBase): padding="VALID", name="conv") b = constant_op.constant( - np.random.normal(2.0, 1.0, [1, 4, 1, 1]), - name="bias", - dtype=dtype) + np.random.normal(2.0, 1.0, [1, 4, 1, 1]), name="bias", dtype=dtype) t = conv + b b = constant_op.constant( - np.random.normal(5.0, 1.0, [1, 4, 1, 1]), - name="bias", - dtype=dtype) + np.random.normal(5.0, 1.0, [1, 4, 1, 1]), name="bias", dtype=dtype) q = conv - b edge = math_ops.sigmoid(q) b = constant_op.constant( - np.random.normal(5.0, 1.0, [1, 4, 1, 1]), - name="bias", - dtype=dtype) + np.random.normal(5.0, 1.0, [1, 4, 1, 1]), name="bias", dtype=dtype) d = b + conv edge3 = math_ops.sigmoid(d) c = constant_op.constant( - np.random.normal(1.0, 1.0, [1, 4, 1, 1]), - name="bias", - dtype=dtype) + np.random.normal(1.0, 1.0, [1, 4, 1, 1]), name="bias", dtype=dtype) edge1 = gen_math_ops.tan(conv) t = t - edge1 q = q + edge @@ -93,5 +84,6 @@ class MultiConnectionNeighborEngineTest(trt_test.TfTrtIntegrationTestBase): allclose_atol=1.e-03, allclose_rtol=1.e-03) + if __name__ == "__main__": test.main() diff --git a/tensorflow/contrib/tensorrt/test/neighboring_engine_test.py b/tensorflow/contrib/tensorrt/test/neighboring_engine_test.py index bbe8823552..439af81664 100644 --- a/tensorflow/contrib/tensorrt/test/neighboring_engine_test.py +++ b/tensorflow/contrib/tensorrt/test/neighboring_engine_test.py @@ -39,12 +39,9 @@ class NeighboringEngineTest(trt_test.TfTrtIntegrationTestBase): input_dims = [2, 3, 7, 5] g = ops.Graph() with g.as_default(): - x = array_ops.placeholder( - dtype=dtype, shape=input_dims, name=input_name) + x = array_ops.placeholder(dtype=dtype, shape=input_dims, name=input_name) e = constant_op.constant( - np.random.normal(.3, 0.05, [3, 2, 3, 4]), - name="weights", - dtype=dtype) + np.random.normal(.3, 0.05, [3, 2, 3, 4]), name="weights", dtype=dtype) conv = nn.conv2d( input=x, filter=e, @@ -53,9 +50,7 @@ class NeighboringEngineTest(trt_test.TfTrtIntegrationTestBase): padding="VALID", name="conv") b = constant_op.constant( - np.random.normal(1.0, 1.0, [1, 4, 1, 1]), - name="bias", - dtype=dtype) + np.random.normal(1.0, 1.0, [1, 4, 1, 1]), name="bias", dtype=dtype) t = conv * b e = gen_math_ops.tan(conv) t = t - e @@ -69,5 +64,6 @@ class NeighboringEngineTest(trt_test.TfTrtIntegrationTestBase): allclose_atol=1.e-03, allclose_rtol=1.e-03) + if __name__ == "__main__": test.main() diff --git a/tensorflow/contrib/tensorrt/test/tf_trt_integration_test_base.py b/tensorflow/contrib/tensorrt/test/tf_trt_integration_test_base.py index 48890ad413..6e12e7e026 100644 --- a/tensorflow/contrib/tensorrt/test/tf_trt_integration_test_base.py +++ b/tensorflow/contrib/tensorrt/test/tf_trt_integration_test_base.py @@ -169,7 +169,8 @@ class TfTrtIntegrationTestBase(test_util.TensorFlowTestCase): num_engines += 1 self.assertNotEqual(self._ToBytes(""), n.attr["serialized_segment"].s) self.assertNotEqual(self._ToBytes(""), n.attr["segment_funcdef_name"].s) - self.assertEqual(self._ToBytes(precision_mode), n.attr["precision_mode"].s) + self.assertEqual( + self._ToBytes(precision_mode), n.attr["precision_mode"].s) self.assertEqual(not dynamic_engine, n.attr["static_engine"].b) if _IsQuantizationMode(precision_mode) and is_calibrated: self.assertNotEqual(self._ToBytes(""), n.attr["calibration_data"].s) diff --git a/tensorflow/contrib/tensorrt/test/unary_test.py b/tensorflow/contrib/tensorrt/test/unary_test.py index 4c10c50e85..7395c4a311 100644 --- a/tensorflow/contrib/tensorrt/test/unary_test.py +++ b/tensorflow/contrib/tensorrt/test/unary_test.py @@ -32,7 +32,6 @@ from tensorflow.contrib.tensorrt.test import tf_trt_integration_test_base as trt class UnaryTest(trt_test.TfTrtIntegrationTestBase): - def GetParams(self): """unit test for unary operations in TF-TRT""" @@ -43,8 +42,7 @@ class UnaryTest(trt_test.TfTrtIntegrationTestBase): input2_dims = [12, 5, 8, 1, 12, 1, 1] g = ops.Graph() with g.as_default(): - x = array_ops.placeholder( - dtype=dtype, shape=input_dims, name=input_name) + x = array_ops.placeholder(dtype=dtype, shape=input_dims, name=input_name) q = math_ops.abs(x) q = q + 1.0 q = gen_math_ops.exp(q) @@ -107,5 +105,6 @@ class UnaryTest(trt_test.TfTrtIntegrationTestBase): allclose_atol=1.e-03, allclose_rtol=1.e-03) + if __name__ == "__main__": test.main() diff --git a/tensorflow/contrib/tensorrt/test/vgg_block_nchw_test.py b/tensorflow/contrib/tensorrt/test/vgg_block_nchw_test.py index 3621c13bc9..0e28afeaf4 100644 --- a/tensorflow/contrib/tensorrt/test/vgg_block_nchw_test.py +++ b/tensorflow/contrib/tensorrt/test/vgg_block_nchw_test.py @@ -40,8 +40,7 @@ class VGGBlockNCHWTest(trt_test.TfTrtIntegrationTestBase): input_dims = [5, 2, 8, 8] g = ops.Graph() with g.as_default(): - x = array_ops.placeholder( - dtype=dtype, shape=input_dims, name=input_name) + x = array_ops.placeholder(dtype=dtype, shape=input_dims, name=input_name) x, mean_x, var_x = nn_impl.fused_batch_norm( x, np.random.randn(2).astype(np.float32), @@ -59,8 +58,7 @@ class VGGBlockNCHWTest(trt_test.TfTrtIntegrationTestBase): strides=[1, 1, 2, 2], padding="SAME", name="conv") - b = constant_op.constant( - np.random.randn(6), name="bias", dtype=dtype) + b = constant_op.constant(np.random.randn(6), name="bias", dtype=dtype) t = nn.bias_add(conv, b, data_format="NCHW", name="biasAdd") relu = nn.relu(t, "relu") idty = array_ops.identity(relu, "ID") @@ -79,5 +77,6 @@ class VGGBlockNCHWTest(trt_test.TfTrtIntegrationTestBase): allclose_atol=1.e-03, allclose_rtol=1.e-03) + if __name__ == "__main__": test.main() diff --git a/tensorflow/contrib/tensorrt/test/vgg_block_test.py b/tensorflow/contrib/tensorrt/test/vgg_block_test.py index 1ef32fe52f..f2aacddd87 100644 --- a/tensorflow/contrib/tensorrt/test/vgg_block_test.py +++ b/tensorflow/contrib/tensorrt/test/vgg_block_test.py @@ -40,8 +40,7 @@ class VGGBlockTest(trt_test.TfTrtIntegrationTestBase): input_dims = [5, 8, 8, 2] g = ops.Graph() with g.as_default(): - x = array_ops.placeholder( - dtype=dtype, shape=input_dims, name=input_name) + x = array_ops.placeholder(dtype=dtype, shape=input_dims, name=input_name) x, mean_x, var_x = nn_impl.fused_batch_norm( x, np.random.randn(2).astype(np.float32), @@ -53,8 +52,7 @@ class VGGBlockTest(trt_test.TfTrtIntegrationTestBase): np.random.randn(1, 1, 2, 6), name="weights", dtype=dtype) conv = nn.conv2d( input=x, filter=e, strides=[1, 2, 2, 1], padding="SAME", name="conv") - b = constant_op.constant( - np.random.randn(6), name="bias", dtype=dtype) + b = constant_op.constant(np.random.randn(6), name="bias", dtype=dtype) t = nn.bias_add(conv, b, name="biasAdd") relu = nn.relu(t, "relu") idty = array_ops.identity(relu, "ID") @@ -70,5 +68,6 @@ class VGGBlockTest(trt_test.TfTrtIntegrationTestBase): allclose_atol=1.e-03, allclose_rtol=1.e-03) + if __name__ == "__main__": test.main() -- cgit v1.2.3