无符号整数支持_add-uint-support
以下为本文档的中文说明该技能专门用于为PyTorch算子添加无符号整数uint类型支持通过更新AT_DISPATCH宏来实现。其核心问题是PyTorch中许多算子默认只支持有符号整数和有符号浮点类型当用户需要使用uint16、uint32、uint64类型时需要手动扩展这些算子的类型覆盖范围。此技能提供了一种系统化的方法来完成这项工作。使用场景包括为现有的算子添加uint类型支持、用户提到需要“unsigned types”或“uint support”时、启用kUInt16/kUInt32/kUInt64在内核中的支持、以及处理需要扩展类型覆盖范围的算子实现。技能的核心方法是在AT_DISPATCH_V2宏中添加AT_EXPAND(AT_ALL_TYPES_AND_UINT)或者使用AT_EXPAND(AT_UINT_TYPES)来专门添加无符号整数类型。技能还提供了两种扩展策略一种是在现有调度上追加uint类型另一种是为uint类型创建专门的分支调度。此外技能还涵盖了如何处理不同uint类型之间的转换、如何在CUDA内核中正确处理uint类型的数学运算以及如何编写测试来验证新添加的uint支持是否正确。该技能将PyTorch内部类型系统的复杂知识简化为一套清晰的步骤是PyTorch贡献者和内部开发者的实用工具。Add Unsigned Integer (uint) Support to OperatorsThis skill helps add support for unsigned integer types (uint16, uint32, uint64) to PyTorch operators by updating their AT_DISPATCH macros.When to use this skillUse this skill when:Adding uint16, uint32, or uint64 support to an operatorUser mentions “unsigned types”, “uint support”, “barebones unsigned types”Enabling support for kUInt16, kUInt32, kUInt64 in kernelsWorking with operator implementations that need expanded type coverageQuick referenceAdd unsigned types to existing dispatch:// BeforeAT_DISPATCH_V2(dtype,op,AT_WRAP([](){kernelscalar_t();}),AT_EXPAND(AT_ALL_TYPES));// After (method 1: add unsigned types explicitly)AT_DISPATCH_V2(dtype,op,AT_WRAP([](){kernelscalar_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([](){kernelscalar_t();}),AT_EXPAND(AT_INTEGRAL_TYPES_V2),AT_EXPAND(AT_FLOATING_TYPES));Type group referenceUnsigned type groups:AT_BAREBONES_UNSIGNED_TYPES: kUInt16, kUInt32, kUInt64AT_INTEGRAL_TYPES_V2: AT_INTEGRAL_TYPES AT_BAREBONES_UNSIGNED_TYPESRelationship:AT_INTEGRAL_TYPES// kByte, kChar, kInt, kLong, kShortAT_BAREBONES_UNSIGNED_TYPES// kUInt16, kUInt32, kUInt64AT_INTEGRAL_TYPES_V2// INTEGRAL_TYPES BAREBONES_UNSIGNED_TYPESInstructionsStep 1: Determine if conversion to V2 is neededCheck if the file uses AT_DISPATCH_V2:If using old AT_DISPATCH:First convert to AT_DISPATCH_V2 using the at-dispatch-v2 skillThen proceed with adding uint supportIf already using AT_DISPATCH_V2:Proceed directly to Step 2Step 2: Analyze the current dispatch macroIdentify what type groups are currently in use:AT_DISPATCH_V2(dtype,op,AT_WRAP([](){// body}),AT_EXPAND(AT_ALL_TYPES),kHalf,kBFloat16);^^^^^^^^^^^^^^^^^^^^^^^^^Current type coverageCommon 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 typesStep 3: Choose the uint addition methodTwo approaches:Method 1: Add AT_BAREBONES_UNSIGNED_TYPES explicitlyUse when: You want to be explicit about adding uint supportAddAT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES)to the type listMethod 2: Substitute AT_INTEGRAL_TYPES with AT_INTEGRAL_TYPES_V2Use when: The dispatch already usesAT_EXPAND(AT_INTEGRAL_TYPES)More concise: replaces one type group with its supersetOnly applicable if AT_INTEGRAL_TYPES is presentStep 4: Apply the transformationMethod 1 example:// BeforeAT_DISPATCH_V2(dtype,min_values_cuda,AT_WRAP([](){kernel_implscalar_t(iter);}),AT_EXPAND(AT_ALL_TYPES),kBFloat16,kHalf,kBool);// After (add unsigned types)AT_DISPATCH_V2(dtype,min_values_cuda,AT_WRAP([](){kernel_implscalar_t(iter);}),AT_EXPAND(AT_ALL_TYPES),AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES),kBFloat16,kHalf,kBool);Method 2 example:// BeforeAT_DISPATCH_V2(dtype,integral_op,AT_WRAP([](){kernelscalar_t();}),AT_EXPAND(AT_INTEGRAL_TYPES));// After (substitute with V2)AT_DISPATCH_V2(dtype,integral_op,AT_WRAP([](){kernelscalar_t();}),AT_EXPAND(AT_INTEGRAL_TYPES_V2));Step 5: Handle AT_ALL_TYPES vs individual type groupsIf the dispatch usesAT_EXPAND(AT_ALL_TYPES):AT_ALL_TYPESAT_INTEGRAL_TYPESAT_FLOATING_TYPESTo add uint: addAT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES)to the listIf the dispatch separately lists INTEGRAL and FLOATING:// BeforeAT_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 sitesCheck 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 sitesEnsure each gets the same type coverage updatesStep 7: Validate the changesCheck that:AT_DISPATCH_V2 format is used (not old AT_DISPATCH)Unsigned types are added via one of the two methodsAll relevant dispatch sites in the file are updatedType groups useAT_EXPAND()Arguments are properly formatted and comma-separatedCommon patternsPattern 1: AT_ALL_TYPES extras// BeforeAT_DISPATCH_V2(dtype,op,AT_WRAP([](){kernelscalar_t();}),AT_EXPAND(AT_ALL_TYPES),kHalf,kBFloat16);// AfterAT_DISPATCH_V2(dtype,op,AT_WRAP([](){kernelscalar_t();}),AT_EXPAND(AT_ALL_TYPES),AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES),kHalf,kBFloat16);Pattern 2: Separate INTEGRAL FLOATING// BeforeAT_DISPATCH_V2(dtype,op,AT_WRAP([](){kernelscalar_t();}),AT_EXPAND(AT_INTEGRAL_TYPES),AT_EXPAND(AT_FLOATING_TYPES));// AfterAT_DISPATCH_V2(dtype,op,AT_WRAP([](){kernelscalar_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,[](){kernelscalar_t();});// After v2 conversionAT_DISPATCH_V2(dtype,op,AT_WRAP([](){kernelscalar_t();}),AT_EXPAND(AT_ALL_TYPES),kHalf,kBFloat16);// After adding uint supportAT_DISPATCH_V2(dtype,op,AT_WRAP([](){kernelscalar_t();}),AT_EXPAND(AT_ALL_TYPES),AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES),kHalf,kBFloat16);Multiple dispatch sites exampleFor a file with multiple functions:voidmin_values_kernel_cuda(TensorIteratoriter){AT_DISPATCH_V2(iter.dtype(),min_values_cuda,AT_WRAP([](){implscalar_t(iter);}),AT_EXPAND(AT_ALL_TYPES),AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES),kBFloat16,kHalf);// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^// Added uint support}voidmin_launch_kernel(TensorIteratoriter){AT_DISPATCH_V2(iter.input_dtype(),min_cuda,AT_WRAP([](){gpu_reduce_kernelscalar_t(iter);}),AT_EXPAND(AT_ALL_TYPES),AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES),kBFloat16,kHalf);// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^// Added uint support here too}Decision treeUse 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 listEdge casesCase 1: Dispatch with only floating typesIf 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([](){kernelscalar_t();}),AT_EXPAND(AT_FLOATING_TYPES),kHalf);Case 2: Complex types presentUnsigned types work alongside complex types:AT_DISPATCH_V2(dtype,op,AT_WRAP([](){kernelscalar_t();}),AT_EXPAND(AT_ALL_TYPES),AT_EXPAND(AT_BAREBONES_UNSIGNED_TYPES),AT_EXPAND(AT_COMPLEX_TYPES),kHalf,kBFloat16);Case 3: Already has uint supportCheck if uint types are already present:IfAT_INTEGRAL_TYPES_V2is used → already has uint supportIfAT_BAREBONES_UNSIGNED_TYPESis already in list → already has uint supportSkip the file if uint support is already presentWorkflowWhen asked to add uint support:Read the target fileCheck if using AT_DISPATCH_V2:If not → use at-dispatch-v2 skill firstIdentify all dispatch macro sitesFor each dispatch:Analyze current type groupsChoose method (add BAREBONES_UNSIGNED or upgrade to V2)Apply transformation with Edit toolShow the user the changesExplain what was modifiedImportant notesAlways check if v2 conversion is needed firstApply changes consistently across all dispatch sites in the fileMethod 2 (AT_INTEGRAL_TYPES_V2) is cleaner when applicableMethod 1 (explicit AT_BAREBONES_UNSIGNED_TYPES) is more explicitUnsigned types are: kUInt16, kUInt32, kUInt64 (not kByte which is uint8)Some operators may not semantically support unsigned types - use judgmentTestingAfter adding uint support, the operator should accept uint16, uint32, and uint64 tensors. The user is responsible for functional testing.3e:[“,,,L41”,null,{“content”:“$42”,“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.”}}]3f:[“KaTeX parse error: Expected }, got EOF at end of input: …,children:[[”,“div”,null,{“className”:“flex items-center justify-between border-b border-border bg-muted/30 px-4 py-2.5”,“children”:[[“KaTeX parse error: Expected }, got EOF at end of input: …,children:[”,“span”,null,{“className”:“truncate text-xs font-medium text-muted-foreground”,“children”:“同仓库更多 Skills”}]}],[“KaTeX parse error: Expected EOF, got } at position 88: …ldren:同仓库}]]}̲],[”,“div”,null,{“className”:“p-4 sm:p-5”,“children”:[[“,h2,null,id:related−skills−heading,className:text−2xlfont−semiboldtracking−normaltext−foreground,children:同仓库更多Skills],[,h2,null,{id:related-skills-heading,className:text-2xl font-semibold tracking-normal text-foreground,children:同仓库更多 Skills}],[,h2,null,id:related−skills−heading,className:text−2xlfont−semiboldtracking−normaltext−foreground,children:同仓库更多Skills],[”,“div”,null,{“className”:“mt-4 grid gap-3 sm:grid-cols-2”,“children”:[“L43,L43,L43,L44”,“L45,L45,L45,L46”,“L47,L47,L47,L48”]}]]}]]}]49:I[206516,[“/_next/static/chunks/051aanbhrv4br.js”,“/_next/static/chunks/0mizr60h7ayzt.js”,“/_next/static/chunks/0v9lm1dmbdoo-.js”,“/_next/static/chunks/0rxr1j1j3j-.r.js”,“/_next/static/chunks/02ftybezfvqjd.js”,“/_next/static/chunks/0.v9ksvnnj8ia.js”,“/_next/static/chunks/0bn6id96nx3k.js,“/_next/static/chunks/13ybnhn37c.tc.js”,“/_next/static/chunks/0_fnrdtruz8uf.js”,“/_next/static/chunks/0r6l15utt1mwb.js”,“/_next/static/chunks/0dm9a5into854.js”,/_next/static/chunks/07k6hqoibtcn.js”,“/next/static/chunks/0b4cao.4y…j.js”,“/_next/static/chunks/02i-n28z7kjd0.js”],“default”]

