This PR fixes the unification of shapes. Originally,
x = ShapeElem(1)
y = ShapeElem(None)
unify_shape((x,), (y,))
would have changed y into (ShapeElem(1),). However, this will result in the following inference.
x = torch.Tensor(4, 1, dtype=torch.float)
for i in range(5):
x = x.expand(4, x.size(1) + 1)
# x : torch.Tensor(float32, (4, 1)) <-- shape should be (4, None)
This PR a) fixes this behavior, and b) adds implementation for applying shape annotation for tensors, which will be broken by a).
This PR fixes the unification of shapes. Originally,
would have changed y into
(ShapeElem(1),)
. However, this will result in the following inference.This PR a) fixes this behavior, and b) adds implementation for applying shape annotation for tensors, which will be broken by a).