Skip to content

Commit d35ef9d

Browse files
committed
follow commit
1 parent ccf0b1b commit d35ef9d

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

paddle/function/BufferArg.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,31 @@ class BufferArg {
5656
: buf_(buf), valueType_(valueType) {}
5757

5858
BufferArg(const Matrix& matrix)
59-
: buf_((void*)matrix.getData()),
59+
: buf_(reinterpret_cast<void*>(matrix.getData())),
6060
valueType_(DataType<real>::value),
6161
shape_(2) {
6262
shape_.setDim(0, matrix.getHeight());
6363
shape_.setDim(1, matrix.getWidth());
6464
}
6565

6666
BufferArg(const Matrix& matrix, const TensorShape& shape)
67-
: buf_((void*)matrix.getData()),
67+
: buf_(reinterpret_cast<void*>(matrix.getData())),
6868
valueType_(DataType<real>::value),
6969
shape_(shape) {
7070
CHECK_EQ(matrix.getElementCnt(), shape.getElements());
7171
}
7272

7373
BufferArg(const Vector& vector)
74-
: buf_((void*)vector.getData()),
74+
: buf_(reinterpret_cast<void*>(vector.getData())),
7575
valueType_(DataType<real>::value),
7676
shape_(1) {
7777
shape_.setDim(0, vector.getSize());
7878
}
7979

8080
BufferArg(const IVector& vector)
81-
: buf_((void*)vector.getData()), valueType_(VALUE_TYPE_INT32), shape_(1) {
81+
: buf_(reinterpret_cast<void*>(vector.getData())),
82+
valueType_(VALUE_TYPE_INT32),
83+
shape_(1) {
8284
shape_.setDim(0, vector.getSize());
8385
}
8486

@@ -129,7 +131,7 @@ class BufferArg {
129131
// sequence start positions in a mini-batch of sequences
130132
// shape_.ndims() == 1
131133
// valueType_ = int32
132-
// if a < b than value_.buf_[a] < value_.buf_[b]
134+
// if a < b then value_.buf_[a] < value_.buf_[b]
133135
class SequenceIdArg : public BufferArg {
134136
public:
135137
SequenceIdArg(void* buf, const TensorShape& shape)
@@ -203,13 +205,13 @@ class SparseMatrixArg : public BufferArg {
203205

204206
SparseMatrixArg(const CpuSparseMatrix& sparse)
205207
: BufferArg(sparse),
206-
row_((void*)sparse.getRows(), VALUE_TYPE_INT32),
207-
col_((void*)sparse.getCols(), VALUE_TYPE_INT32) {}
208+
row_(reinterpret_cast<void*>(sparse.getRows()), VALUE_TYPE_INT32),
209+
col_(reinterpret_cast<void*>(sparse.getCols()), VALUE_TYPE_INT32) {}
208210

209211
SparseMatrixArg(const GpuSparseMatrix& sparse)
210212
: BufferArg(sparse),
211-
row_((void*)sparse.getRows(), VALUE_TYPE_INT32),
212-
col_((void*)sparse.getCols(), VALUE_TYPE_INT32) {}
213+
row_(reinterpret_cast<void*>(sparse.getRows()), VALUE_TYPE_INT32),
214+
col_(reinterpret_cast<void*>(sparse.getCols()), VALUE_TYPE_INT32) {}
213215

214216
~SparseMatrixArg() {}
215217

paddle/function/TensorShape.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ class TensorShape {
3030
TensorShape(std::initializer_list<size_t> dims) {
3131
ndims_ = dims.size();
3232
initDims(ndims_);
33-
std::copy(dims.begin(), dims.end(), dims_.begin());
33+
dims_.assign(dims);
3434
numElements();
3535
};
3636

3737
TensorShape(const TensorShape& t)
3838
: ndims_(t.ndims_), nelements_(t.nelements_) {
3939
initDims(ndims_);
40-
std::copy(t.dims_.begin(), t.dims_.end(), dims_.begin());
40+
dims_.assign(t.dims_.begin(), t.dims_.end());
4141
};
4242

4343
// get the size of specified dimension

0 commit comments

Comments
 (0)