Updated destroy and amended tests to ensure they test tensor in scope

This commit is contained in:
Alejandro Saucedo 2021-03-07 08:10:42 +00:00
parent 1cc369cb19
commit bb64b2b37c
3 changed files with 41 additions and 7 deletions

View file

@ -50,7 +50,7 @@ Tensor::rebuild(void* data,
}
this->allocateMemoryCreateGPUResources();
this->rawMapData();
this->mapRawData();
memcpy(this->mRawData, data, this->memorySize());
}
@ -64,7 +64,10 @@ Tensor::tensorType()
bool
Tensor::isInit()
{
return this->mDevice && this->mPrimaryBuffer && this->mPrimaryMemory;
return this->mDevice
&& this->mPrimaryBuffer
&& this->mPrimaryMemory
&& this->mRawData;
}
@ -360,6 +363,7 @@ Tensor::destroy()
{
KP_LOG_DEBUG("Kompute Tensor started destroy()");
// Setting raw data to null regardless whether device is available to invalidate Tensor
this->mRawData = nullptr;
this->mSize = 0;
this->mDataTypeMemorySize = 0;
@ -370,6 +374,9 @@ Tensor::destroy()
return;
}
// Unmap the current memory data
this->unmapRawData();
if (this->mFreePrimaryBuffer) {
if (!this->mPrimaryBuffer) {
KP_LOG_WARN("Kompose Tensor expected to destroy primary buffer "