Skip to content

Commit

Permalink
fix backward compatibility of math prod
Browse files Browse the repository at this point in the history
  • Loading branch information
miaotianyi committed Jul 2, 2021
1 parent e02336d commit 87456d8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions torchimage/pooling/operator.py
@@ -1,4 +1,4 @@
from math import prod
import numpy as np
import torch
from torch.nn import functional as F

Expand Down Expand Up @@ -35,7 +35,7 @@ def any_conv_1d(x: torch.Tensor, w: torch.Tensor, *, dim: int, stride: int, dila
w = w.view(1, 1, -1) # out_channels, in_channels/groups, input kernel width
x = F.conv1d(x, w, bias=None, stride=stride, padding=0, dilation=dilation, groups=1)
else:
x = x.view(prod(x.shape[:dim]), 1, x.shape[dim], -1)
x = x.view(np.prod(x.shape[:dim]), 1, x.shape[dim], -1)
w = w.view(1, 1, -1, 1) # out_channels, in_channels/groups, input kernel height, input kernel width
x = F.conv2d(x, w, bias=None, stride=(stride, 1), padding=0, dilation=(dilation, 1), groups=1)

Expand Down

0 comments on commit 87456d8

Please sign in to comment.