Skip to content

Commit 240a3dd

Browse files
committed
Add unit test for dynamic_flops with multiple outputs
1 parent 9f0839e commit 240a3dd

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

python/paddle/tests/test_model.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -733,30 +733,14 @@ def customize_dropout(m, x, y):
733733
print_detail=True)
734734

735735
def test_dynamic_flops_with_multiple_outputs(self):
736-
class MyMnist(paddle.nn.Layer):
737-
def __init__(self):
738-
super(MyMnist, self).__init__()
739-
self.flatten = paddle.nn.Flatten()
740-
self.linear_1 = paddle.nn.Linear(784, 512)
741-
self.linear_2 = paddle.nn.Linear(512, 10)
742-
self.relu = paddle.nn.ReLU()
743-
self.dropout = paddle.nn.Dropout(0.2)
744-
745-
def forward(self, inputs):
746-
y = self.flatten(inputs)
747-
y = self.linear_1(y)
748-
y1 = self.relu(y)
749-
y2 = self.dropout(y1)
750-
y2 = self.linear_2(y2)
751-
return y1, y2
752-
753-
net = MyMnist()
736+
net = paddle.nn.MaxPool2D(
737+
kernel_size=2, stride=2, padding=0, return_mask=True)
754738

755739
def customize_dropout(m, x, y):
756740
m.total_ops += 0
757741

758742
paddle.flops(
759-
net, [1, 1, 28, 28],
743+
net, [1, 2, 32, 32],
760744
custom_ops={paddle.nn.Dropout: customize_dropout},
761745
print_detail=True)
762746

0 commit comments

Comments
 (0)