相关新闻

红队测试插件开发_redteam-plugin-development

红队测试插件开发_redteam-plugin-development

以下为本文档的中文说明该技能用于开发Promptfoo红队测试插件,帮助安全团队对AI应用进行对抗性测试。它支持自定义测试策略、注入攻击模拟、输出评估和报告生成。Promptfoo是一个AI安全评估框架,此技能扩展其红队测试能力,适用于需要系统性评…

2026/7/6 14:57:50 阅读更多 →
消息列表虚拟滚动_message-list

消息列表虚拟滚动_message-list

以下为本文档的中文说明Message List 技能是一个占位符状态的待开发工具,未来将为 virtuoso.dev/message-list 包提供代理指导。当前阶段,该技能的内容编写尚未完成,仅作为技能目录中的一个条目存在,标记了后续编写计划的参考文档…

2026/7/6 14:57:50 阅读更多 →
47_AI短片实战第二十弹:AIGCAI视频生成全流程实战(第十一部分):动态增强、镜头重组与剪辑软件核心设置

47_AI短片实战第二十弹:AIGCAI视频生成全流程实战(第十一部分):动态增强、镜头重组与剪辑软件核心设置

剪辑进入最终冲刺。本节课将解决两个常见问题:画面静止缺乏运动感和镜头叙事逻辑不顺。你将学到:如何用震动/动态效果拯救呆板镜头、何时果断停用“鸡肋”素材、如何通过复合片段二次变速控制怪兽奔跑冲击力、以及剪辑软件中“磁吸”“联动”等设置对效率的影响。 一、解决“…

