Skip to content

Commit

Permalink
[Fluid Clean] remove unfold, deformable_roi_pooling, shard_index, har…
Browse files Browse the repository at this point in the history
…d_swish, mish, uniform_random, unbind (#48451)
  • Loading branch information
heyanru01 authored Dec 8, 2022
1 parent f88713e commit 9c395d3
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 1,422 deletions.
4 changes: 2 additions & 2 deletions python/paddle/distribution/uniform.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
_non_static_mode,
in_dygraph_mode,
)
from paddle.fluid.layers import nn, tensor
from paddle.fluid.layers import tensor
from paddle.tensor import random


Expand Down Expand Up @@ -187,7 +187,7 @@ def sample(self, shape, seed=0):
return output
else:
output_shape = shape + batch_shape
output = nn.uniform_random(
output = paddle.uniform(
output_shape, dtype=self.dtype, min=0.0, max=1.0, seed=seed
) * (
tensor.zeros(output_shape, dtype=self.dtype)
Expand Down
671 changes: 0 additions & 671 deletions python/paddle/fluid/layers/nn.py

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion python/paddle/fluid/tests/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,6 @@ set_tests_properties(test_bilinear_interp_v2_op PROPERTIES TIMEOUT 120)
set_tests_properties(test_svd_op PROPERTIES TIMEOUT 80)
set_tests_properties(test_einsum_op PROPERTIES TIMEOUT 120)
set_tests_properties(test_qr_op PROPERTIES TIMEOUT 60)
set_tests_properties(test_deformable_psroi_pooling PROPERTIES TIMEOUT 120)
set_tests_properties(test_trilinear_interp_v2_op PROPERTIES TIMEOUT 120)
set_tests_properties(test_imperative_static_runner_mnist PROPERTIES TIMEOUT 120)
set_tests_properties(test_masked_select_op PROPERTIES TIMEOUT 120)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class ElementwiseActivationMkldnnFusePassTest_Add_HardSwish(
):
def set_params(self):
self.operand = paddle.add
self.act = fluid.layers.hard_swish
self.act = paddle.nn.functional.hardswish


class ElementwiseActivationMkldnnFusePassTest_Add_SQRT(
Expand Down Expand Up @@ -202,7 +202,7 @@ class ElementwiseActivationMkldnnFusePassTest_Sub_HardSwish(
):
def set_params(self):
self.operand = paddle.subtract
self.act = fluid.layers.hard_swish
self.act = paddle.nn.functional.hardswish


class ElementwiseActivationMkldnnFusePassTest_Sub_ABS(
Expand Down Expand Up @@ -294,7 +294,7 @@ class ElementwiseActivationMkldnnFusePassTest_Mul_HardSwish(
):
def set_params(self):
self.operand = paddle.multiply
self.act = fluid.layers.hard_swish
self.act = paddle.nn.functional.hardswish


class ElementwiseActivationMkldnnFusePassTest_Mul_SQRT(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def append_act(self, x):

class TensorRTSubgraphPassHardSwishTest(TensorRTSubgraphPassActivationTest):
def append_act(self, x):
return fluid.layers.hard_swish(x)
return paddle.nn.functional.hardswish(x)


class TensorRTSubgraphPassHardSigmoidTest(TensorRTSubgraphPassActivationTest):
Expand All @@ -100,7 +100,7 @@ class TensorRTSubgraphPassHardSwishPluginTest(
TensorRTSubgraphPassActivationTest
):
def append_act(self, x):
return fluid.layers.hard_swish(x, threshold=4.0, scale=8.0)
return paddle.nn.functional.hardswish(x)


class TensorRTSubgraphPassClipTest(TensorRTSubgraphPassActivationTest):
Expand Down Expand Up @@ -166,7 +166,7 @@ def setUpTensorRTParam(self):
)

def append_act(self, x):
return fluid.layers.mish(x)
return paddle.nn.functional.mish(x)


class TensorRTSubgraphPassMishFp16SerializeTest(
Expand All @@ -179,7 +179,7 @@ def setUpTensorRTParam(self):
)

def append_act(self, x):
return fluid.layers.mish(x)
return paddle.nn.functional.mish(x)


class TensorRTSubgraphPassDynamicMishFp16SerializeTest(
Expand All @@ -200,7 +200,7 @@ def setUpTensorRTParam(self):
)

def append_act(self, x):
return fluid.layers.mish(x)
return paddle.nn.functional.mish(x)


class TensorRTSubgraphPassPreluAllTest(TensorRTSubgraphPassActivationTest):
Expand Down
8 changes: 4 additions & 4 deletions python/paddle/fluid/tests/unittests/test_activation_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -2073,15 +2073,15 @@ def test_dygraph_api(self):
def test_fluid_api(self):
with fluid.program_guard(fluid.Program()):
x = fluid.data('X', self.x_np.shape, self.x_np.dtype)
out = fluid.layers.hard_swish(x)
out = paddle.nn.functional.hardswish(x)
exe = fluid.Executor(self.place)
res = exe.run(feed={'X': self.x_np}, fetch_list=[out])
out_ref = ref_hardswish(self.x_np)
np.testing.assert_allclose(out_ref, res[0], rtol=1e-05)

paddle.disable_static(self.place)
x = paddle.to_tensor(self.x_np)
out = paddle.fluid.layers.hard_swish(x)
out = paddle.nn.functional.hardswish(x)
np.testing.assert_allclose(out_ref, out.numpy(), rtol=1e-05)
paddle.enable_static()

Expand Down Expand Up @@ -3414,7 +3414,7 @@ def ref_mish(x, threshold=20.0):
class TestMish(TestActivation):
def setUp(self):
self.op_type = "mish"
self.python_api = paddle.fluid.layers.nn.mish
self.python_api = paddle.nn.functional.mish
self.init_dtype()
self.init_shape()

Expand Down Expand Up @@ -3480,7 +3480,7 @@ def test_fluid_api(self):
paddle.enable_static()
with fluid.program_guard(fluid.Program()):
x = fluid.data('X', self.x_np.shape, self.x_np.dtype)
out = fluid.layers.mish(x)
out = paddle.nn.functional.mish(x)
exe = fluid.Executor(self.place)
res = exe.run(feed={'X': self.x_np}, fetch_list=[out])
out_ref = ref_mish(self.x_np)
Expand Down
26 changes: 7 additions & 19 deletions python/paddle/fluid/tests/unittests/test_cuda_random_seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,19 @@ def test_gen_dropout_dygraph(self):
gen.manual_seed(111111111)
st = paddle.get_cuda_rng_state()

x = fluid.layers.uniform_random(
[2, 10], dtype="float32", min=0.0, max=1.0
)
x_again = fluid.layers.uniform_random(
[2, 10], dtype="float32", min=0.0, max=1.0
)
x_third = fluid.layers.uniform_random(
[2, 10], dtype="float32", min=0.0, max=1.0
)
x = paddle.uniform([2, 10], dtype="float32", min=0.0, max=1.0)
x_again = paddle.uniform([2, 10], dtype="float32", min=0.0, max=1.0)
x_third = paddle.uniform([2, 10], dtype="float32", min=0.0, max=1.0)
print("x: {}".format(x.numpy()))
print("x_again: {}".format(x_again.numpy()))
x = x + x_again + x_third
y = fluid.layers.dropout(x, 0.5)

paddle.set_cuda_rng_state(st)

x1 = fluid.layers.uniform_random(
[2, 10], dtype="float32", min=0.0, max=1.0
)
x1_again = fluid.layers.uniform_random(
[2, 10], dtype="float32", min=0.0, max=1.0
)
x1_third = fluid.layers.uniform_random(
[2, 10], dtype="float32", min=0.0, max=1.0
)
x1 = paddle.uniform([2, 10], dtype="float32", min=0.0, max=1.0)
x1_again = paddle.uniform([2, 10], dtype="float32", min=0.0, max=1.0)
x1_third = paddle.uniform([2, 10], dtype="float32", min=0.0, max=1.0)
x1 = x1 + x1_again + x1_third
y1 = fluid.layers.dropout(x1, 0.5)
y_np = y.numpy()
Expand Down Expand Up @@ -128,7 +116,7 @@ def test_gen_TruncatedNormal_initializer(self):
with fluid.program_guard(train_program, startup_program):
# example 1:
# attr shape is a list which doesn't contain tensor Variable.
x = fluid.layers.uniform_random(shape=[2, 10])
x = paddle.uniform(shape=[2, 10])
result_1 = fluid.layers.fc(
input=x,
size=10,
Expand Down
Loading

0 comments on commit 9c395d3

Please sign in to comment.