MCPcopy Create free account
hub / github.com/apache/singa / CopyDataFromHostPtr

Method CopyDataFromHostPtr

src/core/tensor/tensor.cc:250–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248
249template <typename DType>
250void Tensor::CopyDataFromHostPtr(const DType *src, const size_t num,
251 const size_t offset) const {
252 CHECK_EQ(sizeof(DType), SizeOf(data_type_))
253 << "data_type is " << DataType_Name(data_type_)
254 << " user given type is of size " << sizeof(DType);
255 if (src != nullptr) {
256 Device *dev = device_.get();
257 const Tensor &thisRef = *this;
258 size_t nBytes = sizeof(DType) * num;
259 size_t dst_offset = sizeof(DType) * offset;
260 device_->Exec(
261 [dev, thisRef, src, nBytes, dst_offset](Context *ctx) mutable {
262 dev->CopyDataFromHostPtr(thisRef.block(), src, nBytes, dst_offset,
263 ctx);
264 },
265 {}, {block()}, "CopyDataFromHostPtr");
266 } else {
267 LOG(WARNING) << "Copy data from null host ptr";
268 }
269}
270template void Tensor::CopyDataFromHostPtr(const unsigned char *src,
271 const size_t num,
272 const size_t offset) const;

Callers 15

TESTFunction · 0.45
TESTFunction · 0.45
TESTFunction · 0.45
TEST_FFunction · 0.45
SetUpMethod · 0.45
TEST_FFunction · 0.45
TESTFunction · 0.45
TESTFunction · 0.45
TESTFunction · 0.45
TESTFunction · 0.45
TESTFunction · 0.45
TESTFunction · 0.45

Calls 4

SizeOfFunction · 0.85
ExecMethod · 0.80
getMethod · 0.45
blockMethod · 0.45

Tested by 15

TESTFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36
TEST_FFunction · 0.36
SetUpMethod · 0.36
TEST_FFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36