dynamic-network-architectures icon indicating copy to clipboard operation
dynamic-network-architectures copied to clipboard

Replace torch.linspace with np.linspace

Open fepegar opened this issue 5 months ago • 5 comments

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)

fepegar avatar Aug 06 '25 15:08 fepegar

FYI @TaWald @FabianIsensee

fepegar avatar Aug 06 '25 15:08 fepegar

Is this change welcome? Otherwise I'll start working from a fork.

fepegar avatar Aug 26 '25 12:08 fepegar

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

TaWald avatar Aug 27 '25 09:08 TaWald

Thanks, @TaWald.

fepegar avatar Aug 30 '25 22:08 fepegar

Is it possible to review, merge and release? I'm happy to help with maintenance if needed.

fepegar avatar Oct 09 '25 15:10 fepegar