Input broadcasting for Add operator
For the ViT model, some "Add" operators require broadcasting of inputs. For input tensors A and B, these are the shapes cases for the ViT model:
A.shape == B.shape # Only case currently supported
A.shape == [1] or B.shape == [1] # Broadcasting is done on all dimensions
A.shape == [B.shape[-1]] or B.shape == [A.shape[-1]] # Broadcasting is done on all dimensions except the last one
A.shape == [B.shape[:-1], 1] or B.shape == [A.shape[:-1], 1] # Broadcasting is done on the last dimension
There are other Broadcasting cases supported by onnx and numpy but they are not needed for ViT.