stormlog.tensorflow.context_profiler
TensorFlow Context Profiling
Functions
Clear global profiler state. |
|
Reset profiling data without discarding the global profiler. |
|
Get or create global profiler instance. |
|
|
Return aggregated profiling summaries for recent functions/contexts. |
|
Context manager for profiling code blocks. |
|
Decorator to profile function memory usage. |
|
Profile Keras model training. |
|
Profile all layers in a TensorFlow model. |
|
Set global profiler instance. |
Classes
|
Wrapper for TensorFlow layers with automatic profiling. |
|
High-level TensorFlow profiling interface. |
- stormlog.tensorflow.context_profiler.get_global_profiler()[source]
Get or create global profiler instance.
- Return type:
- stormlog.tensorflow.context_profiler.set_global_profiler(profiler)[source]
Set global profiler instance.
- Parameters:
profiler (TFMemoryProfiler)
- Return type:
None
- stormlog.tensorflow.context_profiler.profile_function(func=None, *, profiler=None, name=None)[source]
Decorator to profile function memory usage.
- Parameters:
func (F | None) – Function to profile
profiler (TFMemoryProfiler | None) – Profiler instance (uses global if None)
name (str | None) – Custom name for profiling
- Return type:
Callable[[F], F] | F
- stormlog.tensorflow.context_profiler.profile_context(name='context', profiler=None)[source]
Context manager for profiling code blocks.
- Parameters:
name (str) – Name for the profiling context
profiler (TFMemoryProfiler | None) – Profiler instance (uses global if None)
- Return type:
Iterator[None]
- class stormlog.tensorflow.context_profiler.ProfiledLayer(layer, profiler=None, name=None)[source]
Bases:
objectWrapper for TensorFlow layers with automatic profiling.
- Parameters:
layer (Any)
profiler (TFMemoryProfiler | None)
name (str | None)
- stormlog.tensorflow.context_profiler.profile_model(model, profiler=None)[source]
Profile all layers in a TensorFlow model.
- Parameters:
model (Any) – TensorFlow model
profiler (TFMemoryProfiler | None) – Profiler instance
- Returns:
Model with profiled layers
- Return type:
Any
- class stormlog.tensorflow.context_profiler.TensorFlowProfiler(device=None)[source]
Bases:
objectHigh-level TensorFlow profiling interface.
- Parameters:
device (str | None)
- profile_training(model, dataset, epochs=1, steps_per_epoch=None)[source]
Profile model training.
- Parameters:
model (Any) – TensorFlow model
dataset (Any) – Training dataset
epochs (int) – Number of epochs
steps_per_epoch (int | None) – Steps per epoch
- Return type:
None
- stormlog.tensorflow.context_profiler.profile_keras_training(model, x_train, y_train, epochs=1, batch_size=32, validation_data=None, profiler=None)[source]
Profile Keras model training.
- Parameters:
model (Any) – Keras model
x_train (Any) – Training data
y_train (Any) – Training labels
epochs (int) – Number of epochs
batch_size (int) – Batch size
validation_data (Any | None) – Validation data tuple (x_val, y_val)
profiler (TFMemoryProfiler | None) – Profiler instance
- Return type:
None
- stormlog.tensorflow.context_profiler.clear_global_profiler()[source]
Clear global profiler state.
- Return type:
None