Skip to content

Commit

Permalink
Make it able to set ptrs to null when Release fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
yzhliu committed Feb 5, 2016
1 parent 1286bea commit 6a9d036
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mshadow/tensor_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,17 @@ class TensorContainer: public Tensor<Device, dimension, DType> {
*/
inline void Release(void) {
if (data_.dptr_ != NULL) {
mshadow::FreeSpace(&data_);
this->dptr_ = data_.dptr_ = NULL;
this->shape_[0] = 0;
this->stride_ = 0;
this->data_.stride_ = 0;
this->data_.shape_[0] = 0;
try {
mshadow::FreeSpace(&data_);
} catch (const dmlc::Error &e) {
this->dptr_ = data_.dptr_ = NULL;
throw e;
}
this->dptr_ = data_.dptr_ = NULL;
}
}

Expand Down

0 comments on commit 6a9d036

Please sign in to comment.