fix bug in reshape: (#20781)

consider the situation that shape of input can contain more than one -1.
test=develop
yaoxuefeng
Yamei-Lee 6 years ago committed by hong
parent 1d1552d106
commit cf717fd6dd

@ -186,13 +186,16 @@ class ReshapeOp : public framework::OperatorWithKernel {
output_shape[unk_dim_idx] = -1;
}
} else {
PADDLE_ENFORCE_EQ(
capacity, in_size,
"ShapeError: The 'shape' in ReshapeOp is invalid. "
"The input tensor X'size must be equal to the capacity of 'shape'. "
"But received X's shape = [%s], X's size = %d, 'shape' is [%s], the "
"capacity of 'shape' is %d.",
in_dims, in_size, framework::make_ddim(shape), capacity);
if (all_positive) {
PADDLE_ENFORCE_EQ(
capacity, in_size,
"ShapeError: The 'shape' in ReshapeOp is invalid. "
"The input tensor X'size must be equal to the capacity of 'shape'. "
"But received X's shape = [%s], X's size = %d, 'shape' is [%s], "
"the "
"capacity of 'shape' is %d.",
in_dims, in_size, framework::make_ddim(shape), capacity);
}
}
return framework::make_ddim(output_shape);
}

Loading…
Cancel
Save