Skip to content

Commit 5b8bb34

Browse files
committed
Refine reshape_op by following comments.
1 parent 09743b6 commit 5b8bb34

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

paddle/fluid/operators/reshape_op.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ data in Input(X) are unchanged.
4949
specified by Attr(shape) is [6, 8], the reshape operator will transform Input(X)
5050
into a 2-D tensor with shape [6, 8] and leaving Input(X)'s data unchanged.
5151
52-
1. Given a 3-D tensor Input(X) with a shape [2, 4, 6], and the target shape
52+
2. Given a 3-D tensor Input(X) with a shape [2, 4, 6], and the target shape
5353
specified by Attr(shape) is [2, 3, -1, 2], the reshape operator will transform
5454
Input(X) into a 4-D tensor with shape [2, 3, 4, 2] and leaving Input(X)'s data
5555
unchanged. In this case, one and only dimension of Attr(shape) can be set to -1,
5656
the value of this dimension is inferred from the total element number of
5757
Input(X) and remaining dimensions.
5858
59-
1. Given a 3-D tensor Input(X) with a shape [2, 4, 6], and the target shape
59+
3. Given a 3-D tensor Input(X) with a shape [2, 4, 6], and the target shape
6060
specified by Attr(shape) is [-1, 0, 3, 2], the reshape operator will transform
6161
Input(X) into a 4-D tensor with shape [2, 4, 3, 2] and leaving Input(X)'s data
6262
unchanged. In this case, besides -1, 0 means the actual dimension value is going
@@ -67,11 +67,13 @@ to be copied from the corresponding dimension of Input(X).
6767
1. One and only one dimension in Attr(shape) can be set -1. In this case,
6868
the actual dimension value will be infered from the total element number of
6969
Input(X) and remaining dimensions.
70-
1. More than one dimensions in Attr(shape) can be set to 0, which means the real
70+
71+
2. More than one dimensions in Attr(shape) can be set to 0, which means the real
7172
dimension value will be copied from Input(X) at runtime. Note that the index of
7273
0 can not exceed Rank(X). For example, Input(X) is a 3-D tensor with shape
7374
[2, 3, 4], Attr(shape) = [2, 3, 2, 0] is an invalid input.
74-
1. Input(Shape) has a higher priority than Attr(shape) if it is provided, while
75+
76+
3. Input(Shape) has a higher priority than Attr(shape) if it is provided, while
7577
Attr(shape) still should be set correctly to gurantee shape inference in
7678
compile-time.
7779

paddle/fluid/operators/reshape_op.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ class ReshapeOp : public framework::OperatorWithKernel {
6666
int64_t capacity = 1;
6767
int unk_dim_idx = -1;
6868
for (size_t i = 0; i < shape.size(); ++i) {
69-
// std::cout<< shape[i] << "haha";
7069
if (shape[i] == unk_dim_val) {
7170
PADDLE_ENFORCE(
7271
unk_dim_idx == -1,

python/paddle/fluid/layers/nn.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3337,7 +3337,7 @@ def reshape(x, shape, actual_shape=None, act=None, inplace=True, name=None):
33373337
number of x and remaining dimensions. Thus one and only one dimension can
33383338
be set -1.
33393339
3340-
1. 0 means the actual dimension value is going to be copied from the
3340+
2. 0 means the actual dimension value is going to be copied from the
33413341
corresponding dimension of x. The indice of 0s in shape can not exceed
33423342
Rank(X).
33433343
@@ -3347,14 +3347,14 @@ def reshape(x, shape, actual_shape=None, act=None, inplace=True, name=None):
33473347
is [6, 8], the reshape operator will transform x into a 2-D tensor with
33483348
shape [6, 8] and leaving x's data unchanged.
33493349
3350-
1. Given a 3-D tensor x with a shape [2, 4, 6], and the target shape
3350+
2. Given a 3-D tensor x with a shape [2, 4, 6], and the target shape
33513351
specified is [2, 3, -1, 2], the reshape operator will transform x into a
33523352
4-D tensor with shape [2, 3, 4, 2] and leaving x's data unchanged. In this
33533353
case, one dimension of the target shape is set to -1, the value of this
33543354
dimension is inferred from the total element number of x and remaining
33553355
dimensions.
33563356
3357-
1. Given a 3-D tensor x with a shape [2, 4, 6], and the target shape
3357+
3. Given a 3-D tensor x with a shape [2, 4, 6], and the target shape
33583358
is [-1, 0, 3, 2], the reshape operator will transform x into a 4-D tensor
33593359
with shape [2, 4, 3, 2] and leaving x's data unchanged. In this case,
33603360
besides -1, 0 means the actual dimension value is going to be copied from

0 commit comments

Comments
 (0)