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

Method test_network_by_share

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

Source from the content-addressed store, hash-verified

251 self.do_forward(network)
252
253 def test_network_by_share(self):
254 network = LiteNetwork()
255 network.load(self.model_path)
256
257 input_name = network.get_input_name(0)
258 input_tensor = network.get_io_tensor(input_name)
259 output_name = network.get_output_name(0)
260 output_tensor = network.get_io_tensor(output_name)
261
262 assert input_tensor.device_type == LiteDeviceType.LITE_CPU
263 layout = LiteLayout(self.input_data.shape, self.input_data.dtype)
264 tensor_tmp = LiteTensor(layout=layout)
265 tensor_tmp.set_data_by_share(self.input_data)
266 input_tensor.share_memory_with(tensor_tmp)
267
268 for i in range(3):
269 network.forward()
270 network.wait()
271
272 output_data = output_tensor.to_numpy()
273 self.check_correct(output_data)
274
275 def test_network_share_weights(self):
276 option = LiteOptions()

Callers

nothing calls this directly

Calls 13

loadMethod · 0.95
get_input_nameMethod · 0.95
get_io_tensorMethod · 0.95
get_output_nameMethod · 0.95
set_data_by_shareMethod · 0.95
forwardMethod · 0.95
waitMethod · 0.95
LiteNetworkClass · 0.85
LiteTensorClass · 0.85
LiteLayoutClass · 0.50
share_memory_withMethod · 0.45
to_numpyMethod · 0.45

Tested by

no test coverage detected