Skip to content

adapt_input_conv: add type hints #2441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion timm/models/_manipulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import torch
import torch.utils.checkpoint
from torch import nn as nn
from torch import Tensor

from timm.layers import use_reentrant_ckpt

Expand Down Expand Up @@ -284,7 +285,7 @@ def forward(_x):
return x


def adapt_input_conv(in_chans, conv_weight):
def adapt_input_conv(in_chans: int, conv_weight: Tensor) -> Tensor:
conv_type = conv_weight.dtype
conv_weight = conv_weight.float() # Some weights are in torch.half, ensure it's float for sum on CPU
O, I, J, K = conv_weight.shape
Expand Down