ReferenceUnitCell) from aihwkit.simulator.rpu_base import cuda # Prepare the datasets (input and expected output). x = Tensor([[0.1, 0.2, 0.4, 0.3], [0.2, 0.1, 0.1, 0.3]]) y = Tensor([[1.0, 0.5], [0.7, 0.3]]) # Define a single-layer network, using a vector device having multiple # devices per crosspoint. Each device can be arbitrarily defined rpu_config = UnitCellRPUConfig() # 3 arbitrary devices per cross-point. rpu_config.device = VectorUnitCell( unit_cell_devices=[ ReferenceUnitCell(unit_cell_devices=[SoftBoundsDevice(w_max=1.0)]), ConstantStepDevice(), LinearStepDevice(w_max_dtod=0.4), SoftBoundsDevice() ]) # Only one of the devices should receive a single update. # That is selected randomly, the effective weights is the sum of all # weights. rpu_config.device.update_policy = VectorUnitCellUpdatePolicy.SINGLE_RANDOM model = AnalogLinear(4, 2, bias=True, rpu_config=rpu_config) print(rpu_config) # Move the model and tensors to cuda if it is available.
VectorUnitCell ) from aihwkit.simulator.rpu_base import cuda # Prepare the datasets (input and expected output). x = Tensor([[0.1, 0.2, 0.4, 0.3], [0.2, 0.1, 0.1, 0.3]]) y = Tensor([[1.0, 0.5], [0.7, 0.3]]) # Define a single-layer network, using a vector device having multiple # devices per crosspoint. Each device can be arbitrarily defined rpu_config = UnitCellRPUConfig() # 3 arbitrary single unit cell devices (of the same type) per cross-point. rpu_config.device = VectorUnitCell( unit_cell_devices=[ ConstantStepDevice(w_max=0.3), ConstantStepDevice(w_max_dtod=0.4), ConstantStepDevice(up_down_dtod=0.1), ]) # Only one of the devices should receive a single update. # That is selected randomly, the effective weights is the sum of all # weights. rpu_config.device.update_policy = VectorUnitCellUpdatePolicy.SINGLE_RANDOM model = AnalogLinear(4, 2, bias=True, rpu_config=rpu_config) print(rpu_config) # Move the model and tensors to cuda if it is available. if cuda.is_compiled():
LinearStepDevice, SoftBoundsDevice) from aihwkit.simulator.rpu_base import cuda # Prepare the datasets (input and expected output). x = Tensor([[0.1, 0.2, 0.4, 0.3], [0.2, 0.1, 0.1, 0.3]]) y = Tensor([[1.0, 0.5], [0.7, 0.3]]) # Define a single-layer network, using a vector device having multiple # devices per crosspoint. Each device can be arbitrarily defined rpu_config = UnitCellRPUConfig() # 3 arbitrary devices per cross-point. rpu_config.device = VectorUnitCellDevice(unit_cell_devices=[ ConstantStepDevice(), LinearStepDevice(w_max_dtod=0.4), SoftBoundsDevice() ]) # Only one of the devices should receive a single update. rpu_config.device.single_device_update = True # That is selected randomly, the effective weights is the sum of all # weights. rpu_config.device.single_device_update_random = True model = AnalogLinear(4, 2, bias=True, rpu_config=rpu_config) print(model.analog_tile.tile) # Move the model and tensors to cuda if it is available. if cuda.is_compiled():