fixing #1356

Changed input variables to be shared variables, so that we minimize the number of transfers between GPU and CPU.