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

Function throughput

moby_linear.py:317–333  ·  view source on GitHub ↗
(data_loader, model, logger)

Source from the content-addressed store, hash-verified

315
316@torch.no_grad()
317def throughput(data_loader, model, logger):
318 model.eval()
319
320 for idx, (images, _) in enumerate(data_loader):
321 images = images.cuda(non_blocking=True)
322 batch_size = images.shape[0]
323 for i in range(50):
324 model(images)
325 torch.cuda.synchronize()
326 logger.info(f"throughput averaged with 30 times")
327 tic1 = time.time()
328 for i in range(30):
329 model(images)
330 torch.cuda.synchronize()
331 tic2 = time.time()
332 logger.info(f"batch_size {batch_size} throughput {30 * batch_size / (tic2 - tic1)}")
333 return
334
335
336if __name__ == '__main__':

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected