mcpbeat Sign in

Cortex M Agent Skill

Build, test, or develop the Cortex-M (CMSIS-NN) backend. Use when working on backends/cortex_m/, running Cortex-M tests, or exporting models for Cortex-M targets.

841 tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
4857
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/pytorch/executorch --skill cortex-m

The instruction itself

6 sections, as written by the author

Cortex-M (CMSIS-NN) Backend

Architecture

Not a delegate backend — no partitioner. Custom ops and graph passes replace ATen quantized ops with CMSIS-NN equivalents at the graph level.

Pipeline

Uses standard PT2E quantization (prepare_pt2e / convert_pt2e), then CortexMPassManager rewrites quantized ops to cortex_m:: equivalents.

from executorch.backends.cortex_m.quantizer.quantizer import CortexMQuantizer
from executorch.backends.cortex_m.passes.cortex_m_pass_manager import CortexMPassManager
from torch.export import export
from torchao.quantization.pt2e.quantize_pt2e import convert_pt2e, prepare_pt2e
from executorch.exir import to_edge_transform_and_lower, EdgeCompileConfig

quantizer = CortexMQuantizer()
captured = export(model, example_inputs).module()
prepared = prepare_pt2e(captured, quantizer)
prepared(*example_inputs)  # calibration
quantized = convert_pt2e(prepared)

exported = export(quantized, example_inputs)
edge = to_edge_transform_and_lower(
    exported,
    compile_config=EdgeCompileConfig(_check_ir_validity=False),
)
edge._edge_programs["forward"] = CortexMPassManager(
    edge.exported_program(), CortexMPassManager.pass_list
).transform()
et_program = edge.to_executorch()

In tests, CortexMTester wraps this pipeline:

from executorch.backends.cortex_m.test.tester import CortexMTester

tester = CortexMTester(model, example_inputs)
tester.quantize().export().to_edge().run_passes().to_executorch()

Key Files

| File | Purpose |

|------|---------|

| backends/cortex_m/quantizer/quantizer.py | CortexMQuantizer — quantizes model for CMSIS-NN |

| backends/cortex_m/passes/cortex_m_pass_manager.py | CortexMPassManager — rewrites ATen ops → cortex_m:: ops |

| backends/cortex_m/test/tester.py | CortexMTester — test harness with test_dialect() and test_implementation() |

| backends/cortex_m/ops/operators.py | Python op definitions and reference implementations (cortex_m:: namespace) |

| backends/cortex_m/ops/operators.yaml | C++ kernel registration schemas (used by build system) |

C++ kernels calling CMSIS-NN APIs live under backends/cortex_m/ops/.

Testing

Toolchain setup (required for test_implementation tests):

./examples/arm/setup.sh --i-agree-to-the-contained-eula
source ./examples/arm/arm-scratch/setup_path.sh

Run all tests:

source ./examples/arm/arm-scratch/setup_path.sh
pytest backends/cortex_m/test/

test_dialect_* tests verify graph correctness (pure Python, no toolchain needed).

test_implementation_* tests verify numerical accuracy on the Corstone-300 FVP (requires toolchain on PATH).

Baremetal build:

backends/cortex_m/test/build_test_runner.sh

Adding a New Op

  • Define the op schema, meta function, and reference implementation in operators.py
  • Write the C++ kernel in backends/cortex_m/ops/ calling CMSIS-NN APIs
  • Register the .out kernel in operators.yaml
  • Add a pass to rewrite the ATen op → cortex_m:: op
  • Test with CortexMTester.test_dialect() (graph correctness) and test_implementation() (numerical accuracy on FVP)

Other skills for the same job

different authors, same section of the catalogue
Protocolsio Integration
by christophacham
×4

Integration with protocols.io API for managing scientific protocols. This skill should be used when working with protocols.io to search, create, update, or publish protocols; manage protocol steps and materials; handle discussions and comments; organize workspaces; upload and manage files; or integrate protocols.io functionality into workflows. Applicable for protocol discovery, collaborative protocol development, experiment tracking, lab protocol management, and scientific documentation.

16k tokens
Tailored Resume Generator
by frostant
×4

Analyzes job descriptions and generates tailored resumes that highlight relevant experience, skills, and achievements to maximize interview chances

3k tokens
Excalidraw Diagram Generator
by github
vendor ×3

Generate Excalidraw diagrams from natural language descriptions. Use when asked to "create a diagram", "make a flowchart", "visualize a process", "draw a system architecture", "create a mind map", or "generate an Excalidraw file". Supports flowcharts, relationship diagrams, mind maps, and system architecture diagrams. Outputs .excalidraw JSON files that can be opened directly in Excalidraw.

36k tokens scripts
Expo Dev Client
by openai
vendor ×3

Build and distribute Expo development clients locally or via TestFlight

961 tokens
Executing Plans
by ZhanlinCui
×3

Use when you have a written implementation plan to execute in a separate session with review checkpoints

542 tokens
Anndata
by christophacham
×3

Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.

16k tokens
Benchling Integration
by christophacham
×3

Benchling R&D platform integration. Access registry (DNA, proteins), inventory, ELN entries, workflows via API, build Benchling Apps, query Data Warehouse, for lab data management automation.

14k tokens
Biopython
by christophacham
×3

Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.

24k tokens

How to use it

Copy the folder

Take pytorch/cortex-m from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.