From d35ef9de10b3b97f63fa0156a8c7d36e7e89c8b8 Mon Sep 17 00:00:00 2001 From: hedaoyuan Date: Mon, 9 Jan 2017 11:47:18 +0800 Subject: [PATCH] follow commit --- paddle/function/BufferArg.h | 20 +++++++++++--------- paddle/function/TensorShape.h | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/paddle/function/BufferArg.h b/paddle/function/BufferArg.h index 52494afed3b..d787d2814d8 100644 --- a/paddle/function/BufferArg.h +++ b/paddle/function/BufferArg.h @@ -56,7 +56,7 @@ public: : buf_(buf), valueType_(valueType) {} BufferArg(const Matrix& matrix) - : buf_((void*)matrix.getData()), + : buf_(reinterpret_cast(matrix.getData())), valueType_(DataType::value), shape_(2) { shape_.setDim(0, matrix.getHeight()); @@ -64,21 +64,23 @@ public: } BufferArg(const Matrix& matrix, const TensorShape& shape) - : buf_((void*)matrix.getData()), + : buf_(reinterpret_cast(matrix.getData())), valueType_(DataType::value), shape_(shape) { CHECK_EQ(matrix.getElementCnt(), shape.getElements()); } BufferArg(const Vector& vector) - : buf_((void*)vector.getData()), + : buf_(reinterpret_cast(vector.getData())), valueType_(DataType::value), shape_(1) { shape_.setDim(0, vector.getSize()); } BufferArg(const IVector& vector) - : buf_((void*)vector.getData()), valueType_(VALUE_TYPE_INT32), shape_(1) { + : buf_(reinterpret_cast(vector.getData())), + valueType_(VALUE_TYPE_INT32), + shape_(1) { shape_.setDim(0, vector.getSize()); } @@ -129,7 +131,7 @@ protected: // sequence start positions in a mini-batch of sequences // shape_.ndims() == 1 // valueType_ = int32 -// if a < b than value_.buf_[a] < value_.buf_[b] +// if a < b then value_.buf_[a] < value_.buf_[b] class SequenceIdArg : public BufferArg { public: SequenceIdArg(void* buf, const TensorShape& shape) @@ -203,13 +205,13 @@ public: SparseMatrixArg(const CpuSparseMatrix& sparse) : BufferArg(sparse), - row_((void*)sparse.getRows(), VALUE_TYPE_INT32), - col_((void*)sparse.getCols(), VALUE_TYPE_INT32) {} + row_(reinterpret_cast(sparse.getRows()), VALUE_TYPE_INT32), + col_(reinterpret_cast(sparse.getCols()), VALUE_TYPE_INT32) {} SparseMatrixArg(const GpuSparseMatrix& sparse) : BufferArg(sparse), - row_((void*)sparse.getRows(), VALUE_TYPE_INT32), - col_((void*)sparse.getCols(), VALUE_TYPE_INT32) {} + row_(reinterpret_cast(sparse.getRows()), VALUE_TYPE_INT32), + col_(reinterpret_cast(sparse.getCols()), VALUE_TYPE_INT32) {} ~SparseMatrixArg() {} diff --git a/paddle/function/TensorShape.h b/paddle/function/TensorShape.h index e70484a1afd..0333fe18316 100644 --- a/paddle/function/TensorShape.h +++ b/paddle/function/TensorShape.h @@ -30,14 +30,14 @@ public: TensorShape(std::initializer_list dims) { ndims_ = dims.size(); initDims(ndims_); - std::copy(dims.begin(), dims.end(), dims_.begin()); + dims_.assign(dims); numElements(); }; TensorShape(const TensorShape& t) : ndims_(t.ndims_), nelements_(t.nelements_) { initDims(ndims_); - std::copy(t.dims_.begin(), t.dims_.end(), dims_.begin()); + dims_.assign(t.dims_.begin(), t.dims_.end()); }; // get the size of specified dimension -- GitLab