pytorch-image-models
pytorch-image-models copied to clipboard
Use in-place operations for EMA
Hi,
I noticed that the EMA used here is pretty slow, since it does not use in-place operations. Using in-place ops results in a ~50% faster EMA, however, it does not work with type-promotion.
One workaround is to check whether a tensor from the model is floating point or not, with Tensor.is_floating_point()
.
I don't think there is any point in doing EMA on int tensors such as num_batches_tracked
in BN.
Cheers!