AGENT SKILL

inference-export

Use Tensorpack PredictConfig, OfflinePredictor, SmartInit, checkpoints, model export, and model-conversion workflows.

License 许可
Apache-2.0
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
inference-export
license
Apache 2.0
metadata
{ "disco-role": "operating" }
description
Use Tensorpack PredictConfig, OfflinePredictor, SmartInit, checkpoints, model export, and model-conversion workflows.
disable-model-invocation
true

02 资源文件 6

03 SKILL.md 正文

inference-export

Root skill id: tensorpack.

This sub-skill covers Tensorpack inference, checkpoint inspection, export, and optional model-conversion flows. Use it when a task is about turning trained weights into a predictor, a SavedModel, a compact graph, or a clean inference graph.

Use this sub-skill for

  • PredictConfig, OfflinePredictor, OnlinePredictor, and FeedfreePredictor.
  • SmartInit, SaverRestore, DictRestore, and checkpoint / .npz loading.
  • ModelExporter.export_serving() and ModelExporter.export_compact().
  • tensorpack.utils.loadcaffe and Caffe-to-npz conversion flows.
  • Example inference routes from export, saliency, CAM, ResNet loading, and Faster R-CNN prediction scripts.

Route elsewhere

  • Training loops, callbacks, trainer selection, or resume semantics -> ../training/SKILL.md.
  • Input pipelines, augmentation, serializers, or dataset plumbing -> ../dataflow/SKILL.md.
  • Deployment orchestration beyond TensorFlow export formats -> document only, do not build here.

Read first

Operating rules

  1. Prefer a clean inference graph. If you build the graph yourself, wrap it in TowerContext(..., is_training=False).
  2. Do not import a training metagraph for inference. Recreate only the tensors needed for prediction.
  3. Restore parameters by exact name. When names or shapes differ, read the checkpoint guide before relaxing mismatch checks.
  4. Expose graph endpoints with tf.identity(..., name='...') or by using the exact tensor names produced by the tower.
  5. Use OfflinePredictor for the common numpy-array path.
  6. Use OnlinePredictor only when you already own a live session and tensor handles.
  7. Use FeedfreePredictor only when the inputs come from an InputSource.
  8. Prefer ModelExporter.export_serving() for SavedModel and export_compact() for a frozen/pruned .pb.
  9. Keep Caffe conversion optional. It depends on Caffe Python bindings, model files, and usually OpenCV.

Predictor roles

  • PredictConfig is the configuration hub. It can be built from a ModelDesc, a plain tower_func plus input_signature, or a TowerFunc wrapper.
  • OfflinePredictor builds a fresh graph and session from that config, then accepts numpy inputs and returns numpy outputs.
  • OnlinePredictor is a thin wrapper around an existing session plus explicit tensors.
  • FeedfreePredictor consumes an InputSource instead of feeds and is useful when the input is already staged, queued, or dataflow-driven.

Quick decision map

  • I have a checkpoint, .npz, or dict: see Checkpoint guide.
  • I need to inspect variable names or dump a normalized .npz: run scripts/inspect_checkpoint.py.
  • I need a simple predictor from numpy arrays: see Workflow guide.
  • I need SavedModel / TensorFlow Serving export: see Workflow guide.
  • I need a compact frozen graph: see Workflow guide.
  • I need a fake-data end-to-end export demo: run scripts/export_model_demo.py.
  • I need a Caffe model converted to Tensorpack weights: see Workflow guide and Troubleshooting guide.

Distilled example patterns

The bundled references cover these source-evidence patterns without requiring the original example checkout:

  • Basic export: toy training, a separate inference graph, SavedModel export, compact graph export, and apply modes.
  • Caffe-imported vision models: convert Caffe weights to .npz, preprocess images, and load with SmartInit.
  • Converted ResNet inference: load converted .npz weights, run ImageNet-style prediction, and optionally evaluate when the user supplies data.
  • Saliency and CAM: build predictors around fixed ImageNet-style models and fetch gradients or activation-map tensors.
  • Detection prediction/export: detector prediction, evaluation JSON, multiple outputs, postprocessing, and compact/Serving export choices.

What this sub-skill does not own

  • Training graph construction, callbacks, monitors, or trainer wiring.
  • Data loading, augmentation, serializers, or batching policy.
  • General serving orchestration beyond TensorFlow export formats.

If a request mixes inference with any of the above, keep the prediction or export pieces here and route the rest to the adjacent sub-skills.

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

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).

★ 351