| 6 | namespace kp { |
| 7 | |
| 8 | OpTensorCopy::OpTensorCopy(const std::vector<std::shared_ptr<Tensor>>& tensors) |
| 9 | { |
| 10 | KP_LOG_DEBUG("Kompute OpTensorCopy constructor with params"); |
| 11 | |
| 12 | this->mTensors = tensors; |
| 13 | |
| 14 | if (this->mTensors.size() < 2) { |
| 15 | throw std::runtime_error( |
| 16 | "Kompute OpTensorCopy called with less than 2 tensor"); |
| 17 | } |
| 18 | |
| 19 | kp::Tensor::TensorDataTypes dataType = this->mTensors[0]->dataType(); |
| 20 | uint32_t size = this->mTensors[0]->size(); |
| 21 | for (const std::shared_ptr<Tensor>& tensor : tensors) { |
| 22 | if (tensor->dataType() != dataType) { |
| 23 | throw std::runtime_error(fmt::format( |
| 24 | "Attempting to copy tensors of different types from {} to {}", |
| 25 | Tensor::toString(dataType), |
| 26 | Tensor::toString(tensor->dataType()))); |
| 27 | } |
| 28 | if (tensor->size() != size) { |
| 29 | throw std::runtime_error(fmt::format( |
| 30 | "Attempting to copy tensors of different sizes from {} to {}", |
| 31 | size, |
| 32 | tensor->size())); |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | OpTensorCopy::~OpTensorCopy() |
| 38 | { |