Created by: chenwhql
What this PR does:
- Change the arrangement of the error message stack, from top to bottom is
C++ Call Stack
,Python Call Stack
,Error message summary
- Add the separation and prompt between stack information
- Simplify C++ stack information
- Discard error type that confuses users, like
Enforce failed
Original error message:
paddle.fluid.core_avx.EnforceNotMet: Invoke operator mul error.
Python Callstacks:
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/framework.py", line 1771, in append_op
attrs=kwargs.get("attrs", None))
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/layer_helper.py", line 43, in append_op
return self.main_program.current_block().append_op(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/layers/nn.py", line 334, in fc
"y_num_col_dims": 1})
File "startup.py", line 15, in <module>
y_ = fluid.layers.fc(input=x, size=1, act=None)
C++ Callstacks:
Enforce failed. Expected x_mat_dims[1] == y_mat_dims[0], but received x_mat_dims[1]:13 != y_mat_dims[0]:12.
First matrix's width must be equal with second matrix's height. 13, 12 at [/work/Paddle/paddle/fluid/operators/mul_op.cc:63]
PaddlePaddle Call Stacks:
0 0x7fb7b6d511ddp void paddle::platform::EnforceNotMet::Init<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char const*, int) + 509
1 0x7fb7b6d51ecdp paddle::platform::EnforceNotMet::EnforceNotMet(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int) + 125
2 0x7fb7b70a5d4bp paddle::operators::MulOp::InferShape(paddle::framework::InferShapeContext*) const + 3435
3 0x7fb7b8ed5271p paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&, paddle::framework::RuntimeContext*) const + 897
4 0x7fb7b8ed5d07p paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) const + 487
5 0x7fb7b8ecf24ep paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) + 318
6 0x7fb7b6f2c076p paddle::framework::Executor::RunPreparedContext(paddle::framework::ExecutorPrepareContext*, paddle::framework::Scope*, bool, bool, bool) + 374
7 0x7fb7b6f2efddp paddle::framework::Executor::Run(paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int, bool, bool, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, bool) + 189
8 0x7fb7b6d37a26p
9 0x7fb7b6d83544p
10 0x4ea137p PyCFunction_Call + 119
11 0x53c176p PyEval_EvalFrameEx + 23030
12 0x53fc97p
13 0x53bc93p PyEval_EvalFrameEx + 21779
14 0x53fc97p
15 0x53b83fp PyEval_EvalFrameEx + 20671
16 0x53fc97p
17 0x5409bfp PyEval_EvalCode + 31
18 0x60cb42p
19 0x60efeap PyRun_FileExFlags + 154
20 0x60f7dcp PyRun_SimpleFileExFlags + 444
21 0x640256p Py_Main + 1110
22 0x4d0001p main + 225
23 0x7fb8215b5830p __libc_start_main + 240
24 0x5d6999p _start + 41
New error message:
--------------------------------------------
C++ Call Stacks (More useful to developers):
--------------------------------------------
0 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > paddle::platform::GetTraceBackString<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int)
1 paddle::platform::EnforceNotMet::EnforceNotMet(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int)
2 paddle::operators::MulOp::InferShape(paddle::framework::InferShapeContext*) const
3 paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&, paddle::framework::RuntimeContext*) const
4 paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) const
5 paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&)
6 paddle::framework::Executor::RunPreparedContext(paddle::framework::ExecutorPrepareContext*, paddle::framework::Scope*, bool, bool, bool)
7 paddle::framework::Executor::Run(paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int, bool, bool, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, bool)
------------------------------------------
Python Call Stacks (More useful to users):
------------------------------------------
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/framework.py", line 1904, in append_op
attrs=kwargs.get("attrs", None))
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/layer_helper.py", line 43, in append_op
return self.main_program.current_block().append_op(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/layers/nn.py", line 350, in fc
"y_num_col_dims": 1})
File "startup.py", line 15, in <module>
y_ = fluid.layers.fc(input=x, size=1, act=None)
----------------------
Error Message Summary:
----------------------
PaddleCheckError: Expected x_mat_dims[1] == y_mat_dims[0], but received x_mat_dims[1]:13 != y_mat_dims[0]:12.
First matrix's width must be equal with second matrix's height. 13, 12 at [/work/paddle/paddle/fluid/operators/mul_op.cc:66]
[operator < mul > error]
Test cases:
- run time error
import paddle.fluid as fluid
import numpy
place = fluid.CPUPlace()
exe = fluid.Executor(place)
x = fluid.layers.data(name='X', shape=[12], dtype='float32')
y = fluid.layers.data(name='Y', shape=[1], dtype='float32')
y_ = fluid.layers.fc(input=x, size=1, act=None)
loss = fluid.layers.square_error_cost(input=y_, label=y)
avg_loss = fluid.layers.mean(loss)
fluid.optimizer.SGD(learning_rate=0.01).minimize(avg_loss)
exe.run(fluid.default_startup_program())
x = numpy.random.random(size=(10, 13)).astype('float32')
y = numpy.random.random(size=(10, 1)).astype('float32')
loss_data, = exe.run(fluid.default_main_program(), feed={'X': x, 'Y': y}, fetch_list=[avg_loss.name])
- compile time error
import paddle.fluid as fluid
x=fluid.layers.data(name='x', append_batch_size = False, shape=[2, 5, 4, 3], dtype='float64')
y=fluid.layers.data(name='y', append_batch_size = False, shape=[2, 4, 4, 3], dtype='float64')
mul=fluid.layers.mul(x=x, y=y, x_num_col_dims=2, y_num_col_dims=2)