| 461 | } |
| 462 | |
| 463 | void Tensor::unmap(MapType mtype, DimensionType dtype, void *mapPtr) { |
| 464 | auto nativeDescribe = mDescribe; |
| 465 | auto bn = nativeDescribe->getBackend(); |
| 466 | if (nullptr == bn) { |
| 467 | return; |
| 468 | } |
| 469 | |
| 470 | bool ret = bn->onUnmapTensor(mtype, dtype, this, mapPtr); |
| 471 | if(true == ret) { |
| 472 | //do unmap already, just return |
| 473 | return; |
| 474 | } |
| 475 | |
| 476 | if(mtype == Tensor::MAP_TENSOR_WRITE) { |
| 477 | //srcTensor alloc |
| 478 | MNN::Tensor srcTensor(this, dtype, false); |
| 479 | srcTensor.buffer().host = (uint8_t *)mapPtr; |
| 480 | |
| 481 | //use onCopyBuffer |
| 482 | bn->onCopyBuffer(&srcTensor, this); |
| 483 | } |
| 484 | if(mapPtr != nullptr) { |
| 485 | free(mapPtr); |
| 486 | mapPtr = nullptr; |
| 487 | } |
| 488 | } |
| 489 | int Tensor::wait(MapType mtype, bool finish) { |
| 490 | auto nativeDescribe = mDescribe; |
| 491 | auto bn = nativeDescribe->getBackend(); |