MCPcopy
hub / github.com/microsoft/Swin-Transformer / throughput

Function throughput

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

Source from the content-addressed store, hash-verified

281
282@torch.no_grad()
283def throughput(data_loader, model, logger):
284 model.eval()
285
286 for idx, (images, _) in enumerate(data_loader):
287 images = images.cuda(non_blocking=True)
288 batch_size = images.shape[0]
289 for i in range(50):
290 model(images)
291 torch.cuda.synchronize()
292 logger.info(f"throughput averaged with 30 times")
293 tic1 = time.time()
294 for i in range(30):
295 model(images)
296 torch.cuda.synchronize()
297 tic2 = time.time()
298 logger.info(f"batch_size {batch_size} throughput {30 * batch_size / (tic2 - tic1)}")
299 return
300
301
302if __name__ == '__main__':

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected