Skip to content

Commit 7c00e16

Browse files
committed
Add More comments
1 parent f9d93bf commit 7c00e16

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

python/paddle/fluid/layers/layer_function_generator.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,22 @@ def templatedoc():
230230
and AddInput. The ${name} is Python snake style. i.e., xxx_xxx.
231231
* ${{name}_type}: The type of ${name}.
232232
233-
234233
Returns:
235-
Decorated funciton.
234+
Decorated function.
236235
"""
237236

238237
def __impl__(func):
239238
op_proto = OpProtoHolder.instance().get_op_proto(func.__name__)
240239
tmpl = string.Template(func.__doc__)
241-
args = {"comment": " ".join(op_proto.comment.split())}
240+
241+
comment_lines = op_proto.comment.split("\n")
242+
comment = ""
243+
for line in comment_lines:
244+
line = line.lstrip()
245+
comment += line
246+
comment += "\n"
247+
248+
args = {"comment": comment}
242249
for each_input in op_proto.inputs:
243250
input_name = _convert_(each_input.name)
244251
args["{0}_comment".format(input_name)] = each_input.comment

python/paddle/fluid/layers/nn.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,22 @@ def gru_unit(input,
799799
return updated_hidden, reset_hidden_pre, gate
800800

801801

802+
@templatedoc()
802803
def linear_chain_crf(input, label, param_attr=None):
804+
"""
805+
Linear Chain CRF.
806+
807+
${comment}
808+
809+
Args:
810+
input(${emission_type}): ${emission_comment}
811+
label(${label_type}): ${label_comment}
812+
param_attr(ParamAttr): The attribute of the learnable parameter.
813+
814+
Returns:
815+
${log_likelihood_comment}
816+
817+
"""
803818
helper = LayerHelper('linear_chain_crf', **locals())
804819
size = input.shape[1]
805820
transition = helper.create_parameter(
@@ -825,7 +840,19 @@ def linear_chain_crf(input, label, param_attr=None):
825840
return log_likelihood
826841

827842

843+
@templatedoc()
828844
def crf_decoding(input, param_attr, label=None):
845+
"""
846+
${comment}
847+
848+
Args:
849+
input(${emission_type}): ${emission_comment}
850+
param_attr(ParamAttr): The parameter attribute for training.
851+
label(${label_type}): ${label_comment}
852+
853+
Returns:
854+
${viterbi_path_comment}
855+
"""
829856
helper = LayerHelper('crf_decoding', **locals())
830857
transition = helper.get_parameter(param_attr.name)
831858
viterbi_path = helper.create_tmp_variable(dtype=helper.input_dtype())

0 commit comments

Comments
 (0)