diff --git a/python/paddle/common_ops_import.py b/python/paddle/common_ops_import.py index 47bce838936d442e4237fc5f04b093520e457646..7169671ad3c246b4560e6e1878e6a33e5f1cdc53 100644 --- a/python/paddle/common_ops_import.py +++ b/python/paddle/common_ops_import.py @@ -36,6 +36,6 @@ from paddle.fluid.data_feeder import ( # noqa: F401 check_variable_and_dtype, convert_dtype, ) -from paddle.fluid.layers import fill_constant, utils, scale # noqa: F401 +from paddle.fluid.layers import fill_constant, utils # noqa: F401 from paddle.tensor.layer_function_generator import templatedoc # noqa: F401 import paddle.fluid as fluid # noqa: F401 diff --git a/python/paddle/fluid/dygraph/io.py b/python/paddle/fluid/dygraph/io.py index f84949aa5e014e3d57cbf8bed935396450b2b5f6..ba00deed977a97f39db8c8a6eecdd1903ce2d292 100644 --- a/python/paddle/fluid/dygraph/io.py +++ b/python/paddle/fluid/dygraph/io.py @@ -522,7 +522,7 @@ class _ProgramHolder: with framework.program_guard(program): for i, out in enumerate(self._output_descs): var = program.global_block().var(out.name()) - var = nn.scale( + var = paddle.scale( var, 1.0, name="translated_layer/scale_{}".format(i) ) scale_output_vars.append(var) diff --git a/python/paddle/fluid/layers/io.py b/python/paddle/fluid/layers/io.py index e92fea5afb1b06f718f153d7f2ded163616f5a9a..2259044e14e79e41edb08b79483d392836f3a835 100644 --- a/python/paddle/fluid/layers/io.py +++ b/python/paddle/fluid/layers/io.py @@ -189,6 +189,7 @@ class ListenAndServ: .. code-block:: python import paddle.fluid as fluid + import paddle with fluid.program_guard(main): serv = layers.ListenAndServ( "127.0.0.1:6170", ["X"], optimizer_mode=False) @@ -199,7 +200,7 @@ class ListenAndServ: name="X", append_batch_size=False) fluid.initializer.Constant(value=1.0)(x, main.global_block()) - layers.scale(x=x, scale=10.0, out=out_var) + paddle.scale(x=x, scale=10.0, out=out_var) exe = fluid.Executor(place) exe.run(main) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 18bbc6bc760d4829c0d4198c5d958d4ace993551..d412f344b096f76ac54a8d29c91cafb3644d3d35 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -113,7 +113,6 @@ __all__ = [ 'flatten', 'unique', 'unique_with_counts', - 'scale', 'elementwise_add', 'elementwise_div', 'elementwise_sub', @@ -7924,103 +7923,6 @@ def _elementwise_op(helper): return helper.append_activation(out) -def scale(x, scale=1.0, bias=0.0, bias_after_scale=True, act=None, name=None): - """ - - Putting scale and bias to the input Tensor as following: - - ``bias_after_scale`` is True: - - .. math:: - Out=scale*X+bias - - ``bias_after_scale`` is False: - - .. math:: - Out=scale*(X+bias) - - Args: - x(Tensor): Input N-D Tensor of scale operator. Data type can be float32, float64, int8, int16, int32, int64, uint8. - scale(float|Tensor): The scale factor of the input, it should be a float number or a Tensor with shape [1] and data type as float32. - bias(float): The bias to be put on the input. - bias_after_scale(bool): Apply bias addition after or before scaling. It is useful for numeric stability in some circumstances. - act(str, optional): Activation applied to the output such as tanh, softmax, sigmoid, relu. - name(str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name` - - Returns: - Tensor: Output tensor of scale operator, with shape and data type same as input. - - Examples: - - .. code-block:: python - - # scale as a float32 number - import paddle - - data = paddle.randn(shape=[2,3], dtype='float32') - res = paddle.scale(data, scale=2.0, bias=1.0) - - .. code-block:: python - - # scale with parameter scale as a Tensor - import paddle - - data = paddle.randn(shape=[2, 3], dtype='float32') - factor = paddle.to_tensor([2], dtype='float32') - res = paddle.scale(data, scale=factor, bias=1.0) - - """ - - if in_dygraph_mode(): - out = _C_ops.scale(x, scale, float(bias), bias_after_scale) - return dygraph_utils._append_activation_in_dygraph(out) - if _non_static_mode(): - _scale = scale.numpy().item(0) if isinstance(scale, Variable) else scale - out = _legacy_C_ops.scale( - x, - 'scale', - float(_scale), - 'bias', - float(bias), - 'bias_after_scale', - bias_after_scale, - ) - return dygraph_utils._append_activation_in_dygraph(out) - - check_variable_and_dtype( - x, - "x", - [ - 'float16', - 'uint16', - 'float32', - 'float64', - 'int8', - 'int16', - 'int32', - 'int64', - 'uint8', - ], - "scale", - ) - inputs = {'X': [x]} - attrs = { - 'bias': float(bias), - 'bias_after_scale': bias_after_scale, - } - if isinstance(scale, Variable): - inputs['ScaleTensor'] = [scale] - else: - attrs['scale'] = float(scale) - helper = LayerHelper('scale', **locals()) - out = helper.create_variable_for_type_inference(dtype=x.dtype) - - helper.append_op( - type='scale', inputs=inputs, outputs={'Out': out}, attrs=attrs - ) - return helper.append_activation(out) - - def elementwise_add(x, y, axis=-1, act=None, name=None): """ diff --git a/python/paddle/fluid/nets.py b/python/paddle/fluid/nets.py index c4bd6cf81f5f425711b01590a101b6354d40bf58..5cd8380eba58651c4f2a7e896a73f4f82f547ed1 100644 --- a/python/paddle/fluid/nets.py +++ b/python/paddle/fluid/nets.py @@ -620,7 +620,7 @@ def scaled_dot_product_attention( v = __split_heads(v, num_heads) key_dim_per_head = keys.shape[-1] // num_heads - scaled_q = layers.scale(x=q, scale=key_dim_per_head**-0.5) + scaled_q = paddle.scale(x=q, scale=key_dim_per_head**-0.5) product = layers.matmul(x=scaled_q, y=k, transpose_y=True) x = paddle.reshape(x=product, shape=[-1, product.shape[-1]]) diff --git a/python/paddle/fluid/tests/book/test_recommender_system.py b/python/paddle/fluid/tests/book/test_recommender_system.py index b947102d23a30902260c7c0ba205539290cb6c5a..c270c87b3c2acc44dce6d24b9722890d40ac6ee6 100644 --- a/python/paddle/fluid/tests/book/test_recommender_system.py +++ b/python/paddle/fluid/tests/book/test_recommender_system.py @@ -162,7 +162,7 @@ def model(): # need cos sim inference = layers.cos_sim(X=usr_combined_features, Y=mov_combined_features) - scale_infer = layers.scale(x=inference, scale=5.0) + scale_infer = paddle.scale(x=inference, scale=5.0) label = layers.data(name='score', shape=[1], dtype='float32') square_cost = layers.square_error_cost(input=scale_infer, label=label) diff --git a/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_transformer.py b/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_transformer.py index c052de953dec193a9f230290dcf23c7a451e2bd1..bcdd7329bb18e73d6c2d284a3b192a069caf353e 100644 --- a/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_transformer.py +++ b/python/paddle/fluid/tests/unittests/collective/fleet/parallel_dygraph_transformer.py @@ -537,7 +537,7 @@ class PrepareEncoderDecoderLayer(Layer): def forward(self, src_word, src_pos): src_word_emb = self._input_emb(src_word) - src_word_emb = fluid.layers.scale( + src_word_emb = paddle.scale( x=src_word_emb, scale=self._src_emb_dim**0.5 ) # # TODO change this to fit dynamic length input diff --git a/python/paddle/fluid/tests/unittests/dist_transformer.py b/python/paddle/fluid/tests/unittests/dist_transformer.py index 5a02ddf7005954a998dc5f553dfc782f1acf9150..4778a942dd5f79acc94169d1ef76b562ddbd0c91 100644 --- a/python/paddle/fluid/tests/unittests/dist_transformer.py +++ b/python/paddle/fluid/tests/unittests/dist_transformer.py @@ -1173,7 +1173,7 @@ def multi_head_attention( """ Scaled Dot-Product Attention """ - scaled_q = layers.scale(x=q, scale=d_model**-0.5) + scaled_q = paddle.scale(x=q, scale=d_model**-0.5) product = layers.matmul(x=scaled_q, y=k, transpose_y=True) if attn_bias: product += attn_bias @@ -1305,7 +1305,7 @@ def prepare_encoder( ), ) - src_word_emb = layers.scale(x=src_word_emb, scale=src_emb_dim**0.5) + src_word_emb = paddle.scale(x=src_word_emb, scale=src_emb_dim**0.5) src_pos_enc = layers.embedding( src_pos, size=[src_max_len, src_emb_dim], diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/bert_dygraph_model.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/bert_dygraph_model.py index 0bccfea79d1781791d0722dc6c3eeb6eb474102b..f35e7a973d3fa3aa48f93c7531cca331a4b7912c 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/bert_dygraph_model.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/bert_dygraph_model.py @@ -276,7 +276,7 @@ class BertModelLayer(Layer): self_attn_mask = fluid.layers.matmul( x=input_mask, y=input_mask, transpose_y=True ) - self_attn_mask = fluid.layers.scale( + self_attn_mask = paddle.scale( x=self_attn_mask, scale=10000.0, bias=-1.0, bias_after_scale=False ) n_head_self_attn_mask = paddle.stack( diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/transformer_dygraph_model.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/transformer_dygraph_model.py index dc2f00584cc039d6ac2aab5231d299e4c2c3c94f..9819b79ae6f768a90fd273e2e7a6a69179dfb93f 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/transformer_dygraph_model.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/transformer_dygraph_model.py @@ -342,7 +342,7 @@ class WrapEncoder(Layer): def forward(self, src_word, src_pos, src_slf_attn_bias): word_emb = self.word_embedder(src_word) - word_emb = layers.scale(x=word_emb, scale=self.emb_dim**0.5) + word_emb = paddle.scale(x=word_emb, scale=self.emb_dim**0.5) pos_enc = self.pos_encoder(src_pos) pos_enc.stop_gradient = True emb = word_emb + pos_enc @@ -546,7 +546,7 @@ class WrapDecoder(Layer): caches=None, ): word_emb = self.word_embedder(trg_word) - word_emb = layers.scale(x=word_emb, scale=self.emb_dim**0.5) + word_emb = paddle.scale(x=word_emb, scale=self.emb_dim**0.5) pos_enc = self.pos_encoder(trg_pos) pos_enc.stop_gradient = True emb = word_emb + pos_enc diff --git a/python/paddle/fluid/tests/unittests/ipu/test_scale_op_ipu.py b/python/paddle/fluid/tests/unittests/ipu/test_scale_op_ipu.py index 17d5b8207c1211a07fdc2b6b8d1afba8bb29d729..e95a86799e32a5b4abc7515fac6dc1eb60c18ae5 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_scale_op_ipu.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_scale_op_ipu.py @@ -55,7 +55,7 @@ class TestBase(IPUOpTest): x = paddle.static.data( name=self.feed_list[0], shape=self.feed_shape[0], dtype='float32' ) - out = paddle.fluid.layers.scale(x, **self.attrs) + out = paddle.scale(x, **self.attrs) self.fetch_list = [out.name] def run_model(self, exec_mode): @@ -126,7 +126,7 @@ class TestCase5(TestBase): y = paddle.static.data( name=self.feed_list[1], shape=self.feed_shape[1], dtype='float32' ) - out = paddle.fluid.layers.scale(x, scale=y, **self.attrs) + out = paddle.scale(x, scale=y, **self.attrs) self.fetch_list = [out.name] diff --git a/python/paddle/fluid/tests/unittests/ipu/test_varname_inplace_ipu.py b/python/paddle/fluid/tests/unittests/ipu/test_varname_inplace_ipu.py index bc5464941a574f061da4e03c199e2a3dfaeed059..61b38e80e7873ac9a7e675f303e9e714696ea619 100644 --- a/python/paddle/fluid/tests/unittests/ipu/test_varname_inplace_ipu.py +++ b/python/paddle/fluid/tests/unittests/ipu/test_varname_inplace_ipu.py @@ -62,9 +62,9 @@ class TestBase(IPUOpTest): add1 = paddle.fluid.layers.elementwise_add(x, x) reshape = paddle.reshape(add1, **self.attrs) add2 = paddle.fluid.layers.elementwise_add(reshape, reshape) - scale1 = paddle.fluid.layers.scale(add2) - scale2 = paddle.fluid.layers.scale(scale1, scale=1.3, bias=0.5) - scale3 = paddle.fluid.layers.scale(scale2, scale=2, bias=0.7) + scale1 = paddle.scale(add2) + scale2 = paddle.scale(scale1, scale=1.3, bias=0.5) + scale3 = paddle.scale(scale2, scale=2, bias=0.7) fetch_list = [scale3.name] diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_scale_op.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_scale_op.py index ffa83eb875595e408a0535156480793fc5ccb5b5..0ffabd017814131ecee30ad7b852a424bc9d24cd 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_scale_op.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_scale_op.py @@ -17,6 +17,7 @@ import unittest import numpy as np from inference_pass_test import InferencePassTest +import paddle import paddle.fluid as fluid import paddle.fluid.core as core from paddle.fluid.core import AnalysisConfig, PassVersionChecker @@ -39,7 +40,7 @@ class TRTScaleTest(InferencePassTest): self.fetch_list = [out] def append_scale(self, data): - return fluid.layers.scale( + return paddle.scale( x=data, scale=2.0, bias=-1.0, bias_after_scale=False ) @@ -71,7 +72,7 @@ class TRTScaleShape2Test(InferencePassTest): self.fetch_list = [out] def append_scale(self, data): - return fluid.layers.scale( + return paddle.scale( x=data, scale=2.0, bias=-1.0, bias_after_scale=False ) diff --git a/python/paddle/fluid/tests/unittests/ir/test_ir_fusion_group_pass.py b/python/paddle/fluid/tests/unittests/ir/test_ir_fusion_group_pass.py index 4d4fdc3e279af4d1b5fb1ed6a14b919d497900d6..19754fd6f2da0540f1f70fbb4cb240feb5e6cd8e 100644 --- a/python/paddle/fluid/tests/unittests/ir/test_ir_fusion_group_pass.py +++ b/python/paddle/fluid/tests/unittests/ir/test_ir_fusion_group_pass.py @@ -207,7 +207,7 @@ class FusionGroupPassFillConstantTest(FusionGroupPassTest): tmp_0 = layers.elementwise_add(self.feed_vars[0], self.feed_vars[1]) tmp_1 = layers.fill_constant(shape=[2, 2], dtype=dtype, value=2.0) - tmp_2 = layers.scale( + tmp_2 = paddle.scale( tmp_1, scale=3.0, bias=1.0, bias_after_scale=True ) tmp_3 = layers.elementwise_mul(tmp_2, tmp_0) diff --git a/python/paddle/fluid/tests/unittests/mlu/test_scale_op_mlu.py b/python/paddle/fluid/tests/unittests/mlu/test_scale_op_mlu.py index c7858a482295d534c1ed472007cd76ce2a951645..df164e26950619409a9fa93fa2fc4358064b52e2 100644 --- a/python/paddle/fluid/tests/unittests/mlu/test_scale_op_mlu.py +++ b/python/paddle/fluid/tests/unittests/mlu/test_scale_op_mlu.py @@ -131,7 +131,7 @@ class TestScaleOpSelectedRows(unittest.TestCase): class TestScaleRaiseError(unittest.TestCase): def test_errors(self): def test_type(): - fluid.layers.scale([10]) + paddle.scale([10]) self.assertRaises(TypeError, test_type) diff --git a/python/paddle/fluid/tests/unittests/test_array_read_write_op.py b/python/paddle/fluid/tests/unittests/test_array_read_write_op.py index f5f54017d9983a9c0d420bceaeed3a002e9e6cbf..e8d2579b3f2914506529199252eaf1ba0b5e32a4 100644 --- a/python/paddle/fluid/tests/unittests/test_array_read_write_op.py +++ b/python/paddle/fluid/tests/unittests/test_array_read_write_op.py @@ -80,7 +80,7 @@ class TestArrayReadWrite(unittest.TestCase): self.assertEqual(outs[0], outs[1]) total_sum = layers.sums(input=[a_sum, x_sum]) - total_sum_scaled = layers.scale(x=total_sum, scale=1 / 6.0) + total_sum_scaled = paddle.scale(x=total_sum, scale=1 / 6.0) append_backward(total_sum_scaled) @@ -117,7 +117,7 @@ class TestArrayReadWrite(unittest.TestCase): total_sum_dygraph = layers.sums( input=[a_sum_dygraph, x_sum_dygraph] ) - total_sum_scaled_dygraph = layers.scale( + total_sum_scaled_dygraph = paddle.scale( x=total_sum_dygraph, scale=1 / 6.0 ) total_sum_scaled_dygraph.backward() diff --git a/python/paddle/fluid/tests/unittests/test_dist_train.py b/python/paddle/fluid/tests/unittests/test_dist_train.py index 65753803282fa977bbc410629070ef55d29d7026..3067321289b9cf1eae8d8972745a951a989a322c 100644 --- a/python/paddle/fluid/tests/unittests/test_dist_train.py +++ b/python/paddle/fluid/tests/unittests/test_dist_train.py @@ -29,6 +29,7 @@ import paddle.fluid.layers.ops as ops from dist_test_utils import remove_ps_flag from paddle.fluid import core +import paddle RPC_OP_ROLE_ATTR_NAME = ( op_role_attr_name @@ -150,7 +151,7 @@ class TestSendOp(unittest.TestCase): append_batch_size=False, ) fluid.initializer.Constant(value=2.3)(x, main.global_block()) - o = layers.scale(x=x, scale=10.0) + o = paddle.scale(x=x, scale=10.0) exe = fluid.Executor(place) self.local_out = exe.run(main, fetch_list=[o]) diff --git a/python/paddle/fluid/tests/unittests/test_eager_deletion_recurrent_op.py b/python/paddle/fluid/tests/unittests/test_eager_deletion_recurrent_op.py index 21ebf05038e8ce44ca713add39bca8738e311c55..7d53e2aac86233a3847c731834a399fb63b0a961 100644 --- a/python/paddle/fluid/tests/unittests/test_eager_deletion_recurrent_op.py +++ b/python/paddle/fluid/tests/unittests/test_eager_deletion_recurrent_op.py @@ -155,7 +155,7 @@ class EagerDeletionRecurrentOpTest1(unittest.TestCase): h_pre = rnn.memory(init=h_boot) x_t = rnn.step_input(x) - h = layers.scale( + h = paddle.scale( x=layers.elementwise_add(x=h_pre, y=x_t), scale=self.py_rnn.scale, ) @@ -431,8 +431,8 @@ class EagerDeletionRecurrentOpMultipleMemoryTest(EagerDeletionRecurrentOpTest1): h_pre2 = rnn.memory(init=h_boot2) x_t = rnn.step_input(x) - mem1 = layers.scale(x=h_pre1, scale=1.0) - mem2 = layers.scale(x=h_pre2, scale=1.0) + mem1 = paddle.scale(x=h_pre1, scale=1.0) + mem2 = paddle.scale(x=h_pre2, scale=1.0) out = layers.sums(input=[mem1, x_t, mem2]) rnn.update_memory(h_pre1, mem1) @@ -691,7 +691,7 @@ class EagerDeletionFarwardOnlyRnnAndBackwardRnnTest( h_pre = forward_only_rnn.memory(init=h_boot) x_t = forward_only_rnn.step_input(x) - h = layers.scale( + h = paddle.scale( x=layers.elementwise_add(x=h_pre, y=x_t), scale=self.py_rnn.scale, ) @@ -707,7 +707,7 @@ class EagerDeletionFarwardOnlyRnnAndBackwardRnnTest( h_pre = rnn.memory(init=h_boot) x_t = rnn.step_input(x) - h = layers.scale( + h = paddle.scale( x=layers.elementwise_add(x=h_pre, y=x_t), scale=self.py_rnn.scale, ) diff --git a/python/paddle/fluid/tests/unittests/test_imperative_transformer_sorted_gradient.py b/python/paddle/fluid/tests/unittests/test_imperative_transformer_sorted_gradient.py index f8671a76e2cd64e09486efb3e102703325f57336..b5c398b36c26a626afb38bbb29044e833c774851 100644 --- a/python/paddle/fluid/tests/unittests/test_imperative_transformer_sorted_gradient.py +++ b/python/paddle/fluid/tests/unittests/test_imperative_transformer_sorted_gradient.py @@ -692,7 +692,7 @@ class PrepareEncoderDecoderLayer(Layer): def forward(self, src_word, src_pos): src_word_emb = self._input_emb(src_word) - src_word_emb = fluid.layers.scale( + src_word_emb = paddle.scale( x=src_word_emb, scale=self._src_emb_dim**0.5 ) # # TODO change this to fit dynamic length input diff --git a/python/paddle/fluid/tests/unittests/test_layers.py b/python/paddle/fluid/tests/unittests/test_layers.py index f62adf08ecf952dc32dd5971720299ac705f4dbd..752a089dadf834f9cfdc15202401ecabe8a9dbb1 100644 --- a/python/paddle/fluid/tests/unittests/test_layers.py +++ b/python/paddle/fluid/tests/unittests/test_layers.py @@ -3632,7 +3632,7 @@ class TestBook(LayerTest): dtype='float32', append_batch_size=False, ) - out = layers.scale(input, scale=scale_var) + out = paddle.scale(input, scale=scale_var) return out def make_iou_similarity(self): diff --git a/python/paddle/fluid/tests/unittests/test_recurrent_op.py b/python/paddle/fluid/tests/unittests/test_recurrent_op.py index e8069c5f06363dfb25b428015caa841ff50f36b0..e0abda02b37f3ba4ef9e8fdbb7e165b3cce95ab1 100644 --- a/python/paddle/fluid/tests/unittests/test_recurrent_op.py +++ b/python/paddle/fluid/tests/unittests/test_recurrent_op.py @@ -151,7 +151,7 @@ class RecurrentOpTest1(unittest.TestCase): h_pre = rnn.memory(init=h_boot) x_t = rnn.step_input(x) - h = layers.scale( + h = paddle.scale( x=layers.elementwise_add(x=h_pre, y=x_t), scale=self.py_rnn.scale, ) @@ -419,8 +419,8 @@ class RecurrentOpMultipleMemoryTest(RecurrentOpTest1): h_pre2 = rnn.memory(init=h_boot2) x_t = rnn.step_input(x) - mem1 = layers.scale(x=h_pre1, scale=1.0) - mem2 = layers.scale(x=h_pre2, scale=1.0) + mem1 = paddle.scale(x=h_pre1, scale=1.0) + mem2 = paddle.scale(x=h_pre2, scale=1.0) out = layers.sums(input=[mem1, x_t, mem2]) rnn.update_memory(h_pre1, mem1) diff --git a/python/paddle/fluid/tests/unittests/test_scale_op.py b/python/paddle/fluid/tests/unittests/test_scale_op.py index 07be7620a93a1174dc8cd8a63dd6708bcc730341..8082128a02fce46156869a44075a0fa6a293d4f7 100644 --- a/python/paddle/fluid/tests/unittests/test_scale_op.py +++ b/python/paddle/fluid/tests/unittests/test_scale_op.py @@ -133,7 +133,7 @@ class TestScaleOpSelectedRows(unittest.TestCase): class TestScaleRaiseError(unittest.TestCase): def test_errors(self): def test_type(): - fluid.layers.scale([10]) + paddle.scale([10]) self.assertRaises(TypeError, test_type) diff --git a/python/paddle/fluid/tests/unittests/transformer_model.py b/python/paddle/fluid/tests/unittests/transformer_model.py index cf564e771e26f0e34633c9758c8d6700a8572986..dfb29fdeb40358cb8243f6894f436e41488ede37 100644 --- a/python/paddle/fluid/tests/unittests/transformer_model.py +++ b/python/paddle/fluid/tests/unittests/transformer_model.py @@ -161,7 +161,7 @@ def multi_head_attention( sum_out = layers.reduce_sum(exp_out, dim=-1, keep_dim=False) return layers.elementwise_div(x=exp_out, y=sum_out, axis=0) - scaled_q = layers.scale(x=q, scale=d_model**-0.5) + scaled_q = paddle.scale(x=q, scale=d_model**-0.5) product = layers.matmul(x=scaled_q, y=k, transpose_y=True) weights = __softmax(layers.elementwise_add(x=product, y=attn_bias)) if dropout_rate: diff --git a/python/paddle/static/io.py b/python/paddle/static/io.py index 47e3dddbbd893970418f11a164483f5052b038ad..fdcfc1a657069d9fa77c4826cfaeb214c06ccdb5 100644 --- a/python/paddle/static/io.py +++ b/python/paddle/static/io.py @@ -26,7 +26,6 @@ from paddle.fluid import ( CompiledProgram, default_main_program, Program, - layers, unique_name, program_guard, ) @@ -201,7 +200,7 @@ def normalize_program(program, feed_vars, fetch_vars): uniq_fetch_vars = [] for i, var in enumerate(fetch_vars): if var.dtype != paddle.bool: - var = layers.scale( + var = paddle.scale( var, 1.0, name="save_infer_model/scale_{}".format(i) ) uniq_fetch_vars.append(var) diff --git a/python/paddle/tensor/ops.py b/python/paddle/tensor/ops.py index c4d8b01762a2af9e854874945b330ee0519f91e4..2897f4fd85a1b21075b6ce682f0c0becf62d2692 100644 --- a/python/paddle/tensor/ops.py +++ b/python/paddle/tensor/ops.py @@ -52,7 +52,7 @@ __inplace_unary_func__ = [ __all__ = [] # It is a hot fix in some unittest using: -# fluid.layers.scale(x=x, scale=10.0, out=out_var) +# paddle.scale(x=x, scale=10.0, out=out_var) # e.g.: test_program_code.py, test_dist_train.py globals()['_scale'] = generate_layer_fn('scale')