From 69e92b39fc612819d8b393b60581bc72a8e393ab Mon Sep 17 00:00:00 2001 From: Yancey1989 Date: Wed, 11 Oct 2017 20:29:44 +0800 Subject: [PATCH] add an enforce --- paddle/operators/sequence_concat_op.cc | 3 ++- paddle/operators/sequence_concat_op.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/paddle/operators/sequence_concat_op.cc b/paddle/operators/sequence_concat_op.cc index c4d681bc85..3d19471618 100644 --- a/paddle/operators/sequence_concat_op.cc +++ b/paddle/operators/sequence_concat_op.cc @@ -65,7 +65,8 @@ class SequenceConcatOpMaker : public framework::OpProtoAndCheckerMaker { "If the level is 0, the inputs will be joined at the nested " "sequence level." "If the level is 1, the inputs will be joined at the " - "sequence level.") + "sequence level." + "The level should be less than the levels of input") .SetDefault(0); AddComment(R"DOC( The sequence_concat operator concatenates multiple LoDTensors. diff --git a/paddle/operators/sequence_concat_op.h b/paddle/operators/sequence_concat_op.h index b08699e1a1..a197a05bbb 100644 --- a/paddle/operators/sequence_concat_op.h +++ b/paddle/operators/sequence_concat_op.h @@ -77,6 +77,9 @@ class SequenceConcatOpKernel : public framework::OpKernel { "LoDTensors should be the same."); } } + PADDLE_ENFORCE_GT(ins[0]->NumLevels(), level, + "The levels of all the input LoDTensors " + "should be greater than the specify level"); out->mutable_data(ctx.GetPlace()); auto out_lod = concatLoD(ins, axis, level);