MCPcopy Create free account
hub / github.com/BindsNET/bindsnet / create_spikes_tensor

Function create_spikes_tensor

examples/benchmark/sparse_vs_dense_tensors.py:17–28  ·  view source on GitHub ↗
(percent_of_true_values, sparse, return_memory_usage=True)

Source from the content-addressed store, hash-verified

15
16
17def create_spikes_tensor(percent_of_true_values, sparse, return_memory_usage=True):
18 spikes_tensor = torch.bernoulli(
19 torch.full(shape, percent_of_true_values, device=device)
20 ).bool()
21 if sparse:
22 spikes_tensor = spikes_tensor.to_sparse()
23
24 if return_memory_usage:
25 torch.cuda.reset_peak_memory_stats(device=device)
26 return round(torch.cuda.max_memory_allocated(device=device) / (1024**2))
27 else:
28 return spikes_tensor
29
30
31def memory_benchmark():

Callers 2

memory_benchmarkFunction · 0.85
runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected