def get_tile(self, out_size, in_size, **kwargs): resistive_device = VectorUnitCell([ ConstantStepResistiveDeviceParameters(w_max_dtod=0, w_min_dtod=0), ConstantStepResistiveDeviceParameters(w_max_dtod=0, w_min_dtod=0), ]) return AnalogTile(out_size, in_size, resistive_device, **kwargs).cuda()
def get_tile(self, out_size, in_size, device_params=None): """Return an analog tile of the specified dimensions.""" device_params = device_params or ConstantStepResistiveDeviceParameters( ) resistive_device = ConstantStepResistiveDevice( params_devices=device_params) python_tile = AnalogTile(out_size, in_size, resistive_device) self.set_init_weights(python_tile) return python_tile
def get_noisefree_tile(self, out_size, in_size): """Return a tile of the specified dimensions with noisiness turned off.""" resistive_device = IdealResistiveDevice( params_forward=AnalogTileInputOutputParameters(is_perfect=True), params_backward=AnalogTileBackwardInputOutputParameters( is_perfect=True)) python_tile = AnalogTile(out_size, in_size, resistive_device) self.set_init_weights(python_tile) return python_tile
def get_tile(self, out_size, in_size, **kwargs): resistive_device = TransferUnitCell( [ SoftBoundsResistiveDeviceParameters(w_max_dtod=0, w_min_dtod=0), SoftBoundsResistiveDeviceParameters(w_max_dtod=0, w_min_dtod=0) ], params_transfer_forward=AnalogTileInputOutputParameters( is_perfect=True)) return AnalogTile(out_size, in_size, resistive_device, **kwargs).cuda()
def get_tile_for_plotting(rpu_config: SingleRPUConfig, n_traces: int, use_cuda: bool = False, noise_free: bool = False) -> BaseTile: """Returns an analog tile for plotting the response curve. Args: rpu_config: RPU Configuration to use for plotting n_traces: Number of traces to plot use_cuda: Whether to use the CUDA implementation (if available) noise_free: Whether to turn-off cycle-to-cycle noises Returns: Instantiated tile. """ config = deepcopy(rpu_config) # Make sure we use single pulses for the overview. config.update.update_bl_management = False config.update.update_management = False config.update.desired_bl = 1 if noise_free: config.forward.is_perfect = True config.device.dw_min_std = 0.0 # Noise free. if (hasattr(config.device, 'write_noise_std') and getattr(config.device, 'write_noise_std') > 0.0): # Just make very small to avoid hidden parameter mismatch. setattr(config.device, 'write_noise_std', 1e-6) analog_tile = AnalogTile(n_traces, 1, config) # type: BaseTile analog_tile.set_learning_rate(1) weights = config.device.as_bindings().w_min * ones((n_traces, 1)) analog_tile.set_weights(weights) if use_cuda and cuda.is_compiled(): return analog_tile.cuda() return analog_tile
def get_tile(self, out_size, in_size, rpu_config=None, **kwargs): rpu_config = rpu_config or self.get_rpu_config() return AnalogTile(out_size, in_size, rpu_config, **kwargs)
def get_tile_for_plotting(rpu_config: Union[SingleRPUConfig, UnitCellRPUConfig], n_traces: int, use_cuda: bool = False, noise_free: bool = False) -> BaseTile: """Return an analog tile for plotting the response curve. Args: rpu_config: RPU Configuration to use for plotting n_traces: Number of traces to plot use_cuda: Whether to use the CUDA implementation (if available) noise_free: Whether to turn-off cycle-to-cycle noises (if possible) Returns: Instantiated tile. """ def set_noise_free(dev: Any) -> Any: if hasattr(dev, 'dw_min_std'): dev.dw_min_std = 0.0 # Noise free. if hasattr(dev, 'refresh_forward'): setattr(dev, 'refresh_forward', IOParameters(is_perfect=True)) if hasattr(dev, 'refresh_update'): setattr(dev, 'refresh_update', UpdateParameters(pulse_type=PulseType.NONE)) if hasattr(dev, 'transfer_forward'): setattr(dev, 'refresh_forward', IOParameters(is_perfect=True)) if hasattr(dev, 'transfer_update'): setattr(dev, 'transfer_update', UpdateParameters(pulse_type=PulseType.NONE)) if (hasattr(dev, 'write_noise_std') and getattr(dev, 'write_noise_std') > 0.0): # Just make very small to avoid hidden parameter mismatch. setattr(dev, 'write_noise_std', 1e-6) config = deepcopy(rpu_config) # Make sure we use single pulses for the overview. config.update.update_bl_management = False config.update.update_management = False config.update.desired_bl = 1 if noise_free: config.forward.is_perfect = True set_noise_free(config.device) if hasattr(config.device, 'unit_cell_devices'): for dev in getattr(config.device, 'unit_cell_devices'): set_noise_free(dev) if hasattr(config.device, 'device'): set_noise_free(getattr(config.device, 'device')) analog_tile = AnalogTile(n_traces, 1, config) # type: BaseTile analog_tile.set_learning_rate(1) w_min = getattr(config.device.as_bindings(), 'w_min', -1.0) weights = w_min * ones((n_traces, 1)) analog_tile.set_weights(weights) if use_cuda and cuda.is_compiled(): return analog_tile.cuda() return analog_tile
def get_tile(self, out_size, in_size, **kwargs): resistive_device = ExpStepResistiveDevice( ExpStepResistiveDeviceParameters(w_max_dtod=0, w_min_dtod=0)) return AnalogTile(out_size, in_size, resistive_device, **kwargs).cuda()
def get_tile(self, out_size, in_size, **kwargs): resistive_device = IdealResistiveDevice() return AnalogTile(out_size, in_size, resistive_device, **kwargs).cuda()
def get_tile(self, out_size, in_size, **kwargs): resistive_device = DifferenceUnitCell( ConstantStepResistiveDeviceParameters(w_max_dtod=0, w_min_dtod=0)) return AnalogTile(out_size, in_size, resistive_device, **kwargs)
def get_tile(self, out_size, in_size, **kwargs): resistive_device = PulsedResistiveDevice( LinearStepResistiveDeviceParameters(w_max_dtod=0, w_min_dtod=0)) return AnalogTile(out_size, in_size, resistive_device, **kwargs)