From ccdc9f0164c7c22164928c108abf9130ffadc35f Mon Sep 17 00:00:00 2001 From: zong_shuai Date: Mon, 30 Aug 2021 10:51:56 +0800 Subject: [PATCH] st --- tests/st/ops/gpu/test_batchtospace_op.py | 24 ++++++++++++------------ tests/st/ops/gpu/test_spacetobatch_op.py | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/st/ops/gpu/test_batchtospace_op.py b/tests/st/ops/gpu/test_batchtospace_op.py index 407185c82ea..0f33d7f3055 100644 --- a/tests/st/ops/gpu/test_batchtospace_op.py +++ b/tests/st/ops/gpu/test_batchtospace_op.py @@ -23,9 +23,9 @@ from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter class BatchToSpaceNet(nn.Cell): - def __init__(self, nptype, block_size=2, input_shape=(4,1,2,2)): + def __init__(self, nptype, block_size=2, input_shape=(4, 1, 2, 2)): super(BatchToSpaceNet, self).__init__() - self.BatchToSpace = P.BatchToSpace(block_size=block_size, crops=[[0,0],[0,0]]) + self.BatchToSpace = P.BatchToSpace(block_size=block_size, crops=[[0, 0], [0, 0]]) input_size = 1 for i in input_shape: input_size = input_size*i @@ -39,14 +39,14 @@ class BatchToSpaceNet(nn.Cell): return y1 -def BatchToSpace(nptype, block_size=2, input_shape=(4,1,2,2)): +def BatchToSpace(nptype, block_size=2, input_shape=(4, 1, 2, 2)): context.set_context(mode=context.GRAPH_MODE, device_target='GPU') input_size = 1 for i in input_shape: input_size = input_size*i - expect = np.array([[[[0, 4, 1, 5], - [8, 12, 9, 13], - [2, 6, 3, 7], + expect = np.array([[[[0, 4, 1, 5], + [8, 12, 9, 13], + [2, 6, 3, 7], [10, 14, 11, 15]]]]).astype(nptype) dts = BatchToSpaceNet(nptype, block_size, input_shape) @@ -54,17 +54,17 @@ def BatchToSpace(nptype, block_size=2, input_shape=(4,1,2,2)): assert (output.asnumpy() == expect).all() -def BatchToSpace_pynative(nptype, block_size=2, input_shape=(4,1,2,2)): +def BatchToSpace_pynative(nptype, block_size=2, input_shape=(4, 1, 2, 2)): context.set_context(mode=context.PYNATIVE_MODE, device_target='GPU') input_size = 1 for i in input_shape: input_size = input_size*i - expect = np.array([[[[0, 4, 1, 5], - [8, 12, 9, 13], - [2, 6, 3, 7], + expect = np.array([[[[0, 4, 1, 5], + [8, 12, 9, 13], + [2, 6, 3, 7], [10, 14, 11, 15]]]]).astype(nptype) - dts = P.BatchToSpace(block_size=block_size, crops=[[0,0],[0,0]]) + dts = P.BatchToSpace(block_size=block_size, crops=[[0, 0], [0, 0]]) arr_input = Tensor(np.arange(input_size).reshape(input_shape).astype(nptype)) output = dts(arr_input) @@ -81,4 +81,4 @@ def test_batchtospace_graph_float32(): @pytest.mark.platform_x86_gpu_training @pytest.mark.env_onecard def test_batchtospace_graph_float16(): - BatchToSpace(np.float16) \ No newline at end of file + BatchToSpace(np.float16) diff --git a/tests/st/ops/gpu/test_spacetobatch_op.py b/tests/st/ops/gpu/test_spacetobatch_op.py index 5a493ee256a..a89751c0fdc 100644 --- a/tests/st/ops/gpu/test_spacetobatch_op.py +++ b/tests/st/ops/gpu/test_spacetobatch_op.py @@ -25,7 +25,7 @@ from mindspore.common.parameter import Parameter class SpaceToBatchNet(nn.Cell): def __init__(self, nptype, block_size=2, input_shape=(1, 1, 4, 4)): super(SpaceToBatchNet, self).__init__() - self.SpaceToBatch = P.SpaceToBatch(block_size=block_size, paddings=[[0,0],[0,0]]) + self.SpaceToBatch = P.SpaceToBatch(block_size=block_size, paddings=[[0, 0], [0, 0]]) input_size = 1 for i in input_shape: input_size = input_size*i @@ -72,7 +72,7 @@ def SpaceToBatch_pynative(nptype, block_size=2, input_shape=(1, 1, 4, 4)): [[[5, 7], [13, 15]]]]).astype(nptype) - dts = P.SpaceToBatch(block_size=block_size, paddings=[[0,0],[0,0]]) + dts = P.SpaceToBatch(block_size=block_size, paddings=[[0, 0], [0, 0]]) arr_input = Tensor(np.arange(input_size).reshape(input_shape).astype(nptype)) output = dts(arr_input) @@ -89,4 +89,4 @@ def test_spacetobatch_graph_float32(): @pytest.mark.platform_x86_gpu_training @pytest.mark.env_onecard def test_spacetobatch_graph_float16(): - SpaceToBatch(np.float16) \ No newline at end of file + SpaceToBatch(np.float16)