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

Function throughput

main_simmim_ft.py:277–293  ·  view source on GitHub ↗
(data_loader, model, logger)

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected