Agent skill · software engineering · aiskillstore
at-dispatch-v2
Convert PyTorch AT_DISPATCH macros to AT_DISPATCH_V2 format in ATen C++ code. Use when porting AT_DISPATCH_ALL_TYPES_AND*, AT_DISPATCH_FLOATING_TYPES*, or other dispatch macros to the new v2 API. For ATen kernel files, CUDA kernels, and native operator implementations.
Why this skill is useful
Provides specific transformation patterns and examples for converting legacy PyTorch dispatch macros to the new v2 API, which the AI wouldn't reliably generate on its own.
What it needs
About 4k tokens when loaded. Last updated 2026-08-07. 405 stars on the source repository.
What this skill does
ATDISPATCH to ATDISPATCHV2 Converter This skill helps convert PyTorch's legacy ATDISPATCH macros to the new ATDISPATCHV2 format, as defined in aten/src/ATen/Dispatchv2.h. When to use this skill Use this skill when: Converting ATDISPATCH macros to ATDISPATCHV2 Porting ATen kernels to use the new dispatch API Working with files in aten/src/ATen/native/ that use dispatch macros User mentions "ATDISPATCH", "dispatch v2", "Dispatchv2.h", or macro conversion Quick reference Old format: New format: Key transformations 1. Reorder arguments: scalartype and name come first, then lambda, then types 2. Wrap the lambda: Use ATWRAP(lambda) to handle internal commas 3. Expand type groups: Use ATEXPAND(ATALLTYPES) instead of implicit expansion 4. List individual types: Add extra types (kHalf, kBFloat16, etc.) after expanded groups 5. Add include: #include <ATen/Dispatchv2.h> near other Dispatch includes Instructions Step 1: Add the Dispatchv2.h include Add the v2 header near the existing #include <ATen/Dispatch.h>: Keep the old Dispatch.h include for now (other code may still need it). Step 2: Identify the old dispatch pattern Common patterns to convert: ATDISPATCHALLTYPESAND{2,3,4}(type1, type2, ..., scalartype, name, lambda) ATDISPATCHFLOATINGTYPESAND{2,3}(type1, type2, ..., scalartype, name, lambda) ATDISPATCHALLTYPESANDCOMPLEXAND{2,3}(type1, ..., scalartype, name, lambda) ATDISPATCHFLOATINGANDCOMPLEXTYPESAND{2,3}(type1, ..., scalartype, name, lambda) Step 3: Map the old macro to type groups Identify which type group macro corresponds to the base types: Old macro base ATDISPATCHV2 type group ---------------- --------------------------- ALLTYPES ATEXPAND(ATALLTYPES) FLOATINGTYPES ATEXPAND(ATFLOATINGTYPES) INTEGRALTYPES ATEXPAND(ATINTEGRALTYPES) COMPLEXTYPES ATEXPAND(ATCOMPLEXTYPES) ALLTYPESANDCOMPLEX ATEXPAND(ATALLTYPESANDCOMPLEX) For combined patterns, use multiple ATEXPAND() entries: Step 4: Extract the individual types From ATDISPATCHAND2(type1, type2, ...) or ATDISPATCHAND3(t …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills aiskillstore/at-dispatch-v2