Skip to content

Commit bf28032

Browse files
committed
Init
1 parent 96479e6 commit bf28032

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

bindsnet/utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,18 @@ def reshape_local_connection_2d_weights(
276276
]
277277

278278
return square
279+
280+
281+
class FakeStream:
282+
def __enter__(self):
283+
pass
284+
285+
def __exit__(self, *_):
286+
pass
287+
288+
289+
def stream(device=None):
290+
try:
291+
return torch.cuda.stream(torch.cuda.Stream(device=device))
292+
except RuntimeError as _:
293+
return FakeStream()

mutability.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import torch
2+
from torch.multiprocessing.spawn import spawn
3+
4+
5+
def layer_update(z, self):
6+
self.x += 1
7+
8+
9+
class Network:
10+
def __init__(self):
11+
self.x = torch.tensor([1, 1, 1], device='cpu')
12+
13+
def run(self):
14+
spawn(layer_update, args=(self,))
15+
print(self.x)
16+
17+
if __name__ == '__main__':
18+
Network().run()
19+

0 commit comments

Comments
 (0)