From 1c5a7c431690ba6a981ac9f72aacf556da1bc1db Mon Sep 17 00:00:00 2001 From: hedaoyuan Date: Tue, 17 Jan 2017 17:33:15 +0800 Subject: [PATCH] follow comments --- paddle/function/BufferArg.h | 1 + paddle/function/FunctionTest.cpp | 1 + paddle/function/FunctionTest.h | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/paddle/function/BufferArg.h b/paddle/function/BufferArg.h index 9c792c6bb72..84209265ce7 100644 --- a/paddle/function/BufferArg.h +++ b/paddle/function/BufferArg.h @@ -192,6 +192,7 @@ public: SequenceIdArg(const TensorShape& shape, ArgType argType = UNSPECIFIED) : BufferArg(VALUE_TYPE_INT32, shape, argType) { CHECK_EQ(shape_.ndims(), (size_t)1); + CHECK_GT(shape_[0], 1); numSeqs_ = shape_[0] - 1; } diff --git a/paddle/function/FunctionTest.cpp b/paddle/function/FunctionTest.cpp index 03c609b5242..fdf7e631e5a 100644 --- a/paddle/function/FunctionTest.cpp +++ b/paddle/function/FunctionTest.cpp @@ -85,6 +85,7 @@ void testBufferArgs(const BufferArgs& inputs, } void testBufferArgs(const BufferArgs& inputs, const CheckBufferArg& check) { + EXPECT_EQ(inputs.size(), 1); check(inputs[0]); } diff --git a/paddle/function/FunctionTest.h b/paddle/function/FunctionTest.h index 412e3a7d1b3..24e7a36a43c 100644 --- a/paddle/function/FunctionTest.h +++ b/paddle/function/FunctionTest.h @@ -172,7 +172,7 @@ protected: void initArg(SequenceIdArg& arg, size_t batchSize) { size_t numSeqs = arg.numSeqs(); - int* buf = (int*)arg.data(); + int* buf = reinterpret_cast(arg.data()); int pos = 0; size_t maxLen = 2 * batchSize / numSeqs; for (int i = 0; i < (int)numSeqs; ++i) { -- GitLab