Overview
The profiler module provides tools to analyze neural network models and generate detailed reports about their computational and memory requirements.profile_model
Profiles a neural network model and generates a comprehensive report.Parameters
The neural network model to profile. Must have a
layer_sizes attribute.Batch size for activation memory estimation.
Directory where the profiling report JSON file will be saved.
Returns
Returns a tuple containing:report(dict): Profiling report with the following structure:timestamp: ISO 8601 timestampmodel: Model class namelayer_sizes: List of layer dimensionsbatch_size: Batch size usedtotal_trainable_parameters: Total parameter countlayer_wise_parameters: List of per-layer parameter detailsparameter_memory_mb: Memory footprint for float32, float16, and int8activation_memory: Activation memory details in bytes and MB
report_file(Path): Path to the saved JSON report
Example
Helper Functions
summary_table
Generates a formatted text summary of a profiling report. Parameters:report(dict): Profiling report fromprofile_model
run_from_config
Runs profiling from a configuration file. Parameters:config_path(str): Path to Python configuration module
Configuration Format
When usingrun_from_config, your config file should define:
CLI Usage
Notes
- The profiler performs a forward pass to accurately measure activation memory
- Memory estimates are provided for three precision modes: float32, float16, and int8
- Layer-wise parameter counts help identify model bottlenecks
- All numeric values in the JSON report are JSON-serializable (numpy types converted)