IrTensor::DTYPE type = IrTensor::DTYPE::FLOAT;
size_t elementSize;
+ const char *srcData;
+ size_t bufferSize;
+
if (bp.data_size() != 0)
{
assert(bp.double_data_size() == 0);
elementSize = sizeof(float);
+ bufferSize = bp.data_size() * elementSize;
+ srcData = reinterpret_cast<const char *>(bp.data().data());
}
else if (bp.double_data_size() != 0)
{
elementSize = sizeof(double);
+ bufferSize = bp.double_data_size() * elementSize;
+ srcData = reinterpret_cast<const char *>(bp.double_data().data());
}
else
{
}
// Create untyped tensor. Note, tensor contents will be *copied* here.
- std::shared_ptr<char> tensorBufferCopy(new char[bp.data().size() * elementSize],
- [](char *d) { delete[] d; });
+ std::shared_ptr<char> tensorBufferCopy(new char[bufferSize],
+ std::default_delete<char[]>());
- std::copy(bp.data().begin(), bp.data().end(), tensorBufferCopy.get());
+ char *dstData = tensorBufferCopy.get();
+ memcpy(dstData, srcData, bufferSize);
Shape tensorShape = common::ShapeHelper::createShape(
bp.shape().dim(), static_cast<size_t>(bp.shape().dim_size()));