| 485 | } |
| 486 | |
| 487 | HostTensorND ChannelImpl::get_value(Handle handle) { |
| 488 | MGB_LOCK_GUARD(m_spin); |
| 489 | assert_available(); |
| 490 | mgb_assert( |
| 491 | m_valid_handle.find(handle) != m_valid_handle.end(), "invalid handle: %p", |
| 492 | handle); |
| 493 | auto info = reinterpret_cast<TensorInfo*>(handle); |
| 494 | // donnot use info->value_fetched, it's unsafe |
| 495 | mgb_assert(!info->invalid, "tensor is unusable due to previous error"); |
| 496 | |
| 497 | // pin |
| 498 | SmallVector<TensorInfo*> vec({info}); |
| 499 | m_dtr.pin(vec); |
| 500 | |
| 501 | auto ret = wait_tensor(info, TensorProp::HostValue)->get_value(); |
| 502 | |
| 503 | // unpin |
| 504 | auto& state = get_channel_state(); |
| 505 | auto dtr_evictee_minimum_size = state.options.dtr_evictee_minimum_size; |
| 506 | m_dtr.unpin(vec, dtr_evictee_minimum_size); |
| 507 | return ret; |
| 508 | } |
| 509 | |
| 510 | TensorShape ChannelImpl::get_shape(Handle handle) { |
| 511 | MGB_LOCK_GUARD(m_spin); |