Agent SkillsMicrock/ordinary-claude-skills › add-uint-support

add-uint-support

GitHub

辅助在PyTorch算子中添加无符号整数(uint16/32/64)类型支持,通过更新AT_DISPATCH宏实现。适用于需扩展类型覆盖或显式启用无符号类型的内核开发场景。

skills_all/add-uint-support/SKILL.md Microck/ordinary-claude-skills

Trigger Scenarios

添加uint16, uint32, uint64支持到算子 用户提及unsigned types, uint support, barebones unsigned types 在内核中启用kUInt16, kUInt32, kUInt64

Install

npx skills add Microck/ordinary-claude-skills --skill add-uint-support -g -y
More Options

Non-standard path

npx skills add https://github.com/Microck/ordinary-claude-skills/tree/main/skills_all/add-uint-support -g -y

Use without installing

npx skills use Microck/ordinary-claude-skills@add-uint-support

指定 Agent (Claude Code)

npx skills add Microck/ordinary-claude-skills --skill add-uint-support -a claude-code -g -y

安装 repo 全部 skill

npx skills add Microck/ordinary-claude-skills --all -g -y

预览 repo 内 skill

npx skills add Microck/ordinary-claude-skills --list

SKILL.md

Frontmatter
{
    "name": "add-uint-support",
    "description": "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."
}

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, kUInt64
  • AT_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_TYPES
  • AT_EXPAND(AT_INTEGRAL_TYPES) → signed integers only
  • AT_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_V2 is used → already has uint support
  • If AT_BAREBONES_UNSIGNED_TYPES is already in list → already has uint support
  • Skip the file if uint support is already present

Workflow

When asked to add uint support:

  1. Read the target file
  2. Check if using AT_DISPATCH_V2:
    • If not → use at-dispatch-v2 skill first
  3. Identify all dispatch macro sites
  4. For each dispatch:
    • Analyze current type groups
    • Choose method (add BAREBONES_UNSIGNED or upgrade to V2)
    • Apply transformation with Edit tool
  5. Show the user the changes
  6. 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.

Version History

  • 1056d29 Current 2026-07-24 18:10

Same Skill Collection

skills_all/activitypub-testing/SKILL.md
skills_all/agent-identifier/SKILL.md
skills_all/agentdb-advanced-features/SKILL.md
skills_all/agentdb-learning-plugins/SKILL.md
skills_all/agentdb-memory-patterns/SKILL.md
skills_all/agentdb-performance-optimization/SKILL.md
skills_all/agentdb-vector-search/SKILL.md
skills_all/agile-product-owner/SKILL.md
skills_all/ai-llm-engineering/SKILL.md
skills_all/alex-hormozi-pitch/SKILL.md
skills_all/algorithmic-art/SKILL.md
skills_all/all-traditions-speaking-as-one/SKILL.md
skills_all/alphafold-database/SKILL.md
skills_all/analyzing-agentscope-library/SKILL.md
skills_all/analyzing-financial-statements/SKILL.md
skills_all/andrew-kane-gem-writer/SKILL.md
skills_all/angular-migration/SKILL.md
skills_all/api-design-principles/SKILL.md
skills_all/api-test-generator/SKILL.md
skills_all/applying-brand-guidelines/SKILL.md
skills_all/arboreto/SKILL.md
skills_all/architecture-patterns/SKILL.md
skills_all/archon/SKILL.md
skills_all/artifacts-builder/SKILL.md
skills_all/arxiv-search/SKILL.md
skills_all/astropy/SKILL.md
skills_all/async-python-patterns/SKILL.md
skills_all/at-dispatch-v2/SKILL.md
skills_all/auth-implementation-patterns/SKILL.md
skills_all/awakening-stage-recognition/SKILL.md
skills_all/aws-skills/SKILL.md
skills_all/aws-skills/skills/aws-cdk-development/SKILL.md
skills_all/aws-skills/skills/aws-cost-operations/SKILL.md
skills_all/bap-identity/SKILL.md
skills_all/bash-defensive-patterns/SKILL.md
skills_all/bats-testing-patterns/SKILL.md
skills_all/bd-issue-tracking/SKILL.md
skills_all/benchling-integration/SKILL.md
skills_all/billing-automation/SKILL.md
skills_all/biomni/SKILL.md
skills_all/biorxiv-database/SKILL.md
skills_all/bioservices/SKILL.md
skills_all/bitcoin-auth-diagnostics/SKILL.md
skills_all/blockchain-developer/SKILL.md
skills_all/blog-post-writer/SKILL.md
skills_all/brand-guidelines/SKILL.md
skills_all/brightdata/SKILL.md
skills_all/btc-connect/SKILL.md
skills_all/buck2-rule-basics/SKILL.md

Metadata

Files
0
Version
1056d29
Hash
44f509c1
Indexed
2026-07-24 18:10

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-16 18:13
浙ICP备14020137号-1 $mapa de visitantes$