pytorch-summary
Use and maintain the legacy torchsummary PyTorch model-summary package, including summary calls, device and dtype handling, smoke checks, and focused repo tests.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- pytorch-summary
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Use and maintain the legacy torchsummary PyTorch model-summary package, including summary calls, device and dtype handling, smoke checks, and focused repo tests.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/repo-provenance.md2.0 KB
- 参考文档references/repo-routing-metadata.json337 B
- 参考文档references/troubleshooting.md3.8 KB
- 脚本scripts/check_install.py3.3 KB
03 SKILL.md 正文
pytorch-summary
Use this repo skill when a task names pytorch-summary or torchsummary, or
when a PyTorch model needs the legacy Keras-style summary(...) table for
output shapes, parameter counts, and rough size estimates.
This package is small and legacy. The source README recommends the newer
torchinfo project for new and more advanced model-inspection work. Use this
skill when existing code depends on torchsummary, when a task asks about this
repo/package specifically, or when the lightweight legacy API is enough.
Quick install and import check
torchsummary version 1.5.1 imports both PyTorch and NumPy, but its packaging
metadata does not declare them as install requirements. Install PyTorch for the
intended backend first, then install torchsummary and numpy if needed.
CPU-oriented example:
python -m pip install numpy torchsummary
# install a PyTorch build appropriate for the target platform/backend separately
python - <<'PY'
from torchsummary import summary, summary_string
print(summary, summary_string)
PY
Run the bundled diagnostic when imports or device behavior are uncertain:
python scripts/check_install.py --help
python scripts/check_install.py --device cpu
The diagnostic is safe: it imports torchsummary, torch, and numpy, prints
public signatures, reports CUDA visibility, and runs a tiny torch.nn.Linear
summary on the requested device.
Route map
- For end-user model inspection with
summary(...)orsummary_string(...), readsub-skills/model-summary-usage/SKILL.md. This covers single inputs, multiple inputs,dtypes, CPU/CUDA placement, returned counts, table interpretation, and a bundled smoke helper. - For editing this checkout, fixing tests, changing packaging metadata, or
preserving source compatibility, read
sub-skills/repo-maintenance/SKILL.md. - For install/import, backend, dependency, and package-selection failures shared
by both routes, read
references/troubleshooting.md. - Before deciding whether this generated skill is stale for a checkout, read
references/repo-provenance.md.
Public API facts
The package exports exactly the legacy public functions below:
from torchsummary import summary, summary_string
Verified signatures:
summary(model, input_size, batch_size=-1, device=torch.device("cuda:0"), dtypes=None)
summary_string(model, input_size, batch_size=-1, device=torch.device("cuda:0"), dtypes=None)
Key usage constraints:
modelmust be a PyTorchtorch.nn.Moduleand must already be on the same device passed asdevice.input_sizeexcludes batch. Use a tuple for one input and a list of tuples for multiple positional inputs.- The default device is CUDA; CPU-only use should pass
device="cpu"ortorch.device("cpu")explicitly. dtypes, when provided, is a list aligned with theinput_sizelist.summary(...)prints a table and returns(total_params, trainable_params).summary_string(...)returns(summary_text, (total_params, trainable_params)).
Use torchinfo instead when
- The task is not tied to legacy
torchsummarycompatibility. - The model needs dictionary, keyword-only, or non-tensor inputs.
- You need richer nested-module display, configurable columns/depth, or modern PyTorch behavior.
- Memory estimates must be credible enough for deployment planning.
Verification baseline
This generated skill was built against torchsummary 1.5.1 with CPU PyTorch
verification. CUDA is documented as an optional device path, not a required
backend for this skill. Use refresh-repo-skill if the package source,
packaging metadata, public signatures, tests, or README guidance change.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).