| 169 | |
| 170 | |
| 171 | bool Tensor::copyFromHostTensor(const Tensor* hostTensor) { |
| 172 | auto bn = mDescribe->getBackend(); |
| 173 | if (nullptr == bn) { |
| 174 | return false; |
| 175 | } |
| 176 | auto hostbn = hostTensor->mDescribe->getBackend(); |
| 177 | std::shared_ptr<Tensor> tmpTensor; |
| 178 | if (nullptr != hostbn && hostbn->type() != bn->type() && hostbn->type() != MNN_FORWARD_CPU) { |
| 179 | tmpTensor.reset(new Tensor(hostTensor, hostTensor->getDimensionType())); |
| 180 | hostTensor->copyToHostTensor(tmpTensor.get()); |
| 181 | hostTensor = tmpTensor.get(); |
| 182 | } |
| 183 | bn->onCopyBuffer(hostTensor, this); |
| 184 | return true; |
| 185 | } |
| 186 | |
| 187 | bool Tensor::copyToHostTensor(Tensor* hostTensor) const { |
| 188 | auto bn = mDescribe->getBackend(); |