We should allow the user to use memref.collapse_shape, memref.expand_shape, tensor.collapse_shape, tensor.expand_shape.
We should also make more specific operations squeeze and unsqueeze which work like they do in numpy and can be used to add/remove dimensions of size 1.
The syntax and logic for collapse_shape and expand_shape might be non-trivial, since you have to deal with static vs dynamic dimensions.