Compare commits
2
Commits
4029a0b27e
...
7281d91fd6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7281d91fd6 | ||
|
|
4645e48a2c |
No files matched your search
@@ -57,7 +57,7 @@ class PeriodicBlockStepper:
|
||||
self._status = "new"
|
||||
self._step_count = 0
|
||||
self._allocations = []
|
||||
self._stream = self._copy = self._step = None
|
||||
self._stream = self._module = self._copy = self._step = None
|
||||
with self.ctx.activate():
|
||||
try:
|
||||
free, _ = cuda.mem_get_info()
|
||||
@@ -179,7 +179,7 @@ class PeriodicBlockStepper:
|
||||
self._stream.synchronize()
|
||||
except Exception as exc:
|
||||
error = exc
|
||||
self._copy = self._step = None
|
||||
self._copy = self._step = self._module = None
|
||||
for pointer in self._allocations:
|
||||
try:
|
||||
pointer.free()
|
||||
|
||||
@@ -114,7 +114,9 @@ class CpuContracts(unittest.TestCase):
|
||||
backend._lock = RLock()
|
||||
backend._status = "ready"
|
||||
backend._stream = Mock()
|
||||
backend._module = Mock()
|
||||
backend._copy = backend._step = Mock()
|
||||
backend._dst, backend._src = Mock(), Mock()
|
||||
backend._block, backend._grid, backend._copy_grid = (32, 1, 1), (1, 1, 1), (1, 1)
|
||||
backend._allocations = [Mock(), Mock()]
|
||||
backend._current, backend._spare = backend._allocations
|
||||
@@ -154,7 +156,7 @@ class CpuContracts(unittest.TestCase):
|
||||
|
||||
def test_activation_failure_retains_resources_for_retry(self):
|
||||
backend = self.fake_backend()
|
||||
allocations, stream = backend._allocations[:], backend._stream
|
||||
allocations, stream, module = backend._allocations[:], backend._stream, backend._module
|
||||
unavailable = MagicMock()
|
||||
unavailable.__enter__.side_effect = RuntimeError("activation failed")
|
||||
backend.ctx.activate = Mock(side_effect=[unavailable, nullcontext()])
|
||||
@@ -163,8 +165,12 @@ class CpuContracts(unittest.TestCase):
|
||||
self.assertEqual(backend._status, "failed")
|
||||
self.assertEqual(backend._allocations, allocations)
|
||||
self.assertIs(backend._stream, stream)
|
||||
self.assertIs(backend._module, module)
|
||||
backend.close()
|
||||
self.assertEqual(backend._status, "closed")
|
||||
self.assertIsNone(backend._module)
|
||||
self.assertIsNone(backend._copy)
|
||||
self.assertIsNone(backend._step)
|
||||
for allocation in allocations:
|
||||
allocation.free.assert_called_once()
|
||||
|
||||
|
||||
Reference in new issue
Block a user