@albanD
I have made the changes to code (see above) and passed the variable W to forward function directly instead of init(). Now both x and W are on cuda device, but still I am getting the same error.