visualize_comparison() — pytorch Function Reference
Architecture documentation for the visualize_comparison() function in utils.py from the pytorch codebase.
Entity Profile
Dependency Diagram
graph TD 3d2c6e7f_0e61_a579_1388_3d494d9ef856["visualize_comparison()"] 4634f831_1443_4f10_1e21_793e698b53e4["visualize()"] 4634f831_1443_4f10_1e21_793e698b53e4 -->|calls| 3d2c6e7f_0e61_a579_1388_3d494d9ef856 ee2a0377_fc0a_6dcc_ff4c_9e0e6201c7cc["get_backend_colors()"] 3d2c6e7f_0e61_a579_1388_3d494d9ef856 -->|calls| ee2a0377_fc0a_6dcc_ff4c_9e0e6201c7cc style 3d2c6e7f_0e61_a579_1388_3d494d9ef856 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
benchmarks/dynamo/genai_layers/utils.py lines 243–316
def visualize_comparison(
profiling_results: dict[str, list[Performance]],
title: Optional[str] = None,
output_path: Optional[str] = None,
) -> None:
"""
Create a single memory_bandwidth comparison plot from profiling results.
Args:
profiling_results: Dict mapping backend names to lists of Performance objects
output_path: Path to save the plot (optional)
"""
# Get backend colors
backend_colors = get_backend_colors()
# Extract settings from eager backend which runs all settings
all_settings = []
for perf in profiling_results["eager"]:
all_settings.append(perf.setting)
# Create single plot
fig, ax = plt.subplots(1, 1, figsize=(12, 8))
for backend in profiling_results:
backend_perfs = profiling_results[backend]
perf_dict = {perf.setting: perf for perf in backend_perfs}
x_vals = []
y_vals = []
for i, setting in enumerate(all_settings):
if setting in perf_dict:
x_vals.append(i)
y_vals.append(perf_dict[setting].memory_bandwidth)
if x_vals: # Only plot if we have data
color = backend_colors.get(backend, backend_colors["default"])
ax.plot(
x_vals,
y_vals,
"o-",
label=backend,
color=color,
linewidth=2,
markersize=8,
alpha=0.8,
)
# Configure the plot
ax.set_title(title or "Memory Bandwidth Comparison", fontsize=16)
ax.set_xlabel("Shape", fontsize=12)
ax.set_ylabel("memory bandwidth (GB/s)", fontsize=12)
ax.set_xticks(range(len(all_settings)))
ax.set_xticklabels(
[
s.replace("shape: ", "").replace("[", "").replace("]", "")
for s in all_settings
],
rotation=45,
ha="right",
)
ax.legend(fontsize=10)
ax.grid(True, alpha=0.3)
plt.tight_layout()
# Save the plot if output path is provided
if output_path:
# Save as PNG
os.makedirs("pics", exist_ok=True)
full_path = os.path.join("pics", output_path + ".png")
plt.savefig(full_path, dpi=300, bbox_inches="tight", facecolor="white")
print(f"Chart saved to {full_path}")
plt.close()
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does visualize_comparison() do?
visualize_comparison() is a function in the pytorch codebase.
What does visualize_comparison() call?
visualize_comparison() calls 1 function(s): get_backend_colors.
What calls visualize_comparison()?
visualize_comparison() is called by 1 function(s): visualize.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free