Back to list
johnzfitch

burn-onnx

by johnzfitch

Comprehensive Claude Code plugin for the Burn deep learning framework

1🍴 0📅 Jan 19, 2026

SKILL.md


name: burn-onnx description: This skill should be used when the user asks about "ONNX import", "PyTorch to Burn", "safetensors", "model conversion", "burn-import", "unsupported operator", "opset version", or importing external models into Burn. version: 0.1.0

Burn Model Import

Knowledge for importing ONNX, PyTorch, and Safetensors models into Burn.

ONNX Import Overview

Burn uses burn-import crate for ONNX model conversion at build time.

Setup

Add to Cargo.toml:

[dependencies]
burn = { version = "0.16", features = ["wgpu"] }

[build-dependencies]
burn-import = "0.16"

Build Script

Create build.rs:

use burn_import::onnx::ModelGen;

fn main() {
    ModelGen::new()
        .input("models/my_model.onnx")
        .out_dir("model/")
        .run_from_script();
}

Generated Code

The build generates a Rust module with:

  • Model struct matching ONNX architecture
  • Weights embedded or loadable
  • Type-safe forward method
mod model {
    include!(concat!(env!("OUT_DIR"), "/model/my_model.rs"));
}

use model::Model;

let model = Model::<Backend>::default();
let output = model.forward(input);

Operator Coverage

burn-import supports common operators. Check coverage before import:

  • Fully supported: Conv, Linear, ReLU, BatchNorm, MaxPool, etc.
  • Partial: Some transformer ops, dynamic shapes
  • Unsupported: Custom ops, some recent opset additions

Troubleshooting

Unsupported Operator

If import fails with unsupported op:

  1. Check if newer burn-import version supports it
  2. Consider opset conversion (downgrade to supported version)
  3. Implement manually and splice into model

Shape Mismatches

ONNX uses dynamic shapes, Burn uses static:

  1. Check input shapes match expected
  2. Use reshape to convert dynamic to static
  3. Verify batch dimension handling

PyTorch Import

For PyTorch models without ONNX:

  1. Export from PyTorch: torch.onnx.export(model, dummy_input, "model.onnx")
  2. Use ONNX import flow above

Or manual weight loading:

  1. Save PyTorch weights as safetensors
  2. Define matching Burn architecture
  3. Load weights with key remapping

Additional Resources

Consult references/topic-map-onnx.md for:

  • Complete operator coverage list
  • Opset version compatibility
  • Advanced import options
  • Weight remapping patterns

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon