From c8283844d6606691abda9e64415760a7fb0ee461 Mon Sep 17 00:00:00 2001 From: Alejandro Saucedo Date: Sat, 6 Feb 2021 19:09:48 +0000 Subject: [PATCH] Added destructor for staging tensors --- src/OpTensorCreate.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/OpTensorCreate.cpp b/src/OpTensorCreate.cpp index eac588a6f..cc3f698c3 100644 --- a/src/OpTensorCreate.cpp +++ b/src/OpTensorCreate.cpp @@ -23,6 +23,16 @@ OpTensorCreate::OpTensorCreate( OpTensorCreate::~OpTensorCreate() { SPDLOG_DEBUG("Kompute OpTensorCreate destructor started"); + + SPDLOG_DEBUG("Kompute OpBase freeing staging tensors"); + for (std::shared_ptr tensor : this->mStagingTensors) { + if (tensor && tensor->isInit()) { + tensor->freeMemoryDestroyGPUResources(); + } else { + SPDLOG_ERROR("Kompute OpBase expected to free " + "tensor but has already been freed."); + } + } } void