aihwkit.utils.analog_info module

Analog Information utility.

This module prints relevant information about the model and its analog execution.

class aihwkit.utils.analog_info.AnalogInfo(model, input_size=None, rpu_config=None)[source]

Bases: object

Class for computing and storing results of the analog summary.

Parameters
calculate_num_analog()[source]

Calculate the number of analog layers.

Return type

int

calculate_num_tiles()[source]

Calculate the total number of tiles needed by the model.

Return type

int

create_layer_summary()[source]

Create the layer summary list.

This list contains LayerInfo elements that corresponds to each layer of the model.

Return type

List[aihwkit.utils.analog_info.LayerInfo]

register_hooks_recursively(module, hook)[source]

Hooks the function into all layers with no children.

Parameters
  • module (torch.nn.modules.module.Module) –

  • hook (Any) –

Return type

None

class aihwkit.utils.analog_info.LayerInfo(module, rpu_config=None, input_size=None, output_size=None)[source]

Bases: object

Class for storing layer statistics and information.

Parameters
calculate_reuse_factor()[source]

Compute the reuse factor.

The reuse factor is the number of vector matrix multiplication a layer computes.

Return type

None

input_size: Any
isanalog: bool
kernel_size: Any
layer_summary_dict()[source]

Return a dictionary with all layer’s information.

Return type

dict

module: torch.nn.modules.module.Module
name: str
num_tiles: int
output_size: Any
reuse_factor: int
set_kernel_size()[source]

Set kernel size attribute.

Return type

None

set_tiles_info()[source]

Create TileInfo objects for each tile of the layer.

Return type

List[aihwkit.utils.analog_info.TileInfo]

tiles_info: List[aihwkit.utils.analog_info.TileInfo]
tiles_summary_dict()[source]

Return a dictionary with all tiles information.

Return type

dict

class aihwkit.utils.analog_info.TileInfo(tile, is_mapped)[source]

Bases: object

Class for storing tile statistics and information.

Parameters
  • tile (aihwkit.simulator.tiles.base.BaseTile) –

  • is_mapped (bool) –

log_in_size: Any
log_out_size: Any
phy_in_size: Any
phy_out_size: Any
tile_summary_dict()[source]

Return a dictionary with the tile info.

Return type

dict

utilization: float
aihwkit.utils.analog_info.analog_summary(model, input_size=None, rpu_config=None)[source]

Summarize the given PyTorch model.

Summarized information includes:

  1. Layer names,

  2. input/output shapes,

  3. kernel shape,

  4. # of digital parameters,

  5. # of analog parameters,

  6. # of analog tiles

  7. reuse factor

Parameters
Returns

AnalogInfo Object.

Return type

aihwkit.utils.analog_info.AnalogInfo