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

Method test_network_async

lite/pylite/test/test_network.py:306–335  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

304 self.do_forward(new_network)
305
306 def test_network_async(self):
307 count = 0
308 finished = False
309
310 def async_callback():
311 nonlocal finished
312 finished = True
313 return 0
314
315 option = LiteOptions()
316 option.var_sanity_check_first_run = 0
317 config = LiteConfig(option=option)
318
319 network = LiteNetwork(config=config)
320 network.load(self.model_path)
321
322 network.async_with_callback(async_callback)
323
324 input_tensor = network.get_io_tensor(network.get_input_name(0))
325 output_tensor = network.get_io_tensor(network.get_output_name(0))
326
327 input_tensor.set_data_by_share(self.input_data)
328 network.forward()
329
330 while not finished:
331 count += 1
332
333 assert count > 0
334 output_data = output_tensor.to_numpy()
335 self.check_correct(output_data)
336
337 def test_network_start_callback(self):
338 network = LiteNetwork()

Callers

nothing calls this directly

Calls 12

loadMethod · 0.95
async_with_callbackMethod · 0.95
get_io_tensorMethod · 0.95
get_input_nameMethod · 0.95
get_output_nameMethod · 0.95
forwardMethod · 0.95
LiteOptionsClass · 0.85
LiteNetworkClass · 0.85
set_data_by_shareMethod · 0.80
LiteConfigClass · 0.50
to_numpyMethod · 0.45
check_correctMethod · 0.45

Tested by

no test coverage detected