Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[remove fluid] PRelu BilinearTensorProduct Conv2DTranspose SequenceConv RowConv #48654

Merged
merged 14 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
634 changes: 0 additions & 634 deletions python/paddle/fluid/dygraph/nn.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ def test_transformed_static_result(self):

# 1. test Apis that inherit from layers.Layer
def dyfunc_BilinearTensorProduct(layer1, layer2):
bilinearTensorProduct = fluid.dygraph.nn.BilinearTensorProduct(
input1_dim=5,
input2_dim=4,
output_dim=1000,
param_attr=fluid.ParamAttr(
bilinearTensorProduct = paddle.nn.Bilinear(
5,
4,
1000,
weight_attr=fluid.ParamAttr(
initializer=fluid.initializer.Constant(value=0.99)
),
bias_attr=fluid.ParamAttr(
Expand Down Expand Up @@ -165,12 +165,11 @@ def dyfunc_Conv3D(input):


def dyfunc_Conv2DTranspose(input):
conv2dTranspose = fluid.dygraph.nn.Conv2DTranspose(
num_channels=3,
num_filters=12,
filter_size=12,
use_cudnn=False,
param_attr=fluid.ParamAttr(
conv2dTranspose = paddle.nn.Conv2DTranspose(
3,
12,
12,
weight_attr=fluid.ParamAttr(
initializer=fluid.initializer.Constant(value=0.99)
),
bias_attr=fluid.ParamAttr(
Expand Down Expand Up @@ -221,11 +220,12 @@ def dyfunc_Pool2D(input):


def dyfunc_Prelu(input):
prelu0 = fluid.PRelu(
mode='all',
param_attr=fluid.ParamAttr(initializer=fluid.initializer.Constant(1.0)),
prelu0 = paddle.nn.PReLU(
weight_attr=fluid.ParamAttr(
initializer=fluid.initializer.Constant(1.0)
),
)
res = prelu0(input=input)
res = prelu0(input)
return res


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph import to_variable
from paddle.fluid.dygraph.nn import BatchNorm, Conv2DTranspose
from paddle.fluid.dygraph.nn import BatchNorm
from paddle.jit import ProgramTranslator
from paddle.jit.api import declarative

Expand Down Expand Up @@ -430,14 +430,13 @@ def __init__(
initializer=fluid.initializer.Constant(0.0)
)

self._deconv = Conv2DTranspose(
self._deconv = paddle.nn.Conv2DTranspose(
num_channels,
num_filters,
filter_size=filter_size,
filter_size,
stride=stride,
padding=padding,
use_cudnn=use_cudnn,
param_attr=fluid.ParamAttr(
weight_attr=fluid.ParamAttr(
initializer=fluid.initializer.NormalInitializer(
loc=0.0, scale=stddev
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
class TestDygraphBilinearTensorProductAPIError(unittest.TestCase):
def test_errors(self):
with fluid.program_guard(fluid.Program(), fluid.Program()):
layer = fluid.dygraph.nn.BilinearTensorProduct(
input1_dim=5, input2_dim=4, output_dim=1000
)
layer = paddle.nn.Bilinear(5, 4, 1000)
# the input must be Variable.
x0 = fluid.create_lod_tensor(
np.array([-1, 3, 5, 5]), [[1, 1, 1, 1]], fluid.CPUPlace()
Expand Down
81 changes: 0 additions & 81 deletions python/paddle/fluid/tests/unittests/test_conv2d_transpose_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -1084,86 +1084,5 @@ def call_func(self, x):
return out


class TestTensorOutputSize5(TestTensorOutputSize1):
def path_prefix(self):
return 'conv2d_transpose_tensor_output_size5'

def call_func(self, x):
w_var = paddle.randn((3, 6, 3, 3), dtype='float32')
output_size = [17, paddle.assign([17])]
conv2d_trans = paddle.fluid.dygraph.Conv2DTranspose(
num_channels=3,
num_filters=6,
filter_size=3,
output_size=output_size,
stride=2,
)
out = conv2d_trans(x)
return out


class TestTensorOutputSize6(TestTensorOutputSize1):
def path_prefix(self):
return 'conv2d_transpose_tensor_output_size6'

def var_prefix(self):
return "Var["

def call_func(self, x):
w_var = paddle.randn((3, 6, 3, 3), dtype='float32')
output_size = paddle.assign([17, 17])
conv2d_trans = paddle.fluid.dygraph.Conv2DTranspose(
num_channels=3,
num_filters=6,
filter_size=3,
output_size=output_size,
stride=2,
)
out = conv2d_trans(x)
return out


class TestTensorOutputSize7(TestTensorOutputSize1):
def path_prefix(self):
return 'conv2d_transpose_tensor_output_size7'

def var_prefix(self):
return ""

def call_func(self, x):
w_var = paddle.randn((3, 6, 3, 3), dtype='float32')
output_size = 17
conv2d_trans = paddle.fluid.dygraph.Conv2DTranspose(
num_channels=3,
num_filters=6,
filter_size=3,
output_size=output_size,
stride=2,
)
out = conv2d_trans(x)
return out


class TestTensorOutputSize8(TestTensorOutputSize1):
def path_prefix(self):
return 'conv2d_transpose_tensor_output_size8'

def var_prefix(self):
return ""

def call_func(self, x):
w_var = paddle.randn((3, 6, 3, 3), dtype='float32')
output_size = [17, 17]
conv2d_trans = paddle.fluid.dygraph.Conv2DTranspose(
num_channels=3,
num_filters=6,
filter_size=3,
output_size=output_size,
stride=2,
)
out = conv2d_trans(x)
return out


if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest

import numpy as np

import paddle
import paddle.fluid as fluid
import numpy as np
import unittest


def infinite_reader():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import paddle
import paddle.fluid as fluid
import paddle.fluid.framework as framework
from paddle.fluid.dygraph.nn import BatchNorm, Embedding, GroupNorm, PRelu
from paddle.fluid.dygraph.nn import BatchNorm, Embedding, GroupNorm
from paddle.nn import Linear


Expand Down Expand Up @@ -212,9 +212,6 @@ def __init__(self):
self.layer_norm_1 = paddle.nn.LayerNorm([10])
self.layer_norm_2 = paddle.nn.LayerNorm(10)

self.prelu1 = PRelu("channel", channel=5)
self.prelu2 = PRelu("channel", channel=5)

self.group_norm1 = GroupNorm(8, 4)
self.gourp_norm2 = GroupNorm(8, 4)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ def __init__(
):
super().__init__()

self._deconv = fluid.dygraph.Conv2DTranspose(
num_channels=num_channels,
num_filters=num_filters,
filter_size=filter_size,
self._deconv = paddle.nn.Conv2DTranspose(
num_channels,
num_filters,
filter_size,
stride=stride,
padding=padding,
bias_attr=None if use_bias else False,
Expand Down
Loading