def prepare_trajectory(self, trajectory): logger.info('GPU preparing') n_confs = len(trajectory) if self._gpurmsd != None: raise ValueError("messed up call pattern") xyzlist = trajectory['XYZList'] if self.atomindices != None: xyzlist = xyzlist[:, self.atomindices, :] xyzlist = np.array(xyzlist.swapaxes(1,2).swapaxes(0,2), copy=True, order='C') self._gpurmsd = _GPURMSD(xyzlist) self._gpurmsd.set_subset_flag_array(np.ones(n_confs, dtype=np.int32)) self._gpurmsd.center_and_precompute_G() return np.arange(n_confs)
def prepare_trajectory(self, trajectory): """Prepare a trajectory for disance calculation on the GPU. Parameters ---------- trajectory : msmbuilder trajectory The trajectory to send to the GPU Returns ------- prepared_trajectory : np.ndarray Don't worry about what the return value is :) its just input that you should give to GPURMSD.one_to_all(). Notes ----- - the GPU kernels except the xyz coordinates to be layed out as n_atoms x n_dimensions x n_frames, which means we need to first reorder them on the GPU before sending them. - You can only run prepare_trajectory once -- you have to send all the frames to the GPU in one go. """ logger.info('GPU preparing') if self._gpurmsd != None: raise ValueError("messed up call pattern") xyzlist = trajectory['XYZList'] n_confs, n_atoms = xyzlist.shape[0:2] if self.atomindices != None: xyzlist = xyzlist[:, self.atomindices, :] n_atoms = len(self.atomindices) xyzlist = np.array(xyzlist.swapaxes(1, 2).swapaxes(0, 2), copy=True, order='C') self._gpurmsd = _GPURMSD(xyzlist) self._gpurmsd.set_subset_flag_array(np.ones(n_atoms, dtype=np.int32)) self._gpurmsd.center_and_precompute_G() self._n_confs = n_confs return Xrange(self._n_confs)
def prepare_trajectory(self, trajectory): """Prepare a trajectory for disance calculation on the GPU. Parameters ---------- trajectory : msmbuilder trajectory The trajectory to send to the GPU Returns ------- prepared_trajectory : np.ndarray Don't worry about what the return value is :) its just input that you should give to GPURMSD.one_to_all(). Notes ----- - the GPU kernels except the xyz coordinates to be layed out as n_atoms x n_dimensions x n_frames, which means we need to first reorder them on the GPU before sending them. - You can only run prepare_trajectory once -- you have to send all the frames to the GPU in one go. """ logger.info('GPU preparing') if self._gpurmsd != None: raise ValueError("messed up call pattern") xyzlist = trajectory['XYZList'] n_confs, n_atoms = xyzlist.shape[0:2] if self.atomindices != None: xyzlist = xyzlist[:, self.atomindices, :] n_atoms = len(self.atomindices) xyzlist = np.array(xyzlist.swapaxes(1,2).swapaxes(0,2), copy=True, order='C') self._gpurmsd = _GPURMSD(xyzlist) self._gpurmsd.set_subset_flag_array(np.ones(n_atoms, dtype=np.int32)) self._gpurmsd.center_and_precompute_G() self._n_confs = n_confs return Xrange(self._n_confs)