MCPcopy Create free account
hub / github.com/DragonisCV/RAM / preload

Method preload

ram/data/utils/prefetch_dataloader.py:105–115  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

103 self.preload()
104
105 def preload(self):
106 try:
107 self.batch = next(self.loader) # self.batch is a dict
108 except StopIteration:
109 self.batch = None
110 return None
111 # put tensors to gpu
112 with torch.cuda.stream(self.stream):
113 for k, v in self.batch.items():
114 if torch.is_tensor(v):
115 self.batch[k] = self.batch[k].to(device=self.device, non_blocking=True)
116
117 def next(self):
118 torch.cuda.current_stream().wait_stream(self.stream)

Callers 3

__init__Method · 0.95
nextMethod · 0.95
resetMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected