RuntimeError: Expected tensor to have size 256 at dimension 1, but got size 3 for argument #2 'batch2' (while checking arguments for bmm)

When I execute the program mapping_mat = torch.matmul(frame, scaling_mat),there is a RuntimeError: Expected tensor to have size 256 at dimension 1, but got size 3 for argument #2 ‘batch2’ (while checking arguments for bmm).
frame is torch.Size([1, 3, 256, 256])
scaling_mat is torch.Size([1, 3, 3])

scaling_mat should be of size (1, 256, 3) for matmul to work.

Check the pytorch doc for input dimension instructions.