尧图网络 高端网站定制 · 原创设计
免费咨询热线
400-888-6620
免费获取方案
无符号整数支持_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”]
RELATED

相关推荐

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

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

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

📅 2026/11/8 12:00:21
消息列表虚拟滚动_message-list

消息列表虚拟滚动_message-list

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

📅 2026/10/28 14:55:44
代理浏览器工具_agent-browser

代理浏览器工具_agent-browser

以下为本文档的中文说明该技能为agent-browser,是一套专业的工具和最佳实践集合。它提供了完整的功能实现指导,涵盖核心概念、配置方法和典型应用场景。该技能注重实用性和可操作性,适用于需要在相关领域实现自动化和高效工作的开发者和技术团…

📅 2026/10/27 23:30:49
MORE NEWS

更多资讯

📰

工地可以查电工证吗 电工证过期了怎么报名复审

工地可以查电工证吗 电工证过期了怎么报名复审 证书过期了不知道怎么复审延期?你不是一个人。很多在工地从事电工工作的朋友,尤其是河南的公路工程从业者,常遇到这种情况:电工证快到期了,却不知道怎么操作,甚至不知道自己能在哪里查证、在哪里报名。这…

📰

湛江电工证怎样报名网上查询实操考试心里没底怕挂科

湛江电工证怎样报名网上查询实操考试心里没底怕挂科 实操考试心里没底怕挂科?很多在湛江准备报考电工证的朋友都这么想。其实,只要提前准备,了解流程和考试重点,就能大大提升通过率。今天我们就从“湛江电工证怎样报名”这个核心问题入手,详细聊聊报名流…

📰

电工作业封面图片内部消息:郑州金水区电工证报名避坑全攻略

电工作业封面图片内部消息:郑州金水区电工证报名避坑全攻略 你是不是也经常在朋友圈、贴吧、论坛上看到有人问“电工作业封面图片怎么弄?”,然后一堆人回答“找中介”?可你心里明白, 不知道去哪报名怕被中介坑…

📰

中级维修电工证哪里考怎么报名实操考试心里没底怕挂科

中级维修电工证哪里考怎么报名实操考试心里没底怕挂科 你是不是也担心实操考试心里没底,怕挂科?特别是第一次报考中级维修电工证,不知道怎么报名,更不知道哪里考。别急,这篇文章专门为你解决这些问题,从报考流程到培训机构选择,再到实操考试技巧,一网…

📰

中级电工证难不难学 2026河南最新政策下如何备考和复审

中级电工证难不难学 2026河南最新政策下如何备考和复审 工地太忙根本没时间复习考试,这是很多特种作业人员的真实写照,特别是持有中级电工证的电工师傅。2026年河南最新政策对特种作业操作证的考核和复审流程进行了优化,但也对从业人员提出了更高…

📰

2021电工证考哪些 电工证报考真实经历告诉你怎么准备

2021电工证考哪些 电工证报考真实经历告诉你怎么准备 我有个朋友在洛阳涧西区一家中小型施工企业干了八年电工,最近想考个正式的电工证,结果发现报名流程复杂,材料要求多,学历低还担心能不能报上。我一听就想起自己当年在河南某工地也遇到过类似的情…

TODAY

今日更新

THIS WEEK

本周精选

THIS MONTH

本月热门

读完文章,想聊聊您的网站?

告诉我们您的行业与需求,资深顾问一对一梳理方案与报价,全程免费。

📞 💬