未验证 提交 9666979d 编写于 作者: C ccrrong 提交者: GitHub

move conv2d_transpose and conv3d_transpose (#48198)

上级 32462c64
此差异已折叠。
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
import unittest import unittest
import numpy as np import numpy as np
from inference_pass_test import InferencePassTest from inference_pass_test import InferencePassTest
import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
from paddle.fluid.core import PassVersionChecker from paddle.fluid.core import PassVersionChecker
...@@ -173,7 +174,7 @@ class ConvTransposeMkldnnFusePassDialtionsGroupsTest(InferencePassTest): ...@@ -173,7 +174,7 @@ class ConvTransposeMkldnnFusePassDialtionsGroupsTest(InferencePassTest):
initializer=fluid.initializer.Xavier(uniform=False), initializer=fluid.initializer.Xavier(uniform=False),
learning_rate=0.001, learning_rate=0.001,
) )
conv_out = fluid.layers.conv2d_transpose( conv_out = paddle.static.nn.conv2d_transpose(
input=data, input=data,
num_filters=3, num_filters=3,
filter_size=3, filter_size=3,
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
import unittest import unittest
import numpy as np import numpy as np
from inference_pass_test import InferencePassTest from inference_pass_test import InferencePassTest
import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
import paddle.fluid.core as core import paddle.fluid.core as core
from paddle.fluid.core import PassVersionChecker from paddle.fluid.core import PassVersionChecker
...@@ -28,7 +29,7 @@ class TensorRTSubgraphPassConv3dTransposeTest(InferencePassTest): ...@@ -28,7 +29,7 @@ class TensorRTSubgraphPassConv3dTransposeTest(InferencePassTest):
data = fluid.data( data = fluid.data(
name="data", shape=[-1, 4, 4, 32, 32], dtype="float32" name="data", shape=[-1, 4, 4, 32, 32], dtype="float32"
) )
conv_out = fluid.layers.conv3d_transpose( conv_out = paddle.static.nn.conv3d_transpose(
input=data, input=data,
num_filters=self.conv_num_filters, num_filters=self.conv_num_filters,
filter_size=self.conv_filter_size, filter_size=self.conv_filter_size,
...@@ -95,7 +96,7 @@ class DynamicShapeTensorRTSubgraphPassConv3dTransposeTest(InferencePassTest): ...@@ -95,7 +96,7 @@ class DynamicShapeTensorRTSubgraphPassConv3dTransposeTest(InferencePassTest):
data = fluid.data( data = fluid.data(
name="data", shape=[-1, 6, -1, -1, -1], dtype="float32" name="data", shape=[-1, 6, -1, -1, -1], dtype="float32"
) )
conv_out = fluid.layers.conv3d_transpose( conv_out = paddle.static.nn.conv3d_transpose(
input=data, input=data,
num_filters=self.conv_num_filters, num_filters=self.conv_num_filters,
filter_size=self.conv_filter_size, filter_size=self.conv_filter_size,
......
...@@ -16,6 +16,7 @@ import os ...@@ -16,6 +16,7 @@ import os
import unittest import unittest
import numpy as np import numpy as np
from inference_pass_test import InferencePassTest from inference_pass_test import InferencePassTest
import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
import paddle.fluid.core as core import paddle.fluid.core as core
from paddle.fluid.core import PassVersionChecker from paddle.fluid.core import PassVersionChecker
...@@ -109,7 +110,7 @@ class TensorRTSubgraphPassConvTransposeTest(InferencePassTest): ...@@ -109,7 +110,7 @@ class TensorRTSubgraphPassConvTransposeTest(InferencePassTest):
data = fluid.data( data = fluid.data(
name="data", shape=[-1, 6, 64, 64], dtype="float32" name="data", shape=[-1, 6, 64, 64], dtype="float32"
) )
conv_out = fluid.layers.conv2d_transpose( conv_out = paddle.static.nn.conv2d_transpose(
input=data, input=data,
num_filters=self.conv_num_filters, num_filters=self.conv_num_filters,
filter_size=self.conv_filter_size, filter_size=self.conv_filter_size,
......
...@@ -237,7 +237,7 @@ class QuantDequantTensorRTSubgraphPassConvTransposeTest(QuantDequantTest): ...@@ -237,7 +237,7 @@ class QuantDequantTensorRTSubgraphPassConvTransposeTest(QuantDequantTest):
data_reshape = paddle.reshape(self.data, shape=[1, 4, 14, 14]) data_reshape = paddle.reshape(self.data, shape=[1, 4, 14, 14])
self.label = fluid.data(name='label', shape=[1, 1], dtype='int64') self.label = fluid.data(name='label', shape=[1, 1], dtype='int64')
label_shape = paddle.reshape(self.label, shape=[1, 1, 1]) label_shape = paddle.reshape(self.label, shape=[1, 1, 1])
conv_out = fluid.layers.conv2d_transpose( conv_out = paddle.static.nn.conv2d_transpose(
input=data_reshape, input=data_reshape,
num_filters=self.conv_num_filters, num_filters=self.conv_num_filters,
filter_size=self.conv_filter_size, filter_size=self.conv_filter_size,
......
...@@ -499,21 +499,21 @@ class TestConv2DTransposeAPI(unittest.TestCase): ...@@ -499,21 +499,21 @@ class TestConv2DTransposeAPI(unittest.TestCase):
data2 = fluid.layers.data( data2 = fluid.layers.data(
name='data2', shape=[5, 5, 3], dtype='float32' name='data2', shape=[5, 5, 3], dtype='float32'
) )
out1 = fluid.layers.conv2d_transpose( out1 = paddle.static.nn.conv2d_transpose(
input=data1, input=data1,
groups=1, groups=1,
num_filters=6, num_filters=6,
filter_size=3, filter_size=3,
data_format='NCHW', data_format='NCHW',
) )
out2 = fluid.layers.conv2d_transpose( out2 = paddle.static.nn.conv2d_transpose(
input=data2, input=data2,
groups=1, groups=1,
num_filters=6, num_filters=6,
filter_size=3, filter_size=3,
data_format='NHWC', data_format='NHWC',
) )
out3 = fluid.layers.conv2d_transpose( out3 = paddle.static.nn.conv2d_transpose(
input=data1, input=data1,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -521,7 +521,7 @@ class TestConv2DTransposeAPI(unittest.TestCase): ...@@ -521,7 +521,7 @@ class TestConv2DTransposeAPI(unittest.TestCase):
padding=[[0, 0], [1, 1], [1, 1], [0, 0]], padding=[[0, 0], [1, 1], [1, 1], [0, 0]],
data_format='NHWC', data_format='NHWC',
) )
out4 = fluid.layers.conv2d_transpose( out4 = paddle.static.nn.conv2d_transpose(
input=data1, input=data1,
groups=3, groups=3,
num_filters=6, num_filters=6,
...@@ -529,7 +529,7 @@ class TestConv2DTransposeAPI(unittest.TestCase): ...@@ -529,7 +529,7 @@ class TestConv2DTransposeAPI(unittest.TestCase):
padding=[[0, 0], [0, 0], [2, 1], [0, 0]], padding=[[0, 0], [0, 0], [2, 1], [0, 0]],
data_format='NCHW', data_format='NCHW',
) )
out5 = fluid.layers.conv2d_transpose( out5 = paddle.static.nn.conv2d_transpose(
input=data2, input=data2,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -537,7 +537,7 @@ class TestConv2DTransposeAPI(unittest.TestCase): ...@@ -537,7 +537,7 @@ class TestConv2DTransposeAPI(unittest.TestCase):
padding='SAME', padding='SAME',
data_format='NCHW', data_format='NCHW',
) )
out6 = fluid.layers.conv2d_transpose( out6 = paddle.static.nn.conv2d_transpose(
input=data1, input=data1,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -545,7 +545,7 @@ class TestConv2DTransposeAPI(unittest.TestCase): ...@@ -545,7 +545,7 @@ class TestConv2DTransposeAPI(unittest.TestCase):
padding='VALID', padding='VALID',
data_format='NHWC', data_format='NHWC',
) )
out7 = fluid.layers.conv2d_transpose( out7 = paddle.static.nn.conv2d_transpose(
input=data1, input=data1,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -586,7 +586,7 @@ class TestConv2DTransposeOpException(unittest.TestCase): ...@@ -586,7 +586,7 @@ class TestConv2DTransposeOpException(unittest.TestCase):
data = fluid.layers.data(name='data', shape=[3, 5, 5], dtype="float32") data = fluid.layers.data(name='data', shape=[3, 5, 5], dtype="float32")
def attr_data_format(): def attr_data_format():
out = fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
input=data, input=data,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -597,7 +597,7 @@ class TestConv2DTransposeOpException(unittest.TestCase): ...@@ -597,7 +597,7 @@ class TestConv2DTransposeOpException(unittest.TestCase):
self.assertRaises(ValueError, attr_data_format) self.assertRaises(ValueError, attr_data_format)
def attr_padding_str(): def attr_padding_str():
out = fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
input=data, input=data,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -608,7 +608,7 @@ class TestConv2DTransposeOpException(unittest.TestCase): ...@@ -608,7 +608,7 @@ class TestConv2DTransposeOpException(unittest.TestCase):
self.assertRaises(ValueError, attr_padding_str) self.assertRaises(ValueError, attr_padding_str)
def attr_padding_list(): def attr_padding_list():
out = fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
input=data, input=data,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -619,7 +619,7 @@ class TestConv2DTransposeOpException(unittest.TestCase): ...@@ -619,7 +619,7 @@ class TestConv2DTransposeOpException(unittest.TestCase):
self.assertRaises(ValueError, attr_padding_list) self.assertRaises(ValueError, attr_padding_list)
def attr_padding_with_data_format(): def attr_padding_with_data_format():
out = fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
input=data, input=data,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -635,14 +635,14 @@ class TestConv2DTransposeOpException(unittest.TestCase): ...@@ -635,14 +635,14 @@ class TestConv2DTransposeOpException(unittest.TestCase):
) )
def error_input_size(): def error_input_size():
out = fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
input=error_input, groups=1, num_filters=6, filter_size=3 input=error_input, groups=1, num_filters=6, filter_size=3
) )
self.assertRaises(ValueError, error_input_size) self.assertRaises(ValueError, error_input_size)
def error_groups(): def error_groups():
out = fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
input=data, input=data,
groups=0, groups=0,
num_filters=6, num_filters=6,
......
...@@ -435,21 +435,21 @@ class TestConv2DTransposeAPI(unittest.TestCase): ...@@ -435,21 +435,21 @@ class TestConv2DTransposeAPI(unittest.TestCase):
data2 = fluid.layers.data( data2 = fluid.layers.data(
name='data2', shape=[5, 5, 3], dtype='float32' name='data2', shape=[5, 5, 3], dtype='float32'
) )
out1 = fluid.layers.conv2d_transpose( out1 = paddle.static.nn.conv2d_transpose(
input=data1, input=data1,
groups=1, groups=1,
num_filters=6, num_filters=6,
filter_size=3, filter_size=3,
data_format='NCHW', data_format='NCHW',
) )
out2 = fluid.layers.conv2d_transpose( out2 = paddle.static.nn.conv2d_transpose(
input=data2, input=data2,
groups=1, groups=1,
num_filters=6, num_filters=6,
filter_size=3, filter_size=3,
data_format='NHWC', data_format='NHWC',
) )
out3 = fluid.layers.conv2d_transpose( out3 = paddle.static.nn.conv2d_transpose(
input=data1, input=data1,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -457,7 +457,7 @@ class TestConv2DTransposeAPI(unittest.TestCase): ...@@ -457,7 +457,7 @@ class TestConv2DTransposeAPI(unittest.TestCase):
padding=[[0, 0], [1, 1], [1, 1], [0, 0]], padding=[[0, 0], [1, 1], [1, 1], [0, 0]],
data_format='NHWC', data_format='NHWC',
) )
out4 = fluid.layers.conv2d_transpose( out4 = paddle.static.nn.conv2d_transpose(
input=data1, input=data1,
groups=3, groups=3,
num_filters=6, num_filters=6,
...@@ -465,7 +465,7 @@ class TestConv2DTransposeAPI(unittest.TestCase): ...@@ -465,7 +465,7 @@ class TestConv2DTransposeAPI(unittest.TestCase):
padding=[[0, 0], [0, 0], [2, 1], [0, 0]], padding=[[0, 0], [0, 0], [2, 1], [0, 0]],
data_format='NCHW', data_format='NCHW',
) )
out5 = fluid.layers.conv2d_transpose( out5 = paddle.static.nn.conv2d_transpose(
input=data2, input=data2,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -473,7 +473,7 @@ class TestConv2DTransposeAPI(unittest.TestCase): ...@@ -473,7 +473,7 @@ class TestConv2DTransposeAPI(unittest.TestCase):
padding='SAME', padding='SAME',
data_format='NCHW', data_format='NCHW',
) )
out6 = fluid.layers.conv2d_transpose( out6 = paddle.static.nn.conv2d_transpose(
input=data1, input=data1,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -481,7 +481,7 @@ class TestConv2DTransposeAPI(unittest.TestCase): ...@@ -481,7 +481,7 @@ class TestConv2DTransposeAPI(unittest.TestCase):
padding='VALID', padding='VALID',
data_format='NHWC', data_format='NHWC',
) )
out7 = fluid.layers.conv2d_transpose( out7 = paddle.static.nn.conv2d_transpose(
input=data1, input=data1,
groups=1, groups=1,
num_filters=6, num_filters=6,
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
# limitations under the License. # limitations under the License.
import numpy as np import numpy as np
import paddle
from paddle import fluid, nn from paddle import fluid, nn
import paddle.fluid.dygraph as dg import paddle.fluid.dygraph as dg
import paddle.nn.functional as F import paddle.nn.functional as F
...@@ -104,7 +105,7 @@ class Conv2DTransposeTestCase(unittest.TestCase): ...@@ -104,7 +105,7 @@ class Conv2DTransposeTestCase(unittest.TestCase):
else: else:
bias_attr = I.NumpyArrayInitializer(self.bias) bias_attr = I.NumpyArrayInitializer(self.bias)
y_var = fluid.layers.conv2d_transpose( y_var = paddle.static.nn.conv2d_transpose(
x_var, x_var,
self.num_filters, self.num_filters,
filter_size=self.filter_size, filter_size=self.filter_size,
......
...@@ -835,21 +835,21 @@ class TestConv2DTransposeAPI(unittest.TestCase): ...@@ -835,21 +835,21 @@ class TestConv2DTransposeAPI(unittest.TestCase):
data2 = fluid.layers.data( data2 = fluid.layers.data(
name='data2', shape=[5, 5, 3], dtype='float32' name='data2', shape=[5, 5, 3], dtype='float32'
) )
out1 = fluid.layers.conv2d_transpose( out1 = paddle.static.nn.conv2d_transpose(
input=data1, input=data1,
groups=1, groups=1,
num_filters=6, num_filters=6,
filter_size=3, filter_size=3,
data_format='NCHW', data_format='NCHW',
) )
out2 = fluid.layers.conv2d_transpose( out2 = paddle.static.nn.conv2d_transpose(
input=data2, input=data2,
groups=1, groups=1,
num_filters=6, num_filters=6,
filter_size=3, filter_size=3,
data_format='NHWC', data_format='NHWC',
) )
out3 = fluid.layers.conv2d_transpose( out3 = paddle.static.nn.conv2d_transpose(
input=data1, input=data1,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -857,7 +857,7 @@ class TestConv2DTransposeAPI(unittest.TestCase): ...@@ -857,7 +857,7 @@ class TestConv2DTransposeAPI(unittest.TestCase):
padding=[[0, 0], [1, 1], [1, 1], [0, 0]], padding=[[0, 0], [1, 1], [1, 1], [0, 0]],
data_format='NHWC', data_format='NHWC',
) )
out4 = fluid.layers.conv2d_transpose( out4 = paddle.static.nn.conv2d_transpose(
input=data1, input=data1,
groups=3, groups=3,
num_filters=6, num_filters=6,
...@@ -865,7 +865,7 @@ class TestConv2DTransposeAPI(unittest.TestCase): ...@@ -865,7 +865,7 @@ class TestConv2DTransposeAPI(unittest.TestCase):
padding=[[0, 0], [0, 0], [2, 1], [0, 0]], padding=[[0, 0], [0, 0], [2, 1], [0, 0]],
data_format='NCHW', data_format='NCHW',
) )
out5 = fluid.layers.conv2d_transpose( out5 = paddle.static.nn.conv2d_transpose(
input=data2, input=data2,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -873,7 +873,7 @@ class TestConv2DTransposeAPI(unittest.TestCase): ...@@ -873,7 +873,7 @@ class TestConv2DTransposeAPI(unittest.TestCase):
padding='SAME', padding='SAME',
data_format='NCHW', data_format='NCHW',
) )
out6 = fluid.layers.conv2d_transpose( out6 = paddle.static.nn.conv2d_transpose(
input=data1, input=data1,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -881,7 +881,7 @@ class TestConv2DTransposeAPI(unittest.TestCase): ...@@ -881,7 +881,7 @@ class TestConv2DTransposeAPI(unittest.TestCase):
padding='VALID', padding='VALID',
data_format='NHWC', data_format='NHWC',
) )
out7 = fluid.layers.conv2d_transpose( out7 = paddle.static.nn.conv2d_transpose(
input=data1, input=data1,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -919,7 +919,7 @@ class TestConv2DTransposeOpException(unittest.TestCase): ...@@ -919,7 +919,7 @@ class TestConv2DTransposeOpException(unittest.TestCase):
data = fluid.layers.data(name='data', shape=[3, 5, 5], dtype="float32") data = fluid.layers.data(name='data', shape=[3, 5, 5], dtype="float32")
def attr_data_format(): def attr_data_format():
out = fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
input=data, input=data,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -930,7 +930,7 @@ class TestConv2DTransposeOpException(unittest.TestCase): ...@@ -930,7 +930,7 @@ class TestConv2DTransposeOpException(unittest.TestCase):
self.assertRaises(ValueError, attr_data_format) self.assertRaises(ValueError, attr_data_format)
def attr_padding_str(): def attr_padding_str():
out = fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
input=data, input=data,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -941,7 +941,7 @@ class TestConv2DTransposeOpException(unittest.TestCase): ...@@ -941,7 +941,7 @@ class TestConv2DTransposeOpException(unittest.TestCase):
self.assertRaises(ValueError, attr_padding_str) self.assertRaises(ValueError, attr_padding_str)
def attr_padding_list(): def attr_padding_list():
out = fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
input=data, input=data,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -952,7 +952,7 @@ class TestConv2DTransposeOpException(unittest.TestCase): ...@@ -952,7 +952,7 @@ class TestConv2DTransposeOpException(unittest.TestCase):
self.assertRaises(ValueError, attr_padding_list) self.assertRaises(ValueError, attr_padding_list)
def attr_padding_with_data_format(): def attr_padding_with_data_format():
out = fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
input=data, input=data,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -968,14 +968,14 @@ class TestConv2DTransposeOpException(unittest.TestCase): ...@@ -968,14 +968,14 @@ class TestConv2DTransposeOpException(unittest.TestCase):
) )
def error_input_size(): def error_input_size():
out = fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
input=error_input, groups=1, num_filters=6, filter_size=3 input=error_input, groups=1, num_filters=6, filter_size=3
) )
self.assertRaises(ValueError, error_input_size) self.assertRaises(ValueError, error_input_size)
def error_groups(): def error_groups():
out = fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
input=data, input=data,
groups=0, groups=0,
num_filters=6, num_filters=6,
...@@ -1064,7 +1064,7 @@ class TestTensorOutputSize3(TestTensorOutputSize1): ...@@ -1064,7 +1064,7 @@ class TestTensorOutputSize3(TestTensorOutputSize1):
def call_func(self, x): def call_func(self, x):
w_var = paddle.randn((3, 6, 3, 3), dtype='float32') w_var = paddle.randn((3, 6, 3, 3), dtype='float32')
output_size = paddle.assign([17]) output_size = paddle.assign([17])
out = paddle.fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
x, num_filters=6, output_size=output_size, filter_size=3, stride=2 x, num_filters=6, output_size=output_size, filter_size=3, stride=2
) )
return out return out
...@@ -1076,7 +1076,7 @@ class TestTensorOutputSize4(TestTensorOutputSize1): ...@@ -1076,7 +1076,7 @@ class TestTensorOutputSize4(TestTensorOutputSize1):
def call_func(self, x): def call_func(self, x):
output_size = [17, paddle.assign([17])] output_size = [17, paddle.assign([17])]
out = paddle.fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
x, num_filters=6, output_size=output_size, filter_size=3, stride=2 x, num_filters=6, output_size=output_size, filter_size=3, stride=2
) )
return out return out
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
# limitations under the License. # limitations under the License.
import numpy as np import numpy as np
import paddle
from paddle import fluid, nn from paddle import fluid, nn
import paddle.fluid.dygraph as dg import paddle.fluid.dygraph as dg
import paddle.nn.functional as F import paddle.nn.functional as F
...@@ -101,7 +102,7 @@ class Conv3DTransposeTestCase(unittest.TestCase): ...@@ -101,7 +102,7 @@ class Conv3DTransposeTestCase(unittest.TestCase):
bias_attr = False bias_attr = False
else: else:
bias_attr = I.NumpyArrayInitializer(self.bias) bias_attr = I.NumpyArrayInitializer(self.bias)
y_var = fluid.layers.conv3d_transpose( y_var = paddle.static.nn.conv3d_transpose(
x_var, x_var,
self.num_filters, self.num_filters,
filter_size=self.filter_size, filter_size=self.filter_size,
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
import unittest import unittest
import numpy as np import numpy as np
import paddle
import paddle.fluid.core as core import paddle.fluid.core as core
import paddle.fluid as fluid import paddle.fluid as fluid
from test_conv3d_transpose_op import TestConv3DTransposeOp from test_conv3d_transpose_op import TestConv3DTransposeOp
...@@ -91,21 +92,21 @@ class TestConv3DTransposeAPI(unittest.TestCase): ...@@ -91,21 +92,21 @@ class TestConv3DTransposeAPI(unittest.TestCase):
name='data2', shape=[5, 5, 5, 3], dtype='float32' name='data2', shape=[5, 5, 5, 3], dtype='float32'
) )
out1 = fluid.layers.conv3d_transpose( out1 = paddle.static.nn.conv3d_transpose(
input=data1, input=data1,
groups=1, groups=1,
num_filters=6, num_filters=6,
filter_size=3, filter_size=3,
data_format='NCDHW', data_format='NCDHW',
) )
out2 = fluid.layers.conv3d_transpose( out2 = paddle.static.nn.conv3d_transpose(
input=data2, input=data2,
groups=1, groups=1,
num_filters=6, num_filters=6,
filter_size=3, filter_size=3,
data_format='NDHWC', data_format='NDHWC',
) )
out3 = fluid.layers.conv3d_transpose( out3 = paddle.static.nn.conv3d_transpose(
input=data1, input=data1,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -113,7 +114,7 @@ class TestConv3DTransposeAPI(unittest.TestCase): ...@@ -113,7 +114,7 @@ class TestConv3DTransposeAPI(unittest.TestCase):
padding=[[0, 0], [0, 0], [1, 1], [0, 0], [1, 1]], padding=[[0, 0], [0, 0], [1, 1], [0, 0], [1, 1]],
data_format='NCDHW', data_format='NCDHW',
) )
out4 = fluid.layers.conv3d_transpose( out4 = paddle.static.nn.conv3d_transpose(
input=data2, input=data2,
groups=3, groups=3,
num_filters=6, num_filters=6,
...@@ -121,7 +122,7 @@ class TestConv3DTransposeAPI(unittest.TestCase): ...@@ -121,7 +122,7 @@ class TestConv3DTransposeAPI(unittest.TestCase):
padding=[[0, 0], [0, 0], [1, 1], [1, 2], [0, 0]], padding=[[0, 0], [0, 0], [1, 1], [1, 2], [0, 0]],
data_format='NDHWC', data_format='NDHWC',
) )
out5 = fluid.layers.conv3d_transpose( out5 = paddle.static.nn.conv3d_transpose(
input=data2, input=data2,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -129,7 +130,7 @@ class TestConv3DTransposeAPI(unittest.TestCase): ...@@ -129,7 +130,7 @@ class TestConv3DTransposeAPI(unittest.TestCase):
padding='SAME', padding='SAME',
data_format='NCDHW', data_format='NCDHW',
) )
out6 = fluid.layers.conv3d_transpose( out6 = paddle.static.nn.conv3d_transpose(
input=data2, input=data2,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -137,7 +138,7 @@ class TestConv3DTransposeAPI(unittest.TestCase): ...@@ -137,7 +138,7 @@ class TestConv3DTransposeAPI(unittest.TestCase):
padding='VALID', padding='VALID',
data_format='NDHWC', data_format='NDHWC',
) )
out7 = fluid.layers.conv3d_transpose( out7 = paddle.static.nn.conv3d_transpose(
input=data2, input=data2,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -177,7 +178,7 @@ class TestConv3DTransposeOpException(unittest.TestCase): ...@@ -177,7 +178,7 @@ class TestConv3DTransposeOpException(unittest.TestCase):
) )
def attr_data_format(): def attr_data_format():
out = fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
input=data, input=data,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -188,7 +189,7 @@ class TestConv3DTransposeOpException(unittest.TestCase): ...@@ -188,7 +189,7 @@ class TestConv3DTransposeOpException(unittest.TestCase):
self.assertRaises(ValueError, attr_data_format) self.assertRaises(ValueError, attr_data_format)
def attr_padding_str(): def attr_padding_str():
out = fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
input=data, input=data,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -199,7 +200,7 @@ class TestConv3DTransposeOpException(unittest.TestCase): ...@@ -199,7 +200,7 @@ class TestConv3DTransposeOpException(unittest.TestCase):
self.assertRaises(ValueError, attr_padding_str) self.assertRaises(ValueError, attr_padding_str)
def attr_padding_list(): def attr_padding_list():
out = fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
input=data, input=data,
groups=1, groups=1,
num_filters=6, num_filters=6,
...@@ -210,7 +211,7 @@ class TestConv3DTransposeOpException(unittest.TestCase): ...@@ -210,7 +211,7 @@ class TestConv3DTransposeOpException(unittest.TestCase):
self.assertRaises(ValueError, attr_padding_list) self.assertRaises(ValueError, attr_padding_list)
def attr_padding_with_data_format(): def attr_padding_with_data_format():
out = fluid.layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
input=data, input=data,
groups=1, groups=1,
num_filters=6, num_filters=6,
......
...@@ -36,7 +36,7 @@ class TestConvTransposeDoubleGradCheck(unittest.TestCase): ...@@ -36,7 +36,7 @@ class TestConvTransposeDoubleGradCheck(unittest.TestCase):
if core.is_compiled_with_rocm(): if core.is_compiled_with_rocm():
dtype = np.float32 dtype = np.float32
x = layers.data('x', shape, False, dtype) x = layers.data('x', shape, False, dtype)
y = layers.conv2d_transpose( y = paddle.static.nn.conv2d_transpose(
x, 2, filter_size=1, groups=1, bias_attr=False x, 2, filter_size=1, groups=1, bias_attr=False
) )
x_arr = np.random.uniform(-1, 1, shape).astype(dtype) x_arr = np.random.uniform(-1, 1, shape).astype(dtype)
...@@ -92,7 +92,7 @@ class TestConvTranspose2DoubleGradCheck_AsyPadding( ...@@ -92,7 +92,7 @@ class TestConvTranspose2DoubleGradCheck_AsyPadding(
if core.is_compiled_with_rocm(): if core.is_compiled_with_rocm():
dtype = np.float32 dtype = np.float32
x = layers.data('x', shape, False, dtype) x = layers.data('x', shape, False, dtype)
y = layers.conv2d_transpose( y = paddle.static.nn.conv2d_transpose(
input=x, input=x,
num_filters=2, num_filters=2,
filter_size=1, filter_size=1,
...@@ -145,7 +145,7 @@ class TestConvTranspose2DoubleGradCheck_PaddingSAME( ...@@ -145,7 +145,7 @@ class TestConvTranspose2DoubleGradCheck_PaddingSAME(
if core.is_compiled_with_rocm(): if core.is_compiled_with_rocm():
dtype = np.float32 dtype = np.float32
x = layers.data('x', shape, False, dtype) x = layers.data('x', shape, False, dtype)
y = layers.conv2d_transpose( y = paddle.static.nn.conv2d_transpose(
input=x, input=x,
num_filters=2, num_filters=2,
filter_size=1, filter_size=1,
...@@ -198,7 +198,7 @@ class TestConvTranspose2DoubleGradCheck_PaddingVALID( ...@@ -198,7 +198,7 @@ class TestConvTranspose2DoubleGradCheck_PaddingVALID(
if core.is_compiled_with_rocm(): if core.is_compiled_with_rocm():
dtype = np.float32 dtype = np.float32
x = layers.data('x', shape, False, dtype) x = layers.data('x', shape, False, dtype)
y = layers.conv2d_transpose( y = paddle.static.nn.conv2d_transpose(
input=x, input=x,
num_filters=2, num_filters=2,
filter_size=1, filter_size=1,
...@@ -251,7 +251,7 @@ class TestConvTranspose2DoubleGradCheck_ChannelLast( ...@@ -251,7 +251,7 @@ class TestConvTranspose2DoubleGradCheck_ChannelLast(
if core.is_compiled_with_rocm(): if core.is_compiled_with_rocm():
dtype = np.float32 dtype = np.float32
x = layers.data('x', shape, False, dtype) x = layers.data('x', shape, False, dtype)
y = layers.conv2d_transpose( y = paddle.static.nn.conv2d_transpose(
input=x, input=x,
num_filters=2, num_filters=2,
filter_size=1, filter_size=1,
......
...@@ -89,7 +89,7 @@ class TestFunctionalConv2D(TestCase): ...@@ -89,7 +89,7 @@ class TestFunctionalConv2D(TestCase):
(-1, self.in_channels, -1, -1), (-1, self.in_channels, -1, -1),
dtype=self.dtype, dtype=self.dtype,
) )
y = fluid.layers.conv2d_transpose( y = paddle.static.nn.conv2d_transpose(
x, x,
self.out_channels, self.out_channels,
output_size=self.output_size, output_size=self.output_size,
......
...@@ -89,7 +89,7 @@ class TestFunctionalConv3DTranspose(TestCase): ...@@ -89,7 +89,7 @@ class TestFunctionalConv3DTranspose(TestCase):
(-1, self.in_channels, -1, -1, -1), (-1, self.in_channels, -1, -1, -1),
dtype=self.dtype, dtype=self.dtype,
) )
y = fluid.layers.conv3d_transpose( y = paddle.static.nn.conv3d_transpose(
x, x,
self.out_channels, self.out_channels,
output_size=self.output_size, output_size=self.output_size,
...@@ -550,7 +550,7 @@ class TestFunctionalConv3DTransposeErrorCase10(TestCase): ...@@ -550,7 +550,7 @@ class TestFunctionalConv3DTransposeErrorCase10(TestCase):
with fluid.unique_name.guard(): with fluid.unique_name.guard():
with fluid.program_guard(main, start): with fluid.program_guard(main, start):
x = fluid.data("input", self.input.shape, dtype=paddle.float32) x = fluid.data("input", self.input.shape, dtype=paddle.float32)
y = fluid.layers.conv3d_transpose( y = paddle.static.nn.conv3d_transpose(
x, x,
self.num_filters, self.num_filters,
self.filter_size, self.filter_size,
......
...@@ -103,20 +103,20 @@ class TestDygraphLoadStatic(unittest.TestCase): ...@@ -103,20 +103,20 @@ class TestDygraphLoadStatic(unittest.TestCase):
name="conv2d_trans_in", shape=[None, 10, 10, 10] name="conv2d_trans_in", shape=[None, 10, 10, 10]
) )
conv2d_trans_out_1 = fluid.layers.conv2d_transpose( conv2d_trans_out_1 = paddle.static.nn.conv2d_transpose(
conv2d_trans_in, num_filters=10, filter_size=5, act="relu" conv2d_trans_in, num_filters=10, filter_size=5, act="relu"
) )
conv2d_trans_out_2 = fluid.layers.conv2d_transpose( conv2d_trans_out_2 = paddle.static.nn.conv2d_transpose(
conv2d_trans_in, num_filters=10, filter_size=5, act="relu" conv2d_trans_in, num_filters=10, filter_size=5, act="relu"
) )
conv3d_trans_in = fluid.data( conv3d_trans_in = fluid.data(
name='conv3d_trans_in', shape=[None, 3, 12, 32, 32], dtype='float32' name='conv3d_trans_in', shape=[None, 3, 12, 32, 32], dtype='float32'
) )
conv3d_trans_out_1 = fluid.layers.conv3d_transpose( conv3d_trans_out_1 = paddle.static.nn.conv3d_transpose(
input=conv3d_trans_in, num_filters=2, filter_size=3, act="relu" input=conv3d_trans_in, num_filters=2, filter_size=3, act="relu"
) )
conv3d_trans_out_2 = fluid.layers.conv3d_transpose( conv3d_trans_out_2 = paddle.static.nn.conv3d_transpose(
input=conv3d_trans_in, num_filters=2, filter_size=3, act="relu" input=conv3d_trans_in, num_filters=2, filter_size=3, act="relu"
) )
......
...@@ -716,7 +716,7 @@ class TestLayer(LayerTest): ...@@ -716,7 +716,7 @@ class TestLayer(LayerTest):
inp_np = np.arange(0, 24).reshape([2, 3, 2, 2]).astype('float32') inp_np = np.arange(0, 24).reshape([2, 3, 2, 2]).astype('float32')
with self.static_graph(): with self.static_graph():
img = layers.data(name='pixel', shape=[3, 2, 2], dtype='float32') img = layers.data(name='pixel', shape=[3, 2, 2], dtype='float32')
out = layers.conv2d_transpose( out = paddle.static.nn.conv2d_transpose(
input=img, input=img,
num_filters=10, num_filters=10,
filter_size=27, filter_size=27,
...@@ -2270,7 +2270,7 @@ class TestLayer(LayerTest): ...@@ -2270,7 +2270,7 @@ class TestLayer(LayerTest):
with self.static_graph(): with self.static_graph():
img = layers.data(name='pixel', shape=[3, 2, 2, 2], dtype='float32') img = layers.data(name='pixel', shape=[3, 2, 2, 2], dtype='float32')
out = layers.conv3d_transpose( out = paddle.static.nn.conv3d_transpose(
input=img, num_filters=12, filter_size=12, use_cudnn=False input=img, num_filters=12, filter_size=12, use_cudnn=False
) )
static_rlt = self.get_static_graph_result( static_rlt = self.get_static_graph_result(
...@@ -3062,7 +3062,7 @@ class TestBook(LayerTest): ...@@ -3062,7 +3062,7 @@ class TestBook(LayerTest):
fluid.default_main_program(), fluid.default_startup_program() fluid.default_main_program(), fluid.default_startup_program()
): ):
img = self._get_data(name='pixel', shape=[3, 2, 2], dtype='float32') img = self._get_data(name='pixel', shape=[3, 2, 2], dtype='float32')
return layers.conv2d_transpose( return paddle.static.nn.conv2d_transpose(
input=img, num_filters=10, output_size=28 input=img, num_filters=10, output_size=28
) )
......
...@@ -14,15 +14,15 @@ ...@@ -14,15 +14,15 @@
from .common import fc # noqa: F401 from .common import fc # noqa: F401
from .common import deform_conv2d # noqa: F401 from .common import deform_conv2d # noqa: F401
from .common import conv2d_transpose # noqa: F401
from .common import conv3d_transpose # noqa: F401
from ...fluid.layers import batch_norm # noqa: F401 from ...fluid.layers import batch_norm # noqa: F401
from ...fluid.layers import bilinear_tensor_product # noqa: F401 from ...fluid.layers import bilinear_tensor_product # noqa: F401
from ...fluid.layers import case # noqa: F401 from ...fluid.layers import case # noqa: F401
from ...fluid.layers import cond # noqa: F401 from ...fluid.layers import cond # noqa: F401
from ...fluid.layers import conv2d # noqa: F401 from ...fluid.layers import conv2d # noqa: F401
from ...fluid.layers import conv2d_transpose # noqa: F401
from ...fluid.layers import conv3d # noqa: F401 from ...fluid.layers import conv3d # noqa: F401
from ...fluid.layers import conv3d_transpose # noqa: F401
from ...fluid.layers import create_parameter # noqa: F401 from ...fluid.layers import create_parameter # noqa: F401
from ...fluid.layers import crf_decoding # noqa: F401 from ...fluid.layers import crf_decoding # noqa: F401
from ...fluid.layers import data_norm # noqa: F401 from ...fluid.layers import data_norm # noqa: F401
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册