Why does torch.linalg.cross no longer support broadcasting like e.g.
I am using expressions like:
x = torch.linalg.cross(m, p)
where m
is a vector field with shape (nx, ny, nz, 3) and p
is a material parameter.
p
may either be of the same shape as m
or of shape (3) if the material is constant.
Both versions worked with a previous version of pytorch, but this behaviour was changed in ‘Strenghten preconditions of linalg.cross (#83798)’. Now the second version raises the following exception:
RuntimeError: linalg.cross: inputs must have the same number of dimensions.
I would now need to check the dimension of p
first and reshape / expand accordingly.
Is there a more elegant way?
best wishes
Florian