未验证 提交 9e29d3eb 编写于 作者: H huzhiqiang 提交者: GitHub

【OpPorting Example】DEMO OF FIX COMPILE&RUNTIME LOD_EQUALITY (#22460)

上级 00c110f3
...@@ -32,6 +32,15 @@ class SequenceEraseOp : public framework::OperatorWithKernel { ...@@ -32,6 +32,15 @@ class SequenceEraseOp : public framework::OperatorWithKernel {
"Input(X) of SequenceEraseOp should be a 2-D LoDTensor " "Input(X) of SequenceEraseOp should be a 2-D LoDTensor "
"with the 2nd dimension equal to 1."); "with the 2nd dimension equal to 1.");
ctx->SetOutputDim("Out", x_dims); 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"));
}
} }
}; };
......
...@@ -37,6 +37,9 @@ class SequenceReshapeOp : public framework::OperatorWithKernel { ...@@ -37,6 +37,9 @@ class SequenceReshapeOp : public framework::OperatorWithKernel {
} else { } else {
// when compiling, the batch size is undetermined, just set to -1 // when compiling, the batch size is undetermined, just set to -1
ctx->SetOutputDim("Out", {-1, static_cast<int64_t>(new_dim)}); ctx->SetOutputDim("Out", {-1, static_cast<int64_t>(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);
} }
} }
}; };
......
...@@ -19,11 +19,25 @@ ...@@ -19,11 +19,25 @@
# reasons for skipping compile_vs_runtime test or be fixed later. # reasons for skipping compile_vs_runtime test or be fixed later.
COMPILE_RUN_OP_WHITE_LIST = [ COMPILE_RUN_OP_WHITE_LIST = [
'lod_reset', 'sequence_pool', 'sequence_slice', 'generate_mask_labels', 'lod_reset', \
'sequence_reshape', 'generate_proposals', 'mine_hard_examples', 'sequence_pool', \
'retinanet_detection_output', 'ctc_align', 'fusion_seqpool_cvm_concat', 'sequence_slice', \
'gru', 'sequence_erase', 'rpn_target_assign', 'retinanet_target_assign', 'generate_mask_labels', \
'filter_by_instag', 'multiclass_nms', 'multiclass_nms2', 'im2sequence', 'generate_proposals', \
'generate_proposal_labels', 'distribute_fpn_proposals', 'detection_map', 'mine_hard_examples', \
'locality_aware_nms', 'var_conv_2d' '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'
] ]
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册