Skip to content

Commit cbec20e

Browse files
authored
Cherry-pick the correct of the doc in Python API (#15725) (#15785)
test=release/1.3
1 parent fbf0a35 commit cbec20e

File tree

6 files changed

+24
-23
lines changed

6 files changed

+24
-23
lines changed

paddle/fluid/API.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ paddle.fluid.layers.increment ArgSpec(args=['x', 'value', 'in_place'], varargs=N
261261
paddle.fluid.layers.array_write ArgSpec(args=['x', 'i', 'array'], varargs=None, keywords=None, defaults=(None,))
262262
paddle.fluid.layers.create_array ArgSpec(args=['dtype'], varargs=None, keywords=None, defaults=None)
263263
paddle.fluid.layers.less_than ArgSpec(args=['x', 'y', 'force_cpu', 'cond'], varargs=None, keywords='ignored', defaults=(None, None))
264-
paddle.fluid.layers.equal ArgSpec(args=['x', 'y', 'cond'], varargs=None, keywords='ignored', defaults=(None,))
264+
paddle.fluid.layers.equal ArgSpec(args=['x', 'y', 'cond'], varargs=None, keywords=None, defaults=(None,))
265265
paddle.fluid.layers.array_read ArgSpec(args=['array', 'i'], varargs=None, keywords=None, defaults=None)
266266
paddle.fluid.layers.array_length ArgSpec(args=['array'], varargs=None, keywords=None, defaults=None)
267267
paddle.fluid.layers.IfElse.__init__ ArgSpec(args=['self', 'cond', 'name'], varargs=None, keywords=None, defaults=(None,))

paddle/fluid/operators/controlflow/compare_op.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ class CompareOpProtoMaker : public framework::OpProtoAndCheckerMaker {
5151
comment.type));
5252
AddInput("Y", string::Sprintf("the right hand operand of %s operator",
5353
comment.type));
54+
AddAttr<int>(
55+
"axis",
56+
"The start dimension index for broadcasting Y onto X. [default -1]")
57+
.SetDefault(-1)
58+
.EqualGreaterThan(-1);
5459
AddAttr<bool>("force_cpu",
5560
"Force fill output variable to cpu "
5661
"memory. Otherwise, fill output variable to the running "
@@ -64,11 +69,6 @@ N-dim tensor. X and Y could be any type. The each element of the Out tensor is
6469
calculated by $%s$
6570
)DOC",
6671
comment.equation));
67-
AddAttr<int>(
68-
"axis",
69-
"The start dimension index for broadcasting Y onto X. [default -1]")
70-
.SetDefault(-1)
71-
.EqualGreaterThan(-1);
7272
}
7373
};
7474

python/paddle/fluid/framework.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,8 @@ def generated_op_attr_names():
555555
return {
556556
core.op_proto_and_checker_maker.kOpRoleAttrName(),
557557
core.op_proto_and_checker_maker.kOpRoleVarAttrName(),
558-
core.op_proto_and_checker_maker.kOpNameScopeAttrName()
558+
core.op_proto_and_checker_maker.kOpNameScopeAttrName(),
559+
core.op_proto_and_checker_maker.kOpCreationCallstackAttrName()
559560
}
560561

561562

python/paddle/fluid/layers/control_flow.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,9 @@ class While(object):
506506
while loop control flow.
507507
508508
Args:
509-
cond (Variable): condition used to compare.
509+
cond(Variable): condition used to compare.
510510
is_test(bool): A flag indicating whether execution is in test phase.
511-
name (str): The name of this layer.
511+
name(str): The name of this layer.
512512
513513
Examples:
514514
.. code-block:: python
@@ -589,7 +589,8 @@ def _complete(self):
589589

590590

591591
def lod_rank_table(x, level=0):
592-
"""LoD Rank Table Operator. Given an input variable **x** and a level number
592+
"""
593+
LoD Rank Table Operator. Given an input variable **x** and a level number
593594
of LoD, this layer creates a LodRankTable object. A LoDRankTable object
594595
contains a list of bi-element tuples. Each tuple consists of an index and
595596
a length, both of which are int type. Refering to specified level of LoD,
@@ -883,10 +884,8 @@ def less_than(x, y, force_cpu=None, cond=None, **ignored):
883884
return cond
884885

