it's crazy how much faster pytorch is than numpy
MODIFY
test/test_conv_speed.py
test/test_conv_speed.py
@@ -96,6 +96,8 @@ class TestConvSpeed(unittest.TestCase):
# get torch baseline
@classmethod
def setUpClass(self):
+ torch.backends.mkldnn.enabled = False
+
conv = 3
inter_chan, out_chan = 32, 64
c1 = torch.randn(inter_chan,1,conv,conv, requires_grad=True)
@@ -106,6 +108,7 @@ class TestConvSpeed(unittest.TestCase):
mp = torch.nn.MaxPool2d((2,2))
lsm = torch.nn.LogSoftmax(dim=1)
+ with torch.autograd.profiler.profile(record_shapes=True) as tprof:
cnt = 5
fpt, bpt = 0.0, 0.0
for i in range(1+cnt):
@@ -131,6 +134,8 @@ class TestConvSpeed(unittest.TestCase):
print("forward pass: %.3f ms" % self.fpt_baseline)
print("backward pass: %.3f ms" % self.bpt_baseline)
+ print(tprof.key_averages().table(sort_by="cpu_time", row_limit=20))
+
if __name__ == '__main__':
unittest.main()

it's crazy how much faster pytorch is than numpy