add shape to pass-throughs
diff --git a/test/test_autograd.py b/test/test_autograd.py
index efb6f6d..8a11d41 100644
--- a/test/test_autograd.py
+++ b/test/test_autograd.py
@@ -1075,6 +1075,12 @@
o = (b + a).sum()
o.backward()
+ def test_shape(self):
+ x = Variable(torch.randn(3, 4))
+ self.assertEqual(2, len(x.shape))
+ self.assertEqual(x.shape[0], 3)
+ self.assertEqual(x.shape[1], 4)
+
def test_return_leaf(self):
class Identity(Function):
diff --git a/torch/autograd/variable.py b/torch/autograd/variable.py
index 658839e..60e10cc 100644
--- a/torch/autograd/variable.py
+++ b/torch/autograd/variable.py
@@ -57,6 +57,7 @@
'dim',
'get_device',
'is_cuda',
+ 'shape'
}
def __getattr__(self, name):