Cannot reshape tensor to desired shape

I am creating a tensor using torch.frombuffer(). The buffer contains image data. When i am trying to reshape the tensor to (H,W,C) I am getting the following error:

Error in processing frame: shape ‘[640, 640, 3]’ is invalid for input of size 1310720.

Could this be due to stride bytes?