Skip to content

Commit 9c395d3

Browse files
authored
[Fluid Clean] remove unfold, deformable_roi_pooling, shard_index, hard_swish, mish, uniform_random, unbind (#48451)
1 parent f88713e commit 9c395d3

17 files changed

+59
-1422
lines changed

python/paddle/distribution/uniform.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
_non_static_mode,
2424
in_dygraph_mode,
2525
)
26-
from paddle.fluid.layers import nn, tensor
26+
from paddle.fluid.layers import tensor
2727
from paddle.tensor import random
2828

2929

@@ -187,7 +187,7 @@ def sample(self, shape, seed=0):
187187
return output
188188
else:
189189
output_shape = shape + batch_shape
190-
output = nn.uniform_random(
190+
output = paddle.uniform(
191191
output_shape, dtype=self.dtype, min=0.0, max=1.0, seed=seed
192192
) * (
193193
tensor.zeros(output_shape, dtype=self.dtype)

python/paddle/fluid/layers/nn.py

Lines changed: 0 additions & 671 deletions
Large diffs are not rendered by default.

python/paddle/fluid/tests/unittests/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,6 @@ set_tests_properties(test_bilinear_interp_v2_op PROPERTIES TIMEOUT 120)
10971097
set_tests_properties(test_svd_op PROPERTIES TIMEOUT 80)
10981098
set_tests_properties(test_einsum_op PROPERTIES TIMEOUT 120)
10991099
set_tests_properties(test_qr_op PROPERTIES TIMEOUT 60)
1100-
set_tests_properties(test_deformable_psroi_pooling PROPERTIES TIMEOUT 120)
11011100
set_tests_properties(test_trilinear_interp_v2_op PROPERTIES TIMEOUT 120)
11021101
set_tests_properties(test_imperative_static_runner_mnist PROPERTIES TIMEOUT 120)
11031102
set_tests_properties(test_masked_select_op PROPERTIES TIMEOUT 120)

python/paddle/fluid/tests/unittests/ir/inference/test_mkldnn_elt_act_fuse_pass.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class ElementwiseActivationMkldnnFusePassTest_Add_HardSwish(
102102
):
103103
def set_params(self):
104104
self.operand = paddle.add
105-
self.act = fluid.layers.hard_swish
105+
self.act = paddle.nn.functional.hardswish
106106

107107

108108
class ElementwiseActivationMkldnnFusePassTest_Add_SQRT(
@@ -202,7 +202,7 @@ class ElementwiseActivationMkldnnFusePassTest_Sub_HardSwish(
202202
):
203203
def set_params(self):
204204
self.operand = paddle.subtract
205-
self.act = fluid.layers.hard_swish
205+
self.act = paddle.nn.functional.hardswish
206206

207207

208208
class ElementwiseActivationMkldnnFusePassTest_Sub_ABS(
@@ -294,7 +294,7 @@ class ElementwiseActivationMkldnnFusePassTest_Mul_HardSwish(
294294
):
295295
def set_params(self):
296296
self.operand = paddle.multiply
297-
self.act = fluid.layers.hard_swish
297+
self.act = paddle.nn.functional.hardswish
298298

299299

300300
class ElementwiseActivationMkldnnFusePassTest_Mul_SQRT(

python/paddle/fluid/tests/unittests/ir/inference/test_trt_activation_pass.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def append_act(self, x):
8888

8989
class TensorRTSubgraphPassHardSwishTest(TensorRTSubgraphPassActivationTest):
9090
def append_act(self, x):
91-
return fluid.layers.hard_swish(x)
91+
return paddle.nn.functional.hardswish(x)
9292

9393

9494
class TensorRTSubgraphPassHardSigmoidTest(TensorRTSubgraphPassActivationTest):
@@ -100,7 +100,7 @@ class TensorRTSubgraphPassHardSwishPluginTest(
100100
TensorRTSubgraphPassActivationTest
101101
):
102102
def append_act(self, x):
103-
return fluid.layers.hard_swish(x, threshold=4.0, scale=8.0)
103+
return paddle.nn.functional.hardswish(x)
104104

105105

106106
class TensorRTSubgraphPassClipTest(TensorRTSubgraphPassActivationTest):
@@ -166,7 +166,7 @@ def setUpTensorRTParam(self):
166166
)
167167

168168
def append_act(self, x):
169-
return fluid.layers.mish(x)
169+
return paddle.nn.functional.mish(x)
170170

171171

172172
class TensorRTSubgraphPassMishFp16SerializeTest(
@@ -179,7 +179,7 @@ def setUpTensorRTParam(self):
179179
)
180180

181181
def append_act(self, x):
182-
return fluid.layers.mish(x)
182+
return paddle.nn.functional.mish(x)
183183

184184

185185
class TensorRTSubgraphPassDynamicMishFp16SerializeTest(
@@ -200,7 +200,7 @@ def setUpTensorRTParam(self):
200200
)
201201

202202
def append_act(self, x):
203-
return fluid.layers.mish(x)
203+
return paddle.nn.functional.mish(x)
204204

205205

206206
class TensorRTSubgraphPassPreluAllTest(TensorRTSubgraphPassActivationTest):

python/paddle/fluid/tests/unittests/test_activation_op.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,15 +2073,15 @@ def test_dygraph_api(self):
20732073
def test_fluid_api(self):
20742074
with fluid.program_guard(fluid.Program()):
20752075
x = fluid.data('X', self.x_np.shape, self.x_np.dtype)
2076-
out = fluid.layers.hard_swish(x)
2076+
out = paddle.nn.functional.hardswish(x)
20772077
exe = fluid.Executor(self.place)
20782078
res = exe.run(feed={'X': self.x_np}, fetch_list=[out])
20792079
out_ref = ref_hardswish(self.x_np)
20802080
np.testing.assert_allclose(out_ref, res[0], rtol=1e-05)
20812081

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

@@ -3414,7 +3414,7 @@ def ref_mish(x, threshold=20.0):
34143414
class TestMish(TestActivation):
34153415
def setUp(self):
34163416
self.op_type = "mish"
3417-
self.python_api = paddle.fluid.layers.nn.mish
3417+
self.python_api = paddle.nn.functional.mish
34183418
self.init_dtype()
34193419
self.init_shape()
34203420

@@ -3480,7 +3480,7 @@ def test_fluid_api(self):
34803480
paddle.enable_static()
34813481
with fluid.program_guard(fluid.Program()):
34823482
x = fluid.data('X', self.x_np.shape, self.x_np.dtype)
3483-
out = fluid.layers.mish(x)
3483+
out = paddle.nn.functional.mish(x)
34843484
exe = fluid.Executor(self.place)
34853485
res = exe.run(feed={'X': self.x_np}, fetch_list=[out])
34863486
out_ref = ref_mish(self.x_np)

python/paddle/fluid/tests/unittests/test_cuda_random_seed.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,19 @@ def test_gen_dropout_dygraph(self):
4141
gen.manual_seed(111111111)
4242
st = paddle.get_cuda_rng_state()
4343

44-
x = fluid.layers.uniform_random(
45-
[2, 10], dtype="float32", min=0.0, max=1.0
46-
)
47-
x_again = fluid.layers.uniform_random(
48-
[2, 10], dtype="float32", min=0.0, max=1.0
49-
)
50-
x_third = fluid.layers.uniform_random(
51-
[2, 10], dtype="float32", min=0.0, max=1.0
52-
)
44+
x = paddle.uniform([2, 10], dtype="float32", min=0.0, max=1.0)
45+
x_again = paddle.uniform([2, 10], dtype="float32", min=0.0, max=1.0)
46+
x_third = paddle.uniform([2, 10], dtype="float32", min=0.0, max=1.0)
5347
print("x: {}".format(x.numpy()))
5448
print("x_again: {}".format(x_again.numpy()))
5549
x = x + x_again + x_third
5650
y = fluid.layers.dropout(x, 0.5)
5751

5852
paddle.set_cuda_rng_state(st)
5953

60-
x1 = fluid.layers.uniform_random(
61-
[2, 10], dtype="float32", min=0.0, max=1.0
62-
)
63-
x1_again = fluid.layers.uniform_random(
64-
[2, 10], dtype="float32", min=0.0, max=1.0
65-
)
66-
x1_third = fluid.layers.uniform_random(
67-
[2, 10], dtype="float32", min=0.0, max=1.0
68-
)
54+
x1 = paddle.uniform([2, 10], dtype="float32", min=0.0, max=1.0)
55+
x1_again = paddle.uniform([2, 10], dtype="float32", min=0.0, max=1.0)
56+
x1_third = paddle.uniform([2, 10], dtype="float32", min=0.0, max=1.0)
6957
x1 = x1 + x1_again + x1_third
7058
y1 = fluid.layers.dropout(x1, 0.5)
7159
y_np = y.numpy()
@@ -128,7 +116,7 @@ def test_gen_TruncatedNormal_initializer(self):
128116
with fluid.program_guard(train_program, startup_program):
129117
# example 1:
130118
# attr shape is a list which doesn't contain tensor Variable.
131-
x = fluid.layers.uniform_random(shape=[2, 10])
119+
x = paddle.uniform(shape=[2, 10])
132120
result_1 = fluid.layers.fc(
133121
input=x,
134122
size=10,

0 commit comments

Comments
 (0)