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

Method get_value

src/tensorrt/impl/opr_replace.cpp:1230–1240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1228}
1229
1230HostTensorND TensorRTReplacePass::Impl::get_value(VarNode* var, ConvFormat format) {
1231 auto cg = m_opt_state.graph().comp_graph();
1232 auto inferred_val = HostTensorND(var->comp_node(), dtype::Float32());
1233 auto cb = [&](DeviceTensorND& val) { inferred_val.copy_from(val); };
1234 if (format == ConvFormat::NCHW) {
1235 mgb_assert(var->dtype() == dtype::Float32());
1236 auto orig_level = cg->options().log_level;
1237 cg->options().log_level = 0;
1238 MGB_TRY { cg->compile({{var, cb}})->execute(); }
1239 MGB_FINALLY(cg->options().log_level = orig_level);
1240 } else {
1241 mgb_assert(format == ConvFormat::NCHW4);
1242 if (var->shape().ndim == 5) {
1243 // assume nchw4 layout

Callers

nothing calls this directly

Calls 7

comp_graphMethod · 0.80
graphMethod · 0.45
comp_nodeMethod · 0.45
copy_fromMethod · 0.45
dtypeMethod · 0.45
executeMethod · 0.45
compileMethod · 0.45

Tested by

no test coverage detected