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

Function test_gather_other

src/core/test/mem_alloc.cpp:573–591  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

571}
572
573void test_gather_other(CompNode cn0, CompNode cn1) {
574 if (cn0.get_mem_status_bytes().second > cn1.get_mem_status_bytes().second) {
575 std::swap(cn0, cn1);
576 }
577 size_t elems = cn0.get_mem_status_bytes().second * 2 / 5 / sizeof(dt_int32);
578 auto xv = std::make_shared<DeviceTensorND>(cn0, TensorShape{elems}, dtype::Int32());
579 auto graph = ComputingGraph::make();
580 auto x = opr::SharedDeviceTensor::make(*graph, xv), x1 = x + 1,
581 x2 = opr::MarkDynamicVar::make(x), y = opr::Copy::make(x1, {cn1});
582 // x1 must be released (which requires y to finish) before x2 succeeds
583
584 set_priority(x1, -10);
585 set_priority(y, -10);
586 graph->options().var_sanity_check_first_run = false;
587 graph->options().async_exec_level = 0;
588 auto func = graph->compile({{x2, {}}, {y, {}}});
589 opr::Sleep::sleep(cn1, 0.7);
590 func->execute();
591}
592} // namespace
593
594#if MGB_CUDA

Callers 1

TESTFunction · 0.85

Calls 6

swapFunction · 0.85
set_priorityFunction · 0.85
makeFunction · 0.70
get_mem_status_bytesMethod · 0.45
compileMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected