dataflow
Use Tensorpack DataFlow, datasets, augmentors, serializers, input sources, and performance-tuning utilities.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- dataflow
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use Tensorpack DataFlow, datasets, augmentors, serializers, input sources, and performance-tuning utilities.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md14.7 KB
- 参考文档references/troubleshooting.md12.2 KB
- 参考文档references/workflows.md13.4 KB
- 脚本scripts/dataflow_serializer_smoke.py7.9 KB
03 SKILL.md 正文
Tensorpack DataFlow Skill
Use this sub-skill when the user needs Tensorpack data loading, preprocessing, serialization, image augmentation, TensorFlow input-source bridging, or data pipeline performance diagnosis. Keep answers self-contained: rely on the bundled references and script here instead of reopening the original repository.
Read first
- For exact API signatures, component roles, optional dependencies, and gotchas,
read
references/api-reference.md. - For concrete construction recipes and decision trees, read
references/workflows.md. - For symptom-to-recovery guidance, read
references/troubleshooting.md. - For a safe serializer availability/roundtrip check, use
scripts/dataflow_serializer_smoke.py.
Use this when
- The task mentions
tensorpack.dataflow,DataFlow, datapoints, components,reset_state(),__iter__(),BatchData,MapData,MapDataComponent,FakeData,DataFromList,DataFromGenerator,RepeatedData, orPrintData. - The user asks how to choose between parallel runners and parallel mappers, or between threads, processes, and ZeroMQ data pipes.
- The task involves
LMDBSerializer,NumpySerializer,TFRecordSerializer,HDF5Serializer, optional serializer imports, or a data serialization roundtrip. - The task involves
tensorpack.dataflow.imgaug,AugmentorList, deterministic image transforms, coordinate transforms,Flip,Resize,CenterCrop,GoogleNetRandomCropAndResize, dtype conversions, contrast, or brightness. - The task asks how a DataFlow feeds Tensorpack trainers through
FeedInput,QueueInput,StagingInput,TFDatasetInput,TensorInput, orZMQInput. - The task involves Tensorpack dataset loaders such as
Mnist,Cifar10,SVHNDigit,ILSVRC12, orILSVRC12Files. - The task is about queue size,
TestDataSpeed, random disk reads, CPU-bound augmentation, network/IPC bottlenecks, or slow input pipelines.
Route elsewhere
- Model definitions, trainer selection, callbacks, summaries, and full training
loops belong in
../training/SKILL.md. - Offline prediction, export, checkpoint loading,
.npzmodel-zoo variables, and checkpoint inspection belong in../inference-export/SKILL.md. - Full domain example command catalogs belong at the root example catalog and the
training example recipes:
../../references/examples-catalog.mdand../training/references/example-recipes.md.
Operating model
Tensorpack DataFlow is a pure-Python iterator system. A source DataFlow yields
one datapoint at a time; wrappers transform, filter, batch, shuffle, prefetch,
or serialize those datapoints. A datapoint is normally a list of components, but
some DataFlow utilities also support dict datapoints. Tensorpack trainers do not
usually consume DataFlow directly; an InputSource turns a DataFlow or another
input producer into tensors in the TensorFlow graph.
Default answer pattern:
- Identify whether the user needs a source, wrapper, parallelization, serialization, augmentation, dataset loader, InputSource, or performance diagnosis.
- State the DataFlow contract: implement
__iter__(), callreset_state()in the process that will iterate, treat__len__()as optional/rough unless the downstream consumer needs exact size, and avoid concurrent iteration of one non-reentrant instance. - Choose the smallest composition that preserves correctness before optimizing speed.
- For training, allow distribution-preserving duplication/reordering only when it is acceptable for stochastic training. For validation/inference, preserve exact membership and usually exact ordering.
- Use
PrintDataandTestDataSpeedbefore guessing. If a trainer queue is close to empty, diagnose the input pipeline; if it is full, route graph or trainer speed questions to training.
Quick decisions
- New custom data format: write a source
DataFlowor wrap a generator withDataFromGenerator; then compose maps, augmentors, batches, and prefetching. - In-memory toy or deterministic tests: use
FakeDataorDataFromList. - Map one component: use
MapDataComponent(ds, func, index=...); map/filter a full datapoint: useMapData(ds, func), returningNoneto drop it. - Batch same-shaped components: use
BatchData(ds, batch_size); useuse_list=Truewhen components have variable shapes such as raw images. - Training prefetch with independent stochastic workers: use
MultiProcessRunnerZMQorMultiThreadRunneronly when duplicated/reordered i.i.d. samples are acceptable. - Preserve set membership while parallelizing expensive transforms: use
MultiThreadMapDataorMultiProcessMapData/MultiProcessMapDataZMQ; usestrict=Truefor finite validation-style passes, remembering order is still not preserved. - Random-read ImageNet-like data on slow disks: consider serializing encoded bytes to LMDB, then sequentially read, locally shuffle, decode, augment, and batch.
- Feed a Tensorpack trainer: prefer
QueueInput(dataflow)for most DataFlow training; wrap withStagingInputwhen GPU staging is useful; useTFDatasetInputorTensorInputfor TensorFlow-native input pipelines.
Reference tasks
- Build or audit a custom DataFlow contract: use
references/workflows.md#custom-source-dataflowand the DataFlow section ofreferences/api-reference.md#dataflow-object-contract. - Compose maps, filters, batches, and debug prints: use
references/workflows.md#compose-maps-batches-and-debug-prints. - Decide runner vs mapper / threads vs processes: use
references/workflows.md#parallelism-decision-tree. - Serialize and reload tiny or large DataFlows: use
references/workflows.md#serialization-roundtripsand the bundled smoke script. - Create ImageNet-style training/validation pipelines: use
references/workflows.md#imagenet-style-pipelines. - Distill a TIMIT-style LMDB preprocessing pattern: use
references/workflows.md#timit-style-lmdb-pattern. - Bridge to Tensorpack trainers: use
references/workflows.md#inputsource-bridge-to-trainers. - Diagnose speed: use
references/workflows.md#performance-diagnosisandreferences/troubleshooting.md#slow-or-empty-queues.
Safe checks
Use the bundled script for serializer availability, optional dependency messages, and tiny deterministic roundtrips:
python sub-skills/dataflow/scripts/dataflow_serializer_smoke.py --help
python sub-skills/dataflow/scripts/dataflow_serializer_smoke.py \
--workdir <scratch-dir> --formats numpy
python sub-skills/dataflow/scripts/dataflow_serializer_smoke.py \
--workdir <scratch-dir> --formats all
The script writes only under --workdir, uses tiny synthetic datapoints, avoids
network and downloads, and does not require original Tensorpack source files.
Hard boundaries
- Do not recommend running original example or test files as part of answering a user question. Use the distilled recipes and bundled helper instead.
- Do not claim GPU or multi-node performance verification from this skill; the DataFlow references document CPU/IPC/disk/network reasoning and route trainer scaling to training.
- Do not expose machine-specific environment or filesystem locations in user-facing answers.
- Do not use runner-style parallelism for validation unless the user explicitly accepts potential duplication and reordering; use mapper-style strict passes or a single runner process for exact validation-style data.
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).