Skip to content

Commit

Permalink
declare explicitly the tblob default assign operator and copy constru…
Browse files Browse the repository at this point in the history
…ctor (apache#15937)
  • Loading branch information
hzfan authored and Ubuntu committed Aug 20, 2019
1 parent 5bfd963 commit 47a0554
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions include/mxnet/tensor_blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ class TBlob {
TBlob(const mshadow::Tensor<Device, dim, DType> &src) { // NOLINT(*)
*this = src;
}
/*!
* \brief constructor from TBlob (copy constructor)
* \param src source TBlob
*/
TBlob(const TBlob &src): dptr_(src.dptr_), shape_(src.shape_), type_flag_(src.type_flag_) {
this->SetDLTensor(src.dev_mask(), src.dev_id());
}
/*!
* \brief assignment from tensor
* \param src source tensor
Expand All @@ -164,6 +171,18 @@ class TBlob {
SetDLTensor(Device::kDevMask, -1);
return *this;
}
/*!
* \brief assignment from TBlob (copy assignment)
* \param src source TBlob
* \return reference of self
*/
inline TBlob &operator=(const TBlob &src) {
dptr_ = src.dptr_;
shape_ = src.shape_;
type_flag_ = src.type_flag_;
SetDLTensor(src.dev_mask(), src.dev_id());
return *this;
}
/*!
* \return whether the tensor's memory is continuous
*/
Expand Down

0 comments on commit 47a0554

Please sign in to comment.