I"m not sure what input share you are using, but based on your code comments I just tried this and it works:
x = torch.randn(512, 32, 128)
output = model(x)

Could you post your input shape which is causing the error?