Skip to content

Commit d6194fc

Browse files
committed
Add check for inverse.
1 parent 8967a66 commit d6194fc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

paddle/fluid/operators/inverse_op.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ class InverseOp : public framework::OperatorWithKernel {
3535
"The dimension of Input(Input) is expected to be no less than 2. "
3636
"But recieved: Input(Input)'s dimension = %d, shape = [%s].",
3737
input_rank, input_dims));
38+
for (int64_t i = 0; i < input_rank; ++i) {
39+
PADDLE_ENFORCE_EQ(
40+
(input_dims[i] == -1) || (input_dims[i] > 0), true,
41+
platform::errors::InvalidArgument(
42+
"Each dimension of input tensor is expected to be -1 or a "
43+
"positive number, but recieved %d. Input's shape is [%s].",
44+
input_dims[i], input_dims));
45+
}
3846
if (input_dims[input_rank - 2] > 0 && input_dims[input_rank - 1] > 0) {
3947
PADDLE_ENFORCE_EQ(input_dims[input_rank - 2], input_dims[input_rank - 1],
4048
platform::errors::InvalidArgument(

0 commit comments

Comments
 (0)