diff --git a/python/paddle/distributed/fleet/metrics/metric.py b/python/paddle/distributed/fleet/metrics/metric.py index 80900d7f1f2ed6de881ca1554d0d24f816e0b3c1..8c15e47307381d862b15518cf860e34d4f9c4280 100644 --- a/python/paddle/distributed/fleet/metrics/metric.py +++ b/python/paddle/distributed/fleet/metrics/metric.py @@ -41,7 +41,7 @@ def sum(input, scope=None, util=None): input = fluid.layers.cast(some_input, dtype='float32') cnt = paddle.sum(input) global_cnt = paddle.static.create_global_var(persistable=True, dtype='float32', shape=[1], value=0) - tmp = fluid.layers.elementwise_add(cnt, global_cnt) + tmp = paddle.add(cnt, global_cnt) fluid.layers.assign(tmp, global_cnt) # in train.py, after train or infer @@ -121,7 +121,7 @@ def min(input, scope=None, util=None): input = fluid.layers.cast(some_input, dtype='float32') cnt = paddle.sum(input) global_cnt = paddle.static.create_global_var(persistable=True, dtype='float32', shape=[1], value=0) - tmp = fluid.layers.elementwise_min(cnt, global_cnt) + tmp = paddle.minimum(cnt, global_cnt) fluid.layers.assign(tmp, global_cnt) # in train.py, after train or infer @@ -161,7 +161,7 @@ def auc(stat_pos, stat_neg, scope=None, util=None): # in model.py similarity_norm = fluid.layers.sigmoid(fluid.layers.clip(output, min=-15.0, max=15.0)) binary_predict = fluid.layers.concat( - input=[fluid.layers.elementwise_sub(fluid.layers.ceil(similarity_norm), similarity_norm), similarity_norm], axis=1) + input=[paddle.subtract(fluid.layers.ceil(similarity_norm), similarity_norm), similarity_norm], axis=1) self.auc, batch_auc, [batch_stat_pos, batch_stat_neg, stat_pos, stat_neg] = paddle.static.auc(input=binary_predict, label=label, curve='ROC', num_thresholds=4096) @@ -396,11 +396,11 @@ def acc(correct, total, scope=None, util=None): acc = fluid.layers.acc(predict, label, k=1, correct=correct, total=total) global_correct = paddle.static.create_global_var(persistable=True, dtype='float32', shape=[1], value=0) - tmp1 = fluid.layers.elementwise_min(correct, global_correct) + tmp1 = paddle.minimum(correct, global_correct) fluid.layers.assign(tmp1, global_correct) global_total = paddle.static.create_global_var(persistable=True, dtype='float32', shape=[1], value=0) - tmp2 = fluid.layers.elementwise_min(total, global_total) + tmp2 = paddle.minimum(total, global_total) fluid.layers.assign(tmp2, global_total) # in train.py, after train or infer diff --git a/python/paddle/fluid/data_feeder.py b/python/paddle/fluid/data_feeder.py index 2728cbfb8d28f77c3e2266347bea983f86eb350f..03fb59c2594d26217f44f53338e6f870f29fc24d 100644 --- a/python/paddle/fluid/data_feeder.py +++ b/python/paddle/fluid/data_feeder.py @@ -485,7 +485,7 @@ class DataFeeder: x = fluid.data(name='x', shape=[None, 2, 2]) y = fluid.data(name='y', shape=[None, 2, 2], dtype='float32') - z = fluid.layers.elementwise_add(x, y) + z = paddle.add(x, y) feeder = fluid.DataFeeder(['x','y'], fluid.CPUPlace()) place_num = 2 diff --git a/python/paddle/fluid/incubate/fleet/utils/fleet_util.py b/python/paddle/fluid/incubate/fleet/utils/fleet_util.py index 9678914b50bed30c4eba7da1bdffcc99769cb601..df198931199f59520368faee025a77b42b5bdcd7 100644 --- a/python/paddle/fluid/incubate/fleet/utils/fleet_util.py +++ b/python/paddle/fluid/incubate/fleet/utils/fleet_util.py @@ -188,7 +188,7 @@ class FleetUtil: similarity_norm = fluid.layers.sigmoid(fluid.layers.clip(\ emb, min=-15.0, max=15.0), name="similarity_norm")\ binary_predict = fluid.layers.concat(input=[\ - fluid.layers.elementwise_sub(\ + paddle.subtract(\ fluid.layers.ceil(similarity_norm), similarity_norm),\ similarity_norm], axis=1) auc, batch_auc, [batch_stat_pos, batch_stat_neg, stat_pos, \ @@ -1377,7 +1377,7 @@ class FleetUtil: similarity_norm = fluid.layers.sigmoid(fluid.layers.clip(\ emb, min=-15.0, max=15.0), name="similarity_norm")\ binary_predict = fluid.layers.concat(input=[\ - fluid.layers.elementwise_sub(\ + paddle.subtract(\ fluid.layers.ceil(similarity_norm), similarity_norm),\ similarity_norm], axis=1) auc, batch_auc, [batch_stat_pos, batch_stat_neg, stat_pos, \ @@ -1577,7 +1577,7 @@ class FleetUtil: similarity_norm = fluid.layers.sigmoid(fluid.layers.clip(\ emb, min=-15.0, max=15.0), name="similarity_norm")\ binary_predict = fluid.layers.concat(input=[\ - fluid.layers.elementwise_sub(\ + paddle.subtract(\ fluid.layers.ceil(similarity_norm), similarity_norm),\ similarity_norm], axis=1) auc, batch_auc, [batch_stat_pos, batch_stat_neg, stat_pos, \ diff --git a/python/paddle/fluid/io.py b/python/paddle/fluid/io.py index 1e07431f7bbe8c958cdbb168faad165df41ce337..51ea32196a8047a5d1551210f9f0593da5305469 100644 --- a/python/paddle/fluid/io.py +++ b/python/paddle/fluid/io.py @@ -359,7 +359,7 @@ def save_vars( w = paddle.create_parameter(shape=[784, 200], dtype='float32', name='fc_w') b = paddle.create_parameter(shape=[200], dtype='float32', name='fc_b') hidden_w = paddle.matmul(x=data, y=w) - hidden_b = fluid.layers.elementwise_add(hidden_w, b) + hidden_b = paddle.add(hidden_w, b) place = fluid.CPUPlace() exe = fluid.Executor(place) exe.run(startup_prog) @@ -834,7 +834,7 @@ def load_vars( w = paddle.create_parameter(shape=[784, 200], dtype='float32', name='fc_w') b = paddle.create_parameter(shape=[200], dtype='float32', name='fc_b') hidden_w = paddle.matmul(x=data, y=w) - hidden_b = fluid.layers.elementwise_add(hidden_w, b) + hidden_b = paddle.add(hidden_w, b) place = fluid.CPUPlace() exe = fluid.Executor(place) exe.run(startup_prog) @@ -1602,7 +1602,7 @@ def load_inference_model( w = paddle.create_parameter(shape=[784, 200], dtype='float32') b = paddle.create_parameter(shape=[200], dtype='float32') hidden_w = paddle.matmul(x=data, y=w) - hidden_b = fluid.layers.elementwise_add(hidden_w, b) + hidden_b = paddle.add(hidden_w, b) place = fluid.CPUPlace() exe = fluid.Executor(place) exe.run(startup_prog) diff --git a/python/paddle/fluid/layers/control_flow.py b/python/paddle/fluid/layers/control_flow.py index 3cf045559fb9f5b9f4cbe8715e13fa33c5aedeed..158480aa281e29e7389c287f42c3fa1cf33a1add 100755 --- a/python/paddle/fluid/layers/control_flow.py +++ b/python/paddle/fluid/layers/control_flow.py @@ -1088,10 +1088,10 @@ class While: cond = paddle.less_than(x=i, y=loop_len) while_op = fluid.layers.While(cond=cond) with while_op.block(): - sums_tensor = fluid.layers.elementwise_add(x=data, y=data) + sums_tensor = paddle.add(x=data, y=data) fluid.layers.assign(sums_tensor, sums) # Update the value of sums_tensor defined in While to the sums which defined outside of While through layers.assign i = paddle.increment(x=i, value=1) - data = fluid.layers.elementwise_add(x=data, y=one) + data = paddle.add(x=data, y=one) paddle.assign(paddle.less_than(x=i, y=loop_len), cond) feed_data = np.ones(1).astype('float32') diff --git a/python/paddle/fluid/tests/unittests/xpu/test_assign_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_assign_op_xpu.py index c44867c1b02b1f67d243c86a45a293ea2153a2f8..9e18f20ca088120bfea7376c213810ff20f40581 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_assign_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_assign_op_xpu.py @@ -47,7 +47,7 @@ class TestAssignOpWithLoDTensorArray(unittest.TestCase): x.stop_gradient = False y = fluid.layers.fill_constant( shape=[100, 10], dtype='float32', value=1) - z = fluid.layers.elementwise_add(x=x, y=y) + z = paddle.add(x=x, y=y) i = fluid.layers.fill_constant(shape=[1], dtype='int64', value=0) init_array = paddle.tensor.array_write(x=z, i=i) array = fluid.layers.assign(init_array)