fix if else error info (#19974)

test=develop
test=document_fix
fix-python-transpose
Zhaolong Xing 5 years ago committed by GitHub
parent a7512db2bc
commit f04f2b232a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -190,9 +190,23 @@ class MergeLoDTensorInferShape : public framework::InferShapeBase {
"MergeLoDTensorOp must has output Out");
auto mask_dim = context->GetInputDim("Mask");
PADDLE_ENFORCE_EQ(mask_dim.size(), 2);
PADDLE_ENFORCE_EQ(mask_dim.size(), 2,
"If you are using IfElse OP:"
"\n\nie = fluid.layers.IfElse(cond=cond)\nwith "
"ie.true_block():\n out_1 = ie.input(x)\n\n"
"Please ensure that the cond should be a 2-D tensor and "
"the second dim size of cond should be 1. "
"But now the cond's shape is [",
*mask_dim.Get(), "].\n");
if (context->IsRuntime() || mask_dim[1] > 0) {
PADDLE_ENFORCE_EQ(mask_dim[1], 1);
PADDLE_ENFORCE_EQ(mask_dim[1], 1,
"If you are using IfElse OP:"
"\n\nie = fluid.layers.IfElse(cond=cond)\nwith "
"ie.true_block():\n out_1 = ie.input(x)\n\n"
"Please ensure that the cond should be a 2-D tensor "
"and the second dim size of cond should be 1. "
"But now the cond's shape is [",
*mask_dim.Get(), "].\n");
}
context->SetOutputDim("Out", context->GetInputDim("InTrue"));

@ -156,9 +156,23 @@ class SplitLoDTensorInferShape : public framework::InferShapeBase {
"SplitLoDTensorOp must has output OutFalse.");
auto mask_dim = context->GetInputDim("Mask");
PADDLE_ENFORCE_EQ(mask_dim.size(), 2);
PADDLE_ENFORCE_EQ(mask_dim.size(), 2,
"If you are using IfElse OP:"
"\n\nie = fluid.layers.IfElse(cond=cond)\nwith "
"ie.true_block():\n out_1 = ie.input(x)\n\n"
"Please ensure that the cond should be a 2-D tensor and "
"the second dim size of cond should be 1. "
"But now the cond's shape is [",
*mask_dim.Get(), "].\n");
if (context->IsRuntime()) {
PADDLE_ENFORCE_EQ(mask_dim[1], 1);
PADDLE_ENFORCE_EQ(mask_dim[1], 1,
"If you are using IfElse OP:"
"\n\nie = fluid.layers.IfElse(cond=cond)\nwith "
"ie.true_block():\n out_1 = ie.input(x)\n\n"
"Please ensure that the cond should be a 2-D tensor "
"and the second dim size of cond should be 1. "
"But now the cond's shape is [",
*mask_dim.Get(), "].\n");
}
context->SetOutputDim("OutTrue", context->GetInputDim("X"));

Loading…
Cancel
Save