MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / get_value

Method get_value

imperative/src/impl/interpreter/interpreter_impl.cpp:487–508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

485}
486
487HostTensorND 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
510TensorShape ChannelImpl::get_shape(Handle handle) {
511 MGB_LOCK_GUARD(m_spin);

Callers 15

TESTFunction · 0.45
TESTFunction · 0.45
check_rng_basicFunction · 0.45
get_static_infer_valueFunction · 0.45
apply_on_var_nodeFunction · 0.45
applyFunction · 0.45
reprMethod · 0.45
apply_on_physical_tensorFunction · 0.45

Calls 4

findMethod · 0.45
endMethod · 0.45
pinMethod · 0.45
unpinMethod · 0.45

Tested by 5

TESTFunction · 0.36
TESTFunction · 0.36
check_rng_basicFunction · 0.36