def test_builder_poptype_errors(): pytest.importorskip("nxsdk") # Test error in build_synapse model = Model() block = LoihiBlock(1) block.compartment.configure_lif() model.add_block(block) synapse = Synapse(1) synapse.set_weights([[1]]) synapse.pop_type = 8 block.add_synapse(synapse) discretize_model(model) allocator = Greedy() # one core per ensemble board = allocator(model, n_chips=1) with pytest.raises(ValueError, match="[Ss]ynapse.*[Uu]nrec.*pop.*type"): build_board(board) # Test error in collect_axons model = Model() block0 = LoihiBlock(1) block0.compartment.configure_lif() model.add_block(block0) block1 = LoihiBlock(1) block1.compartment.configure_lif() model.add_block(block1) axon = Axon(1) block0.add_axon(axon) synapse = Synapse(1) synapse.set_weights([[1]]) synapse.pop_type = 8 axon.target = synapse block1.add_synapse(synapse) discretize_model(model) board = allocator(model, n_chips=1) with pytest.raises(ValueError, match="[Aa]xon.*[Uu]nrec.*pop.*type"): build_board(board)
def __init__( self, model, use_snips=True, seed=None, snip_max_spikes_per_step=50, n_chips=2, allocator=None, ): self.closed = False self._probe_filters = {} self._probe_filter_pos = {} self.model = model self.use_snips = use_snips self.seed = seed self.check_nxsdk_version() # clear cached content from SpikeProbe class attribute d_func(SpikeProbe, b"cHJvYmVEaWN0", b"Y2xlYXI=") # --- allocate allocator = Greedy() if allocator is None else allocator self.board = allocator(self.model, n_chips=n_chips) # --- validate validate_board(self.board) # --- build self.nxsdk_board = build_board( self.board, use_snips=self.use_snips, seed=self.seed ) # --- create snips or non-snip infrastructure self.snips, self.no_snips = None, None if self.use_snips: self.snips = Snips( self.model, self.board, self.nxsdk_board, snip_max_spikes_per_step ) self.chip2host = self.snips.chip2host else: self.no_snips = NoSnips( self.model.dt, self.board.probe_map, self.nxsdk_board.global_spike_generator, ) self.chip2host = self.no_snips.chip2host
def build(self, model, allocator, seed=None): validate_model(model) self.model = model self.pes_error_scale = getattr(model, 'pes_error_scale', 1.) if self.use_snips: # tag all probes as being snip-based, # having normal probes at the same time as snips causes problems for probe in self._iter_probes(): probe.use_snip = True self._snip_probe_data[probe] = [] # --- allocate self.board = allocator(self.model) # --- validate validate_board(self.board) # --- build self.n2board = build_board(self.board, seed=seed)