add-uint-support
Add unsigned integer (uint) type support to PyTorch operators by updating AT_DISPATCH macros. Use when adding support for uint16, uint32, uint64 types to operators, kernels, or when user mentions enabling unsigned types, barebones unsigned types, or uint support.
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o add-uint-support.zip https://jpskill.com/download/19804.zip && unzip -o add-uint-support.zip && rm add-uint-support.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/19804.zip -OutFile "$d\add-uint-support.zip"; Expand-Archive "$d\add-uint-support.zip" -DestinationPath $d -Force; ri "$d\add-uint-support.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
add-uint-support.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
add-uint-supportフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
演算子への符号なし整数 (uint) サポートの追加
このスキルは、PyTorch 演算子に符号なし整数型 (uint16, uint32, uint64) のサポートを追加するために、AT_DISPATCH マクロを更新するのに役立ちます。
このスキルを使用するタイミング
このスキルは、次の場合に使用してください。
- 演算子に uint16、uint32、または uint64 のサポートを追加する場合
- ユーザーが「unsigned types」、「uint support」、「barebones unsigned types」について言及している場合
- カーネルで kUInt16、kUInt32、kUInt64 のサポートを有効にする場合
- 型の適用範囲を拡大する必要がある演算子の実装を扱っている場合
クイックリファレンス
既存のディスパッチに符号なし型を追加する:
// Before
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_ALL_TYPES));
// After (方法 1: 符号なし型を明示的に追加)
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_ALL_TYPES), AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES));
// After (方法 2: AT_INTEGRAL_TYPES が存在する場合、V2 整数型を使用)
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_INTEGRAL_TYPES_V2), AT_EXPAND(AT_FLOATING_TYPES));
型グループのリファレンス
符号なし型グループ:
AT_BAREBONES_UNSIGNED_TYPES: kUInt16, kUInt32, kUInt64AT_INTEGRAL_TYPES_V2: AT_INTEGRAL_TYPES + AT_BAREBONES_UNSIGNED_TYPES
関係:
AT_INTEGRAL_TYPES // kByte, kChar, kInt, kLong, kShort
AT_BAREBONES_UNSIGNED_TYPES // kUInt16, kUInt32, kUInt64
AT_INTEGRAL_TYPES_V2 // INTEGRAL_TYPES + BAREBONES_UNSIGNED_TYPES
手順
ステップ 1: V2 への変換が必要かどうかを判断する
ファイルが AT_DISPATCH_V2 を使用しているかどうかを確認します。
古い AT_DISPATCH を使用している場合:
- まず、at-dispatch-v2 スキルを使用して AT_DISPATCH_V2 に変換します。
- その後、uint サポートの追加に進みます。
すでに AT_DISPATCH_V2 を使用している場合:
- 直接ステップ 2 に進みます。
ステップ 2: 現在のディスパッチマクロを分析する
現在使用されている型グループを特定します。
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
// body
}), AT_EXPAND(AT_ALL_TYPES), kHalf, kBFloat16);
^^^^^^^^^^^^^^^^^^^^^^^^^
現在の型適用範囲
一般的なパターン:
AT_EXPAND(AT_ALL_TYPES)→ AT_INTEGRAL_TYPES + AT_FLOATING_TYPES を含むAT_EXPAND(AT_INTEGRAL_TYPES)→ 符号付き整数のみAT_EXPAND(AT_FLOATING_TYPES)→ 浮動小数点型
ステップ 3: uint 追加方法を選択する
2 つのアプローチがあります。
方法 1: AT_BAREBONES_UNSIGNED_TYPES を明示的に追加する
- 使用する場合: uint サポートの追加を明示的にしたい場合
- 型リストに
AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES)を追加します。
方法 2: AT_INTEGRAL_TYPES を AT_INTEGRAL_TYPES_V2 に置き換える
- 使用する場合: ディスパッチがすでに
AT_EXPAND(AT_INTEGRAL_TYPES)を使用している場合 - より簡潔: 1 つの型グループをそのスーパーセットに置き換えます。
- AT_INTEGRAL_TYPES が存在する場合にのみ適用可能です。
ステップ 4: 変換を適用する
方法 1 の例:
// Before
AT_DISPATCH_V2(
dtype,
"min_values_cuda",
AT_WRAP([&]() {
kernel_impl<scalar_t>(iter);
}),
AT_EXPAND(AT_ALL_TYPES),
kBFloat16, kHalf, kBool
);
// After (符号なし型を追加)
AT_DISPATCH_V2(
dtype,
"min_values_cuda",
AT_WRAP([&]() {
kernel_impl<scalar_t>(iter);
}),
AT_EXPAND(AT_ALL_TYPES),
AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES),
kBFloat16, kHalf, kBool
);
方法 2 の例:
// Before
AT_DISPATCH_V2(
dtype,
"integral_op",
AT_WRAP([&]() {
kernel<scalar_t>();
}),
AT_EXPAND(AT_INTEGRAL_TYPES)
);
// After (V2 に置き換え)
AT_DISPATCH_V2(
dtype,
"integral_op",
AT_WRAP([&]() {
kernel<scalar_t>();
}),
AT_EXPAND(AT_INTEGRAL_TYPES_V2)
);
ステップ 5: AT_ALL_TYPES と個々の型グループのどちらを処理するか
ディスパッチが AT_EXPAND(AT_ALL_TYPES) を使用している場合:
AT_ALL_TYPES=AT_INTEGRAL_TYPES+AT_FLOATING_TYPES- uint を追加するには: リストに
AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES)を追加します。
ディスパッチが INTEGRAL と FLOATING を個別にリストしている場合:
// Before
AT_EXPAND(AT_INTEGRAL_TYPES), AT_EXPAND(AT_FLOATING_TYPES)
// After (方法 2 が推奨)
AT_EXPAND(AT_INTEGRAL_TYPES_V2), AT_EXPAND(AT_FLOATING_TYPES)
ステップ 6: すべてのディスパッチサイトを確認する
uint サポートが必要なすべてのディスパッチマクロについてファイルを確認します。
- 一部の演算子には複数のディスパッチサイト (CPU、CUDA、異なる関数) があります。
- すべてのサイトで変換を一貫して適用します。
- それぞれが同じ型適用範囲の更新を受け取るようにします。
ステップ 7: 変更を検証する
以下を確認してください。
- [ ] AT_DISPATCH_V2 形式が使用されていること (古い AT_DISPATCH ではないこと)
- [ ] 符号なし型が 2 つの方法のいずれかで追加されていること
- [ ] ファイル内のすべての関連するディスパッチサイトが更新されていること
- [ ] 型グループが
AT_EXPAND()を使用していること - [ ] 引数が適切にフォーマットされ、カンマで区切られていること
一般的なパターン
パターン 1: AT_ALL_TYPES + 追加
// Before
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_ALL_TYPES), kHalf, kBFloat16);
// After
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_ALL_TYPES), AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES), kHalf, kBFloat16);
パターン 2: INTEGRAL + FLOATING を分離
// Before
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_INTEGRAL_TYPES), AT_EXPAND(AT_FLOATING_TYPES));
// After
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_INTEGRAL_TYPES_V2), AT_EXPAND(AT_FLOATING_TYPES));
パターン 3: 古いディスパッチは最初に変換が必要
// Before (最初に v2 変換が必要)
AT_DISPATCH_ALL_TYPES_AND2(kHalf, kBFloat16, dtype, "op", [&]() {
kernel<scalar_t>();
});
// v2 変換後
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_ALL_TYPES), kHalf, kBFloat16);
// uint サポート追加後
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_ALL_TYPES), AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES), kHalf, kBFloat16);
複数のディスパッチサイトの例
複数の関数を持つファイルの場合:
// (原文がここで切り詰められています) 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Add Unsigned Integer (uint) Support to Operators
This skill helps add support for unsigned integer types (uint16, uint32, uint64) to PyTorch operators by updating their AT_DISPATCH macros.
When to use this skill
Use this skill when:
- Adding uint16, uint32, or uint64 support to an operator
- User mentions "unsigned types", "uint support", "barebones unsigned types"
- Enabling support for kUInt16, kUInt32, kUInt64 in kernels
- Working with operator implementations that need expanded type coverage
Quick reference
Add unsigned types to existing dispatch:
// Before
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_ALL_TYPES));
// After (method 1: add unsigned types explicitly)
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_ALL_TYPES), AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES));
// After (method 2: use V2 integral types if AT_INTEGRAL_TYPES present)
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_INTEGRAL_TYPES_V2), AT_EXPAND(AT_FLOATING_TYPES));
Type group reference
Unsigned type groups:
AT_BAREBONES_UNSIGNED_TYPES: kUInt16, kUInt32, kUInt64AT_INTEGRAL_TYPES_V2: AT_INTEGRAL_TYPES + AT_BAREBONES_UNSIGNED_TYPES
Relationship:
AT_INTEGRAL_TYPES // kByte, kChar, kInt, kLong, kShort
AT_BAREBONES_UNSIGNED_TYPES // kUInt16, kUInt32, kUInt64
AT_INTEGRAL_TYPES_V2 // INTEGRAL_TYPES + BAREBONES_UNSIGNED_TYPES
Instructions
Step 1: Determine if conversion to V2 is needed
Check if the file uses AT_DISPATCH_V2:
If using old AT_DISPATCH:
- First convert to AT_DISPATCH_V2 using the at-dispatch-v2 skill
- Then proceed with adding uint support
If already using AT_DISPATCH_V2:
- Proceed directly to Step 2
Step 2: Analyze the current dispatch macro
Identify what type groups are currently in use:
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
// body
}), AT_EXPAND(AT_ALL_TYPES), kHalf, kBFloat16);
^^^^^^^^^^^^^^^^^^^^^^^^^
Current type coverage
Common patterns:
AT_EXPAND(AT_ALL_TYPES)→ includes AT_INTEGRAL_TYPES + AT_FLOATING_TYPESAT_EXPAND(AT_INTEGRAL_TYPES)→ signed integers onlyAT_EXPAND(AT_FLOATING_TYPES)→ floating point types
Step 3: Choose the uint addition method
Two approaches:
Method 1: Add AT_BAREBONES_UNSIGNED_TYPES explicitly
- Use when: You want to be explicit about adding uint support
- Add
AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES)to the type list
Method 2: Substitute AT_INTEGRAL_TYPES with AT_INTEGRAL_TYPES_V2
- Use when: The dispatch already uses
AT_EXPAND(AT_INTEGRAL_TYPES) - More concise: replaces one type group with its superset
- Only applicable if AT_INTEGRAL_TYPES is present
Step 4: Apply the transformation
Method 1 example:
// Before
AT_DISPATCH_V2(
dtype,
"min_values_cuda",
AT_WRAP([&]() {
kernel_impl<scalar_t>(iter);
}),
AT_EXPAND(AT_ALL_TYPES),
kBFloat16, kHalf, kBool
);
// After (add unsigned types)
AT_DISPATCH_V2(
dtype,
"min_values_cuda",
AT_WRAP([&]() {
kernel_impl<scalar_t>(iter);
}),
AT_EXPAND(AT_ALL_TYPES),
AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES),
kBFloat16, kHalf, kBool
);
Method 2 example:
// Before
AT_DISPATCH_V2(
dtype,
"integral_op",
AT_WRAP([&]() {
kernel<scalar_t>();
}),
AT_EXPAND(AT_INTEGRAL_TYPES)
);
// After (substitute with V2)
AT_DISPATCH_V2(
dtype,
"integral_op",
AT_WRAP([&]() {
kernel<scalar_t>();
}),
AT_EXPAND(AT_INTEGRAL_TYPES_V2)
);
Step 5: Handle AT_ALL_TYPES vs individual type groups
If the dispatch uses AT_EXPAND(AT_ALL_TYPES):
AT_ALL_TYPES=AT_INTEGRAL_TYPES+AT_FLOATING_TYPES- To add uint: add
AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES)to the list
If the dispatch separately lists INTEGRAL and FLOATING:
// Before
AT_EXPAND(AT_INTEGRAL_TYPES), AT_EXPAND(AT_FLOATING_TYPES)
// After (Method 2 preferred)
AT_EXPAND(AT_INTEGRAL_TYPES_V2), AT_EXPAND(AT_FLOATING_TYPES)
Step 6: Verify all dispatch sites
Check the file for ALL dispatch macros that need uint support:
- Some operators have multiple dispatch sites (CPU, CUDA, different functions)
- Apply the transformation consistently across all sites
- Ensure each gets the same type coverage updates
Step 7: Validate the changes
Check that:
- [ ] AT_DISPATCH_V2 format is used (not old AT_DISPATCH)
- [ ] Unsigned types are added via one of the two methods
- [ ] All relevant dispatch sites in the file are updated
- [ ] Type groups use
AT_EXPAND() - [ ] Arguments are properly formatted and comma-separated
Common patterns
Pattern 1: AT_ALL_TYPES + extras
// Before
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_ALL_TYPES), kHalf, kBFloat16);
// After
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_ALL_TYPES), AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES), kHalf, kBFloat16);
Pattern 2: Separate INTEGRAL + FLOATING
// Before
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_INTEGRAL_TYPES), AT_EXPAND(AT_FLOATING_TYPES));
// After
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_INTEGRAL_TYPES_V2), AT_EXPAND(AT_FLOATING_TYPES));
Pattern 3: Old dispatch needs conversion first
// Before (needs v2 conversion first)
AT_DISPATCH_ALL_TYPES_AND2(kHalf, kBFloat16, dtype, "op", [&]() {
kernel<scalar_t>();
});
// After v2 conversion
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_ALL_TYPES), kHalf, kBFloat16);
// After adding uint support
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_ALL_TYPES), AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES), kHalf, kBFloat16);
Multiple dispatch sites example
For a file with multiple functions:
void min_values_kernel_cuda(TensorIterator& iter) {
AT_DISPATCH_V2(iter.dtype(), "min_values_cuda", AT_WRAP([&]() {
impl<scalar_t>(iter);
}), AT_EXPAND(AT_ALL_TYPES), AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES), kBFloat16, kHalf);
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Added uint support
}
void min_launch_kernel(TensorIterator &iter) {
AT_DISPATCH_V2(iter.input_dtype(), "min_cuda", AT_WRAP([&]() {
gpu_reduce_kernel<scalar_t>(iter);
}), AT_EXPAND(AT_ALL_TYPES), AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES), kBFloat16, kHalf);
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Added uint support here too
}
Decision tree
Use this decision tree to determine the approach:
Is the file using AT_DISPATCH_V2?
├─ No → Use at-dispatch-v2 skill first, then continue
└─ Yes
└─ Does it use AT_EXPAND(AT_INTEGRAL_TYPES)?
├─ Yes → Replace with AT_EXPAND(AT_INTEGRAL_TYPES_V2)
└─ No → Add AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES) to type list
Edge cases
Case 1: Dispatch with only floating types
If the operator only supports floating point types, don't add uint support:
// Leave as-is - floating point only operator
AT_DISPATCH_V2(dtype, "float_op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_FLOATING_TYPES), kHalf);
Case 2: Complex types present
Unsigned types work alongside complex types:
AT_DISPATCH_V2(dtype, "op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_ALL_TYPES),
AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES),
AT_EXPAND(AT_COMPLEX_TYPES),
kHalf, kBFloat16);
Case 3: Already has uint support
Check if uint types are already present:
- If
AT_INTEGRAL_TYPES_V2is used → already has uint support - If
AT_BAREBONES_UNSIGNED_TYPESis already in list → already has uint support - Skip the file if uint support is already present
Workflow
When asked to add uint support:
- Read the target file
- Check if using AT_DISPATCH_V2:
- If not → use at-dispatch-v2 skill first
- Identify all dispatch macro sites
- For each dispatch:
- Analyze current type groups
- Choose method (add BAREBONES_UNSIGNED or upgrade to V2)
- Apply transformation with Edit tool
- Show the user the changes
- Explain what was modified
Important notes
- Always check if v2 conversion is needed first
- Apply changes consistently across all dispatch sites in the file
- Method 2 (AT_INTEGRAL_TYPES_V2) is cleaner when applicable
- Method 1 (explicit AT_BAREBONES_UNSIGNED_TYPES) is more explicit
- Unsigned types are: kUInt16, kUInt32, kUInt64 (not kByte which is uint8)
- Some operators may not semantically support unsigned types - use judgment
Testing
After adding uint support, the operator should accept uint16, uint32, and uint64 tensors. The user is responsible for functional testing.