KomputeProject/kompute

"Kompute Tensor device is null" when rebuilding tensor

MiroPalmu opened this issue · 0 comments

When creating a tensor from manager with

inline std::shared_ptr<kp::TensorT<float>> kp::Manager::tensorT<float>(const kp::Constants &data, kp::Tensor::TensorTypes tensorType = kp::Tensor::TensorTypes::eDevice)

and then calling rebuild on created tensor it will throw "Kompute Tensor device is null"

I'm not very familiar with kompute yet but it seems if in rebuild member function following branch gets executed

if (this->mPrimaryBuffer || this->mPrimaryMemory) {
        KP_LOG_DEBUG(
          "Kompute Tensor destroying existing resources before rebuild");
        this->destroy();
    }

then in allocateMemoryCreateGPUResources

if (!this->mDevice) {
        throw std::runtime_error("Kompute Tensor device is null");
    }

gets executed every time because after this->destroy() mDevice is nullptr every time. This can be seen at Tensor.cpp:548

if (this->mDevice) {
    this->mDevice = nullptr;
}