dynamic-network-architectures
dynamic-network-architectures copied to clipboard
Replace torch.linspace with np.linspace
This allows to initialize models in the "meta" device, which is >10× faster, if desired.
import torch
from dynamic_network_architectures.architectures.primus import Primus
def initialize_primus():
return Primus(1, 864, 3 * (8,), 2, input_shape=3 * (160,))
%%timeit
initialize_primus()
2.45 s ± 38 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
%%timeit
with torch.device("meta"):
initialize_primus()
195 ms ± 871 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)
FYI @TaWald @FabianIsensee
Is this change welcome? Otherwise I'll start working from a fork.
Fabi is currently away for the next two weeks and AFAIK he is the only person who has permissions to merge these changes into the official MIC-DKFZ repo. Once he's back I can ping him to merge this
Thanks, @TaWald.
Is it possible to review, merge and release? I'm happy to help with maintenance if needed.