Thank You!! this solves the error.
Two points -


Where/how did you get the device mismatch error?


self.n_ is already on device, so why use register_buffer again? There are many other variables in the actual code, how do you decide if a parameter should be registered as a buffer or not? Here, in this code, e.g. I have self.window_ along with self.n_; why not register it as buffer as well?