-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Update comments for two operators. #7457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
67d508d
2aca8c7
7829031
5b912e2
e3e9a40
49c20a0
473fd63
40ed8a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,24 +31,40 @@ class ReorderLoDTensorByRankTableOpProtoMaker | |
| "Input(RankTable)."); | ||
| AddInput("RankTable", | ||
| "(LoDRankTable), the rank table according to which Input(X) is " | ||
| "ordered."); | ||
| "reordered."); | ||
| AddOutput("Out", "(LoDTensor), the reordered lod tensor."); | ||
| AddComment(R"DOC(ReorderLoDTensorByRankTable | ||
| AddComment(R"DOC(ReorderLoDTensorByRankTable operator. | ||
|
|
||
| Reorder the Input(X) according to the information provided by Input(RankTable). | ||
| For example, If the indices stored in the Input(RankTable) is [3, 0, 2, 1], the | ||
| Input(X) is a batch of sequences. Input(RankTable) stores new orders of the | ||
| input sequence batch. The reorder_lod_tensor_by_rank operator reorders the | ||
| Input(X) according to the information provided by Input(RankTable). | ||
|
|
||
| For example: | ||
|
|
||
| If the indices stored in the Input(RankTable) is [3, 0, 2, 1], the | ||
| Input(X) will be reordered that the forth sequence in Input(X) will become the | ||
|
||
| first one, and then followed by the originally first, third, and the second one. | ||
|
||
|
|
||
| NOTE: This operator sort Input(X) according to a given LoDRankTable which dose | ||
| This is: | ||
| X = [Seq0, Seq1, Seq2, Seq3]. The indices in RankTable are [3, 0, 2, 1]. | ||
| Out = [Seq3, Seq0, Seq2, Seq1] with a new LoD information. | ||
|
|
||
| If the LoD information of Input(X) is empty, this means Input(X) is not a | ||
|
||
| sequcence. This is also identical to a batch of sequences, each sequence in | ||
| which has a fixed length 1. In this case, the reorder_lod_tensor_by_rank operator | ||
| reorders each slice of Input(X) along the first axis according to | ||
| Input(RankTable). | ||
|
|
||
| This is: | ||
| X = [Slice0, Slice1, Slice2, Slice3] and its LoD information is empty. The | ||
| indices in RankTable are [3, 0, 2, 1]. | ||
| Out = [Slice3, Slice0, Slice2, Slice1] with no LoD information is appended. | ||
|
|
||
| NOTE: This operator sorts Input(X) according to a given LoDRankTable which dose | ||
|
||
| not need to be calculated according to Input(X). It can be calculated according | ||
| to any other different sequence, and then this operator sort Input(X) according | ||
| to other different sequence, and then this operator sorts Input(X) according | ||
| to the given LoDRankTable. | ||
|
|
||
| For example: | ||
| The X = [Seq0, Seq1, Seq2, Seq3]. The indices of RankTable are [3, 0, 2, 1]. | ||
|
|
||
| The Out = [Seq3, Seq0, Seq2, Seq1] with new LoD information. | ||
| )DOC"); | ||
| } | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -687,11 +687,10 @@ def topk(input, k): | |
|
|
||
|
|
||
| def lod_tensor_to_array(x, table): | ||
| """This function performs the operation that converts an LOD_Tensor to | ||
| an array. | ||
| """ Convert a LOD_TENSOR_ARRAY to an TensorArray. | ||
|
||
|
|
||
| Args: | ||
| x (Variable|list): The tensor that needs to be converted to an array. | ||
| x (Variable|list): The LoD tensor to be converted to a LoD tensor array. | ||
| table (ParamAttr|list): The variable that stores the level of lod | ||
| which is ordered by sequence length in | ||
| descending order. | ||
|
|
@@ -721,10 +720,10 @@ def lod_tensor_to_array(x, table): | |
|
|
||
|
|
||
| def array_to_lod_tensor(x, table): | ||
| """This function converts an LOD_TENSOR_ARRAY to an LODTensor. | ||
| """Convert a LoD_Tensor_Aarry to an LoDTensor. | ||
|
|
||
| Args: | ||
| x (Variable|list): The array that needs to be converted to a tensor. | ||
| x (Variable|list): The LoD Tensor Array to be converted to a tensor. | ||
|
||
| table (ParamAttr|list): The variable that stores the level of lod | ||
| which is ordered by sequence length in | ||
| descending order. | ||
|
|
@@ -752,7 +751,8 @@ def array_to_lod_tensor(x, table): | |
|
|
||
|
|
||
| def increment(x, value=1.0, in_place=True): | ||
| """This function performs an operation that increments each value in the | ||
| """ | ||
| This function performs an operation that increments each value in the | ||
| input :math:`x` by an amount: :math:`value` as mentioned in the input | ||
| parameter. This operation is performed in-place by default. | ||
|
|
||
|
|
@@ -785,8 +785,9 @@ def increment(x, value=1.0, in_place=True): | |
|
|
||
|
|
||
| def array_write(x, i, array=None): | ||
| """This function writes the given input variable to the specifict position | ||
| which is indicated by the arrary index to an output LOD_TENSOR_ARRAY. If the | ||
| """ | ||
| This function writes the given input variable to the specified position | ||
| indicating by the arrary index to an output LOD_TENSOR_ARRAY. If the | ||
| output LOD_TENSOR_ARRAY is not given(None), a new one will be created and | ||
| returned. | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,10 +146,10 @@ def fill_constant(shape, dtype, value, out=None): | |
| """ | ||
| **fill_constant** | ||
|
|
||
| This function creates a tensor with the specified *shape* and | ||
| *dtype*, and initializes it with the constant given by *value*. | ||
| This function creates a tensor with the specified `shape` and | ||
|
||
| `dtype`, and initializes it with the constant specifed by `value`. | ||
|
||
|
|
||
| The attribute *stop_gradient* of the created tensor is set to True. | ||
| The attribute `stop_gradient` of the created tensor is set to True. | ||
|
|
||
| Args: | ||
| shape(tuple|list|None): Shape of the output tensor. | ||
|
|
@@ -166,6 +166,7 @@ def fill_constant(shape, dtype, value, out=None): | |
|
|
||
| data = fluid.layers.fill_constant(shape=[1], value=0, dtype='int64') | ||
| """ | ||
|
|
||
| helper = LayerHelper("fill_constant", **locals()) | ||
| if out is None: | ||
| out = helper.create_tmp_variable(dtype=dtype) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is -> are
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.