未验证 提交 b68e0c47 编写于 作者: H HongyuJia 提交者: GitHub

clean fluid elementwise_max (part2): remove API (#48034)

上级 d6be9000
...@@ -79,7 +79,7 @@ def max(input, scope=None, util=None): ...@@ -79,7 +79,7 @@ def max(input, scope=None, util=None):
input = fluid.layers.cast(some_input, dtype='float32') input = fluid.layers.cast(some_input, dtype='float32')
cnt = fluid.layers.reduce_sum(input) cnt = fluid.layers.reduce_sum(input)
global_cnt = fluid.layers.create_global_var(persistable=True, dtype='float32', shape=[1], value=0) global_cnt = fluid.layers.create_global_var(persistable=True, dtype='float32', shape=[1], value=0)
tmp = fluid.layers.elementwise_max(cnt, global_cnt) tmp = paddle.maximum(cnt, global_cnt)
fluid.layers.assign(tmp, global_cnt) fluid.layers.assign(tmp, global_cnt)
# in train.py, after train or infer # in train.py, after train or infer
......
...@@ -154,7 +154,6 @@ __all__ = [ ...@@ -154,7 +154,6 @@ __all__ = [
'elementwise_div', 'elementwise_div',
'elementwise_sub', 'elementwise_sub',
'elementwise_mul', 'elementwise_mul',
'elementwise_max',
'elementwise_min', 'elementwise_min',
'elementwise_pow', 'elementwise_pow',
'elementwise_mod', 'elementwise_mod',
...@@ -12632,71 +12631,6 @@ def elementwise_mul(x, y, axis=-1, act=None, name=None): ...@@ -12632,71 +12631,6 @@ def elementwise_mul(x, y, axis=-1, act=None, name=None):
return _elementwise_op(LayerHelper('elementwise_mul', **locals())) return _elementwise_op(LayerHelper('elementwise_mul', **locals()))
def elementwise_max(x, y, axis=-1, act=None, name=None):
"""
:alias_main: paddle.elementwise_max
:alias: paddle.elementwise_max,paddle.tensor.elementwise_max,paddle.tensor.math.elementwise_max
:old_api: paddle.fluid.layers.elementwise_max
Examples:
.. code-block:: python
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.array([2, 3, 4]).astype('float32'),
"y": np.array([1, 5, 2]).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[3], dtype='float32')
y = fluid.data(name="y", shape=[3], dtype='float32')
z = fluid.layers.elementwise_max(x, y)
place = fluid.CPUPlace()
exe = fluid.Executor(place)
z_value = exe.run(feed=gen_data(),
fetch_list=[z.name])
print(z_value) #[2, 5, 4]
.. code-block:: python
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.ones((2, 3, 4, 5)).astype('float32'),
"y": np.zeros((3, 4)).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
y = fluid.data(name="y", shape=[3,4], dtype='float32')
z = fluid.layers.elementwise_max(x, y, axis=1)
place = fluid.CPUPlace()
exe = fluid.Executor(place)
z_value = exe.run(feed=gen_data(),
fetch_list=[z.name])
print(z_value)#[[[[1., 1., 1., 1., 1.] .... [1., 1., 1., 1., 1.]]]]
"""
if _non_static_mode():
return _elementwise_op_in_dygraph(
x, y, axis=axis, act=act, op_name='elementwise_max'
)
return _elementwise_op(LayerHelper('elementwise_max', **locals()))
def elementwise_min(x, y, axis=-1, act=None, name=None): def elementwise_min(x, y, axis=-1, act=None, name=None):
""" """
:alias_main: paddle.elementwise_min :alias_main: paddle.elementwise_min
...@@ -12874,7 +12808,6 @@ for func in [ ...@@ -12874,7 +12808,6 @@ for func in [
elementwise_div, elementwise_div,
elementwise_sub, elementwise_sub,
elementwise_mul, elementwise_mul,
elementwise_max,
elementwise_pow, elementwise_pow,
elementwise_min, elementwise_min,
elementwise_mod, elementwise_mod,
......
...@@ -145,7 +145,7 @@ class TestMin(TestMul): ...@@ -145,7 +145,7 @@ class TestMin(TestMul):
class TestMax(TestMul): class TestMax(TestMul):
def set_test_op(self): def set_test_op(self):
self.op = paddle.fluid.layers.elementwise_max self.op = paddle.maximum
class TestPow(TestMul): class TestPow(TestMul):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册