{"id":10020979,"date":"2025-08-27T21:23:50","date_gmt":"2025-08-27T13:23:50","guid":{"rendered":"https:\/\/itmax.cn\/?p=10020979"},"modified":"2025-08-27T21:23:50","modified_gmt":"2025-08-27T13:23:50","slug":"%e3%80%90triton-%e6%95%99%e7%a8%8b%e3%80%91triton_language-join","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10020979","title":{"rendered":"\u3010Triton \u6559\u7a0b\u3011triton_language.join"},"content":{"rendered":"<p>Triton \u662f\u4e00\u79cd\u7528\u4e8e\u5e76\u884c\u7f16\u7a0b\u7684\u8bed\u8a00\u548c\u7f16\u8bd1\u5668\u3002\u5b83\u65e8\u5728\u63d0\u4f9b\u4e00\u4e2a\u57fa\u4e8e Python \u7684\u7f16\u7a0b\u73af\u5883\uff0c\u4ee5\u9ad8\u6548\u7f16\u5199\u81ea\u5b9a\u4e49 DNN \u8ba1\u7b97\u5185\u6838\uff0c\u5e76\u80fd\u591f\u5728\u73b0\u4ee3 GPU \u786c\u4ef6\u4e0a\u4ee5\u6700\u5927\u541e\u5410\u91cf\u8fd0\u884c\u3002<\/p>\n<p>\u66f4\u591a Triton \u4e2d\u6587\u6587\u6863\u53ef\u8bbf\u95ee \u2192<a href=\"https:\/\/link.segmentfault.com\/?enc=lgWqB1ZYLQl8TA0E1YwN2g%3D%3D.wxZM4Oe509%2Bxkr3eUDXey5QCt3MiD8MBVNAd1SuMXhc%3D\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">https:\/\/triton.hyper.ai\/<\/a><\/p>\n<pre><code>triton.language.join(a, b)<\/code><\/pre>\n<p>\u5728 1 \u4e2a\u65b0\u7684\u6b21\u8981\u7ef4\u5ea6\u4e2d\u8fde\u63a5\u7ed9\u5b9a\u7684\u5f20\u91cf\u3002<\/p>\n<p>For example, given two tensors of shape (4,8), produces a new tensor of shape (4,8,2). Given two scalars, returns a tensor of shape (2).<\/p>\n<p>\u4f8b\u5982\uff0c\u7ed9\u5b9a 2 \u4e2a\u5f62\u72b6\u4e3a (4,8) \u7684\u5f20\u91cf\uff0c\u751f\u6210 1 \u4e2a\u65b0\u7684\u5f62\u72b6\u4e3a (4,8,2) \u7684\u5f20\u91cf\u3002\u7ed9\u5b9a 2 \u4e2a\u6807\u91cf\uff0c\u8fd4\u56de 1 \u4e2a\u5f62\u72b6\u4e3a (2) \u7684\u5f20\u91cf\u3002<\/p>\n<p>2 \u4e2a\u8f93\u5165\u88ab\u5e7f\u64ad\u5230\u76f8\u540c\u7684\u5f62\u72b6\u3002<\/p>\n<p>If you want to join more than two elements, you can use multiple calls to this function. This reflects the constraint in Triton that tensors must have power-of-two sizes.<\/p>\n<p>\u5982\u679c\u4f60\u60f3\u8fde\u63a5\u8d85\u8fc7 2 \u4e2a\u5143\u7d20\uff0c\u53ef\u4ee5\u591a\u6b21\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\u3002\u8fd9\u53cd\u6620\u4e86 Triton \u4e2d\u7684\u7ea6\u675f\uff0c\u5373\u5f20\u91cf\u7684\u5927\u5c0f\u5fc5\u987b\u662f 2 \u7684\u5e42\u3002<\/p>\n<p><code>join<\/code>\u00a0\u662f\u00a0<code>split<\/code>\u00a0\u7684\u9006\u64cd\u4f5c\u3002<\/p>\n<p><strong>\u53c2\u6570<\/strong>\uff1a<\/p>\n<ul>\n<li><strong>a<\/strong>\u00a0(<em>T<\/em><em>ensor<\/em>)\u2013 \u7b2c 1 \u4e2a\u8f93\u5165\u5f20\u91cf\u3002<\/li>\n<li><strong>b<\/strong>\u00a0(<em>T<strong>en<\/strong>sor<\/em>) &#8211; \u7b2c 2 \u4e2a\u8f93\u5165\u5f20\u91cf\u3002<\/li>\n<\/ul>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000047215639\">https:\/\/segmentfault.com\/a\/1190000047215639<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Triton \u662f\u4e00\u79cd\u7528\u4e8e\u5e76\u884c\u7f16\u7a0b\u7684\u8bed\u8a00\u548c\u7f16\u8bd1\u5668\u3002\u5b83\u65e8\u5728\u63d0\u4f9b\u4e00\u4e2a\u57fa\u4e8e Python \u7684\u7f16\u7a0b\u73af\u5883\uff0c\u4ee5\u9ad8\u6548\u7f16\u5199\u81ea\u5b9a\u4e49 [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10020979","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020979","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10020979"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10020979\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10020979"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10020979"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10020979"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}