2026/7/6 14:55:47 阅读更多 →

最新新闻

Fashion-MNIST实战指南:从传统MNIST到现代计算机视觉的进阶之路

Fashion-MNIST实战指南:从传统MNIST到现代计算机视觉的进阶之路

Fashion-MNIST实战指南:从传统MNIST到现代计算机视觉的进阶之路 【免费下载链接】fashion-mnist A MNIST-like fashion product database. Benchmark :point_down: 项目地址: https://gitcode.com/gh_mirrors/fa/fashion-mnist 在机器学习的演进历程中&…

2026/7/6 15:48:45 阅读更多 →
深度解析Marp插件开发:5大进阶实战技巧与架构设计指南

深度解析Marp插件开发:5大进阶实战技巧与架构设计指南

深度解析Marp插件开发:5大进阶实战技巧与架构设计指南 【免费下载链接】marp The entrance repository of Markdown presentation ecosystem 项目地址: https://gitcode.com/gh_mirrors/mar/marp Marp作为现代化的Markdown演示文稿生态系统,为开发…

2026/7/6 15:48:45 阅读更多 →
Lightpanda:9倍内存效率的革命性无头浏览器,专为AI时代打造

Lightpanda:9倍内存效率的革命性无头浏览器,专为AI时代打造

Lightpanda:9倍内存效率的革命性无头浏览器,专为AI时代打造 【免费下载链接】browser Lightpanda: the headless browser designed for AI and automation 项目地址: https://gitcode.com/GitHub_Trending/browser32/browser 在AI代理、自动化测试…

