コード例 #1
0
ファイル: configs.py プロジェクト: tunghoang290780/aihwkit
class Idealized4Preset(UnitCellRPUConfig):
    """Preset configuration using four Idealized devices per cross-point
    (:class:`~aihwkit.simulator.presets.devices.IdealizedPresetDevice`),
    where both are updated with random selection policy for update.

    See :class:`~aihwkit.simulator.configs.devices.VectorUnitCell` for
    more details on multiple devices per cross-points.

    The default peripheral hardware
    (:class:`~aihwkit.simulator.presets.utils.PresetIOParameters`) and
    analog update
    (:class:`~aihwkit.simulator.presets.utils.PresetUpdateParameters`)
    configuration is used otherwise.
    """

    device: UnitCell = field(default_factory=lambda: VectorUnitCell(
        unit_cell_devices=[
            IdealizedPresetDevice(),
            IdealizedPresetDevice(),
            IdealizedPresetDevice(),
            IdealizedPresetDevice()
        ],
        update_policy=VectorUnitCellUpdatePolicy.SINGLE_RANDOM))
    forward: IOParameters = field(default_factory=PresetIOParameters)
    backward: IOParameters = field(default_factory=PresetIOParameters)
    update: UpdateParameters = field(default_factory=PresetUpdateParameters)
コード例 #2
0
ファイル: tiles.py プロジェクト: diego-plan9/aihwkit
 def get_rpu_config(self):
     return UnitCellRPUConfig(device=VectorUnitCell(unit_cell_devices=[
         ConstantStepDevice(w_max_dtod=0, w_min_dtod=0),
         ConstantStepDevice(w_max_dtod=0, w_min_dtod=0)
     ]))
コード例 #3
0
    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():
コード例 #4
0
    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.