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.
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Une commande directe contourne le prompt de vérification. Examinez la source avant de l'exécuter.
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:
// BeforeAT_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, , ([&]() {
<>();
}), (AT_INTEGRAL_TYPES_V2), (AT_FLOATING_TYPES));
voidmin_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
}
voidmin_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 operatorAT_DISPATCH_V2(dtype, "float_op", AT_WRAP([&]() {
kernel<scalar_t>();
}), AT_EXPAND(AT_FLOATING_TYPES), kHalf);
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:
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, run repository-defined focused tests and builds proving the operator accepts uint16, uint32, and uint64 tensors. If a required check is unavailable, report exactly what was not run and why.