2026/7/6 15:46:42 阅读更多 →
如何在3分钟内用Open-Sora免费创作专业级AI视频:完整指南

如何在3分钟内用Open-Sora免费创作专业级AI视频:完整指南

如何在3分钟内用Open-Sora免费创作专业级AI视频:完整指南 【免费下载链接】Open-Sora Open-Sora: Democratizing Efficient Video Production for All 项目地址: https://gitcode.com/GitHub_Trending/op/Open-Sora 想象一下,只需输入几个简单的文…

2026/7/6 15:44:40 阅读更多 →
如何将闲置USB-C显示屏变身高颜值系统监控中心?

如何将闲置USB-C显示屏变身高颜值系统监控中心?

如何将闲置USB-C显示屏变身高颜值系统监控中心? 【免费下载链接】turing-smart-screen-python Unofficial Python system monitor and library for small IPS USB-C displays like Turing Smart Screen / TURZX 项目地址: https://gitcode.com/GitHub_Trending/tu…

2026/7/6 15:44:40 阅读更多 →
SVG Gobbler:矢量资源管理的终极解决方案,彻底改变你的设计工作流

SVG Gobbler:矢量资源管理的终极解决方案,彻底改变你的设计工作流

SVG Gobbler:矢量资源管理的终极解决方案,彻底改变你的设计工作流 【免费下载链接】svg-gobbler Open source browser extension for finding, editing, exporting, optimizing, and managing SVG content. 项目地址: https://gitcode.com/gh_mirrors/…

