MCPcopy Create free account
hub / github.com/KomputeProject/kompute / OpTensorCopy

Method OpTensorCopy

src/OpTensorCopy.cpp:8–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6namespace kp {
7
8OpTensorCopy::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
37OpTensorCopy::~OpTensorCopy()
38{

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.80
dataTypeMethod · 0.80

Tested by

no test coverage detected