Skip to content

Commit

Permalink
Merge pull request apache#98 from javelinjs/fix-tensor-container-release
Browse files Browse the repository at this point in the history
Make it able to set ptrs to null when Release fails.
  • Loading branch information
tqchen committed Feb 5, 2016
2 parents 1286bea + 6a9d036 commit 62ca0b7
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 62ca0b7

Please sign in to comment.