namedtensor
namedtensor copied to clipboard
Addition isn't commutative (if dimensions are ordered)
It feels a little weird, but I guess it is fine if the dimensions aren't supposed to be ordered
y = ntorch.randn(1, 1, 1, 1, names=['n', 'c', 'h', 'w'])
x = ntorch.randn(1, 1, names=['h', 'c'])
(x + y).shape
OrderedDict([('n', 1), ('w', 1), ('h', 1), ('c', 1)])
(y + x).shape
OrderedDict([('n', 1), ('c', 1), ('h', 1), ('w', 1)])
Yes, we've been debating this point. The current aggressive proposal is to change shape to not be an ordereddict at all, and remove the transpose function or have it return a non-named tensor.