2026/7/6 15:42:36 阅读更多 →

日新闻

H2 与 MySQL 单元测试兼容性:5 个关键 SQL 语句差异与规避方案

H2 与 MySQL 单元测试兼容性:5 个关键 SQL 语句差异与规避方案

H2与MySQL单元测试兼容性:5个关键SQL语句差异与规避方案1. 单元测试中的数据库兼容性挑战在Java开发领域,单元测试是保证代码质量的重要环节。当应用涉及数据库操作时,测试环境的搭建往往成为开发者的痛点。H2数据库因其轻量级、内存模式和快…

2026/7/6 0:01:17 阅读更多 →
Windows任务栏终极清理指南:用RBTray一键隐藏窗口到系统托盘

Windows任务栏终极清理指南:用RBTray一键隐藏窗口到系统托盘

Windows任务栏终极清理指南:用RBTray一键隐藏窗口到系统托盘 【免费下载链接】rbtray A fork of RBTray from http://sourceforge.net/p/rbtray/code/. 项目地址: https://gitcode.com/gh_mirrors/rb/rbtray 你是否厌倦了Windows任务栏上密密麻麻的图标&…

2026/7/6 0:01:17 阅读更多 →
Visual C++ 运行时库一键安装终极指南:告别DLL缺失烦恼

Visual C++ 运行时库一键安装终极指南:告别DLL缺失烦恼

Visual C 运行时库一键安装终极指南:告别DLL缺失烦恼 【免费下载链接】vcredist AIO Repack for latest Microsoft Visual C Redistributable Runtimes 项目地址: https://gitcode.com/gh_mirrors/vc/vcredist 你是否曾经遇到过这样的情况:下载了…

2026/7/6 0:05:19 阅读更多 →

周新闻

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容 【免费下载链接】BiliTools A cross-platform bilibili toolbox. 跨平台哔哩哔哩工具箱,支持下载视频、番剧等等各类资源 项目地址: https://gitcode.com/GitHub_Trending/bilit/BiliTools …

2026/7/6 8:11:50 阅读更多 →
威胁模型全解析:从新手入门到实战应用,助你构建安全产品!

威胁模型全解析:从新手入门到实战应用,助你构建安全产品!

威胁模型的陌生现状在忙碌疲惫的一天里,参与了关于混合后量子密码学的讨论,应付端点攻击找茬的人,还参与留言板讨论后,发现“威胁模型”对多数人仍是陌生概念,且多被当作时髦用语。有趣的相关画作有一幅由 Embyr 创作的…

2026/7/6 8:11:52 阅读更多 →
渗透测试入门指南:从零基础到实战环境搭建

渗透测试入门指南:从零基础到实战环境搭建

1. 从“看热闹”到“入门”:我理解的渗透测试到底是什么?每次看到新闻里说某个大公司的数据被“黑”了,或者某个网站被攻击导致服务瘫痪,你是不是和我一样,心里会冒出两个念头:一是“这黑客真厉害”&#x…

2026/7/6 6:52:56 阅读更多 →

月新闻