MCPcopy Create free account
hub / github.com/LeapLabTHU/DAT / throughput

Function throughput

main.py:305–321  ·  view source on GitHub ↗
(data_loader, model, logger)

Source from the content-addressed store, hash-verified

303
304@torch.no_grad()
305def throughput(data_loader, model, logger):
306 model.eval()
307
308 for _, (images, _) in enumerate(data_loader):
309 images = images.cuda(non_blocking=True)
310 batch_size = images.shape[0]
311 for i in range(50):
312 model(images)
313 torch.cuda.synchronize()
314 logger.info(f"throughput averaged with 30 times")
315 tic1 = time.time()
316 for i in range(30):
317 model(images)
318 torch.cuda.synchronize()
319 tic2 = time.time()
320 logger.info(f"batch_size {batch_size} throughput {30 * batch_size / (tic2 - tic1)}")
321 return
322
323if __name__ == '__main__':
324 main()

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected