MCPcopy Create free account
hub / github.com/UbiquitousLearning/mllm / main

Function main

tests/engine/AsyncModuleTest.cpp:31–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29};
30
31int main() {
32 mllm::initializeContext();
33 {
34 auto net = FooNet("foo_net");
35
36 // Make some fake weights
37 auto params = ParameterFile::create();
38 for (int i = 0; i < 4; ++i) {
39 auto name = "foo_net.linear_" + std::to_string(i);
40 auto w = Tensor::empty({2048, 1024}).setMemType(kParamsNormal).setName(name + ".weight").alloc();
41 auto b = Tensor::empty({2048}).setMemType(kParamsNormal).setName(name + ".bias").alloc();
42 params->push(w.name(), w);
43 params->push(b.name(), b);
44 }
45 net.load(params);
46
47 // Async run.
48 // The net will not run, until mllm::async::wait is called.
49 auto future_0 = mllm::async::fork(net, Tensor::empty({1, 12, 1024, 1024}, kFloat32).alloc());
50 auto future_1 = mllm::async::fork(net, Tensor::empty({1, 12, 1024, 1024}, kFloat32).alloc());
51
52 // Run future_0 and future_1 async.
53 auto [outs_0, outs_1] = mllm::async::wait(future_0, future_1);
54
55 mllm::print(outs_0[0].shape(), outs_0[1].shape(), outs_0[2].shape(), outs_0[3].shape());
56 mllm::print(outs_1[0].shape(), outs_1[1].shape(), outs_1[2].shape(), outs_1[3].shape());
57 }
58 mllm::memoryReport();
59}

Callers

nothing calls this directly

Calls 13

forkFunction · 0.85
printFunction · 0.85
FooNetClass · 0.70
initializeContextFunction · 0.50
emptyFunction · 0.50
waitFunction · 0.50
memoryReportFunction · 0.50
allocMethod · 0.45
setNameMethod · 0.45
pushMethod · 0.45
nameMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected