einops
Use the einops Python package for readable tensor rearrangement, reductions, repetition, named-axis einsum, packing, framework layers, and repository maintenance workflows.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- einops
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Use the einops Python package for readable tensor rearrangement, reductions, repetition, named-axis einsum, packing, framework layers, and repository maintenance workflows.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/repo-provenance.md3.0 KB
- 参考文档references/repo-routing-metadata.json438 B
- 参考文档references/troubleshooting.md4.1 KB
- 脚本scripts/check_einops_install.py2.9 KB
03 SKILL.md 正文
einops Repo Skill
Use this repo skill when a task involves the einops Python package: readable
and shape-checked tensor manipulation, named axes, deep-learning tensor
refactors, reversible token/feature packing, optional framework layers, or
maintainer workflows for the einops repository.
Install and Minimal Check
Public package install:
pip install einops
einops declares no runtime dependencies. Install NumPy, PyTorch, TensorFlow,
JAX, or another tensor framework separately according to the user's project.
For a minimal core check with NumPy installed:
import numpy as np
from einops import rearrange, reduce, repeat
x = np.arange(2 * 3 * 4).reshape(2, 3, 4)
assert rearrange(x, "batch channel time -> batch time channel").shape == (2, 4, 3)
assert reduce(x, "batch channel time -> batch time", "sum").shape == (2, 4)
assert repeat(x, "batch channel time -> batch channel time copy", copy=2).shape == (2, 3, 4, 2)
For a bundled diagnostic, run
scripts/check_einops_install.py after
installing einops and, for the full smoke, numpy.
Route Map
sub-skills/tensor-operations/: userearrange,reduce,repeat,parse_shape, andasnumpyfor core tensor shape transformations, pooling, broadcasting, stack/concatenate, ellipsis, and pattern troubleshooting.sub-skills/named-einsum-and-packing/: useeinsum,pack, andunpackfor named-axis contractions, attention-like dot products, class-token/multimodal packing, packed-shape (PS) handling, and reversible split/merge workflows.sub-skills/framework-integrations/: use optional backend dispatch, Array API functions, framework layers,EinMix, torch scripting/compilation notes, and missing optional dependency diagnostics.sub-skills/repo-development/: use maintainer guidance for focused tests, backend selection,EINOPS_TEST_BACKENDS, docs/notebook checks, formatting/type checks, CI matrix interpretation, and release/deploy boundaries.
Core Decision Points
- If the user wants a readable replacement for
reshape,view,permute,transpose, pooling, tiling, broadcasting, or shape parsing, start withtensor-operations. - If the operation is a mathematical contraction or a dot product with named
axes, use
named-einsum-and-packingand remember thateinops.einsumtakes tensors first and the pattern last. - If multiple tensors must be concatenated and later split without losing their
heterogeneous middle dimensions, use
pack/unpackrather than manual slices. - If the transform belongs inside a neural-network model definition, serialized
layer, Keras model, Flax module, or Torch
Sequential, useframework-integrations. - If the task is about changing the repository, running native tests, or
building docs, use
repo-developmentinstead of package-usage routes.
Shared References
references/repo-provenance.md: source commit, tag, package version, evidence paths, and refresh cues.references/repo-routing-metadata.json: structured scenario metadata for DisCo repo-skill routing if imported later.references/troubleshooting.md: cross-cutting install/import, optional dependency, backend, and stale-skill troubleshooting.
Safe Operating Rules
- Keep runtime guidance self-contained. Do not require future agents to open or run original repository notebooks, tests, docs, or scripts to complete normal package-usage tasks.
- Treat optional frameworks as optional. A CPU NumPy smoke does not prove CUDA, ROCm, MPS, TensorFlow, JAX, or PyTorch runtime behavior.
- Prefer explicit semantic axis names (
batch,channel,height,width) in examples that explain user intent. - When decomposing axes such as
(height h2), supply or validate lengths that cannot be inferred safely. - For maintainer commands that can mutate an environment or docs tree, use the repo-development sub-skill's dry-run helpers before executing.
Refresh Triggers
Read references/repo-provenance.md before deciding this skill is current for a
checkout. Refresh the repo skill if the package version, public API exports,
pattern grammar, backend list, layer modules, native test runner, docs scripts,
CI matrix, or relevant evidence paths changed since the recorded snapshot.
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).