Skip to content

Commit 58fbc3f

Browse files
committed
add tests for Sub
1 parent 38d49ad commit 58fbc3f

10 files changed

+69
-0
lines changed
224 Bytes
Binary file not shown.
152 Bytes
Binary file not shown.
224 Bytes
Binary file not shown.
224 Bytes
Binary file not shown.
152 Bytes
Binary file not shown.
224 Bytes
Binary file not shown.

testdata/dnn/onnx/generate_onnx_models.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,3 +1523,38 @@ def save_data_and_paddle_model(model, name, input_data):
15231523
input_shape = [1, 2, 3, 4]
15241524
x = paddle.rand(input_shape, dtype="float32")
15251525
save_data_and_paddle_model(Resize_HumanSeg(), "resize_humanseg", x)
1526+
1527+
class SubFromConstBroadcast(nn.Module):
1528+
def __init__(self, *args, **kwargs):
1529+
super(SubFromConstBroadcast, self).__init__()
1530+
self.const = torch.randn(1, 3, dtype=torch.float32)
1531+
1532+
def forward(self, x):
1533+
return self.const - x
1534+
1535+
model = SubFromConstBroadcast()
1536+
input_ = Variable(torch.randn(2, 3, dtype=torch.float32))
1537+
save_data_and_model("sub_from_const_broadcast", input_, model)
1538+
1539+
class SubFromConstEltWise(nn.Module):
1540+
def __init__(self, *args, **kwargs):
1541+
super(SubFromConstEltWise, self).__init__()
1542+
self.const = torch.randn(1, 2, 3, 4, dtype=torch.float32)
1543+
1544+
def forward(self, x):
1545+
return self.const - x
1546+
1547+
model = SubFromConstEltWise()
1548+
input_ = Variable(torch.randn(1, 2, 3, 4, dtype=torch.float32))
1549+
save_data_and_model("sub_from_const_eltwise", input_, model)
1550+
1551+
class SubFromConst1(nn.Module):
1552+
def __init__(self, *args, **kwargs):
1553+
super(SubFromConst1, self).__init__()
1554+
1555+
def forward(self, x):
1556+
return 1 - x
1557+
1558+
model = SubFromConst1()
1559+
input_ = Variable(torch.randn(1, 2, 3, 4, dtype=torch.float32))
1560+
save_data_and_model("sub_from_const1", input_, model)
171 Bytes
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
pytorch1.9:�
2+
;1
3+
Constant_0"Constant*
4+
value*J W@�@-�oy��
5+

6+
1
7+
02Sub_1"Subtorch-jit-exportZ
8+
0
9+

10+

11+
b
12+
2
13+

14+

15+
B

testdata/dnn/onnx/models/sub_from_const_eltwise.onnx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
pytorch1.9:�
2+
�1
3+
Constant_0"Constant*x
4+
value*lJ`�)h����Vg>]D���t8�����/�0?F��ko]��3���uI?�X�=.&����,��[W�����>a��Z]��ǒ�?�2V־�݂��
5+

6+
1
7+
02Sub_1"Subtorch-jit-exportZ
8+
0
9+

10+

11+

12+

13+
b
14+
2
15+

16+

17+

18+

19+
B

0 commit comments

Comments
 (0)