MCPcopy Create free account
hub / github.com/SwinTransformer/Transformer-SSL / throughput

Function throughput

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

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected