diff --git a/paddle/function/BufferArg.h b/paddle/function/BufferArg.h index 52494afed3b8554e9960f4ceccb86c9d94a6e91d..d787d2814d88bfc8753620e5f51d7a99936e432f 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 e70484a1afd9926b93c298b0a090f321f6daef95..0333fe18316ba4a82bbdc2b1ef99e6d2186a234c 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