diff --git a/src/Sequence.cpp b/src/Sequence.cpp index 4db458288..501e965d0 100644 --- a/src/Sequence.cpp +++ b/src/Sequence.cpp @@ -27,7 +27,9 @@ Sequence::~Sequence() { KP_LOG_DEBUG("Kompute Sequence Destructor started"); - this->destroy(); + if (this->mDevice) { + this->destroy(); + } } void @@ -81,7 +83,9 @@ void Sequence::clear() { KP_LOG_DEBUG("Kompute Sequence calling clear"); - this->end(); + if (this->isRecording()) { + this->end(); + } } std::shared_ptr diff --git a/src/Tensor.cpp b/src/Tensor.cpp index 90c21fc8a..a7b433a74 100644 --- a/src/Tensor.cpp +++ b/src/Tensor.cpp @@ -28,7 +28,9 @@ Tensor::~Tensor() KP_LOG_DEBUG("Kompute Tensor destructor started. Type: {}", this->tensorType()); - this->destroy(); + if (this->mDevice) { + this->destroy(); + } KP_LOG_DEBUG("Kompute Tensor destructor success"); }