MCPcopy Create free account
hub / github.com/alibaba/MNN / copyToDevicePtr

Method copyToDevicePtr

express/Expr.cpp:591–613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

589}
590
591bool Variable::copyToDevicePtr(void* devicePtr, int memoryType) {
592 if (nullptr != mFrom->get()) {
593 MNN_ERROR("Can't copyToDevicePtr to no-input op\n");
594 return false;
595 }
596
597 auto inside = mFrom->inside();
598 auto originTensor = inside->mOutputTensors[mFromIndex];
599
600 auto bn = TensorUtils::getDescribeOrigin(originTensor)->getBackend();
601 if(bn == nullptr) {
602 MNN_ERROR("Error: Varp copyToDevicePtr can't find backend\n");
603 return false;
604 }
605
606 MNN::Tensor tempTensor(originTensor->dimensions(), originTensor->getDimensionType());
607 tempTensor.setDevicePtr(devicePtr, memoryType);
608
609 TensorUtils::getDescribeOrigin(originTensor)->getBackend()->onCopyBuffer(originTensor, &tempTensor);
610 // Sync the result
611 tempTensor.wait(Tensor::MAP_TENSOR_READ, true);
612 return true;
613}
614
615const std::string& Variable::name() const {
616 return mFrom->outputName(mFromIndex);

Callers 3

mainFunction · 0.80
runMethod · 0.80

Calls 7

getDimensionTypeMethod · 0.80
getMethod · 0.45
getBackendMethod · 0.45
dimensionsMethod · 0.45
setDevicePtrMethod · 0.45
onCopyBufferMethod · 0.45
waitMethod · 0.45

Tested by 2

mainFunction · 0.64
runMethod · 0.64