885886

886-
def equal(x, y, cond=None, **ignored):
887+
def equal(x, y, cond=None):
887888
"""
888-
**equal**
889-
890889
This layer returns the truth value of :math:`x == y` elementwise.
891890
892891
Args:
@@ -1458,7 +1457,6 @@ def step_input(self, x):
14581457
14591458
Returns:
14601459
The current timestep in the input sequence.
1461-
14621460
"""
14631461
self._assert_in_rnn_block_("step_input")
14641462
if not isinstance(x, Variable):
@@ -1535,8 +1533,7 @@ def static_input(self, x):
15351533
@signature_safe_contextmanager
15361534
def block(self):
15371535
"""
1538-
The block for user to define operators in RNN. See the class docstring
1539-
for more details.
1536+
The block for user to define operators in RNN.
15401537
"""
15411538
if self.status != DynamicRNN.BEFORE_RNN:
15421539
raise ValueError("rnn.block() can only be invoke once")
@@ -1640,8 +1637,7 @@ def memory(self,
16401637
dtype(str|numpy.dtype): The data type of the initialized memory.
16411638
16421639
Returns:
1643-
the memory variable.
1644-
1640+
The memory variable.
16451641
"""
16461642
self._assert_in_rnn_block_('memory')
16471643
self._init_zero_idx_()
@@ -1740,7 +1736,7 @@ def update_memory(self, ex_mem, new_mem):
17401736

17411737
def output(self, *outputs):
17421738
"""
1743-
mark the RNN output variables.
1739+
Mark the RNN output variables.
17441740
17451741
Args:
17461742
outputs: The output variables.

python/paddle/fluid/layers/layer_function_generator.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from ..layer_helper import LayerHelper
2525

2626
__all__ = [
27-
'deprecated', 'generate_layer_fn', 'generate_layer_fn_noattr', 'autodoc',
27+
'deprecated', 'generate_layer_fn', 'generate_activation_fn', 'autodoc',
2828
'templatedoc'
2929
]
3030

@@ -89,6 +89,9 @@ def _generate_doc_string_(op_proto, additional_args_lines=None):
8989
buf.write('\n')
9090

9191
skip_attrs = OpProtoHolder.generated_op_attr_names()
92+
# attr use_mkldnn and is_test also should not be visible to users.
93+
skip_attrs.add("use_mkldnn")
94+
skip_attrs.add("is_test")
9295

9396
for each_attr in op_proto.attrs:
9497
if each_attr.name in skip_attrs:
@@ -226,7 +229,7 @@ def func(*args, **kwargs):
226229
return func
227230

228231

229-
def generate_layer_fn_noattr(op_type):
232+
def generate_activation_fn(op_type):
230233
"""Register the Python layer for an Operator without Attribute.
231234
232235
Args:
@@ -246,6 +249,7 @@ def func(x, name=None):
246249

247250
func.__name__ = op_type
248251
func.__doc__ = _generate_doc_string_(op_proto)
252+
249253
return func
250254

251255

python/paddle/fluid/layers/ops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from __future__ import print_function
1616
import os
17-
from .layer_function_generator import generate_layer_fn, generate_layer_fn_noattr
17+
from .layer_function_generator import generate_layer_fn, generate_activation_fn
1818
from .. import core
1919
from ..framework import convert_np_dtype_to_dtype_
2020

@@ -53,7 +53,7 @@
5353
__all__ += __activations_noattr__
5454

5555
for _OP in set(__activations_noattr__):
56-
globals()[_OP] = generate_layer_fn_noattr(_OP)
56+
globals()[_OP] = generate_activation_fn(_OP)
5757

5858
__all__ += ["uniform_random"]
5959

0 commit comments

Comments
 (0)