stormlog.tensorflow.utils

Utility functions for TensorFlow memory profiling.

This module provides helper functions for memory formatting, system information, and TensorFlow-specific optimizations.

Functions

analyze_fragmentation(snapshots)

Analyze memory fragmentation from snapshots.

clear_tensorflow_session()

Clear TensorFlow session and free memory.

format_memory(bytes_value)

Format memory size in human-readable format.

generate_summary_report(profile_result)

Generate a comprehensive summary report.

get_backend_info()

Return backend diagnostics used by CLI and system reporting.

get_gpu_info()

Get detailed GPU information for TensorFlow.

get_system_info()

Get system and TensorFlow environment information.

get_tensorflow_memory_usage()

Get current TensorFlow memory usage.

optimize_tensorflow_memory()

Apply TensorFlow memory optimizations.

suggest_optimizations(profile_result)

Generate TensorFlow-specific optimization suggestions.

validate_tensorflow_environment()

Validate TensorFlow environment for memory profiling.

Classes

BackendInfo

class stormlog.tensorflow.utils.BackendInfo[source]

Bases: TypedDict

is_apple_silicon: bool
hardware_gpu_detected: bool
runtime_gpu_count: int
runtime_backend: str
is_cuda_build: bool
is_rocm_build: bool
is_tensorrt_build: bool
tensorflow_metal_installed: bool
stormlog.tensorflow.utils.get_backend_info()[source]

Return backend diagnostics used by CLI and system reporting.

Return type:

BackendInfo

stormlog.tensorflow.utils.format_memory(bytes_value)[source]

Format memory size in human-readable format.

Parameters:

bytes_value (int | float | None)

Return type:

str

stormlog.tensorflow.utils.get_gpu_info()[source]

Get detailed GPU information for TensorFlow.

Return type:

Dict[str, Any]

stormlog.tensorflow.utils.get_system_info()[source]

Get system and TensorFlow environment information.

Return type:

Dict[str, Any]

stormlog.tensorflow.utils.analyze_fragmentation(snapshots)[source]

Analyze memory fragmentation from snapshots.

Parameters:

snapshots (List)

Return type:

Dict[str, float]

stormlog.tensorflow.utils.suggest_optimizations(profile_result)[source]

Generate TensorFlow-specific optimization suggestions.

Parameters:

profile_result (Any)

Return type:

List[str]

stormlog.tensorflow.utils.generate_summary_report(profile_result)[source]

Generate a comprehensive summary report.

Parameters:

profile_result (Any)

Return type:

str

stormlog.tensorflow.utils.optimize_tensorflow_memory()[source]

Apply TensorFlow memory optimizations.

Return type:

List[str]

stormlog.tensorflow.utils.get_tensorflow_memory_usage()[source]

Get current TensorFlow memory usage.

Return type:

Dict[str, float]

stormlog.tensorflow.utils.clear_tensorflow_session()[source]

Clear TensorFlow session and free memory.

Return type:

None

stormlog.tensorflow.utils.validate_tensorflow_environment()[source]

Validate TensorFlow environment for memory profiling.

Return type:

Dict[str, Any]