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

Method exit

imperative/python/src/tensor.cpp:1323–1366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1321 }
1322
1323 void exit() {
1324 auto& self = *this;
1325 if (self.tracing) {
1326 tracing_guard.reset();
1327 if (self.without_host) {
1328 self.tracing->postprocess_trace_result();
1329 self.inpmark_to_id = self.tracing->inpmark_to_id;
1330 self.outmark_to_id = self.tracing->outmark_to_id;
1331 }
1332 self.trace_result = self.tracing->get_result();
1333 if (self.without_host) {
1334 for (auto&& var : self.trace_result->vars) {
1335 var.shape_required = false;
1336 var.value_required = false;
1337 if (var.data_required && var.out_marker.empty() &&
1338 remove_unused_data_required)
1339 var.data_required = false;
1340 if (var.inp_marker.empty() &&
1341 var.kind == TraceResult::VarInfo::Kind::External) {
1342 if (var.bound_data) {
1343 var.kind = TraceResult::VarInfo::Kind::Constant;
1344 } else if (self.check_external) {
1345 throw std::runtime_error(
1346 "have some unknown input tensors in trace "
1347 "result, maybe you can set "
1348 "`capture_as_const=True` when trace");
1349 }
1350 }
1351 }
1352 }
1353 self.tracing.reset();
1354 if (self.lazy_eval) {
1355 auto lazy_eval = std::move(self.lazy_eval);
1356 lazy_eval_guard.reset();
1357 lazy_eval->check_exception();
1358 }
1359 } else if (self.compiled) {
1360 if (!without_host)
1361 compiled_guard.reset();
1362 self.compiled->wait();
1363 } else {
1364 mgb_throw(MegBrainError, "invalid state: neither tracing nor compiled");
1365 }
1366 }
1367
1368 VarNodeArray dump(
1369 std::shared_ptr<ComputingGraph> graph,

Callers

nothing calls this directly

Calls 6

get_resultMethod · 0.80
resetMethod · 0.45
emptyMethod · 0.45
check_exceptionMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected