Skip to content

Commit 58f7a4b

Browse files
committed
2.9 only
1 parent 7d198bd commit 58f7a4b

File tree

2 files changed

+21
-35
lines changed

2 files changed

+21
-35
lines changed

tools/pnnx/tests/onnx/test_F_interpolate.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,15 @@ def forward(self, x, y, z, w):
4040

4141
w = F.interpolate(w, scale_factor=(2.976744,2.976744), mode='nearest', recompute_scale_factor=False)
4242

43-
if version.parse(torch.__version__) >= version.parse('1.11'):
44-
x = F.interpolate(x, size=12, mode='nearest-exact') + 2
45-
x = F.interpolate(x, scale_factor=(3), mode='nearest-exact')
46-
y = F.interpolate(y, size=(11,12), mode='nearest-exact') + 3
47-
y = F.interpolate(y, scale_factor=(3,2), mode='nearest-exact')
48-
z = F.interpolate(z, size=(11,12,13), mode='nearest-exact') + 4
49-
z = F.interpolate(z, scale_factor=(3,1,2), mode='nearest-exact')
50-
51-
return x0, x1, x2, y0, y1, y2, y3, z0, z1, z2, z3, w, x, y, z
52-
else:
53-
return x0, x1, x2, y0, y1, y2, y3, z0, z1, z2, z3, w
43+
return x0, x1, x2, y0, y1, y2, y3, z0, z1, z2, z3, w
5444
else:
5545
x = F.interpolate(x, size=16)
5646
x = F.interpolate(x, scale_factor=2, mode='nearest')
5747
x = F.interpolate(x, size=(20), mode='nearest')
5848
x = F.interpolate(x, scale_factor=(4), mode='nearest')
59-
x = F.interpolate(x, size=12, mode='nearest-exact') + 2
60-
x = F.interpolate(x, scale_factor=(3), mode='nearest-exact')
49+
if version.parse(torch.__version__) >= version.parse('2.9'):
50+
x = F.interpolate(x, size=12, mode='nearest-exact') + 2
51+
x = F.interpolate(x, scale_factor=(3), mode='nearest-exact')
6152
x = F.interpolate(x, size=16, mode='linear')
6253
x = F.interpolate(x, scale_factor=2, mode='linear')
6354
x = F.interpolate(x, size=(24), mode='linear', align_corners=True)
@@ -73,8 +64,9 @@ def forward(self, x, y, z, w):
7364
y = F.interpolate(y, scale_factor=(4,4), mode='nearest')
7465
y = F.interpolate(y, size=(16,24), mode='nearest')
7566
y = F.interpolate(y, scale_factor=(2,3), mode='nearest')
76-
y = F.interpolate(y, size=(11,12), mode='nearest-exact') + 3
77-
y = F.interpolate(y, scale_factor=(3,2), mode='nearest-exact')
67+
if version.parse(torch.__version__) >= version.parse('2.9'):
68+
y = F.interpolate(y, size=(11,12), mode='nearest-exact') + 3
69+
y = F.interpolate(y, scale_factor=(3,2), mode='nearest-exact')
7870
y = F.interpolate(y, size=16, mode='bilinear')
7971
y = F.interpolate(y, scale_factor=2, mode='bilinear')
8072
y = F.interpolate(y, size=(20,20), mode='bilinear', align_corners=False)
@@ -101,8 +93,9 @@ def forward(self, x, y, z, w):
10193
z = F.interpolate(z, scale_factor=(4,4,4), mode='nearest')
10294
z = F.interpolate(z, size=(16,24,20), mode='nearest')
10395
z = F.interpolate(z, scale_factor=(2,3,4), mode='nearest')
104-
z = F.interpolate(z, size=(11,12,13), mode='nearest-exact') + 4
105-
z = F.interpolate(z, scale_factor=(3,1,2), mode='nearest-exact')
96+
if version.parse(torch.__version__) >= version.parse('2.9'):
97+
z = F.interpolate(z, size=(11,12,13), mode='nearest-exact') + 4
98+
z = F.interpolate(z, scale_factor=(3,1,2), mode='nearest-exact')
10699
z = F.interpolate(z, size=16, mode='trilinear')
107100
z = F.interpolate(z, scale_factor=2, mode='trilinear')
108101
z = F.interpolate(z, size=(20,20,20), mode='trilinear', align_corners=False)

tools/pnnx/tests/onnx/test_nn_Upsample.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def __init__(self):
8181

8282
self.up_w = nn.Upsample(scale_factor=(1.499,1.499), mode='nearest')
8383

84-
if version.parse(torch.__version__) >= version.parse('1.11'):
84+
if version.parse(torch.__version__) >= version.parse('2.9'):
8585
self.up_1d_0_4 = nn.Upsample(size=12, mode='nearest-exact')
8686
self.up_1d_0_5 = nn.Upsample(scale_factor=(3), mode='nearest-exact')
8787
self.up_2d_0_6 = nn.Upsample(size=(11,12), mode='nearest-exact')
@@ -118,23 +118,14 @@ def forward(self, x, y, z, w):
118118

119119
w = self.up_w(w)
120120

121-
if version.parse(torch.__version__) >= version.parse('1.11'):
122-
x = self.up_1d_0_4(x) + 2
123-
x = self.up_1d_0_5(x)
124-
y = self.up_2d_0_6(y) + 3
125-
y = self.up_2d_0_7(y)
126-
z = self.up_3d_0_6(z) + 4
127-
z = self.up_3d_0_7(z)
128-
129-
return x0, x1, x2, y0, y1, y2, y3, z0, z1, z2, z3, w, x, y, z
130-
else:
131-
return x0, x1, x2, y0, y1, y2, y3, z0, z1, z2, z3, w
121+
return x0, x1, x2, y0, y1, y2, y3, z0, z1, z2, z3, w
132122
else:
133123
x = self.up_1d_0_0(x)
134124
x = self.up_1d_0_1(x)
135125
x = self.up_1d_0_2(x)
136-
x = self.up_1d_0_3(x)
137-
x = self.up_1d_0_4(x) + 2
126+
if version.parse(torch.__version__) >= version.parse('2.9'):
127+
x = self.up_1d_0_3(x)
128+
x = self.up_1d_0_4(x) + 2
138129
x = self.up_1d_0_5(x)
139130
x = self.up_1d_1_0(x)
140131
x = self.up_1d_1_1(x)
@@ -146,8 +137,9 @@ def forward(self, x, y, z, w):
146137
y = self.up_2d_0_2(y)
147138
y = self.up_2d_0_3(y)
148139
y = self.up_2d_0_4(y)
149-
y = self.up_2d_0_5(y)
150-
y = self.up_2d_0_6(y) + 3
140+
if version.parse(torch.__version__) >= version.parse('2.9'):
141+
y = self.up_2d_0_5(y)
142+
y = self.up_2d_0_6(y) + 3
151143
y = self.up_2d_0_7(y)
152144
y = self.up_2d_1_0(y)
153145
y = self.up_2d_1_1(y)
@@ -167,8 +159,9 @@ def forward(self, x, y, z, w):
167159
z = self.up_3d_0_2(z)
168160
z = self.up_3d_0_3(z)
169161
z = self.up_3d_0_4(z)
170-
z = self.up_3d_0_5(z)
171-
z = self.up_3d_0_6(z) + 4
162+
if version.parse(torch.__version__) >= version.parse('2.9'):
163+
z = self.up_3d_0_5(z)
164+
z = self.up_3d_0_6(z) + 4
172165
z = self.up_3d_0_7(z)
173166
z = self.up_3d_1_0(z)
174167
z = self.up_3d_1_1(z)

0 commit comments

Comments
 (0)