diff --git a/paddle/fluid/operators/sequence_ops/sequence_erase_op.cc b/paddle/fluid/operators/sequence_ops/sequence_erase_op.cc index ddda80ee0824e261b0d737f86e03866d5fdfd77a..4343a76b484126ce1a5be911d1a3cf5d270741a1 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_erase_op.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_erase_op.cc @@ -32,6 +32,15 @@ class SequenceEraseOp : public framework::OperatorWithKernel { "Input(X) of SequenceEraseOp should be a 2-D LoDTensor " "with the 2nd dimension equal to 1."); ctx->SetOutputDim("Out", x_dims); + // The output LoDTensor's lod_level should be input X's lod_level. + // For compile-time, we call SetLoDLevel to set output's lod_level. + // For runtime, output LoDTensor's lod is determined by input X's lod and + // the level specified by input RandTable. + // We cannot get X's detail lod and RankTable's level in this function, so + // leave this work to the detail kernel implementation. + if (!ctx->IsRuntime()) { + ctx->SetLoDLevel("Out", ctx->GetLoDLevel("X")); + } } }; diff --git a/paddle/fluid/operators/sequence_ops/sequence_reshape_op.cc b/paddle/fluid/operators/sequence_ops/sequence_reshape_op.cc index e1d8911c32ffc56209b1b59805d10f59f24dd25f..60350bd96d1f06b701a91e7435f7a2832d69aaee 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_reshape_op.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_reshape_op.cc @@ -37,6 +37,9 @@ class SequenceReshapeOp : public framework::OperatorWithKernel { } else { // when compiling, the batch size is undetermined, just set to -1 ctx->SetOutputDim("Out", {-1, static_cast(new_dim)}); + // when compiling, the LodLevel of Out is set to be 1, which is consistent + // with that in running time. + ctx->SetLoDLevel("Out", 1); } } }; diff --git a/python/paddle/fluid/tests/unittests/white_list/compile_vs_runtime_white_list.py b/python/paddle/fluid/tests/unittests/white_list/compile_vs_runtime_white_list.py index 9aabfb40827a307c9a2272b19db738063a23bd29..ed7788443a6a18ec20e98c28957296d760530ace 100644 --- a/python/paddle/fluid/tests/unittests/white_list/compile_vs_runtime_white_list.py +++ b/python/paddle/fluid/tests/unittests/white_list/compile_vs_runtime_white_list.py @@ -19,11 +19,25 @@ # reasons for skipping compile_vs_runtime test or be fixed later. COMPILE_RUN_OP_WHITE_LIST = [ - 'lod_reset', 'sequence_pool', 'sequence_slice', 'generate_mask_labels', - 'sequence_reshape', 'generate_proposals', 'mine_hard_examples', - 'retinanet_detection_output', 'ctc_align', 'fusion_seqpool_cvm_concat', - 'gru', 'sequence_erase', 'rpn_target_assign', 'retinanet_target_assign', - 'filter_by_instag', 'multiclass_nms', 'multiclass_nms2', 'im2sequence', - 'generate_proposal_labels', 'distribute_fpn_proposals', 'detection_map', - 'locality_aware_nms', 'var_conv_2d' + 'lod_reset', \ + 'sequence_pool', \ + 'sequence_slice', \ + 'generate_mask_labels', \ + 'generate_proposals', \ + 'mine_hard_examples', \ + 'retinanet_detection_output', \ + 'ctc_align', \ + 'fusion_seqpool_cvm_concat', \ + 'gru', \ + 'rpn_target_assign', \ + 'retinanet_target_assign', \ + 'filter_by_instag', \ + 'multiclass_nms', \ + 'multiclass_nms2', \ + 'im2sequence', \ + 'generate_proposal_labels', \ + 'distribute_fpn_proposals', \ + 'detection_map', \ + 'locality_aware_nms', \ + 'var_conv_2d' ]