def bind_local_sino(self, task_index=None): if task_index is None: task_index = ThisHost.host().task_index if ThisHost.is_master(): logger.info("On Master node, skip bind local sino.") return else: logger.info( "On Worker node, local data for worker {}.".format(task_index)) worker_sinos = self.load_local_sino(task_index) self.worker_graphs[task_index].init_sino(worker_sinos)
def bind_local_data(self, data_info, task_index=None): if task_index is None: task_index = ThisHost.host().task_index if ThisHost.is_master(): logger.info("On Master node, skip bind local data.") return else: logger.info( "On Worker node, local data for worker {}.".format(task_index)) emap, lors = self.load_local_data(data_info, task_index) self.worker_graphs[task_index].assign_efficiency_map(emap) self.worker_graphs[task_index].assign_lors(lors)
def bind_local_matrix(self, task_index=None): if task_index is None: task_index = ThisHost.host().task_index if ThisHost.is_master(): logger.info("On Master node, skip bind local matrix.") return else: logger.info( "On Worker node, local data for worker {}.".format(task_index)) worker_matrix = self.load_local_matrix(task_index) worker_matrix = sparse.coo_matrix(worker_matrix) self.worker_graphs[task_index].init_matrix(worker_matrix)
def bind_local_data(self): """ bind the static effmap data """ return map_file = self.work_directory + self.image_info.map_file #matrix_file = self.work_directory + self.Inputinfo.sm task_index = ThisHost.host().task_index if ThisHost.is_master(): logger.info("On Master node, skip bind local data.") return else: logger.info( "On Worker node, local data for worker {}.".format(task_index)) emap = self.load_local_effmap(map_file) self.worker_graphs[task_index].init_efficiency_map(emap) self.bind_local_sino() self.bind_local_matrix()
def run_and_save_if_is_master(self, x, path): if ThisHost.is_master(): if isinstance(x, Tensor): x = x.data result = ThisSession.run(x) np.save(path, result)
def run_and_print_if_is_master(self, x): if ThisHost.is_master(): if isinstance(x, Tensor): x = x.data result = ThisSession.run(x) print(result)