Paddle 加入IfElse导致paddle.fluid.core.EnforceNotMet

gcxthw6b  于 2022-10-20  发布在  其他
关注(0)|答案(2)|浏览(288)
  • 版本、环境信息:

   1)PaddlePaddle版本:1.4.1
   2)CPU:-
   3)GPU:Nvidia V100
   4)系统环境:python2.7

  • 训练信息

   1)单机,多卡
   2)32G
   3)Operator信息

  • 复现信息:
limit = fluid.layers.fill_constant_batch_size_like(
                input=cond1, shape=[1], value=0, dtype=cond1.dtype)
        cond = fluid.layers.less_than(x=cond1, y=limit)
        ie = fluid.layers.IfElse(cond)
        with ie.true_block():
            ie_input = ie.input(input)
            zero_output = paddle.fluid.layers.zeros(shape=ie_input.shape, dtype=input.dtype)
            ie.output(zero_output)

        with ie.false_block():
            ie_input = ie.input(input)
            op_output = self.conv_bn_layer(input=ie_input, num_filters=filter1, filter_size=5, stride=2, act='relu')
            ie.output(op_output)

        conv1 = ie()[0]
        conv2 = self.conv_bn_layer(input=input, num_filters=filter1, filter_size=3, stride=2, act='relu')
        conv = fluid.layers.elementwise_add(conv1, conv2)

报错信息为

File "/home/slurm/python-gcc482-paddle/lib/python2.7/site-packages/paddle/fluid/optimizer.py", line 403, in backward
    no_grad_set, callbacks)
  File "/home/slurm/python-gcc482-paddle/lib/python2.7/site-packages/paddle/fluid/backward.py", line 518, in append_backward
    _append_backward_vars_(root_block, fwd_op_num, grad_to_var, grad_info_map)
  File "/home/slurm/python-gcc482-paddle/lib/python2.7/site-packages/paddle/fluid/backward.py", line 354, in _append_backward_vars_
    op_desc.infer_shape(block.desc)
paddle.fluid.core.EnforceNotMet:  at [/paddle/paddle/fluid/operators/controlflow/conditional_block_op.cc:214]
PaddlePaddle Call Stacks:
0       0x7fdfb35217f0p void paddle::platform::EnforceNotMet::Init<char const*>(char const*, char const*, int) + 352
1       0x7fdfb3521b69p paddle::platform::EnforceNotMet::EnforceNotMet(std::__exception_ptr::exception_ptr, char const*, int) + 137
2       0x7fdfb4c7e861p paddle::operators::ConditionalBlockGradInferShape::operator()(paddle::framework::InferShapeContext*) const + 1089
3       0x7fdfb4c7ea73p std::_Function_handler<void (paddle::framework::InferShapeContext*), paddle::framework::details::OpInfoFiller<paddle::operators::Condi
tionalBlockGradInferShape, (paddle::framework::details::OpInfoFillType)4>::operator()(char const*, paddle::framework::OpInfo*) const::{lambda(paddle::framewor
k::InferShapeContext*)#1}>::_M_invoke(std::_Any_data const&, paddle::framework::InferShapeContext*) + 35
4       0x7fdfb367c21ep paddle::framework::OpDesc::InferShape(paddle::framework::BlockDesc const&) const + 862
5       0x7fdfb35d2b2cp
6       0x7fdfb35548dep
7       0x7fe04aa8555fp PyEval_EvalFrameEx + 29855
8       0x7fe04aa8786dp PyEval_EvalCodeEx + 2061
9       0x7fe04aa849fcp PyEval_EvalFrameEx + 26940
10      0x7fe04aa8786dp PyEval_EvalCodeEx + 2061
11      0x7fe04aa849fcp PyEval_EvalFrameEx + 26940
12      0x7fe04aa8786dp PyEval_EvalCodeEx + 2061
13      0x7fe04aa849fcp PyEval_EvalFrameEx + 26940
14      0x7fe04aa8786dp PyEval_EvalCodeEx + 2061
15      0x7fe04aa849fcp PyEval_EvalFrameEx + 26940
16      0x7fe04aa84b17p PyEval_EvalFrameEx + 27223
17      0x7fe04aa84b17p PyEval_EvalFrameEx + 27223
18      0x7fe04aa8786dp PyEval_EvalCodeEx + 2061
19      0x7fe04aa879a2p PyEval_EvalCode + 50
20      0x7fe04aab0782p PyRun_FileExFlags + 146
21      0x7fe04aab1af9p PyRun_SimpleFileExFlags + 217
22      0x7fe04aac782dp Py_Main + 3149
23      0x7fe049cc4bd5p __libc_start_main + 245
24            0x4007a1p
  • 问题描述:

希望通过使用IfElse操作在不同的step通过feed的方式选择不同的层进行前向和训练,但使用过程中报如上错误,没有准确的错误信息
去掉IfElse操作,直接将 conv1 赋为 conv_bn_layer 能够正常运行

xhv8bpkk

xhv8bpkk1#

zero_output = paddle.fluid.layers.zeros(shape=ie_input.shape, dtype=input.dtype)
shape应该跟false分支输出一致

owfi6suc

owfi6suc2#

zero_output = paddle.fluid.layers.zeros(shape=ie_input.shape, dtype=input.dtype)
shape应该跟false分支输出一致

将两个layer都替换成同样的conv,仍然报该错误

相关问题