def add_worker_LPU(config, i, j, retina, manager): gexf_filename = config['Retina']['gexf_file'] suffix = config['General']['file_suffix'] dt = config['General']['dt'] debug = config['Retina']['debug'] time_sync = config['Retina']['time_sync'] eye_num = config['General']['eye_num'] worker_num = config['Retina']['worker_num'] gexf_file = '{}{}_{}{}.gexf.gz'.format(gexf_filename, i, j, suffix) G = retina.get_worker_graph(j + 1, worker_num) G = nx.convert_node_labels_to_integers(G) nx.write_gexf(G, gexf_file) worker_dev = j + i * worker_num + eye_num print('Device worker number {}'.format(worker_dev)) n_dict_ret, s_dict_ret = LPU.lpu_parser(gexf_file) worker_id = get_worker_id(worker_dev) modules = [] manager.add(LPU, worker_id, dt, n_dict_ret, s_dict_ret, input_file=None, output_file=None, device=worker_dev, debug=debug, time_sync=time_sync, modules=modules, input_generator=None)
def add_retina_LPU(config, i, retina, manager, generator): ''' This method adds Retina LPU and its parameters to the manager so that it can be initialized later. Depending on configuration input can either be created in advance and read from file or generated during simulation by a generator object. -- config: configuration dictionary like object i: identifier of eye in case more than one is used retina: retina array object required for the generation of graph. manager: manager object to which LPU will be added generator: generator object or None ''' dt = config['General']['dt'] debug = config['Retina']['debug'] time_sync = config['Retina']['time_sync'] input_filename = config['Retina']['input_file'] output_filename = config['Retina']['output_file'] gexf_filename = config['Retina']['gexf_file'] suffix = config['General']['file_suffix'] if generator is None: input_file = '{}{}{}.h5'.format(input_filename, i, suffix) else: input_file = None output_file = '{}{}{}.h5'.format(output_filename, i, suffix) gexf_file = '{}{}{}.gexf.gz'.format(gexf_filename, i, suffix) # retina also allows a subset of its graph to be taken # in case it is needed later to split the retina model to more # GPUs G = retina.get_worker_nomaster_graph() nx.write_gexf(G, gexf_file) n_dict_ret, s_dict_ret = rLPU.lpu_parser(gexf_file) retina_id = get_retina_id(i) modules = [] manager.add(rLPU, retina_id, dt, n_dict_ret, s_dict_ret, input_file=input_file, output_file=output_file, device=2*i, debug=debug, time_sync=time_sync, modules=modules, input_generator=generator)
def add_LPU(config, manager): config_photor = config['Photoreceptor'] gexf_file = config_photor['gexf_file'] input_file = config_photor['input_file'] output_file = config_photor['output_file'] generate_gexf(config_photor, gexf_file) n_dict_ph, s_dict_ph = LPU.lpu_parser(gexf_file) LPU_id = 'photoreceptor' debug = config_photor['debug'] dt = config['General']['dt'] modules = ['retina.neurons.photoreceptor'] manager.add(LPU, LPU_id, dt, n_dict_ph, s_dict_ph, input_file=input_file, output_file=output_file, device=0, debug=debug, time_sync=False, modules=modules)
def add_master_LPU(config, i, retina, manager, generator): dt = config['General']['dt'] debug = config['Retina']['debug'] time_sync = config['Retina']['time_sync'] input_filename = config['Retina']['input_file'] output_filename = config['Retina']['output_file'] gexf_filename = config['Retina']['gexf_file'] suffix = config['General']['file_suffix'] if generator is None: input_file = '{}{}{}.h5'.format(input_filename, i, suffix) else: input_file = None output_file = '{}{}{}.h5'.format(output_filename, i, suffix) gexf_file = '{}{}{}.gexf.gz'.format(gexf_filename, i, suffix) G = retina.get_master_graph() nx.write_gexf(G, gexf_file) n_dict_ret, s_dict_ret = LPU.lpu_parser(gexf_file) master_id = get_master_id(i) modules = [] manager.add(LPU, master_id, dt, n_dict_ret, s_dict_ret, input_file=input_file, output_file=output_file, device=i, debug=debug, time_sync=time_sync, modules=modules, input_generator=generator)