From 5b9716d1f6f8653a4785e50582548f473df21a0a Mon Sep 17 00:00:00 2001 From: tangwei12 Date: Mon, 6 Aug 2018 21:22:35 +0800 Subject: [PATCH] add dims check --- paddle/fluid/operators/sampling_id_op.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/paddle/fluid/operators/sampling_id_op.cc b/paddle/fluid/operators/sampling_id_op.cc index 17f6461fcb8..d13eeabcb96 100644 --- a/paddle/fluid/operators/sampling_id_op.cc +++ b/paddle/fluid/operators/sampling_id_op.cc @@ -30,6 +30,8 @@ class SamplingIdOp : public framework::OperatorWithKernel { "Output(Out) of SamplingIdOp should not be null."); auto input_dims = ctx->GetInputDim("X"); + PADDLE_ENFORCE(input_dims.size() == 2, + "Input(X, Filter) should be 2-D tensor."); framework::DDim dims = input_dims; ctx->SetOutputDim("Out", dims); @@ -46,10 +48,8 @@ class SamplingIdOpMaker : public framework::OpProtoAndCheckerMaker { AddOutput("Out", "SamplingId data tensor."); AddComment(R"DOC( SamplingId Operator. - @brief A layer for sampling id from multinomial distribution from the - input layer. Sampling one id for one sample. The result is stored in - output_.ids. -)DOC"); +A layer for sampling id from multinomial distribution from the + input layer. Sampling one id for one sample.)DOC"); } }; } // namespace operators -- GitLab