Command Palette

Search for a command to run...

Назад к скиллам
скилл № 94333

edge-ai

Use when the user asks about edge AI, on-device inference, TensorRT on Jetson, ONNX Runtime, LiteRT (TFLite), TinyML, int8 quantization, Coral, NPUs or…

БесплатноБез исполняемых скриптов
j4flmaoот j4flmao★ 47 звёзд на GitHub

Установить edge-ai в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Edge AI Deployment

Purpose

A model that works in a notebook still has to fit the device's memory, latency, power and operator support. This skill picks the runtime for the target hardware, converts and quantizes the model without silently losing accuracy, and measures it on the device.

Agent Protocol

Trigger

"edge AI", "on-device inference", "TensorRT", "ONNX Runtime", "TFLite", "LiteRT", "TinyML", "int8 quantization", "Jetson", "Coral", "NPU", "ExecuTorch".

Input Context

  • Model framework, architecture, input shape, accuracy metric and baseline
  • Target hardware (MCU, Cortex-A CPU, mobile NPU/GPU, Jetson, Hailo, Coral) and OS
  • Latency, throughput, memory and power budgets

Output Artifact

Export/convert/quantize scripts, runtime integration code, benchmark plan. No file unless requested.

Response Format

Target: {hardware + OS}
Path: {framework -> format -> runtime/EP}
Precision: {FP32 | FP16 | INT8 (PTQ/QAT) | INT4}
Calibration: {dataset, size}
Result: {latency p50/p99, memory, accuracy delta vs FP32}
Risks: {unsupported ops, fallback to CPU, accuracy drop}

1. Choose the Runtime by Hardware

Hardware Typical runtime Notes
NVIDIA Jetson / dGPU TensorRT (or ONNX Runtime with TensorRT/CUDA EP) Engines are built per GPU + TensorRT version; rebuild on upgrade
Android phones LiteRT (formerly TensorFlow Lite) with GPU/NNAPI delegates, or vendor SDKs (Qualcomm AI Engine Direct/QNN) NNAPI is deprecated in Android 15; prefer GPU delegate or vendor SDK
iOS / Apple silicon Core ML (convert with coremltools) ANE used automatically for supported layers
Linux Cortex-A CPU ONNX Runtime (CPU EP / XNNPACK), LiteRT + XNNPACK NEON-optimised kernels
Microcontrollers LiteRT for Microcontrollers (TFLM), CMSIS-NN kernels, vendor tools (STM32Cube.AI, Edge Impulse) INT8 only in practice; static tensor arena
Dedicated NPUs (Hailo, Coral Edge TPU, NXP eIQ, Rockchip) Vendor compiler + runtime Coral needs fully INT8 models compiled with edgetpu_compiler
PyTorch-first mobile/embedded ExecuTorch Backends: XNNPACK, Core ML, Vulkan, Qualcomm, Arm Ethos-U

ONNX is the usual interchange format: one export, then hardware-specific runtimes or Execution Providers (EPs).

2. Export

import torch

model.eval()
example = torch.randn(1, 3, 224, 224)
torch.onnx.export(
    model, (example,), "model.onnx",
    input_names=["input"], output_names=["logits"],
    dynamic_axes={"input": {0: "batch"}, "logits": {0: "batch"}},
    opset_version=17,
)
  • Validate: onnx.checker.check_model, then compare ONNX Runtime outputs with PyTorch on real samples (np.testing.assert_allclose with a tolerance).
  • Fix shapes where the target needs static shapes (most NPUs/MCUs); simplify the graph (onnxsim) before conversion.
  • Check operator coverage for the target early — one unsupported op can force a CPU fallback or a graph split that dominates latency.

3. Quantization

Method Effort Accuracy Use
FP16 none ~unchanged GPUs/NPUs with FP16
Dynamic INT8 (weights only, activations at runtime) low small drop CPU, transformer/LSTM layers
Static PTQ INT8 (calibrated activations) medium small drop if calibrated well CNNs on NPUs/MCUs/TensorRT
QAT (quantization-aware training) high best INT8 when PTQ loses too much
INT4 weight-only medium model dependent LLMs/large models on capable runtimes
  • Calibrate with a few hundred representative, preprocessed samples from the real input distribution (not random tensors).
  • Per-channel weight quantization for convolutions; keep sensitive layers (first/last, softmax/attention) in higher precision if accuracy drops.
  • Always report accuracy delta on the full validation set, not one image.

ONNX Runtime static quantization sketch:

from onnxruntime.quantization import quantize_static, CalibrationDataReader, QuantFormat, QuantType

class Reader(CalibrationDataReader):
    def __init__(self, batches): self._it = iter(batches)
    def get_next(self): return next(self._it, None)   # dict {"input": np.ndarray} or None

quantize_static("model.onnx", "model.int8.onnx", Reader(calib_batches),
                quant_format=QuantFormat.QDQ,
                activation_type=QuantType.QInt8, weight_type=QuantType.QInt8,
                per_channel=True)

4. TensorRT Build

trtexec --onnx=model.onnx --saveEngine=model.fp16.plan --fp16
# INT8 needs calibration data or a QDQ (explicitly quantized) ONNX model
trtexec --onnx=model.int8.onnx --saveEngine=model.int8.plan --int8

TensorRT fuses layers (conv+bias+activation), selects kernels per GPU and can use FP16/INT8. Engines are not portable across GPU models or TensorRT versions. On Jetson use the JetPack-matched TensorRT and power mode (nvpmodel, jetson_clocks) when benchmarking.

5. Microcontrollers (TinyML

Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл edge-ai?

Use when the user asks about edge AI, on-device inference, TensorRT on Jetson, ONNX Runtime, LiteRT (TFLite), TinyML, int8 quantization, Coral, NPUs or ExecuTorch. Produces export, quantization and on-device benchmarking plans. Not for model training (use ml-deep-learning) or cloud LLM serving (use ml-inference-optimization).

Как установить скилл edge-ai?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл edge-ai запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить edge-ai с