def queue_put(): x = torch.DoubleStorage(4) q = mp.Queue() self.assertFalse(lc.has_shm_files()) q.put(x) time.sleep(0.05) # queue serializes asynchronously self.assertTrue(lc.has_shm_files(wait=False)) q.get()
def add(self, criterion, weight=1): self.criterions.append(criterion) new_weights = torch.DoubleStorage(len(self.criterions)) for i, v in enumerate(self.weights): new_weights[i] = v new_weights[len(self.criterions) - 1] = weight self.weights = new_weights return self
def test_fs(self): with fs_sharing(), leak_checker(self) as lc: x = torch.DoubleStorage(4) q = mp.Queue() self.assertFalse(lc.has_shm_files()) q.put(x) self.assertTrue(lc.has_shm_files(wait=False)) q.get() del x del q # We have to clean up fds for leak_checker
def reset(self): self.scores = torch.DoubleTensor(torch.DoubleStorage()).numpy() self.targets = torch.LongTensor(torch.LongStorage()).numpy()
def reset(self): """Reset stored scores and targets.""" self.scores = torch.DoubleTensor(torch.DoubleStorage()).numpy() self.targets = torch.LongTensor(torch.LongStorage()).numpy()
def __init__(self, ): super(MultiCriterion, self).__init__() self.criterions = [] self.weights = torch.DoubleStorage()
def reset(self): """Resets the scores and targets buffers.""" self.scores = torch.DoubleTensor(torch.DoubleStorage()).numpy() self.targets = torch.LongTensor(torch.LongStorage()).numpy() self.cached = None