| 71 | } |
| 72 | |
| 73 | void |
| 74 | Tensor::rebuild(void* data, |
| 75 | uint32_t elementTotalCount, |
| 76 | uint32_t elementMemorySize) |
| 77 | { |
| 78 | KP_LOG_DEBUG("Kompute Tensor rebuilding with size {}", elementTotalCount); |
| 79 | |
| 80 | this->mSize = elementTotalCount; |
| 81 | this->mDataTypeMemorySize = elementMemorySize; |
| 82 | |
| 83 | if (this->mPrimaryBuffer || this->mPrimaryMemory) { |
| 84 | KP_LOG_DEBUG( |
| 85 | "Kompute Tensor destroying existing resources before rebuild"); |
| 86 | this->destroy(); |
| 87 | } |
| 88 | |
| 89 | this->allocateMemoryCreateGPUResources(); |
| 90 | |
| 91 | if (this->tensorType() != Tensor::TensorTypes::eStorage) { |
| 92 | this->mapRawData(); |
| 93 | memcpy(this->mRawData, data, this->memorySize()); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | Tensor::TensorTypes |
| 98 | Tensor::tensorType() |