Reformatted

This commit is contained in:
Alejandro Saucedo 2020-09-12 17:21:50 +01:00
parent c5df89c17b
commit fdc1d3b91a
23 changed files with 455 additions and 418 deletions

View file

@ -35,19 +35,18 @@ OpTensorCreate::init()
"Kompute OpTensorCreate called with less than 1 tensor");
}
for (std::shared_ptr<Tensor> tensor: this->mTensors) {
for (std::shared_ptr<Tensor> tensor : this->mTensors) {
if (tensor->isInit()) {
throw std::runtime_error("Kompute OpTensorCreate: Tensor has already been initialized");
throw std::runtime_error(
"Kompute OpTensorCreate: Tensor has already been initialized");
}
if (tensor->tensorType() == Tensor::TensorTypes::eDevice) {
tensor->init(
this->mPhysicalDevice, this->mDevice);
tensor->init(this->mPhysicalDevice, this->mDevice);
std::shared_ptr<Tensor> stagingTensor = std::make_shared<Tensor>(
tensor->data(), Tensor::TensorTypes::eStaging);
stagingTensor->init(
this->mPhysicalDevice, this->mDevice);
stagingTensor->init(this->mPhysicalDevice, this->mDevice);
stagingTensor->mapDataIntoHostMemory();
@ -55,12 +54,11 @@ OpTensorCreate::init()
} else {
tensor->init(
this->mPhysicalDevice, this->mDevice);
tensor->init(this->mPhysicalDevice, this->mDevice);
tensor->mapDataIntoHostMemory();
// We push a nullptr when no staging tensor is needed to match
// We push a nullptr when no staging tensor is needed to match
// index number in array to have one to one mapping with tensors
this->mStagingTensors.push_back(nullptr);
}
@ -74,8 +72,9 @@ OpTensorCreate::record()
for (size_t i = 0; i < this->mTensors.size(); i++) {
if (this->mTensors[i]->tensorType() == Tensor::TensorTypes::eDevice) {
this->mTensors[i]->recordCopyFrom(this->mCommandBuffer, this->mStagingTensors[i], false);
}
this->mTensors[i]->recordCopyFrom(
this->mCommandBuffer, this->mStagingTensors[i], false);
}
}
}