Compare commits

..
632 Commits
Author SHA1 Message Date
weili10 e0d724c3c6 update cann version.
Signed-off-by: weili10 <liwei386@huawei.com>
2023-01-30 13:19:59 +00:00
weili10 0ea0d95f7b update README.zh.md.
Signed-off-by: weili10 <liwei386@huawei.com>
2023-01-19 08:02:48 +00:00
i-robot d4ffa0a823 !2129 Unified version number format.
Merge pull request !2129 from 闫鹏全/v1.5.0
2023-01-17 06:18:50 +00:00
闫鹏全 a47d202e3e Unified version number format. 2023-01-14 18:49:24 +08:00
AtlasAccount 6db8b2d88d 同步1.5.0 bb20140941c0d6e6dcbdba9a0510bbbe5e20b791
!3620 Add exclude aicore engine of viewcopy and index.
    Merge pull request !3620 from 於欣洁/master
2022-12-26 23:00:43 +08:00
AtlasAccount 03a193fd0d 同步1.5.0 4ece93ce4b22e422f5e7bb9a71ae3df4b607a0d9
!3619 [Fix] revert Pull Request !3618 : [Feature] Modify the size of AvgPoolV2Grad to int32
    Merge pull request !3619 from weili10/revert-merge-3618-master
2022-12-16 16:31:09 +08:00
AtlasAccount 513f46decc 同步1.5.0 b152e9648995ac6de929cbac3e20dbcd1435ac66
!3618 [Feature] Modify the size of AvgPoolV2Grad to int32
    Merge pull request !3618 from 戢芳/avg_pool2d_grad1.5
2022-12-15 12:00:45 +08:00
weili10 2b48121bbf update OWNERS.
Signed-off-by: weili10 <liwei386@huawei.com>
2022-12-13 09:28:10 +00:00
weili10 e3e229839f update OWNERS.
Signed-off-by: weili10 <liwei386@huawei.com>
2022-12-09 02:14:36 +00:00
weili10 88719bd40a update OWNERS.
Signed-off-by: weili10 <liwei386@huawei.com>
2022-11-30 06:40:47 +00:00
i-robot 3fc20b8b30 !1600 新API清单更新
Merge pull request !1600 from 彭子荣/v1.5.0
2022-11-17 12:08:48 +00:00
pengzirong e751f65710 api清单更新 2022-11-16 16:29:52 +08:00
weili10 86a79738b3 update OWNERS.
Signed-off-by: weili10 <liwei386@huawei.com>
2022-11-14 09:23:47 +00:00
weili10 5fcd2ba271 update OWNERS.
Signed-off-by: weili10 <liwei386@huawei.com>
2022-11-14 08:59:57 +00:00
AtlasAccount cb18de2fef 同步1.5.0 f98435a698ede814e377438beb38045da3aeec04
!3614 【BugFix】补充nllloss_2d的weight赋0的判断条件
    Merge pull request !3614 from 戢芳/nllloss_debug1.5
2022-11-07 12:00:50 +08:00
AtlasAccount b292bc05c9 同步1.5.0 ffe03b307b8cbd4d2e60b19588cf5f250d5e0b2a
!3613 [refactor]npu_dtype_cast replace to function.
    Merge pull request !3613 from darin123/master
--
    !3608 [refactor]npu_dtype_cast replace to function.
    Merge pull request !3608 from darin123/master
2022-11-01 23:00:43 +08:00
AtlasAccount 95cf34f163 同步1.5.0 ee09df85b727ced2406ae91ab6045b1438a8a098
!3610 【Refactor】taskqueue重构:优化usleep与结构体析构
    Merge pull request !3610 from yangxiaorun/master
2022-10-27 23:00:56 +08:00
weili10 eb4a799674 update README.zh.md.
Signed-off-by: weili10 <liwei386@huawei.com>
2022-10-22 04:05:54 +00:00
AtlasAccount d1305fd848 同步1.5.0 eee06586452597ab040198a7bb79b7bcc1874c2d
Merge: 00ae3c23f 03716faf1
    !3605 [fix] scalar scene and rank=1 scene do not support nz
    Merge pull request !3605 from 王强/master
Merge: 4b3479311 f01d27c64
    !3606 index和viewcopy修改入参编译选项
    Merge pull request !3606 from 王晓/index_viewcopy_independent
    index and viewcopy fix
    [fix] scalar scene and rank=1 scene do not support nz
2022-10-20 19:31:13 +08:00
weili10 c5f7e64aa5 update README.zh.md.
Signed-off-by: weili10 <liwei386@huawei.com>
2022-10-20 01:46:06 +00:00
AtlasAccount abc10caebd 同步1.5.0 4b347931184da0fbc47dfacb77e6a9425a433727
!3598 index indexput v3
    Merge pull request !3598 from 王晓/index_v3_new
2022-10-15 00:11:48 +08:00
AtlasAccount fd7a52be39 同步1.5.0 d8d3a108ba68f16924a3402ede78741168feb87b
!3601 更改版本号6->7
    Merge pull request !3601 from 王夏夏/master
2022-10-12 23:00:39 +08:00
AtlasAccount 847cbbbb1a 同步1.5.0 9b3fd49c7369bd86888e11e14d6885be70a58cd9
!3591 【bernoulli适配】 bernoulli IR修改,适配层对齐 & cast 问题处理
    Merge pull request !3591 from 沈鹏程/108_bernoulli_IR
--
    !3585 GridSampler2D入参修改符合 算子IR
    Merge pull request !3585 from aikede/1.5_bug_grid
--
    !3590 修复index中转连续走aicpu导致性能下降问题
    Merge pull request !3590 from 王晓/index_mae
--
    !3587 修复index_select反向index_add不支持index为0维问题
    Merge pull request !3587 from 王晓/index_add
--
    !3586 【BugFix】修复index_put check indices报错
    Merge pull request !3586 from hxf12345677/inp
2022-10-08 23:00:55 +08:00
AtlasAccount 681f5543e4 同步1.5.0 012b968a50c9b3557045dc9a0b09da03c6ea6424
!3583 【BugFix】修复maksed_select的输出shape
    Merge pull request !3583 from 戢芳/maksed_select1.5
--
    !3582 【BugFix】修复avgpool2d 算子输出shape错误问题, 对不支持三维输入做增维操作
    Merge pull request !3582 from 戢芳/avgpool2d
--
    !3584 【BCM】indexput 适配
    Merge pull request !3584 from hxf12345677/indexput
2022-09-29 23:00:43 +08:00
AtlasAccount 1a380aefee 同步1.5.0 42069cd2f18462b54e5822b0d6b439fe35b462d1
!3581 【BugFix】_unique2算子fp16场景存在精度问题,转fp32规避
    Merge pull request !3581 from 戢芳/unique1.5
--
    !3580 masked_select支持非bool mask
    Merge pull request !3580 from 王晓/maskedselect
2022-09-27 23:00:44 +08:00
AtlasAccount d52f542aa7 同步1.5.0 88e743638d41a0f36453d07936e8d5b647d60b39
!3573 【BCM】upsample_nearest1d调用Resize
    Merge pull request !3573 from 戢芳/resize1.5
--
    !3570 【算子适配】 MaskedSelect改为第三类算子适配
    Merge pull request !3570 from hxf12345677/maskselect
2022-09-20 23:00:43 +08:00
AtlasAccount e434ebc805 同步1.5.0 240174e62da5c45598faea4e89da5fbef194a904
!3566 【算子适配】 unique2改为第三类算子适配
    Merge pull request !3566 from hxf12345677/un
--
    !3564 Modify randperm adapt to StatelessRandperm
    Merge pull request !3564 from 王晓/1.5randperm_n_input
2022-09-19 23:04:53 +08:00
AtlasAccount 41bfe9c544 同步1.5.0 6a60895589b231dd9384f70f5cba13e8dc122339
!3563 index算子IR变更(商分)
    Merge pull request !3563 from 王晓/1.5rc3_index
2022-09-17 23:01:05 +08:00
AtlasAccount df05b7a031 同步1.5.0 5a0f37cc0c586468171426572ac3b9e5c5953c90
!3561 【bugfix】修复onehot算子,入参为scalar时,性能下降问题
    Merge pull request !3561 from hxf12345677/oneh
2022-09-16 23:00:38 +08:00
AtlasAccount c39e008d3b 同步1.5.0 810a702dc3adf05f76e18879fb1ffd6f1cbfb048
!3559 index算子IR变更
    Merge pull request !3559 from 王晓/1.5index_new
2022-09-15 23:00:38 +08:00
AtlasAccount 3d3750411f 同步1.5.0 9d0053314e398e674a0be7a5ee85efb9ae584e3d
!3543 【算子适配】nms_rotated_npu调用NPU算子IR更新
    Merge pull request !3543 from 赖长铃/rotatednms
2022-09-14 23:00:43 +08:00
AtlasAccount 11e4eb7eb8 同步1.5.0 c3e94122d4a11c7f269e7d0a345fcba578a99736
!3554 【BCM整改】multinomial增加seed、offset
    Merge pull request !3554 from 戢芳/multinomial
2022-09-13 23:00:42 +08:00
AtlasAccount defe0587f6 同步1.5.0 0513d0db60b14371538432e8162b44be92a94fbc
!3557 cummin算子IR变更,适配同步修改
    Merge pull request !3557 from 王晓/cummin_axis
2022-09-06 23:00:42 +08:00
AtlasAccount dffecfba93 同步1.5.0 de2ef9dae9391c65c614e2d9a6db5812b53704d2
!3553 index算子调用添加输入IR名称
    Merge pull request !3553 from 赖长铃/index
2022-09-03 12:00:40 +08:00
AtlasAccount d57152e0cd 同步1.5.0 e064c1da43eb595f7e3d399f4c292bf246ef6a07
!3548 随机数算子uniform_, random_, normal更换算子,固定seed
    Merge pull request !3548 from 王晓/stateless_ops
2022-09-01 12:00:38 +08:00
AtlasAccount 04c8dfea99 同步1.5.0 9fd6202960a4d44aeded5f13d3a779c940214709
!3550 【bugfix】 修改index 算子mask入参为const节点
    Merge pull request !3550 from hxf12345677/inde
--
    !3551 add: 新增npu_convolution_transpose_backward的反向函数绑定
    Merge pull request !3551 from 郭夏/master
2022-08-30 23:07:01 +08:00
i-robot db66d80806 !1181 网络模型移植与训练指南全文问题检查&多机多卡训练适配指南资料修改
Merge pull request !1181 from 彭子荣/v1.5.0
2022-08-29 12:42:32 +00:00
pengzirong 9ab75c8967 网络模型移植与训练指南全文问题检查&环境变量代码缺少空格 2022-08-26 10:27:19 +08:00
AtlasAccount c8085ae921 同步1.5.0 6f5fbe514fc753be519861b9a7365e651be96c92
!3546 回退 Pull Request !3508 : sum算子对int64型数据的支持
    Merge pull request !3546 from weili10/revert-merge-3508-master
2022-08-25 23:00:54 +08:00
AtlasAccount 2032d04858 同步1.5.0 653dafb269ce01c9a69fee887ada4259390cedc8
!3545 移除module.forward中未使用的increase_step
    Merge pull request !3545 from lj_new/master
2022-08-25 12:01:14 +08:00
AtlasAccount 255de550cc 同步1.5.0 f2176df2b7169e8d6207f0627414dbef54b75bd6
!3544 ptcopy切换为viewcopy
    Merge pull request !3544 from 王晓/viewcopy1.5
2022-08-24 23:00:42 +08:00
weili10 7a8ecbca90 update OWNERS.
Signed-off-by: weili10 <liwei386@huawei.com>
2022-08-18 11:53:17 +00:00
AtlasAccount 43f5a19a2f 同步1.5.0 f0cc489eb4751724ad1dbdefa32d924afe5fe661
!3538 【BugFix】同步embedding_renorm算子适配逻辑与1.8一致
    Merge pull request !3538 from 戢芳/embedding1.5
2022-08-11 23:00:35 +08:00
AtlasAccount 93a2fdc566 同步1.5.0 2bbc1d6af71acaf0a9b983fd6ef5bbda648813ba
!3539 【适配】bernoulli 适配    算子原型改动,适配层对齐修改
    Merge pull request !3539 from 沈鹏程/IR_by_bernoulli
2022-08-09 23:03:15 +08:00
i-robot 6d23724871 !1095 网络模型移植与训练指南修改
Merge pull request !1095 from 彭子荣/v1.5.0
2022-08-08 12:28:31 +00:00
pengzirong 32f82f58ef 更新跳转链接与分布式训练添加 2022-08-08 16:35:51 +08:00
AtlasAccount dfec8bbb20 同步1.5.0 a92bbcbb21ebb73ac4d19283eae79f24fc1b128a
!3537 【1.5】回退非host memory修改
    Merge pull request !3537 from 周和光/fix_storage_format
2022-08-04 12:04:24 +08:00
AtlasAccount 4fd08f5fc6 同步1.5.0 b17ba4b0bac8928b2684843afaf123ac3fb113e7
!3533 回退 Pull Request !3525 : sum算子对int64型数据的支持
    Merge pull request !3533 from weili10/revert-merge-3525-master
--
    !3532 【bernoulli】remove stream synchronization for model
    Merge pull request !3532 from 沈鹏程/modify_bernoulli
2022-07-29 23:01:37 +08:00
AtlasAccount e5e76d5ff0 同步1.5.0 f3228834e071b9ab9653d095546e2c8af48e0cf7
!3531 【1.5】修正host memory未设置storage Shape/Format问题
    Merge pull request !3531 from 周和光/fix_storage_format
--
    !3527 bernoulli 算子适配,算子新增优化随机数机制,提高兼容性
    Merge pull request !3527 from 沈鹏程/adapt_bernoulli
2022-07-28 23:00:37 +08:00
AtlasAccount 1ca343fff0 同步1.5.0 a9374eaab1592005e73feafddd74ee679b303113
!3528 【bugfix】修复one_hot算子走aicpu分支时报错场景
    Merge pull request !3528 from hxf12345677/one
2022-07-27 23:00:54 +08:00
i-robot 99172aa0ca !1088 Updated English docs.
Merge pull request !1088 from zwy/v1.5.0
2022-07-26 06:20:15 +00:00
AtlasAccount 2b58bddcb0 同步1.5.0 0d9083e346bb706963742f6cdfc845506f3422ad
!3525 sum算子对int64型数据的支持
    Merge pull request !3525 from aikede/b_sum_dtype
2022-07-26 12:01:12 +08:00
AtlasAccount 4f7caaaf7f 同步1.5.0 36b80ca87a878ac507db4bef09f19404d4b126d8
!3510 回退sort修改
    Merge pull request !3510 from 王夏夏/master
2022-07-25 23:00:42 +08:00
yanhuiling 02298ccc80 Updated English docs. 2022-07-25 17:26:26 +08:00
AtlasAccount f80b97dadc 同步1.5.0 8578cd9a5cd15907af28c87f2a097dae7f8a7366
!3517 支持rng_state
    Merge pull request !3517 from hanjun/master
2022-07-20 12:01:07 +08:00
AtlasAccount b31dfee2d7 同步1.5.0 7d9dd60df7b13268f8ec703cddf03598dd31e4d5
!3504 opcmd支持dtype传参
    Merge pull request !3504 from 王晓/dtype_attr
2022-07-18 23:00:37 +08:00
AtlasAccount 64c1e12c6a 同步1.5.0 3e6c6f59c99032f0dfe854079dc237cc8d9f9895
!3508 sum算子对int64型数据的支持
    Merge pull request !3508 from aikede/b_sum_dtype
2022-07-15 12:00:38 +08:00
weili10 732ae7c134 update maintenance status for 3.0.rc2 2022-07-15 03:30:31 +00:00
i-robot 333c907f8d !1048 多机多卡训练适配指南 英文资料更新
Merge pull request !1048 from 彭子荣/v1.5.0
2022-07-13 08:32:22 +00:00
pengzirong 2e7e39b507 update ip tothe smple ip
1
2022-07-12 15:30:50 +08:00
i-robot 57cc74e900 !1043 Update README and PyTorch Installation Guide based on Chinese revisions.
Merge pull request !1043 from zwy/v1.5.0
2022-07-11 13:30:52 +00:00
weili10 c3a5d05424 !1034 网络模型移植与训练指南修改
Merge pull request !1034 from 彭子荣/v1.5.0
2022-07-11 09:35:58 +00:00
zwy a18e48a834 Updated README and PyTorch Installation Guide based on Chinese revisions. 2022-07-11 16:42:26 +08:00
pengzirong 5930dbec25 网络模型移植与训练指南新增硬件支持说明 2022-07-11 14:48:31 +08:00
AtlasAccount a932e65f9e 同步1.5.0 d5b893e768dc36d410b90986c4534cf4f9a3bf63
!3507 [bugfix] right lock for task queue
    Merge pull request !3507 from 蒋荣强/master
2022-07-11 12:00:47 +08:00
i-robot 6e3dbfa3c7 !1028 V1.5.0资料更新
Merge pull request !1028 from 彭子荣/v1.5.0
2022-07-11 03:33:36 +00:00
pengzirong 889d2ae716 v1.5.0README与安装指南修改
1

1
2022-07-11 09:51:52 +08:00
AtlasAccount bdc0d2a819 同步1.5.0 ece606e4dc43d9a9e0d6986b524b077ef76174a2
!3505 bugfix:删除cmake中的rpath=True设置
    Merge pull request !3505 from 施博/master
2022-07-09 23:00:43 +08:00
AtlasAccount d5aca3c9d8 同步1.5.0 9cb0b5fffe4a53ce5a086488a0d3fff32b3f4379
!3500 sort算子走fp32 && 更新版本号post5->post6
    Merge pull request !3500 from 王夏夏/master
2022-07-07 23:00:40 +08:00
weili10 5b477928d5 !1012 README与安装指南差异修改
Merge pull request !1012 from 彭子荣/v1.5.0
2022-07-07 09:53:39 +00:00
pengzirong 6daeb34d1e 更新README与安装指南差异与问题
更新依赖下载

i
2022-07-07 16:55:05 +08:00
AtlasAccount 67b74b6919 同步1.5.0 6f0751810b75da99796af08cdf031057982e11e8
!3496 ASCEND_OPP_PATH 路径错误增加GE报错信息
    Merge pull request !3496 from 汪瑞哲/master
2022-07-04 12:00:48 +08:00
i-robot 8c019dc9f6 !988 torch1.5 环境变量说明调整
Merge pull request !988 from 李超/v1.5.0
2022-07-02 03:12:50 +00:00
李超 138ccbab13 update environment variables 2022-07-02 09:57:47 +08:00
AtlasAccount e8e34e1648 同步1.5.0 533ca3e0e3162f24ac8a6634b02e832a635ffcc5
!3497 回退 Pull Request !3486 : Conv2d适配模糊编译二进制
    Merge pull request !3497 from weili10/revert-merge-3486-master
2022-07-01 23:00:43 +08:00
i-robot c693353ef1 !981 API 支持度资料修改
Merge pull request !981 from 彭子荣/v1.5.0
2022-07-01 06:46:10 +00:00
pengzirong f9b8c654cf torch.cdist支持度修改 2022-07-01 09:40:45 +08:00
i-robot 350a490e87 !976 README更新
Merge pull request !976 from 彭子荣/v1.5.0
2022-06-30 08:23:26 +00:00
pengzirong e7d59cbfaf 多机多卡训练适配指南修改资料中IP为样例IP 2022-06-30 15:49:06 +08:00
pengzirong 32ca47c016 readme与安装指南合并,内容拷贝到安装指南 2022-06-30 15:42:22 +08:00
AtlasAccount 88bc2d63eb 同步1.5.0 206e8a36c89c7493c546e7840f544a853b7edc40
!3494 【bugfix】 修复cdist算子,属性p=inf,npu报错
    Merge pull request !3494 from hxf12345677/cdist
2022-06-30 12:00:41 +08:00
AtlasAccount 7c14ecce0d 同步1.5.0 0e58834e66ebecc031387b2ca0d71fa163eaa4e1
!3488 wrap AclopCompileAndExecuteV2
    Merge pull request !3488 from 王晓/unique_consecutive_wrap
--
    !3481 【bugfix】修复all算子输入为空Tensor,计算结果错误场景
    Merge pull request !3481 from hxf12345677/all
--
    !3482 【BugFix】修复floor_divide算子int32格式的精度问题(同步1.8)
    Merge pull request !3482 from 戢芳/divide1.5
2022-06-27 23:03:17 +08:00
AtlasAccount a05df6bdda 同步1.5.0 4caaee8d3fcaede8044157f462739d2997b33f39
!3480 BernoulliCust适配
    Merge pull request !3480 from 李思杰/bernoulli_cust
--
    !3486 Conv2d适配模糊编译二进制
    Merge pull request !3486 from 郭鹏/master
--
    !3478 unique_consecutive适配
    Merge pull request !3478 from 王晓/unique_consecutive
2022-06-25 23:00:34 +08:00
AtlasAccount b3a7f790c8 同步1.5.0 e71da1b59d7e685f8c2260a4dbb4f1eee12149fd
!3483 回退 Pull Request !3466 : randn算子适配,支持seed配置,以及对dtype类型的attr支持
    Merge pull request !3483 from weili10/revert-merge-3466-master
--
    !3477 all算子支持uint8入参
    Merge pull request !3477 from aikede/b_all
2022-06-23 23:00:42 +08:00
AtlasAccount 88e7cd0667 同步1.5.0 0b1ffcfd22b713fc3bdbbb1be8b4cc91cf1cff9c
!3473 fix bug of lazy print
    Merge pull request !3473 from wangyu/dev
2022-06-21 12:00:34 +08:00
AtlasAccount 38267666fe 同步1.5.0 61605a199df457a6bb82d1311f7b1d03681cbbc3
!3471 去除InputPair操作
    Merge pull request !3471 from hxf12345677/ho
2022-06-20 23:00:43 +08:00
AtlasAccount b387a3427d 同步1.5.0 a7cf1481f9b810ad1fcef773781df9e7d6a4d89b
!3465 ne支持int32输入
    Merge pull request !3465 from aikede/b_ne
2022-06-16 23:02:02 +08:00
AtlasAccount 3f4ffba595 同步1.5.0 1db3bc5742446fb80b5cde89057e00318cc11cef
!3462 删除requirements.txt文件中重复pyyaml
    Merge pull request !3462 from 王夏夏/master
--
    !3466 randn算子适配,支持seed配置,以及对dtype类型的attr支持
    Merge pull request !3466 from 王晓/randn_seed
--
    !3459 Fixed Split K BUG
    Merge pull request !3459 from 唐超/fixed_NZ_bug
2022-06-16 12:01:19 +08:00
i-robot 154bcfced6 !911 安装指南资料修改
Merge pull request !911 from 彭子荣/v1.5.0
2022-06-15 07:01:20 +00:00
AtlasAccount 12303a6da0 同步1.5.0 99252a026bee508d110da24ca95a5185afff6664
!3461 修复部分模型因为算子重复编译导致的asstride性能下降问题
    Merge pull request !3461 from 李超/dev-asstrided
2022-06-14 23:01:40 +08:00
pengzirong 7a20b65e2f 修改下载昇腾适配APEX的源码命令 2022-06-14 17:12:06 +08:00
i-robot d11cd94156 !897 处理器名称更新
Merge pull request !897 from 彭子荣/v1.5.0
2022-06-10 10:00:31 +00:00
pengzirong c45de03e71 ASCEND 710 -->ASCEND 310P 2022-06-10 16:48:42 +08:00
AtlasAccount c87f2cd51b 同步1.5.0 612acab3aa879a5479b280cf55ba66affbd61e96
!3456 【BugFix】thredshold算子去D
    Merge pull request !3456 from 戢芳/threshold1.5
2022-06-07 12:01:35 +08:00
AtlasAccount a6189a76e5 同步1.5.0 953a0f6b93c6bf0fc8f35545f493fb7e5de3f34d
!3455 【BugFix】lstm_cell_backward构造bias输出时,type与i一致
    Merge pull request !3455 from 戢芳/lstm_cell_fix
2022-06-02 23:00:47 +08:00
AtlasAccount 73c47b1e64 同步1.5.0 23f0a06a8b1571ddbfce2b334dc27dc68e3ee8ff
!3430 BernoulliCust算子适配
    Merge pull request !3430 from 龚政/Bernoulli
2022-06-01 23:04:31 +08:00
AtlasAccount 2d7d639562 同步1.5.0 09cc7f597fc187168c6c77ca235d56658c97d8d9
!3453 arange算子默认输出类型和cpu修改一致
    Merge pull request !3453 from aikede/b_arange
2022-06-01 12:08:14 +08:00
AtlasAccount ace64b8445 同步1.5.0 140c0f720af4fb23b979e3d435182295b655b534
!3452 为Mul算子tensor*scalar新增一个UT
    Merge pull request !3452 from 詹隽/add_test
2022-05-31 23:00:45 +08:00
AtlasAccount c06ce48b89 同步1.5.0 179c0ba3b26763b29fb3208b44aaa7ed749a1e52
!3445 【功能修复】适配层主动调用cpu的cast方法解决算子不支持不同dtype输入问题
    Merge pull request !3445 from 詹隽/scalar_bug
--
    !3447 【新接口】1.5动态shape新接口
    Merge pull request !3447 from 詹隽/dynamic_interface
--
    !3428 Only_MM_Split_k
    Merge pull request !3428 from 唐超/only_mm_split
2022-05-25 23:00:52 +08:00
i-robot 274b892c56 !829 1.5新增combine_grad说明
Merge pull request !829 from lj_new/v1.5.0
2022-05-25 03:04:23 +00:00
AtlasAccount 7e2c3d7979 同步1.5.0 63ee4d2144db51de342e2f477f482ef9ee2bd26f
!3431 [optimize] 非连续流程优化
    Merge pull request !3431 from 李超/git
--
    !3443 【BugFix】file rename
    Merge pull request !3443 from 戢芳/rename1.8
2022-05-24 23:00:50 +08:00
i-robot 4b396515d5 !818 README更新
Merge pull request !818 from 彭子荣/v1.5.0
2022-05-24 09:19:12 +00:00
AtlasAccount 2d8ece95b3 同步1.5.0 90382c1c71d343f9609471fd2055e9f551ada92b
!3439 【FixBug】修复lstm中lengths[0]不为T时的场景
    Merge pull request !3439 from 王晓/lstm_shape
--
    !3435 【1.5算子适配】lstm_cell、lstm_cell_backward
    Merge pull request !3435 from 戢芳/lstm_cell1.5
2022-05-23 23:04:59 +08:00
lj_new de3435090b 1.5新增combine_grad说明 2022-05-23 04:00:20 +00:00
lj_new 27cf56f730 1.5文档新增combine_ddp使用说明 2022-05-23 03:57:50 +00:00
AtlasAccount 4dc478adab 同步1.5.0 f45f80fb2d571e175dc7a9be2e9e3ced6d4ca11b
!3414 【bugfix】sub适配新增other的device判断、addmm和cat增加输入tensor类型检查
    Merge pull request !3414 from 郭夏/sub
--
    !3422 [Bugfix] Lt support LongTensor.
    Merge pull request !3422 from 尤安升/master
2022-05-19 15:26:49 +08:00
pengzirong e1f9bb08d1 更新配套参考表格 2022-05-19 11:45:42 +08:00
weili10 4b28c57993 update docs/zh/PyTorch安装指南/PyTorch安装指南.md. 2022-05-18 10:43:11 +00:00
weili10 6afb6c635b update README.zh.md. 2022-05-18 10:41:46 +00:00
weili10 3ae0c6ae3f !814 安装指南与README新增安装提示说明
Merge pull request !814 from 彭子荣/v1.5.0
2022-05-18 10:40:33 +00:00
pengzirong 30b9ebb94d 安装指南与README更新提示 2022-05-18 17:36:35 +08:00
AtlasAccount 844328508e 同步1.5.0 2cb9f26f9b0221d4951c1c2818af51b4954bd3c5
!3421 回退 Pull Request !3408 : 【1.5新算子适配】norm适配LpNorm算子
    Merge pull request !3421 from weili10/revert-merge-3408-master
2022-05-13 12:00:57 +08:00
AtlasAccount ec0828a267 同步1.5.0 1556b0eccd6f26c7570812b362754fa3b3201248
!3408 【1.5新算子适配】norm适配LpNorm算子
    Merge pull request !3408 from 肖代鹏/1.8_adapt_222
--
    !3412 下发优化代码回退
    Merge pull request !3412 from 李超/master-git
2022-05-12 11:57:25 +08:00
AtlasAccount 54c1b37228 同步1.5.0 9ecfb14a51719a8d6a917337560e90f5358dba40
!3397 更新apply_adam底层算子
    Merge pull request !3397 from 王晓/applyadam
--
    !3409 [bugfix] 暂时回退 get_npu_format修改
    Merge pull request !3409 from 李超/master
2022-05-10 23:01:53 +08:00
AtlasAccount 4b31ff2cb5 同步1.5.0 21a1c102215b8dbe98a41a0592126e48e09b6ff7
!3398 调整shutdown阶段资源释放流程
    Merge pull request !3398 from wangyu/dev
--
    !3391 调整进程退出阶段资源释放流程
    Merge pull request !3391 from wangyu/dev
2022-05-06 23:00:52 +08:00
AtlasAccount 150ead5660 同步1.5.0 09ea7e8fa7de87420d217775375b44f3509c26c1
!3393 sync dev to master
    Merge pull request !3393 from 王强/dev
2022-05-05 12:02:00 +08:00
AtlasAccount cfcc3a2f8b 同步1.5.0 4baf85d4d061ed874fe71c96b5a053aa973a5cd2
!3387 randperm 适配
    Merge pull request !3387 from 沈鹏程/randperm
2022-04-29 23:00:46 +08:00
weili10 aeba162110 update ascend pytorch version 2022-04-29 03:10:06 +00:00
AtlasAccount 7c31e72e10 同步1.5.0 0e3c8619b6df6775666c912ee8c35f8e663a6e93
!3384 【FixBug】修复max.out接口checkout错误场景
    Merge pull request !3384 from hxf12345677/max
--
    !3386 【bugfix】:修复embedding_renorm_适配导致图模式用例失败的问题
    Merge pull request !3386 from 郭夏/master
2022-04-27 23:00:56 +08:00
AtlasAccount e3e79304fd 同步1.5.0 08c9f799c3ebed16f8cab47bd6518c0598bcce76
!3381 [optimize] 非连续+适配层下发优化3
    Merge pull request !3381 from 李超/git
--
    !3380 dev合入master
    Merge pull request !3380 from 蒋荣强/dev
--
    !3379 merge master to dev
    Merge pull request !3379 from 蒋荣强/dev
--
    !3376 print入图功能,修复生成string的bug
    Merge pull request !3376 from wangyu/dev
--
    !3374 修复print入参场景下,异步h2d没有做内存释放控制的bug
    Merge pull request !3374 from wangyu/dev
--
    !3372 add format adaptation for ops that only support NCHW/NHWC
    Merge pull request !3372 from 王强/dev
--
    !3371 CMD重构,master to dev
    Merge pull request !3371 from 王强/dev
--
    !3362 print入图支持传递tensor name
    Merge pull request !3362 from wangyu/dev
--
    !3350 【1.5算子重构】 Pdist,QuantizePerChannel,Renorm,UpsampleLinear1d,SoftShrink
    Merge pull request !3350 from 肖代鹏/1.5_adapt_construction
    !3359 【1.5代码重构】quantize_per_tensor,repeat_interleave,soft_margin_loss,softshrink_backward,upsample_bicubic2d_backward
    Merge pull request !3359 from 肖代鹏/1.5_adapt_construction3
--
    !3370 add format adaptation for strideadd and col2im
    Merge pull request !3370 from 王强/dev
--
    !3367 【BugFix】logical_or,logsigmoid,logdet,matrix,nms_v4,nms_with_mask
    Merge pull request !3367 from 周凡/cg10
--
    !3369 【refactor】strideadd,one_hot,index,nllloss2d_backward
    Merge pull request !3369 from 王强/dev
    !3345 【refactor】strideadd,one_hot,index,nllloss2d_backward
    Merge pull request !3345 from 周凡/cg4zf
2022-04-25 23:00:47 +08:00
AtlasAccount 3c84bfa2c3 同步1.5.0 d39f2510376f93bd80161f9ab3fdf9b21e826a53
!3366 【fixbug】embedding_backward, embeddingdensebackward算子ut修改
    Merge pull request !3366 from hxf12345677/embedding
2022-04-21 12:00:59 +08:00
i-robot 7759024b2c !712 add pull request template
Merge pull request !712 from weili10/v1.5.0
2022-04-21 01:39:51 +00:00
AtlasAccount 0e5945d7e7 同步1.5.0 9ac4ebdfae709ae01e2b407c209b648551684920
!3364 【FixBug】修复kl_div_backward算子Reduction为Mean计算结果错误场景
    Merge pull request !3364 from hxf12345677/kld
--
    !3357 【BugFix】delete npu_transpose_to_contiguous
    Merge pull request !3357 from 戢芳/transpose1.5
--
    !3355 【FixBug】Celu算子名修改
    Merge pull request !3355 from hxf12345677/fix
2022-04-20 23:01:35 +08:00
weili10 af794ca02d add pull request template 2022-04-20 14:55:03 +08:00
i-robot 433d206ff7 !706 Updated README-EN and the LSTMCELL operator in the API Support (English version).
Merge pull request !706 from zwy/v1.5.0
2022-04-20 06:25:52 +00:00
AtlasAccount 15c670d1f8 同步1.5.0 e4200efc7b53ea596890b89f1b95af0cec999939
!3350 【1.5算子重构】 Pdist,QuantizePerChannel,Renorm,UpsampleLinear1d,SoftShrink
    Merge pull request !3350 from 肖代鹏/1.5_adapt_construction
--
    !3359 【1.5代码重构】quantize_per_tensor,repeat_interleave,soft_margin_loss,softshrink_backward,upsample_bicubic2d_backward
    Merge pull request !3359 from 肖代鹏/1.5_adapt_construction3
2022-04-19 23:00:47 +08:00
AtlasAccount 5a9ac1dece 同步1.5.0 ca6538008f5430012823113d501b241ca28d1ba3
!3353 增加e2e 打点,和pytorch profiler对应
    Merge pull request !3353 from 施博/master
2022-04-18 23:00:45 +08:00
yanhuiling 03739b8421 Update 2022-04-18 18:36:40 +08:00
yanhuiling 94f19f9447 Update 2022-04-18 18:21:13 +08:00
yinzijun 13e1c247bc !698 Updated English docs.
Merge pull request !698 from zwy/v1.5.0
2022-04-18 01:26:00 +00:00
yanhuiling cfe4effb45 Update 2022-04-16 17:42:05 +08:00
i-robot bf2a5a75f0 !694 安装指南中新增CANN版本配套表-v1.5.0
Merge pull request !694 from yinzijun/v1.5.0
2022-04-16 07:21:09 +00:00
yinzijun 9edee0857d 新增cann版本配套表 2022-04-16 06:54:57 +00:00
AtlasAccount 4f38dbfe21 同步1.5.0 a518461dd8e0665deb42ed7f0537c56b37b1edee
!3343 【BugFix】logical_or,logsigmoid,logdet,matrix,nms_v4,nms_with_mask
    Merge pull request !3343 from 周凡/cgmodzf
2022-04-16 12:00:52 +08:00
AtlasAccount e23edc496a 同步1.5.0 dac15bb346999be5a58602240d847cb6ce1efa10
!3349 【图模式】add const ops to graph inputs for graph construction
    Merge pull request !3349 from 王强/dev
--
    !3345 【refactor】strideadd,one_hot,index,nllloss2d_backward
    Merge pull request !3345 from 周凡/cg4zf
--
    !3344 回退lstm_cell的正反向适配
    Merge pull request !3344 from 戢芳/cell_back_master
2022-04-15 23:00:47 +08:00
i-robot 7b620de388 !685 AOE工具内容修改
Merge pull request !685 from 彭子荣/v1.5.0
2022-04-15 08:30:50 +00:00
pengzirong 49e47199f0 用户知识库目录修改 2022-04-15 09:56:20 +08:00
i-robot 40394042b1 !682 v1.5.0分支增加arm环境torchvision安装指导
Merge pull request !682 from 王夏夏/v1.5.0
2022-04-15 01:41:31 +00:00
AtlasAccount b3927b466a 同步1.5.0 43f88e44daf41afe422170bbcd5051aded1760ac
!3337 【max_pool2d算子补充ut】adaptive_max_pool2d,adaptive_max_pool2d_backward,max_pool2d_backward,max_pool2d_with_indices_backward
    Merge pull request !3337 from 周凡/modut
--
    !3333 【功能需求】print入图等需求合入
    Merge pull request !3333 from 蒋荣强/master
--
    !3336 【BugFix】take算子ApplyTensor使用错误
    Merge pull request !3336 from 戢芳/take1.5
2022-04-14 23:01:34 +08:00
xiaxia3 6285c99df0 v1.5.0 arm 安装torchvision指导 2022-04-14 21:27:45 +08:00
i-robot 2005dfa5cf !673 算子支持度修改
Merge pull request !673 from 彭子荣/v1.5.0
2022-04-14 08:29:03 +00:00
AtlasAccount 7f42d3111f 同步1.5.0 9e07c268868154f274d4f65da5a2f5562d942a82
!3322 [bugfix] 修复asstride计算错误问题
    Merge pull request !3322 from 李超/master
2022-04-14 12:00:48 +08:00
pengzirong e05a732de7 修改LSTMCELL算子不支持场景 2022-04-14 09:41:32 +08:00
AtlasAccount 9ee9b54722 同步1.5.0 f504941d8f78d7fae48644f368d065efa055b8b5
!3332 回退 Pull Request !3327 : 【refactor】strideadd,one_hot,index,nllloss2d_backward
    Merge pull request !3332 from weili10/revert-merge-3327-master
--
    !3331 【性能优化】dev优化合入到master
    Merge pull request !3331 from 蒋荣强/master
2022-04-13 23:00:46 +08:00
AtlasAccount 120ab81ead 同步1.5.0 69885324ad8af2b219cf45658f5e265f3c06e0bd
!3329 【refactor】logical_or,logsigmoid,logdet,matrix,nms_v4,nms_with_mask
    Merge pull request !3329 from 周凡/opcgzf1
--
    !3328 【1.5算子重构】take、gatherv2d、erfinv、elu_backeard
    Merge pull request !3328 from 戢芳/move1.5_2
--
    !3327 【refactor】strideadd,one_hot,index,nllloss2d_backward
    Merge pull request !3327 from 周凡/opcgzf
--
    !3324 【1.5算子重构】cdist,baddbmm,nnpack_spatial_convolution,det,true_divide
    Merge pull request !3324 from 戢芳/move1.5
--
    !3321 【1.5算子重构】col2im_backward
    Merge pull request !3321 from 戢芳/col2im1.5
2022-04-12 23:00:45 +08:00
i-robot d1ec3489a8 !659 补充NPU自定算子列表中缺失的算子
Merge pull request !659 from 彭子荣/v1.5.0
2022-04-12 01:44:15 +00:00
pengzirong 8af1e10abc 补充NPU自定算子列表中缺失的算子 (详细算子清单说明中存在)
u

u
2022-04-12 09:17:38 +08:00
weili10 d0cfe101cf !656 V1.5.0 问题单修改
Merge pull request !656 from 彭子荣/v1.5.0
2022-04-09 10:15:12 +00:00
pengzirong c1e759b93c V1.5.0问题单修改 2022-04-09 17:14:10 +08:00
i-robot 3e878edfd5 !650 刷新cann prof资料
Merge pull request !650 from 施博/v1.5
2022-04-09 03:21:55 +00:00
shibo19 34aad3ba20 刷新cann prof资料 2022-04-09 11:09:18 +08:00
AtlasAccount 2d3c963a8b 同步1.5.0 233b0f0a21bd2bfdd74bfda0eb149acdb09f8a93
!3313 【BugFix】规避lstm_cell_backward精度问题
    Merge pull request !3313 from 戢芳/lstm_cell_backward1.5
--
    !3314 删除cann prof不必要的参数设置
    Merge pull request !3314 from 施博/fix_e2e
--
    !3316 cann profiling默认关闭TRAINING_TRACE
    Merge pull request !3316 from lijing/master
2022-04-08 21:50:57 +08:00
i-robot 36b69a909b !645 版本说明与E2E工具内容更新
Merge pull request !645 from 彭子荣/v1.5.0
2022-04-08 11:24:52 +00:00
pengzirong e65c39e589 3.0.RC1版本说明书更新 2022-04-08 17:32:04 +08:00
pengzirong 96e2e34cbb 更新E2E prof工具内容 2022-04-08 17:19:09 +08:00
AtlasAccount 5fa7efcfba 同步1.5.0 22c1ca725cda8d89622b92d747a2c5d428423ca3
!3307 【bugfix】deformable_conv2d_backward
    Merge pull request !3307 from 周凡/defzf
--
    !3305 【功能修复】当eventfd相关接口发生EINTR错误,程序继续运行
    Merge pull request !3305 from 蒋荣强/master
--
    !3310 nll_loss加入溢出检测黑名单
    Merge pull request !3310 from 王夏夏/master
--
    !3309 增加编译选项控制
    Merge pull request !3309 from wangyu/master
2022-04-06 22:43:53 +08:00
AtlasAccount d0a4b62e54 同步1.5.0 04d73412bb8586ea1f72775753e04bc2f1ab2b95
!3306 aoe功能创建路径问题解决
    Merge pull request !3306 from 施博/fix_aoe_bug
2022-04-02 23:00:46 +08:00
AtlasAccount 2ea0c67fc1 同步1.5.0 bdc61eac1f3061568c7c46b7af40843b667bac04
!3302 shutdown前主动释放processgroup相关资源
    Merge pull request !3302 from wangyu/master
--
    !3300 刷新e2e 功能报错信息
    Merge pull request !3300 from 施博/fix_e2e_bug
2022-04-02 11:59:11 +08:00
weili10 4caa12ab7d update docs/zh/PyTorch安装指南/PyTorch安装指南.md. 2022-04-01 13:25:47 +00:00
i-robot 10a9e48f97 !596 删除1.8.1相关
Merge pull request !596 from 彭子荣/v1.5.0
2022-04-01 13:16:19 +00:00
weili10 cb45330ce1 update README.zh.md. 2022-04-01 13:13:39 +00:00
weili10 dc98244a89 update README.zh.md. 2022-04-01 12:39:18 +00:00
weili10 682eca49df update README.zh.md. 2022-04-01 12:37:00 +00:00
weili10 71554f76d1 update scripts/gen.sh. 2022-04-01 12:33:06 +00:00
weili10 c279e2e92a update scripts/gen.sh. 2022-04-01 12:20:40 +00:00
weili10 9fcd859d96 update README.zh.md. 2022-04-01 12:19:48 +00:00
weili10 294aef2b9b update scripts/gen.sh. 2022-04-01 12:06:14 +00:00
weili10 47b089cb6c update README.zh.md. 2022-04-01 12:00:45 +00:00
pengzirong fbde60dc1d 删除1.8.1相关 2022-04-01 19:54:58 +08:00
weili10 3a44ffc52e update scripts/gen.sh. 2022-04-01 10:37:27 +00:00
weili10 cb3d7402d2 update README.zh.md. 2022-04-01 09:24:07 +00:00
weili10 22c2d837ca update README.zh.md. 2022-04-01 09:12:23 +00:00
weili10 dca21b621a update scripts/gen.sh. 2022-04-01 09:11:03 +00:00
weili10 c2a7d66b13 update scripts/gen.sh. 2022-04-01 09:09:14 +00:00
weili10 5e5a2a7925 update README.zh.md. 2022-04-01 09:08:05 +00:00
AtlasAccount a3bb1f25c4 同步1.5.0 fd0ceb73a7c14a6b28d3839ecbd9c95ae74ab1c6
!3299 [bugfix] 修复 BN scale参数dtype引起精度问题
    Merge pull request !3299 from 李超/master1
--
    !3288 [feature] 解除asstrided算子精确编译限制
    Merge pull request !3288 from 李超/master
2022-03-31 23:00:46 +08:00
i-robot 0d33ee3e0d !585 刷新api资料,diag算子仅支持diagonal=0场景
Merge pull request !585 from 戢芳/msg_diag
2022-03-31 13:31:04 +00:00
pipihugh 796d41d691 刷新api资料,diag算子仅支持diagonal=0场景 2022-03-31 19:35:06 +08:00
AtlasAccount bdb376cdb3 同步1.5.0 7c9813a3a6d68c0231749a53486299bbc9352858
!3297 shutdown 前主动释放process group相关资源
    Merge pull request !3297 from wangyu/master
2022-03-31 09:39:20 +08:00
AtlasAccount 4dc31edf9a 同步1.5.0 6a8be028864854d4e204677c90f8ed9e421211e9
!3287 【BugFix】修复inverse不支持fp16 out场景
    Merge pull request !3287 from 王晓/inverse
--
    !3290 【BugFix】lstm_cell增加bias=false的场景
    Merge pull request !3290 from 戢芳/lstm_cell_debug
--
    !3294 回退 Pull Request !3284 : 在npu shutdown流程前主动释放process group
    Merge pull request !3294 from weili10/revert-merge-3284-master
2022-03-29 23:00:51 +08:00
AtlasAccount aafe2061ac 同步1.5.0 1fe05e27602d1ceed302541e3da9b6b02ef19aea
!3284 在npu shutdown流程前主动释放process group
    Merge pull request !3284 from wangyu/master
2022-03-28 12:23:43 +08:00
AtlasAccount 2eaee92eb0 同步1.5.0 392a9d7e12c3af78ce45a4f4241e26f6cc7d7336
!3280 【1.5算子适配】 ReplicationPad1dBackward 算子适配
    Merge pull request !3280 from 沈鹏程/replicatback
2022-03-26 23:00:46 +08:00
AtlasAccount 416deb85dd 同步1.5.0 e48e6bd63caa8764fd85ed823ca563e182e15465
!3277 [feature] 删除TRI_COMBINED_ENABLE环境变量
    Merge pull request !3277 from 李超/master
--
    !3272 【1.5算子适配】lstm_cell_backward
    Merge pull request !3272 from 戢芳/lstm_cell_back1.5
--
    !3275 规避as strided算子精度问题
    Merge pull request !3275 from 蒋荣强/master
--
    !3262 Add verbose in enable graph mode & Enhance error information about GE interface
    Merge pull request !3262 from 汪瑞哲/coding
2022-03-24 22:17:53 +08:00
AtlasAccount f1891c36af 同步1.5.0 73ce683bf259cd2cc357989a7a0fc0dd8de070f7
!3271 修复MobileNetV2网络dump问题
    Merge pull request !3271 from 周司南/master
2022-03-24 15:34:53 +08:00
AtlasAccount e7e6580ca2 同步1.5.0 d4966fde08017b8ef41b0d6fa15b2593d0f1df76
!3264 【图模式】enbale static memory opt
    Merge pull request !3264 from 王强/master
2022-03-23 19:51:38 +08:00
尤安升 c1f3ad0761 del pytorch1.8.1 2022-03-23 19:50:28 +08:00
AtlasAccount 913f54dc61 同步1.5.0 af5a43963bf86227fce4005d608fa87b83de6ed9
!3265 【BugFix】dropout_with_add_softmax算子名回退
    Merge pull request !3265 from 戢芳/dropout1.5
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-03-22 21:12:04 +08:00
AtlasAccount 31c3f964bd 同步1.5.0 db48001ed53f91ab992c88990cb9f70f9cd9fd8c
!3261 增加显式调用domask和genmask的接口
    Merge pull request !3261 from lijing/master
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-03-22 15:35:59 +08:00
AtlasAccount f70a8b1e31 同步1.5.0 8e14e688a1d328e931838d6b6f0be1fd28c69484
!3259 [bugfix] 修复asstride计算错误问题
    Merge pull request !3259 from 李超/master
--
    !3253 【1.5算子适配】lstm_cell
    Merge pull request !3253 from 戢芳/lstm_cell_forward1.5
--
    !3239 DDP:修复broadcast_coalesced部分数据错误的问题
    Merge pull request !3239 from 袁舰/master
--
    !3251 [bugfix] 修复asstride计算错误问题
    Merge pull request !3251 from 李超/master
--
    !3258 【BugFix】dropout_with_add_softmax修改算子名
    Merge pull request !3258 from 戢芳/dropout1.5
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-03-21 23:01:05 +08:00
AtlasAccount 6d5a62b73d 同步1.5.0 acd1a7fe34e0da7552bad2978550fa1bd20f6ddb
!3255 【Sortv2支持-1轴排序】sort_without_indices
    Merge pull request !3255 from 周凡/sortwizf
--
    !3256 aoe刷新支持的算子列表
    Merge pull request !3256 from 施博/fix_aoe
--
    !3254 【Topk算子实现改变,删除large_topk分支】topk
    Merge pull request !3254 from 周凡/topk318
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-03-18 23:01:17 +08:00
AtlasAccount 4f5ed6616a 同步1.5.0 9f59490e7edb5454f8fba51febee6002564c2377
!3246 增加融合算子MultiHeadAttention正反向适配
    Merge pull request !3246 from 李思杰/multi_head_attention
--
    !3245 【bugfix】修复batch_nms问题
    Merge pull request !3245 from 王晓/batch_nms
--
    !3250 【BugFix】layer_norm算子UT更改
    Merge pull request !3250 from 戢芳/layer_norm1.5
--
    !3247 aoe dump功能:屏蔽对不进行调优的算子
    Merge pull request !3247 from 施博/fix_aoe
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-03-17 23:00:54 +08:00
AtlasAccount 8d535a9189 同步1.5.0 a9ff45c79ee5b4ac41cf226589c428dce579cf65
!3249 [feature] 非连续环境变量移除
    Merge pull request !3249 from 李超/master
--
    !3248 同步刷新aoe接口
    Merge pull request !3248 from 施博/aoe_update
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-03-16 23:00:53 +08:00
AtlasAccount 563de6fbd9 同步1.5.0 35e6c75271c1bc4b6b9c0739cf734a458fa6b439
!3244 【图模式】deal with the problem of constructing graphs for op NPUClearFloatStatus.
    Merge pull request !3244 from 王强/master
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-03-16 12:01:24 +08:00
AtlasAccount ed367a62b7 同步1.5.0 eb8fa3576eed877700b0619b7a54eec4a5506847
!3238 支持cann prof区分step信息
    Merge pull request !3238 from 施博/fix_cann
--
    !3237 图模式 scalar-memory能力增强+单算子场景指定标量格式为ND
    Merge pull request !3237 from 王强/dev
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-03-14 12:01:04 +08:00
AtlasAccount 3eecafe015 同步1.5.0 0da5e0e53b04208d0556cb58e8e275c7f08b8e46
!3236 【BugFix】修复dropout_with_add_softmax用例bug
    Merge pull request !3236 from 戢芳/drop1.5
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-03-11 23:01:00 +08:00
AtlasAccount 274004f7ad 同步1.5.0 1bec1e30648214d6b887241e85d52a9359efb6a0
!3234 【BugFix】修复layer_norm结果不匹配的问题
    Merge pull request !3234 from 戢芳/layer_norm1.5
--
    !3229 【功能回退】暂时不使能aclrtQueryEventStatus接口
    Merge pull request !3229 from 蒋荣强/master
--
    !3210 bugfix: 修改Bernoulli启动第2个aicpu代码,原方案不可行,只能支持一种输入情况开启并行
    Merge pull request !3210 from 郭夏/b
--
    !3220 【ctclossv2算子泛化,支持输入targets为1D的场景(原仅支持2D)】ctc_losss
    Merge pull request !3220 from 周凡/ctczf
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-03-10 23:00:54 +08:00
AtlasAccount 6b9315ad91 同步1.5.0 f12e79810fc1f2347baa10d36a02ef2e417ea0ce
!3224 dev 合入 master
    Merge pull request !3224 from 王强/master
--
    !3216 【BugFix】layer_norm算子问题修复
    Merge pull request !3216 from 戢芳/layer_norm1.5
--
    !3219 合并dev
    Merge pull request !3219 from wangyu/master
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-03-08 23:01:01 +08:00
AtlasAccount 3c9a47cd8c 同步1.5.0 702251cf53328a3761755877cb919a7c0cbd9680
!3214 kl_div 1.5算子需求增加
    Merge pull request !3214 from hxf12345677/kl
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-03-08 12:01:10 +08:00
AtlasAccount 586b3fa039 同步1.5.0 0bb991acd040a67ff19c124b6c4d5f02d04ace4c
!3211 【BugFix】grid_sampler算子的问题修复
    Merge pull request !3211 from 戢芳/gridsampler1.5
--
    !3207 修复dropout_with_byte_mask_精度bug
    Merge pull request !3207 from 詹隽/dropoutv3_dev_fix
--
    !3208 refactor(NpuAny Type): reimplement Npu Any type
    Merge pull request !3208 from 宇世康/master
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-03-07 23:00:51 +08:00
AtlasAccount e093b4359a 同步1.5.0 89cc8d62897d765284d550bf432f34d950dd5210
!3204 [bugfix] 禁止asstrided算子参与模糊编译
    Merge pull request !3204 from 李超/master
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-03-04 23:01:08 +08:00
AtlasAccount a861f3cb96 同步1.5.0 161dc9d87f9db4ae1cc4d688ad771bc2602f86e5
!3199 【FixBug】topk大规模场景性能问题适配规避
    Merge pull request !3199 from 王晓/topk
--
    !3197 【1.5算子适配】dropout_with_add_softmax融合算子
    Merge pull request !3197 from 戢芳/dropadd
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-03-03 23:00:52 +08:00
AtlasAccount 47b5c52129 同步1.5.0 89cc2e50c164bc3f5bf17e7c46af7280c2024d77
!3182 pytorch适配DropoutV3
    Merge pull request !3182 from 詹隽/dropoutv3
--
    !3189 【Topk算子实现改变,删除large_topk分支】topk
    Merge pull request !3189 from 周凡/topkzf
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-03-02 23:00:53 +08:00
weili10 f738240fd5 update OWNERS. 2022-03-02 09:21:52 +00:00
i-robot c837a70844 !338 资料合入
Merge pull request !338 from 彭子荣/master
2022-03-01 09:47:50 +00:00
weili10 2a323fab49 update OWNERS. 2022-03-01 09:43:37 +00:00
pengzirong 1a08ccad88 update pics&contents of pytroch网络模型移植&训练指南&Pytroch 安装指南
update

update url of Pytorch installation

update url of Pytorch installation
2022-03-01 17:29:35 +08:00
AtlasAccount f7b065414b 同步1.5.0 d710800a5dafa29aefd6d80bd12150f6f5d2b615
!3181 修改InputWithoutContiguous warning级别,避免强制打屏
    Merge pull request !3181 from 李超/master
--
    !3169 增加npu_format_cast.Tensor、get_npu_format接口,test: format_cast
    Merge pull request !3169 from 王晓/format_cast
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-02-25 15:59:50 +08:00
AtlasAccount b3fbc1dee0 同步1.5.0 055bf8ca2bc6b3e2fcb09d23844017800bdb2302
!3168 移动NPUEvent.h到c10路径下
    Merge pull request !3168 from wangyu/master
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-02-21 12:00:49 +08:00
AtlasAccount ba413bdc6c 同步1.5.0 d1d273166807a809d3c72126b166a4d9115ea527
!3163 合并dev分支
    Merge pull request !3163 from weili10/dev
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-02-18 12:00:59 +08:00
i-robot 5193ae8b44 !274 刷新api资料,query接口不支持
Merge pull request !274 from 施博/master
2022-02-18 01:31:52 +00:00
shibo19 48b35ef669 刷新api资料,query接口不支持 2022-02-17 19:52:32 +08:00
AtlasAccount e382982f9f 同步1.5.0 362f14f3d12c289a1269e79b9b94f1ebba5a6136
!3155 更改非连续Torch warn类别
    Merge pull request !3155 from 李超/master
--
    !3136 HCCL:修改计算bucket采用的size标准
    Merge pull request !3136 from 袁舰/master
--
    !3137 modify: 修改median调用fill_传参形式,避免调用scalar接口导致频繁编译问题
    Merge pull request !3137 from 郭夏/median
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-02-14 23:01:04 +08:00
AtlasAccount 3107fe16f7 同步1.5.0 ee97ee4d3b4402b50322b002425cf2cca8939f7c
!3143 [optimize] 转连续通用PTCopy算子替换为asStrided算子
    Merge pull request !3143 from 李超/git_asstride
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-02-14 12:00:45 +08:00
AtlasAccount 178f3bc3c8 同步1.5.0 f318a3ebbfa9ffda6f09c187824b24b0b53cc183
!3149 1.5.0 小版本号变更
    Merge pull request !3149 from 周司南/masterbk
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-02-11 14:28:35 +08:00
AtlasAccount c085ad4eb7 同步1.5.0 7e62822bd52eb78d27b9161dc7b68caf77a3094c
!3146 提供DDP分布式流程下,skip grad allreduce的能力
    Merge pull request !3146 from wangyu/master
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-02-08 23:00:43 +08:00
彭子荣 0fc3c3a7c4 参考图片 2022-02-08 03:12:34 +00:00
AtlasAccount f89c8a2187 同步1.5.0 a6e7c66af4d9f068792ba80afc3e521bb86d9a85
!3141 【功能维测】新增ut防止开启队列的动态场景下算子attr被重复释放
    Merge pull request !3141 from 蒋荣强/ut
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-02-07 23:00:46 +08:00
i-robot aeca353926 !171 bugfix:修复英文资料的路径和拼写错误
Merge pull request !171 from shibo/master
2022-01-29 09:31:36 +00:00
shibo 6e3d104476 修复英文资料的路径和拼写错误 2022-01-29 16:48:50 +08:00
i-robot d003421c1a !166 bugfix: 修复资料中拼写错误
Merge pull request !166 from shibo/master
2022-01-29 08:37:35 +00:00
shibo 193772bbea 修复拼写错误 2022-01-29 15:35:06 +08:00
AtlasAccount 9ae625472e 同步1.5.0 a37d767dd4110c6561b35a19ae53f265ea71f563
!3139 图模式去除设置High Precision
    Merge pull request !3139 from wangyu/master
--
    !3138 [optimization]非连续下发优化
    Merge pull request !3138 from 李超/git_contiguous
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-01-28 23:01:27 +08:00
AtlasAccount 26178c3a1b 同步1.5.0 2f354fcc04b2186126affa38d94613d733c1af6b
!3134 【维持】queue执行接口加RECORD_HOST_FUNCTION
    Merge pull request !3134 from 蒋荣强/record
--
    !3130 默认开启模糊编译缓存文件落盘
    Merge pull request !3130 from 宇世康/master
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-01-27 12:01:08 +08:00
AtlasAccount be5356c0c6 同步1.5.0 994f343554d44acd58bea036c0b21d05cd90bd80
!3132 修改门禁把resnet作为必跑用例
    Merge pull request !3132 from 龚俊强/master
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-01-26 23:01:14 +08:00
AtlasAccount b3372ee933 同步1.5.0 fc962f2d66fc3ebb4183a5305f1c083cac522e7f
!3129 merge dev
    Merge pull request !3129 from 宇世康/master
--
    !3117 LinearBackwardKernelNpu中增加对grad的format校验,避免两次linear_backward_out_npu中对grad重复的transdata
    Merge pull request !3117 from 王姜奔/master
--
    !3124 【1.5算子适配】 ReplicationPad1d 算子适配(2)
    Merge pull request !3124 from 沈鹏程/rep
--
    !3102 【1.5算子适配】 reflectionPad1d 算子适配
    Merge pull request !3102 from 沈鹏程/reflectionPad1d
--
    !3126 回退 Pull Request !3114 : [optimize] 非连续转连续下发优化
    Merge pull request !3126 from weili10/revert-merge-3114-master
--
    !3120 fix option
    Merge pull request !3120 from 宇世康/dev
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-01-25 23:00:43 +08:00
AtlasAccount e96c816b06 同步1.5.0 05af491da69a887ee164bc6907ffbfec7df8a6c1
!3114 [optimize] 非连续转连续下发优化
    Merge pull request !3114 from 李超/contiguous0121
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-01-24 23:01:59 +08:00
AtlasAccount 7eeb579f3f 同步1.5.0 b5bb63fbee5ef9d0147b66a474d26f4129203516
!3116 [optimize] 非连续转连续下发优化-part1-UT修改
    Merge pull request !3116 from 李超/master
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
2022-01-23 23:01:10 +08:00
AtlasAccount c489d97007 同步1.5.0 e41693cd9a610d956c3fe7ea93cc14f96685fe2b
同步1.8.1 5ef4201b03e2651946576f806bef9fdaa7aa1d86
    !2903 1.8.1 addcmul算子适配
    Merge pull request !2903 from 孙幸/1.8_addcmul
--
    !3071 【1.8算子移植】 rsub 算子适配
    Merge pull request !3071 from 沈鹏程/1.8_rsub
--
    !2906 1.8.1 affinegridgenerator算子适配
    Merge pull request !2906 from 孙幸/1.8_affinegridgenerator
--
    !3105 【1.8.1算子适配】ger
    Merge pull request !3105 from 戢芳/ger1.8.1
--
    !3066 remainder1.8.1算子适配
    Merge pull request !3066 from hxf12345677/remainder
2022-01-22 12:00:45 +08:00
i-robot ca485063d0 !106 Updated FrameworkPTAdapter 2.0.4 Release Notes
Merge pull request !106 from yanhuiling/master
2022-01-22 02:48:07 +00:00
AtlasAccount 3cd7ed797d 同步1.5.0 e41693cd9a610d956c3fe7ea93cc14f96685fe2b
!3081 UT 公共文件调整
    Merge pull request !3081 from 龚俊强/master
同步1.8.1 82c1938da320d69e05d03498163d64defc76eb1a
    !3115 ceil算子1.8.1移植
    Merge pull request !3115 from hxf12345677/ceil
--
    !3108 【1.8.1算子适配】 Add Arange Operator
    Merge pull request !3108 from 周凡/NewArangezf
2022-01-21 23:00:55 +08:00
AtlasAccount 6ca23d5514 同步1.5.0 bc11aeb9574ec4229d260f6e335f9b94b9898d3a
同步1.8.1 7b005e2b1e14a04f1aea3a5d4f2e79279f7afff5
    !3103 batch_norm_backward_reduce算子1.8.1移植
    Merge pull request !3103 from hxf12345677/batch_norm_backward_reduce
2022-01-21 12:01:25 +08:00
yanhuiling 287c6e6cc3 update docs/en/RELEASENOTE/FrameworkPTAdapter 2.0.4 Release Notes.md. 2022-01-21 02:30:39 +00:00
yanhuiling 316cc29ee2 Updated this file 2022-01-21 02:27:55 +00:00
yanhuiling f77253ae52 删除文件 docs/en/RELEASENOTE/RELEASENOTE.md 2022-01-21 02:27:44 +00:00
AtlasAccount ae834d5ab6 同步1.5.0 bc11aeb9574ec4229d260f6e335f9b94b9898d3a
!3094 新增对ACL_AUTO_TUNE_MODE的设置的回调函数
    Merge pull request !3094 from 王姜奔/master
同步1.8.1 1fef46b8e6ced0439c22e93488794af076d0bb14
    !3083 【1.8算子迁移】npu_giou
    Merge pull request !3083 from wuxiankun/1.8giou
--
    !3089 【1.8算子适配】 Addbmm 算子适配
    Merge pull request !3089 from 沈鹏程/fix_errorName
--
    !3088 【1.8算子适配】 BinaryCrossEntropy 算子
    Merge pull request !3088 from 沈鹏程/1.8_Bce
--
    !3093 【1.8算子迁移】fast_gelu
    Merge pull request !3093 from wuxiankun/1.8fastgelu
--
    !3033 【1.8.1算子适配】log2
    Merge pull request !3033 from 王晓/1.8.1_log2
2022-01-20 23:00:53 +08:00
i-robot 824e689004 !103 资料合入1.18
Merge pull request !103 from 彭子荣/master
2022-01-20 11:10:54 +00:00
i-robot 456439d5fa !105 [资料修改] readme添加支持python3.9描述
Merge pull request !105 from 李超/master
2022-01-20 04:00:50 +00:00
李超 073a7ea5ff add python 3.9 to readme 2022-01-20 09:21:01 +08:00
AtlasAccount 5f3a2c11fc 同步1.5.0 a64dee29b83da4595f794a8a3f732750deac1fbb
!3082 【功能维测】增加acl接口失败时error msg打印
    Merge pull request !3082 from 蒋荣强/errmsg
同步1.8.1 4068c9ee00fc7808716c5bc10366340e58b837f4
    !3051 gather1.8.1算子移植
    Merge pull request !3051 from hxf12345677/gather
--
    !3070 【1.8算子适配】index
    Merge pull request !3070 from 戢芳/index1.8.1
2022-01-19 23:00:48 +08:00
彭子荣 c61f676a86 update docs/zh/RELEASENOTE/RELEASENOTE.md. 2022-01-19 02:12:47 +00:00
AtlasAccount 05b72bbd37 同步1.5.0 874be2eee35aa7e78f38d50936501a33a7992783
!3069 check_operators_in_prof 函数移入common目录
    Merge pull request !3069 from 龚俊强/master
--
    !3025 【Bugfix】pow不合理ut修改
    Merge pull request !3025 from wuxiankun/powfix
--
    !3068 pytorch单算子&图模式 GE初始化归一
    Merge pull request !3068 from wangyu/master
同步1.8.1 ec77daa5dbb2c1576105932848cd7411eb762d16
    !2679 add: grid_sampler_3d and backward for 1.8.1
    Merge pull request !2679 from 郭夏/grid_sampler_3d
2022-01-18 23:00:48 +08:00
pengzirong 5cc52fb0d1 delete 2022-01-18 17:23:39 +08:00
pengzirong fd7df84a23 update &delete 2022-01-18 17:22:07 +08:00
AtlasAccount b9b4bb55f2 同步1.5.0 007013d041515737cdc132a588baef68937739bc
!3024 【Optim】dropout模糊编译场景下用storage_size
    Merge pull request !3024 from wuxiankun/dropoutfix
同步1.8.1 de30180167ec61b5a87b6b736dce099e48b702f0
    !3049 【1.8.1算子适配】 Add Embedding Operator
    Merge pull request !3049 from 周凡/Embeddingzf
2022-01-17 23:00:51 +08:00
AtlasAccount 5c4774edfd 同步1.5.0 d47b18923e83b31836a378c1f25a7d6b38a35246
同步1.8.1 7b5815af14f46887f5a6f96a853ec42540d45439
    !3050 【1.8.1算子适配】nonzero
    Merge pull request !3050 from 戢芳/nonzero1.8.1
--
    !3048 【1.8.1算子适配】log
    Merge pull request !3048 from 戢芳/log1.8.1
--
    !3036 full1.8.1移植
    Merge pull request !3036 from hxf12345677/full
2022-01-17 12:00:50 +08:00
i-robot 9e8c744c9b !95 资料合入
Merge pull request !95 from 彭子荣/master
2022-01-17 03:29:33 +00:00
weili10 c69b311610 update README.zh.md. 2022-01-17 02:54:41 +00:00
AtlasAccount 4fc41a0ba9 同步1.5.0 d47b18923e83b31836a378c1f25a7d6b38a35246
!3041 非连续ut新增场景识别功能
    Merge pull request !3041 from 李超/contut_git
同步1.8.1 f5798433897cec7315b3c4975ebea87f870216ac
    !3032 bitwise_and 算子1.8.1移植
    Merge pull request !3032 from hxf12345677/bitwise_and
--
    !3007 【1.8算子适配】addcdiv算子适配
    Merge pull request !3007 from 戢芳/addcdiv1.8.1
--
    !3017 floor_divide算子  1.8移植
    Merge pull request !3017 from hxf12345677/floordivided
2022-01-14 23:00:47 +08:00
AtlasAccount 5e85916c11 同步1.5.0 2ed40e98c3f5324ed4688964b8e2e83672a4d11b
!3044 codecheck问题解决
    Merge pull request !3044 from shibo/codecheck_master
同步1.8.1 74798a86310dbeea6f2465943d62b08ff7242a13
    !3045 codecheck问题解决
    Merge pull request !3045 from shibo/codecheck_1.8
2022-01-14 11:08:22 +08:00
AtlasAccount 087c31c639 同步1.5.0 609b84e21970541672b3a3d778b457999d948a61
!3031 【FixBug】修复mul原地接口不支持bool类型的问题
    Merge pull request !3031 from 王晓/bool_mul_
--
    !3038 【BugFix】解决eye不支持bool类型的泛化问题
    Merge pull request !3038 from 陈庆/eye
--
    !2999 【图模式】为AOE不支持私有格式所做的一些工作
    Merge pull request !2999 from 宇世康/master
同步1.8.1 e6365127cfc0cfe901d34cc95687a8ae2b3e59d4
    !3040 【1.8算子适配】norm
    Merge pull request !3040 from 戢芳/norm1.8.1
--
    !3037 【1.8.1算子适配】 Add Bitwise_not Operator
    Merge pull request !3037 from 周凡/bitwise_notzf
--
    !3030 【1.8算子移植  bugfix】asin 算子适配  增加了check memory 、nochenk和checkout操作
    Merge pull request !3030 from 沈鹏程/1.8_asin
2022-01-13 23:00:48 +08:00
i-robot 5043e98a9d !97 Updated English documents in Pytorch docs
Merge pull request !97 from yanhuiling/master
2022-01-13 08:34:36 +00:00
i-robot da46157333 !96 【轻量级 PR】:Updated docs/en/RELEASENOTE/RELEASENOTE.md.
Merge pull request !96 from yanhuiling/N/A
2022-01-13 08:32:37 +00:00
AtlasAccount e4d4da89fb 同步1.5.0 b2885acb09ab80f7e83e7905103428e21767ec1c
!3023 修改cla错误注册路径
    Merge pull request !3023 from 周司南/master
--
    !3021 E2E prof: 增加RTS数据
    Merge pull request !3021 from shibo/update_e2e
同步1.8.1 d5a74a059f253c36d95d2e3147add3b73de69dc1
    !3020 【1.8算子适配】masked_fill_
    Merge pull request !3020 from 戢芳/masked_fill_1.8.1
--
    !3015 【1.8.1算子适配】 Add Sign Operator
    Merge pull request !3015 from 周凡/Signzf
2022-01-13 12:01:08 +08:00
yanhuiling 33ddeeacc1 updated this file 2022-01-13 01:35:53 +00:00
yanhuiling 7c25c163b5 updated this file 2022-01-13 01:24:38 +00:00
AtlasAccount 44456a207d 同步1.5.0 fe7bb42f9ad101851e6666d1f693cc832bb563e8
!2987 重构优化:将获取reducetion算子的reduce str属性方法提取
    Merge pull request !2987 from shibo/reduce_refactor
同步1.8.1 85feac381d2696f90686bddf4a1b20642feac2de
    !3013 【1.8算子适配】sort
    Merge pull request !3013 from 戢芳/sort1.8.1
--
    !2969 【1.8.1算子适配】 asin 算子适配
    Merge pull request !2969 from 沈鹏程/1.8_asin
2022-01-12 23:00:47 +08:00
yanhuiling e4545fc3a1 Updated this file 2022-01-12 13:07:55 +00:00
yanhuiling 4c55098d78 删除文件 docs/en/PyTorch Operator Support/PyTorch Operator Support.md 2022-01-12 13:07:22 +00:00
yanhuiling 6e5333f278 Updated this file 2022-01-12 13:07:00 +00:00
yanhuiling 5de24000dc 删除文件 docs/en/ONNX Operator List/ONNX Operator List.md 2022-01-12 13:06:40 +00:00
yanhuiling a70b2dc515 Updated this file 2022-01-12 13:06:04 +00:00
yanhuiling ce1a48074f 删除文件 docs/en/PyTorch Network Model Porting and Training Guide/PyTorch Network Model Porting and Training Guide.md 2022-01-12 13:05:39 +00:00
yanhuiling e6c723cf1d Added new three files. 2022-01-12 13:03:40 +00:00
彭子荣 5bd7ddf2b6 !1 update docs/en/PyTorch Operator Development Guide/PyTorch Operator Development Guide.md.
Merge pull request !1 from 阿里斯开扇/N/A
2022-01-12 02:08:50 +00:00
彭子荣 f519cc5110 !2 update docs/en/PyTorch Installation Guide/PyTorch Installation Guide.md.
Merge pull request !2 from 阿里斯开扇/N/A
2022-01-12 02:08:16 +00:00
彭子荣 3dd19b2755 !3 update docs/en/PyTorch Online Inference Guide/PyTorch Online Inference Guide.md.
Merge pull request !3 from 阿里斯开扇/N/A
2022-01-12 02:07:24 +00:00
AtlasAccount c441c8ab11 同步1.5.0 e04468a8072a298400e4663930375dac5e7c271b
同步1.8.1 226b38852b3d5f13696bddd50d98be6e4201b169
    !3011 BinaryCrossEntropyWithLogitsKernelNpu 算子适配
    Merge pull request !3011 from 沈鹏程/1.8_BinaryCrossEntropyWithLogitsKernelNpu
--
    !3012 upsample_nearest2d_backward.grad_input修改
    Merge pull request !3012 from hxf12345677/upsample_nearest2d_backward
--
    !2678 add: grid_sampler for 1.8.1
    Merge pull request !2678 from 郭夏/grid_sampler
2022-01-11 23:00:47 +08:00
阿里斯开扇 675e0d7869 update docs/en/PyTorch Online Inference Guide/PyTorch Online Inference Guide.md.
少量优化
2022-01-11 12:13:11 +00:00
阿里斯开扇 4c9cc52b0e update docs/en/PyTorch Installation Guide/PyTorch Installation Guide.md.
少量优化
2022-01-11 11:56:00 +00:00
yanhuiling 5f326039fd Updated docs/en/RELEASENOTE/RELEASENOTE.md.
Updated the English version based on the Chinese version.
2022-01-11 11:24:54 +00:00
阿里斯开扇 62fed021fe update docs/en/PyTorch Operator Development Guide/PyTorch Operator Development Guide.md.
少量优化
2022-01-11 11:19:59 +00:00
AtlasAccount 91837b9a3b 同步1.5.0 3cb40ae6d0f4a1ad2a059428e1d0a52a2a031573
!2883 modify: upsample_nearest3d反向支持FP16输入
    Merge pull request !2883 from 郭夏/upsample_nearest3d
同步1.8.1 b36205a79412c995f8af9d3dc1ce4f689230fdcf
    !2718 【1.8.1适配“MaxUnpool2d”】
    Merge pull request !2718 from 李攀/do_1.8.1
--
    !2988 添加UT:dataloader模块
    Merge pull request !2988 from shibo/add_data_181
--
    !3006 BinaryCrossEntropy算子适配
    Merge pull request !3006 from 沈鹏程/1.8_Bce
--
    !2970 argsort算子适配
    Merge pull request !2970 from 沈鹏程/1.8_argsort
--
    !2985 Argmax算子适配
    Merge pull request !2985 from 沈鹏程/1.8_argmax
2022-01-11 12:01:13 +08:00
AtlasAccount 57299e8539 同步1.5.0 a171f976cd63fd9c1827f0250862d74811a6dfae
同步1.8.1 2d27390353026584b536879952b84532e06ed4d3
    !2994 atan算子适配
    Merge pull request !2994 from 沈鹏程/1.8_atan
--
    !2990 atan2算子适配
    Merge pull request !2990 from 沈鹏程/1.8_atan2
--
    !3005 clamp算子适配
    Merge pull request !3005 from 沈鹏程/1.8_clamp
2022-01-10 23:00:46 +08:00
pengzirong 3a01034b86 update onnx operator support list 2022-01-10 11:46:45 +08:00
AtlasAccount e6ed5931a7 同步1.5.0 a171f976cd63fd9c1827f0250862d74811a6dfae
同步1.8.1 6d17cfd33a1f5783949d45fd9090da0fa886a61e
    !2977 单元测试引用文件结构
    Merge pull request !2977 from 龚俊强/pytorch1.8.1
2022-01-08 23:00:46 +08:00
AtlasAccount f7cd5ac04a 同步1.5.0 a171f976cd63fd9c1827f0250862d74811a6dfae
!3000 路径拼接使用os.path.join 代替直接字符串加
    Merge pull request !3000 from 龚俊强/master
--
    !3001 回退代码
    Merge pull request !3001 from wangyu/master
同步1.8.1 8937dfc7728adc20d3e5a8f8e6907a37361dd7d0
2022-01-07 23:00:52 +08:00
i-robot b05f263002 !93 资料合入
Merge pull request !93 from 彭子荣/master
2022-01-07 04:00:40 +00:00
pengzirong 8c5dd060e3 fix erro 2022-01-07 11:31:36 +08:00
pengzirong ac5c210a3f delete 2022-01-07 09:42:54 +08:00
pengzirong dde15147ef new file 2022-01-07 09:22:24 +08:00
pengzirong b08e75eb9b delete 2022-01-07 09:22:01 +08:00
pengzirong 8eb3985a69 Merge branch 'master' of gitee.com:peng-zirong/pytorch 2022-01-07 09:21:49 +08:00
pengzirong 745ea1d2ca new file 2022-01-07 09:21:24 +08:00
pengzirong 67d8b2d801 delete 2022-01-07 09:21:05 +08:00
pengzirong 0774236c93 new file 2022-01-07 09:18:23 +08:00
pengzirong 40c47421ab delete 2022-01-07 09:17:42 +08:00
pengzirong 3fbdcf7b02 Merge branch 'master' of gitee.com:peng-zirong/pytorch 2022-01-07 09:16:11 +08:00
AtlasAccount 150a34d6b9 同步1.5.0 c38bbfd7b64217ee049b8125ebf7497c2613c50f
!2997 【功能修复】解决因为memset导致的内存泄漏问题
    Merge pull request !2997 from 蒋荣强/memory
--
    !2961 [Requirement] 模型需求 var 算子适配
    Merge pull request !2961 from 沈鹏程/adapt_var
同步1.8.1 8937dfc7728adc20d3e5a8f8e6907a37361dd7d0
2022-01-06 23:00:52 +08:00
pengzirong 53296dbd84 delete 2022-01-06 17:52:47 +08:00
pengzirong b81e31a023 new files 2022-01-06 17:49:27 +08:00
pengzirong 4a91d7f244 delete all files 2022-01-06 17:49:05 +08:00
AtlasAccount f99e45f951 同步1.5.0 752642b4993a90359274fe49efeeace9718cde66
!2967 rotatediou适配     在原基础上增加两个attr属性
    Merge pull request !2967 from 沈鹏程/rotatediou_adapt
同步1.8.1 8937dfc7728adc20d3e5a8f8e6907a37361dd7d0
2022-01-06 12:00:50 +08:00
AtlasAccount 6b932a1c14 同步1.5.0 1e7b9443e574817d7513413e37d52254b0cfd93e
!2980 【bugfix】torch1.5不支持python3.9.不再提供编包支持
    Merge pull request !2980 from 李超/master
同步1.8.1 8937dfc7728adc20d3e5a8f8e6907a37361dd7d0
2022-01-05 23:00:47 +08:00
AtlasAccount 081221378d 同步1.5.0 7448ccd0ad9192c58cab04ef1c1097144c63b624
!2974 优化 graph_utils.py 引用结构
    Merge pull request !2974 from 龚俊强/master
--
    !2971 【泛化】适配层兜底,泛化BatchNormGatherStatsWithCounts算子精度
    Merge pull request !2971 from wuxiankun/bngswc16
同步1.8.1 8937dfc7728adc20d3e5a8f8e6907a37361dd7d0
    !2968 argmin算子适配
    Merge pull request !2968 from 沈鹏程/1.8_Argmin
--
    !2976 【支持3.9】pytorch1.8.1支持python3.9环境编包
    Merge pull request !2976 from 李超/pytorch1.8.1
2022-01-04 23:00:49 +08:00
AtlasAccount 8ef0a73f52 同步1.5.0 4aefefb8b34ba797713af6cea714fd3607fb3fd3
!2964 bugfix   处理   由于输出shape为空,导致模型报错问题
    Merge pull request !2964 from 沈鹏程/bug_fix1
同步1.8.1 b59213c0dad6f3384b4556683c023011f8fe1417
2021-12-31 23:00:47 +08:00
AtlasAccount fb4a88b4df 同步1.5.0 8c5b04d0e2827d4ea72a29f79edaebe8cba38a40
!2960 回退:reduce_op 影响范围广,不能再公共层修改
    Merge pull request !2960 from shibo/master
同步1.8.1 b59213c0dad6f3384b4556683c023011f8fe1417
2021-12-31 12:00:49 +08:00
AtlasAccount dbc635ffd8 同步1.5.0 6fcdca5a55cf72fa4ea07518a9ffedf72d7ae813
!2956 bugfix   处理 由于输出为空shape,导致模型报错问题
    Merge pull request !2956 from 沈鹏程/bug_fix
--
    !2957 bugfix 处理 由于输出为空shape,导致模型报错问题
    Merge pull request !2957 from 沈鹏程/bug_fix1
--
    !2954 【Bugfix】SyncBNTrainingUpdate 支持5hd操作
    Merge pull request !2954 from wuxiankun/204tr204tr5synbcwit
同步1.8.1 b59213c0dad6f3384b4556683c023011f8fe1417
    !2910 All算子适配
    Merge pull request !2910 from 沈鹏程/1.8_all
2021-12-30 23:00:47 +08:00
AtlasAccount 341a0d458e 同步1.5.0 b703cc7e3e21142ce0210f36f9b339e82a79bb92
!2948 【功能优化】队列执行接口增加RECORD_HOST_FUNCTION
    Merge pull request !2948 from 蒋荣强/master
同步1.8.1 ca365306224b30011046732c31a9766a3fcd608a
2021-12-30 12:00:49 +08:00
AtlasAccount 30dea0aa6b 同步1.5.0 15f933e18f5c64b5e1f4f2e46ab6ea59ac0caa85
!2949 修复bug,图模式set option之前先check option长度
    Merge pull request !2949 from wangyu/master
--
    !2945 【性能优化】增大release queue的size,避免队列归一后出现release queue满队列
    Merge pull request !2945 from 蒋荣强/ReleaseQueue
同步1.8.1 ca365306224b30011046732c31a9766a3fcd608a
2021-12-29 23:00:49 +08:00
AtlasAccount 9e457706a6 同步1.5.0 3589de64c034ae33997c1951003db08fb167f751
!2942 E2E prof:ut修改
    Merge pull request !2942 from shibo/e2e_bugfix
同步1.8.1 ca365306224b30011046732c31a9766a3fcd608a
2021-12-29 12:01:04 +08:00
AtlasAccount 9541c9b673 同步1.5.0 e08b3ae490cd0a3f0e358caa3a2a7f3b453e5708
!2932 modify:logical_and适配支持更多dtype类型输入
    Merge pull request !2932 from 郭夏/logical_and
--
    !2929 SyncBatchNorm: 修改命名、修复codecheck
    Merge pull request !2929 from 袁舰/master
--
    !2880 modify: upsample_trilinear3d正反向支持FP16输入
    Merge pull request !2880 from 郭夏/upsample_trilinear3d
同步1.8.1 ca365306224b30011046732c31a9766a3fcd608a
2021-12-28 23:00:44 +08:00
AtlasAccount ec8cc698f9 同步1.5.0 03c06784b9377d170df34173012e6f1e5d752161
!2939 合并dev分支
    Merge pull request !2939 from weili10/dev
--
    !2938 整理环境变量UT_FAST_MODE
    Merge pull request !2938 from 龚俊强/master
同步1.8.1 ca365306224b30011046732c31a9766a3fcd608a
    !2884 1.8.1 __And__算子适配
    Merge pull request !2884 from 孙幸/1.8_And
2021-12-27 23:00:51 +08:00
AtlasAccount 886e7defe3 同步1.5.0 53d356a5e5ddd64ea7f02df1d6ae4d6e6415962a
!2937 【modify】celu底层算子IR修改,pytorch同步修改
    Merge pull request !2937 from 王晓/celu
--
    !2935 修改test\test_npu目录下import语句
    Merge pull request !2935 from 龚俊强/master
--
    !2936 【图模式】图模式走GE的推理模式
    Merge pull request !2936 from 宇世康/master
同步1.8.1 b034ed3575df353a16ddfce2345c751982a02b3f
    !2909 Any算子适配
    Merge pull request !2909 from 沈鹏程/1.8_adaption
--
    !2922 1.8.1 addbmm+bmm算子适配
    Merge pull request !2922 from 孙幸/1.8_addbmm
2021-12-25 23:02:04 +08:00
AtlasAccount 8d079ca335 同步1.5.0 e7dbd0e1c5cc7020b673d836e8f7b0bfb0273b14
!2919 修复codexdex问题
    Merge pull request !2919 from 周司南/master
同步1.8.1 de23fbe927c2cf47ea37da06a001735b3cc65904
2021-12-23 23:01:00 +08:00
AtlasAccount dd58af6101 同步1.5.0 44c3eb40a822b553a7c7e4c86856f6dfaab1d247
!2916 SyncBatchNorm: NPU支持SyncBatchNorm特性
    Merge pull request !2916 from 袁舰/master
--
    !2925 embeding_bag正向host cpu处理&增加测试用例
    Merge pull request !2925 from 牛作东/emb_new
--
    !2923 【BugFix】SyncBn相关算子在混合精度的异常dtype问题修改
    Merge pull request !2923 from wuxiankun/syncbnfix
--
    !2914 bugfix:修复安全问题,对于nullptr检查
    Merge pull request !2914 from shibo/fix_null
--
    !2913 bugfix: cann prof在start时需要同步,保证device上算子全部执行完成
    Merge pull request !2913 from shibo/cann_fix
同步1.8.1 de23fbe927c2cf47ea37da06a001735b3cc65904
2021-12-22 23:01:08 +08:00
AtlasAccount b3a172415b 同步1.5.0 7e61d03b1349f162b348f5a16676252377fb56e1
!2891 【适配】自定义接口npu_rotated_box_encode和npu_rotated_box_decode适配
    Merge pull request !2891 from 陈庆/rotated_box
--
    !2905 bugfix  adapt RotatedIou
    Merge pull request !2905 from 沈鹏程/adaptIR
同步1.8.1 de23fbe927c2cf47ea37da06a001735b3cc65904
2021-12-21 23:00:48 +08:00
AtlasAccount 35c09c5858 同步1.5.0 95f1549a1eadb6c7c7e55033aaaa75810b5ce3aa
!2896 UT全量测试加入test_graph_mode test_dynamic_ops等目录下的用例
    Merge pull request !2896 from 龚俊强/master
同步1.8.1 de23fbe927c2cf47ea37da06a001735b3cc65904
    !2890 1.8.1 __Rshift__算子适配
    Merge pull request !2890 from 孙幸/1.8_Rshift
2021-12-21 12:00:51 +08:00
AtlasAccount da90916ab0 同步1.5.0 52e8bc75379dc3079e31ccbeb65ccebc3a80f191
!2897 embedding_bag_backward_npu hostcpu适配实现
    Merge pull request !2897 from 牛作东/master
--
    !2901 合并dev分支
    Merge pull request !2901 from weili10/dev
--
    !2904 python3.9环境jit index parsing告警解除
    Merge pull request !2904 from 李超/master
--
    !2902 修复E2E prof多次调用的问题
    Merge pull request !2902 from shibo/e2e_bugfix
同步1.8.1 f9f494b14ca91bbf236f99f78aef3927c7c3cdab
2021-12-20 23:24:47 +08:00
i-robot 12364d5728 !85 迭代3 需求
Merge pull request !85 from liuquan/master
2021-12-20 07:44:53 +00:00
liuquan eec0f1d6e1 quick start 2021-12-20 11:15:43 +08:00
AtlasAccount 8efe0da55e 同步1.5.0 9b0a379565e3d54a388600c587bc706356778d22
!2895 【FixUp】`Div`算子替换为`RealDiv`,满足int32下的负数的小数位处理
    Merge pull request !2895 from wuxiankun/RealDiv
同步1.8.1 f9f494b14ca91bbf236f99f78aef3927c7c3cdab
    !2881 1.8.1算子适配:index_select
    Merge pull request !2881 from 王晓/1.8_index_select_1
2021-12-18 23:01:13 +08:00
AtlasAccount 86b2def4fc 同步1.5.0 da86ec1bc3c86cfc584d4b5e94330a69367d1242
!2774 for potorch org test case
    Merge pull request !2774 from 邱彬/master
同步1.8.1 db9b820f4aba41894f26e187a67450e4b2064a4c
2021-12-17 23:00:55 +08:00
AtlasAccount 86c8e6deb9 同步1.5.0 3caf6d087849ae99931af5393a5c0c747e1330a6
!2794 【Issue】】Silu支持inplace
    Merge pull request !2794 from wuxiankun/issue1.0
--
    !2775 补充ut测试用例
    Merge pull request !2775 from 王夏夏/master
同步1.8.1 db9b820f4aba41894f26e187a67450e4b2064a4c
2021-12-16 23:02:06 +08:00
AtlasAccount e966169b78 同步1.5.0 704b98e1c093599b549fc69004270956af73b6b9
!2749 【Requirement】SyncBatchnorm内部接口算子batch_norm_gather_stats_with_counts适配
    Merge pull request !2749 from wuxiankun/bngswc
--
    !2874 prof增加UT用例
    Merge pull request !2874 from shibo/e2e_ut
--
    !2876 bugfix:修复profiler可能多次初始化错误
    Merge pull request !2876 from shibo/master
同步1.8.1 db9b820f4aba41894f26e187a67450e4b2064a4c
2021-12-16 12:02:47 +08:00
AtlasAccount 504fa67da2 同步1.5.0 d3724a9f1132ddb957773d154b801584903caa18
!2865 [Requirement] 模型需求 rotated_iou算子adapt
    Merge pull request !2865 from 沈鹏程/adaptIR
--
    !2882 Task: clean codecheck warnings
    Merge pull request !2882 from 赵光灿/master
同步1.8.1 db9b820f4aba41894f26e187a67450e4b2064a4c
2021-12-15 23:03:23 +08:00
AtlasAccount 37ee6fafaa 同步1.5.0 f1e3ae1004dd8b609c2c1ab4062a4769d31202c2
!2855 【Optim&reFactor】addcdivfp16转fp32提高精度优化
    Merge pull request !2855 from wuxiankun/addcdiv16
--
    !2856 【FixBug】BatchNormBackwardReduce针对未定义时tensor的问题修复
    Merge pull request !2856 from wuxiankun/bnwcbug
--
    !2878 【fixbug】加入空实现修复cpu编译
    Merge pull request !2878 from wuxiankun/bertadam
--
    !2852 bug: 修改batchnorm推理失败错误问题
    Merge pull request !2852 from 郭夏/bntrainingupdate
同步1.8.1 db9b820f4aba41894f26e187a67450e4b2064a4c
    !2863 【fixbug】修复1.8.1 ne重复分发的问题
    Merge pull request !2863 from 王晓/pytorch1.8.1
--
    !2879 clean codecheck warnings
    Merge pull request !2879 from 龚俊强/pytorch1.8.1
2021-12-14 23:02:11 +08:00
AtlasAccount cb11345fbe 同步1.5.0 fd0700df1eca64d01571072bb51d56143e3efde3
!2877 单元测试算子出错时加入resnet18测试
    Merge pull request !2877 from 龚俊强/master
--
    !2873 【适配】自定义接口npu_nms_rotated适配
    Merge pull request !2873 from 陈庆/nms
--
    !2871 Task: clean codecheck warnings
    Merge pull request !2871 from 赵光灿/master
同步1.8.1 558f739f09d9f9422ec0f8e283c9f80ab62b42e5
    !2872 删除pytorch181 test/test_npu/目录下重复的testcase
    Merge pull request !2872 from 龚俊强/pytorch1.8.1
--
    !2870 Feature: add NPU AMP testcases
    Merge pull request !2870 from 赵光灿/pytorch1.8.1
2021-12-14 12:00:47 +08:00
AtlasAccount 166c725588 同步1.5.0 5a25bc8c316500e25ec05872fab20c11263300bf
!2840 【适配】解决upsample_nearest1d不支持fp16场景
    Merge pull request !2840 from 陈庆/upsample
--
    !2848 E2E prof刷新:使用rangeStart方式代替push和pop
    Merge pull request !2848 from shibo/fix_e2e
--
    !2861 cann prof: bugfix
    Merge pull request !2861 from shibo/master
同步1.8.1 b43c20ebdc1a9654362128a1e0c026592997cbb3
2021-12-11 23:02:29 +08:00
AtlasAccount 4f4eaecb7f 同步1.5.0 ffe6546441045daf30e2160d9dedc3f804b9f256
!2868 回退 Pull Request !2828 : 【BugFix】adaptive_max_pool2d更换底层算子
    Merge pull request !2868 from shibo/revert-merge-2828-master
--
    !2867 回退 Pull Request !2833 : 【FixBug】max_pool2d泛化增强
    Merge pull request !2867 from shibo/revert-merge-2833-master
同步1.8.1 b43c20ebdc1a9654362128a1e0c026592997cbb3
2021-12-11 12:01:24 +08:00
liuquan 4603744324 updata 2021-12-10 17:05:42 +08:00
liuquan 501c17aade remove PyTorch API 2021-12-10 16:57:30 +08:00
liuquan b998cd272d updata API 2021-12-10 16:12:35 +08:00
i-robot bed57e03c3 !84 添加开源社区贡献文档CONTRIBUTING.zh.md
Merge pull request !84 from shibo/add_docs
2021-12-10 02:32:04 +00:00
AtlasAccount 1cba4e9e8c 同步1.5.0 9af15479e7efd03da611ca897f106bd8d86980bb
!2846 【图模式】修改编译选项option配置+使用data构图避免重复编译
    Merge pull request !2846 from 王强/master
--
    !2833 【FixBug】max_pool2d泛化增强
    Merge pull request !2833 from 王晓/max_pool2d
--
    !2854 [bugfix] 更改HCCL编译依赖so版本
    Merge pull request !2854 from 李超/master
--
    !2828 【BugFix】adaptive_max_pool2d更换底层算子
    Merge pull request !2828 from 王晓/adaptive_max_pool2d
--
    !2829 添加开源社区贡献文档CONTRIBUTING.zh.md
    Merge pull request !2829 from 周司南/master
同步1.8.1 b43c20ebdc1a9654362128a1e0c026592997cbb3
2021-12-09 23:00:58 +08:00
liuquan ad7017491b pytorch 2021-12-09 14:32:24 +08:00
AtlasAccount 548d08f5e9 同步1.5.0 3e3d5c3c32363c2dedbcaaeabe8f4724c3e179b3
!2842 concat算子使用静态算子
    Merge pull request !2842 from shibo/fix_queue
--
    !2801 delete unnecessary check, refactor env.sh
    Merge pull request !2801 from weili10/master
同步1.8.1 b43c20ebdc1a9654362128a1e0c026592997cbb3
    !2830 Feature: AMP in pytorch 1.8.1 adapt to NPU
    Merge pull request !2830 from 赵光灿/pytorch1.8.1
2021-12-09 12:00:43 +08:00
shibo 0d362b2572 Merge branch 'master' of gitee.com:ascend/pytorch into add_docs 2021-12-09 03:59:02 +00:00
shibo19 194352fe9e fix 2021-12-09 11:52:05 +08:00
liuquan c718961328 updata 2021-12-09 11:12:45 +08:00
AtlasAccount 67407fd00e 同步1.5.0 a067a49a8bf60af93c787eb092e646d6b3333ed2
!2823 modify: 修改BNTrainingUpdate算子mean和var在FP32时也进行强转FP32导致性能损失问题
    Merge pull request !2823 from 郭夏/bntrainingupdate
--
    !2841 AOE接口更新:dump接口opt参数仅支持nullptr
    Merge pull request !2841 from shibo/aoe_bugfix
同步1.8.1 c915e5ba3fe0831340ef817ec3fcad27fa5151c9
2021-12-08 23:01:13 +08:00
liuquan fad4a75b37 updata 2021-12-08 22:07:31 +08:00
liuquan 035121e1fb updata 2021-12-08 21:30:55 +08:00
shibo19 82d7341955 update 2021-12-08 16:43:36 +08:00
AtlasAccount 8cd641382e 同步1.5.0 4d9ff332ada3bc91bf37c4aaa97725040472d6fa
!2836 AOE接口更新
    Merge pull request !2836 from shibo/aoe_update
--
    !2751 【适配】LSTM双层双向场景适配
    Merge pull request !2751 from 陈庆/lstm_bi
同步1.8.1 c915e5ba3fe0831340ef817ec3fcad27fa5151c9
2021-12-08 12:00:43 +08:00
liuquan c6648343a7 updata 2021-12-08 10:11:23 +08:00
AtlasAccount 89a7a12a03 同步1.5.0 581620286789c28cb32617bd256ca57ecc925a90
!2805 【Optim】ApplyAdamV2算子侧有增强,适配层同步修改接口
    Merge pull request !2805 from wuxiankun/adalm
--
    !2826 Task: clean codecheck warnings
    Merge pull request !2826 from 赵光灿/master
--
    !2813 [非连续优化]-clone公共层耗时优化+转连续UT
    Merge pull request !2813 from 李超/cont_git1202-1
--
    !2811 modify: upsample_nearest3d支持FP16和6HD输入报错问题
    Merge pull request !2811 from 郭夏/upsample_nearest3d
同步1.8.1 c915e5ba3fe0831340ef817ec3fcad27fa5151c9
2021-12-07 23:00:56 +08:00
liuquan 4eba985a2f updata 2021-12-07 18:59:02 +08:00
liuquan ea8d8ad8c9 add code 2021-12-07 15:54:47 +08:00
liuquan 590e749dfe add pytorch train 2021-12-07 15:10:42 +08:00
AtlasAccount 6a949ada88 同步1.5.0 2b84dd37673a9c2588a4e8b9f296cdf70778511b
!2808 【BugFix】反向算子DynamicRNNGrad不支持指定direction,正向适配规避
    Merge pull request !2808 from 陈庆/lstm_direction
同步1.8.1 c915e5ba3fe0831340ef817ec3fcad27fa5151c9
2021-12-07 12:01:03 +08:00
AtlasAccount 40169ac353 同步1.5.0 bb6beaa95e6df9e0dc5499bc4cd360826ad846b2
!2791 【泛化】 gru支持batch_first参数
    Merge pull request !2791 from wuxiankun/optim2.0
--
    !2789 【1.5PT整改】整改PTUpsampleBilinear2dGrad
    Merge pull request !2789 from 李攀/bugfix
同步1.8.1 c915e5ba3fe0831340ef817ec3fcad27fa5151c9
    !2827 Task: clean codecheck warnings
    Merge pull request !2827 from 赵光灿/pytorch1.8.1
2021-12-06 23:00:55 +08:00
liuquan c13ed77bd6 updata API 2021-12-06 22:06:42 +08:00
shibo19 ea3dda5363 update 2021-12-06 17:37:02 +08:00
AtlasAccount d52329f755 同步1.5.0 41725bbf17d3b132f2f1ed13424c9e13f2770021
!2812 修复conv3d梯度分布式计算错误问题
    Merge pull request !2812 from lijing/master
--
    !2796 【Optim】SyncBatchNormBackwardReduce代码优化
    Merge pull request !2796 from wuxiankun/optim1.0
同步1.8.1 b668ec453ef4392fdb0585fd2d72756a0122f15c
    !2825 删除test/test_npu/目录下重复的testcase
    Merge pull request !2825 from 龚俊强/pytorch1.8.1
2021-12-06 12:00:42 +08:00
liuquan 9a2ffe7dc5 add pytorch 1.8.1 API 2021-12-06 11:25:29 +08:00
AtlasAccount 6102b560d4 同步1.5.0 02bce90c89c8ff9abd9973b6d2d7e097de46c858
!2822 taskqueue场景下release para不使用queue
    Merge pull request !2822 from shibo/fix_queue
同步1.8.1 438c8daf58550d882e8b4763910cc93b927d89f7
2021-12-05 23:01:03 +08:00
AtlasAccount a704d91840 同步1.5.0 f49cdb77ff1e8d8cca32a89097573208ee2cb1b8
!2819 [BugFix] 判断内存重叠是转换顺序,防止storage()为空
    Merge pull request !2819 from 宇世康/master
同步1.8.1 438c8daf58550d882e8b4763910cc93b927d89f7
2021-12-04 23:00:46 +08:00
liuquan 4dadfcf404 support python3.9 2021-12-04 15:51:23 +08:00
i-robot 643cc072eb !83 刷新readme
Merge pull request !83 from shibo/add_docs
2021-12-04 02:38:07 +00:00
AtlasAccount dc69d5441d 同步1.5.0 32cd40c1dd233f893dae2d351fac072cb4a0ffd9
!2806 【性能优化】scalar输入改成ACL_MEMTYPE_HOST_COMPILE_INDEPENDENT输入
    Merge pull request !2806 from 蒋荣强/scalar
同步1.8.1 438c8daf58550d882e8b4763910cc93b927d89f7
2021-12-03 23:00:55 +08:00
AtlasAccount 12e6d9f07a 同步1.5.0 aec197c05caa58c118810b9cc57069752966b9c0
!2804 modify: Bernoulli AICPU算子启用第2个流修改(参照dropout)
    Merge pull request !2804 from 郭夏/bernoulli
同步1.8.1 438c8daf58550d882e8b4763910cc93b927d89f7
2021-12-03 12:00:43 +08:00
AtlasAccount f6b284d021 同步1.5.0 b087ec154910da641e1e40b97ce3dde8f742d0c3
!2782 modify: batchnorm 支持FP16参数输入
    Merge pull request !2782 from 郭夏/bntrainingupdate
--
    !2807 删除test/test_npu/目录下重复的testcase
    Merge pull request !2807 from 龚俊强/master
--
    !2803 Task: clean codecheck warnings
    Merge pull request !2803 from 赵光灿/master
同步1.8.1 438c8daf58550d882e8b4763910cc93b927d89f7
2021-12-02 23:00:53 +08:00
shibo19 b87b437702 update readne 2021-12-02 09:39:32 +08:00
AtlasAccount 38675dbea0 同步1.5.0 4b53265e607eb120b4b1c7924014c5d45561632c
!2763 【性能优化】入队列优化
    Merge pull request !2763 from 蒋荣强/enqueue
--
    !2772 增加E2E profiling功能
    Merge pull request !2772 from shibo/e2e_better
同步1.8.1 438c8daf58550d882e8b4763910cc93b927d89f7
2021-12-01 23:00:51 +08:00
AtlasAccount e9a794a491 同步1.5.0 b08d8f7bbfa236bc413a16d0d2f8c8c086c3d654
!2798 【需求】【1.8反合1.5】1.8版本增加NPU独有算子反合1.5版本
    Merge pull request !2798 from 姚斌/master
同步1.8.1 438c8daf58550d882e8b4763910cc93b927d89f7
2021-12-01 12:00:44 +08:00
AtlasAccount 141d1b4c51 同步1.5.0 18dad28e5f25f2334f456aaf6d5f32680bccff25
!2784 提交图模式 test_contiguous ut 测试代码
    Merge pull request !2784 from 薛磊/test_nllloss
--
    !2776 Task: clean codecheck warnings
    Merge pull request !2776 from 赵光灿/master
--
    !2797 graph mode ut code style 3
    Merge pull request !2797 from 薛磊/pr_ut_1130
--
    !2767 modify: std规避ReduceStdWithMean算子输入0维或者1维1个元素时报错的问题
    Merge pull request !2767 from 郭夏/std_modify
--
    !2795 graph mode ut code style 2
    Merge pull request !2795 from 薛磊/pr_ut_code_check_v2
同步1.8.1 438c8daf58550d882e8b4763910cc93b927d89f7
2021-11-30 23:00:47 +08:00
AtlasAccount 9961ec03ae 同步1.5.0 58174932de2d5809cc64768eb3c43ea2bf981618
!2760 【优化】Div适配优化
    Merge pull request !2760 from 吴贤坤/fixbug5.0
同步1.8.1 438c8daf58550d882e8b4763910cc93b927d89f7
2021-11-30 12:00:58 +08:00
i-robot e8e641b331 !82 刷新docs文档:提示切换分支
Merge pull request !82 from shibo/add_docs
2021-11-30 01:50:08 +00:00
AtlasAccount eb29fd3e36 同步1.5.0 5185b6cbd85176ff1854db1ed80ef1c87147a3b0
!2786 【图模式】Run图接口添加RecordHostFunc,记录耗时
    Merge pull request !2786 from 宇世康/master
--
    !2792 PR门禁脚本改为运行test/test_npu/XXX/目录下脚本
    Merge pull request !2792 from 龚俊强/master
--
    !2788 graph mode ut code style
    Merge pull request !2788 from 薛磊/test_code_check
--
    !2755 【Bugfix】grid_sampler2d修改test_batchnormbackwardreduce脚本参数名修改重构
    Merge pull request !2755 from 吴贤坤/fixbug4.0
同步1.8.1 438c8daf58550d882e8b4763910cc93b927d89f7
    !2790 Task: clean codecheck warnings
    Merge pull request !2790 from 赵光灿/pytorch1.8.1
--
    !2773 1.8.1算子适配:ge,le
    Merge pull request !2773 from 王晓/1.8_ge_le_gt_lt
2021-11-29 23:00:45 +08:00
i-robot 0c5c61e3bc !81 Added README.en.md.
Merge pull request !81 from yanhuiling/master
2021-11-29 11:22:14 +00:00
shibo19 3708204f40 update docs 2021-11-29 10:55:12 +08:00
AtlasAccount fbdf33ddd0 同步1.5.0 2e9004844c45a4ef97f1642ec3ed395451115879
!2781 【Patch】gru bias bug 修复补丁
    Merge pull request !2781 from 吴贤坤/grupatch
--
    !2778 [Feature] 支持python3.9
    Merge pull request !2778 from 李超/py39
同步1.8.1 c2fd32bc49a6ce4170114c122a503d1c92589716
2021-11-27 12:00:47 +08:00
AtlasAccount 676978f973 同步1.5.0 ce7a96cd1f0d4ea0cc24bb1b134e534aca6c3ca9
!2783 nllloss2d 修改调用接口,删除老接口
    Merge pull request !2783 from 薛磊/dev_nllloss
--
    !2780 删除图模式contiguous, pow相关用例
    Merge pull request !2780 from 薛磊/del_contiguous
--
    !2771 解决图模式下 nllloss 适配层内存拷贝问题
    Merge pull request !2771 from 薛磊/pr_calcu_nllloss
--
    !2732 图模式ut
    Merge pull request !2732 from 薛磊/ut_graph
--
    !2779 【图模式】修复is graph mode接口的double free问题
    Merge pull request !2779 from 宇世康/master
--
    !2769 【图模式】 去除图模式的abi为1的依赖,需要等cann包更新后合入
    Merge pull request !2769 from 宇世康/ysk
同步1.8.1 c2fd32bc49a6ce4170114c122a503d1c92589716
2021-11-26 23:02:48 +08:00
AtlasAccount 6ff723d026 同步1.5.0 528664affa111c3976ff6a72ab9befa42ff96fef
!2713 【optimize】3d 类模型格式转换优化
    Merge pull request !2713 from 李超/3d_transdata
--
    !2727 add test case for the cross-device copy check
    Merge pull request !2727 from weili10/master
--
    !2761 Task: clean codecheck warnings
    Merge pull request !2761 from 赵光灿/master
同步1.8.1 c2fd32bc49a6ce4170114c122a503d1c92589716
    !2770 【BugFix】【需求】NPU独有算子适配apply_adam_out_npu、bert_apply_adam_out_npu
    Merge pull request !2770 from 姚斌/pytorch1.8.1
--
    !2762 Task: clean codecheck warnings
    Merge pull request !2762 from 赵光灿/pytorch1.8.1
2021-11-25 23:00:47 +08:00
AtlasAccount 184db237b1 同步1.5.0 841a9a8d082265efd5649d0d9c7cf050ea9379aa
!2748 [Requirement] 模型需求 rotated_overlaps算子adapt
    Merge pull request !2748 from 吴贤坤/rto
同步1.8.1 b220e1bfda03c88c7a5d72322e2fe2b68794149e
2021-11-25 12:00:51 +08:00
AtlasAccount df03cbe8d6 同步1.5.0 0941c08390a26f4ab4627f73371adf4bdd49b7c1
!2766 【优化】Dropout适配优化
    Merge pull request !2766 from 陈庆/drop
--
    !2753 修改PR门禁以及全量UT测试的判错标准
    Merge pull request !2753 from 龚俊强/master
--
    !2758 [contrib/npu/optimized_lib/] avoid warning
    Merge pull request !2758 from 王姜奔/master
--
    !2768 【图模式】set graph mode varibale mem max size to 1M
    Merge pull request !2768 from 王强/master
同步1.8.1 b220e1bfda03c88c7a5d72322e2fe2b68794149e
2021-11-24 23:00:47 +08:00
yanhuiling 02b5954125 added README.en.md.
added  README.en.md.
2021-11-24 14:05:14 +00:00
AtlasAccount c3723c6db0 同步1.5.0 5655fb8d0be5580b7870c5e8ec65f3ac2e9197a8
!2754 modify: 调用dot时修改为直接调用NPU函数,保证模糊编译能够正常运行
    Merge pull request !2754 from 郭夏/matmul
--
    !2757 【图模式】图模式与单算子模式都在empty与empty with format中将storage添加入context中
    Merge pull request !2757 from 宇世康/master
--
    !2756 【图模式】bugfix of switch between graph mode and single-op mode
    Merge pull request !2756 from 王强/master
同步1.8.1 b220e1bfda03c88c7a5d72322e2fe2b68794149e
2021-11-24 12:04:05 +08:00
AtlasAccount 2125edf662 同步1.5.0 57fb197351ff3087282bd37a01da3d2f59f67491
!2734 dump图以支持aoe功能
    Merge pull request !2734 from shibo/aoe
同步1.8.1 b220e1bfda03c88c7a5d72322e2fe2b68794149e
2021-11-23 23:00:48 +08:00
liuquan 273ab333eb GPU dump NPU load 2021-11-23 19:46:23 +08:00
AtlasAccount e698adf379 同步1.5.0 482cf5c72cbb3b52ebf4a626566aeaa6da014824
!2750 【FixBug】修复mse_loss在非nd场景下的报错
    Merge pull request !2750 from 王晓/mseloss
同步1.8.1 b220e1bfda03c88c7a5d72322e2fe2b68794149e
2021-11-23 12:00:42 +08:00
AtlasAccount 172a8154f8 同步1.5.0 49dfa00e664e205b94843572ac10064546583660
!2744 [acl profiling]兼容msprof,对msprof已经运行的错误不做处理
    Merge pull request !2744 from lijing/master
--
    !2729 【适配】npu_min接口适配
    Merge pull request !2729 from 陈庆/minv1
同步1.8.1 b220e1bfda03c88c7a5d72322e2fe2b68794149e
2021-11-22 23:01:02 +08:00
AtlasAccount e6c9ed0c77 同步1.5.0 774fb0bd7f1e7c30f18517e3ef5f41a7dc4761d6
!2730 【性能优化】优化出队列间隙耗时
    Merge pull request !2730 from 蒋荣强/optimize1
--
    !2743 跨so调用增加TORCH_NPU_API维护GraphExecutor单例
    Merge pull request !2743 from 宇世康/master
--
    !2741 【图模式】原地算子中,内存overlap判断情形增加IS_NULL
    Merge pull request !2741 from 宇世康/master
同步1.8.1 b220e1bfda03c88c7a5d72322e2fe2b68794149e
2021-11-19 23:01:33 +08:00
liuquan 30951b3eda update 2021-11-19 16:25:27 +08:00
weili10 d938e07a73 update README.zh.md. 2021-11-19 08:17:21 +00:00
weili10 8a5c0b30a1 update README.zh.md. 2021-11-19 08:14:41 +00:00
weili10 262d785419 update README.zh.md. 2021-11-19 08:14:05 +00:00
AtlasAccount cebdde8f48 同步1.5.0 fbee31be058af34c021da0f152d128ecf5e86c5d
同步1.8.1 b220e1bfda03c88c7a5d72322e2fe2b68794149e
    !2740 【bugfix】【需求】【1.8NPU独有算子适配整改】npu_bert_apply_adam
    Merge pull request !2740 from 姚斌/pytorch1.8.1
2021-11-19 00:41:55 +08:00
AtlasAccount e9257ed887 同步1.5.0 fbee31be058af34c021da0f152d128ecf5e86c5d
!2728 【功能修复】解决event入队列后的死锁问题
    Merge pull request !2728 from 蒋荣强/bug1
--
    !2677 graph mode cat和stack代码适配修改
    Merge pull request !2677 from 薛磊/dev_cat_stack
同步1.8.1 63b24dfd62f070475f36d43df01a74181ce90aa5
2021-11-18 19:54:32 +08:00
i-robot e420c35be6 !80 需求合入
Merge pull request !80 from liuquan/master
2021-11-18 09:27:43 +00:00
weili10 c5581b6189 update OWNERS. 2021-11-18 09:26:13 +00:00
AtlasAccount f44d2a8710 同步1.5.0 241bab3b3b873e4219bacf244e178e88abe85994
!2737 增加一些图模式需要的函数打桩+修复cuda版本的编译问题
    Merge pull request !2737 from 宇世康/master
--
    !2736 【图模式pr】view and contiguous changes of graph mode
    Merge pull request !2736 from 王强/master
--
    !2731 【Bugfix】LSTM反向梯度丢失
    Merge pull request !2731 from 陈庆/master
同步1.8.1 63b24dfd62f070475f36d43df01a74181ce90aa5
2021-11-18 12:00:45 +08:00
AtlasAccount 4eb5bbd3fe 同步1.5.0 a79fa0808e178fe36ee49ae22d874fa5cfa15bff
!2724 【图模式PR_2】pr_2的主要修改是融合GraphCommandImpl到OpCommandBase中,接管Opcmd的接口,在不改变单算子适配的情况下使能图构造
    Merge pull request !2724 from 宇世康/graph_mode
--
    !2725 fix broadcast opt verification conditions, avoid incorrect recognition of expand + view
    Merge pull request !2725 from 王强/master
同步1.8.1 63b24dfd62f070475f36d43df01a74181ce90aa5
2021-11-17 16:09:04 +08:00
AtlasAccount 0c58e128e7 同步1.5.0 cd7987730df2e98d4d725ddbee973db7645c656a
!2726 【功能修复】开启queue后删除oom保护机制
    Merge pull request !2726 from 蒋荣强/bug
--
    !2719 【FixBug】AICPU算子upsample_nearest3d正反向支持fp16
    Merge pull request !2719 from 王晓/up_n3d_b
同步1.8.1 63b24dfd62f070475f36d43df01a74181ce90aa5
    !2702 【需求】【1.8NPU独有算子适配】npu_bert_apply_adam、npu_apply_adam
    Merge pull request !2702 from 姚斌/pytorch1.8.1
--
    !2722 add cross-device copy check
    Merge pull request !2722 from weili10/pytorch1.8.1
2021-11-16 23:22:38 +08:00
AtlasAccount 0e1d68761b 同步1.5.0 73424f02c30a6800cf967c23920a27e5f4fbc212
!2721 add cross-device copy check
    Merge pull request !2721 from weili10/master
同步1.8.1 07edd5926b30109419e105521bc675f55ae0e3f6
2021-11-16 12:00:53 +08:00
AtlasAccount e161be6f75 同步1.5.0 474fcee57578ecb93985b22b3b50aff461250fd2
!2716 【图模式】 PR_1 :增量修改,增加图构造,图执行,图缓存的能力以及增加pytorch层的四个接口
    Merge pull request !2716 from 宇世康/graph_mode
同步1.8.1 07edd5926b30109419e105521bc675f55ae0e3f6
2021-11-16 10:11:52 +08:00
AtlasAccount 40e0982fe4 同步1.5.0 e0da7d2e6931d71edb7bbcba6d68d3d12f1bd20f
!2709 [contrib/npu/optimized_lib/] add SiLU
    Merge pull request !2709 from 王姜奔/silu
--
    !2714 【功能修复】解决record event入队列后,event资源延迟释放导致的evnet资源耗尽问题
    Merge pull request !2714 from 蒋荣强/bug
--
    !2670 【Bugfix】 修改&补充test.constant_pad_nd测试用例
    Merge pull request !2670 from 吴贤坤/fixbug2.0
--
    !2711 【FixBug】修复mv在输入为转置tensor时报错的问题
    Merge pull request !2711 from 王晓/mv
--
    !2712 调用aclopCompileAndExecute时判断gil锁是否被持有,持有的话释放。目的时防止TE编译算子时无法获取gil锁。
    Merge pull request !2712 from 宇世康/ysk
同步1.8.1 07edd5926b30109419e105521bc675f55ae0e3f6
2021-11-15 14:40:25 +08:00
liuquan 3a36da0345 modify IR2TBE 2021-11-13 17:44:27 +08:00
AtlasAccount 6a32513e71 同步1.5.0 226265063cfb50661352605720c96d09498e7564
!2697 【适配优化】constant_pad_nd性能优化
    Merge pull request !2697 from 陈庆/master
--
    !2695 【Bugfix】nll_loss输出格式修改
    Merge pull request !2695 from 吴贤坤/fixbug3.0
同步1.8.1 07edd5926b30109419e105521bc675f55ae0e3f6
2021-11-12 09:30:13 +08:00
AtlasAccount 3b92e80698 同步1.5.0 2f47f3a0304a181ecc4f75c6a36f329e6435b0b6
!2672 【Requirement】Gru多层双向功能适配补充
    Merge pull request !2672 from 吴贤坤/gru
--
    !2704 add: bincount for 1.5.1
    Merge pull request !2704 from 郭夏/bincount
--
    !2674 【FixBug】softmax_backward移除多余格式转换
    Merge pull request !2674 from 王晓/softmax_backward_nz
同步1.8.1 07edd5926b30109419e105521bc675f55ae0e3f6
    !2599 add:  erf op for ver 1.8.1
    Merge pull request !2599 from 郭夏/erf
2021-11-11 12:00:45 +08:00
AtlasAccount 127ddaeb87 同步1.5.0 ee9cf0fbc27e260173c16ce55a829f477e51f84f
同步1.8.1 120ae5365ebb24137b534ce063c7d7dc7a408c61
    !2657 【1.8.1】适配“upsamplebilinear2d”
Merge: 1fb062334 049b1e4f2
    !2662 【1.8.1】适配“Scatter_”
    Merge pull request !2662 from 李攀/do_1.8.1
--
    !2647 delete redundant check_match and invalid trans-contiguous code
    Merge pull request !2647 from weili10/pytorch1.8.1
2021-11-10 23:00:45 +08:00
AtlasAccount eb42aa1431 同步1.5.0 ee9cf0fbc27e260173c16ce55a829f477e51f84f
!2705 【性能优化】新增SCALAR_TO_HOST_MEM环境变量用于控制scalar输入的是否转为host memory
    Merge pull request !2705 from 蒋荣强/bug
同步1.8.1 a355a602d33f0fe3b65a627d9d0cf784309c1466
    !2700 bugfix: 修复profiler打印信息错误问题
    Merge pull request !2700 from shibo/profiler_bug
2021-11-10 20:46:37 +08:00
liuquan 3a1a239c76 modify format 2021-11-10 17:34:32 +08:00
liuquan 62c4f91fff modify format 2021-11-10 17:17:15 +08:00
liuquan ba0cdcc6f5 profiler 新增功能 2021-11-10 16:46:54 +08:00
AtlasAccount 9d8ba72c9b 同步1.5.0 7d56e9e47baa563428026b1315ea3e7155e29082
同步1.8.1 db8554c8db96ce9bac588aa6c0a9b6321482d76d
    !2696 【1.8算子适配】cdist、cdist_backward、pdist
    Merge pull request !2696 from 姚斌/pytorch1.8.1_1
2021-11-09 23:00:56 +08:00
AtlasAccount 77069c2c3e 同步1.5.0 7d56e9e47baa563428026b1315ea3e7155e29082
!2663 【图模式】Graph execute/construct/cache/utils功能以及正式python接口
    Merge pull request !2663 from 宇世康/master
同步1.8.1 c3ca90462e9c6d7cdefec410ce71b6d01ac76142
2021-11-09 12:00:50 +08:00
AtlasAccount 5510f37292 同步1.5.0 61e1a032928f4b80953bf4b130debba5f971a53d
!2699 修复RECORD_HOST_FUNCTION宏的bug,acl task queue线程也可以使用RECORD_HOST_FUNCTION
    Merge pull request !2699 from wangyu/master
--
    !2698  提供RECORD_HOST_FUNCTION宏,用于只记录host侧耗时
    Merge pull request !2698 from wangyu/master
--
    !2684 [dump utils] ThnnConvDepthwise2DBackward 在特定情况下仍然走cudnn
    Merge pull request !2684 from lijing/master
同步1.8.1 c3ca90462e9c6d7cdefec410ce71b6d01ac76142
    !2661 【1.8算子适配】softmax、true_divide
    Merge pull request !2661 from 姚斌/pytorch1.8.1
2021-11-08 23:00:44 +08:00
AtlasAccount 49aac16852 同步1.5.0 5dbbdd469a94c9e120360555c61fc66011478e26
同步1.8.1 87c1ee679055f052ab9a2bcdfc7bbfd065dd0ade
    !2642 【pytorch 1.8 算子适配】提交算子addmv、addr
    Merge pull request !2642 from TD_lihan/py18_addmv
--
    !2640 【pytorch 1.8 算子适配】提交算子adaptive_avg_pool1d
    Merge pull request !2640 from TD_lihan/py18_AdaptiveAvgPool1d
--
    !2604 【1.8算子迁移】卷积类修改等
    Merge pull request !2604 from 吴贤坤/conv_1.8
--
    !2654 增加profiler UT
    Merge pull request !2654 from shibo/profiler_ut
--
    !2668 【1.8算子适配】celu、selu
    Merge pull request !2668 from 姚斌/pytorch1.8.1_1
2021-11-08 12:00:45 +08:00
AtlasAccount 25b61ee2ee 同步1.5.0 5dbbdd469a94c9e120360555c61fc66011478e26
同步1.8.1 ddeb6df954cd6db748138cdd7d27e6d61de80b14
    !2683 1.8版本增加HCCL环境变量
    Merge pull request !2683 from shibo/add_env
--
    !2681 ddp在fp32场景下训练失败修复
    Merge pull request !2681 from shibo/dd_bugfix
--
    !2682 修复npu tensor类型转换丢失梯度属性问题
    Merge pull request !2682 from shibo/cast_bugfix
2021-11-06 16:37:10 +08:00
AtlasAccount 2ece9b72f6 同步1.5.0 5dbbdd469a94c9e120360555c61fc66011478e26
!2649 使用Identity代替Transdata
    Merge pull request !2649 from 詹隽/Identity_dev
--
    !2667 【性能优化】add record event to queue
    Merge pull request !2667 from 蒋荣强/RecordEvent
--
    !2660 1.5版本profiler功能优化
    Merge pull request !2660 from shibo/profiler_15
--
    !2658 【Bugfix】修改oom问题当调Conv3d时
    Merge pull request !2658 from 吴贤坤/fixbug
同步1.8.1 9702fe1349fd09e99d12a9d6799da5783da84663
    !2601 PyTorch1.8算子适配:uniform_
    Merge pull request !2601 from 牛作东/uniform_
2021-11-04 23:00:44 +08:00
AtlasAccount 2572775832 同步1.5.0 98d45fbd807b8bff03f51a05aedc3ac5efca29e3
!2666 Task: clean codecheck warnings
    Merge pull request !2666 from 赵光灿/master
同步1.8.1 80e9f656f8a2e05d80cd616847d7b7cb2586efc0
    !2645 Task: clean codecheck warnings
    Merge pull request !2645 from 赵光灿/pytorch1.8.1
2021-11-04 12:01:01 +08:00
AtlasAccount 500b51dd61 同步1.5.0 0a6f40ccd42088c4e0266ca62f22c3a1e1812ac7
同步1.8.1 b505d498eb6541469d8c8fdc07ed96c1a80f63c8
2021-11-03 12:01:11 +08:00
AtlasAccount bda7456cd9 同步1.5.0 0a6f40ccd42088c4e0266ca62f22c3a1e1812ac7
!2634 【1.5适配】“BatchNormBackwardElemt”
    Merge pull request !2634 from 李攀/bugfix
--
    !2629 东北大学TensorEqual算子适配测试文件交付
    Merge pull request !2629 from k188/TensorEqual
--
    !2650 Task: clean codecheck warnings
    Merge pull request !2650 from 赵光灿/master
同步1.8.1 b505d498eb6541469d8c8fdc07ed96c1a80f63c8
    !2655 【1.8算子适配】randperm、stack
    Merge pull request !2655 from 姚斌/pytorch1.8.1_1
--
    !2652 【1.8算子适配】std、std_mean、trunc
    Merge pull request !2652 from 姚斌/pytorch1.8.1
--
    !2646 【1.8.1】适配“maxunpool3d”
    Merge pull request !2646 from 李攀/do_1.8.1_2
--
    !2638 【pytorch 1.8 算子适配】提交算子abs
    Merge pull request !2638 from TD_lihan/py18_abs
--
    !2648 【1.8适配】“优化test_floatstatus.py”
    Merge pull request !2648 from 李攀/do_1.8.1
2021-11-03 09:39:32 +08:00
AtlasAccount 040029c1a1 同步1.5.0 58a86f5a7d8cfbb02dba057f04537b9e004f4593
同步1.8.1 cfa8827d1fb5c28878e856d6c5d1ec5f261ab206
2021-11-02 12:01:04 +08:00
AtlasAccount ec371989b4 同步1.5.0 58a86f5a7d8cfbb02dba057f04537b9e004f4593
!2641 Task: clean codecheck warnings
    Merge pull request !2641 from 赵光灿/master
--
    !2621 【算子适配】grid_sampler_2d算子正反向
    Merge pull request !2621 from 姚斌/master
--
    !2632 【Bugfix】算子不支持batch_first为True,适配层需将输出的Batch轴作为第0轴
    Merge pull request !2632 from 陈庆/master
同步1.8.1 cfa8827d1fb5c28878e856d6c5d1ec5f261ab206
    !2639 【pytorch 1.8 算子适配】提交算子acos
    Merge pull request !2639 from TD_lihan/py18_acos
--
    !2626 【1.8升级】L1Loss
2021-11-01 23:00:57 +08:00
liuquan ca59aaf3c6 修改格式 2021-11-01 18:42:41 +08:00
liuquan 78f946c17d 新增:IR映射TBE 2021-11-01 18:37:42 +08:00
AtlasAccount ef4e7240b6 同步1.5.0 790429b1a174b47714d38e7dd2b18a36bef01f83
同步1.8.1 1901c67035192c760ebdd32f422ea86fa40bf922
2021-10-31 23:00:50 +08:00
AtlasAccount 6ac16dfab0 同步1.5.0 790429b1a174b47714d38e7dd2b18a36bef01f83
同步1.8.1 1901c67035192c760ebdd32f422ea86fa40bf922
2021-10-31 12:00:49 +08:00
AtlasAccount 283e923317 同步1.5.0 790429b1a174b47714d38e7dd2b18a36bef01f83
!2637 异步拷贝入队列
    Merge pull request !2637 from 蒋荣强/async
--
    !2635 Task: clean codecheck warnings
    Merge pull request !2635 from 赵光灿/master
同步1.8.1 1901c67035192c760ebdd32f422ea86fa40bf922
    !2624 【适配】To/Rsub算子适配
    Merge pull request !2624 from 陈庆/pytorch1.8.1
--
    !2603 1.8算子迁移】ps_roi_pooling,npu_roi_align, npu_iou等
    Merge pull request !2603 from 吴贤坤/npu_fd_bd_1.8_bnms
--
    !2636 1.8版本优化profiler
    Merge pull request !2636 from shibo/profiler_simple
2021-10-30 23:02:03 +08:00
AtlasAccount e6e7203cce 同步1.5.0 caf3ceb04e4a115ce8d1498952c110fb4b9bc317
!2625 修改OpCommandBase中input和output接口参数
    Merge pull request !2625 from 薛磊/dev_opcommand_parameter
同步1.8.1 2bfd20f98a90ed25faa3a019ec42379e6e153b3e
2021-10-30 12:00:39 +08:00
AtlasAccount 6bb0e87a77 同步1.5.0 639610b805d6bc4abfe4ee632e6291aa48835d3c
!2630 Task: clean codecheck warnings
    Merge pull request !2630 from 赵光灿/master
同步1.8.1 2bfd20f98a90ed25faa3a019ec42379e6e153b3e
2021-10-29 23:00:56 +08:00
AtlasAccount 2497544a76 同步1.5.0 b1f4e771b0b6f736386bba9838e28edb0556e743
同步1.8.1 2bfd20f98a90ed25faa3a019ec42379e6e153b3e
    !2631 Task: clean codecheck warnings
    Merge pull request !2631 from 赵光灿/pytorch1.8.1
2021-10-29 12:00:48 +08:00
AtlasAccount ae597b5e21 同步1.5.0 b1f4e771b0b6f736386bba9838e28edb0556e743
同步1.8.1 c1fa09ac6f19542adfd7a1dded1561b1a0fb3fd9
    !2616 1.8.1算子tril、ne、eq适配迁移
    Merge pull request !2616 from 王晓/tril
--
    !2613 1.8.1算子triu适配迁移
    Merge pull request !2613 from 王晓/1.8.1_triu
2021-10-28 23:00:49 +08:00
AtlasAccount c0723277c4 同步1.5.0 b1f4e771b0b6f736386bba9838e28edb0556e743
同步1.8.1 ebba68383c462ce8351d6fc4c1f19b3039568925
2021-10-28 12:00:53 +08:00
AtlasAccount 64daba9637 同步1.5.0 b1f4e771b0b6f736386bba9838e28edb0556e743
同步1.8.1 ebba68383c462ce8351d6fc4c1f19b3039568925
2021-10-27 23:15:47 +08:00
AtlasAccount d9e50e3a9f 同步1.5.0 b1f4e771b0b6f736386bba9838e28edb0556e743
同步1.8.1 ebba68383c462ce8351d6fc4c1f19b3039568925
2021-10-27 12:00:50 +08:00
AtlasAccount 4dec0c82a1 同步1.5.0 b1f4e771b0b6f736386bba9838e28edb0556e743
!2622 solve input type mismatch problem of mul
    Merge pull request !2622 from 蒋荣强/scalar
同步1.8.1 ebba68383c462ce8351d6fc4c1f19b3039568925
    !2600 add:  exp op for 1.8.1
    Merge pull request !2600 from 郭夏/exp
--
    !2565 1.8.1适配“maxpool3d, smoothL1Loss, SoftMarginLoss”
    Merge pull request !2565 from 李攀/do_1.8.1_2
2021-10-26 23:00:52 +08:00
AtlasAccount e6b84a7986 同步1.5.0 bf7628c383f445fbdb4c95fb3aa002bff260a9f3
!2620 op proto for graph mode
    Merge pull request !2620 from 薛磊/dev_op_proto
--
    !2619 [dump utils]修复op map返回为空的问题
    Merge pull request !2619 from lijing/master
同步1.8.1 62372aba9b1c73f87ef30f87027886e93d960382
    !2617  【function】add python3.8 compiling to pytorch1.8
    Merge pull request !2617 from 李超/pytorch1.8.1
--
    !2612 【1.8算子迁移】tanh,sigmoidgrad等
    Merge pull request !2612 from 吴贤坤/backward_1.8
--
    !2610 【1.8适配】nllloss2dbackward
    Merge pull request !2610 from 李攀/do_1.8.1_5
--
    !2618 1.8版本profiling支持屏蔽适配层内算子
    Merge pull request !2618 from shibo/profiler_simple
--
    !2611 【1.8算子适配】min、mv、ones
    Merge pull request !2611 from 姚斌/pytorch1.8.1
2021-10-26 12:00:48 +08:00
i-robot f2e2a4168d !78 update the catalog of en docs
Merge pull request !78 from yinzijun/master
2021-10-26 01:32:56 +00:00
AtlasAccount 92f9e54783 同步1.5.0 081357bddfac9aafadf4c37cfbccffbe21e392fe
!2595 [dump utils]新增view类黑名单算子
    Merge pull request !2595 from lijing/master
--
    !2615 [contrib/npu/optimized_lib/] add giou
    Merge pull request !2615 from 王姜奔/giou
--
    !2614 dynamicShape: forbiden roialign and roialigngrad
    Merge pull request !2614 from 周司南/master
同步1.8.1 87920ba2ff21bb968a8e371f11dc4ba47b94a768
2021-10-25 23:00:45 +08:00
AtlasAccount 5d23983945 同步1.5.0 88bb20489508d6783c1d2816eb911dae21757f7a
同步1.8.1 87920ba2ff21bb968a8e371f11dc4ba47b94a768
2021-10-24 23:00:55 +08:00
AtlasAccount 0850d4e22a 同步1.5.0 88bb20489508d6783c1d2816eb911dae21757f7a
同步1.8.1 87920ba2ff21bb968a8e371f11dc4ba47b94a768
2021-10-24 12:01:05 +08:00
AtlasAccount c788e1a85c 同步1.5.0 88bb20489508d6783c1d2816eb911dae21757f7a
!2594 使用 OpCommand 接口适配relu和gelu backward算子
    Merge pull request !2594 from 薛磊/dev_relu_gelu
同步1.8.1 87920ba2ff21bb968a8e371f11dc4ba47b94a768
2021-10-23 23:00:46 +08:00
AtlasAccount f414fe6e4c 同步1.5.0 7508158b533e4974558a4e72653917aa45d694c3
同步1.8.1 87920ba2ff21bb968a8e371f11dc4ba47b94a768
    !2607 【1.8算子适配】round、rsqrt、sqrt
    Merge pull request !2607 from 姚斌/pytorch1.8.1
2021-10-22 23:00:57 +08:00
ZijunYin af726a697e update en docs. 2021-10-22 17:30:59 +08:00
AtlasAccount afa8699efc 同步1.5.0 7508158b533e4974558a4e72653917aa45d694c3
同步1.8.1 c3e7e61c49a22e7564a914ec70ea3e37d99adef0
2021-10-22 00:58:31 +08:00
AtlasAccount 89f71305c3 同步1.5.0 7508158b533e4974558a4e72653917aa45d694c3
!2598 add Enqueue profiling
    Merge pull request !2598 from 蒋荣强/queue
同步1.8.1 c3e7e61c49a22e7564a914ec70ea3e37d99adef0
2021-10-21 12:00:46 +08:00
AtlasAccount 2bd42a661f 同步1.5.0 46cd8d05f7f053fd22ccf4d1d35ff0ae881b071f
同步1.8.1 c3e7e61c49a22e7564a914ec70ea3e37d99adef0
2021-10-20 23:05:13 +08:00
AtlasAccount 88cbcb90dd 同步1.5.0 46cd8d05f7f053fd22ccf4d1d35ff0ae881b071f
!2590 Add Version + 1
    Merge pull request !2590 from 周司南/master
--
    !2570 ifdef 和 if defined 不能混用
    Merge pull request !2570 from shibo/bug_fix
--
    Merge pull request !2593 from weili10/revert-merge-2554-master
--
    Merge pull request !2592 from weili10/revert-merge-2584-master
--
    !2587 [dump utils]fix compile error
    Merge pull request !2587 from lijing/master
同步1.8.1 c3e7e61c49a22e7564a914ec70ea3e37d99adef0
    !2582 【1.8算子迁移】thnn_conv2d_forward重构
    Merge pull request !2582 from 吴贤坤/thnn_conv_1.8
--
    !2581 【1.8算子迁移】Upsample部分
    Merge pull request !2581 from 吴贤坤/up3d_1.8
--
    !2579 1.8.1算子适配 cross
    Merge pull request !2579 from 王晓/1.8_cross
2021-10-20 16:04:06 +08:00
AtlasAccount 706b56bf41 同步1.5.0 0178176bcf5feb64a463ee5eea17e15e30acd60f
!2586 【dump utils】修复当tensor某些维度为0时load报错问题
    Merge pull request !2586 from lijing/master
同步1.8.1 1e37554a67274f6244ece6522a8ba7a5888c426e
    !2495 【pytorch1.8适配】Where、Resize、Norm、Pow适配
    Merge pull request !2495 from 陈庆/pytorch1.8.1
--
    !2577 【1.8算子迁移】col2im等
    Merge pull request !2577 from 吴贤坤/colim_1.8
--
    !2574 pytorch1.8 pprofiling功能
    Merge pull request !2574 from shibo/profiler_update
2021-10-19 12:02:15 +08:00
AtlasAccount 5f1e9f8cc8 同步1.5.0 9305e2ee100c65f034ef8d0128d3c4b2faa40c29
同步1.8.1 71641840df36c327d5400f22bbdc02d825bee026
2021-10-18 12:00:49 +08:00
AtlasAccount 4317ec1bca 同步1.5.0 9305e2ee100c65f034ef8d0128d3c4b2faa40c29
同步1.8.1 71641840df36c327d5400f22bbdc02d825bee026
2021-10-17 12:00:56 +08:00
i-robot ace7ba9a8b !76 update image in Installation Guide
Merge pull request !76 from yinzijun/master
2021-10-15 10:30:49 +00:00
weili10 8dc400cd8a update README.zh.md. 2021-10-15 10:06:20 +00:00
ZijunYin f2c1df9134 update image in docs/en/PyTorch Installation Guide 2021-10-15 17:52:30 +08:00
i-robot 728b16d171 !74 update English docs
Merge pull request !74 from yinzijun/master
2021-10-15 09:36:48 +00:00
ZijunYin 6285b3b60f Merge branch 'master' of https://gitee.com/yinzijun/pytorch 2021-10-15 17:22:45 +08:00
ZijunYin 1017d89d57 update English docs. 2021-10-15 17:22:34 +08:00
AtlasAccount 424de74a3a 同步1.5.0 7682920856d82fcc09bd1806585cf042a5a99b3b
!2584 solve accuracy problem due to adding async copy to queue
    Merge pull request !2584 from 蒋荣强/master
同步1.8.1 82054017ffd27967cfd4224f6142fdaf23000b5b
    !2566 1.8.1适配“mseloss, avgpool2d, avgpool3d”
2021-10-15 12:01:11 +08:00
AtlasAccount 7e05a39e42 同步1.5.0 da42cdf6867c2e854c21278dbf0ca135e036beb4
!2573 modify scalar input to host memory input
    Merge pull request !2573 from 蒋荣强/scalar
同步1.8.1 290416bb037a6ca8168f266e5f0ad547f2b5afc5
    !2575 1.8.1“float_status”
    Merge pull request !2575 from 李攀/do_1.8.1
2021-10-14 12:00:53 +08:00
i-robot 24bfeaa78c !72 更新readme
Merge pull request !72 from shibo/update_readme
2021-10-13 09:30:49 +00:00
AtlasAccount 47e8fac4ae 同步1.5.0 86ce2266c01b28e46d42f1c34c81f73a70e238cf
同步1.8.1 7afd57f35ebc3b81dd4c3f642e3f8ba81c1f07f0
2021-10-13 12:01:01 +08:00
AtlasAccount c916024ec7 同步1.5.0 86ce2266c01b28e46d42f1c34c81f73a70e238cf
!2563 适配silu正反向算子
    Merge pull request !2563 from 王夏夏/master
--
    !2569 solve codex problem
    Merge pull request !2569 from 蒋荣强/master
--
    !2567 fix codexbug
    Merge pull request !2567 from 周司南/master
--
    !2568 修复codedex告警
    Merge pull request !2568 from 詹隽/mm_nd_dev
同步1.8.1 7afd57f35ebc3b81dd4c3f642e3f8ba81c1f07f0
2021-10-12 12:00:58 +08:00
AtlasAccount 710ce99fa7 同步1.5.0 2d8899df9adbfe0234c5d913dff8a8fddee61ada
同步1.8.1 7afd57f35ebc3b81dd4c3f642e3f8ba81c1f07f0
2021-10-11 12:00:48 +08:00
shibo19 14f78e1593 update 2021-10-11 11:32:48 +08:00
shibo19 ad48d8f66b update 2021-10-11 11:30:40 +08:00
shibo19 5dee0e68b4 update 2021-10-11 11:29:04 +08:00
AtlasAccount 20034c4f3b 同步1.5.0 2d8899df9adbfe0234c5d913dff8a8fddee61ada
同步1.8.1 7afd57f35ebc3b81dd4c3f642e3f8ba81c1f07f0
2021-10-10 12:01:13 +08:00
i-robot ecd705896a !70 update RELEASENOTE with 2.0.2
Merge pull request !70 from yinzijun/master
2021-10-09 10:11:51 +00:00
ZijunYin a1297c462f update RELEASENOTE.md 2021-10-09 17:53:59 +08:00
yinzijun 04e467e6c2 !69 update README
Merge pull request !69 from liuquan/master
2021-10-09 08:43:04 +00:00
刘全 33a911c624 update docs/zh/RELEASENOTE/RELEASENOTE.md. 2021-10-09 07:20:02 +00:00
yinzijun 14bd359387 !65 add releasenote
Merge pull request !65 from yinzijun/master
2021-10-09 07:03:12 +00:00
AtlasAccount 52701635fa 同步1.5.0 2d8899df9adbfe0234c5d913dff8a8fddee61ada
同步1.8.1 7afd57f35ebc3b81dd4c3f642e3f8ba81c1f07f0
2021-10-09 12:01:54 +08:00
ZijunYin f8028e788f add RELEASENOTE.md 2021-10-09 09:54:11 +08:00
weili10 2e5af37b40 update README.zh.md. 2021-10-09 01:12:54 +00:00
AtlasAccount 472a02ee7b 同步1.5.0 2d8899df9adbfe0234c5d913dff8a8fddee61ada
同步1.8.1 7afd57f35ebc3b81dd4c3f642e3f8ba81c1f07f0
2021-10-08 12:01:05 +08:00
AtlasAccount 03077bc002 同步1.5.0 2d8899df9adbfe0234c5d913dff8a8fddee61ada
同步1.8.1 7afd57f35ebc3b81dd4c3f642e3f8ba81c1f07f0
2021-10-07 12:00:48 +08:00
AtlasAccount 8027eddae2 同步1.5.0 2d8899df9adbfe0234c5d913dff8a8fddee61ada
同步1.8.1 7afd57f35ebc3b81dd4c3f642e3f8ba81c1f07f0
2021-10-06 12:01:02 +08:00
AtlasAccount 4e12aed2c4 同步1.5.0 2d8899df9adbfe0234c5d913dff8a8fddee61ada
同步1.8.1 7afd57f35ebc3b81dd4c3f642e3f8ba81c1f07f0
2021-10-05 12:01:05 +08:00
AtlasAccount d60a312292 同步1.5.0 2d8899df9adbfe0234c5d913dff8a8fddee61ada
同步1.8.1 7afd57f35ebc3b81dd4c3f642e3f8ba81c1f07f0
2021-10-04 12:01:10 +08:00
AtlasAccount ed5baac37f 同步1.5.0 2d8899df9adbfe0234c5d913dff8a8fddee61ada
!2554 add AsyncMemcpy to queue
    Merge pull request !2554 from 蒋荣强/fuzzy
同步1.8.1 7afd57f35ebc3b81dd4c3f642e3f8ba81c1f07f0
2021-10-03 12:00:54 +08:00
yinzijun d3fca1bddd !63 update docs 2.0.3.B090
Merge pull request !63 from yinzijun/master
2021-09-30 07:15:55 +00:00
ZijunYin 4082c74535 update docs/zh/PyTorch API支持清单/PyTorch API支持清单.md & docs/zh/PyTorch网络模型移植&训练指南/PyTorch网络模型移植&训练指南.md 2021-09-30 15:02:46 +08:00
ZijunYin 7b0b8cc5b9 update docs 2.0.3.B090 2021-09-30 14:41:32 +08:00
AtlasAccount bd49e63f36 同步1.5.0 a4dfab7869d894d1f2a3629463f1aed4b63bec1b
同步1.8.1 7afd57f35ebc3b81dd4c3f642e3f8ba81c1f07f0
2021-09-30 12:31:03 +08:00
AtlasAccount c47ca17bee 同步1.5.0 a4dfab7869d894d1f2a3629463f1aed4b63bec1b
!2560 【BugFix】修复输入shape不一致,算子侧未broadcast,导致不支持
    Merge pull request !2560 from 姚斌/master
--
    !2557 modify: 去除UT中1维NZ格式的用例
    Merge pull request !2557 from 郭夏/ut_modify
--
    !2555 修复IOU输出数据类型转换
    Merge pull request !2555 from 李攀/bugfix
同步1.8.1 7afd57f35ebc3b81dd4c3f642e3f8ba81c1f07f0
2021-09-29 12:01:07 +08:00
AtlasAccount 6e78d9b798 同步1.5.0 f9ff07a2aef09f4901025c8375dfcb4157fe38e0
!2551 add fuzzy flag to queue
    Merge pull request !2551 from 蒋荣强/fuzzy
同步1.8.1 7afd57f35ebc3b81dd4c3f642e3f8ba81c1f07f0
2021-09-28 12:00:45 +08:00
AtlasAccount 325e0c9686 同步1.5.0 6ee40447c11dc17c5f58d7fcad9ae9f1a078057e
!2552 修复load模式时conv2d反向dump结果ir_name被覆盖的问题
    Merge pull request !2552 from gaokai21/master
同步1.8.1 7afd57f35ebc3b81dd4c3f642e3f8ba81c1f07f0
2021-09-27 20:58:36 +08:00
AtlasAccount 8b46a4fa68 同步1.5.0 68aca6bc147877979b06059240f3f246f0625a07
!2477 [contrib/npu/optimized_lib/] 修复iou和bbox_coder在输入经过归一化时精度下降的问题
    Merge pull request !2477 from 王姜奔/20210903
--
    !2456 [contrib/npu/optimized_lib/] fix import bug in __init__
    Merge pull request !2456 from 王姜奔/master
--
    !2543 修复maxunpool2dbackward执行报错
    Merge pull request !2543 from 李攀/bugfix
同步1.8.1 7afd57f35ebc3b81dd4c3f642e3f8ba81c1f07f0
2021-09-27 12:00:48 +08:00
AtlasAccount c927f4d52e 同步1.5.0 f0be9e9f84b731b59baf432510a25b601e2ba1b3
!2538 修改norm精度问题
    Merge pull request !2538 from 李攀/bugfix
--
    !2534 添加gpu和npu映射接口
    Merge pull request !2534 from gaokai21/master
--
    !2541 【bugfix】修复输入维度不一致时,算子不支持场景
    Merge pull request !2541 from 陈庆/lshift
同步1.8.1 7afd57f35ebc3b81dd4c3f642e3f8ba81c1f07f0
    !2542 build.sh二次编译问题
    Merge pull request !2542 from 周司南/pytorch1.8.1
2021-09-26 18:06:10 +08:00
AtlasAccount a52a2a7582 同步1.5.0 b8c5f967d3793315893507c8bb0e8ef9d5f8ad5b
!2540 修改batchnormstats接口精度(静态)
    Merge pull request !2540 from 吴贤坤/bnstats
--
    !2535 [cube] bmmv2 delete expand
    Merge pull request !2535 from 丁世浩/master
同步1.8.1 bcb12248e9ba9e72b6852c05b06c80b7ca395169
2021-09-26 12:01:03 +08:00
AtlasAccount 28b81ba784 同步1.5.0 c22928e1702155adb6f17d45277269f90f0b6e43
!2533 Ptiou整改
    Merge pull request !2533 from 李攀/bugfix
同步1.8.1 bcb12248e9ba9e72b6852c05b06c80b7ca395169
2021-09-25 12:00:46 +08:00
AtlasAccount 118cead9db 同步1.5.0 67d1906d95b9ff3658f65b5e955b983950045425
!2531 PT整改scatterAdd
    Merge pull request !2531 from 李攀/bugfix
同步1.8.1 bcb12248e9ba9e72b6852c05b06c80b7ca395169
2021-09-24 12:00:46 +08:00
AtlasAccount 37983612eb 同步1.5.0 4951d13206bcd73597b7449b40ca7cf6cb846840
!2526 mm、bmm支持对齐shape的nd适配开关
    Merge pull request !2526 from 詹隽/mm_nd_dev
--
    !2484 [dump utils] support NPU dump and gpu load
    Merge pull request !2484 from lijing/master
--
    !2523 清理冗余代码
    Merge pull request !2523 from weili10/master
--
    !2518 修改 codex 问题
    Merge pull request !2518 from 周司南/master
同步1.8.1 bcb12248e9ba9e72b6852c05b06c80b7ca395169
    !2519 编译问题已修复,脚本还原
    Merge pull request !2519 from shibo/update_build
2021-09-23 12:01:05 +08:00
AtlasAccount a0d5f0413a 同步1.5.0 860b52e16d12312680f057183820b849682f701f
!2521 【问题清理】pad3问题修改
    Merge pull request !2521 from 吴贤坤/bugclear
--
    !2528 修复BatchNormElemt精度问题
    Merge pull request !2528 from 李攀/bugfix
--
    !2516 PT整改-UpsampleBilinear2D
    Merge pull request !2516 from 李攀/bugfix
同步1.8.1 0eab0ff8a6b96eb6053b87d428c18cdc0556ec8e
2021-09-22 12:00:46 +08:00
AtlasAccount 3f7654bb90 同步1.5.0 a515d5fc8cf79e7f998e72f7f358476a6f071d5b
同步1.8.1 0eab0ff8a6b96eb6053b87d428c18cdc0556ec8e
2021-09-21 12:00:58 +08:00
AtlasAccount 6f3c3f8c93 同步1.5.0 a515d5fc8cf79e7f998e72f7f358476a6f071d5b
同步1.8.1 0eab0ff8a6b96eb6053b87d428c18cdc0556ec8e
2021-09-20 12:01:04 +08:00
yinzijun 663e48a628 !62 update docs API支持清单
Merge pull request !62 from yinzijun/master
2021-09-19 13:53:30 +00:00
AtlasAccount 4c0b1766ab 同步1.5.0 a515d5fc8cf79e7f998e72f7f358476a6f071d5b
同步1.8.1 0eab0ff8a6b96eb6053b87d428c18cdc0556ec8e
2021-09-19 12:00:45 +08:00
ZijunYin 69547a0826 update docs/zh/PyTorch API支持清单/PyTorch API支持清单.md 2021-09-19 11:05:41 +08:00
ZijunYin 5b9b7041b2 update docs/zh/PyTorch API支持清单/PyTorch API支持清单.md 2021-09-19 11:02:34 +08:00
AtlasAccount bc0fbdcac9 同步1.5.0 a515d5fc8cf79e7f998e72f7f358476a6f071d5b
!2520 删除OpcommandBase的拷贝和赋值构造函数,不应出现UpSample**算子适配中的这种用法
    Merge pull request !2520 from 宇世康/master
--
    !2515 Bugfix: fix codemars warnings and add path check
    Merge pull request !2515 from 赵光灿/master
同步1.8.1 0eab0ff8a6b96eb6053b87d428c18cdc0556ec8e
    !2513 适配"elu, hardsigmoid, nllloss2d, multilabel_margin_loss"
Merge: d767dccb7 bbfa373d9
    !2517 1.8适配“softshrink, softplus, adaptiveavgpool3d, adaptivemaxpool2d”
    Merge pull request !2517 from 李攀/do_1.8.1_3
2021-09-18 12:03:11 +08:00
i-robot ea561b97c9 !57 Add py38 package building method
Merge pull request !57 from 李超/master
2021-09-17 05:50:33 +00:00
AtlasAccount f431153967 同步1.5.0 888d06f1b261e49f6329a2a72358792bab258c94
同步1.8.1 d767dccb71ea1043a0fbe0d7a814f6bde2232923
2021-09-17 12:01:01 +08:00
AtlasAccount e82066018d 同步1.5.0 888d06f1b261e49f6329a2a72358792bab258c94
!2510 路径检查
    Merge pull request !2510 from shibo/path_check
同步1.8.1 d767dccb71ea1043a0fbe0d7a814f6bde2232923
    !2512 bugfix 编译错误
    Merge pull request !2512 from 周司南/pytorch1.8.1
--
    !2508 pytorch 1.5.0 同步 1.8.1
    Merge pull request !2508 from 周司南/pytorch1.8.1
--
    !2511 1.8"hardtanh, leakyrelu, logsigmoid"
    Merge pull request !2511 from 李攀/do_1.8.1_3
--
    !2494 diag 1.8.1适配
    Merge pull request !2494 from 王晓/1.8_diag
2021-09-17 09:25:03 +08:00
yinzijun a4fdc51ac9 !61 2.0.3.B060版本资料更新
Merge pull request !61 from yinzijun/master
2021-09-16 12:09:19 +00:00
ZijunYin 42badebbad 2.0.3.B060资料转测 2021-09-16 19:48:58 +08:00
yinzijun 9d43973a43 !60 update docs with all-in-one
Merge pull request !60 from yinzijun/master
2021-09-16 08:11:50 +00:00
ZijunYin 9d4224f9a5 update all-in-one docs/zh/PyTorch安装指南/PyTorch安装指南.md 2021-09-16 15:54:01 +08:00
AtlasAccount c2a7dc3f17 同步1.5.0 faf66d48f5856b0b9c16a07aec78f76bee01e675
!2487 泛化:norm算子适配修改
    Merge pull request !2487 from 姚斌/master
--
    !2509 performance optimization
    Merge pull request !2509 from 蒋荣强/optimize1
--
    !2507 【Adapter Task】batch_norm_backward_reduce 适配
    Merge pull request !2507 from 吴贤坤/bn_bw_rd
同步1.8.1 09f155356e3f4323d88c7181e8b2915ba04e6033
    !2462 1.8版本:更新readme文件
    Merge pull request !2462 from shibo/add_readme_181
2021-09-16 12:01:54 +08:00
i-robot be21b4c339 !58 docs更新:增加编译选项说明
Merge pull request !58 from shibo/update_idp
2021-09-15 08:32:30 +00:00
i-robot 851cc9e42e !56 更新readme
Merge pull request !56 from shibo/read_me
2021-09-15 08:30:35 +00:00
AtlasAccount 6963a9c6f5 同步1.5.0 0fc7ffde0cfcfb82e1bee4ab124136433a54dee0
!2502 [fixbug]  Fill, avgpool2d修复
    Merge pull request !2502 from 吴贤坤/fixbug
--
    !2500 batchnormelemt添加参数检查
    Merge pull request !2500 from 李攀/bugfix
同步1.8.1 fd81d36aac30c9ea0c1cb91f1e36c146d549711e
2021-09-15 12:00:49 +08:00
shibo19 f38ae2d871 add compile option note 2021-09-14 20:24:09 +08:00
AtlasAccount cc3ebabbca 同步1.5.0 6ce19779227f5b627f6aa39eb5c8db32d3fd91ea
!2501 修复ndexing不支持动态shape问题
    Merge pull request !2501 from 李攀/bugfix_2
--
    !2485 path路径强校验
    Merge pull request !2485 from 周司南/master
同步1.8.1 fd81d36aac30c9ea0c1cb91f1e36c146d549711e
    !2499 移除CPU上NPU的依赖, 支持USE_NPU=0编译
    Merge pull request !2499 from 周司南/pytorch1.8.1
2021-09-14 12:00:45 +08:00
AtlasAccount d70ae50d78 同步1.5.0 aff14c6dd491ed6b2ddebb15c64a366bfb231188
同步1.8.1 135d70c6d0d16b381e35a39747659e7f3d6cda96
2021-09-13 12:00:45 +08:00
李超 f99298b02b Add py38 package building method 2021-09-13 10:54:06 +08:00
AtlasAccount 8d64c91316 同步1.5.0 aff14c6dd491ed6b2ddebb15c64a366bfb231188
!2489 修复双向lstm参数传入数量不对问题
    Merge pull request !2489 from zhusiyi/master
同步1.8.1 135d70c6d0d16b381e35a39747659e7f3d6cda96
2021-09-12 12:00:54 +08:00
AtlasAccount a40e37d953 同步1.5.0 0cfee0d7ea81c78b852cadfadf8e64021b167307
同步1.8.1 135d70c6d0d16b381e35a39747659e7f3d6cda96
2021-09-11 12:00:46 +08:00
AtlasAccount 5996fed7b1 同步1.5.0 0cfee0d7ea81c78b852cadfadf8e64021b167307
同步1.8.1 135d70c6d0d16b381e35a39747659e7f3d6cda96
    !2498 fixBug conv2d_out_npu
    Merge pull request !2498 from 周司南/pytorch1.8.1
2021-09-10 15:50:07 +08:00
AtlasAccount 3be7bcf63d 同步1.5.0 0cfee0d7ea81c78b852cadfadf8e64021b167307
同步1.8.1 88795ab0435ba8144a5b419d0144698c6dc7c7b3
    !2491 【pytorch1.8算子适配】neg reciprocal sin sinh tan tanh
    Merge pull request !2491 from 姚斌/pytorch1.8.1
2021-09-10 13:56:49 +08:00
AtlasAccount 6fc30ad19f 同步1.5.0 0cfee0d7ea81c78b852cadfadf8e64021b167307
同步1.8.1 a69145e398ceaa35226f3c5d977a07f041448939
2021-09-10 12:00:48 +08:00
AtlasAccount 81a39d545f 同步1.5.0 0cfee0d7ea81c78b852cadfadf8e64021b167307
!2496 [bugfix] BinaryCrossEntroy反向适配代码修改
    Merge pull request !2496 from 吴贤坤/bugfix
同步1.8.1 a69145e398ceaa35226f3c5d977a07f041448939
2021-09-09 16:08:52 +08:00
AtlasAccount 75a9089e09 同步1.5.0 45372575e229cb5261582ebd322a30805f68ebb3
!2493 修复ndexing不支持动态shape问题
    Merge pull request !2493 from 李攀/bugfix
--
    !2492 适配batch_norm_elemt
    Merge pull request !2492 from 李攀/master
同步1.8.1 a69145e398ceaa35226f3c5d977a07f041448939
    !2474 convolution
    Merge pull request !2474 from 周司南/pytorch1.8.1
2021-09-09 12:00:45 +08:00
weili10 b256f3cfcd update README.zh.md. 2021-09-09 02:55:55 +00:00
AtlasAccount a03b990d2f 同步1.5.0 0bebd44de43cda65ac171865c966d0f050740d04
!2471 【ut修复】GE增加对tensor的shape校验,导致部分UT不过
    Merge pull request !2471 from TD_lihan/utMod
--
    !2476 【FixBug】修复prod精度问题
    Merge pull request !2476 from 王晓/prod
同步1.8.1 493306e5d89167be4d0e81258af2cbddafc07364
2021-09-08 12:01:03 +08:00
shibo19 b1de459aab update readme 2021-09-07 20:16:00 +08:00
i-robot 78bb23dcfc !55 更新readme文件
Merge pull request !55 from shibo/master
2021-09-07 05:54:37 +00:00
AtlasAccount 358e163e2b 同步1.5.0 a82d3d1c73af57ba35e1e468b406140f13b34b51
!2481 更新环境变量设置HCCL
    Merge pull request !2481 from shibo/add_env
--
    !2479 【适配】ReflectionPad2D支持fp32输入
    Merge pull request !2479 from 陈庆/master
同步1.8.1 493306e5d89167be4d0e81258af2cbddafc07364
    !2475 1.8版本:更新编译报错信息
    Merge pull request !2475 from shibo/update_build
2021-09-07 12:00:55 +08:00
shibo19 e3cacd1240 update read me 2021-09-06 16:34:48 +08:00
AtlasAccount 5a675a23c2 同步1.5.0 766d7155090aaefb27fff8934d644d2741922d15
!2470 Feature: add load with acl dump function
    Merge pull request !2470 from 赵光灿/master
同步1.8.1 c28fda19acb944bc0859c243c889137491da831d
2021-09-06 12:00:55 +08:00
yinzijun 62e6edd1be update docs/zh/PyTorch网络模型移植&训练指南/PyTorch网络模型移植&训练指南.md.
修改表格样式问题
2021-09-05 09:38:58 +00:00
AtlasAccount 8b0bb12ed2 同步1.5.0 488d65cf1f2832a605272d7ed32678bc9286828e
!2473 适配: roi_align&roi_align_backward算子适配重构与修改
    Merge pull request !2473 from 姚斌/master
--
    !2467 泛化:logical_not_out算子增加outshape_resize
    Merge pull request !2467 from 姚斌/master
--
    !2472 适配replicationPad2dBackward
    Merge pull request !2472 from 李攀/replication_backward
--
    !2466 【适配】ReflectionPad2D反向适配
    Merge pull request !2466 from 陈庆/padv3grad
--
    !2461 "修改适配replicationPad2d, reflectionPad2d"
    Merge pull request !2461 from 李攀/master
--
    !2459 [Requirement] batchnormstats adapter
    Merge pull request !2459 from 吴贤坤/bnstats
--
    !2463 [bugfix] span-axis indexing should execute ptcopy
    Merge pull request !2463 from 李超/master
--
    !2457 bugfix: const节点性能优化
    Merge pull request !2457 from 郭鹏/master
--
    !2464 max_unpool3d正反向添加输入校验
    Merge pull request !2464 from 王晓/max_unpool3d
--
    !2460 【迭代四需求】max_unpool3d正反向适配
    Merge pull request !2460 from 王晓/max_unpool3d
--
    !2454 泛化:inverse支持入参fp16
    Merge pull request !2454 from 姚斌/master
--
    !2446 【迭代四需求】修改constant_pad_nd反向适配,支持更多场景
    Merge pull request !2446 from 王晓/constant_pad_nd
--
    !2447 "MaxUnpool2d"适配
    Merge pull request !2447 from 李攀/master
--
    !2445 [optimize]  optimize mm adapter and refresh storage desc
    Merge pull request !2445 from 李超/master
--
    !2453 [dump utils] fix bug: creating Int blob with Long data
    Merge pull request !2453 from lijing/master
--
    !2439 [contrib/npu/optimized_lib/] add npu_bbox_coder_encode_xyxy2xywh and npu_bbox_coder_decode_xywh2xyxy
    Merge pull request !2439 from 王姜奔/bounding_box_decode
--
    !2451 Feature: support detect_anomaly when check overflow is on
    Merge pull request !2451 from 赵光灿/master
--
    !2452 【客户现场问题】softmax_backward支持动态nz场景
    Merge pull request !2452 from 王晓/softmax_backward_nz
--
    !2437  [contrib/npu/optimized_lib/] add 双向lstm
    Merge pull request !2437 from zhusiyi/master
--
    !2449 const节点创建host tensor使用memcpy优化性能
    Merge pull request !2449 from 郭鹏/master
--
    !2450 performance optimization
    Merge pull request !2450 from 蒋荣强/optimize
--
    !2448 [Optim] 优化AvgPoolv2性能
    Merge pull request !2448 from 吴贤坤/avgpoolv2
--
    !2443 cumsum性能优化
    Merge pull request !2443 from 陈庆/cumsum
--
    !2429 softmax_backward添加nz分支
    Merge pull request !2429 from 王晓/softmax_backward_nz
--
    !2442 requirement文件修改:pytorch1.5版本仅支持torchvision0.6版本
    Merge pull request !2442 from shibo/fix_readme
--
    !2427 performance optimization
    Merge pull request !2427 from 蒋荣强/optimize
--
    !2433 mm及bmm适配代码优化
    Merge pull request !2433 from 郭鹏/master
--
    !2436 [Bugfix] avgpoolv2问题修复
    Merge pull request !2436 from 吴贤坤/avgpolv2
--
    !2438 [Bugfix] con3dBackward 特殊shape问题修复
    Merge pull request !2438 from 吴贤坤/conv3dbackwardissue
--
    !2423 适配acl Prof api,支持cann profiling
    Merge pull request !2423 from 李攀/master
--
    !2428 算子适配:conv_transpose3d_backward
    Merge pull request !2428 from 姚斌/master
--
    !2432 [contrib/npu/optimized_lib/] add Mish
    Merge pull request !2432 from 王姜奔/master
--
    !2426 【适配】增加cummin aicpu算子适配,支持int64输入
    Merge pull request !2426 from 陈庆/cummin
--
    !2431 修改NPUClearFloatStatus算子适配
    Merge pull request !2431 from 詹隽/master
--
    !2430  [optimize] 支持py37和py38 torch包编译
    Merge pull request !2430 from 李超/master
--
    !2414 change TBE-OP for select contiguous opt
    Merge pull request !2414 from 王强/master
--
    !2425 泛化:logspace_out算子增加outshape_resize
    Merge pull request !2425 from 姚斌/master
--
    !2406 Feature: add overflow detection function
    Merge pull request !2406 from 赵光灿/master
--
    !2408 DDP: fix bug. when using DDP, the grad format is different from variable results in an error.
    Merge pull request !2408 from 袁舰/master
--
    !2419 LayerNorm正反向下发性能优化
    Merge pull request !2419 from 郭鹏/master
--
    !2407 [contrib/npu/optimized_lib/] add npu_fast_condition_index_put
    Merge pull request !2407 from 王姜奔/master
--
    !2422 泛化:torch.lt(xx, out=output)场景限制output_dtype为Bool
    Merge pull request !2422 from 姚斌/master
--
    !2420 【算子适配】适配shift系列算子
    Merge pull request !2420 from TD_lihan/bsd
--
    !2416 DUMP:fix bug. when cloning a tensor from gpu to cpu, the stride of the tensor still keeps invariable.
    Merge pull request !2416 from 袁舰/tmp
--
    !2421 [bugfix] 修改padv3执行时传参错误
    Merge pull request !2421 from 吴贤坤/padv2_issue
--
    !2411 泛化:topk算子增加outshape_resize场景
    Merge pull request !2411 from 姚斌/master
--
    !2415 【bugfix】修复`fill` 当dim=0 bug
    Merge pull request !2415 from 吴贤坤/fill_issue
--
    !2403 放开layernorm_backward适配层format限制
    Merge pull request !2403 from 王晓/layernorm_backward
--
    !2412 [issue] 模型场景问题修改
    Merge pull request !2412 from 吴贤坤/issue_3
--
    !2410 performance optimization
    Merge pull request !2410 from 蒋荣强/optimize
--
    !2405 泛化:argmin算子输出format为ND
    Merge pull request !2405 from 姚斌/master
--
    !2409  aoe功能使用多线程调优加速
    Merge pull request !2409 from shibo/aoe_thread
同步1.8.1 c28fda19acb944bc0859c243c889137491da831d
    !2469 1.8版本arm编译失败临时修复
    Merge pull request !2469 from shibo/update_build
--
    !2468 1.8.1移除动态shape能力
    Merge pull request !2468 from 周司南/pytorch1.8.1
--
    !2458 1.8版本:reducer中hook更新,与开源版本保持一致
    Merge pull request !2458 from shibo/ddp_181_hook
--
    !2455 add new adaper for 1.8.1
    Merge pull request !2455 from 周司南/pytorch1.8.1
--
    !2441 pytorch1.8.1: 支持DDP训练
    Merge pull request !2441 from shibo/test_181_ddp
2021-09-03 17:51:40 +08:00
weili10 08895e3452 !53 更新1.8.1:增加1.8.1的版本
Merge pull request !53 from shibo/pt1.8.1_test
2021-09-03 09:44:40 +00:00
shibo19 eb19e5be07 update sh 2021-09-03 15:42:23 +08:00
shibo19 dbbb5b935b 同步1.5.0 ce8e47ddddc42aa66b88188f25be654e3baf1739
同步1.8.1 e4cc08b6ff7a4dcf246e669f0d2d424e2742a7cc
2021-09-02 20:06:56 +08:00
shibo19 27b2513f2f 同步1.5.0 ce8e47ddddc42aa66b88188f25be654e3baf1739 同步1.8.1 e4cc08b6ff7a4 2021-09-02 20:05:45 +08:00
shibo19 18cee26cfb update UT control 2021-09-02 19:47:40 +08:00
shibo19 d9c203af66 rename 2021-09-02 19:26:29 +08:00
shibo19 a96f349728 同步1.5.0 ce8e47ddddc42aa66b88188f25be654e3baf1739 同步1.8.1 e4cc08b6ff7a4dcf246e669f0d2d424e2742a7cc 2021-09-02 16:58:09 +08:00
weili10 08d67bb93b 删除文件 pt_sync.log 2021-09-02 06:41:21 +00:00
AtlasAccount 9d1f8c2062 同步 86fcbb8e91b16e2437c36fc6ca3a8d224e95bfb9
泛化:logical_not_out算子增加outshape_resize
2021-09-02 12:00:33 +08:00
yinzijun e56d176f63 !50 2.0.3.B050资料转测
Merge pull request !50 from yinzijun/master
2021-09-02 02:02:26 +00:00
AtlasAccount 46d2c88c76 同步 c023657b36fc647854d45a12b9833e2409cbf6e7
适配replicationPad2dBackward
 【适配】ReflectionPad2D反向适配
 "修改适配replicationPad2d, reflectionPad2d"
 [Requirement] batchnormstats adapter
2021-09-01 23:00:36 +08:00
ZijunYin 16c6efb99c 2.0.3.B050资料刷新 2021-09-01 17:27:12 +08:00
AtlasAccount 3deb4f4041 同步 16fcae50a1131194038eec02a1fccd28387424e5
[bugfix] span-axis indexing should execute ptcopy
 bugfix: const节点性能优化
 max_unpool3d正反向添加输入校验
 【迭代四需求】max_unpool3d正反向适配
2021-08-31 23:00:36 +08:00
AtlasAccount 63f22cf38d 同步 9ba6d751ab1207d32114588c43d1d366d9581783
泛化:inverse支持入参fp16
 【迭代四需求】修改constant_pad_nd反向适配,支持更多场景
 "MaxUnpool2d"适配
2021-08-30 23:00:35 +08:00
AtlasAccount 95bc96954a 同步 9fb28f8d7e69fa020ebe4b5bb91727b80c8b676b
[optimize] optimize mm adapter and refresh storage desc
2021-08-28 23:00:41 +08:00
AtlasAccount a323bfb26d 同步 51620ab6aa9631e02aff3c893c4a98b3441be1d7
[dump utils] fix bug: creating Int blob with Long data
 [contrib/npu/optimized_lib/] add npu_bbox_coder_encode_xyxy2xywh and npu_bbox_coder_decode_xywh2xyxy
 Feature: support detect_anomaly when check overflow is on
2021-08-28 12:00:36 +08:00
AtlasAccount 4c28fae7ff 同步 a50381c14de1fe552161254749e980f6993d4074
【客户现场问题】softmax_backward支持动态nz场景
 [contrib/npu/optimized_lib/] add 双向lstm
2021-08-27 23:00:33 +08:00
AtlasAccount d73f7d15d1 同步 84bf1f2f6e1e5bcd2515f4504587527371b56413
const节点创建host tensor使用memcpy优化性能
2021-08-27 12:00:37 +08:00
AtlasAccount 64142762fb 同步 57eb858d9a5188f7ccbd3fa2ef99d4467589a086
performance optimization
2021-08-26 23:00:34 +08:00
yinzijun 2671012415 !47 2.0.3.B030版本资料更新
Merge pull request !47 from yinzijun/master
2021-08-26 04:25:21 +00:00
ZijunYin 9cb88c4ae8 add img pth 2021-08-26 11:41:58 +08:00
ZijunYin 3015977115 delete img pth 2021-08-26 11:40:56 +08:00
ZijunYin 25e1415cb4 renew . 2021-08-26 11:31:36 +08:00
AtlasAccount 9276d4c441 同步 15422a9ff9ee2bb3c906de5f068297fe98c61cee
[Optim] 优化AvgPoolv2性能
2021-08-25 23:00:37 +08:00
yinzijun 3ab4642abd Remove docs/en 2021-08-25 09:32:18 +00:00
AtlasAccount aa1466742a 同步 02aa66378171f6b55cbe50ae3a6067de937af8d0
cumsum性能优化
 softmax_backward添加nz分支
 requirement文件修改:pytorch1.5版本仅支持torchvision0.6版本
2021-08-24 23:00:37 +08:00
AtlasAccount 9bfd72d468 同步 ead0163f4e42079e08e018f89b7d4b1caa7a5b27
performance optimization
 mm及bmm适配代码优化
2021-08-24 12:00:41 +08:00
AtlasAccount 0fa13028d3 同步 8468e3b692abe1e24a2576c1c3db71e76105fd3b
[Bugfix] avgpoolv2问题修复
 [Bugfix] con3dBackward 特殊shape问题修复
 适配acl Prof api,支持cann profiling
2021-08-23 23:00:37 +08:00
AtlasAccount 358cba8b6d 同步 a479199b1693507a24d1df875f6844a2665d9306
算子适配:conv_transpose3d_backward
 [contrib/npu/optimized_lib/] add Mish
 【适配】增加cummin aicpu算子适配,支持int64输入
 修改NPUClearFloatStatus算子适配
2021-08-23 12:00:32 +08:00
AtlasAccount c684b7c74a 同步 c6cc6fae2f5bb369d7b166fa1900f6e75723cad8
[optimize] 支持py37和py38 torch包编译
2021-08-21 23:00:38 +08:00
AtlasAccount d836a9cb3c 同步 b6418a68885f2731c65d5d860d37b0ab866367c5
change TBE-OP for select contiguous opt
2021-08-20 23:00:34 +08:00
AtlasAccount 369ebefd2e 同步 f50f0921fd20ee29f1d82784ec88c1be6ef18820
泛化:logspace_out算子增加outshape_resize
 Feature: add overflow detection function
2021-08-19 23:00:34 +08:00
AtlasAccount e1b754a902 同步 a7b60a03303b40169cbab3829fcc57f2ce72faf2
DDP: fix bug. when using DDP, the grad format is different from variable results in an error.
 LayerNorm正反向下发性能优化
2021-08-18 12:00:40 +08:00
AtlasAccount c6ad5c5cc5 同步 082c70d8d31797c00fb0e00cfb0a84c1cc11651d
[contrib/npu/optimized_lib/] add npu_fast_condition_index_put
 泛化:torch.lt(xx, out=output)场景限制output_dtype为Bool
 【算子适配】适配shift系列算子
 DUMP:fix bug. when cloning a tensor from gpu to cpu, the stride of the tensor still keeps invariable.
 [bugfix] 修改padv3执行时传参错误
 泛化:topk算子增加outshape_resize场景
2021-08-17 23:00:33 +08:00
AtlasAccount 54af470c20 同步 3d1cd19f02b15fb9699e73594416f28187a96990
【bugfix】修复`fill` 当dim=0 bug
 放开layernorm_backward适配层format限制
 [issue] 模型场景问题修改
 performance optimization
2021-08-16 23:00:32 +08:00
AtlasAccount c56e5299d5 同步 77355b7650e725d5db500750c0215000598f3e29
泛化:argmin算子输出format为ND
2021-08-16 12:00:34 +08:00
AtlasAccount edfe8b0306 同步 7485a1162efb716e0ab3b6c214098246f62f4fd5
aoe功能使用多线程调优加速
2021-08-14 23:00:33 +08:00
AtlasAccount 0143c1c06e 同步 ce8e47ddddc42aa66b88188f25be654e3baf1739
新增适配reflection_pad2d
 DDP: fix bug of set broadcast_buffers true
 泛化:index_select_out算子增加outshape_resize
 [contrib/npu/optimized_lib/] add npu_yolo_bbox_coder
 【PT整改】PTTriu算子整改
 【算子适配】cummax算子适配
 泛化:stack输出format修改为ND
 开源申明修改
 [bugfix] 修复scatter操作报错当dtype为int32
 Feature: add some debug logs for accuracy comparison
 算子cumsum 在dim=0时走aicpu分支
 算子适配整改:masked_select重构、增加outshape_resize
 算子适配:slow_conv3d、slow_conv3d_forward
 搬运:修改env中拼写错误
2021-08-13 18:32:50 +08:00
weili10 fe09035482 update OWNERS. 2021-08-10 09:00:24 +00:00
yinzijun e8f0e0055c Create en 2021-08-10 03:17:53 +00:00
weili10 255e1b94f6 update scripts/mkdirs.sh. 2021-08-09 07:57:30 +00:00
weili10 b184e1c1d3 update scripts/gen.sh. 2021-08-09 07:57:18 +00:00
weili10 a85cb62301 update LICENSE. 2021-08-09 07:55:30 +00:00
weili10 1500208c7f update LICENSE. 2021-08-09 07:55:03 +00:00
weili10 073ad70cc4 update LICENSE. 2021-08-09 07:54:46 +00:00
weili10 6741696481 调整安装python依赖库位置 2021-08-09 03:23:45 +00:00
i-robot 48dd2489e0 !39 在README中增加版本配套信息
Merge pull request !39 from yinzijun/master
2021-08-06 09:09:23 +00:00
AtlasAccount 7e0b4081ac 同步 43d1f773fd5478ce787360f3c9ced77ae075fbee
修复triangular_solve out报错
 [contrib/npu/optimized_lib/] add npu_single_level_responsible_flags
2021-08-06 16:45:30 +08:00
i-robot 88d5c2c545 !38 env.sh拼写错误
Merge pull request !38 from luweizheng/master
2021-08-05 09:55:22 +00:00
ZijunYin c39847cbba 在README中增加版本配套关系 2021-08-05 17:52:16 +08:00
Lu Weizheng 8fa79690b2 fix env.sh ASCEND typo 2021-08-04 09:46:25 +08:00
AtlasAccount b6464ff2b2 同步 99861473ecf33d695ac1b85a43b5e71b3ac6b6d0
修改deformable_conv2d ut
 scatter算子修改适配到ScatterElements
2021-08-03 21:45:37 +08:00
i-robot a12b0dd319 !37 同步 fb8fc52370bce643091b8572fae8fd151d233bde
Merge pull request !37 from weili10/master
2021-08-03 08:37:20 +00:00
i-robot b9c513ed2d !35 更新算子文档
Merge pull request !35 from yinzijun/master
2021-08-03 08:35:22 +00:00
weili10 e7218aaf60 同步 fb8fc52370bce643091b8572fae8fd151d233bde
[Issue] 模型问题修复
 [contrib/npu/optimized_lib/] add DCNv2
 [bugfix] 规避aicpu fp16不支持场景
 修改pytorch版本到post3
 dump: fix bug of uncontiguous
 “回退scatter_add,性能不达标”
2021-08-03 16:07:57 +08:00
weili10 5de5ce6d04 update OWNERS. 2021-07-31 08:00:23 +00:00
ZijunYin 62992d4000 更新算子开发指南和适配算子清单 2021-07-31 10:25:57 +08:00
weili10 34f84c6ca4 !34 同步 b55753edf56f77307aa77d9034d581430892dff8
Merge pull request !34 from weili10/master
2021-07-29 12:33:33 +00:00
weili10 4ebeb1fd6a 同步 b55753edf56f77307aa77d9034d581430892dff8
【泛化】NllLoss2d & NllLoss2dBackward only support Target Int32/Long
 放开dropout适配层format限制
 PT整改,回退“PTTriu”
 增加算子编译选项:使用高精度/高性能模式算子
 【泛化】torch.lt( )计算支持bool类型入参
 _svd_helper算子适配
2021-07-29 20:15:47 +08:00
i-robot c4c5da1ed0 !26 文档修改命名格式归档
Merge pull request !26 from yinzijun/master
2021-07-29 09:17:03 +00:00
张昱杰 4ad96e17f4 update scripts/mkdirs.sh. 2021-07-29 09:13:17 +00:00
ZijunYin f6bd4ea357 change name of releasenote 2021-07-29 16:46:11 +08:00
i-robot 6c52cd2a5d !29 增加开源软件使用说明
Merge pull request !29 from weili10/master
2021-07-29 01:15:03 +00:00
weili10 11ee398a57 增加开源软件使用说明 2021-07-28 21:59:09 +08:00
ZijunYin c4c9340104 update docs, add releasenote 2021-07-28 20:55:49 +08:00
ZijunYin 931f3c3878 add docs with new name and icon 2021-07-27 16:50:44 +08:00
ZijunYin a48b4fd558 update doc with new file name and icon 2021-07-27 16:42:59 +08:00
i-robot d44bc70aae !25 同步 2e109bb3201b0dab4d8445c7c431c2edf5868ccc
Merge pull request !25 from weili10/master
2021-07-26 13:55:24 +00:00
weili10 021efdf1da 同步 2e109bb3201b0dab4d8445c7c431c2edf5868ccc
【Task】Erfc适配
 算子适配:conv_transpose3d
 _triangular_solve_helper算子适配
 API兼容性整改:编译接口AclopSetCompileFlag
2021-07-26 21:32:26 +08:00
i-robot 1d607dcf4f !24 同步 99ba430b04031e42d0284436f13584a845d82b53
Merge pull request !24 from weili10/master
2021-07-23 10:54:34 +00:00
weili10 b2afdd7871 同步 99ba430b04031e42d0284436f13584a845d82b53
Symeig算子适配
 rrelu_with_noise适配
2021-07-23 18:20:45 +08:00
i-robot 37fc10168a !23 同步 8ec7266c6bdd8119c253919567c2870a3f5aae0c
Merge pull request !23 from weili10/master
2021-07-22 12:40:49 +00:00
weili10 6432bc6349 同步 8ec7266c6bdd8119c253919567c2870a3f5aae0c
泛化:smooth_l1_loss算子支持 0 Shape输入
 【算子适配】tril_indices/triu_indices算子适配
2021-07-22 20:24:36 +08:00
weili10 4160ab8ab6 !22 同步 384a3c920d51a9e7538b7f99737d8acd0f8bd63e
Merge pull request !22 from weili10/master
2021-07-22 01:14:11 +00:00
weili10 afaa4d4e88 同步 384a3c920d51a9e7538b7f99737d8acd0f8bd63e
PT整改
 泛化:torch.max(input, dim, keppdim)支持input为DT_BOOL或DT_INT32入参
 modify the method of query event status
2021-07-21 17:15:46 +08:00
weili10 91014cd3b8 !21 同步 7ea28538822d890b75b190fbd8a1e1f984e4e9e2
Merge pull request !21 from weili10/master
2021-07-20 11:42:49 +00:00
weili10 798f0c3b16 同步7ea28538822d890b75b190fbd8a1e1f984e4e9e2 2021-07-20 19:11:41 +08:00
weili10 c28c47c9cd update LICENSE. 2021-07-16 13:42:44 +00:00
weili10 bda914c574 !17 同步b98f7ec21ee0d6c14be8b0bd09301d9f6e686816
Merge pull request !17 from weili10/master
2021-07-16 13:42:01 +00:00
weili10 edb5c70443 同步b98f7ec21ee0d6c14be8b0bd09301d9f6e686816 2021-07-16 18:19:48 +08:00
weili10 4689a0514b !13 [Task]新版本文档归档
Merge pull request !13 from fenghaolin/master
2021-07-14 13:53:10 +00:00
fenghaolin 63950d1412 新版本资料归档 2021-07-14 21:27:33 +08:00
weili10 16fb2692c6 update LICENSE. 2021-07-14 05:52:06 +00:00
weili10 193cd1f80d update LICENSE. 2021-07-14 04:08:58 +00:00
weili10 6b5302218a update LICENSE. 2021-07-14 03:54:29 +00:00
weili10 a27e4f60c6 !11 同步44740072b1b0ea6a5b63ef7203bab73f986e2472
Merge pull request !11 from weili10/master
2021-07-13 07:55:04 +00:00
weili10 ae48832f81 同步44740072b1b0ea6a5b63ef7203bab73f986e2472 2021-07-13 15:52:09 +08:00
weili10 08403764d6 !10 优化readme中命令执行目录说明
Merge pull request !10 from weili10/master
2021-07-12 12:26:05 +00:00
weli10 998d0c88b9 优化readme中命令执行目录说明 2021-07-12 20:24:20 +08:00
张昱杰 7a0a5a6eb0 !5 [Task]添加docs文件夹中的文档
Merge pull request !5 from fenghaolin/0706
2021-07-09 09:54:27 +00:00
张昱杰 cb9b8627b9 !8 同步42f3827ef92a65a09eee3dd1a9f527de774f5da2
Merge pull request !8 from 张昱杰/master
2021-07-09 09:52:37 +00:00
ascendzyj 6b80c3e7d6 Merge branch 'master' of https://gitee.com/ascend/pytorch into master 2021-07-09 17:47:57 +08:00
weili10 b6069682fd !7 修改命名
Merge pull request !7 from 张昱杰/master
2021-07-09 09:47:39 +00:00
ascendzyj 9cb7f795df Merge branch 'master' of https://gitee.com/ascend/pytorch into master 2021-07-09 17:44:15 +08:00
ascendzyj 7024d04779 同步42f3827ef92a65a09eee3dd1a9f527de774f5da2 2021-07-09 17:43:07 +08:00
z00444290 70f0613df8 修改命名 2021-07-09 16:55:01 +08:00
z00444290 2468dd37ae 修改生成代码和编译脚本 2021-07-08 21:29:58 +08:00
张昱杰 7446763b5f !6 删除URL信息
Merge pull request !6 from 张昱杰/master
2021-07-08 02:25:23 +00:00
ascendzyj a45cb145e9 删除URL信息 2021-07-07 13:54:50 +08:00
fenghaolin 6bbc1db7d2 新增网络模型移植&训练指南 2021-07-06 11:35:16 +08:00
fenghaolin 59d9f9fe86 新增在线推理指南 2021-07-06 11:34:55 +08:00
fenghaolin c682f1e267 新增API支持清单 2021-07-06 11:34:38 +08:00
fenghaolin 1505864443 新增PyTorch适配算子清单 2021-07-06 11:34:19 +08:00
fenghaolin fdfb70af54 新增开发指南 2021-07-06 11:33:56 +08:00
fenghaolin aac3e9f237 添加算子清单 2021-07-06 11:33:16 +08:00
fenghaolin cb5937bf50 删除不需要的内容 2021-07-06 11:32:45 +08:00
fenghaolin 45a79b8865 Merge branch 'master' of https://gitee.com/ascend/pytorch 2021-07-06 11:30:14 +08:00
i-robot 18a27fad1f !4 同步f2209ee61066ae89d4efd1782a30b6235e0e0548
Merge pull request !4 from 张昱杰/master
2021-07-05 11:05:18 +00:00
ascendzyj 2ae4953208 同步f2209ee61066ae89d4efd1782a30b6235e0e0548 2021-07-05 17:14:18 +08:00
i-robot 2e90ba92b9 !3 同步739736a13b52b3203c116ea551f82c78aefe9bee
Merge pull request !3 from 张昱杰/master
2021-06-26 02:30:51 +00:00
ascendzyj dfb77c9348 同步739736a13b52b3203c116ea551f82c78aefe9bee 2021-06-26 09:52:46 +08:00
fenghaolin eca80895e7 添加CRNN文档 2021-06-26 09:11:03 +08:00
i-robot 30722c29f5 !1 [Task]补充CONTRIBUTING.zh.md文件
Merge pull request !1 from fenghaolin/master
2021-06-25 06:44:06 +00:00
fenghaolin e0003631b5 添加CONTRIBUTING.zh.md 2021-06-25 08:35:53 +08:00
ascendzyj a83ecb1f7f init repo pytorch-develop of f14e649790d60cc88e60460743b0038cc00346c9 2021-06-24 16:41:42 +08:00
张昱杰 b2b33bd531 Initial commit 2021-06-24 08:13:55 +00:00
2730 changed files with 220216 additions and 429175 deletions
-7
View File
@@ -1,7 +0,0 @@
# Python dependencies required for unit tests
mypy==1.8.0
# Pin MyPy version because new errors are likely to appear with each release
#Description: linter
#Pinned versions: 1.8.0
#test that import: test_typing.py, test_type_hints.py
@@ -1,51 +0,0 @@
name: Fetch and Rebase
description: Fetch and rebase for repository
inputs:
repo_path:
description: the path the repository locate on
required: true
remote_branch:
description: the branch rebased from
required: true
loop:
description: loop times when fails
required: true
runs:
using: composite
steps:
- name: Fetch and rebase
env:
REPO_PATH: ${{ inputs.repo_path }}
REMOTE_BRANCH: ${{ inputs.remote_branch }}
LOOP: ${{ inputs.loop }}
shell: bash
run: |
set +e
COUNT=0
for i in $(seq 1 ${LOOP})
do
pushd ${REPO_PATH} &&
git fetch --all &&
git rebase ${REMOTE_BRANCH} &&
git submodule sync &&
git submodule update --init --recursive &&
git reset --hard HEAD &&
git clean -dfx &&
git submodule foreach git reset --hard HEAD &&
git submodule foreach git clean -dfx &&
popd
if [[ $? -ne 0 ]]
then
let COUNT++
else
break
fi
done
[[ ${COUNT} -lt ${LOOP} ]] && true || false
-61
View File
@@ -1,61 +0,0 @@
name: Build and Test
on:
workflow_call:
inputs:
runner:
required: true
type: string
description: The runner selected to run on
devices:
required: true
type: string
description: The devices selected to run on
image:
required: true
type: string
description: The docker iamge which will be loaded
jobs:
build-and-test:
runs-on: ${{ inputs.runner }}
defaults:
run:
shell: bash
container:
image: ${{ inputs.image }}
env:
HOME: /root
volumes:
- /usr/local/dcmi:/usr/local/dcmi
- /usr/local/bin/npu-smi:/usr/local/bin/npu-smi
- /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/
- /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info
- /root/codes/:/root/codes
options: --network host ${{ inputs.devices }} --device /dev/davinci_manager --device /dev/devmm_svm --device /dev/hisi_hdc
steps:
- name: Set environment
run: |
source /root/.bashrc && conda activate torch_npu
- name: Prepare the codes
run: |
\cp -rf /root/codes/ /root/build
- name: Compile torch
working-directory: /root/build/pytorch/pytorch
run: |
pip3 install -r requirements.txt -i https://mirrors.huaweicloud.com/repository/pypi/simple
export _GLIBCXX_USE_CXX11_ABI=0
export USE_CUDA=0
export USE_XNNPACK=0
python setup.py develop
- name: Compile and install torch_npu
working-directory: /root/build/npu/pytorch
run: |
pip3 install -r requirements.txt -i https://mirrors.huaweicloud.com/repository/pypi/simple
bash ci/build.sh --python=3.8
pip3 install dist/torch_npu*.whl
- name: Do the test
working-directory: /root/build
run: |
pip3 install -r npu/pytorch/test/requirements.txt -i https://mirrors.huaweicloud.com/repository/pypi/simple --no-deps
python npu/pytorch/ci/access_control_test.py
-30
View File
@@ -1,30 +0,0 @@
name: Fetch and Rebase
on:
workflow_call:
inputs:
runner:
required: true
type: string
description: The runner selected to run on
loop:
required: true
type: string
description: Loop time when fails
jobs:
fetch-and-rebase:
runs-on: ${{ inputs.runner }}
steps:
- name: Pull latest codes for torch
uses: ascend/pytorch/.github/actions/fetch-and-rebase@master
with:
repo_path: /root/codes/pytorch/pytorch
remote_branch: upstream/main
loop: ${{ inputs.loop }}
- name: Pull latest codes for torch_npu
uses: ascend/pytorch/.github/actions/fetch-and-rebase@master
with:
repo_path: /root/codes/npu/pytorch
remote_branch: upstream/master
loop: ${{ inputs.loop }}
-37
View File
@@ -1,37 +0,0 @@
name: Ascend NPU(Manual)
on:
workflow_dispatch:
inputs:
runner:
required: true
type: string
default: 'self-hosted'
description: The runner selected to run on
devices:
required: true
type: string
default: '--device /dev/davinci6'
description: The devices selected to run on
image:
required: true
type: string
default: 'ascendai/cann:7.1-openeuler2203sp2'
description: The docker iamge which will be loaded
jobs:
linux-py3_8-fetch-and-rebase:
name: linux-py3_8-7.0.RC1.alpha005
uses: ./.github/workflows/_fetch_and_rebase.yml
with:
runner: ${{ inputs.runner }}
loop: 10
linux-py3_8-build-and-test:
name: linux-py3_8-7.0.RC1.alpha005
uses: ./.github/workflows/_build-and-test.yml
needs: linux-py3_8-fetch-and-rebase
with:
runner: ${{ inputs.runner }}
devices: ${{ inputs.devices }}
image: ${{ inputs.image }}
-26
View File
@@ -1,26 +0,0 @@
# Note:
# Same runner only needs one job named like .*fetch-and-rebase
name: Ascend NPU
on:
schedule:
- cron: '0 12 * * *'
workflow_dispatch:
jobs:
linux-py3_8-fetch-and-rebase:
name: linux-py3_8-7.0.RC1.alpha005
uses: ./.github/workflows/_fetch_and_rebase.yml
with:
runner: self-hosted
loop: 10
linux-py3_8-build-and-test:
name: linux-py3_8-7.0.RC1.alpha005
uses: ./.github/workflows/_build-and-test.yml
needs: linux-py3_8-fetch-and-rebase
with:
runner: self-hosted
devices: --device /dev/davinci6
image: ascendai/cann:7.1-openeuler2203sp2
-204
View File
@@ -1,204 +0,0 @@
# READ THIS BEFORE YOU REFACTOR ME
#
# setup.py uses the list of patterns in this file to decide
# what to delete, but it's not 100% sound. So, for example,
# if you delete aten/build/ because it's redundant with build/,
# aten/build/ will stop being cleaned. So be careful when
# refactoring this file!
## PyTorch
.coverage
coverage.xml
.dmypy.json
.gradle
.hypothesis
.mypy_cache
*/*.so*
*/**/__pycache__
*/**/*.dylib*
*/**/*.pyd
*/**/*.so*
log
# Root level file used in CI to specify certain env configs.
# E.g., see .circleci/config.yaml
env
.circleci/scripts/COMMIT_MSG
# IPython notebook checkpoints
.ipynb_checkpoints
# Editor temporaries
*.swn
*.swo
*.swp
*.swm
*~
# macOS dir files
.DS_Store
# Ninja files
.ninja_deps
.ninja_log
compile_commands.json
*.egg-info/
## General
# Compiled Object files
*.slo
*.lo
*.o
*.cuo
*.obj
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Compiled protocol buffers
*.pb.h
*.pb.cc
*_pb2.py
# Compiled python
*.pyc
*.pyd
# Compiled MATLAB
*.mex*
# IPython notebook checkpoints
.ipynb_checkpoints
# Editor temporaries
*.swn
*.swo
*.swp
*~
# Sublime Text settings
*.sublime-workspace
*.sublime-project
# Eclipse Project settings
*.*project
.settings
# QtCreator files
*.user
# PyCharm files
.idea
# OSX dir files
.DS_Store
# GDB history
.gdb_history
## Caffe2
# build, distribute, and bins (+ python proto bindings)
build
build_host_protoc
build_android
build_ios
/build_*
.build_debug/*
.build_release/*
.build_profile/*
distribute/*
*.testbin
*.bin
cmake_build
.cmake_build
gen
.setuptools-cmake-build
.pytest_cache
aten/build/*
dist
# Bram
plsdontbreak
# Generated documentation
docs/_site
docs/gathered
_site
doxygen
docs/dev
# LevelDB files
*.sst
*.ldb
LOCK
CURRENT
MANIFEST-*
# generated version file
caffe2/version.py
# setup.py intermediates
.eggs
caffe2.egg-info
# Atom/Watchman required file
.watchmanconfig
# Files generated by CLion
cmake-build-debug
# BEGIN NOT-CLEAN-FILES (setup.py handles this marker. Do not change.)
#
# Below files are not deleted by "setup.py clean".
# Visual Studio Code files
.vscode
.vs
# YouCompleteMe config file
.ycm_extra_conf.py
# Files generated when a patch is rejected
*.orig
*.rej
# Files generated by ctags
CTAGS
GTAGS
GRTAGS
GSYMS
GPATH
tags
TAGS
# ccls file
.ccls-cache/
# clang-format storage location used by apply_clang_format.py
.clang-format-bin
# clangd background index
.clangd/
.cache/
# bazel symlinks
bazel-*
# Generated files
torch_npu/version.py
torch_npu/csrc/aten/NPUNativeFunctions.h
torch_npu/csrc/aten/RegisterAutogradNPU.cpp
torch_npu/csrc/aten/RegisterCPU.cpp
torch_npu/csrc/aten/RegisterNPU.cpp
torch_npu/csrc/aten/python_custom_functions.cpp
torch_npu/_op_plugin_docs.py
-16
View File
@@ -1,16 +0,0 @@
[submodule "third_party/op-plugin"]
path = third_party/op-plugin
url = https://gitee.com/ascend/op-plugin.git
ignore = dirty
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://gitee.com/mirrors/googletest.git
[submodule "third_party/torchair/torchair"]
path = third_party/torchair/torchair
url = https://gitee.com/ascend/torchair.git
[submodule "third_party/Tensorpipe"]
path = third_party/Tensorpipe
url = https://gitee.com/ascend/Tensorpipe.git
[submodule "third_party/nlohmann"]
path = third_party/nlohmann
url = https://gitee.com/mirrors/nlohmann-json.git
-357
View File
@@ -1,357 +0,0 @@
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
find_program(CCACHE ccache)
if(${CCACHE} STREQUAL "CCACHE-NOTFOUND")
message(STATUS "Compile without ccache")
else()
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE} CACHE PATH "cache Compiler")
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE} CACHE PATH "cache Compiler")
message(STATUS "CMAKE_C_COMPILER_LAUNCHER:${CMAKE_C_COMPILER_LAUNCHER}")
message(STATUS "CMAKE_CXX_COMPILER_LAUNCHER:${CMAKE_CXX_COMPILER_LAUNCHER}")
endif()
project(TORCHNPU CXX C)
set(LINUX TRUE)
set(CMAKE_INSTALL_MESSAGE NEVER)
# set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(DEFINED TORCH_VERSION)
add_definitions(-DPYTORCH_NPU_VERSION="${TORCH_VERSION}")
endif()
set(PLUGIN_NAME torch_npu)
set(RPATH_VALUE $ORIGIN)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "${RPATH_VALUE}/lib/:${RPATH_VALUE}/")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${TORCHNPU_INSTALL_LIBDIR})
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
# LTO&PGO optimization in compile option
SET(IF_APPEND FALSE)
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
SET(APPEND_FLAGS "-fGNU-compatibility -fuse-ld=lld -Wno-non-pod-varargs")
if (DEFINED ENABLE_LTO)
SET(IF_APPEND TRUE)
SET(APPEND_FLAGS "${APPEND_FLAGS} -flto=thin")
endif()
if (DEFINED PGO_MODE)
SET(IF_APPEND TRUE)
if (PGO_MODE EQUAL 1)
SET(APPEND_FLAGS "${APPEND_FLAGS} -fprofile-generate")
elseif (PGO_MODE EQUAL 2)
SET(APPEND_FLAGS "${APPEND_FLAGS} -fprofile-use=${CMAKE_CURRENT_SOURCE_DIR}/default.profdata")
endif()
endif()
else()
if (DEFINED ENABLE_LTO)
message(FATAL_ERROR "Currently, LTO auto build is not supported in ${CMAKE_CXX_COMPILER_ID}")
endif()
if (DEFINED PGO_MODE)
message(FATAL_ERROR "Currently, PGO auto build is not supported in ${CMAKE_CXX_COMPILER_ID}")
endif()
endif()
if (IF_APPEND)
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${APPEND_FLAGS}")
endif()
# check and set CMAKE_CXX_STANDARD
string(FIND "${CMAKE_CXX_FLAGS}" "-std=c++" env_cxx_standard)
if(env_cxx_standard GREATER -1)
message(
WARNING "C++ standard version definition detected in environment variable."
"PyTorch requires -std=c++17. Please remove -std=c++ settings in your environment.")
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)
set(TORCHNPU_ROOT "${PROJECT_SOURCE_DIR}/torch_npu/csrc")
set(TORCHNPU_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
set(Torch_DIR ${PYTORCH_INSTALL_DIR}/share/cmake/Torch)
FIND_PACKAGE(Torch REQUIRED)
set(LINUX TRUE)
set(CMAKE_INSTALL_MESSAGE NEVER)
#set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Define build type
IF(CMAKE_BUILD_TYPE MATCHES Debug)
message("Debug build.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_DEBUG")
ELSEIF(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
message("RelWithDebInfo build")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNDEBUG")
ELSE()
message("Release build.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNDEBUG")
ENDIF()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing")
# Eigen fails to build with some versions, so convert this to a warning
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-type-limits")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-array-bounds")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-strict-overflow")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-strict-aliasing")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-ignored-qualifiers")
if (CMAKE_COMPILER_IS_GNUCXX AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-overflow")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=redundant-decls")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=old-style-cast")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(notdir $(abspath $<))\"'")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-builtin-macro-redefined -D__FILE__='\"$(subst $(realpath ${CMAKE_SOURCE_DIR})/,,$(abspath $<))\"'")
# These flags are not available in GCC-4.8.5. Set only when using clang.
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-partial-specialization")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-typedef-redefinition")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-aligned-allocation-unavailable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++17-extensions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-constexpr-not-const")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-braces")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
if (${COLORIZE_OUTPUT})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
endif()
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)
if (${COLORIZE_OUTPUT})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
endif()
endif()
if ((APPLE AND (NOT ("${CLANG_VERSION_STRING}" VERSION_LESS "9.0")))
OR (CMAKE_COMPILER_IS_GNUCXX
AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0 AND NOT APPLE)))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-new")
endif()
if (WERROR)
check_cxx_compiler_flag("-Werror" COMPILER_SUPPORT_WERROR)
if (NOT COMPILER_SUPPORT_WERROR)
set(WERROR FALSE)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()
endif(WERROR)
if (NOT APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-uninitialized")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -O0")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_STATIC_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-math-errno")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-trapping-math")
set(CMAKE_CXX_COVERAGE $ENV{CALCULATE_CXX_COVERAGE})
if (CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_C_FLAGS "-fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack -fPIE -pie ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack -fPIE -pie ${CMAKE_CXX_FLAGS}")
set(CXXFLAGS "-fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack -fPIE -pie ${CXXFLAGS}")
elseif (CMAKE_CXX_COVERAGE STREQUAL "1")
set(CMAKE_C_FLAGS "-fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack -fprofile-arcs -ftest-coverage -fPIE -pie ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack -fprofile-arcs -ftest-coverage -fPIE -pie ${CMAKE_CXX_FLAGS}")
set(CXXFLAGS "-fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack -fprofile-arcs -ftest-coverage -fPIE -pie ${CXXFLAGS}")
else()
set(CMAKE_C_FLAGS "-fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack -fPIE -pie ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack -fPIE -pie ${CMAKE_CXX_FLAGS}")
set(CXXFLAGS "-fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack -fPIE -pie ${CXXFLAGS}")
endif()
if (NOT DEFINED GLIBCXX_USE_CXX11_ABI)
set(GLIBCXX_USE_CXX11_ABI 0)
endif()
message(STATUS "Determined _GLIBCXX_USE_CXX11_ABI=${GLIBCXX_USE_CXX11_ABI}")
set(_GLIBCXX_USE_CXX11_ABI ${GLIBCXX_USE_CXX11_ABI})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=${GLIBCXX_USE_CXX11_ABI}")
if (${GLIBCXX_USE_CXX11_ABI} EQUAL 0)
set(CMAKE_CXX_FLAGS "-fabi-version=11 ${CMAKE_CXX_FLAGS}")
else()
set(CXX_STANDARD_REQUIRED ON)
if (DEFINED ABI_VERSION)
set(CMAKE_CXX_FLAGS "-fabi-version=${ABI_VERSION} ${CMAKE_CXX_FLAGS}")
endif()
endif()
if (DEFINED BUILD_LIBTORCH)
add_compile_definitions(BUILD_LIBTORCH)
endif()
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/torch_npu/csrc/aten)
include_directories(${PROJECT_SOURCE_DIR}/third_party/hccl/inc)
include_directories(${PROJECT_SOURCE_DIR}/third_party/acl/inc)
include_directories(${PROJECT_SOURCE_DIR}/third_party/Tensorpipe)
include_directories(${PROJECT_SOURCE_DIR}/third_party/nlohmann/include)
# Set installed PyTorch dir
if(DEFINED PYTORCH_INSTALL_DIR)
include_directories(${PYTORCH_INSTALL_DIR}/include)
include_directories(${PYTORCH_INSTALL_DIR}/include/torch/csrc/api/include)
include_directories(${PYTORCH_INSTALL_DIR}/include/torch/csrc/distributed)
else()
message(FATAL_ERROR "Cannot find installed PyTorch directory")
endif()
# Set Python include dir
if(DEFINED PYTHON_INCLUDE_DIR)
include_directories(${PYTHON_INCLUDE_DIR})
else()
message(FATAL_ERROR "Cannot find installed Python head file directory")
endif()
# sources
set(ATEN_SRCS)
set(CORE_SRCS)
set(FRAMEWORK_SRCS)
set(LOGGING_SRCS)
if (NOT DEFINED BUILD_LIBTORCH)
set(DIST_SRCS)
set(FLOP_SRCS)
set(NPU_SRCS)
set(PROF_SRCS)
set(UTILS_SRCS)
set(SAN_SRCS)
endif()
if (DEFINED BUILD_LIBTORCH)
set(NPU_CPP_LIBS_SRCS)
endif()
add_subdirectory(${TORCHNPU_ROOT}/aten)
add_subdirectory(${TORCHNPU_ROOT}/core)
add_subdirectory(${TORCHNPU_ROOT}/framework)
add_subdirectory(${TORCHNPU_ROOT}/flopcount)
add_subdirectory(${TORCHNPU_ROOT}/logging)
if (NOT DEFINED BUILD_LIBTORCH)
add_subdirectory(${TORCHNPU_ROOT}/distributed)
add_subdirectory(${TORCHNPU_ROOT}/npu)
add_subdirectory(${TORCHNPU_ROOT}/profiler)
add_subdirectory(${TORCHNPU_ROOT}/utils)
add_subdirectory(${TORCHNPU_ROOT}/sanitizer)
endif()
if (DEFINED BUILD_LIBTORCH)
add_subdirectory(${TORCHNPU_ROOT}/libs)
endif()
set(OPS_PLUGIN_SRCS)
# Add subdirectory of op-plugin
include_directories(${PROJECT_SOURCE_DIR}/third_party/op-plugin)
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/op-plugin/op_plugin)
if (DEFINED BUILD_TENSORPIPE)
add_definitions(-DUSE_RPC_FRAMEWORK)
set(BUILD_SHARED_LIBS ON)
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/Tensorpipe)
set(BUILD_SHARED_LIBS OFF)
endif()
if (DEFINED BUILD_LIBTORCH)
set(CPP_SRCS ${ATEN_SRCS} ${CORE_SRCS} ${OPS_PLUGIN_SRCS} ${FLOP_SRCS} ${FRAMEWORK_SRCS} ${LOGGING_SRCS} ${NPU_CPP_LIBS_SRCS})
else()
# Compile code with pybind11
set(CPP_SRCS ${ATEN_SRCS} ${CORE_SRCS} ${OPS_PLUGIN_SRCS} ${DIST_SRCS} ${FLOP_SRCS} ${LOGGING_SRCS} ${FRAMEWORK_SRCS} ${NPU_SRCS} ${PROF_SRCS} ${UTILS_SRCS} ${SAN_SRCS})
endif()
add_library(${PLUGIN_NAME} SHARED ${CPP_SRCS})
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-fvisibility=hidden" COMPILER_SUPPORTS_HIDDEN_VISIBILITY)
if(${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
target_compile_options(${PLUGIN_NAME} PRIVATE "-fvisibility=hidden")
endif()
if (DEFINED BUILD_TORCHAIR)
add_subdirectory(${TORCHNPU_THIRD_PARTY_ROOT}/torchair)
add_dependencies(${PLUGIN_NAME} copy_torchair_pyfiles)
endif()
link_directories(${PYTORCH_INSTALL_DIR}/lib)
link_directories(${TORCHNPU_THIRD_PARTY_ROOT}/acl/libs)
target_link_libraries(${PLUGIN_NAME} PUBLIC ${TORCHNPU_THIRD_PARTY_ROOT}/acl/libs/libhccl.so)
if (NOT DEFINED BUILD_LIBTORCH)
target_link_libraries(${PLUGIN_NAME} PUBLIC ${PYTORCH_INSTALL_DIR}/lib/libtorch_python.so)
endif()
target_link_libraries(${PLUGIN_NAME} PUBLIC ${TORCHNPU_THIRD_PARTY_ROOT}/acl/libs/libascendcl.so)
target_link_libraries(${PLUGIN_NAME} PUBLIC ${TORCHNPU_THIRD_PARTY_ROOT}/acl/libs/libacl_op_compiler.so)
target_link_libraries(${PLUGIN_NAME} PUBLIC ${TORCHNPU_THIRD_PARTY_ROOT}/acl/libs/libge_runner.so)
target_link_libraries(${PLUGIN_NAME} PUBLIC ${TORCHNPU_THIRD_PARTY_ROOT}/acl/libs/libgraph.so)
if (DEFINED BUILD_TENSORPIPE)
target_link_libraries(${PLUGIN_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/build/packages/torch_npu/lib/libtensorpipe.so)
endif()
target_link_libraries(${PLUGIN_NAME} PUBLIC torch torch_cpu c10)
if (NOT DEFINED BUILD_LIBTORCH)
set(ATEN_THREADING "OMP" CACHE STRING "ATen parallel backend")
message(STATUS "Using ATen parallel backend: ${ATEN_THREADING}")
if ("${ATEN_THREADING}" STREQUAL "OMP")
target_compile_definitions(${PLUGIN_NAME} PUBLIC "-DAT_PARALLEL_OPENMP=1")
elseif ("${ATEN_THREADING}" STREQUAL "NATIVE")
target_compile_definitions(${PLUGIN_NAME} PUBLIC "-DAT_PARALLEL_NATIVE=1")
elseif ("${ATEN_THREADING}" STREQUAL "TBB")
target_compile_definitions(${PLUGIN_NAME} PUBLIC "-DAT_PARALLEL_NATIVE_TBB=1")
else()
message(FATAL_ERROR "Unknown ATen parallel backend: ${ATEN_THREADING}")
endif()
include(GNUInstallDirs)
target_compile_options(${PLUGIN_NAME} PRIVATE "-DC10_BUILD_MAIN_LIB")
install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
if (NOT DEFINED BUILD_LIBTORCH)
add_subdirectory(${TORCHNPU_ROOT}/toolkit)
target_link_libraries(${PLUGIN_NAME} PUBLIC npu_profiler)
endif()
if (DEFINED BUILD_GTEST)
enable_testing()
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build/gtest)
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/googletest)
include_directories(${PROJECT_SOURCE_DIR}/third_party/googletest/googletest/include)
set(TORCH_API_TEST_SOURCES)
add_subdirectory(${PROJECT_SOURCE_DIR}/test/cpp/api)
add_executable(test_api ${TORCH_API_TEST_SOURCES})
target_link_libraries(test_api PUBLIC torch_npu)
target_link_libraries(test_api PUBLIC gtest_main gtest)
endif()
if (DEFINED BUILD_LIBTORCH)
configure_file(
${PROJECT_SOURCE_DIR}/cmake/Torch_npuConfig.cmake.in
${PROJECT_SOURCE_DIR}/build/Torch_npuConfig.cmake
@ONLY)
endif()
+8 -8
View File
@@ -41,20 +41,19 @@
1. 编写测试脚本。
以add运算为例,在“pytorch/test/test\_network\_ops“路径下编写测试脚本文件: test\_add.py。
以add运算为例,在“pytorch/test/test\_npu/test\_network\_ops“路径下编写测试脚本文件: test\_add.py。
以下示例仅为一个简单的用例实现,供用户参考。具体测试用例的实现,需要根据运算定义进行完整的覆盖才能保证功能的基本正确。
```
# 引入依赖库
import sys
sys.path.append('..')
import torch
import torch_npu
import numpy as np
from torch_npu.testing.testcase import TestCase, run_tests
from torch_npu.testing.common_utils import create_common_tensor
from common_utils import TestCase, run_tests
from common_device_type import dtypes, instantiate_device_type_tests
from util_test import create_common_tensor
# 定义add测试用例类
class TestAdd(TestCase):
@@ -86,20 +85,21 @@
self.assertRtolEqual(cpu_output, npu_output)
# 定义具体add场景的测试用例,用例函数需要以test_开头
def test_add_shape_format_fp32_2d(self):
def test_add_shape_format_fp32_2d(self, device):
format_list = [0, 3, 29]
shape_format = [
[np.float32, i, [5, 256]] for i in format_list
]
self.add_result(shape_format)
instantiate_device_type_tests(TestAdd, globals(), except_for="cpu")
if __name__ == "__main__":
run_tests()
```
2. 设置环境变量。
进入"pytorch"根目录,并执行env.sh脚本。
进入"pytorch/src"路径,并执行env.sh脚本。
```
bash env.sh
+18 -66
View File
@@ -1,78 +1,30 @@
From PyTorch:
BSD 3-Clause License
Copyright (c) 2020, Huawei Technologies Co., Ltd
Copyright (c) 2016- Facebook, Inc (Adam Paszke)
Copyright (c) 2014- Facebook, Inc (Soumith Chintala)
Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert)
Copyright (c) 2012-2014 Deepmind Technologies (Koray Kavukcuoglu)
Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu)
Copyright (c) 2011-2013 NYU (Clement Farabet)
Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston)
Copyright (c) 2006 Idiap Research Institute (Samy Bengio)
Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz)
From Caffe2:
Copyright (c) 2016-present, Facebook Inc. All rights reserved.
All contributions by Facebook:
Copyright (c) 2016 Facebook Inc.
All contributions by Google:
Copyright (c) 2015 Google Inc.
All rights reserved.
All contributions by Yangqing Jia:
Copyright (c) 2015 Yangqing Jia
All rights reserved.
All contributions by Kakao Brain:
Copyright 2019-2020 Kakao Brain
All contributions by Cruise LLC:
Copyright (c) 2022 Cruise LLC.
All rights reserved.
All contributions from Caffe:
Copyright(c) 2013, 2014, 2015, the respective contributors
All rights reserved.
All other contributions:
Copyright(c) 2015, 2016 the respective contributors
All rights reserved.
Caffe2 uses a copyright model similar to Caffe: each contributor holds
copyright over their contributions to Caffe2. The project versioning records
all such contribution and copyright details. If a contributor wants to further
mark their specific copyright on a particular contribution, they should
indicate their copyright solely in the commit message of the change when it is
committed.
Copyright (c) 2019, Facebook CORPORATION.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the names of Facebook, Deepmind Technologies, NYU, NEC Laboratories America
and IDIAP Research Institute nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+17 -38
View File
@@ -1,52 +1,31 @@
approvers:
- blian
- nalinaly
- weili10
- li_jing_hw
- clinglai
- xuepenginnanjing
- yskhhh
- brightlyking
- wangjiangben_hw
- wangchao285
- atlasaccount
- dilililiwhy
- chenhao_1209
- sunboquan
- wangchao147
- yanpengquan07
- kaixin1976
- you-ansheng
reviewers:
- shibo19
- Ronnie_zheng
- xiaxia3
- li_chao10
- petissue
- td__lihan
- ascendzyj
- wudingyuan
- yskhhh
- matrixplayer
- li_jing_hw
- wangjiangben_hw
- qingfenxiaochong
- goodjobwubai
- fairwarning
- you-ansheng
- yinzijun
- weili10
- clinglai
- shaoyf
- yanpengquan07
- xiong05
- liu-jiaweikf
- xiepeng20
- brightlyking
- chenhao_1209
- wbigat
- will-devil
- ckirchhoff
- liu-tianlong
- wangchao285
- dilililiwhy
- sunjiayang
- huangyunlong2022
- misty-rain-typhoid
- du-jin-hang
- xqiangx1991
- zhan-jun
- wujianping996
- jiangpengfei712
- nalinaly
- wang-guangbin
- chuboning
- guo-guanghao
- yuhaiyan
- wangchao147
- insanecoder
- Chen_LiQing
- chenhao_1209
+500
View File
@@ -0,0 +1,500 @@
# AscendPyTorch
<h1 id="introductionmd">Introduction</h1>
This project develops the PyTorch Adapter plugin to adapt Ascend to the PyTorch framework so that developers who use the PyTorch framework can obtain powerful compute capabilities of Ascend AI Processors. When setting up the environment for model development and running under PyTorch, you can manually build and install modules adapted to the PyTorch framework on a server.
<h3 id="prerequisitesmd">Prerequisites</h3>
- The development or operating environment of CANN has been installed. For details, see the *CANN Software Installation Guide*.
- Python version: 3.7.5 or 3.8
# System Dependencies
## CentOS & EulerOS
yum install -y patch zlib-devel libffi-devel openssl-devel libjpeg-turbo-devel gcc-c++ sqlite-devel dos2unix openblas git dos2unix
yum install -y gcc==7.3.0 cmake==3.12.0
## Ubuntu
apt-get install -y patch g++ make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev m4 dos2unix libopenblas-dev git dos2unix
apt-get install -y gcc==7.3.0 cmake==3.12.0
>![](figures/icon-note.gif) **NOTE:**
>If an error occurs during the installation of the GCC and CMake dependency commands, use the source code for installation. For details, see the FAQ.
# Ascend Auxiliary Software
| AscendPyTorch Version| CANN Version| Supported PyTorch Version| Gitee Branch|
| :------------ | :----------- | :----------- | ------------ |
| 2.0.2 | CANN 5.0.2 | 1.5.0.post2 | 2.0.2.tr5 |
| 2.0.3 | CANN 5.0.3 | 1.5.0.post3 | 2.0.3.tr5 |
| 2.0.4 | CANN 5.0.4 | 1.5.0.post4 | 2.0.4.tr5 |
| 3.0.rc1 | CANN 5.1.RC1 | 1.5.0.post5 | v1.5.0-3.0.rc1 |
| 3.0.rc1 | CANN 5.1.RC1 | 1.8.1.rc1 | v1.8.1-3.0.rc1 |
| 3.0.rc2 | CANN 5.1.RC2 | 1.5.0.post6 | v1.5.0-3.0.rc2 |
| 3.0.rc2 | CANN 5.1.RC2 | 1.8.1.rc2 | v1.8.1-3.0.rc2 |
# Installation Methods
## Installing the PyTorch Environment Dependencies
Obtain the PyTorch source code (from the current repository) that adapts to Ascend AI Processors.
```
git clone -b v1.5.0-3.0.rc2 https://gitee.com/ascend/pytorch.git
```
## Obtaining the Native PyTorch Source Code and Third-Party Code
Obtain the native PyTorch 1.5.0 source code from the root directory **/pytorch** of the current repository. Check whether there are fixed security-related issues in the Security and Issues categories in the PyTorch native repository. Update the native PyTorch code if there are any fixes.
```sh
cd pytorch
git clone -b v1.5.0 --depth=1 https://github.com/pytorch/pytorch.git
```
Go to the **pytorch/pytorch/** directory and obtain the passive dependency code of PyTorch. It takes a long time to obtain the code.
```sh
cd pytorch
git submodule sync
git submodule update --init --recursive
```
If no error is reported, the PyTorch and third-party code on which PyTorch depends is generated.
## Generating Full PyTorch Code That Adapts to Ascend AI Processors
Go to the **pytorch/scripts** directory and run the script of the selected version. (Note: The downloaded native PyTorch source code must match the following version. Otherwise, an error may occur.)
```sh
cd ../scripts/
bash gen.sh
```
The full code adapted to the NPU is generated in the **pytorch/pytorch/** directory.
## Installing the Python Dependency Library
Go to the **pytorch/pytorch/** directory and install the Python dependency library.
```python3
cd ../pytorch
pip3 install -r requirements.txt
```
## Compiling Torch Binary Package
In the **pytorch/pytorch/** directory, run the following command:
```sh
# Python 3.7
bash build.sh
or
bash build.sh --python=3.7 (recommended)
# Python 3.8
bash build.sh --python=3.8
```
The generated binary package is in the **pytorch/pytorch/dist/** directory.
## Installing PyTorch
**x86_64:**
**torch-1.5.0+ascend-cp37-cp37m-linux_x86_64.whl** (The actual name may contain the minor version number, for example, **torch-1.5.0.post2+ascend-cp37-cp37m-linux_x86_64.whl**.)
```shell
cd dist
pip3 uninstall torch
pip3 install --upgrade torch-1.5.0+ascend-cp37-cp37m-linux_x86_64.whl
```
**arm:**
**torch-1.5.0+ascend-cp37-cp37m-linux_aarch64.whl** (The actual name may contain the minor version number, for example, **torch-1.5.0.post2+ascend-cp37-cp37m-linux_aarch64.whl**.)
```shell
cd dist
pip3 uninstall torch
pip3 install --upgrade torch-1.5.0+ascend-cp37-cp37m-linux_aarch64.whl
```
# Running
## Executing Environment Variables
Run the script for setting environment variables in the **pytorch/pytorch/** directory.
```
cd ../
source env.sh
```
The following are optional environment variables that may affect running models:
```
export COMBINED_ENABLE=1 # (Optional) Discontinuous-to-continuous level-2 derivation optimization. To enable this function, set the value to **1**. When a large number of time-consuming AsStrided operators are called in the model, you can enable this function to improve the device execution efficiency.
export ACL_DUMP_DATA=1 # (Optional) Operator data dump function, which is used for debugging. To enable this function, set the value to **1**.
export TASK_QUEUE_ENABLE=1 # Delivered by an asynchronous task to asynchronously call the ACL interface. You are advised to enable this environment variable and set its value to **1**.
```
If the system is openEuler or its inherited OS, such as UOS, run the following command to cancel CPU core binding.
```
# unset GOMP_CPU_AFFINITY
```
**Table 1** Description of environment variables
<a name="zh-cn_topic_0000001152616261_table42017516135"></a>
<table><thead align="left"><tr id="zh-cn_topic_0000001152616261_row16198951191317"><th class="cellrowborder" valign="top" width="55.48%" id="mcps1.2.3.1.1"><p id="zh-cn_topic_0000001152616261_p51981251161315"><a name="zh-cn_topic_0000001152616261_p51981251161315"></a><a name="zh-cn_topic_0000001152616261_p51981251161315"></a>Environment Variable</p>
</th>
<th class="cellrowborder" valign="top" width="44.519999999999996%" id="mcps1.2.3.1.2"><p id="zh-cn_topic_0000001152616261_p9198135114133"><a name="zh-cn_topic_0000001152616261_p9198135114133"></a><a name="zh-cn_topic_0000001152616261_p9198135114133"></a>Description</p>
</td>
</tr>
<tr id="row78312162301"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="p1832171673019"><a name="p1832171673019"></a><a name="p1832171673019"></a>COMBINED_ENABLE</p>
</td>
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="p583261643014"><a name="p583261643014"></a><a name="p583261643014"></a>(Optional) Discontinuous-to-continuous level-2 derivation optimization. To enable this function, set the value to **1**. When a large number of time-consuming AsStrided operators are called in the model, you can enable this function to improve the device execution efficiency.</p>
</td>
</tr>
<tr id="row183041355123411"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="p730435533415"><a name="p730435533415"></a><a name="p730435533415"></a>ACL_DUMP_DATA</p>
</td>
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="p16304105533412"><a name="p16304105533412"></a><a name="p16304105533412"></a>(Optional) Operator data dump function, which is used for debugging. To enable this function, set the value to **1**.</p>
</td>
</tr>
<tr id="row19173161510309"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001152616261_p16711563237"><a name="zh-cn_topic_0000001152616261_p16711563237"></a><a name="zh-cn_topic_0000001152616261_p16711563237"></a>TASK_QUEUE_ENABLE</p>
</td>
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001152616261_p0711356152317"><a name="zh-cn_topic_0000001152616261_p0711356152317"></a><a name="zh-cn_topic_0000001152616261_p0711356152317"></a>(Optional) Use asynchronous task delivery to asynchronously invoke the ACL interface. To enable this function, set it to **1** (recommended default setting).</p>
</td>
</tbody>
</table>
## Running the Unit Test Script
Verify the running. The output is **OK**.
```shell
// Select a test script that matches the preceding version. The following uses the 1.5.0 version as an example.
cd ../
python3 pytorch1.5.0/test/test_npu/test_network_ops/test_div.py
```
# (Optional) Installing the Mixed Precision Module
Select the APEX module based on the following functions. For details about how to build and install the APEX module, see the [README.en](https://gitee.com/ascend/apex/tree/v1.5.0-3.0.rc2).
- APEX
- O1 configuration mode: Conv and Matmul use the float16 precision for computing, and Softmax and BN use float32.
- O2 configuration mode: BN uses the float32 precision for computing, and others use float16.
- Static loss scale: Parameters are statically set to ensure the convergence of training with mixed precision.
- Dynamic loss scale: The loss scale value is dynamically calculated to determine whether overflow occurs.
# Documents
For more details about the installation guide, model porting and training/inference tutorials, and API list, see [User Documents](https://gitee.com/ascend/pytorch/tree/master/docs/en).
# Suggestions and Communication
We sincerely welcome you to join discussions in the community and contribute your suggestions. We will reply to you as soon as possible.
# Branch Maintenance Policies
The version branches of AscendPyTorch have the following maintenance phases:
| **Status** | **Duration** | **Description** |
|-------------|---------------|--------------------------------------------------|
| Planning | 1 - 3 months | Plan features. |
| Development | 3 months | Develop features. |
| Maintained | 6 - 12 months | Allow the incorporation of all resolved issues and release the version.|
| Unmaintained| 0 - 3 months | Allow the incorporation of all resolved issues. No dedicated maintenance personnel are available. No version will be released. |
| End Of Life (EOL) | N/A | Do not accept any modification to a branch. |
# Maintenance Status of Existing Branches
| **Branch Name**| **Status** | **Launch Date** | **Subsequent Status** | **EOL Date**|
|------------|--------------|----------------------|----------------------------------------|------------|
| **v2.0.2** | Maintained | 2021-07-29 | Unmaintained <br> 2022-07-29 estimated | |
| **v2.0.3** | Maintained | 2021-10-15 | Unmaintained <br> 2022-10-15 estimated | |
| **v2.0.4** | Maintained | 2022-01-15 | Unmaintained <br> 2023-01-15 estimated | |
| **v3.0.rc1** | Maintained | 2022-04-10 | Unmaintained <br> 2023-04-10 estimated | |
| **v3.0.rc2** | Maintained | 2022-07-15 | Unmaintained <br> 2023-07-15 estimated | |
# FAQ
## When PIP is set to the Huawei source, a Python environment error occurs after the typing dependency in the **requirements.txt** file is installed.
When PIP is set to the Huawei source, open the **requirements.txt** file, delete the typing dependency, and then run the following command:
```
pip3 install -r requirments.txt
```
## The **libhccl.so** cannot be found by **import torch**.
Environment variables are not configured. You need to configure them using the **env.sh** script.
```
source pytorch/pytorch1.5.0/src/env.sh
```
## The error message "no module named yaml/typing_extensions." is displayed when **bash build.sh** is run during compilation.
PyTorch compilation depends on the YAML and typing_extensions libraries, which need to be manually installed.
```
pip3 install pyyaml
pip3 install typing_extensions
```
After the installation is successful, run **make clean** and then **bash build.sh** to perform compilation. Otherwise, an unknown compilation error may occur due to the cache.
## TE cannot be found during running.
Development state:
```
cd /urs/local/Ascend/ascend-toolkit/latest/{arch}-linux/lib64 # {arch} indicates the architecture name.
pip3 install --upgrade topi-0.4.0-py3-none-any.whl
pip3 install --upgrade te-0.4.0-py3-none-any.whl
```
User state:
```
cd /urs/local/Ascend/nnae/latest/{arch}-linux/lib64 # {arch} indicates the architecture name.
pip3 install --upgrade topi-0.4.0-py3-none-any.whl
pip3 install --upgrade te-0.4.0-py3-none-any.whl
```
## During CMake installation through the CLI, an error is reported indicating that the package cannot be found. During CMake compilation, another error is reported indicating that the version is too early. In this cause, you can use the installation script or source code to compile and install CMake.
Method 1: Download the installation script and install CMake. (For details, see the CMake official website.)
​ x86_64 environment: cmake-3.12.0-Linux-x86_64.sh
​ AArch64 environment: cmake-3.12.0-Linux-aarch64.sh
1. Run the following commands:
```
./cmake-3.12.0-Linux-{arch}.sh #{arch} indicates the architecture name.
```
2. Set the soft link.
```
ln -s /usr/local/cmake/bin/cmake /usr/bin/cmake
```
3. Run the following command to check whether CMake has been installed:
```
cmake --version
```
If the message "cmake version 3.12.0" is displayed, the installation is successful.
Method 2: Use the source code to compile and install.
1. Obtain the CMake software package.
```
wget https://cmake.org/files/v3.12/cmake-3.12.0.tar.gz --no-check-certificate
```
2. Decompress the package and go to the software package directory.
```
tar -xf cmake-3.12.0.tar.gz
cd cmake-3.12.0/
```
3. Run the configuration, compilation, and installation commands.
```
./configure --prefix=/usr/local/cmake
make && make install
```
4. Set the soft link.
```
ln -s /usr/local/cmake/bin/cmake /usr/bin/cmake
```
5. Run the following command to check whether CMake has been installed:
```
cmake --version
```
If the message "cmake version 3.12.0" is displayed, the installation is successful.
## During GCC installation through the CLI, an error is reported indicating that the package cannot be found. During GCC compilation, another error is reported.
When downloading GCC from some sources, you may be prompted by an error message indicating that the package cannot be found. In this case, use the source code to compile and install GCC.
Perform the following steps as the **root** user.
1. Download **gcc-7.3.0.tar.gz** from [https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz](https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz).
2. GCC installation requires adequate temporary space. Run the following command to clear the **/tmp** directory in advance:
```
sudo rm -rf /tmp/*
```
3. Install the dependency package. (CentOS and Ubuntu are used as examples.)
- For CentOS, run the following command:
```
yum install bzip2
```
- For Ubuntu, run the following command:
```
apt-get install bzip2
```
4. Compile and install GCC.
1. Go to the directory where the source package **gcc-7.3.0.tar.gz** is located and run the following command to decompress it:
```
tar -zxvf gcc-7.3.0.tar.gz
```
2. Go to the extracted directory and download the GCC dependency packages:
```
cd gcc-7.3.0
./contrib/download_prerequisites
```
If an error is reported during the command execution, run the following commands in the **gcc-7.3.0/** directory to download the dependency packages:
```
wget http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2
wget http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2
wget http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz
wget http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.16.1.tar.bz2
```
After the preceding dependencies are downloaded, run the following command again:
```
./contrib/download_prerequisites
```
If the verification fails, check whether there are duplicate dependency packages in the folder. If yes, delete duplicate ones.
3. <a name="zh-cn_topic_0000001135347812_zh-cn_topic_0000001173199577_zh-cn_topic_0000001172534867_zh-cn_topic_0276688294_li1649343041310"></a>Run the configuration, compilation, and installation commands.
```
./configure --enable-languages=c,c++ --disable-multilib --with-system-zlib --prefix=/usr/local/linux_gcc7.3.0
make -j15 # Check the number of CPUs by running **grep -w processor /proc/cpuinfo|wc -l**. In this example, the number is 15. You can set the parameters as required.
make install
```
> ![img](figures/icon-notice.gif) **NOTE:**
>The **--prefix** option is used to specify the **linux_gcc7.3.0** installation path, which is configurable. Do not set it to **/usr/local** or **/usr,** which is the default installation path for the GCC installed by using the software source. Otherwise, a conflict occurs and the original GCC compilation environment of the system is damaged. In this example, the installation path is set to **/usr/local/linux_gcc7.3.0**.
4. Change the soft links.
```
ln -s ${install_path}/bin/gcc /usr/bin/gcc
ln -s ${install_path}/bin/g++ /usr/bin/g++
ln -s ${install_path}/bin/c++ /usr/bin/c++
```
5. Configure environment variables.
Training must be performed in the compilation environment with GCC upgraded. If you want to run training, configure the following environment variable in your training script:
```
export LD_LIBRARY_PATH=${install_path}/lib64:${LD_LIBRARY_PATH}
```
**${install_path}** indicates the GCC 7.3.0 installation path configured in [3.](#zh-cn_topic_0000001135347812_zh-cn_topic_0000001173199577_zh-cn_topic_0000001172534867_zh-cn_topic_0276688294_li1649343041310). In this example, the GCC 7.3.0 installation path is **/usr/local/linux_gcc7.3.0/**.
>![](figures/icon-note.gif) **NOTE:**
>Skip this step if you do not need to use the compilation environment with GCC upgraded.
If the PyTorch compilation fails, check whether the soft link library is correct.
libstdc++->libstdc++.so.6.0.24(7.3.0)
## libblas.so cannot be found.
The OpenBLAS library is missing in the environment. You need to install it.
CentOS and EulerOS
```sh
yum -y install openblas
```
Ubuntu
```sh
apt install libopenblas-dev
```
## torchvision fails to be installed using pip in the Arm environment.
The source code can be used for installation. (You need to install the AscendPyTorch first and configure environment variables using **env.sh**.)
```
git clone -b v0.6.0 https://github.com/pytorch/vision.git
cd vision
python setup.py install
```
Verify that the torchvision is successfully installed.
```
python -c "import torchvision"
```
If no error is reported, the installation is successful.
# Release Notes
For details, see [Release Notes](docs/en/RELEASENOTE).
-267
View File
@@ -1,267 +0,0 @@
# Ascend Extension for PyTorch
## Overview
This repository develops the **Ascend Extension for PyTorch** named **torch_npu** to adapt **Ascend NPU** to **PyTorch** so that developers who use the **PyTorch** can obtain powerful compute capabilities of **Ascend AI Processors**.
Ascend is a full-stack AI computing infrastructure for industry applications and services based on Huawei Ascend processors and software. For more information about Ascend, see [Ascend Community](https://www.hiascend.com/en/).
## Installation
### From Binary
Provide users with wheel package to quickly install **torch_npu**. Before installing **torch_npu**, complete the installation of **CANN** according to [Ascend Auxiliary Software](#ascend-auxiliary-software). To obtain the **CANN** installation package, refer to the [CANN Installation](https://www.hiascend.com/en/software/cann/community).
1. **Install PyTorch**
Install **PyTorch** through pip.
**For Aarch64:**
```Shell
pip3 install torch==2.3.1
```
**For x86:**
```Shell
pip3 install torch==2.3.1+cpu --index-url https://download.pytorch.org/whl/cpu
```
2. **Install torch-npu dependencies**
Run the following command to install dependencies.
```Shell
pip3 install pyyaml
pip3 install setuptools
```
If the installation fails, use the download link or visit the [PyTorch official website](https://pytorch.org/) to download the installation package of the corresponding version.
| OS arch | Python version | link |
|---------|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| x86 | Python3.8 | [link](https://download.pytorch.org/whl/cpu/torch-2.3.1%2Bcpu-cp38-cp38-linux_x86_64.whl#sha256=cab92d5101e6db686c5525e04d87cedbcf3a556073d71d07fbe7d1ce09630ffb) |
| x86 | Python3.9 | [link](https://download.pytorch.org/whl/cpu/torch-2.3.1%2Bcpu-cp39-cp39-linux_x86_64.whl#sha256=a3cb8e61ba311cee1bb7463cbdcf3ebdfd071e2091e74c5785e3687eb02819f9) |
| x86 | Python3.10 | [link](https://download.pytorch.org/whl/cpu/torch-2.3.1%2Bcpu-cp310-cp310-linux_x86_64.whl#sha256=d679e21d871982b9234444331a26350902cfd2d5ca44ce6f49896af8b3a3087d) |
| x86 | Python3.11 | [link](https://download.pytorch.org/whl/cpu/torch-2.3.1%2Bcpu-cp311-cp311-linux_x86_64.whl#sha256=a272defe305dbd944aa28a91cc3db0f0149495b3ebec2e39723a7224fa05dc57) |
| aarch64 | Python3.8 | [link](https://download.pytorch.org/whl/cpu/torch-2.3.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=3b7c1498f904f67eb1e331f2ebe8742771a2ce71b9ee9bc01de967257e881c7d) |
| aarch64 | Python3.9 | [link](https://download.pytorch.org/whl/cpu/torch-2.3.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=db6bff4ba6273b59ae443de04b5adc36d6a40bb2898866133bff2d52f276eafe) |
| aarch64 | Python3.10 | [link](https://download.pytorch.org/whl/cpu/torch-2.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=6544fdf29018668c0a6d4a1bcc955982c1ada70806281b010cba93bdcfbdcf22) |
| aarch64 | Python3.11 | [link](https://download.pytorch.org/whl/cpu/torch-2.3.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=2aaf0e37734cbc5fe6bfcc81ada36ecbb899d4ddbe13498bd84aaca8a91c8628) |
3. **Install torch-npu**
```
pip3 install torch-npu==2.3.1.post6
```
### From Source
In some special scenarios, users may need to compile **torch-npu** by themselves.Select a branch in table [Ascend Auxiliary Software](#ascend-auxiliary-software) and a Python version in table [PyTorch and Python Version Matching Table](#pytorch-and-python-version-matching-table) first. The docker image is recommended for compiling torch-npu through the following steps(It is recommended to mount the working path only and avoid the system path to reduce security risks.), the generated .whl file path is ./dist/. Note that gcc version has the following constraints if you try to compile without using docker image: we recommend to use gcc 10.2 for ARM and gcc 9.3.1 for X86.
1. **Clone torch-npu**
```
git clone https://github.com/ascend/pytorch.git -b v2.3.1-7.0.0 --depth 1
```
2. **Build Docker Image**
```
cd pytorch/ci/docker/{arch} # {arch} for X86 or ARM
docker build -t manylinux-builder:v1 .
```
3. **Enter Docker Container**
```
docker run -it -v /{code_path}/pytorch:/home/pytorch manylinux-builder:v1 bash
# {code_path} is the torch_npu source code path
```
4. **Compile torch-npu**
Take **Python 3.8** as an example.
```
cd /home/pytorch
bash ci/build.sh --python=3.8
```
**Tips**
If you would like to compile with new C++ ABI, then first run this command, at this point, the recommended compilation environment is same to community torch package: glibc 2.28, gcc 11.2.1
```
export _GLIBCXX_USE_CXX11_ABI=1
```
Meanwhile, we support configuring -fabi-version using the following variables,require consistency with the community torch package
```
export _ABI_VERSION=16
```
## Getting Started
### Prerequisites
Initialize **CANN** environment variable by running the command as shown below.
```Shell
# Default path, change it if needed.
source /usr/local/Ascend/ascend-toolkit/set_env.sh
```
### Quick Verification
You can quickly experience **Ascend NPU** by the following simple examples.
```Python
import torch
import torch_npu
x = torch.randn(2, 2).npu()
y = torch.randn(2, 2).npu()
z = x.mm(y)
print(z)
```
## User Manual
Refer to [API of Ascend Extension for PyTorch](docs/api/torch_npu_apis.md) for more detailed informations.
## PyTorch and Python Version Matching Table
| PyTorch Version | Python Version |
|-----------------|:----------------------------------------------------------|
| PyTorch1.11.0 | Python3.7.x(>=3.7.5),Python3.8.x,Python3.9.x,Python3.10.x |
| PyTorch2.1.0 | Python3.8.x,Python3.9.x,Python3.10.x,Python3.11.x |
| PyTorch2.2.0 | Python3.8.x,Python3.9.x,Python3.10.x |
| PyTorch2.3.1 | Python3.8.x,Python3.9.x,Python3.10.x,Python3.11.x |
| PyTorch2.4.0 | Python3.8.x,Python3.9.x,Python3.10.x,Python3.11.x |
| PyTorch2.5.1 | Python3.9.x,Python3.10.x,Python3.11.x |
## Ascend Auxiliary Software
**PyTorch Extension** versions follow the naming convention `{PyTorch version}-{Ascend version}`, where the former represents the PyTorch version compatible with the **PyTorch Extension**, and the latter is used to match the CANN version. The detailed matching is as follows:
| CANN Version | Supported PyTorch Version | Supported Extension Version | Github Branch |
|-----------------------|---------------------------|-----------------------------|-------------------|
| CANN 8.1.RC1 | 2.5.1 | 2.5.1 | v2.5.1-7.0.0 |
| | 2.4.0 | 2.4.0.post4 | v2.4.0-7.0.0 |
| | 2.3.1 | 2.3.1.post6 | v2.3.1-7.0.0 |
| | 2.1.0 | 2.1.0.post12 | v2.1.0-7.0.0 |
| CANN 8.0.0 | 2.4.0 | 2.4.0.post2 | v2.4.0-6.0.0 |
| | 2.3.1 | 2.3.1.post4 | v2.3.1-6.0.0 |
| | 2.1.0 | 2.1.0.post10 | v2.1.0-6.0.0 |
| CANN 8.0.RC3 | 2.4.0 | 2.4.0 | v2.4.0-6.0.rc3 |
| | 2.3.1 | 2.3.1.post2 | v2.3.1-6.0.rc3 |
| | 2.1.0 | 2.1.0.post8 | v2.1.0-6.0.rc3 |
| CANN 8.0.RC2 | 2.3.1 | 2.3.1 | v2.3.1-6.0.rc2 |
| | 2.2.0 | 2.2.0.post2 | v2.2.0-6.0.rc2 |
| | 2.1.0 | 2.1.0.post6 | v2.1.0-6.0.rc2 |
| | 1.11.0 | 1.11.0.post14 | v1.11.0-6.0.rc2 |
| CANN 8.0.RC1 | 2.2.0 | 2.2.0 | v2.2.0-6.0.rc1 |
| | 2.1.0 | 2.1.0.post4 | v2.1.0-6.0.rc1 |
| | 1.11.0 | 1.11.0.post11 | v1.11.0-6.0.rc1 |
| CANN 7.0.0 | 2.1.0 | 2.1.0 | v2.1.0-5.0.0 |
| | 2.0.1 | 2.0.1.post1 | v2.0.1-5.0.0 |
| | 1.11.0 | 1.11.0.post8 | v1.11.0-5.0.0 |
| CANN 7.0.RC1 | 2.1.0 | 2.1.0.rc1 | v2.1.0-5.0.rc3 |
| | 2.0.1 | 2.0.1 | v2.0.1-5.0.rc3 |
| | 1.11.0 | 1.11.0.post4 | v1.11.0-5.0.rc3 |
| CANN 6.3.RC3.1 | 1.11.0 | 1.11.0.post3 | v1.11.0-5.0.rc2.2 |
| CANN 6.3.RC3 | 1.11.0 | 1.11.0.post2 | v1.11.0-5.0.rc2.1 |
| CANN 6.3.RC2 | 2.0.1 | 2.0.1.rc1 | v2.0.1-5.0.rc2 |
| | 1.11.0 | 1.11.0.post1 | v1.11.0-5.0.rc2 |
| | 1.8.1 | 1.8.1.post2 | v1.8.1-5.0.rc2 |
| CANN 6.3.RC1 | 1.11.0 | 1.11.0 | v1.11.0-5.0.rc1 |
| | 1.8.1 | 1.8.1.post1 | v1.8.1-5.0.rc1 |
| CANN 6.0.1 | 1.5.0 | 1.5.0.post8 | v1.5.0-3.0.0 |
| | 1.8.1 | 1.8.1 | v1.8.1-3.0.0 |
| | 1.11.0 | 1.11.0.rc2(beta) | v1.11.0-3.0.0 |
| CANN 6.0.RC1 | 1.5.0 | 1.5.0.post7 | v1.5.0-3.0.rc3 |
| | 1.8.1 | 1.8.1.rc3 | v1.8.1-3.0.rc3 |
| | 1.11.0 | 1.11.0.rc1(beta) | v1.11.0-3.0.rc3 |
| CANN 5.1.RC2 | 1.5.0 | 1.5.0.post6 | v1.5.0-3.0.rc2 |
| | 1.8.1 | 1.8.1.rc2 | v1.8.1-3.0.rc2 |
| CANN 5.1.RC1 | 1.5.0 | 1.5.0.post5 | v1.5.0-3.0.rc1 |
| | 1.8.1 | 1.8.1.rc1 | v1.8.1-3.0.rc1 |
| CANN 5.0.4 | 1.5.0 | 1.5.0.post4 | 2.0.4.tr5 |
| CANN 5.0.3 | 1.8.1 | 1.5.0.post3 | 2.0.3.tr5 |
| CANN 5.0.2 | 1.5.0 | 1.5.0.post2 | 2.0.2.tr5 |
## Hardware support
The Ascend training device includes the following models, all of which can be used as training environments for PyTorch models
| Product series | Product model |
|-----------------------|----------------------------------|
| Atlas Training series products | Atlas 800(model: 9000) |
| | Atlas 800(model:9010) |
| | Atlas 900 PoD(model:9000) |
| | Atlas 300T(model:9000) |
| | Atlas 300T Pro(model:9000) |
| Atlas A2 Training series products | Atlas 800T A2 |
| | Atlas 900 A2 PoD |
| | Atlas 200T A2 Box16 |
| | Atlas 300T A2 |
The Ascend inference device includes the following models, all of which can be used as inference environments for large models
| Product series | Product model |
|-----------------------|----------------------------------|
| Atlas 800I A2 Inference product | Atlas 800I A2 |
## Pipeline Status
Due to the asynchronous development mechanism of upstream and downstream, incompatible modifications in upstream may cause some functions of **torch_npu** to be unavailable (only upstream and downstream development branches are involved, excluding stable branches). Therefore, we built a set of daily tasks that make it easy to detect relevant issues in time and fix them within 48 hours (under normal circumstances), providing users with the latest features and stable quality.
| **OS** | **CANN Version(Docker Image)** | **Upstream Branch** | **Downstream Branch** | **Period** | **Status** |
|:-------------------:|:-------------------------------------------------------:|:----------------------------------------------------:|:-------------------------------------------------------:|:--------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| openEuler 22.03 SP2 | [CANN 7.1](https://hub.docker.com/r/ascendai/cann/tags) | [main](https://github.com/pytorch/pytorch/tree/main) | [master](https://github.com/Ascend/pytorch/tree/master) | UTC 1200 daily | [![Ascend NPU](https://github.com/Ascend/pytorch/actions/workflows/periodic.yml/badge.svg)](https://github.com/Ascend/pytorch/actions/workflows/periodic.yml) |
## Suggestions and Communication
Everyone is welcome to contribute to the community. If you have any questions or suggestions, you can submit [Github Issues](https://github.com/Ascend/pytorch/issues). We will reply to you as soon as possible. Thank you very much.
## Branch Maintenance Policies
The version branches of AscendPyTorch have the following maintenance phases:
| **Status** | **Duration** | **Description** |
|-------------------|--------------|--------------------------------------------------------------------------------------------------------------------------------|
| Planning | 1-3 months | Plan features. |
| Development | 6-12 months | Develop new features and fix issues, regularly release new versions. Different strategies are adopted for different versions of PyTorch, with a regular branch development cycle of 6 months and a long-term support branch development cycle of 12 months. |
| Maintained | 1 year/3.5 years | Regular Release branch for 1 year, Long Term Support branch maintenance for 3.5 years. Fix major issues, do not incorporate new features, and release patch versions based on the impact of fixed bugs. |
| End Of Life (EOL) | N/A | Do not accept any modification to a branch. |
## PyTorch Maintenance Policies
| **PyTorch** | **Maintenance Policies** | **Status** | **Launch Date** | **Subsequent Status** | **EOL Date** |
|-------------|--------------------------|-------------|-----------------|-------------------------------------------------------------------|--------------|
| 2.5.1 | Regular Release | Development | 2024/11/08 | Expected to enter maintenance status from April 8, 2025 | |
| 2.4.0 | Regular Release | Development | 2024/10/15 | Expected to enter maintenance status from June 15, 2025 | |
| 2.3.1 | Regular Release | Development | 2024/06/06 | Expected to enter maintenance status from June 7, 2025 | |
| 2.2.0 | Regular Release | Maintained | 2024/04/01 | Expected to enter maintenance free status from September 10, 2025 | |
| 2.1.0 | Long Term Support | Development | 2023/10/15 | Expected to enter maintenance status from September 15, 2025 | |
| 2.0.1 | Regular Release | EOL | 2023/7/19 | | 2024/3/14 |
| 1.11.0 | Long Term Support | Maintained | 2023/4/19 | Expected to enter maintenance free status from September 10, 2025 | |
| 1.8.1 | Long Term Support | EOL | 2022/4/10 | | 2023/4/10 |
| 1.5.0 | Long Term Support | EOL | 2021/7/29 | | 2022/7/29 |
## Reference Documents
For more detailed information on installation guides, model migration, training/inference tutorials, and API lists, please refer to the [Ascend Extension for PyTorch on the HiAI Community](https://www.hiascend.com/software/ai-frameworks?framework=pytorch).
| Document Name | Document Link |
|------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|
| Installation Guide | [link](https://www.hiascend.com/document/detail/zh/Pytorch/60RC3/configandinstg/instg/insg_0001.html) |
| Network Model Migration and Training | [link](https://www.hiascend.com/document/detail/zh/Pytorch/60RC3/ptmoddevg/trainingmigrguide/PT_LMTMOG_0003.html) |
| Operator Adaptation | [link](https://www.hiascend.com/document/detail/zh/canncommercial/80RC3/operatordev/tbeaicpudevg/atlasopdev_10_0086.html) |
| API List (PyTorch and Custom Interfaces) | [link](https://www.hiascend.com/document/detail/zh/Pytorch/60RC3/apiref/apilist/ptaoplist_000002.html) |
## License
Ascend Extension for PyTorch has a BSD-style license, as found in the [LICENSE](LICENSE) file.
+492 -229
View File
@@ -1,273 +1,536 @@
# Ascend Extension for PyTorch插件
# AscendPyTorch
## 简介
本项目开发了名为**torch_npu**的**Ascend Extension for PyTorch**插件,使昇腾NPU可以适配PyTorch框架,为使用PyTorch框架的开发者提供昇腾AI处理器的超强算力。
<h1 id="简介md">简介</h1>
本项目开发了PyTorch Adapter插件,用于昇腾适配PyTorch框架,为使用PyTorch框架的开发者提供昇腾AI处理器的超强算力。用户在准备相关环境进行基于PyTorch框架模型的开发、运行时,可以选择在服务器中手动编译安装PyTorch框架相关模块。
昇腾为基于华为昇腾处理器和软件的行业应用及服务提供全栈AI计算基础设施。您可以通过访问[昇腾社区](https://www.hiascend.com/zh/),了解关于昇腾的更多信息。
<h3 id="前提条件md">前提条件</h3>
## 安装
- 需完成CANN开发或运行环境的安装,具体操作请参考《CANN 软件安装指南》。
- Python支持版本:3.7.5、3.8。
### 使用二进制文件进行安装
# 系统依赖库
我们为用户提供可以快速安装**torch_npu**的whl安装包。在安装**torch_npu**之前,您需要先安装**CANN**软件。[昇腾辅助软件](#昇腾辅助软件)中有更多关于CANN的版本信息。请参考[CANN安装指南](https://www.hiascend.com/zh/software/cann/community)获取**CANN**安装包。
## CentOS & EulerOS
1. **安装PyTorch**
yum install -y patch zlib-devel libffi-devel openssl-devel libjpeg-turbo-devel gcc-c++ sqlite-devel dos2unix openblas git dos2unix
通过 pip 安装 PyTorch。
yum install -y gcc==7.3.0 cmake==3.12.0
**aarch64:**
## Ubuntu
```Shell
pip3 install torch==2.3.1
apt-get install -y patch g++ make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev m4 dos2unix libopenblas-dev git dos2unix
apt-get install -y gcc==7.3.0 cmake==3.12.0
>![](figures/icon-note.gif) **说明:**
>若安装gcc与cmake依赖命令报错,请参考FAQ使用源码安装。
# Ascend配套软件
| AscendPyTorch版本 | CANN版本 | 支持PyTorch版本 | Gitee分支名称 |
| :------------ | :----------- | :----------- | ------------ |
| 2.0.2 | CANN 5.0.2 | 1.5.0.post2 | 2.0.2.tr5 |
| 2.0.3 | CANN 5.0.3 | 1.5.0.post3 | 2.0.3.tr5 |
| 2.0.4 | CANN 5.0.4 | 1.5.0.post4 | 2.0.4.tr5 |
| 3.0.rc1 | CANN 5.1.RC1 | 1.5.0.post5 | v1.5.0-3.0.rc1 |
| 3.0.rc1 | CANN 5.1.RC1 | 1.8.1.rc1 | v1.8.1-3.0.rc1 |
| 3.0.rc2 | CANN 5.1.RC2 | 1.5.0.post6 | v1.5.0-3.0.rc2 |
| 3.0.rc2 | CANN 5.1.RC2 | 1.8.1.rc2 | v1.8.1-3.0.rc2 |
| 3.0.rc3 | CANN 6.0.RC1 | 1.5.0.post7 | v1.5.0-3.0.rc3 |
| 3.0.rc3 | CANN 6.0.RC1 | 1.8.1.rc3 | v1.8.1-3.0.rc3 |
| 3.0.rc3 | CANN 6.0.RC1 | 1.11.0.rc1(beta) | v1.11.0-3.0.rc3 | \ |
| 3.0.0 | CANN 6.0.1 | 1.5.0.post8 | v1.5.0-3.0.0 | \ |
| 3.0.0 | CANN 6.0.1 | 1.8.1 | v1.8.1-3.0.0 | \ |
| 3.0.0 | CANN 6.0.1 | 1.11.0.rc2(beta) | v1.11.0-3.0.0 | \ |
# 安装方式
## 安装PyTorch依赖环境
获取适配昇腾AI处理器的PyTorch源代码(即当前仓库代码)。
```
git clone -b v1.5.0 https://gitee.com/ascend/pytorch.git
```
## 获取原生PyTorch源代码和third_party代码
在当前仓库根目录pytorch/下获取原生PyTorch1.5.0的源代码。请关注PyTorch原生社区的安全板块与Issue板块是否有安全相关问题修复,并根据社区修复及时更新原生PyTorch代码。
```sh
cd pytorch
git clone -b v1.5.0 --depth=1 https://github.com/pytorch/pytorch.git
```
**x86:**
进入到pytorch/pytorch/目录下, 获取PyTorch被动依赖代码(获取时间较长,请耐心等待)。
```Shell
pip3 install torch==2.3.1+cpu --index-url https://download.pytorch.org/whl/cpu
```sh
cd pytorch
git submodule sync
git submodule update --init --recursive
```
若使用pip命令安装失败,请使用下载链接或进入[PyTorch官方网站](https://pytorch.org/)进行查询下载对应版本。
完成且没有报错之后就生成了PyTorch及其依赖的三方代码
| 架构 | Python版本 | 下载链接 |
|---------|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| x86 | Python3.8 | [下载链接](https://download.pytorch.org/whl/cpu/torch-2.3.1%2Bcpu-cp38-cp38-linux_x86_64.whl#sha256=cab92d5101e6db686c5525e04d87cedbcf3a556073d71d07fbe7d1ce09630ffb) |
| x86 | Python3.9 | [下载链接](https://download.pytorch.org/whl/cpu/torch-2.3.1%2Bcpu-cp39-cp39-linux_x86_64.whl#sha256=a3cb8e61ba311cee1bb7463cbdcf3ebdfd071e2091e74c5785e3687eb02819f9) |
| x86 | Python3.10 | [下载链接](https://download.pytorch.org/whl/cpu/torch-2.3.1%2Bcpu-cp310-cp310-linux_x86_64.whl#sha256=d679e21d871982b9234444331a26350902cfd2d5ca44ce6f49896af8b3a3087d) |
| x86 | Python3.11 | [下载链接](https://download.pytorch.org/whl/cpu/torch-2.3.1%2Bcpu-cp311-cp311-linux_x86_64.whl#sha256=a272defe305dbd944aa28a91cc3db0f0149495b3ebec2e39723a7224fa05dc57) |
| aarch64 | Python3.8 | [下载链接](https://download.pytorch.org/whl/cpu/torch-2.3.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=3b7c1498f904f67eb1e331f2ebe8742771a2ce71b9ee9bc01de967257e881c7d) |
| aarch64 | Python3.9 | [下载链接](https://download.pytorch.org/whl/cpu/torch-2.3.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=db6bff4ba6273b59ae443de04b5adc36d6a40bb2898866133bff2d52f276eafe) |
| aarch64 | Python3.10 | [下载链接](https://download.pytorch.org/whl/cpu/torch-2.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=6544fdf29018668c0a6d4a1bcc955982c1ada70806281b010cba93bdcfbdcf22) |
| aarch64 | Python3.11 | [下载链接](https://download.pytorch.org/whl/cpu/torch-2.3.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl#sha256=2aaf0e37734cbc5fe6bfcc81ada36ecbb899d4ddbe13498bd84aaca8a91c8628) |
## 生成适配昇腾AI处理器的PyTorch全量代码。
2. **安装torch_npu依赖**
进入到pytorch/scripts目录,根据选择的版本执行,执行脚本(注意:下载原生PyTorch源代码和下面版本要对应,否则可能出错)
运行以下命令安装依赖。
```sh
cd ../scripts/
bash gen.sh
```
```Shell
会在pytorch/pytorch/目录中生成npu适配全量代码
## python依赖库
进入到pytorch/pytorch/目录,依赖库安装:
```python3
cd ../pytorch
pip3 install -r requirements.txt
```
## 编译torch的二进制包
在pytorch/pytorch/目录,执行
```sh
# python3.7版本
bash build.sh
或者
bash build.sh --python=3.7(推荐)
# python3.8版本
bash build.sh --python=3.8
```
生成的二进制包在pytorch/pytorch/dist/目录下
## 安装pytorch
**x86_64:**
torch-1.5.0+ascend-cp37-cp37m-linux_x86_64.whl (实际可能附带小版本号例如torch-1.5.0.post2+ascend-cp37-cp37m-linux_x86_64.whl)
```shell
cd dist
pip3 uninstall torch
pip3 install --upgrade torch-1.5.0+ascend-cp37-cp37m-linux_x86_64.whl
```
**arm:**
torch-1.5.0+ascend-cp37-cp37m-linux_aarch64.whl (实际可能附带小版本号例如torch-1.5.0.post2+ascend-cp37-cp37m-linux_aarch64.whl)
```shell
cd dist
pip3 uninstall torch
pip3 install --upgrade torch-1.5.0+ascend-cp37-cp37m-linux_aarch64.whl
```
# 运行
## 运行环境变量
在pytorch/pytorch/中执行设置环境变量脚本
```
cd ../
source env.sh
```
可选的环境变量可能会对运行的模型产生影响:
```
export COMBINED_ENABLE=1 # 非连续转连续二级推导优化,可选,开启设置为1。当模型中有大量AsStrided高耗时算子被调用时,可以尝试开启此优化以获得潜在的device执行效率的提升
export ACL_DUMP_DATA=1 # 算子数据dump功能,调试时使用,可选,开启设置为1
export TASK_QUEUE_ENABLE=1 # 使用异步任务下发,异步调用acl接口,建议默认开启,开启设置为1
```
当系统为openEuler及其继承操作系统时,如UOS,需设置此命令,取消CPU绑核。
```
# unset GOMP_CPU_AFFINITY
```
**表 1** 环境变量说明
<a name="zh-cn_topic_0000001152616261_table42017516135"></a>
<table><thead align="left"><tr id="zh-cn_topic_0000001152616261_row16198951191317"><th class="cellrowborder" valign="top" width="55.48%" id="mcps1.2.3.1.1"><p id="zh-cn_topic_0000001152616261_p51981251161315"><a name="zh-cn_topic_0000001152616261_p51981251161315"></a><a name="zh-cn_topic_0000001152616261_p51981251161315"></a>配置项</p>
</th>
<th class="cellrowborder" valign="top" width="44.519999999999996%" id="mcps1.2.3.1.2"><p id="zh-cn_topic_0000001152616261_p9198135114133"><a name="zh-cn_topic_0000001152616261_p9198135114133"></a><a name="zh-cn_topic_0000001152616261_p9198135114133"></a>说明</p>
</td>
</tr>
<tr id="row78312162301"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="p1832171673019"><a name="p1832171673019"></a><a name="p1832171673019"></a>COMBINED_ENABLE</p>
</td>
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="p583261643014"><a name="p583261643014"></a><a name="p583261643014"></a>(可选)非连续转连续二级推导优化,可选,开启设置为1。当模型中有大量AsStrided高耗时算子被调用时,可以尝试开启此优化以获得潜在的device执行效率的提升。</p>
</td>
</tr>
<tr id="row183041355123411"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="p730435533415"><a name="p730435533415"></a><a name="p730435533415"></a>ACL_DUMP_DATA</p>
</td>
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="p16304105533412"><a name="p16304105533412"></a><a name="p16304105533412"></a>(可选)算子数据dump功能,调试时使用,开启设置为1。</p>
</td>
</tr>
<tr id="row19173161510309"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001152616261_p16711563237"><a name="zh-cn_topic_0000001152616261_p16711563237"></a><a name="zh-cn_topic_0000001152616261_p16711563237"></a>TASK_QUEUE_ENABLE</p>
</td>
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001152616261_p0711356152317"><a name="zh-cn_topic_0000001152616261_p0711356152317"></a><a name="zh-cn_topic_0000001152616261_p0711356152317"></a>(可选)使用异步任务下发,异步调用acl接口,建议默认开启,开启设置为1。 </p>
</td>
</tbody>
</table>
## 执行单元测试脚本
验证运行, 输出结果OK
```shell
// 根据前述版本,选择对应的测试脚本,以下为1.5.0版本
cd ../
python3 pytorch1.5.0/test/test_npu/test_network_ops/test_div.py
```
# 安装混合精度模块(可选)
请用户根据以下功能需要选择使用,若需要安装Apex模块请参考相关[README文档](https://gitee.com/ascend/apex/tree/v1.5.0)进行编译安装Apex模块。
- APEX
- O1配置模式:Conv,Matmul等使用float16精度计算,其他如softmax、BN使用float32精度。
- O2配置模式:除BN使用float32精度外,其他部分使用float16精度。
- 静态loss scale:静态设置参数确保混合精度训练收敛。
- 动态loss scale:动态计算loss scale的值并判断是否溢出。
# 文档
有关安装指南、模型迁移和训练/推理教程和API列表等更多详细信息,请参考[用户文档](docs/zh)。
# 建议与交流
热忱希望各位在用户社区加入讨论,并贡献您的建议,我们会尽快给您回复。
# 分支维护策略
Ascend PyTorch的版本分支有以下几种维护阶段:
| **状态** | **持续时间** | **说明** |
|-------------|---------------|--------------------------------------------------|
| Planning | 1 - 3 months | 特性规划。 |
| Development | 3 months | 特性开发。 |
| Maintained | 6 - 12 months | 允许所有问题修复的合入,并发布版本。 |
| Unmaintained| 0 - 3 months | 允许所有问题修复的合入,无专人维护,不再发布版本。 |
| End Of Life (EOL) | N/A | 不再接受修改合入该分支。 |
# 现有分支维护状态
| **分支名** | **当前状态** | **上线时间** | **后续状态** | **EOL 日期**|
|------------|--------------|----------------------|----------------------------------------|------------|
| **v2.0.2** | EOL | 2021-07-29 | N/A | |
| **v2.0.3** | EOL | 2021-10-15 | N/A | |
| **v2.0.4** | Unmaintained | 2022-01-15 | EOL <br> 2023-04-15 estimated | |
| **v3.0.rc1** | Maintained | 2022-04-10 | Unmaintained <br> 2023-04-10 estimated | |
| **v3.0.rc2** | Maintained | 2022-07-15 | Unmaintained <br> 2023-07-15 estimated | |
| **v3.0.rc3** | Maintained | 2022-10-20 | Unmaintained <br> 2023-10-20 estimated | |
| **v3.0.0** | Maintained | 2023-1-20 | Unmaintained <br> 2024-1-20 estimated | |
# FAQ
## 在PIP设置为华为源时,安装requirments.txt中的typing依赖后,会导致python环境错误。
在PIP设置为华为源时,需打开requirments.txt文件,删除typing依赖,再执行命令。
```
pip3 install -r requirments.txt
```
## import torch 报找不到libhccl.so错误
未配置环境变量,需通过env.sh脚本配置
```
source pytorch/pytorch1.5.0/src/env.sh
```
## 编译过程执行bash build.sh报错FAILED:confu-deps/XNNPACK/CMakefiles/XNNPACK.dir/src/f32-gemm/gen-inc/4x8inc-minmax-{arch}-neonfma-cortex-a{xx}.S.o
编译前,环境变量默认USE_XNNPACK=1,编译时会报错,需设置重设该环境变量,再次编译。
1. 重设环境变量
```
export USE_XNNPACK=0
```
2. 清除编译缓存
```
make clean
```
3. 重新编译
```
bash build.sh --python={python_version}
```
## 编译过程执行bash build.sh报错no module named yaml/typing_extensions.
pytorch编译依赖 yaml库和typing_extensions库,需要手动安装。
```
pip3 install pyyaml
pip3 install setuptools
pip3 install typing_extensions
```
3. **安装torch_npu**
安装成功后,注意需要执行make clean在执行bash build.sh进行编译,否则可能因缓存出现未知编译错误。
## 运行遇到找不到te问题
开发态:
```
pip3 install torch-npu==2.3.1.post6
```
如需要保存安装日志,可在pip3 install命令后面加上参数 `--log <PATH>`,并对您指定的目录`<PATH>`做好权限管控。
cd /urs/local/Ascend/ascend-toolkit/latest/{arch}-linux/lib64 #{arch}为架构名称。
### 使用源代码进行安装
pip3 install --upgrade topi-0.4.0-py3-none-any.whl
某些特殊场景下,用户可能需要自行编译**torch_npu**。可以根据[昇腾辅助软件表](#昇腾辅助软件)和[PyTorch与Python版本配套表](#PyTorch与Python版本配套表)选择合适的分支。推荐使用Docker镜像编译**torch_npu**,可以通过以下步骤获取(建议只挂载工作路径,并避开系统路径,以降低安全风险), 生成的.whl文件路径为./dist/。如果不使用镜像,编译时请注意gcc版本遵循如下约束:ARM架构下推荐使用gcc 10.2版本, X86架构下推荐使用gcc 9.3.1
1. **克隆torch_npu代码仓**
```
git clone https://gitee.com/ascend/pytorch.git -b v2.3.1-7.0.0 --depth 1
```
2. **构建镜像**
```
cd pytorch/ci/docker/{arch} # {arch} for X86 or ARM
docker build -t manylinux-builder:v1 .
```
3. **进入Docker容器**
```
docker run -it -v /{code_path}/pytorch:/home/pytorch manylinux-builder:v1 bash
# {code_path} is the torch_npu source code path
```
4. **编译torch_npu**
以**Python 3.8** 为例。
```
cd /home/pytorch
bash ci/build.sh --python=3.8
```
**提示**
如果想使用新的C++ ABI编译,请首先运行如下命令,此时推荐和社区torch包相同的编译环境:glibc 2.28, gcc 11.2.1
```
export _GLIBCXX_USE_CXX11_ABI=1
```
同时,我们支持使用如下变量配置-fabi-version,要求和社区torch包ABI版本一致
```
export _ABI_VERSION=16
```
## 卸载
Pytorch框架训练环境的卸载可以参考[昇腾官方文档](https://www.hiascend.com/document/detail/zh/ModelZoo/pytorchframework/ptes/ptes_00032.html)。
torch_npu的卸载只需执行命令:
```
pip3 uninstall torch_npu
```
如需要保存卸载日志,可在pip3 uninstall命令后面加上参数 `--log <PATH>`,并对您指定的目录`<PATH>`做好权限管控。
## 入门
### 前提
运行以下命令初始化**CANN**环境变量。
```Shell
# Default path, change it if needed.
source /usr/local/Ascend/ascend-toolkit/set_env.sh
pip3 install --upgrade te-0.4.0-py3-none-any.whl
```
### 快速验证
用户态:
可以通过以下样例快速体验**昇腾NPU**。
```
cd /urs/local/Ascend/nnae/latest/{arch}-linux/lib64 #{arch}为架构名称
```Python
import torch
import torch_npu
pip3 install --upgrade topi-0.4.0-py3-none-any.whl
x = torch.randn(2, 2).npu()
y = torch.randn(2, 2).npu()
z = x.mm(y)
print(z)
pip3 install --upgrade te-0.4.0-py3-none-any.whl
```
## PyTorch与Python版本配套表
| PyTorch版本 | Python版本 |
|---------------|:-------------------------------------------------------------|
| PyTorch1.11.0 | Python3.7.x(>=3.7.5), Python3.8.x, Python3.9.x, Python3.10.x |
| PyTorch2.1.0 | Python3.8.x, Python3.9.x, Python3.10.x, Python 3.11.x |
| PyTorch2.2.0 | Python3.8.x, Python3.9.x, Python3.10.x |
| PyTorch2.3.1 | Python3.8.x, Python3.9.x, Python3.10.x, Python 3.11.x |
| PyTorch2.4.0 | Python3.8.x, Python3.9.x, Python3.10.x, Python 3.11.x |
| PyTorch2.5.1 | Python3.9.x, Python3.10.x, Python 3.11.x |
## 昇腾辅助软件
**PyTorch Extension**版本号采用`{PyTorch版本}-{昇腾版本}`命名规则,前者为**PyTorch Extension**匹配的PyTorch版本,后者用于匹配CANN版本,详细匹配如下:
| CANN版本 | 支持的PyTorch版本 | 支持的Extension版本 | Gitee分支 |
|-----------------------|--------------|------------------|-------------------|
| CANN 8.1.RC1 | 2.5.1 | 2.5.1 | v2.5.1-7.0.0 |
| | 2.4.0 | 2.4.0.post4 | v2.4.0-7.0.0 |
| | 2.3.1 | 2.3.1.post6 | v2.3.1-7.0.0 |
| | 2.1.0 | 2.1.0.post12 | v2.1.0-7.0.0 |
| CANN 8.0.0 | 2.4.0 | 2.4.0.post2 | v2.4.0-6.0.0 |
| | 2.3.1 | 2.3.1.post4 | v2.3.1-6.0.0 |
| | 2.1.0 | 2.1.0.post10 | v2.1.0-6.0.0 |
| CANN 8.0.RC3 | 2.4.0 | 2.4.0 | v2.4.0-6.0.rc3 |
| | 2.3.1 | 2.3.1.post2 | v2.3.1-6.0.rc3 |
| | 2.1.0 | 2.1.0.post8 | v2.1.0-6.0.rc3 |
| CANN 8.0.RC2 | 2.3.1 | 2.3.1 | v2.3.1-6.0.rc2 |
| | 2.2.0 | 2.2.0.post2 | v2.2.0-6.0.rc2 |
| | 2.1.0 | 2.1.0.post6 | v2.1.0-6.0.rc2 |
| | 1.11.0 | 1.11.0.post14 | v1.11.0-6.0.rc2 |
| CANN 8.0.RC1 | 2.2.0 | 2.2.0 | v2.2.0-6.0.rc1 |
| | 2.1.0 | 2.1.0.post4 | v2.1.0-6.0.rc1 |
| | 1.11.0 | 1.11.0.post11 | v1.11.0-6.0.rc1 |
| CANN 7.0.0 | 2.1.0 | 2.1.0 | v2.1.0-5.0.0 |
| | 2.0.1 | 2.0.1.post1 | v2.0.1-5.0.0 |
| | 1.11.0 | 1.11.0.post8 | v1.11.0-5.0.0 |
| CANN 7.0.RC1 | 2.1.0 | 2.1.0.rc1 | v2.1.0-5.0.rc3 |
| | 2.0.1 | 2.0.1 | v2.0.1-5.0.rc3 |
| | 1.11.0 | 1.11.0.post4 | v1.11.0-5.0.rc3 |
| CANN 6.3.RC3.1 | 1.11.0 | 1.11.0.post3 | v1.11.0-5.0.rc2.2 |
| CANN 6.3.RC3 | 1.11.0 | 1.11.0.post2 | v1.11.0-5.0.rc2.1 |
| CANN 6.3.RC2 | 2.0.1 | 2.0.1.rc1 | v2.0.1-5.0.rc2 |
| | 1.11.0 | 1.11.0.post1 | v1.11.0-5.0.rc2 |
| | 1.8.1 | 1.8.1.post2 | v1.8.1-5.0.rc2 |
| CANN 6.3.RC1 | 1.11.0 | 1.11.0 | v1.11.0-5.0.rc1 |
| | 1.8.1 | 1.8.1.post1 | v1.8.1-5.0.rc1 |
| CANN 6.0.1 | 1.5.0 | 1.5.0.post8 | v1.5.0-3.0.0 |
| | 1.8.1 | 1.8.1 | v1.8.1-3.0.0 |
| | 1.11.0 | 1.11.0.rc2(beta) | v1.11.0-3.0.0 |
| CANN 6.0.RC1 | 1.5.0 | 1.5.0.post7 | v1.5.0-3.0.rc3 |
| | 1.8.1 | 1.8.1.rc3 | v1.8.1-3.0.rc3 |
| | 1.11.0 | 1.11.0.rc1(beta) | v1.11.0-3.0.rc3 |
| CANN 5.1.RC2 | 1.5.0 | 1.5.0.post6 | v1.5.0-3.0.rc2 |
| | 1.8.1 | 1.8.1.rc2 | v1.8.1-3.0.rc2 |
| CANN 5.1.RC1 | 1.5.0 | 1.5.0.post5 | v1.5.0-3.0.rc1 |
| | 1.8.1 | 1.8.1.rc1 | v1.8.1-3.0.rc1 |
| CANN 5.0.4 | 1.5.0 | 1.5.0.post4 | 2.0.4.tr5 |
| CANN 5.0.3 | 1.8.1 | 1.5.0.post3 | 2.0.3.tr5 |
| CANN 5.0.2 | 1.5.0 | 1.5.0.post2 | 2.0.2.tr5 |
## 硬件配套
昇腾训练设备包含以下型号,都可作为PyTorch模型的训练环境
| 产品系列 | 产品型号 |
|-----------------------|----------------------------------|
| Atlas 训练系列产品 | Atlas 800 训练服务器(型号:9000) |
| | Atlas 800 训练服务器(型号:9010) |
| | Atlas 900 PoD(型号:9000) |
| | Atlas 300T 训练卡(型号:9000) |
| | Atlas 300T Pro 训练卡(型号:9000)|
| Atlas A2 训练系列产品 | Atlas 800T A2 训练服务器 |
| | Atlas 900 A2 PoD 集群基础单元 |
| | Atlas 200T A2 Box16 异构子框 |
| | Atlas 300T A2 训练卡 |
昇腾推理设备包含以下型号,都可作为大模型的推理环境
| 产品系列 | 产品型号 |
|-----------------------|----------------------------------|
| Atlas 800I A2推理产品 | Atlas 800I A2 推理服务器 |
## 建议与交流
欢迎大家为社区做贡献。如果有任何疑问或建议,请提交[gitee Issues](https://gitee.com/Ascend/pytorch/issues),我们会尽快回复。感谢您的支持。
## 分支维护策略
AscendPyTorch版本分支的维护阶段如下:
| **状态** | **时间** | **说明** |
| ------------------- | -------- | ------------------------------------------------ |
| 计划 | 1—3 个月 | 计划特性 |
| 开发 | 6—12 个月 | 开发新特性并修复问题,定期发布新版本。针对不同的PyTorch版本采取不同的策略,常规分支的开发周期分别为6个月,长期支持分支的开发周期为12个月 |
| 维护 | 1年/3.5年 | 常规分支维护1年,长期支持分支维护3.5年。对重大BUG进行修复,不合入新特性,并视BUG的影响发布补丁版本 |
| 生命周期终止(EOL) | N/A | 分支不再接受任何修改 |
## 命令行安装cmake依赖时提示找不到包、编译cmake报错版本过低,可使用安装脚本或源码编译安装。
## PyTorch版本维护策略
方法一:下载安装脚本安装cmake。(参考cmake官网)
| **PyTorch版本** | **维护策略** | **当前状态** | **发布时间** | **后续状态** | **EOL日期** |
|---------------|----------|----------|------------|----------------------|------------|
| 2.5.1 | 常规分支 | 开发 | 2024/11/08 | 预计2025/04/08起进入维护状态 | - |
| 2.4.0 | 常规分支 | 开发 | 2024/10/15 | 预计2025/06/15起进入维护状态 | - |
| 2.3.1 | 常规分支 | 开发 | 2024/06/06 | 预计2025/06/07起进入维护状态 | |
| 2.2.0 | 常规分支 | 维护 | 2024/04/01 | 预计2025/09/10起进入无维护状态 | |
| 2.1.0 | 长期支持 | 开发 | 2023/10/15 | 预计2025/09/15起进入维护状态 | |
| 2.0.1 | 常规分支 | EOL | 2023/7/19 | | 2024/03/14 |
| 1.11.0 | 长期支持 | 维护 | 2023/4/19 | 预计2025/09/10起进入无维护状态 | |
| 1.8.1 | 长期支持 | EOL | 2022/4/10 | | 2023/4/10 |
| 1.5.0 | 长期支持 | EOL | 2021/7/29 | | 2022/7/29 |
​ X86_64环境脚本安装:cmake-3.12.0-Linux-x86_64.sh
## 安全声明
​ aarch64环境脚本安装:cmake-3.12.0-Linux-aarch64.sh
[Ascend Extension for PyTorch插件 安全声明](SECURITYNOTE.md)
1. 执行命令。
## 参考文档
```
./cmake-3.12.0-Linux-{arch}.sh #{arch}为架构名称
```
有关安装指南、模型迁移和训练/推理教程和API列表等更多详细信息,请参考[昇腾社区Ascend Extension for PyTorch](https://www.hiascend.com/software/ai-frameworks?framework=pytorch)。
2. 设置软连接。
| 文档名称 | 文档链接 |
|--------------------------|-------------------------------------------------------------------------------------------------------------------------|
| 安装指南 | [参考链接](https://www.hiascend.com/document/detail/zh/Pytorch/60RC3/configandinstg/instg/insg_0001.html) |
| 网络模型迁移和训练 | [参考链接](https://www.hiascend.com/document/detail/zh/Pytorch/60RC3/ptmoddevg/trainingmigrguide/PT_LMTMOG_0003.html) |
| 算子适配 | [参考链接](https://www.hiascend.com/document/detail/zh/canncommercial/80RC3/operatordev/tbeaicpudevg/atlasopdev_10_0086.html) |
| API清单(PyTorch原生接口与自定义接口) | [参考链接](https://www.hiascend.com/document/detail/zh/Pytorch/60RC3/apiref/apilist/ptaoplist_000002.html) |
```
ln -s /usr/local/cmake/bin/cmake /usr/bin/cmake
```
## 许可证
3. 执行如下命令验证是否安装成功。
Ascend Extension for PyTorch插件使用BSD许可证。详见[LICENSE](LICENSE)文件。
```
cmake --version
```
如显示“cmake version 3.12.0”则表示安装成功。
方法二:使用源码编译安装。
1. 获取Cmake软件包。
```
wget https://cmake.org/files/v3.12/cmake-3.12.0.tar.gz --no-check-certificate
```
2. 解压并进入软件包目录。
```
tar -xf cmake-3.12.0.tar.gz
cd cmake-3.12.0/
```
3. 执行配置、编译和安装命令。
```
./configure --prefix=/usr/local/cmake
make && make install
```
4. 设置软连接。
```
ln -s /usr/local/cmake/bin/cmake /usr/bin/cmake
```
5. 执行如下命令验证是否安装成功。
```
cmake --version
```
如显示“cmake version 3.12.0”则表示安装成功。
## 命令行安装gcc依赖时提示找不到包、编译时gcc报错问题
部分源下载gcc时会提示无法找到包,需要使用源码编译安装。
以下步骤请在root用户下执行。
1. 下载gcc-7.3.0.tar.gz,下载地址为[https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz](https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz)。
2. 安装gcc时候会占用大量临时空间,所以先执行下面的命令清空/tmp目录:
```
sudo rm -rf /tmp/*
```
3. 安装依赖(以CentOS和Ubuntu系统为例)。
- CentOS执行如下命令安装。
```
yum install bzip2
```
- Ubuntu执行如下命令安装。
```
apt-get install bzip2
```
4. 编译安装gcc。
1. 进入gcc-7.3.0.tar.gz源码包所在目录,解压源码包,命令为:
```
tar -zxvf gcc-7.3.0.tar.gz
```
2. 进入解压后的文件夹,执行如下命令下载gcc依赖包:
```
cd gcc-7.3.0
./contrib/download_prerequisites
```
如果执行上述命令报错,需要执行如下命令在“gcc-7.3.0/“文件夹下下载依赖包:
```
wget http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2
wget http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2
wget http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz
wget http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.16.1.tar.bz2
```
下载好上述依赖包后,重新执行以下命令:
```
./contrib/download_prerequisites
```
如果命令校验失败,需要确认上述依赖包在文件夹中的唯一性,无重复下载,若存在重复的依赖包,需删除。
3. <a name="zh-cn_topic_0000001135347812_zh-cn_topic_0000001173199577_zh-cn_topic_0000001172534867_zh-cn_topic_0276688294_li1649343041310"></a>执行配置、编译和安装命令:
```
./configure --enable-languages=c,c++ --disable-multilib --with-system-zlib --prefix=/usr/local/linux_gcc7.3.0
make -j15 # 通过grep -w processor /proc/cpuinfo|wc -l查看cpu数,示例为15,用户可自行设置相应参数。
make install
```
> ![img](figures/icon-notice.gif) **须知:**
>其中“--prefix“参数用于指定linux_gcc7.3.0安装路径,用户可自行配置,但注意不要配置为“/usr/local“及“/usr“,因为会与系统使用软件源默认安装的gcc相冲突,导致系统原始gcc编译环境被破坏。示例指定为“/usr/local/linux_gcc7.3.0“。
4. 修改软连接。
```
ln -s ${install_path}/gcc-7.3.0/bin/gcc /usr/bin/gcc
ln -s ${install_path}/gcc-7.3.0/bin/g++ /usr/bin/g++
ln -s ${install_path}/gcc-7.3.0/bin/c++ /usr/bin/c++
```
5.配置环境变量。
当用户执行训练时,需要用到gcc升级后的编译环境,因此要在训练脚本中配置环境变量,通过如下命令配置。
```
export LD_LIBRARY_PATH=${install_path}/lib64:${LD_LIBRARY_PATH}
```
其中$\{install\_path\}为[3.](#zh-cn_topic_0000001135347812_zh-cn_topic_0000001173199577_zh-cn_topic_0000001172534867_zh-cn_topic_0276688294_li1649343041310)中配置的gcc7.3.0安装路径,本示例为“/usr/local/gcc7.3.0/“。
>![](figures/icon-note.gif) **说明:**
>本步骤为用户在需要用到gcc升级后的编译环境时才配置环境变量。
若存在pytorch编译不过,请检查软连接的库是否正确。
libstdc++->libstdc++.so.6.0.24(7.3.0)
## 找不到libblas.so问题
环境缺少openblas库,需要安装openblas库
Centos,EulerOS环境
```sh
yum -y install openblas
```
Ubuntu环境
```sh
apt install libopenblas-dev
```
## ARM环境pip安装torchvision失败
可采用源码安装(需先安装昇腾pytorch并通过env.sh配置环境变量)
```
git clone -b v0.6.0 https://github.com/pytorch/vision.git
cd vision
python setup.py install
```
验证torchvision是否安装成功
```
python -c "import torchvision"
```
若不报错,则说明安装成功
# 版本说明
版本说明请参阅[ReleseNote](docs/zh/RELEASENOTE)
-230
View File
@@ -1,230 +0,0 @@
# Ascend Extension for PyTorch插件 安全声明
## 漏洞风险提示
PyTorch 2.6.0以下版本存在CVE-2025-32434漏洞,该漏洞因torch/serialization.py组件兼容性处理导致潜在的远程代码执行(RCE)风险。 torch_npu已参考[LINK](https://github.com/pytorch/pytorch/pull/145020)进行修复。
## 系统安全加固
建议用户在系统中配置开启ASLR(级别2 ),又称**全随机地址空间布局随机化**,可参考以下方式进行配置:
echo 2 > /proc/sys/kernel/randomize_va_space
## 运行用户建议
出于安全性及权限最小化角度考虑,不建议使用root等管理员类型账户使用torch_npu。
## 文件权限控制
1. 建议用户对训练所需文件、训练过程中保存的文件、用户个人的隐私数据、商业资产等敏感文件做好权限控制等安全措施,例如多用户共享数据集场景下的数据集文件写权限控制、profiler等场景产生数据文件权限控制等,设定的权限建议参考[文件权限参考](#文件权限参考)进行设置。
2. torch_npu中profiler工具会生成性能记录文件,生成的文件权限为640,文件夹权限为750,用户可根据需要自行对生成后的相关文件进行权限控制。
3. 用户安装和使用过程需要做好权限控制,建议参考[文件权限参考](#文件权限参考)进行设置。如需要保存安装/卸载日志,可在安装/卸载命令后面加上参数--log <FILE>, 注意对<FILE>文件及目录做好权限管控。
4. PyTorch框架运行中所生成的文件权限依赖系统设定,如torch.save接口保存的文件。建议当前执行脚本的用户根据自身需要,对生成文件做好权限控制,设定的权限可参考[文件权限参考](#文件权限参考) 。可使用umask控制默认权限,降低提权等安全风险,建议用户将主机(包括宿主机)和容器中的umask设置为0027及其以上,提高安全性。
##### 文件权限参考
| 类型 | Linux权限参考最大值 |
|----------------------------------- |-----------------------|
| 用户主目录 | 750(rwxr-x---) |
| 程序文件(含脚本文件、库文件等) | 550(r-xr-x---) |
| 程序文件目录 | 550(r-xr-x---) |
| 配置文件 | 640(rw-r-----) |
| 配置文件目录 | 750(rwxr-x---) |
| 日志文件(记录完毕或者已经归档) | 440(r--r-----) |
| 日志文件(正在记录) | 640(rw-r-----) |
| 日志文件目录 | 750(rwxr-x---) |
| Debug文件 | 640(rw-r-----) |
| Debug文件目录 | 750(rwxr-x---) |
| 临时文件目录 | 750(rwxr-x---) |
| 维护升级文件目录 | 770(rwxrwx---) |
| 业务数据文件 | 640(rw-r-----) |
| 业务数据文件目录 | 750(rwxr-x---) |
| 密钥组件、私钥、证书、密文文件目录 | 700(rwx------) |
| 密钥组件、私钥、证书、加密密文 | 600(rw-------) |
| 加解密接口、加解密脚本 | 500(r-x------) |
## 调试工具声明
torch_npu内集成性能分析工具profiler:
- 集成原因:对标pytorch原生支持能力,提供NPU PyTorch框架开发性能分析能力,加速性能分析调试过程。
- 使用场景:默认不采集,如用户需要进行性能分析时,可在模型训练脚本中添加Ascend Extension for PyTorch Profiler接口,执行训练的同时采集性能数据,完成训练后直接输出可视化的性能数据文件。
- 风险提示:使用该功能会在本地生成性能数据,用户需加强对相关性能数据的保护,请在需要模型性能分析时使用,分析完成后及时关闭。Profiler工具具体细节请参考[《PyTorch 性能分析工具介绍》](https://www.hiascend.com/document/detail/zh/Pytorch/60RC2/ptmoddevg/trainingmigrguide/performance_tuning_0013.html)。
## 数据安全声明
1. PyTorch使用过程中需要加载和保存数据,部分接口使用风险模块pickle,可能存在数据风险,如torch.load、torch.distributed.scatter_object_list等接口,可参考[torch.load](https://pytorch.org/docs/2.3/generated/torch.load.html#torch.load)、[collective-functions](https://pytorch.org/docs/2.3/distributed.html#collective-functions)了解具体风险。
2. Ascend Extension for PyTorch依赖CANN的基础能力实现AOE性能调优、算子dump、日志记录等功能,用户需要关注上述功能生成文件的权限控制,加强对相关数据的保护。
## 构建安全声明
torch_npu支持源码编译安装,在编译时会下载依赖第三方库并执行构建shell脚本,在编译过程中会产生临时程序文件和编译目录。用户可根据需要自行对源代码目录内的文件进行权限管控降低安全风险。
## 运行安全声明
1. 建议用户结合运行环境资源状况编写对应训练脚本。若训练脚本与资源状况不匹配,如数据集加载内存大小超出内存容量限制、训练脚本在本地生成数据超过磁盘空间大小等情况,可能引发错误并导致进程意外退出。
2. PyTorch和torch_npu在运行异常时会退出进程并打印报错信息,属于正常现象。建议用户根据报错提示定位具体错误原因,包括设定算子同步执行、查看CANN日志、解析生成的Core Dump文件等方式。
3. PyTorch和torch_npu的分布式特性仅适用于内部通信。出于性能考虑,这些分布式特性不包含任何授权协议,并且会发送未加密的消息。关于PyTorch分布式特性的详细说明及安全注意事项,可参考[using-distributed-features](https://github.com/pytorch/pytorch/security#using-distributed-features)。
## 公网地址声明
在torch_npu的配置文件和脚本中存在[公网地址](#公网地址)
##### 公网地址
| 类型 | 开源代码地址 | 文件名 | 公网IP地址/公网URL地址/域名/邮箱地址 | 用途说明 |
|------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------|--------------------------------------------------------------------------------|--------------------------------|
| 自研 | 不涉及 | .gitmodules | https://gitee.com/ascend/op-plugin.git | 依赖的开源代码仓 |
| 自研 | 不涉及 | .gitmodules | https://gitee.com/mirrors/googletest.git | 依赖的开源代码仓 |
| 自研 | 不涉及 | .gitmodules | https://gitee.com/ascend/torchair.git | 依赖的开源代码仓 |
| 自研 | 不涉及 | .gitmodules | https://gitee.com/ascend/Tensorpipe.git | 依赖的开源代码仓 |
| 自研 | 不涉及 | .gitmodules | https://gitee.com/mirrors/nlohmann-json.git | 依赖的开源代码仓 |
| 自研 | 不涉及 | ci\docker\X86\Dockerfile | https://mirrors.huaweicloud.com/repository/pypi/simple | docker配置文件,用于配置pip源 |
| 自研 | 不涉及 | ci\docker\X86\Dockerfile | https://download.pytorch.org/whl/cpu | docker配置源,用于配置torch下载连接 |
| 自研 | 不涉及 | ci\docker\ARM\Dockerfile | https://mirrors.huaweicloud.com/repository/pypi/simple | docker配置文件,用于配置pip源 |
| 自研 | 不涉及 | ci\docker\X86\Dockerfile | https://mirrors.wlnmp.com/centos/Centos7-aliyun-altarch.repo | docker配置文件,用于配置yum源 |
| 自研 | 不涉及 | ci\docker\ARM\Dockerfile | https://mirrors.wlnmp.com/centos/Centos7-aliyun-altarch.repo | docker配置文件,用于配置yum源 |
| 自研 | 不涉及 | .github\workflows\\_build-and-test.yml | https://mirrors.huaweicloud.com/repository/pypi/simple | workflow配置文件,用于配置pip源 |
| 自研 | 不涉及 | setup.cfg | https://gitee.com/ascend/pytorch | 用于打包whl的url入参 |
| 自研 | 不涉及 | setup.cfg | https://gitee.com/ascend/pytorch/tags | 用于打包whl的download_url入参 |
| 自研 | 不涉及 | third_party\op-plugin\ci\build.sh | https://gitee.com/ascend/pytorch.git | 编译脚本根据torch_npu仓库地址拉取代码进行编译 |
| 自研 | 不涉及 | third_party\op-plugin\ci\exec_ut.sh | https://gitee.com/ascend/pytorch.git | UT脚本根据torch_npu仓库地址下拉取代码进行UT测试 |
| 开源引入 | https://github.com/pytorch/pytorch/blob/v2.3.1/test/nn/test_convolution.py <br> https://github.com/pytorch/pytorch/blob/v2.3.1/test/test_mps.py <br> https://github.com/pytorch/pytorch/blob/v2.3.1/test/test_serialization.py | test\url.ini | https://download.pytorch.org/test_data/legacy_conv2d.pt | 用于test脚本下载相关pt文件 |
| 开源引入 | https://github.com/pytorch/pytorch/blob/v2.3.1/test/test_serialization.py | test\url.ini | https://download.pytorch.org/test_data/legacy_serialized.pt | 用于test脚本下载相关pt文件 |
| 开源引入 | https://github.com/pytorch/pytorch/blob/v2.3.1/test/test_serialization.py | test\url.ini | https://download.pytorch.org/test_data/gpu_tensors.pt | 用于test脚本下载相关pt文件 |
| 开源引入 | https://github.com/pytorch/pytorch/blob/v2.3.1/test/onnx/test_utility_funs.py | test\url.ini | https://github.com/pytorch/pytorch/issues/new?template=bug-report.yml | issue的链接 |
| 开源引入 | https://github.com/pytorch/pytorch/blob/v2.3.1/test/test_nn.py <br> https://github.com/pytorch/pytorch/blob/v2.3.1/test/test_serialization.py | test\url.ini | https://download.pytorch.org/test_data/linear.pt | 用于test脚本下载相关pt文件 |
| 自研 | 不涉及 | torch_npu\npu\config.yaml | https://raw.githubusercontent.com/brendangregg/FlameGraph/master/flamegraph.pl | 火焰图脚本下载路径 |
| 自研 | 不涉及 | test\requirements-x86.txt | https://download.pytorch.org/whl/cpu | 下载链接,用于下载torch-cpu版本 |
| 自研 | 不涉及 | test\requirements-x86.txt | https://data.pyg.org/whl/torch-2.3.0+cpu.html | 下载链接,用于下载torch-scatter的cpu版本 |
| 自研 | 不涉及 | test\requirements-x86.txt | https://download.pytorch.org/whl/test/cpu | 下载链接,用于下载torchvision的cpu版本 |
| 自研 | 不涉及 | test\get_synchronized_files.sh | https://github.com/pytorch/pytorch.git | 下载链接,用于下载pytorch的测试用例 |
## 公开接口声明
Ascend Extension for PyTorch是PyTorch适配插件,支持用户使用PyTorch在昇腾设备上进行训练和推理。Ascend Extension for PyTorch适配后支持用户使用PyTorch原生接口。除了原生PyTorch接口外,Ascend Extension for PyTorch提供了部分自定义接口,包括自定义算子、亲和库和其他接口,支持PyTorch接口和自定义接口连接,具体可参考[《PyTorch API参考》](https://www.hiascend.com/document/detail/zh/Pytorch/60RC2/apiref/apilist/ptaoplist_000001.html)。
参考[PyTorch社区公开接口规范](https://github.com/pytorch/pytorch/wiki/Public-API-definition-and-documentation),Ascend Extension for PyTorch提供了对外的自定义接口。如果一个函数看起来符合公开接口的标准且在文档中有展示,则该接口是公开接口。否则,使用该功能前可以在社区询问该功能是否确实是公开的或意外暴露的接口,因为这些未暴露接口将来可能会被修改或者删除。
Ascend Extension for PyTorch项目采用C++和Python联合开发,当前除Libtorch场景外正式接口只提供Python接口,在torch_npu的二进制包中动态库不直接提供服务,暴露的接口为内部使用,不建议用户使用。
## 通信安全加固
PyTorch分布式训练服务需要在设备间进行通信,通信开启的端口默认为全0侦听,为了降低安全风险,建议用户针对此场景进行安全加固,如使用iptables配置防火墙,在运行分布式训练开始前限制外部对分布式训练使用端口的访问,在运行分布式训练结束后清理防火墙规则。
1. 防火墙规则设定和移除参考脚本模板
- 防火墙规则设定,可参考如下脚本:
```
#!/bin/bash
set -x
# 要限制的端口号
port={端口号}
# 清除旧规则
iptables -D INPUT -p tcp -j {规则名}
iptables -F {规则名}
iptables -X {规则名}
# 创建新的规则链
iptables -t filter -N {规则名}
# 在多机场景下设定白名单,允许其他节点访问主节点的侦听端口
# 在规则链中添加允许特定IP地址范围的规则
iptables -t filter -A {规则名} -i eno1 -p tcp --dport $port -s {允许外部访问的IP} -j ACCEPT
# 屏蔽外部地址访问分布式训练端口
# 在PORT-LIMIT-RULE规则链中添加拒绝其他IP地址的规则
iptables -t filter -A {规则名} -i {要限制的网卡名} -p tcp --dport $port -j DROP
# 将流量传递给规则链
iptables -I INPUT -p tcp -j {规则名}
```
- 防火墙规则移除,可参考如下脚本:
```
#!/bin/bash
set -x
# 清除规则
iptables -D INPUT -p tcp -j {规则名}
iptables -F {规则名}
iptables -X {规则名}
```
2. 防火墙规则设定和移除参考脚本示例
1. 针对特定端口设定防火墙,脚本中端口号为要限制的端口,在PyTorch分布式训练中端口号请参考[通信矩阵信息](#通信矩阵信息);要限制的网卡名为服务器用于分布式通信使用的网卡,允许的外部访问的IP为分布式训练服务器的IP地址。网卡和服务器IP可以通过ifconfig查看,如下文回显的eth0为网卡名,192.168.1.1为服务器IP地址:
```
# ifconfig
eth0
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::230:64ee:ef1a:c1a/64 Scope:Link
```
2. 假定服务器主节点地址192.168.1.1,另一台需要进行分布式训练的服务器为192.168.1.2,训练端口为29510。
- 防火墙规则设定,可参考如下脚本:
```
#!/bin/bash
set -x
# 设定侦听的端口
port=29510
# 清除旧规则
iptables -D INPUT -p tcp -j PORT-LIMIT-RULE
iptables -F PORT-LIMIT-RULE
iptables -X PORT-LIMIT-RULE
# 创建新的PORT-LIMIT-RULE规则链
iptables -t filter -N PORT-LIMIT-RULE
# 在多机场景下设定白名单,允许192.168.1.2访问主节点
# 在PORT-LIMIT-RULE规则链中添加允许特定IP地址范围的规则
iptables -t filter -A PORT-LIMIT-RULE -i eno1 -p tcp --dport $port -s 192.168.1.2 -j ACCEPT
# 屏蔽外部地址访问分布式训练端口
# 在PORT-LIMIT-RULE规则链中添加拒绝其他IP地址的规则
iptables -t filter -A PORT-LIMIT-RULE -i eth0 -p tcp --dport $port -j DROP
# 将流量传递给PORT-LIMIT-RULE规则链
iptables -I INPUT -p tcp -j PORT-LIMIT-RULE
```
- 防火墙规则移除,可参考如下脚本:
```
#!/bin/bash
set -x
# 清除规则
iptables -D INPUT -p tcp -j PORT-LIMIT-RULE
iptables -F PORT-LIMIT-RULE
iptables -X PORT-LIMIT-RULE
```
## 通信矩阵
PyTorch提供分布式训练能力,支持在单机和多机场景下进行训练,需要进行网络通信。其中PyTorch需要使用TCP进行通信,torch_npu使用CANN中HCCL在NPU设备间通信,通信端口见[通信矩阵信息](#通信矩阵信息)。用户需要注意并保障节点间通信网络安全,可以使用iptables等方式消减安全风险,可参考[通信安全加固](#通信安全加固)进行网络安全加固。
##### 通信矩阵信息
| 组件 | PyTorch | HCCL |
| --------------------- | ------------------------------------ | ------------------------------------ |
| 源设备 | 运行torch_npu进程的服务器 | 运行torch_npu进程的服务器 |
| 源IP | 设备地址IP | 设备地址IP |
| 源端口 | 操作系统自动分配,分配范围由操作系统的自身配置决定 | 默认值为60000,取值范围[1024,65520]。用户可以通过HCCL_IF_BASE_PORT环境变量指定Host网卡起始端口号,配置后系统默认占用以该端口起始的16个端口 |
| 目的设备 | 运行torch_npu进程的服务器 | 运行torch_npu进程的服务器 |
| 目的IP | 设备地址IP | 设备地址IP |
| 目的端口 (侦听) | 默认29500/29400,用户可以设定端口号 | 默认值为60000,取值范围[1024,65520]。用户可以通过HCCL_IF_BASE_PORT环境变量指定Host网卡起始端口号,配置后系统默认占用以该端口起始的16个端口 |
| 协议 | TCP | TCP |
| 端口说明 | 分布式场景下 <br> 1. torchrun/torch.distributed.launch <br> (1) backend为static时(默认该backend),目的端口(默认29500)用于接收和发送数据,源端口用于接收和发送数据。使用master-addr指定地址,master-port指定端口 <br> (2) backend为c10d时,目的端口(默认29400)用于接收和发送数据,源端口用于接收和发送数据。使用rdzv_endpoint指定地址和端口号,格式为"地址:端口号" <br> 2. torch_npu_run:目的端口(默认29500)用于接收和发送数据,源端口用于接收和发送数据。使用master-addr指定地址,master-port指定端口 | 默认值为60000,取值范围[1024,65520]。用户可以通过HCCL_IF_BASE_PORT环境变量指定Host网卡起始端口号,配置后系统默认占用以该端口起始的16个端口 |
| 侦听端口是否可更改 | 是 | 是 |
| 认证方式 | 无认证方式 | 无认证方式 |
| 加密方式 | 无 | 无 |
| 所属平面 | 不涉及 | 不涉及 |
| 版本 | 所有版本 | 所有版本 |
| 特殊场景 | 无 | 无 |
| 备注 | 该通信过程由开源软件PyTorch控制,配置为PyTorch原生设置,可参考[PyTorch文档](https://pytorch.org/docs/stable/distributed.html#launch-utility)。源端口由操作系统自动分配,分配范围由操作系统的配置决定,例如ubuntu:采用/proc/sys/net/ipv4/ipv4_local_port_range文件指定,可通过cat /proc/sys/net/ipv4/ipv4_local_port_range或sysctl net.ipv4.ip_local_port_range查看 | 该通信过程由CANN中HCCL组件控制,torch_npu不进行控制,端口范围可参考[《环境变量参考》](https://www.hiascend.com/document/detail/zh/canncommercial/80RC2/apiref/envvar/envref_07_0001.html)的“执行相关 > 集合通信与分布式训练 > 集合通信相关配置>HCCL_IF_BASE_PORT” |
+85 -122
View File
@@ -1,122 +1,85 @@
OPEN SOURCE SOFTWARE NOTICE
Please note we provide an open source software notice along with this product and/or this product firmware (in the following just “this product”). The open source software licenses are granted by the respective right holders. And the open source licenses prevail all other license information with regard to the respective open source software contained in the product, including but not limited to End User Software Licensing Agreement. This notice is provided on behalf of Huawei Technologies Co. Ltd. and any of its local subsidiaries which may have provided this product to you in your local country.
Warranty Disclaimer
THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
Copyright Notice and License Texts
Software: pytorch v2.3.1
Copyright notice:
Copyright (c) 2011-2013 NYU
Copyright (c) Microsoft Corporation
Copyright (c) 2014- Facebook, Inc
Copyright (c) 2017 The Android Open Source Project
Copyright Python Software Foundation
Copyright (c) 2018 Alex Rogozhnikov
Copyright (c) 2007-2009 Scientific Computing and Imaging Institute, University of Utah
Copyright (c) 2016, NVIDIA CORPORATION, All rights reserved
Copyright (c) 2017 Microsoft
Copyright (c) Meta Platforms, Inc.
Copyright (c) 2022 Apple Inc.
Copyright (c) 2018-present, Facebook, Inc.
Copyright (c) Facebook Inc. and Microsoft Corporation
Copyright (c) 2005-2017, NumPy Developers. All rights reserved
Copyright (c) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, All rights reserved
Copyright (c) 2014, The Regents
Copyright (c) 2005-2010 ActiveState Software Inc.
Copyright 2005, Google Inc. All rights reserved
Copyright (c) 2022, Tri Dao
Copyright (c) 2001-2002 Enthought, Inc. 2003-2019, SciPy Developers. All rights reserved
Copyright 2008 Google Inc. All rights reserved
Copyright (c) 2003-2017 Josef Weidendorfer. All rights reserved
Copyright (c) 2014 Matthew Rocklin
Copyright (c) 2016 Microsoft
Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved
Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
Copyright (c) 2008-2012 The Khronos Group Inc.
Copyright (c) 2016 Facebook Inc.
Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC All Rights Reserved
Copyright (c) 2006, Laurent Montel, <montel@kde.org>
Copyright (c) 2015 Google Inc. All rights reserved
Copyright (c) 2010-2022 by Alex Clark and contributors
Copyright 2015 Google Inc. All Rights Reserved
Copyright (c) 2017 - 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved
Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu)
(c) BNParamType
Copyright 2013-2014 RAD Game
Copyright (c) 2011-2019 Stephan Brumme. All rights reserved
Copyright (c) 2018 MathInf GmbH, Thomas Viehmann
Copyright 2019 Kakao Brain
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software Foundation All Rights Reserved
Copyright 2004-present Facebook. All Rights Reserved
Copyright (c) 2008-2013 The Khronos Group Inc.
Copyright (c) Microsoft Corporation. All rights reserved
Copyright 2006, Google Inc. All rights reserved
Copyright (c) 2014-2015 The Khronos Group Inc.
Copyright 2015 The TensorFlow Authors. All Rights Reserved
Copyright (c) 2023, Tri Dao
Copyright (c) 2011-2014 Idiap Research Institute
Copyright (c) 2016-present, Facebook Inc. All rights reserved
Copyright (c) Advanced Micro Devices, Inc.
Copyright (c) 2001-2014 Python Software Foundation All Rights Reserved
Copyright (c) Bjorn Fahller
Copyright (c) 1995-2011 by Fredrik Lundh
Copyright (c) Edward Z. Yang <ezyang@mit.edu>
Copyright (c) 2012 Massachusetts Institute of Technology
Copyright (c) 2006 Idiap Research Institute
Copyright (c) 2011-2021, NVIDIA CORPORATION. All rights reserved
Copyright (c) 2008 - 2012 The Khronos Group Inc.
Copyright (c) 2015 Yangqing Jia All rights reserved
Copyright 2023-present Facebook. All Rights Reserved
Copyright 2013 Conrad Steenberg <conrad.steenberg@gmail.com>
Copyright (c) 2008-2015 The Khronos Group Inc.
Copyright (c) 2014-2017 The Regents
Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston)
Copyright Malte Skarupke 2017
Copyright (c) Meta Platforms, Inc. and affiliates
Copyright (c) 2023, Advanced Micro Devices, Inc.
Copyright (c) 2016- Facebook, Inc
Copyright (c) 1997-2011 by Secret Labs AB
Copyright (c) 2005-2022 NVIDIA Corporation Built
Copyright (c) Facebook, Inc.
Copyright 2019-2020 Kakao Brain
Copyright (c) 2000-2017 Julian Seward. All rights reserved
Copyright (c) 2016-2017, ARM Limited and Contributors
Copyright (c) 2005-2020 Rich Felker
Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz)
Copyright 2016 Facebook
Copyright (c) 2012-2014 Deepmind Technologies
Copyright (c) 2012 Giovanni Garberoglio Interdisciplinary Laboratory
Copyright (c) 2024, Tri Dao
Copyright (c) Donald Stufft and individual contributors. All rights reserved
Copyright (c) 2018, Steven Moshier All rights reserved
Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved
Copyright (c) 2017-present, Facebook, Inc.
Copyright (c) 2020-2023, NVIDIA CORPORATION. All rights reserved
Copyright (c) 2017 - 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved
Copyright (c) 2014, 2015, The Regents
Copyright (c) 2013 Eddy Petrisor
Copyright (c) 2010 ActiveState Software Inc.
Copyright (c) 2006 The Android Open Source Project
Copyright (c) 2023 Apple Inc.
Copyright 2015 The Gemmlowp Authors. All Rights Reserved
Copyright (c) 2015-2017 The Khronos Group Inc.
Copyright 2022 Cruise LLC
Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved
Copyright (c) 2022 Cruise LLC. All rights reserved
Copyright (c) 2016-present, Facebook, Inc.
(c) Copyright John Maddock 2006
Copyright (c) 2014 Indiana University All rights reserved
copyright 2019 The TensorFlow Authors
License: BSD 3-Clause License
Copyright (c) , <YEAR>,<OWNER>
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OPEN SOURCE SOFTWARE NOTICE
Please note we provide an open source software notice along with this product and/or this product firmware (in the following just “this product”). The open source software licenses are granted by the respective right holders. And the open source licenses prevail all other license information with regard to the respective open source software contained in the product, including but not limited to End User Software Licensing Agreement. This notice is provided on behalf of Huawei Technologies Co. Ltd. and any of its local subsidiaries which may have provided this product to you in your local country.
Warranty Disclaimer
THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
Copyright Notice and License Texts
Software: pytorch 1.5.0
Copyright notice:
Copyright (c) 2016-present, Facebook, Inc.
Copyright (c) Facebook, Inc. and its affiliates.
Copyright 2006, Google Inc.
Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved.
2017-2018 Advanced Micro Devices, Inc. and Facebook Inc. All rights reserved.
Copyright 2004-present Facebook. All Rights Reserved.
Copyright (c) 2018 MathInf GmbH, Thomas Viehmann
Copyright (c) 2014 Indiana University
Copyright (c) 2016, NVIDIA CORPORATION, All rights reserved
Copyright (C) 2012 Giovanni Garberoglio
Copyright 2015 Google Inc. All Rights Reserved.
Copyright (c) Facebook Inc. and Microsoft Corporation.
Copyright © 2001-2014 Python Software Foundation
All Rights Reserved
Copyright (c) 2014-2015 The Khronos Group Inc.
Copyright (c) 2006, Laurent Montel, montel@kde.org
Copyright 2013 Conrad Steenberg conrad.steenberg@gmail.com
Copyright (C) 2017 The Android Open Source Project
Copyright (c) 2010-2017 Benjamin Peterson
Copyright 2013-2014 RAD Game Tools and Valve Software
Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
Copyright (c) 2007-2009 Scientific Computing and Imaging Institute, University of Utah
(c) Facebook, Inc. and its affiliates. Confidential and proprietary.
Copyright (c) 2017 by Contributors
Copyright 2016 Facebook
Copyright (C) 2018 Marat Dukhan
Copyright (c) 2017-2018 Facebook Inc.
Copyright (c) 2017 Georgia Institute of Technology
Copyright (c) 2016 Microsoft
Copyright (c) 2014, 2015, The Regents of the University of California
Copyright (c) 2014, 2015, the respective contributors
Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert)
Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu)
Copyright (c) 2011-2013 NYU (Clement Farabet)
Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert,Leon Bottou, Iain Melvin, Jason Weston)
Copyright (c) 2006 Idiap Research Institute (Samy Bengio)
Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert,Samy Bengio, Johnny Mariethoz)
Copyright (c) 2016-2017, ARM Limited and Contributors
Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
Copyright (C) 2007-2017 Free Software Foundation, Inc.
Copyright Malte Skarupke 2017.
Copyright (C) 2011 - 2012 Andrzej Krzemienski.
Copyright (C) 2001-2019 Free Software Foundation, Inc.
Copyright (c) 1994 Hewlett-Packard Company
Copyright (c) 1996-1998 Silicon Graphics Computer Systems, Inc.
Copyright Michael Park, 2015-2017
Copyright (c) 2008 - 2012 The Khronos Group Inc.
Copyright (c) 2008-2013 The Khronos Group Inc.
Copyright (c) 2008-2012 The Khronos Group Inc.
Copyright (C) 2006 The Android Open Source Project
Copyright (c) 2016- Facebook, Inc (Adam Paszke)
Copyright (c) 2014- Facebook, Inc (Soumith Chintala)
Copyright (c) 2012-2014 Deepmind Technologies (Koray Kavukcuoglu)
Copyright (c) 2011-2013 NYU (Clement Farabet)
Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston)
Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz)
Copyright (c) 2016-present, Facebook Inc. All rights reserved.
Copyright (c) 2016 Facebook Inc.
Copyright (c) 2015 Google Inc.
Copyright (c) 2015 Yangqing Jia
Copyright(c) 2013, 2014, 2015, the respective contributors
Copyright(c) 2015, 2016 the respective contributors
Copyright (c) 2014, The Regents of the University of California (Regents)
Copyright (c) 2014, the respective contributors
Copyright (c) 2008-2015 The Khronos Group Inc.
Copyright (c) 2014-2017 The Regents of the University of California (Regents)
Copyright (c) 2014-2017, the respective contributors
Copyright (c) 2017 Microsoft
Copyright (c) 2017-present, Facebook, Inc.
Copyright (c) 2018-present, Facebook, Inc.
License: BSD 3-Clause License
Please see above.
-279
View File
@@ -1,279 +0,0 @@
import multiprocessing
import glob
import os
import re
import shutil
import subprocess
import sys
import traceback
import platform
from pathlib import Path
from sysconfig import get_paths
from distutils.version import LooseVersion
from distutils import file_util
from codegen.utils import PathManager
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
PathManager.check_directory_path_readable(os.path.join(BASE_DIR, "version.txt"))
with open(os.path.join(BASE_DIR, "version.txt")) as version_f:
VERSION = version_f.read().strip()
def which(thefile):
path = os.environ.get("PATH", os.defpath).split(os.pathsep)
for d in path:
fname = os.path.join(d, thefile)
fnames = [fname]
if sys.platform == 'win32':
exts = os.environ.get('PATHEXT', '').split(os.pathsep)
fnames += [fname + ext for ext in exts]
for name in fnames:
if os.access(name, os.F_OK | os.X_OK) and not os.path.isdir(name):
return name
return None
def get_cmake_command():
def _get_version(cmd):
for line in subprocess.check_output([cmd, '--version']).decode('utf-8').split('\n'):
if 'version' in line:
return LooseVersion(line.strip().split(' ')[2])
raise RuntimeError('no version found')
"Returns cmake command."
cmake_command = 'cmake'
if platform.system() == 'Windows':
return cmake_command
cmake3 = which('cmake3')
cmake = which('cmake')
if cmake3 is not None and _get_version(cmake3) >= LooseVersion("3.18.0"):
cmake_command = 'cmake3'
return cmake_command
elif cmake is not None and _get_version(cmake) >= LooseVersion("3.18.0"):
return cmake_command
else:
raise RuntimeError('no cmake or cmake3 with version >= 3.18.0 found')
def get_build_type():
build_type = 'Release'
if os.getenv('DEBUG', default='0').upper() in ['ON', '1', 'YES', 'TRUE', 'Y']:
build_type = 'Debug'
if os.getenv('REL_WITH_DEB_INFO', default='0').upper() in ['ON', '1', 'YES', 'TRUE', 'Y']:
build_type = 'RelWithDebInfo'
return build_type
def get_pytorch_dir():
try:
import torch
return os.path.dirname(os.path.abspath(torch.__file__))
except Exception:
_, _, exc_traceback = sys.exc_info()
frame_summary = traceback.extract_tb(exc_traceback)[-1]
return os.path.dirname(frame_summary.filename)
def generate_bindings_code(base_dir):
python_execute = sys.executable
generate_code_cmd = ["bash", os.path.join(base_dir, 'generate_code.sh'), python_execute, VERSION]
if subprocess.call(generate_code_cmd) != 0:
print(
'Failed to generate ATEN bindings: {}'.format(generate_code_cmd),
file=sys.stderr)
sys.exit(1)
def build_stub(base_dir):
build_stub_cmd = ["sh", os.path.join(base_dir, 'third_party/acl/libs/build_stub.sh')]
if subprocess.call(build_stub_cmd) != 0:
print(
'Failed to build stub: {}'.format(build_stub_cmd),
file=sys.stderr)
sys.exit(1)
def clean_generated_files():
f_ignore = open(os.path.join(BASE_DIR, '.gitignore'), 'r')
ignores = f_ignore.read()
pat = re.compile(r'^#( BEGIN NOT-CLEAN-FILES )?')
for wildcard in filter(None, ignores.split('\n')):
match = pat.match(wildcard)
if match:
if match.group(1):
# Marker is found and stop reading .gitignore.
break
# Ignore lines which begin with '#'.
else:
for filename in glob.glob(wildcard):
shutil.rmtree(filename, ignore_errors=True)
f_ignore.close()
clean_files = ['torch_npu/csrc/aten/RegisterCPU.cpp', 'torch_npu/csrc/aten/RegisterNPU.cpp',
'torch_npu/csrc/aten/RegisterAutogradNPU.cpp', 'torch_npu/csrc/aten/NPUNativeFunctions.h']
for file in clean_files:
if os.path.exists(os.path.join(BASE_DIR, file)):
os.remove(os.path.join(BASE_DIR, file))
if os.path.exists(os.path.join(BASE_DIR, "libtorch")):
shutil.rmtree(os.path.join(BASE_DIR, "libtorch"))
def check_gtest_valid(base_dir):
# validation of GoogleTest path.
gtest_path = os.path.join(base_dir, 'third_party/googletest/CMakeLists.txt')
return os.path.exists(gtest_path)
def generate_dbg_files_and_strip():
library_dir = Path(BASE_DIR).joinpath("build/packages/torch_npu")
dbg_dir = Path(BASE_DIR).joinpath("build/dbg_libtorch")
os.makedirs(dbg_dir, exist_ok=True)
library_files = [Path(i) for i in library_dir.rglob('*.so')]
for library_file in library_files:
subprocess.check_call(["eu-strip", library_file, "-f",
str(dbg_dir.joinpath(library_file.name)) + ".debug"], cwd=BASE_DIR) # Compliant
def run_cmake():
cmake = get_cmake_command()
if cmake is None:
raise RuntimeError(
"CMake must be installed to build the following extensions: ")
build_dir = os.path.join(BASE_DIR, "build")
build_type_dir = os.path.join(build_dir)
output_lib_path = os.path.join(build_type_dir, "packages/torch_npu/lib")
os.makedirs(build_type_dir, exist_ok=True)
os.makedirs(output_lib_path, exist_ok=True)
cmake_args = [
'-DCMAKE_BUILD_TYPE=' + get_build_type(),
'-DCMAKE_INSTALL_PREFIX=' + os.path.abspath(output_lib_path),
'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + os.path.abspath(output_lib_path),
'-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=' + os.path.abspath(output_lib_path),
'-DTORCHNPU_INSTALL_LIBDIR=' + os.path.abspath(output_lib_path),
'-DPYTHON_INCLUDE_DIR=' + get_paths().get('include'),
'-DPYTORCH_INSTALL_DIR=' + get_pytorch_dir(),
'-DTORCH_VERSION=' + VERSION,
'-DBUILD_LIBTORCH=' + "ON"]
if check_opplugin_valid(BASE_DIR):
cmake_args.append('-DBUILD_OPPLUGIN=on')
cmake_args.append('-DBUILD_NEW_HEADER=on')
if check_tensorpipe_valid(BASE_DIR):
cmake_args.append('-DBUILD_TENSORPIPE=on')
if os.getenv('_GLIBCXX_USE_CXX11_ABI') is not None:
cmake_args.append('-DGLIBCXX_USE_CXX11_ABI=' + os.getenv('_GLIBCXX_USE_CXX11_ABI'))
if os.getenv('_ABI_VERSION') is not None:
cmake_args.append('-DABI_VERSION=' + os.getenv('_ABI_VERSION'))
build_args = ['-j', str(multiprocessing.cpu_count())]
subprocess.check_call([cmake, BASE_DIR] + cmake_args, cwd=build_type_dir, env=os.environ)
subprocess.check_call(['make'] + build_args, cwd=build_type_dir, env=os.environ)
if which('eu-strip') is not None:
generate_dbg_files_and_strip()
def check_opplugin_valid(base_dir):
# build with submodule of op_plugin, if path of op-plugin is valid
op_plugin_path = os.path.join(base_dir, 'third_party/op-plugin/op_plugin')
return os.path.exists(op_plugin_path)
def check_tensorpipe_valid(base_dir):
tensorpipe_path = os.path.join(base_dir, 'third_party/Tensorpipe/tensorpipe')
return os.path.exists(tensorpipe_path)
def copy_file(infile, outfile, preserve_mode=1, preserve_times=1, link=None, level=1):
"""Copy a file respecting verbose, dry-run and force flags. (The
former two default to whatever is in the Distribution object, and
the latter defaults to false for commands that don't define it.)
"""
return file_util.copy_file(infile, outfile, preserve_mode, preserve_times, True, link)
def move_special_hpp(ret):
hpp_name = "torch_npu.h"
for _, dst in ret:
if dst.endswith(hpp_name):
dir_name = os.path.join(os.path.dirname(dst), "../../" + hpp_name)
copy_file(dst, dir_name)
return
def copy_hpp():
def get_src_py_and_dst():
ret = []
header_files = [
"torch_npu/csrc/aten/*.h",
"torch_npu/csrc/aten/*/*.h",
"torch_npu/csrc/aten/*/*/*.h",
"torch_npu/csrc/core/*.h",
"torch_npu/csrc/core/*/*.h",
"torch_npu/csrc/core/*/*/*.h",
"torch_npu/csrc/framework/*.h",
"torch_npu/csrc/framework/*/*.h",
"torch_npu/csrc/framework/*/*/*.h",
"torch_npu/csrc/libs/*.h"
]
glob_header_files = []
for regex_pattern in header_files:
glob_header_files += glob.glob(os.path.join(BASE_DIR, regex_pattern), recursive=True)
for src in glob_header_files:
dst = os.path.join(
os.path.join(BASE_DIR, "libtorch_npu/include/torch_npu"),
os.path.relpath(src, os.path.join(BASE_DIR, "torch_npu")))
os.makedirs(os.path.dirname(dst), exist_ok=True)
ret.append((src, dst))
return ret
ret = get_src_py_and_dst()
for src, dst in ret:
copy_file(src, dst)
move_special_hpp(ret)
def copy_lib():
lib_file = ["build/packages/torch_npu/lib/*.*"]
glob_lib_files = []
for regex_pattern in lib_file:
glob_lib_files += glob.glob(os.path.join(BASE_DIR, regex_pattern), recursive=True)
dst_path = os.path.join(BASE_DIR, "libtorch_npu/lib")
os.makedirs(dst_path, exist_ok=True)
for src in glob_lib_files:
_, src_file_name = os.path.split(src)
copy_file(src, os.path.join(dst_path, src_file_name))
def copy_cmake():
cmake_file = os.path.join(BASE_DIR, "build/Torch_npuConfig.cmake")
dst_path = os.path.join(BASE_DIR, "libtorch_npu/share/cmake/Torch_npu")
os.makedirs(dst_path, exist_ok=True)
copy_file(cmake_file, dst_path)
def build_libtorch_npu():
clean_generated_files()
generate_bindings_code(BASE_DIR)
if Path(BASE_DIR).joinpath("third_party/Tensorpipe/third_party/acl/libs").exists():
build_stub(Path(BASE_DIR).joinpath("third_party/Tensorpipe"))
build_stub(BASE_DIR)
run_cmake()
copy_hpp()
copy_lib()
copy_cmake()
if __name__ == "__main__":
build_libtorch_npu()
-5
View File
@@ -1,5 +0,0 @@
from .constants import (
BASE_DIR, TEST_DIR, NETWORK_OPS_DIR,
SLOW_TEST_BLOCKLIST, NOT_RUN_DIRECTLY, INCLUDE_FILES, EXEC_TIMEOUT
)
from .test_manager import TestMgr
-37
View File
@@ -1,37 +0,0 @@
import os
from pathlib import Path
BASE_DIR = Path(__file__).absolute().parent.parent.parent
TEST_DIR = BASE_DIR / 'test'
NETWORK_OPS_DIR = BASE_DIR / 'third_party/op-plugin/test'
# Add slow test cases here (first element must be test_ops)
SLOW_TEST_BLOCKLIST = [
'test_ops',
'test_modules',
'test_binary_ufuncs',
'test_ops_fwd_gradients',
'test_ops_gradients',
'test_reductions',
'test_unary_ufuncs',
'test_ops_jit',
'test_jit_fuser_te',
"onnx/test_op_consistency",
"onnx/test_fx_op_consistency",
'test_foreach',
'onnx/test_pytorch_onnx_onnxruntime'
]
# exclude some not run directly test files
NOT_RUN_DIRECTLY = {
"jit": "test_jit.py",
}
# include some files
INCLUDE_FILES = [
'jit/test_complexity.py',
]
# default ut cmd execution timeout is 2000s
EXEC_TIMEOUT = os.getenv("PTA_UT_EXEC_TIMEOUT", "2000")
EXEC_TIMEOUT = int(EXEC_TIMEOUT) if EXEC_TIMEOUT.isdigit() else 2000
-5
View File
@@ -1,5 +0,0 @@
from .copy_opt import CopyOptStrategy
from .core import CoreTestStrategy
from .directory_mapping import DirectoryMappingStrategy
from .op import OpStrategy
from .test_file import TestFileStrategy
-30
View File
@@ -1,30 +0,0 @@
import os
import subprocess
from abc import ABCMeta, abstractmethod
from ..constants import BASE_DIR
class AccurateTest(metaclass=ABCMeta):
base_dir = BASE_DIR
test_dir = base_dir / 'test'
@abstractmethod
def identify(self, modify_file):
"""
该接口提供代码对应的UT的路径信息
"""
raise Exception("abstract method. Subclasses should implement it.")
@classmethod
def find_ut_by_regex(cls, regex):
ut_files = []
cmd = "find {} -name {}".format(str(cls.test_dir), regex)
status, output = subprocess.getstatusoutput(cmd)
# 对于找不到的暂不作处理
if not(status or not output):
files = output.split('\n')
for ut_file in files:
ut_file_basename = os.path.basename(ut_file)
if ut_file_basename.startswith("test") and ut_file.endswith(".py"):
ut_files.append(ut_file)
return ut_files
-13
View File
@@ -1,13 +0,0 @@
from .base import AccurateTest
class CopyOptStrategy(AccurateTest):
"""
通过识别非连续转连续的测试用例
"""
def identify(self, modify_file):
if modify_file.find('contiguous') > 0:
regex = '*contiguous*'
return AccurateTest.find_ut_by_regex(regex)
return []
-18
View File
@@ -1,18 +0,0 @@
from pathlib import Path
from .base import AccurateTest
class CoreTestStrategy(AccurateTest):
"""
Determine whether the core tests should be runned
"""
def __init__(self):
super().__init__()
self.block_list = ['test', 'docs']
self.core_test_cases = [str(i) for i in (self.base_dir / 'test/npu').rglob('test_*.py')]
def identify(self, modify_file):
modified_module = str(Path(modify_file).parts[0])
if modified_module not in self.block_list:
return self.core_test_cases
return []
@@ -1,54 +0,0 @@
from pathlib import Path
from .base import AccurateTest
class DirectoryMappingStrategy(AccurateTest):
"""
Map the modified files to the corresponding test cases
"""
mapping_list = {
'contrib': 'test/contrib',
'cpp_extension': 'test/cpp_extensions',
'distributed': 'test/distributed',
'fx': 'test/test_fx.py',
'optim': 'test/optim',
'profiler': 'test/profiler',
'onnx': 'test/onnx',
'utils': 'test/test_utils.py',
'testing': 'test/test_testing.py',
'jit': 'test/test_jit.py',
'rpc': 'test/distributed/rpc',
'dynamo': 'test/dynamo',
}
@staticmethod
def get_module_name(modify_file):
module_name = str(Path(modify_file).parts[1])
if module_name == 'csrc':
module_name = str(Path(modify_file).parts[2])
for part in Path(modify_file).parts:
if part == 'rpc':
module_name = 'rpc'
if module_name == 'utils' and Path(modify_file).parts[2] == 'cpp_extension.py':
module_name = 'cpp_extension'
if module_name == 'utils' and 'dynamo' in Path(modify_file).parts[2]:
module_name = 'dynamo'
return module_name
def identify(self, modify_file):
current_all_ut_path = []
if str(Path(modify_file).parts[0]) == 'torch_npu':
mapped_ut_path = []
module_name = self.get_module_name(modify_file)
if module_name in self.mapping_list:
mapped_ut_path.append(self.mapping_list[module_name])
file_name = str(Path(modify_file).stem)
if file_name in self.mapping_list:
mapped_ut_path.append(self.mapping_list[file_name])
for mapped_path in mapped_ut_path:
if Path.is_file(self.base_dir.joinpath(mapped_path)):
current_all_ut_path.append(str(self.base_dir.joinpath(mapped_path)))
else:
current_all_ut_path += [str(i) for i in (self.base_dir.joinpath(mapped_path)).glob('test_*.py')]
return current_all_ut_path
-25
View File
@@ -1,25 +0,0 @@
import re
from pathlib import Path
from .base import AccurateTest
class OpStrategy(AccurateTest):
"""
通过对适配层的代码的识别
"""
def identify(self, modify_file):
"""
通过对于算子实现文件的文件名解析获取其单元测试的名字,比如:
BinaryCrossEntropyWithLogitsBackwardKernelNpu.cpp
针对这个文件,先识别关键字BinaryCrossEntropyWithLogitsBackward
然后,获取其正则表达式*binary*cross*entropy*with*logits*backward*识别到符合要求的测试用例
具体方法:通过大写字母切分关键字,再识别包含所有这些关键字的测试文件名。
"""
filename = Path(modify_file).name
if filename.find('KernelNpu') >= 0:
feature_line = filename.split('KernelNpu')[0]
features = re.findall('[A-Z][^A-Z]*', feature_line)
regex = '*' + '*'.join([f"{feature.lower()}" for feature in features]) + '*'
return AccurateTest.find_ut_by_regex(regex)
return []
-14
View File
@@ -1,14 +0,0 @@
import re
from pathlib import Path
from .base import AccurateTest
class TestFileStrategy(AccurateTest):
"""
Determine whether the modified files are test cases
"""
def identify(self, modify_file):
is_test_file = str(Path(modify_file).parts[0]) == "test" \
and re.match("test_(.+).py", Path(modify_file).name)
return [(str(self.base_dir.joinpath(modify_file)))] if is_test_file else []
-159
View File
@@ -1,159 +0,0 @@
import os
import re
from pathlib import Path
import torch_npu
from .strategy import (
TestFileStrategy,
CopyOptStrategy,
OpStrategy,
DirectoryMappingStrategy,
CoreTestStrategy
)
from .constants import (
BASE_DIR, TEST_DIR, SLOW_TEST_BLOCKLIST, INCLUDE_FILES
)
def get_test_torch_version_path():
torch_npu_version = torch_npu.__version__
version_list = torch_npu_version.split('.')
if len(version_list) > 2:
return f'test_v{version_list[0]}r{version_list[1]}_ops'
else:
raise RuntimeError("Invalid torch_npu version.")
class TestMgr:
def __init__(self):
self.modify_files = []
self.test_files = {
'ut_files': [],
'op_ut_files': []
}
def load(self, modify_files, world_size):
with open(modify_files) as f:
for line in f:
if world_size != 0 and "test/distributed/" in line:
continue
line = line.strip()
self.modify_files.append(line)
def analyze(self):
for modify_file in self.modify_files:
self.test_files['ut_files'] += TestFileStrategy().identify(modify_file)
self.test_files['ut_files'] += CopyOptStrategy().identify(modify_file)
self.test_files['ut_files'] += OpStrategy().identify(modify_file)
self.test_files['ut_files'] += DirectoryMappingStrategy().identify(modify_file)
self.test_files['op_ut_files'] += OpStrategy().identify(modify_file)
self.test_files['ut_files'] += CoreTestStrategy().identify(modify_file)
unique_files = sorted(set(self.test_files['ut_files']))
exist_ut_file = [
changed_file
for changed_file in unique_files
if Path(changed_file).exists()
]
self.test_files['ut_files'] = exist_ut_file
self.exclude_test_files(slow_files=SLOW_TEST_BLOCKLIST)
def load_core_ut(self):
self.test_files['ut_files'] += [str(i) for i in (BASE_DIR / 'test/npu').rglob('test_*.py')]
def load_distributed_ut(self):
self.test_files['ut_files'] += [str(i) for i in (BASE_DIR / 'test/distributed').rglob('test_*.py')]
def load_op_plugin_ut(self):
version_path = get_test_torch_version_path()
file_hash = {}
for file_path in (BASE_DIR / 'third_party/op-plugin/test').rglob('test_*.py'):
if str(file_path.parts[-2]) in [version_path, "test_custom_ops", "test_base_ops"]:
file_name = str(file_path.name)
if file_name in file_hash:
if str(file_path.parts[-2]) == version_path:
self.test_files['ut_files'].remove(file_hash[file_name])
file_hash[file_name] = str(file_path)
self.test_files['ut_files'].append(str(file_path))
else:
file_hash[file_name] = str(file_path)
self.test_files['ut_files'].append(str(file_path))
def load_all_ut(self, include_distributed_case=False, include_op_plugin_case=False):
all_files = [str(i) for i in (BASE_DIR / 'test').rglob('test_*.py') if 'distributed' not in str(i)]
self.test_files['ut_files'] = all_files
if include_distributed_case:
self.load_distributed_ut()
if include_op_plugin_case:
if os.path.exists(BASE_DIR / 'third_party/op-plugin/test'):
self.load_op_plugin_ut()
else:
raise Exception("The path of op-plugin did not exist, check whether it had been pulled.")
def split_test_files(self, rank, world_size):
if rank > world_size:
raise Exception(f'rank {rank} is greater than world_size {world_size}')
def ordered_split(files, start, step):
return sorted(files)[start::step] if files else []
# node rank starts from 1
self.test_files['ut_files'] = ordered_split(self.test_files['ut_files'], rank - 1, world_size)
self.test_files['op_ut_files'] = ordered_split(self.test_files['op_ut_files'], rank - 1, world_size)
def exclude_test_files(self, slow_files=None, not_run_files=None, mode="slow_test"):
"""
Args:
slow_files: slow test files.
not_run_files: not_run_directly test files.
mode: "slow_test" or "not_run_directly". Default: "slow_test".
Returns:
"""
def remove_test_files(key):
block_list = not_run_files.keys() if mode == "not_run_directly" else slow_files
for test_name in block_list:
test_files_copy = self.test_files.get(key, [])[:]
for test_file in test_files_copy:
is_remove = False
if mode == "slow_test" and test_name + ".py" in test_file:
print(f'Excluding slow test: {test_name}')
is_remove = True
if mode == "not_run_directly":
# remove not run directly files
is_folder_in = not test_name.endswith(".py") and "/" + test_name + "/" in test_file
is_file_in = test_name.endswith(".py") and test_name in test_file
if is_folder_in or is_file_in:
if test_name in ["jit"] and re.search("|".join(INCLUDE_FILES), test_file):
continue
is_remove = True
# add instead file
instead_files.add(str(TEST_DIR.joinpath(not_run_files[test_name])))
if is_remove:
test_files = self.test_files.get(key, [])
if test_file in test_files:
test_files.remove(test_file)
for test_files_key in self.test_files.keys():
instead_files = set()
remove_test_files(test_files_key)
for instead_file in instead_files:
if instead_file not in self.test_files[test_files_key]:
self.test_files[test_files_key].append(instead_file)
def get_test_files(self):
return self.test_files
def print_modify_files(self):
print("modify files:")
for modify_file in self.modify_files:
print(modify_file)
def print_ut_files(self):
print("ut files:")
for ut_file in self.test_files.get('ut_files', []):
print(ut_file)
def print_op_ut_files(self):
print("op ut files:")
for op_ut_file in self.test_files.get('op_ut_files', []):
print(op_ut_file)
-149
View File
@@ -1,149 +0,0 @@
# -*- coding: UTF-8 -*-
import os
import sys
import subprocess
import threading
import queue
import argparse
from pathlib import Path
import random
import psutil
from access_control import (
TestMgr,
BASE_DIR, TEST_DIR, SLOW_TEST_BLOCKLIST, NOT_RUN_DIRECTLY, EXEC_TIMEOUT, NETWORK_OPS_DIR
)
def exec_ut(files):
"""
执行单元测试文件,其中存在失败,则标识异常并打印相关信息
"""
def get_op_name(ut_file):
op_name = str(ut_file.split('/')[-1].split('.')[0])
return op_name[5:] if op_name.startswith("test_") else op_name
def get_ut_name(ut_file):
if 'op-plugin' in str(Path(ut_file)):
return str(Path(ut_file).relative_to(NETWORK_OPS_DIR))[:-3]
return str(Path(ut_file).relative_to(TEST_DIR))[:-3]
def get_ut_cmd(ut_type, ut_file):
cmd = [sys.executable, "run_test.py", "-v"]
if ut_type == "op_ut_files":
# do not skip ops related test entries
return cmd + ["-e"] + SLOW_TEST_BLOCKLIST[1:] + ["-i", "test_ops", "--", "-k", "_" + get_op_name(ut_file)]
if 'op-plugin' in str(Path(ut_file)):
cmd = [sys.executable, NETWORK_OPS_DIR / "run_test.py", "-v"]
return cmd + ["-i", get_ut_name(ut_file)]
def wait_thread(process, event_timer):
process.wait()
event_timer.set()
def enqueue_output(out, log_queue):
for line in iter(out.readline, b''):
log_queue.put(line.decode('utf-8'))
out.close()
return
def start_thread(fn, *args):
stdout_t = threading.Thread(target=fn, args=args)
stdout_t.daemon = True
stdout_t.start()
def print_subprocess_log(log_queue):
while not log_queue.empty():
print((log_queue.get()).strip())
def run_cmd_with_timeout(cmd):
os.chdir(str(TEST_DIR))
stdout_queue = queue.Queue()
event_timer = threading.Event()
p = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
start_thread(wait_thread, p, event_timer)
start_thread(enqueue_output, p.stdout, stdout_queue)
try:
event_timer.wait(EXEC_TIMEOUT)
ret = p.poll()
if ret:
print_subprocess_log(stdout_queue)
if not event_timer.is_set():
ret = 1
parent_process = psutil.Process(p.pid)
for children_process in parent_process.children(recursive=True):
children_process.kill()
p.kill()
p.terminate()
print("Timeout: Command '{}' timed out after {} seconds".format(" ".join(cmd), EXEC_TIMEOUT))
print_subprocess_log(stdout_queue)
except Exception as err:
ret = 1
print(err)
return ret
def run_tests(test_files):
test_infos = []
has_failed = 0
init_method = random.randint(1, 2)
for ut_type, ut_files in test_files.items():
for ut_file in ut_files:
cmd = get_ut_cmd(ut_type, ut_file)
ut_info = str(cmd[-1])
if ut_type == "op_ut_files":
ut_info = "test_ops " + ut_info
else:
cmd = cmd if 'op-plugin' in str(Path(ut_file)) else cmd + ["--init_method={}".format(init_method)]
ret = run_cmd_with_timeout(cmd)
if ret:
has_failed = ret
test_infos.append("exec ut {} failed.".format(ut_info))
else:
test_infos.append("exec ut {} success.".format(ut_info))
init_method = 2 if init_method == 1 else 1
return has_failed, test_infos
ret_status, exec_infos = run_tests(files)
print("***** Total result:")
for exec_info in exec_infos:
print(exec_info)
return ret_status
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Control needed ut cases')
parser.add_argument('--all', action="store_true", help='Run all testcases')
parser.add_argument('--distributed', action="store_true", help='Run distributed testcases')
parser.add_argument('--rank', default=0, type=int, help='Index of current ut nodes')
parser.add_argument('--world_size', default=0, type=int, help='Number of ut nodes')
parser.add_argument('--network_ops', action="store_true", help='Run network_ops testcases in the op-plugin repo')
options = parser.parse_args()
print(f"options: {options}")
cur_modify_files = str(BASE_DIR / 'modify_files.txt')
test_mgr = TestMgr()
if options.all:
test_mgr.load_all_ut(options.distributed, options.network_ops)
elif options.distributed:
test_mgr.load_distributed_ut()
elif os.path.exists(cur_modify_files):
test_mgr.load(cur_modify_files, world_size=options.world_size)
test_mgr.analyze()
else:
test_mgr.load_core_ut()
test_mgr.exclude_test_files(not_run_files=NOT_RUN_DIRECTLY, mode="not_run_directly")
if options.rank > 0 and options.world_size > 0:
test_mgr.split_test_files(options.rank, options.world_size)
cur_test_files = test_mgr.get_test_files()
test_mgr.print_modify_files()
test_mgr.print_ut_files()
test_mgr.print_op_ut_files()
ret_ut = exec_ut(cur_test_files)
sys.exit(ret_ut)
-114
View File
@@ -1,114 +0,0 @@
#!/bin/bash
set -e
CUR_DIR=$(dirname $(readlink -f $0))
SUPPORTED_PY_VERSION=(3.8 3.9 3.10 3.11)
PY_VERSION='3.8' # Default supported python version is 3.8
# Parse arguments inside script
function parse_script_args() {
local args_num=0
if [[ "x${1}" = "x" ]]; then
# default: bash build.sh (python3.8)
return 0
fi
args_num=$#
while true; do
case "${1}" in
--python=*)
PY_VERSION=$(echo "${1}"|cut -d"=" -f2)
args_num=$((args_num-1))
shift
;;
--disable_torchair)
export DISABLE_INSTALL_TORCHAIR=TRUE
args_num=$((args_num-1))
shift
;;
--disable_rpc)
export DISABLE_RPC_FRAMEWORK=TRUE
args_num=$((args_num-1))
shift
;;
--enable_lto)
export ENABLE_LTO=TRUE
args_num=$((args_num-1))
shift
;;
--enable_pgo=*)
pgo_mode=$(echo "${1}"|cut -d"=" -f2)
case $pgo_mode in
1)
export PGO_MODE=1
args_num=$((args_num-1))
;;
2)
export PGO_MODE=2
args_num=$((args_num-1))
;;
*)
echo "ERROR Unsupported parameters: ${1}"
return 1
;;
esac
shift
;;
-*)
echo "ERROR Unsupported parameters: ${1}"
return 1
;;
*)
if [ "x${1}" != "x" ]; then
echo "ERROR Unsupported parameters: ${1}"
return 1
fi
break
;;
esac
done
# if some "--param=value" are not parsed correctly, throw an error.
if [[ ${args_num} -ne 0 ]]; then
return 1
fi
}
function check_python_version() {
matched_py_version='false'
for ver in ${SUPPORTED_PY_VERSION[*]}; do
if [ "${PY_VERSION}" = "${ver}" ]; then
matched_py_version='true'
return 0
fi
done
if [ "${matched_py_version}" = 'false' ]; then
echo "${PY_VERSION} is an unsupported python version, we suggest ${SUPPORTED_PY_VERSION[*]}"
exit 1
fi
}
function main()
{
if ! parse_script_args "$@"; then
echo "Failed to parse script args. Please check your inputs."
exit 1
fi
check_python_version
cd ${CUR_DIR}/..
# if you add or delete file/files in the project, you need to remove the following comment
# make clean
python"${PY_VERSION}" setup.py build bdist_wheel
if [ $? != 0 ]; then
echo "Failed to compile the wheel file. Please check the source code by yourself."
exit 1
fi
exit 0
}
main "$@"
-54
View File
@@ -1,54 +0,0 @@
FROM quay.io/pypa/manylinux2014_aarch64:2023-10-07-c1e05d1
# Set pip
RUN cd /usr/local/bin \
&& ln -s /opt/_internal/cpython-3.7.17/bin/pip3.7 pip3.7 \
&& ln -s /opt/_internal/cpython-3.8.18/bin/pip3.8 pip3.8 \
&& ln -s /opt/_internal/cpython-3.9.18/bin/pip3.9 pip3.9 \
&& ln -s /opt/_internal/cpython-3.10.13/bin/pip3.10 pip3.10 \
&& ln -s /opt/_internal/cpython-3.11.6/bin/pip3.11 pip3.11 \
&& ln -s python3.8 python3
# Set pip source
RUN mkdir /root/.pip \
&& echo "[global]" > /root/.pip/pip.conf \
&& echo "index-url=https://mirrors.huaweicloud.com/repository/pypi/simple" >> /root/.pip/pip.conf \
&& echo "trusted-host=repo.huaweicloud.com" >> /root/.pip/pip.conf \
&& echo "timeout=120" >> /root/.pip/pip.conf
ARG CONFIG_FOR_LCOV=0
RUN if [ "$CONFIG_FOR_LCOV" = "1" ]; then \
mkdir -p /etc/yum.repos.d/backup && \
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/ && \
curl -o /etc/yum.repos.d/Centos7-aliyun.repo https://mirrors.wlnmp.com/centos/Centos7-aliyun-altarch.repo -k && \
yum clean all && \
yum makecache; \
fi
RUN if [ "$CONFIG_FOR_LCOV" = "1" ]; then \
yum install -y perl-Module-Load-Conditional && \
yum install -y perl-Digest-MD5 && \
yum install -y "perl(DateTime)" && \
yum install -y perl-CPAN*; \
fi
# Install pip package(build)
RUN pip3.8 install pyyaml \
&& pip3.8 install torch==2.3.1 \
&& pip3.8 install numpy==1.21.3
RUN pip3.9 install pyyaml \
&& pip3.9 install torch==2.3.1 \
&& pip3.9 install numpy==1.21.3
RUN pip3.10 install pyyaml \
&& pip3.10 install torch==2.3.1 \
&& pip3.10 install numpy==1.21.3
RUN pip3.11 install pyyaml \
&& pip3.11 install torch==2.3.1 \
&& pip3.11 install numpy==1.23.2
WORKDIR /home
-37
View File
@@ -1,37 +0,0 @@
## Ascend Pytorch Dockerfile Repository
This folder hosts the `Dockerfile` to build docker images with various platforms.
### Build torch_npu from Docker container
**Clone torch-npu**
```Shell
git clone https://gitee.com/ascend/pytorch.git --depth 1
```
**Build docker image**
```Shell
cd pytorch/ci/docker/{arch} # {arch} for X86 or ARM
docker build -t manylinux-builder:v1 .
```
If you want to configure the environment of LCOV, please build docker image like this:
```Shell
cd pytorch/ci/docker/{arch} # {arch} for X86 or ARM
docker build -t manylinux-builder:v1 --build-arg CONFIG_FOR_LCOV=1 .
```
**Enter docker Container**
```Shell
docker run -it -v /{code_path}/pytorch:/home/pytorch manylinux-builder:v1 bash
# {code_path} is the torch_npu source code path
```
**Compile torch_npu**
Take Python 3.8 as an example
```Shell
cd /home/pytorch
bash ci/build.sh --python=3.8
```
-59
View File
@@ -1,59 +0,0 @@
FROM pytorch/manylinux-builder:cpu-2.1
# Install python
RUN cd /usr/local/bin \
&& ln -s /opt/_internal/cpython-3.7.5/bin/pip3.7 pip3.7 \
&& ln -s /opt/_internal/cpython-3.8.1/bin/pip3.8 pip3.8 \
&& ln -s /opt/_internal/cpython-3.9.0/bin/pip3.9 pip3.9 \
&& ln -s /opt/_internal/cpython-3.10.1/bin/pip3.10 pip3.10 \
&& ln -s /opt/_internal/cpython-3.11.0/bin/pip3.11 pip3.11 \
&& ln -s /opt/_internal/cpython-3.7.5/bin/python3.7 python3.7 \
&& ln -s /opt/_internal/cpython-3.8.1/bin/python3.8 python3.8 \
&& ln -s /opt/_internal/cpython-3.9.0/bin/python3.9 python3.9 \
&& ln -s /opt/_internal/cpython-3.10.1/bin/python3.10 python3.10 \
&& ln -s /opt/_internal/cpython-3.11.0/bin/python3.11 python3.11 \
&& ln -s python3.8 python3
# Set pip source
RUN mkdir /root/.pip \
&& echo "[global]" > /root/.pip/pip.conf \
&& echo "index-url=https://mirrors.huaweicloud.com/repository/pypi/simple" >> /root/.pip/pip.conf \
&& echo "trusted-host=repo.huaweicloud.com" >> /root/.pip/pip.conf \
&& echo "timeout=120" >> /root/.pip/pip.conf
ARG CONFIG_FOR_LCOV=0
RUN if [ "$CONFIG_FOR_LCOV" = "1" ]; then \
mkdir -p /etc/yum.repos.d/backup && \
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/ && \
curl -o /etc/yum.repos.d/Centos7-aliyun.repo https://mirrors.wlnmp.com/centos/Centos7-aliyun-altarch.repo -k && \
yum clean all && \
yum makecache; \
fi
RUN if [ "$CONFIG_FOR_LCOV" = "1" ]; then \
yum install -y perl-Module-Load-Conditional && \
yum install -y perl-Digest-MD5 && \
yum install -y "perl(DateTime)" && \
yum install -y perl-CPAN*; \
fi
# Install pip package(build)
RUN pip3.8 install pyyaml \
&& pip3.8 install torch==2.3.1+cpu --index-url https://download.pytorch.org/whl/cpu \
&& pip3.8 install numpy==1.21.3
RUN pip3.9 install pyyaml \
&& pip3.9 install torch==2.3.1+cpu --index-url https://download.pytorch.org/whl/cpu \
&& pip3.9 install numpy==1.21.3
RUN pip3.10 install pyyaml \
&& pip3.10 install torch==2.3.1+cpu --index-url https://download.pytorch.org/whl/cpu \
&& pip3.10 install numpy==1.21.3
RUN pip3.11 install pyyaml \
&& pip3.11 install torch==2.3.1+cpu --index-url https://download.pytorch.org/whl/cpu \
&& pip3.11 install numpy==1.23.2
WORKDIR /home
-33
View File
@@ -1,33 +0,0 @@
#!/bin/bash
py_execute=${1-python3}
CUR_DIR=$(dirname $(readlink -f $0))
cd ${CUR_DIR}/../examples/libtorch_resnet
if [ -f ./resnet_model.pt ]; then
rm ./resnet_model.pt
fi
$py_execute resnet_trace.py
if [ $? != 0 ]; then
echo "Failed to trace resnet model."
exit 1
fi
if [ -d "build" ]; then
rm -rf ./build
fi
mkdir build && cd build && \
cmake -DCMAKE_PREFIX_PATH=`$py_execute -c 'import torch;print(torch.utils.cmake_prefix_path)'` .. && \
make && ./libtorch_resnet ../resnet_model.pt > out.log
if grep -q "resnet_model run success!" out.log; then
echo "Success."
exit 0
else
echo "Failed."
exit 1
fi
-31
View File
@@ -1,31 +0,0 @@
include(FindPackageHandleStandardArgs)
if(DEFINED ENV{TORCH_NPU_INSTALL_PREFIX})
set(TORCH_NPU_INSTALL_PREFIX $ENV{TORCH_NPU_INSTALL_PREFIX})
else()
# Assume we are in <install-prefix>/share/cmake/Torch_npu/Torch_npuConfig.cmake
get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(TORCH_NPU_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
endif()
# Include directories.
if(EXISTS "${TORCH_NPU_INSTALL_PREFIX}/include")
set(TORCH_NPU_INCLUDE_DIRS
${TORCH_NPU_INSTALL_PREFIX}/include)
else()
set(TORCH_NPU_INCLUDE_DIRS
${TORCH_NPU_INSTALL_PREFIX}/include)
endif()
# Library dependencies.
find_library(TORCH_NPU_LIBRARY torch_npu PATHS "${TORCH_NPU_INSTALL_PREFIX}/lib")
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(TORCH_NPU_CXX_FALGS "-D_GLIBCXX_USE_CXX11_ABI=@GLIBCXX_USE_CXX11_ABI@")
endif()
include_directories(${TORCH_NPU_INCLUDE_DIRS})
set(TORCH_NPU_LIBRARIES ${TORCH_NPU_LIBRARY})
find_package_handle_standard_args(Torch_npu DEFAULT_MSG TORCH_NPU_LIBRARY TORCH_NPU_INCLUDE_DIRS)
-27
View File
@@ -1,27 +0,0 @@
import os
import stat
import torchgen.gen
from codegen.utils import PathManager
def _write_if_changed_security(self, filename: str, contents: str) -> None:
old_contents: Optional[str]
filepath = os.path.realpath(filename)
try:
with open(filepath, 'r') as f:
old_contents = f.read()
except IOError:
old_contents = None
if contents != old_contents:
PathManager.remove_path_safety(filepath)
with os.fdopen(os.open(filepath, os.O_RDWR | os.O_CREAT, stat.S_IWUSR | stat.S_IRUSR), "w") as f:
f.write(contents)
os.chmod(filepath, stat.S_IRUSR | stat.S_IEXEC | stat.S_IRGRP | stat.S_IXGRP)
def apply_codegen_patches():
torchgen.gen.FileManager._write_if_changed = _write_if_changed_security
apply_codegen_patches()
-47
View File
@@ -1,47 +0,0 @@
import re
from typing import List, Dict
import torchgen.gen
from torchgen.code_template import CodeTemplate
from torchgen.api.autograd import NativeFunctionWithDifferentiabilityInfo, DifferentiabilityInfo
from torchgen.packaged.autograd.gen_inplace_or_view_type import gen_inplace_or_view_type_env
from torchgen.packaged.autograd.gen_autograd_functions import process_function
from codegen.gen_backend_stubs import parse_native_and_custom_yaml
from codegen.utils import CUSTOM_YAML_NAME
def parse_native_and_custom_yaml_(*args, **kwargs):
return parse_native_and_custom_yaml(*args, **kwargs, custom_path=f'./torch_npu/csrc/aten/{CUSTOM_YAML_NAME}')
def gen_inplace_or_view_type_env_for_npu(
fn: NativeFunctionWithDifferentiabilityInfo,
) -> Dict[str, List[str]]:
gen_code = gen_inplace_or_view_type_env(fn)
if len(gen_code['inplace_or_view_method_definitions']):
gen_code['ops_headers'] = []
method_definitions = re.sub(pattern=r"at::_ops::(\w+)::redispatch",
repl=r'at_npu::redispatch::\1',
string=gen_code['inplace_or_view_method_definitions'][0])
gen_code['inplace_or_view_method_definitions'] = [method_definitions]
return gen_code
# A temporary solution, due to op coupling, temporarily removing symint
def process_function_(info: DifferentiabilityInfo, template: CodeTemplate) -> str:
function_codegen = process_function(info, template)
if '_symint' in function_codegen:
function_codegen = function_codegen.replace('_symint', '')
return function_codegen
def apply_autograd_patches():
torchgen.gen.parse_native_yaml = parse_native_and_custom_yaml_
torchgen.packaged.autograd.gen_inplace_or_view_type.gen_inplace_or_view_type_env = \
gen_inplace_or_view_type_env_for_npu
torchgen.packaged.autograd.gen_autograd_functions.process_function = process_function_
apply_autograd_patches()
-93
View File
@@ -1,93 +0,0 @@
"""
To run this file by hand from the root of the PyTorch
repository, run:
python -m codegen.autograd.gen_autograd \
--npu_native_function_dir="./torch_npu/csrc/aten/npu_native_functions.yaml" \
--out_dir=$OUTPUT_DIR \
--autograd_dir="./codegen/autograd/"
Where $OUTPUT_DIR is where you would like the files to be
generated. In the full build system, OUTPUT_DIR is
torch_npu/csrc/aten/
"""
# gen_autograd.py generates C++ autograd functions and Python bindings.
#
# It delegates to the following scripts:
# gen_variable_type.py: generates VariableType.h which contains all tensor methods
import argparse
import os
from torchgen.packaged.autograd.gen_inplace_or_view_type import gen_inplace_or_view_type
from torchgen.packaged.autograd.gen_autograd_functions import gen_autograd_functions_lib
from codegen.utils import get_torchgen_dir, gen_custom_yaml_path
from .gen_variable_type import (
gen_variable_type, gen_variable_type_head
)
from .gen_variable_factories import gen_variable_factories
from .gen_autograd_functions import gen_autograd_functions_python
from .utils import parse_derivatives, filt_npu_autograd_functions
def gen_autograd(
native_functions_path: str,
tags_path: str,
out: str,
autograd_dir: str,
npu_native_functions_path: str
) -> None:
npu_native_functions_path = gen_custom_yaml_path(npu_native_functions_path)
differentiability_infos, native_funcs, funcs_with_diff_infos =\
parse_derivatives(native_functions_path, tags_path, autograd_dir, npu_native_functions_path)
npu_funcs_with_diff_infos, _, _ = filt_npu_autograd_functions(native_functions_path, funcs_with_diff_infos)
template_path = os.path.join(autograd_dir, 'templates')
torch_template_path = os.path.join(get_torchgen_dir(), 'packaged/autograd/templates')
# Generate VariableType.cpp
gen_variable_type(out, funcs_with_diff_infos, template_path)
# Generate VariableType.h
gen_variable_type_head(out, funcs_with_diff_infos, template_path)
# Generate ADInplaceOrViewType.cpp
gen_inplace_or_view_type(out, native_functions_path, tags_path, npu_funcs_with_diff_infos, template_path)
# Generate Functions.h/cpp
gen_autograd_functions_lib(out, differentiability_infos, template_path)
# Generate variable_factories.h
gen_variable_factories(out, torch_template_path, native_funcs)
# Generate python_functions.h/cpp
gen_autograd_functions_python(out, differentiability_infos, template_path)
def main() -> None:
parser = argparse.ArgumentParser(
description='Generate autograd C++ files script')
parser.add_argument('--out_dir', metavar='OUT',
help='path to output directory')
parser.add_argument('--autograd_dir', metavar='AUTOGRAD',
help='path to autograd directory')
parser.add_argument('--npu_native_function_dir',
help='path to npu_native_functions.yaml')
args = parser.parse_args()
torchgen_path = get_torchgen_dir()
tags_yaml_path = os.path.join(torchgen_path, 'packaged/ATen/native/tags.yaml')
native_yaml_path = os.path.join(torchgen_path, 'packaged/ATen/native/native_functions.yaml')
gen_autograd(native_yaml_path,
tags_yaml_path,
args.out_dir,
args.autograd_dir,
args.npu_native_function_dir)
if __name__ == '__main__':
main()
@@ -1,63 +0,0 @@
# Generates C++ autograd functions for the derivatives of ATen operations
#
# This writes two files:
# python_functions.h/cpp: Python bindings for subclasses of autograd::Node
from typing import Dict
from torchgen.api.autograd import DifferentiabilityInfo
from torchgen.model import FunctionSchema
from torchgen.utils import FileManager
from torchgen.gen import FileManager
from torchgen.packaged.autograd.gen_autograd_functions import (
process_function,
get_infos_with_derivatives_list,
PY_FUNCTION_DEFINITION,
PY_FUNCTION_PROPS_AND_GETTERS
)
def gen_autograd_functions_python(
out: str,
differentiability_infos: Dict[FunctionSchema, Dict[str, DifferentiabilityInfo]],
template_path: str,
) -> None:
fm = FileManager(install_dir=out, template_dir=template_path, dry_run=False)
num_shards = 2
fm.write(
"python_functions.h",
lambda: {
"generated_comment":
f"@ generated from {fm.template_dir_for_comments()}/python_functions.h",
"shard_forward_declare": [
f"void initialize_autogenerated_functions_{i}(PyObject* module);"
for i in range(num_shards)
],
"shard_call": [
f"initialize_autogenerated_functions_{i}(module);"
for i in range(num_shards)
],
},
)
# get a 1D list of diffinfos, we do not need them to be per FunctionSchema/DispatchKey here
# infos with the diff dispatchkeys but the same name will still be in the same shard.
infos = get_infos_with_derivatives_list(differentiability_infos)
fm.write_sharded(
"python_functions.cpp",
infos,
key_fn=lambda info: info.name,
base_env={
"generated_comment":
f"@ generated from {fm.template_dir_for_comments()}/python_functions.cpp",
},
env_callable=lambda info: {
"py_function_initializers": [
process_function(info, PY_FUNCTION_DEFINITION)
],
"py_function_props_and_getters": [
process_function(info, PY_FUNCTION_PROPS_AND_GETTERS)
],
},
num_shards=num_shards,
sharded_keys={"py_function_initializers", "py_function_props_and_getters"},
)
@@ -1,27 +0,0 @@
# Generates C++ functions that wrap ATen tensor factory methods to turn them into Variables.
#
# This writes one file: variable_factories.h
from torchgen.gen import FileManager
from torchgen.utils import mapMaybe
from torchgen.packaged.autograd.gen_variable_factories import (
process_function,
is_factory_function,
)
from .utils import NPU_AUTOGRAD_FUNCTION
def gen_variable_factories(
out: str,
template_path: str,
native_functions: list
) -> None:
factory_functions = [fn for fn in native_functions if
(is_factory_function(fn) and fn.func.name.name.base in NPU_AUTOGRAD_FUNCTION)]
fm = FileManager(install_dir=out, template_dir=template_path, dry_run=False)
fm.write_with_template('variable_factories.h', 'variable_factories.h', lambda: {
'generated_comment': '@' + f'generated from {fm.template_dir}/variable_factories.h',
'ops_headers': [f'#include <ATen/ops/{fn.root_name}.h>' for fn in factory_functions],
'function_definitions': list(mapMaybe(process_function, factory_functions)),
})
-135
View File
@@ -1,135 +0,0 @@
# Generates VariableType.h/cpp
#
#If you need any guidance, please refer to the comments in derivatives.yaml in PyTorch.
#
import re
from typing import List
from torchgen.api.autograd import NativeFunctionWithDifferentiabilityInfo
from torchgen.api import cpp
from torchgen.code_template import CodeTemplate
from torchgen.context import native_function_manager
from torchgen.gen import FileManager
from torchgen.packaged.autograd.gen_inplace_or_view_type import (
use_derived, METHOD_DEFINITION, gen_formals,
)
from torchgen.packaged.autograd.gen_trace_type import type_wrapper_name
from torchgen.packaged.autograd.gen_variable_type import (
emit_body, gen_wrapper_registration, GRADIENT_IMPLEMENTED_FOR_COMPLEX
)
from .utils import NPU_AUTOGRAD_FUNCTION
GRADIENT_IMPLEMENTED_FOR_COMPLEX.update((
"stft",
"npu_dtype_cast",
))
NPU_NATIVEFUNCTIONS = {'npu_format_cast', '_npu_format_cast'}
try_jit_decomposition_pattern = (r'if \(\(.*?\)\) \{.*?static c10::OperatorName full_name\("aten::.*?", .*?\);\n.*?'
r'return impl::run_jit_decomposition_with_args_for_jvp<.*?>'
r'\(".*?", \*opt_op, ks, .*?\);\n\s*\} '
r'else \{\n\s*(.*?)\n\s*\}')
use_count_pattern = (r'if \(\S+\.has_storage\(\) && !at::impl::dispatch_mode_enabled\(\) && '
r'!at::impl::tensor_has_dispatch\(\S+\)\) {\s+TORCH_INTERNAL_ASSERT\('
r'\S+\.storage\(\)\.use_count\(\) == 1, "function: \S+"\);\s+}')
METHOD_HEADER_DEFINITION = CodeTemplate("""\
${return_type} ${type_wrapper_name}(${formals});
""")
def gen_variable_type(
out: str,
fns_with_diff_infos: List[NativeFunctionWithDifferentiabilityInfo],
template_path: str,
) -> None:
"""Generate VariableType.cpp body
Generate variable type definition for torch and npu method here.
"""
fm = FileManager(install_dir=out, template_dir=template_path, dry_run=False)
fm.write_sharded(
'VariableType.cpp',
[fn for fn in fns_with_diff_infos if use_derived(fn)],
key_fn=lambda fn: cpp.name(fn.func.func),
base_env={
'generated_comment':
"@" f'generated from {template_path}/VariableType.cpp',
},
env_callable=gen_variable_type_func,
num_shards=1,
sharded_keys={'type_derived_method_definitions', 'wrapper_registrations_aten', 'wrapper_registrations_npu'}
)
def gen_variable_type_head(
out: str,
fns_with_diff_infos: List[NativeFunctionWithDifferentiabilityInfo],
template_path: str,
) -> None:
"""Generate VariableType.h body
"""
fm = FileManager(install_dir=out, template_dir=template_path, dry_run=False)
fm.write_with_template('VariableType.h', 'VariableType.h', lambda: {
'generated_comment': "@" f'generated from {template_path}/VariableType.h',
'npu_variable_type': gen_variable_type_header(fns_with_diff_infos)
})
def gen_variable_type_header(
fns_with_diff_infos: List[NativeFunctionWithDifferentiabilityInfo]
) -> List[str]:
variable_type_header: List[str] = []
for fn in fns_with_diff_infos:
f = fn.func
with native_function_manager(f):
formals = gen_formals(f)
wrapper_name = type_wrapper_name(f)
name = str(fn.func.func.name)
if name in NPU_AUTOGRAD_FUNCTION:
type_header_definition = METHOD_HEADER_DEFINITION.substitute(
return_type=cpp.returns_type(f.func.returns).cpp_type(),
type_wrapper_name=wrapper_name,
formals=formals,
)
variable_type_header.append(type_header_definition)
return variable_type_header
def gen_variable_type_func(
fn: NativeFunctionWithDifferentiabilityInfo
) -> str:
f = fn.func
result = {}
with native_function_manager(f):
formals = gen_formals(f)
type_definition = METHOD_DEFINITION.substitute(
return_type=cpp.returns_type(f.func.returns).cpp_type(),
type_wrapper_name=type_wrapper_name(f),
type_definition_body=emit_body(fn, "Default"),
formals=formals,
)
type_definition = re.sub(try_jit_decomposition_pattern, r"\1", type_definition, flags=re.DOTALL)
type_definition = re.sub(use_count_pattern, "", type_definition, flags=re.DOTALL)
if str(f.func.name) in NPU_AUTOGRAD_FUNCTION:
if f.func.is_out_fn():
type_definition = re.sub(r'at::redispatch::(\w+)_outf', r'at_npu::redispatch::\1_out', type_definition)
else:
type_definition = type_definition.replace('at::redispatch', 'at_npu::redispatch')
wrapper_registration = gen_wrapper_registration(f, "Default")
result[f"type_derived_method_definitions"] = [type_definition]
if str(f.func.name) in NPU_AUTOGRAD_FUNCTION:
result[f"wrapper_registrations_aten"] = []
result[f"wrapper_registrations_npu"] = [wrapper_registration]
else:
result[f"wrapper_registrations_aten"] = [wrapper_registration]
result[f"wrapper_registrations_npu"] = []
return result
@@ -1,31 +0,0 @@
#define TORCH_ASSERT_ONLY_METHOD_OPERATORS
#include "torch/csrc/autograd/VariableTypeUtils.h"
#include <torch/library.h>
#include "torch_npu/csrc/aten/CustomRedispatch.h"
// ${generated_comment}
$ops_headers
using namespace at;
using torch::autograd::CreationMeta;
using torch::autograd::as_view;
using torch::autograd::increment_version;
namespace at_npu {
namespace ADInplaceOrView {
namespace {
${inplace_or_view_method_definitions}
} // namespace
} // namespace ADInplaceOrView
namespace {
TORCH_LIBRARY_IMPL(npu, ADInplaceOrView, m) {
${inplace_or_view_wrapper_registrations};
}
} // namespace
} // namespace at_npu
-24
View File
@@ -1,24 +0,0 @@
#include <torch/csrc/dynamo/compiled_autograd.h>
#include "torch_npu/csrc/framework/autograd/FunctionsManual.h"
#include "torch_npu/csrc/aten/CustomFunctions.h"
// ${generated_comment}
// The manual function definitions that used to be here are now in torch/csrc/autograd/FunctionsManual.cpp
// This speeds up re-compilation and allow to share these implementations so that they can be
// used for forward mode AD formulas as well.
using namespace at_npu::autograd::generated::details;
using namespace at_npu::native::custom_ops;
using at::Tensor;
using at::Scalar;
using at::IntArrayRef;
using at::TensorList;
namespace at_npu { namespace autograd { namespace generated {
${autograd_function_definitions}
}}} // namespace at_npu::autograd::generated
-67
View File
@@ -1,67 +0,0 @@
#pragma once
// ${generated_comment}
#include <ATen/ATen.h>
#include <ATen/core/functional.h>
#include <ATen/TensorGeometry.h>
#include <torch/csrc/autograd/function.h>
#include <torch/csrc/autograd/variable.h>
#include <torch/csrc/autograd/saved_variable.h>
#include <torch/csrc/Export.h>
#include <c10/core/SymIntArrayRef.h>
using namespace torch::autograd;
namespace at_npu { namespace autograd { namespace generated {
using at::Scalar;
using at::Tensor;
using at::IntArrayRef;
using at::ArrayRef;
using at::Type;
using at::TensorGeometry;
using at::ScalarType;
using c10::optional;
using c10::fmap;
inline std::vector<Tensor> unpack_list(at::ArrayRef<SavedVariable> xs, std::shared_ptr<Node> saved_for = nullptr)
{
// NB: we must explicitly do the conversion in the lambda, otherwise template
// deduction will give a Tensor of Variable which is not convertible
return fmap(xs, [&saved_for](const SavedVariable& x) {
return static_cast<Tensor>(x.unpack(saved_for));
});
}
inline c10::List<c10::optional<Tensor>> unpack_opt_list(at::ArrayRef<SavedVariable> xs, std::shared_ptr<Node> saved_for = nullptr)
{
torch::List<c10::optional<Tensor>> result;
result.reserve(xs.size());
for (const SavedVariable& v : xs) {
auto var = v.unpack(saved_for);
result.push_back(var.defined() ? c10::optional<Tensor>(var) : c10::nullopt);
}
return result;
}
struct TypeAndSize {
TypeAndSize() : options(at::TensorOptions()) {}
/* implicit */
TypeAndSize(const Tensor & t)
: sizes(t.sizes().vec())
, options(t.options()) {}
Tensor zeros() { return at::zeros(sizes, options); }
private:
std::vector<int64_t> sizes;
at::TensorOptions options;
};
${autograd_function_declarations}
}}} // namespace at_npu::autograd::generated
@@ -1,69 +0,0 @@
#include <torch/csrc/autograd/VariableTypeUtils.h>
#include <c10/core/impl/TorchDispatchModeTLS.h>
#include <ATen/core/TorchDispatchUtils.h>
#include <ATen/SparseCsrTensorUtils.h>
#include <ATen/RedispatchFunctions.h>
#include <torch/library.h>
#include "torch_npu/csrc/aten/NPUNativeFunctions.h"
#include "torch_npu/csrc/aten/VariableType.h"
#include "torch_npu/csrc/framework/autograd/FunctionsManual.h"
#include "torch_npu/csrc/aten/CustomRedispatch.h"
// ${generated_comment}
// NOTE [Sharded File]: on this file's split-into-shards state
//
// Back in the good old days, VariableType.cpp was generated as one
// file with every function in it, and everything was great and
// simple.
//
// However, this file was also very large (over 36,000 lines), and
// compiling it was very slow, and in fact was a significant
// bottleneck for incremental rebuilds. To address this, we now
// generate the file split across multiple shards, named
// VariableType_0.cpp and so on, which can be compiled in parallel.
//
// For ease of inspection and debugging, so that it's not necessary to
// go rooting around in multiple files, we also generate all the
// functions together in VariableTypeEverything.cpp. This generated
// file is only for convenience; it's not actually used in the
// build. If the file you're looking at now is one of the shards, you
// may want to switch over to the Everything variant to make you
// grepping smoother.
using namespace at;
using namespace at_npu::autograd::generated;
using namespace at_npu::autograd::generated::details;
namespace at_npu { namespace autograd {
namespace VariableType {
namespace {
C10_UNUSED void reset_grad_accumulator(Variable & self) {
AutogradMeta* meta = torch::autograd::impl::get_autograd_meta(self);
if (meta != nullptr) {
meta->grad_accumulator_.reset();
}
}
}
${type_derived_method_definitions}
} // namespace VariableType
namespace {
TORCH_LIBRARY_IMPL(aten, AutogradPrivateUse1, m) {
${wrapper_registrations_aten}
}
TORCH_LIBRARY_IMPL(npu, AutogradPrivateUse1, m) {
${wrapper_registrations_npu}
}
}
}} // namespace at_npu::autograd
-58
View File
@@ -1,58 +0,0 @@
#pragma once
// ${generated_comment}
#include <cstdint> // for size_t
#include <functional> // for function
#include <memory> // for unique_ptr
#include <string>
#include <vector>
#include <ATen/core/Tensor.h>
#include <ATen/Context.h>
#include <c10/util/intrusive_ptr.h>
#include <torch/csrc/Export.h>
#include <torch/csrc/autograd/autograd_not_implemented_fallback.h>
namespace at {
struct Quantizer;
};
namespace at_npu { namespace autograd {
using Variable = at::Tensor;
using at::Context;
using at::Device;
using at::Dimname;
using at::DimnameList;
using at::Generator;
using at::IntArrayRef;
using at::MemoryFormat;
using at::QScheme;
using at::Scalar;
using at::ScalarType;
using at::Storage;
using at::Tensor;
using at::TensorList;
using at::TensorOptions;
using at::Quantizer;
// This is temporary typedef to enable Quantizer in aten native function API
// we'll remove them when we are actually exposing Quantizer class
// to frontend
using ConstQuantizerPtr = const c10::intrusive_ptr<Quantizer>&;
using c10::optional;
namespace VariableType {
TORCH_API std::vector<at::DeprecatedTypeProperties*> allCPUTypes();
at::Tensor& unpack(Tensor& t, const char* name, int pos);
const at::Tensor& unpack(const Tensor& t, const char* name, int pos);
at::Tensor unpack_opt(const Tensor& t, const char* name, int pos);
std::vector<at::Tensor> unpack(at::TensorList tl, const char *name, int pos);
${npu_variable_type}
};
}} // namespace at_npu::autograd
@@ -1,46 +0,0 @@
#ifndef BUILD_LIBTORCH
#include <torch/csrc/autograd/generated/python_functions.h>
// ${generated_comment}
#include <Python.h>
#include <ATen/ATen.h>
#include <c10/core/SymNodeImpl.h>
#include <torch/csrc/autograd/generated/Functions.h>
#include <torch/csrc/autograd/python_cpp_function.h>
#include <torch/csrc/autograd/python_variable.h>
#include <torch/csrc/autograd/saved_variable.h>
#include <torch/csrc/utils/pybind.h>
#include <pybind11/pybind11.h>
#include <torch/csrc/utils/pybind.h>
#include "torch_npu/csrc/aten/Functions.h"
// NOTE: See [Sharded File] comment in VariableType
namespace at_npu {
namespace autograd {
namespace generated {
template <typename C>
static void addClass(PyObject *module, PyTypeObject &type, const char *name,
PyGetSetDef *function_properties = NULL,
PyMethodDef *function_methods = NULL)
{
_initFunctionPyTypeObject(type, name, function_properties, function_methods);
Py_INCREF(&type);
PyModule_AddObject(module, name, (PyObject *)&type);
registerCppFunction(typeid(C), &type);
}
${py_function_props_and_getters}
void initialize_autogenerated_functions${shard_id}(PyObject *module)
{
${py_function_initializers}
}
}
}
} // namespace at_npu::autograd::generated
#endif
@@ -1,24 +0,0 @@
#ifndef BUILD_LIBTORCH
#pragma once
#include <Python.h>
// ${generated_comment}
// Python bindings for automatically generated autograd functions
namespace at_npu {
namespace autograd {
namespace generated {
${shard_forward_declare}
inline void initialize_autogenerated_functions(PyObject *module)
{
${shard_call}
}
}
}
} // namespace at_npu::autograd::generated
#endif
-97
View File
@@ -1,97 +0,0 @@
from pathlib import Path
from typing import List, Dict
import yaml
from torchgen.model import NativeFunction, FunctionSchema
from torchgen.api.autograd import (
match_differentiability_info, NativeFunctionWithDifferentiabilityInfo,
DifferentiabilityInfo
)
from torchgen.packaged.autograd.load_derivatives import load_derivatives
from codegen.utils import get_torchgen_dir, CUSTOM_YAML_NAME, PathManager
from codegen.gen_backend_stubs import parse_native_and_custom_yaml
AUTOGRAD_BLACK_LIST = {'npu_format_cast.Tensor', 'npu_format_cast_', 'npu_format_cast_.acl_format'}
torch_npu_root = Path(__file__).parent.parent.parent
PathManager.check_directory_path_readable(torch_npu_root / "version.txt")
with open(torch_npu_root / "version.txt") as version_f:
version = version_f.read().strip()
VERSION_PART = version.split('.')
def parse_derivatives(
native_functions_path: str,
tags_path: str,
autograd_dir: str,
npu_native_functions_path: str
):
derivatives_path = str(Path(autograd_dir).parents[1].joinpath(
f'third_party/op-plugin/op_plugin/config/v{VERSION_PART[0]}r{VERSION_PART[1]}/derivatives.yaml'
))
differentiability_infos, _ = load_derivatives(
derivatives_path, native_functions_path, tags_path)
native_funcs = parse_native_and_custom_yaml(native_functions_path,
tags_path, npu_native_functions_path).native_functions
funcs = filte_out_native_autograd_function(native_funcs, differentiability_infos)
funcs_with_diff_infos: List[NativeFunctionWithDifferentiabilityInfo] = []
funcs_with_diff_infos = match_differentiability_info(funcs, differentiability_infos)
filt_funcs_with_diff_infos = [f for f in funcs_with_diff_infos if str(f.func.func.name) not in AUTOGRAD_BLACK_LIST]
return (differentiability_infos, native_funcs, filt_funcs_with_diff_infos)
def filt_npu_autograd_functions(
native_functions_path: str,
funcs_with_diff_infos: List[NativeFunctionWithDifferentiabilityInfo]
):
npu_funcs_with_diff_infos: List[NativeFunctionWithDifferentiabilityInfo] = []
torch_functions = set()
PathManager.check_directory_path_readable(native_functions_path)
with open(native_functions_path, 'r') as f:
es = yaml.safe_load(f)
for e in es:
torch_functions.add(e.get('func').split('(')[0])
npu_autograd_functions = set()
torch_derivatives_functions = set()
for f in funcs_with_diff_infos:
name = str(f.func.func.name)
# f.info is differentiabilityinfo. Existence of variants ops with a differentiabilityinfo of none.
if f.info and name not in torch_functions:
npu_funcs_with_diff_infos.append(f)
npu_autograd_functions.add(name)
if f.info and name in torch_functions:
torch_derivatives_functions.add(name)
return npu_funcs_with_diff_infos, npu_autograd_functions, torch_derivatives_functions
def filte_out_native_autograd_function(
native_funcs: List[NativeFunction],
differentiability_infos: Dict[FunctionSchema, Dict[str, DifferentiabilityInfo]],
):
result: List[NativeFunction] = []
derivatives_name_list: List[str] = []
for diffinfo_dict in differentiability_infos.values():
for info in diffinfo_dict.values():
derivatives_name_list.append(str(info.func.func.name))
for funcs in native_funcs:
func_name = str(funcs.func.name)
func_base_name = str(funcs.func.name.name.base)
if (func_name in derivatives_name_list) or (func_base_name in derivatives_name_list):
result.append(funcs)
return result
_, NPU_AUTOGRAD_FUNCTION, TORCH_AUTOGRAD_FUNCTION = filt_npu_autograd_functions(
str(Path(get_torchgen_dir()).joinpath('packaged/ATen/native/native_functions.yaml')),
parse_derivatives(
str(Path(get_torchgen_dir()).joinpath('packaged/ATen/native/native_functions.yaml')),
str(Path(get_torchgen_dir()).joinpath('packaged/ATen/native/tags.yaml')),
str(Path(__file__).parent),
str(Path(__file__).parents[2].joinpath(f'torch_npu/csrc/aten/{CUSTOM_YAML_NAME}')))[-1]
)
-106
View File
@@ -1,106 +0,0 @@
"""
This file is mainly used to transform failed test names into DecorateInfo Object.
"""
from pathlib import Path
import os
import yaml
from torchgen.code_template import CodeTemplate
from torchgen.gen import FileManager
from codegen.autograd.utils import VERSION_PART
from codegen.utils import PathManager
project_path = Path(os.path.dirname(__file__)).parent
op_plugin_info_path = os.path.realpath(os.path.join(
project_path,
f'third_party/op-plugin/test/test_v{VERSION_PART[0]}r{VERSION_PART[1]}_ops',
"unsupported_ops_info.yaml"))
torch_npu_info_path = os.path.realpath(os.path.join(project_path, "test", "unsupported_ops_info.yaml"))
unsupported_dict_path = op_plugin_info_path if os.path.exists(op_plugin_info_path) else torch_npu_info_path
PathManager.check_directory_path_readable(unsupported_dict_path)
with open(unsupported_dict_path, "r") as f:
unsupported_summary_dict = yaml.safe_load(f)
skip_list = dict()
#class2test is a mapping from test class to test names. As is shown in test_ops.py.
class2test = {
"TestCommon":[
"test_compare_cpu",
"test_dtypes",
"test_errors",
"test_multiple_devices",
"test_non_standard_bool_values",
"test_noncontiguous_samples",
"test_numpy_ref",
"test_out",
"test_out_integral_dtype",
"test_out_warning",
"test_pointwise_tag_coverage",
"test_variant_consistency_eager",
"test_complex_half_reference_testing"
],
"TestCompositeCompliance":[
"test_backward",
"test_forward_ad",
"test_operator",
],
"TestMathBits":[
"test_conj_view",
"test_neg_conj_view",
"test_neg_view",
],
"TestFakeTensor":[
"test_fake",
"test_fake_autocast",
"test_fake_crossref_backward_amp",
"test_fake_crossref_backward_no_amp",
"test_pointwise_ops",
],
"TestTags":["test_tags"]
}
def get_class_name(func_name):
for key, value in class2test.items():
if func_name in value:
return key
raise RuntimeError("Can't find corresponding class name of test: {}".format(func_name))
#There are two kinds of templates. One is with Dtype Info, the other is without.
def update_skip_list(class_name, op_name, func_name, dtype):
skip_reason = "npu test skipped!"
template = f"""\nDecorateInfo(unittest.skip("{skip_reason}"), \'{class_name}\', \'{func_name}\', dtypes=(torch.{dtype},))"""
template_ = f"""\nDecorateInfo(unittest.skip("{skip_reason}"), \'{class_name}\', \'{func_name}\')"""
if dtype:
if op_name not in skip_list:
skip_list[op_name] = [template]
else:
skip_list[op_name].append(template)
else:
if op_name not in skip_list:
skip_list[op_name] = [template_]
else:
skip_list[op_name].append(template_)
def gen_ops_info(summary_dict):
for op_name in summary_dict:
for func_name in summary_dict[op_name]:
for dtype in summary_dict[op_name][func_name]:
update_skip_list(get_class_name(func_name), op_name, func_name, dtype)
skip_template = CodeTemplate(
"""\n'${op_name}': [${decorators}]"""
)
fm = FileManager(os.path.join("torch_npu", "testing"), os.path.join("codegen", "templates"), False)
fm.write_with_template(f"_npu_testing_utils.py", "npu_testing_utils.py", lambda:{
"skip_detail": [skip_template.substitute(op_name=op, decorators=doc) for op, doc in skip_list.items()]
})
if __name__ == "__main__":
gen_ops_info(unsupported_summary_dict)
-327
View File
@@ -1,327 +0,0 @@
import re
import itertools
from collections import namedtuple, defaultdict
from dataclasses import dataclass, field
from typing import List, Dict, Sequence
from torchgen.code_template import CodeTemplate
from torchgen.gen import (parse_tags_yaml, FileManager, cpp_string, error_check_native_functions)
from torchgen.model import (BackendIndex, DispatchKey, Variant,
NativeFunction, OperatorName, BackendMetadata, TensorOptionsArguments)
from torchgen.utils import concatMap, mapMaybe
from torchgen.context import with_native_function, native_function_manager, method_with_native_function
from torchgen.api.types import DispatcherSignature
from torchgen.api import cpp
from torchgen.dest.register_dispatch_key import RegisterDispatchKey
from codegen.utils import (enable_opplugin, is_op_valid, field_tag, get_opplugin_wrap_name, parse_npu_yaml)
# Parse native_functions.yaml into a sequence of NativeFunctions and Backend Indices.
ParsedYaml = namedtuple('ParsedYaml', ['native_functions', 'backend_indices'])
CUSTOM_FUNCTIONS_DECLARATION = CodeTemplate("""\
${return_type} ${func_name}(${args_str});
""")
CUSTOM_FUNCTIONS_DEFINITION = CodeTemplate("""\
${return_type} ${func_name}(${args_str}) {
static auto op = c10::Dispatcher::singleton().findSchemaOrThrow("npu::${base_name}", "${overload}").typed<${schema}>();
return op.${func_type}(${args_exprs_str});
}
""")
SKIP_PYTHON_BINDINGS_SIGNATURES = []
@with_native_function
def should_generate_ops_patch(f: NativeFunction) -> bool:
func_signature = str(f.func)
for pattern in SKIP_PYTHON_BINDINGS_SIGNATURES:
if pattern == func_signature:
return False
return True
def parse_custom_yaml(custom_path: str, tag_path: str) -> ParsedYaml:
valid_tags = parse_tags_yaml(tag_path)
rs: List[NativeFunction] = []
bs: Dict[DispatchKey, Dict[OperatorName, BackendMetadata]] = defaultdict(dict)
# Filter the custom native yaml file, and extract the functions we defined.
source_es = parse_npu_yaml(custom_path)
custom_es = source_es.get('custom', []) + source_es.get('custom_autograd', [])
custom_es = field_tag(custom_es)
for e_with_vars in custom_es:
func, m = NativeFunction.from_yaml(e_with_vars, "Location", valid_tags)
func.variants.discard(Variant.method)
rs.append(func)
BackendIndex.grow_index(bs, m)
error_check_native_functions(rs)
# Default dict is to prevent the codegen from barfing when we have a dispatch key that has no kernels yet.
indices: Dict[DispatchKey, BackendIndex] = defaultdict(lambda: BackendIndex(
dispatch_key=DispatchKey.Undefined, use_out_as_primary=True, external=False, index={}))
for k, v in bs.items():
# All structured in-tree operators are implemented in terms of their out operator.
indices[k] = BackendIndex(dispatch_key=k,
use_out_as_primary=True,
external=False,
device_guard=False,
index=v)
return ParsedYaml(rs, indices)
METHOD_DEFINITION = CodeTemplate("""\
${return_type} ${name}(${args_str}) {
${unpack_out}
${unsafe_tensor_check}
${device_check}
${device_guard}
${type_definition_body}
}
""")
TRACE_DISPATCH = CodeTemplate("""\
return ${impl_name}(${args_exprs_str});""")
@with_native_function
def compute_op_definition(f: NativeFunction):
out_num = len(f.func.arguments.out)
sig = DispatcherSignature.from_schema(f.func, prefix=f'wrapper_{f.func.name.overload_name}_')
name = sig.name()
args = sig.arguments()
args_str = ', '.join(a.defn() for a in args)
args_exprs_str = ', '.join(a.name for a in args)
impl_name = f"at_npu::native::NPUNativeFunctions::{cpp.name(f.func)}"
if enable_opplugin() and is_op_valid(str(f.func.name)):
impl_name = f"op_plugin::{get_opplugin_wrap_name(f)}"
check_out = [f'TORCH_CHECK(out.size() == {out_num}, "expected tuple of {out_num} elements but got ", out.size(), '
f'OPS_ERROR(ErrCode::PARAM));']
unpack_out = check_out + [f'at::Tensor {args[-out_num + i].name} = out[{i}];' for i in range(out_num)] \
if out_num > 1 else ''
out_return_type = '::std::tuple<{}>'.format(', '.join(['at::Tensor'] * out_num))
has_tensor_options = any(
isinstance(a, TensorOptionsArguments)
for a in f.func.arguments.non_out
)
# There is precedence for which argument we use to do
# device guard. This describes the precedence order.
self_arg = (
[f.func.arguments.self_arg.argument]
if f.func.arguments.self_arg is not None
else []
)
candidate_args = itertools.chain(
self_arg,
f.func.arguments.out,
f.func.arguments.flat_positional,
)
candidate_tensor_args = []
for a in candidate_args:
if a.type.is_tensor_like():
candidate_tensor_args.append(f"{a.name}")
unsafe_tensor_check = """ // No unsafe tensor check"""
if len(candidate_tensor_args) > 0:
unsafe_tensor_check = \
"""if (c10_npu::get_npu_data_unsafe_flag()) {"""
for tensor_arg in candidate_tensor_args:
unsafe_tensor_check = unsafe_tensor_check + f"""
c10_npu::check_npu_tensor_is_safe({tensor_arg});"""
unsafe_tensor_check = unsafe_tensor_check + """
}
"""
candidate_args = itertools.chain(
f.func.arguments.out,
f.func.arguments.flat_positional,
f.func.arguments.flat_kwarg_only,
)
device_check = RegisterDispatchKey.gen_device_check(
f.device_check, list(candidate_args), name
)
candidate_args = itertools.chain(
self_arg,
f.func.arguments.out,
f.func.arguments.flat_positional,
)
# Only tensor like arguments are eligible
device_of = next(
(
f"{a.name}"
for a in candidate_args
if a.type.is_tensor_like()
),
None,
)
device_guard = ""
if has_tensor_options and device_of is not None:
device_guard = f"""
c10::OptionalDeviceGuard device_guard(device_of({device_of}));
if (device.has_value()) {{
device_guard.reset_device(device_or_default(device));
}}
"""
elif has_tensor_options:
# kernel is creating a tensor
device_guard = """
const c10::DeviceGuard device_guard(device_or_default(device));"""
elif device_of is not None:
# kernel is operating on existing tensors
device_guard = f"const c10::OptionalDeviceGuard device_guard(device_of({device_of}));"
return [METHOD_DEFINITION.substitute(
return_type=out_return_type if out_num > 1 else cpp.returns_type(f.func.returns).cpp_type(),
name=name,
args_str=','.join(a.defn() for a in args[:-out_num]) + ', at::TensorList out' if out_num > 1 else args_str,
unpack_out=unpack_out,
unsafe_tensor_check=unsafe_tensor_check,
device_check=device_check,
device_guard=device_guard,
type_definition_body=[TRACE_DISPATCH.substitute(impl_name=impl_name, args_exprs_str=args_exprs_str)]
)]
@dataclass(frozen=True)
class RegisterCustomSchema:
known_tags: Dict[str, int] = field(default_factory=dict)
@method_with_native_function
def __call__(self, f: NativeFunction):
out_num = len(f.func.arguments.out)
if out_num > 1:
decl = re.compile(r"(?P<name>[^\(]+)\((?P<args>.*)\) -> (?P<returns>.*)").findall(str(f.func))[0]
func_schema = decl[0] + '(' + ','.join(decl[1].split(',')[:-out_num]) + ', Tensor[] out) -> (' + ', '.join(
['Tensor'] * out_num) + ')'
else:
func_schema = str(f.func)
tags = "{" + ", ".join(f"at::Tag::{tag}" for tag in sorted(f.tags)) + "}"
maybe_tags = ""
if tags not in self.known_tags:
idx = len(self.known_tags)
self.known_tags[tags] = idx
maybe_tags = f"const std::vector<at::Tag> tags_{idx} = {tags};\n"
tag_index = f", tags_{self.known_tags[tags]}"
if tags == "{}":
tag_index = ""
pattern = r'\bself\b(?=[,\)])'
func_schema = re.sub(pattern, 'input', func_schema)
if f.has_composite_explicit_autograd_kernel:
name = DispatcherSignature.from_schema(f.func, prefix=f'wrapper_{f.func.name.overload_name}_').name()
return f'{maybe_tags}m.def({cpp_string(func_schema)}, TORCH_FN(at_npu::native::{name}){tag_index});\n'
else:
return f'{maybe_tags}m.def({cpp_string(func_schema)}{tag_index});\n'
@with_native_function
def compute_register_impl(f: NativeFunction):
if f.has_composite_explicit_autograd_kernel:
return []
else:
name = DispatcherSignature.from_schema(f.func, prefix=f'wrapper_{f.func.name.overload_name}_').name()
return [f'm.impl("{f.func.name}", TORCH_FN(at_npu::native::{name}));\n']
def gen_custom_trace(fm: FileManager, custom_trace_functions: Sequence[NativeFunction]):
fm.write_with_template(f'CustomRegisterSchema.cpp', 'CustomRegisterSchema.cpp', lambda: {
'custom_op_definitions': list(concatMap(
lambda f: compute_op_definition(f),
custom_trace_functions
)),
'custom_schema_registrations': list(mapMaybe(
RegisterCustomSchema(),
custom_trace_functions
)),
'custom_impl_registrations': list(concatMap(
lambda f: compute_register_impl(f),
custom_trace_functions
)),
})
def gen_custom_ops_patch(fm: FileManager, custom_trace_functions: Sequence[NativeFunction]):
valid_native_functions = list(filter(should_generate_ops_patch, custom_trace_functions))
fm.write_with_template(f'custom_ops.py', 'custom_ops.py', lambda: {
'custom_ops': [f'torch_npu.{ops} = torch.ops.npu.{ops}'
for ops in set([f.func.name.name for f in valid_native_functions])],
})
def compute_custom_functions_declaration(f: NativeFunction, func_type: str):
with native_function_manager(f):
sig = DispatcherSignature.from_schema(f.func)
name = sig.name()
args = sig.arguments()
if func_type == 'call':
args_str = ', '.join(a.decl() for a in args)
if func_type == 'redispatch':
args_str = 'c10::DispatchKeySet dispatchKeySet, ' + ', '.join(a.decl() for a in args)
return [CUSTOM_FUNCTIONS_DECLARATION.substitute(
return_type=cpp.returns_type(f.func.returns).cpp_type(),
func_name=name,
args_str=args_str,)]
def compute_custom_functions_definition(f: NativeFunction, func_type: str):
with native_function_manager(f):
sig = DispatcherSignature.from_schema(f.func)
name = sig.name()
args = sig.arguments()
if func_type == 'call':
args_str = ', '.join(a.defn() for a in args)
args_exprs_str = ', '.join(a.name for a in args)
if func_type == 'redispatch':
args_str = 'c10::DispatchKeySet dispatchKeySet, ' + ', '.join(a.defn() for a in args)
args_exprs_str = 'dispatchKeySet, ' + ', '.join(a.name for a in args)
return [CUSTOM_FUNCTIONS_DEFINITION.substitute(
return_type=cpp.returns_type(f.func.returns).cpp_type(),
base_name=f.func.name.name,
func_name=name,
overload=f.func.name.overload_name,
args_str=args_str,
func_type=func_type,
schema=sig.type(),
args_exprs_str=args_exprs_str,)]
def gen_custom_functions_dispatch(
fm: FileManager,
custom_functions: Sequence[NativeFunction]
) -> None:
func_type_list = ['call', 'redispatch']
file_name_list = ['CustomFunctions', 'CustomRedispatch']
for func_type, file_name in zip(func_type_list, file_name_list):
fm.write_with_template(
f'{file_name}.h', f'{file_name}.h', lambda:{
'custom_function_declarations':list(concatMap(
lambda f: compute_custom_functions_declaration(f, func_type),
custom_functions
))}
)
fm.write_with_template(
f'{file_name}.cpp', f'{file_name}.cpp', lambda:{
'custom_function_definitions':list(concatMap(
lambda f: compute_custom_functions_definition(f, func_type),
custom_functions
))}
)
-783
View File
@@ -1,783 +0,0 @@
# Copyright (c) 2020 Huawei Technologies Co., Ltd
# Copyright (c) 2019, Facebook CORPORATION.
# All rights reserved.
#
# Licensed under the BSD 3-Clause License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://opensource.org/licenses/BSD-3-Clause
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pathlib
import argparse
import os
import stat
import re
from collections import namedtuple, Counter, defaultdict
from typing import List, Dict, Union, Sequence, Optional, Set, Callable
import yaml
from torchgen.code_template import CodeTemplate
from torchgen.gen import (parse_tags_yaml, FileManager, parse_native_yaml,
get_grouped_native_functions, error_check_native_functions)
from torchgen.model import (BackendIndex, DispatchKey,
NativeFunction, NativeFunctionsGroup, OperatorName,
BackendMetadata, is_cuda_dispatch_key)
from torchgen.native_function_generation import add_generated_native_functions
from torchgen.selective_build.selector import SelectiveBuilder
from torchgen.utils import Target, concatMap, context, NamespaceHelper
import torchgen.dest as dest
import torchgen.api.dispatcher as dispatcher
import torchgen.api.native as native
from torchgen.api.cpp import JIT_TO_CPP_DEFAULT
from torchgen.gen_backend_stubs import gen_dispatchkey_nativefunc_headers
from codegen.gen_functionalization_type import gen_functionalization_definition, gen_functionalization_registration
from codegen.utils import (get_torchgen_dir, rename_privateuse1_dispatch_key, gen_unstructured, add_header_to_template_file,
get_grouped_native_functions_optional_out, parse_npu_yaml, get_opplugin_wrap_name,
get_target_functions, merge_custom_yaml, field_tag, gen_custom_yaml_path,
update_opapi_info, is_opapi, update_internal_format_opapi_info, PathManager, filt_exposed_api, get_target_native_registration,
NativeFunctionsGroupOptionalOut, gen_device_check, filt_compositeimplicitautograd_api,
DEVICE_NOCHECK_SET)
from codegen.custom_functions import (parse_custom_yaml, gen_custom_trace, gen_custom_ops_patch,
gen_custom_functions_dispatch)
# Create backend_indices map for func retrieval with the key of each func we supported.
def create_backend_index(backend_ops: List[str],
symint_ops: Set[str],
dispatch_key: DispatchKey,
native_funcs_map: Dict[OperatorName, NativeFunction],
cpp_namespace: str,
) -> BackendIndex:
metadata: Dict[OperatorName, BackendMetadata] = {}
for op in backend_ops:
op_name = OperatorName.parse(op)
if op_name not in native_funcs_map:
raise KeyError(f"Found an invalid operator name: {op_name}")
# See Note [External Backends Follow Dispatcher API]
kernel_name = dispatcher.name(native_funcs_map[op_name].func)
if op in symint_ops:
kernel_name += "_symint"
m = BackendMetadata(kernel=kernel_name, structured=False, cpp_namespace=cpp_namespace)
metadata[op_name] = m
return BackendIndex(
dispatch_key=dispatch_key,
use_out_as_primary=False,
external=True,
device_guard=True,
index=metadata)
# Check whether the function is placed at the wrong place.
def check_grouped_native_functions(
backend_key: DispatchKey,
autograd_key: DispatchKey,
backend_indices: Dict[DispatchKey, BackendIndex],
grouped_native_functions: Sequence[Union[NativeFunction, NativeFunctionsGroup]]):
for g in grouped_native_functions:
if isinstance(g, NativeFunction):
forward_kernels = [] if backend_key is None else \
[m for m in [backend_indices[backend_key].get_kernel(g)] if m is not None]
backward_kernels = [] if autograd_key is None else \
[m for m in [backend_indices[autograd_key].get_kernel(g)] if m is not None]
else:
if backend_key is None:
forward_kernels = []
else:
forward_kernels = []
for f in g.functions():
kernel = backend_indices[backend_key].get_kernel(f)
if kernel is not None:
forward_kernels.append(kernel)
if autograd_key is None:
backward_kernels = []
else:
backward_kernels = []
for f in g.functions():
kernel = backend_indices[autograd_key].get_kernel(f)
if kernel is not None:
backward_kernels.append(kernel)
forward_kernels = [f for f in forward_kernels if f is not None]
backward_kernels = [f for f in backward_kernels if f is not None]
if len(forward_kernels) != 0 and len(backward_kernels) != 0:
raise ValueError(f'Currently, all variants of an op must either be registered to a backend key, \
or to a backend\'s autograd key. They cannot be mix and matched. If this is \
something you need, feel free to create an issue! {forward_kernels[0].kernel} \
is listed under "supported", but {backward_kernels[0].kernel} is listed under "autograd".')
_GLOBAL_PARSE_NATIVE_YAML_CACHE = {}
# Parse native_functions.yaml into a sequence of NativeFunctions and Backend Indices.
ParsedYaml = namedtuple('ParsedYaml', ['native_functions', 'backend_indices'])
def modify_func_in_native_yaml(func: str) -> str:
# func_to_modify: {old_value: new_value}
func_to_modify = {"matmul_backward(Tensor grad, Tensor self, Tensor other, bool[2] mask) -> (Tensor, Tensor)":
"matmul_backward(Tensor grad_out, Tensor self, Tensor other, bool[2] mask) -> (Tensor, Tensor)"}
if func in func_to_modify:
return func_to_modify[func]
return func
def parse_native_and_custom_yaml(path: str, tag_path: str, custom_path: str) -> ParsedYaml:
global _GLOBAL_PARSE_NATIVE_YAML_CACHE
if path not in _GLOBAL_PARSE_NATIVE_YAML_CACHE:
valid_tags = parse_tags_yaml(tag_path)
PathManager.check_directory_path_readable(path)
with open(path, 'r') as f:
es = yaml.safe_load(f)
if not isinstance(es, list):
raise TypeError("es is not list")
rs: List[NativeFunction] = []
bs: Dict[DispatchKey, Dict[OperatorName, BackendMetadata]] = defaultdict(dict)
for e in es:
e["func"] = modify_func_in_native_yaml(e["func"])
func, m = NativeFunction.from_yaml(e, "Location", valid_tags)
rs.append(func)
BackendIndex.grow_index(bs, m)
source_es = parse_npu_yaml(custom_path)
custom_es = source_es.get('custom', []) + source_es.get('custom_autograd', [])
supported_es = source_es.get('supported', []) + source_es.get('autograd', []) + custom_es
for es in supported_es:
update_opapi_info(es)
update_internal_format_opapi_info(es)
custom_es = field_tag(custom_es)
for e in custom_es:
func, m = NativeFunction.from_yaml(e, "Location", valid_tags)
rs.append(func)
BackendIndex.grow_index(bs, m)
error_check_native_functions(rs)
# Default dict is to prevent the codegen from barfing when we have a dispatch key that has no kernels yet.
indices: Dict[DispatchKey, BackendIndex] = defaultdict(lambda: BackendIndex(
dispatch_key=DispatchKey.Undefined,
use_out_as_primary=True,
device_guard=True,
external=False,
index={}))
add_generated_native_functions(rs, bs)
for k, v in bs.items():
# All structured in-tree operators are implemented in terms of their out operator.
indices[k] = BackendIndex(dispatch_key=k,
use_out_as_primary=True,
external=False,
device_guard=is_cuda_dispatch_key(k),
index=v)
_GLOBAL_PARSE_NATIVE_YAML_CACHE[path] = ParsedYaml(rs, indices)
return _GLOBAL_PARSE_NATIVE_YAML_CACHE[path]
# Parses the external backend's yaml, and adds a new BackendIndex for the backend's dispatch key.
# Returns a Tuple of (true_backend, backend_key, autograd_key, cpp_namespace, updated BackendIndex mapping)
ParsedExternalYaml = namedtuple('ParsedExternalYaml', [
'true_backend', 'backend_key', 'autograd_key', 'cpp_namespace', 'backend_indices'])
def parse_backend_yaml(
native_yaml_path:str,
backend_yaml_path: str,
grouped_native_functions: Sequence[Union[NativeFunction, NativeFunctionsGroup]],
backend_indices: Dict[DispatchKey, BackendIndex]
) -> ParsedExternalYaml:
native_functions_map = {}
for f in grouped_native_functions:
if isinstance(f, NativeFunction):
native_functions_map[f.func.name] = f
else:
for func in f.functions():
native_functions_map[func.func.name] = func
PathManager.check_directory_path_readable(backend_yaml_path)
with open(backend_yaml_path, 'r') as f:
yaml_values = yaml.safe_load(f)
if not isinstance(yaml_values, dict):
raise TypeError("yaml_values is not dict")
valid_keys = ['backend', 'cpp_namespace', 'supported', 'autograd', 'custom', 'custom_autograd', 'symint', 'quant']
yaml_backend = yaml_values.pop('backend', None)
true_backend = 'PrivateUse1' if yaml_backend == 'NPU' else yaml_backend
if true_backend is None:
raise ValueError("You must provide a value for 'backend'")
backend = "NPU"
cpp_namespace = yaml_values.pop('cpp_namespace', None)
if cpp_namespace is None:
raise ValueError("You must provide a value for 'cpp_namespace'")
supported = yaml_values.pop('supported', [])
if supported is None:
supported = [] # Allow an empty list of supported ops
if not isinstance(supported, list):
raise TypeError(f'expected "supported" to be a list, but got type {type(supported)}')
symint = yaml_values.pop("symint", [])
if symint is None:
symint = []
if not (isinstance(symint, list)):
raise RuntimeError(f'expected "symint" to be a list, but got: {supported} (of type {type(supported)})')
symint = [op['func'].split("(")[0] if isinstance(op, Dict) else op for op in symint]
symint_set = set(symint)
supported_autograd = yaml_values.pop('autograd', [])
if not isinstance(supported_autograd, list):
raise TypeError(f'expected "autograd" to be a list, but got: {supported_autograd}')
supported_list = []
for op in supported:
if isinstance(op, Dict) and op.get('device_check', None) == 'NoCheck':
DEVICE_NOCHECK_SET.add(op['func'].split("(")[0])
if isinstance(op, Dict) and ({"impl_ns", "op_api", "device_check"} & set(op.keys())):
supported_list.append(op['func'].split("(")[0])
elif not isinstance(op, Dict):
supported_list.append(op)
supported = supported_list
supported_autograd = [op['func'].split("(")[0] if isinstance(op, Dict) else op for op in supported_autograd]
supported_autograd += filt_compositeimplicitautograd_api(native_yaml_path, supported)
custom = yaml_values.pop('custom', [])
if not isinstance(custom, list):
raise TypeError(f'expected "autograd" to be a list, but got: {custom}')
for item in custom:
try:
supported.append(item['func'][:item['func'].index('(')])
except ValueError as e:
raise Exception(f'Wrong format for function: {item["func"]}') from e
custom_autograd = yaml_values.pop('custom_autograd', [])
if not isinstance(custom_autograd, list):
raise TypeError(f'expected "autograd" to be a list, but got: {custom_autograd}')
for item in custom_autograd:
supported_autograd.append(item['func'][:item['func'].index('(')])
quant = yaml_values.pop('quant', [])
if not isinstance(quant, list):
raise TypeError(f'expected "quant" to be a list, but got: {quant}')
quant = [op['func'].split("(")[0] if isinstance(op, Dict) else op for op in quant]
# custom_supported is only supported for filt expose api, and is not useful here.
yaml_values.pop('custom_supported', [])
if (len(yaml_values.keys()) > 0):
raise KeyError(f'{backend_yaml_path} contains unexpected keys: {", ".join(yaml_values.keys())}. \
Only the following keys are supported: {", ".join(valid_keys)}')
backend_key: Optional[DispatchKey] = None
opapi_key = "OpApi"
if len(supported) > 0:
with context(lambda: f'The provided value for "backend" must be a valid DispatchKey, but got {backend}.'):
backend_key = DispatchKey.parse(backend)
backend_idx = create_backend_index(supported, symint_set, backend_key, native_functions_map, cpp_namespace)
opapi_backend_idx = create_backend_index([op for op in supported if is_opapi(op)],
symint_set, backend_key, native_functions_map, cpp_namespace)
if backend_key in backend_indices:
raise KeyError("backend_key should not be in backend_indices.")
backend_indices[backend_key] = backend_idx
backend_indices[str(backend_key) + opapi_key] = opapi_backend_idx
autograd_key: Optional[DispatchKey] = None
if len(supported_autograd) > 0:
with context(lambda: f'The "autograd" key was specified, which indicates that you would like to override \
the behavior of autograd for some operators on your backend. However "Autograd{backend}" is not a valid DispatchKey.'):
autograd_key = DispatchKey.parse(f'Autograd{backend}')
autograd_idx = create_backend_index(supported_autograd, symint_set,
autograd_key, native_functions_map, cpp_namespace)
opapi_autograd_idx = create_backend_index([op for op in supported_autograd if is_opapi(op)],
symint_set, autograd_key, native_functions_map, cpp_namespace)
if autograd_key in backend_indices:
raise KeyError("autograd_key should not be in backend_indices.")
backend_indices[autograd_key] = autograd_idx
backend_indices[str(autograd_key) + opapi_key] = opapi_autograd_idx
quant_key = "Quantize"
if len(quant) > 0:
quant_idx = create_backend_index(quant, symint_set, backend_key, native_functions_map, cpp_namespace)
if quant_key in backend_indices:
raise KeyError("quant_key should not be in backend_indices.")
backend_indices[str(backend_key) + quant_key] = quant_idx
# check_grouped_native_functions(backend_key, autograd_key, backend_indices, grouped_native_functions)
return ParsedExternalYaml(true_backend, backend_key, autograd_key, cpp_namespace, backend_indices)
def op_plugin_kernel_conut(op_plugin_ops_dir: str):
actual_backend_kernel_name_counts = Counter()
file_path = os.path.join(op_plugin_ops_dir, "OpInterface.h")
PathManager.check_directory_path_readable(file_path)
try:
with open(file_path, 'r') as f:
backend_defns = f.read()
except IOError as e:
raise AssertionError(f'Unable to read from the specified impl_path file: {file_path}') from e
kernel_defn_regex = rf'\w+(?=\()'
actual_backend_kernel_name_counts += Counter(re.findall(kernel_defn_regex, backend_defns))
return actual_backend_kernel_name_counts
def pta_kernel_conut(class_name: str, pta_op_dir: str):
actual_backend_kernel_name_counts = Counter()
for cur_dir, _, filenames in os.walk(pta_op_dir):
for filename in filenames:
if not filename.endswith('.cpp'):
continue
file_path = os.path.join(cur_dir, filename)
PathManager.check_directory_path_readable(file_path)
try:
with open(file_path, 'r') as f:
backend_defns = f.read()
except IOError:
raise AssertionError(f'Unable to read from the specified impl_path file: {file_path}')
kernel_defn_regex = rf'{class_name}::([\w\d]*)\([^\)]*\)\s*{{'
actual_backend_kernel_name_counts += Counter(re.findall(kernel_defn_regex, backend_defns))
return actual_backend_kernel_name_counts
def check_op_plugin_kernels(
native_functions: Sequence[NativeFunction],
expected_kernel_counts: Dict[str, List[NativeFunction]],
actual_kernel_counts: Dict[str, List[NativeFunction]]):
for f in native_functions:
wrap_name = get_opplugin_wrap_name(f)
expect_op_plugin_kernel_count = len(expected_kernel_counts[wrap_name])
if expect_op_plugin_kernel_count > actual_kernel_counts[wrap_name]:
return False
return True
def main() -> None:
parser = argparse.ArgumentParser(description='Generate backend stub files')
parser.add_argument(
'-s',
'--source_yaml',
help='path to source yaml file containing operator external definitions')
parser.add_argument(
'-o', '--output_dir', help='output directory')
parser.add_argument(
'--dry_run', type=bool, default=False, help='output directory')
parser.add_argument(
'--impl_path', type=str, default=None, help='path to the source C++ file containing kernel definitions')
parser.add_argument(
'--op_plugin_impl_path', type=str, default=None,
help='path to the source C++ file containing kernel definitions in op_plugin')
parser.add_argument(
'--op_plugin_yaml_path', type=str, default=None,
help='path to the source yaml file containing kernel definitions in op_plugin')
options = parser.parse_args()
run(options.source_yaml, options.output_dir, options.dry_run,
options.impl_path, options.op_plugin_impl_path, options.op_plugin_yaml_path)
def gen_dispatcher_registrations(
fm: FileManager,
class_name: str,
backend_indices: Dict[DispatchKey, BackendIndex],
grouped_native_functions: Sequence[Union[NativeFunction, NativeFunctionsGroup]],
backend_dispatch_key: DispatchKey,
dispatch_key: DispatchKey,
selector: "SelectiveBuilder",
dispatch_key_name: str,
register_dispatch_key_func: Callable,
native_function_registrations: str = '',
):
backend_index = backend_indices[backend_dispatch_key]
ns_helper = NamespaceHelper(namespace_str="at")
native_func_header = """\
#include "torch_npu/csrc/core/npu/NPURecovery.h"
#ifndef BUILD_LIBTORCH
#include "torch_npu/csrc/profiler/utils.h"
#endif
#include "torch_npu/csrc/aten/NPUNativeFunctions.h"
#include "torch_npu/csrc/framework/interface/EnvVariables.h"
#include "torch_npu/csrc/aten/NPUOpApiNativeFunctions.h"
#include "torch_npu/csrc/framework/FormatHelper.h"
#include "torch_npu/csrc/framework/utils/ForceAclnnList.h"
#include "op_plugin/OpInterface.h"
"""
static_template = CodeTemplate(
"""\
TORCH_LIBRARY_IMPL(aten, $dispatch_key, m) {
$dispatch_registrations_body
};"""
)
static_init_dispatch_registrations = static_template.substitute(
dispatch_key=dispatch_key_name,
dispatch_registrations_body=list(
concatMap(
register_dispatch_key_func(
backend_index,
Target.REGISTRATION,
selector,
rocm=False,
symint=True,
class_method_name=f"{class_name}",
skip_dispatcher_op_registration=False,
),
grouped_native_functions,
)
),
)
fm.write_with_template(f'Register{dispatch_key}.cpp', 'RegisterDispatchKey.cpp', lambda: {
'extra_cuda_headers': '',
'external_backend_headers': native_func_header,
'namespaced_headers': '',
'DispatchKey': dispatch_key,
'dispatch_headers': dest.gen_registration_headers(
backend_index, per_operator_headers=False, rocm=False
),
'ops_headers': '',
'dispatch_definitions': fm.substitute_with_template(
'RegisterDispatchDefinitions.ini',
lambda: {
'ns_prologue': ns_helper.prologue,
'ns_epilogue': ns_helper.epilogue,
'static_init_dispatch_registrations': static_init_dispatch_registrations,
'deferred_dispatch_registrations': '',
'dispatch_helpers': dest.gen_registration_helpers(backend_index),
'dispatch_namespace': dispatch_key.lower(),
'dispatch_namespaced_definitions': native_function_registrations,
'dispatch_anonymous_definitions': list(
concatMap(
register_dispatch_key_func(
backend_index,
Target.ANONYMOUS_DEFINITION,
selector,
rocm=False,
symint=True,
class_method_name=f'{class_name}',
skip_dispatcher_op_registration=False,
),
grouped_native_functions,
)
),
},
).split('\n'),
})
def get_supported_grouped_native_functions(
grouped_native_functions: Sequence[Union[NativeFunction, NativeFunctionsGroup]],
backend_index: BackendIndex,
) -> Sequence[Union[NativeFunction, NativeFunctionsGroup]]:
supported_grouped_native_functions: Sequence[Union[NativeFunction, NativeFunctionsGroup]] = []
for funcs in grouped_native_functions:
if isinstance(funcs, NativeFunctionsGroup) and not backend_index.has_kernel(funcs.out):
for f in funcs.functions():
if backend_index.has_kernel(f):
supported_grouped_native_functions.append(f)
continue
supported_grouped_native_functions.append(funcs)
return supported_grouped_native_functions
def gen_foreach_register(
fm: FileManager,
tags_yaml_path: str,
native_yaml_path: str,
grouped_native_functions: Sequence[Union[NativeFunction, NativeFunctionsGroup]],
backend_indices: BackendIndex,
):
cpu_backend_indices = parse_native_yaml(native_yaml_path, tags_yaml_path).backend_indices[DispatchKey.CPU]
foreach_dict: Dict[str, str] = {}
header_set = set()
def get_foreach_kernel(func: NativeFunction):
schema = func.func.name
if not str(schema).startswith("_foreach"):
return
if schema in cpu_backend_indices.index and schema not in backend_indices.index:
foreach_dict[str(schema)] = cpu_backend_indices.index[schema].kernel
for f in grouped_native_functions:
if isinstance(f, NativeFunctionsGroup):
header_set.add(str(f.signature().name.name.base))
for func in f.functions():
get_foreach_kernel(func)
else:
header_set.add(str(f.func.name.name.base))
get_foreach_kernel(f)
kernel_template = CodeTemplate(
"""\
m.impl("${schema}", TORCH_FN(at::native::${kernel}));"""
)
header_template = CodeTemplate(
"""\
#include <ATen/ops/${function}_native.h>"""
)
fm.write_with_template(f'ForeachRegister.cpp', 'ForeachRegister.cpp', lambda: {
'include_headers': [header_template.substitute(function=h) for h in header_set if h.startswith("_foreach")],
'foreach_kernel': [kernel_template.substitute(schema=kv[0], kernel=kv[1]) for kv in foreach_dict.items()]
})
def gen_quantize_register(
fm: FileManager,
backend_indices: BackendIndex,
):
ns_helper = NamespaceHelper(namespace_str="at")
quantize_dict: Dict[str, str] = {}
for op_name, metadata in backend_indices.index.items():
quantize_dict[op_name] = metadata.kernel
native_func_header = """\
#include <ATen/ops/quantize_per_tensor.h>
#include "op_plugin/OpInterface.h"
"""
static_template = CodeTemplate(
"""\
TORCH_LIBRARY_IMPL(aten, $dispatch_key, m) {
$dispatch_registrations_body
m.impl("q_scale", TORCH_FN(at::native::q_scale_quant));
m.impl("q_per_channel_scales", TORCH_FN(at::native::q_per_channel_scales));
m.impl("q_zero_point", TORCH_FN(at::native::q_zero_point_quant));
m.impl("q_per_channel_zero_points", TORCH_FN(at::native::q_per_channel_zero_points));
m.impl("q_per_channel_axis", TORCH_FN(at::native::q_per_channel_axis));
m.impl("qscheme", TORCH_FN(at::native::qscheme_quant));
};"""
)
kernel_template = CodeTemplate(
"""\
m.impl("${schema}", TORCH_FN(op_plugin::${kernel}));"""
)
static_init_dispatch_registrations = static_template.substitute(
dispatch_key="QuantizedPrivateUse1",
dispatch_registrations_body=[kernel_template.substitute(schema=kv[0], kernel=kv[1]) for kv in quantize_dict.items()]
)
fm.write_with_template(f'QuantizedRegister.cpp', 'RegisterDispatchKey.cpp', lambda: {
'extra_cuda_headers': '',
'external_backend_headers': native_func_header,
'namespaced_headers': '',
'DispatchKey': 'NPU',
'dispatch_headers': '',
'ops_headers': '',
'dispatch_definitions': fm.substitute_with_template(
'RegisterDispatchDefinitions.ini',
lambda: {
'ns_prologue': ns_helper.prologue,
'ns_epilogue': ns_helper.epilogue,
'static_init_dispatch_registrations': static_init_dispatch_registrations,
'deferred_dispatch_registrations': '',
'dispatch_helpers': '',
'dispatch_namespace': '',
'dispatch_namespaced_definitions': '',
'dispatch_anonymous_definitions': '',
},
).split('\n'),
})
def gen_functionalization(fm: FileManager,
selector: "SelectiveBuilder",
grouped_native_functions: Sequence[Union[NativeFunction, NativeFunctionsGroupOptionalOut]],
):
def key_func(
fn: Union[NativeFunction, NativeFunctionsGroupOptionalOut]
) -> str:
return fn.root_name
def functionalization_env_callable(g):
definition = gen_functionalization_definition(selector, g)
register = gen_functionalization_registration(selector, g)
return {
"func_definitions": definition,
"func_registrations": register,
}
fm.write_sharded(
"RegisterFunctionalization.cpp",
grouped_native_functions,
key_fn=key_func,
env_callable=functionalization_env_callable,
num_shards=2,
sharded_keys={
"func_definitions",
"func_registrations",
},
)
return
def gen_target_registration(
target_op_type: str,
dispatch_key: DispatchKey,
backend_indices: Dict[DispatchKey, BackendIndex],
grouped_native_functions: Sequence[Union[NativeFunction, NativeFunctionsGroup]],
op_plugin_yaml_path: str,
fm: FileManager,
selector: "SelectiveBuilder",
native_functions: List[NativeFunction] = None,
):
target_ops = get_target_functions(op_plugin_yaml_path, target_op_type=target_op_type)
target_native_functions = []
for f in grouped_native_functions:
if isinstance(f, NativeFunctionsGroup):
for func in f.functions():
if func.func in target_ops:
target_native_functions.append(func)
elif f.func in target_ops:
target_native_functions.append(f)
metadata: Dict[OperatorName, BackendMetadata] = {}
for op in target_ops:
kernel_name = dispatcher.name(op)
metadata[op.name] = BackendMetadata(kernel=kernel_name, structured=False, cpp_namespace=target_op_type)
backend_indices[dispatch_key] = BackendIndex(
dispatch_key=dispatch_key,
use_out_as_primary=False,
external=True,
device_guard=True,
index=metadata)
native_registration = get_target_native_registration(dispatch_key, backend_indices, metadata, native_functions)
gen_dispatcher_registrations(
fm,
backend_indices[dispatch_key].native_function_class_name(),
backend_indices,
target_native_functions,
dispatch_key,
dispatch_key,
selector,
dispatch_key_name=dispatch_key.name,
register_dispatch_key_func=dest.RegisterDispatchKey,
native_function_registrations=native_registration,
)
def run(source_yaml: str, output_dir: str, dry_run: bool,
impl_path: Optional[str], op_plugin_impl_path: Optional[str], op_plugin_yaml_path: Optional[str]) -> None:
rename_privateuse1_dispatch_key()
torchgen_path = get_torchgen_dir()
template_dir = os.path.join(torchgen_path, "packaged/ATen/templates")
def make_file_manager(install_dir: str) -> FileManager:
return FileManager(install_dir=install_dir, template_dir=template_dir, dry_run=dry_run)
fm = make_file_manager(output_dir)
merge_custom_yaml(source_yaml, op_plugin_yaml_path)
source_yaml = gen_custom_yaml_path(source_yaml)
tags_yaml_path = os.path.join(torchgen_path, 'packaged/ATen/native/tags.yaml')
native_yaml_path = os.path.join(torchgen_path, 'packaged/ATen/native/native_functions.yaml')
parsed_yaml = parse_native_and_custom_yaml(native_yaml_path, tags_yaml_path, source_yaml)
get_target_functions(op_plugin_yaml_path)
native_functions, backend_indices = parsed_yaml.native_functions, parsed_yaml.backend_indices
grouped_native_functions = get_grouped_native_functions(native_functions)
parsed_backend_yaml = parse_backend_yaml(native_yaml_path, source_yaml, grouped_native_functions, backend_indices)
true_backend = parsed_backend_yaml.true_backend
backend_key = parsed_backend_yaml.backend_key
autograd_key = parsed_backend_yaml.autograd_key
cpp_namespace = parsed_backend_yaml.cpp_namespace
backend_indices = parsed_backend_yaml.backend_indices
selector = SelectiveBuilder.get_nop_selector()
if backend_key is not None:
backend_dispatch_key: DispatchKey = backend_key
autograd_dispatch_key: DispatchKey = autograd_key
class_name = backend_indices[backend_dispatch_key].native_function_class_name()
gen_dispatchkey_nativefunc_headers(
fm,
class_name,
cpp_namespace,
backend_indices,
grouped_native_functions,
backend_key,
None,
)
gen_dispatchkey_nativefunc_headers(
fm,
"NPUNativeOpApiFunctions",
cpp_namespace,
backend_indices,
grouped_native_functions,
str(backend_key) + "OpApi",
None,
)
for dispatch_key in [backend_dispatch_key, autograd_dispatch_key]:
if not dispatch_key:
continue
gen_dispatcher_registrations(
fm,
class_name,
backend_indices,
get_supported_grouped_native_functions(grouped_native_functions, backend_indices[dispatch_key]),
dispatch_key,
dispatch_key,
selector,
dispatch_key_name=dispatch_key.name.replace("NPU", true_backend),
register_dispatch_key_func=dest.RegisterDispatchKey,
)
gen_quantize_register(fm, backend_indices["NPUQuantize"])
pta_template_dir = os.path.join(pathlib.Path(__file__).parent.absolute(), "templates")
fm = FileManager(install_dir=output_dir, template_dir=pta_template_dir, dry_run=dry_run)
custom_functions = parse_custom_yaml(source_yaml, tags_yaml_path).native_functions
grouped_custom_functions = get_grouped_native_functions_optional_out(custom_functions)
gen_functionalization(fm, selector, grouped_custom_functions)
gen_custom_trace(fm, custom_functions)
gen_custom_functions_dispatch(fm, custom_functions)
gen_foreach_register(fm,
tags_yaml_path,
native_yaml_path,
grouped_native_functions,
backend_indices[backend_dispatch_key])
custom_ops_patch_dir = os.path.join(output_dir, "../../utils/")
fm = FileManager(install_dir=custom_ops_patch_dir, template_dir=pta_template_dir, dry_run=dry_run)
gen_custom_ops_patch(fm, custom_functions)
filt_exposed_list = filt_exposed_api(source_yaml)
exposed_path = pathlib.Path(__file__).parents[1].joinpath('torch_npu/utils/exposed_api.py')
PathManager.remove_path_safety(exposed_path)
with os.fdopen(os.open(exposed_path, os.O_RDWR | os.O_CREAT, stat.S_IWUSR | stat.S_IRUSR), 'w') as f:
f.write(f'public_npu_functions = {filt_exposed_list}')
os.chmod(exposed_path, stat.S_IRUSR | stat.S_IEXEC | stat.S_IRGRP | stat.S_IXGRP)
fm = make_file_manager(output_dir)
gen_target_registration(
"sparse",
DispatchKey.SparsePrivateUse1,
backend_indices,
grouped_native_functions,
op_plugin_yaml_path,
fm,
selector,
native_functions
)
def apply_torchgen_patch():
dest.RegisterDispatchKey.gen_unstructured = gen_unstructured
dest.RegisterDispatchKey.gen_device_check = gen_device_check
# generate default arguments
JIT_TO_CPP_DEFAULT["contiguous_format"] = "c10::MemoryFormat::Contiguous"
add_header_to_template_file()
dispatcher.arguments = native.arguments
if __name__ == '__main__':
apply_torchgen_patch()
main()
-258
View File
@@ -1,258 +0,0 @@
from typing import List, Union
from torchgen.api import dispatcher
from torchgen.api.translate import translate
from torchgen.api.types import (
DispatcherSignature,
)
from torchgen.context import (
with_native_function,
with_native_function_and,
)
from torchgen.model import (
BaseTy,
BaseType,
NativeFunction,
NativeFunctionsGroup,
SchemaKind
)
from torchgen.selective_build.selector import SelectiveBuilder
from torchgen.gen_functionalization_type import (
wrapper_name,
modifies_arguments,
unwrap_tensor_args,
convert_to_meta_tensors,
get_mutable_redispatch_return_names,
return_str,
maybe_create_output,
return_from_mutable_noop_redispatch,
)
from .utils import NativeFunctionsGroupOptionalOut
def wrap_propagate_mutations_and_return(
f: NativeFunction, functional_op: NativeFunction, inner_return_var: str
) -> str:
mutable_arg_names = f.func.arguments.mutable_arg_names()
(
aliased_outer_rets,
non_aliased_outer_rets,
) = get_mutable_redispatch_return_names(f, inner_return_var)
_, non_aliased_inner_rets = get_mutable_redispatch_return_names(
functional_op, inner_return_var
)
# The outer function may have a mix of aliased and non-aliased outputs,
# But the inner functional op that we're transforming to should only have non-aliased outputs
if len(mutable_arg_names) + len(non_aliased_outer_rets) != len(non_aliased_inner_rets):
raise RuntimeError("The sum of the lengths of mutable_arg_names and non_aliased_outer_rets "
"does not equal the length of non_aliased_inner_rets.")
# First, take all of the newly created outputs from the inner call and wrap them into functional tensors
updates = []
non_aliased_wrapped_ret_names = []
for i, inner_ret in enumerate(
non_aliased_inner_rets[: len(non_aliased_outer_rets)]
):
ret_name = f"output_{i}"
updates.append(
f"""\
auto output_{i} = at::functionalization::impl::to_functional_tensor({inner_ret});"""
)
non_aliased_wrapped_ret_names.append(ret_name)
# Next, take all of the mutated outputs from the inner call corresponding to mutated inputs,
# and propagate the mutations
for outer_arg, inner_ret in zip(
mutable_arg_names, non_aliased_inner_rets[len(non_aliased_outer_rets) :]
):
updates.append(
f"""\
at::functionalization::impl::replace_({outer_arg}, {inner_ret});
at::functionalization::impl::commit_update({outer_arg});
at::functionalization::impl::sync({outer_arg});"""
)
# Finally, we return:
# - Any mutable arguments that also returns
# - Any immutable returns that were created wrapping the output from the inner call
returns_str = return_str(
f.func.returns, aliased_outer_rets + non_aliased_wrapped_ret_names
)
updates_str = "\n".join(updates)
return f"""\
{updates_str}
{returns_str}"""
# Generates the Functionalization kernel for:
# - mutation ops (inplace and out= ops)
@with_native_function_and
def emit_inplace_functionalization_body(
f: NativeFunction, g: NativeFunctionsGroup
) -> str:
# mutation case
if not modifies_arguments(f):
raise RuntimeError(f"The function {f.func.name} does not modify its arguments.")
dispatcher_sig = DispatcherSignature.from_schema(f.func)
dispatcher_sig_func = DispatcherSignature.from_schema(g.functional.func)
unwrap_tensor_args_str, unwrapped_args_ctx = unwrap_tensor_args(
dispatcher_sig, is_view_op=False
)
mutated_names = [
a.name
for a in f.func.arguments.flat_all
if a.type.is_tensor_like() and a.annotation is not None
]
non_mutated_names = [
a.name
for a in f.func.arguments.flat_all
if a.type.is_tensor_like() and a.annotation is None
]
# all mutable inputs must be functional tensors in order to participate in functionalization
check_all_mutated_args_are_functional = " && ".join(
["true"]
+ [
f"at::functionalization::impl::isFunctionalTensor({a})"
for a in mutated_names
]
)
check_any_non_mutated_args_are_functional = " || ".join(
["false"]
+ [
f"at::functionalization::impl::isFunctionalTensor({a})"
for a in non_mutated_names
]
)
# These are used in the cases where we don't functionalize and redispatch to the inplace op
# case 1: we hit an inplace op that doesn't have an out-of-place equivalent
# case 2: we hit an inplace ops but our inputs are not functional tensors (in which case our kernel just no-ops)
inplace_exprs = [
e.expr
for e in translate(unwrapped_args_ctx, dispatcher_sig.arguments(), method=False)
]
# call the out-of-place variant of the op
return_type = (
dispatcher.returns_type(g.functional.func.returns).remove_const_ref().cpp_type()
)
functional_sig = DispatcherSignature.from_schema(g.functional.func)
functional_exprs = [
e.expr
for e in translate(unwrapped_args_ctx, functional_sig.arguments(), method=False)
]
meta_conversion_str, meta_call_ctx = convert_to_meta_tensors(dispatcher_sig)
# We don't want to run the inplace meta func for ops like .set_(), because:
# (1) they're unnecessary: inplace meta checks are only useful for ops like add_(),
# where broadcasting will work for the out-of-place case but should fail on the inplace call
# (2) They'll also fail without adding extra infra: we'd need to convert the input storage argument
# into a meta storage
any_storage_args = any(
a.type == BaseType(BaseTy.Storage) for a in f.func.arguments.flat_all
)
return f"""
{dispatcher_sig.defn(name=wrapper_name(f.func), is_redispatching_fn=True)} {{
if ({str(not any_storage_args and f.func.kind() == SchemaKind.inplace).lower()}) {{
// Before converting the mutable op to its functional variant, run meta tensors through the original op.
// This will help us catch shape errors that apply to inplace ops that wouldn't apply to their functional variants.
// (We can only do this for inplace ops today though, because they technicaly all support meta tensors).
{meta_conversion_str}
at::AutoDispatchSkipFunctionalize func_guard;
c10::impl::ExcludeDispatchKeyGuard guard(exclude_keys_for_meta_dispatch);
at_npu::native::custom_ops::{dispatcher_sig.name()}({', '.join(a.name for a in meta_call_ctx)});
}}
{unwrap_tensor_args_str}
if (!({check_all_mutated_args_are_functional})) {{
if ({check_any_non_mutated_args_are_functional}) {{
// case 1: trying to mutate a non functional tensor with a functional tensor is an error
TORCH_INTERNAL_ASSERT(false,
"mutating a non-functional tensor with a functional tensor is not allowed.",
" Please ensure that all of your inputs are wrapped inside of a functionalize() call.", PTA_ERROR(ErrCode::PARAM));
}} else {{
// case 2: arguments are not functional tensors, so we no-op and redispatch.
at::AutoDispatchSkipFunctionalize guard;
{maybe_create_output(f, 'tmp_output')}at_npu::native::custom_ops::{dispatcher_sig.name()}({', '.join(inplace_exprs)});
{return_from_mutable_noop_redispatch(f, 'tmp_output')}
}}
}} else {{
{return_type} tmp_output;
{{
at::AutoDispatchSkipFunctionalize guard;
tmp_output = at_npu::native::custom_ops::{dispatcher_sig_func.name()}({', '.join(functional_exprs)});
}}
{wrap_propagate_mutations_and_return(f, g.functional, 'tmp_output')}
}}
}}"""
def gen_functionalization_registration(
selector: SelectiveBuilder,
g: Union[NativeFunction, NativeFunctionsGroupOptionalOut],
) -> List[str]:
@with_native_function
def emit_registration_helper(f: NativeFunction) -> str:
registration_str = f"TORCH_FN(functionalization::{wrapper_name(f.func)})"
return f'm.impl("{f.func.name}", {registration_str});'
# Don't generate kernels in mobile build
if not selector.include_all_operators:
return []
if isinstance(g, NativeFunctionsGroupOptionalOut):
fns = list(g.functions())
else :
fns = []
registrations = []
for f in fns:
if len(f.func.arguments.out) > 1:
return []
if str(f.func.name) == "lift":
# See Note [Functionalization <> torch.Tensor constructor]
return []
if str(f.func.name) == "resize_":
# See Note [resize_ in Functionalization]
return []
if f.is_view_op:
raise RuntimeError(f"The {f.func.name} func is a view op.")
# functionalization needs to generate and register kernals for inplace ops.
# We *also* need to directly register CompositeImplicitAUtograd kernels
# so that they decompose properly before functioanlization.
if modifies_arguments(f):
registrations.append(emit_registration_helper(f))
return registrations
def gen_functionalization_definition(
selector: SelectiveBuilder,
# Note: Ideally this code should never have to look at NativeFunction
# (and instead only need to operate on grouped NativeFunctions).
# The only reason currently is because we need to emit direct dispatch registrations
# For CompositeImplicitAutograd operators, which are potentially ungrouped.
g: Union[NativeFunction, NativeFunctionsGroupOptionalOut],
) -> List[str]:
# Don't generate kernels in mobile build
if not selector.include_all_operators:
return []
if isinstance(g, NativeFunction):
return []
else:
# Case 2: emit inplace -> out-of-place kernels for the functionalization.
mutation_defs = []
if g.out is not None:
if len(g.out.func.arguments.out) > 1:
return []
mutation_defs.append(emit_inplace_functionalization_body(g.out, g))
if g.inplace is not None:
mutation_defs.append(emit_inplace_functionalization_body(g.inplace, g))
if g.mutable is not None:
mutation_defs.append(emit_inplace_functionalization_body(g.mutable, g))
return mutation_defs
return []
-14
View File
@@ -1,14 +0,0 @@
#include <ATen/core/dispatch/Dispatcher.h>
#include "torch_npu/csrc/aten/CustomFunctions.h"
namespace at_npu {
namespace native {
namespace custom_ops {
${custom_function_definitions}
} // namespace custom_ops
} // namespace native
} // namespace at_npu
-16
View File
@@ -1,16 +0,0 @@
#ifndef TORCH_NPU_CSRC_ATEN_CUSTOM_FUNCTIONS
#define TORCH_NPU_CSRC_ATEN_CUSTOM_FUNCTIONS
#include <ATen/ATen.h>
namespace at_npu {
namespace native {
namespace custom_ops {
${custom_function_declarations}
} // namespace custom_ops
} // namespace native
} // namespace at_npu
#endif
-12
View File
@@ -1,12 +0,0 @@
#include <ATen/core/dispatch/Dispatcher.h>
#include "torch_npu/csrc/aten/CustomRedispatch.h"
namespace at_npu {
namespace redispatch {
${custom_function_definitions}
} // namespace redispatch
} // namespace at_npu
-14
View File
@@ -1,14 +0,0 @@
#ifndef TORCH_NPU_CSRC_ATEN_CUSTOM_REDISPATCH
#define TORCH_NPU_CSRC_ATEN_CUSTOM_REDISPATCH
#include <ATen/ATen.h>
namespace at_npu {
namespace redispatch {
${custom_function_declarations}
} // namespace redispatch
} // namespace at_npu
#endif
@@ -1,60 +0,0 @@
#include <c10/core/TensorImpl.h>
#include <c10/core/Allocator.h>
#include <ATen/DeviceGuard.h>
#include <ATen/NativeFunctions.h>
#include <ATen/MetaFunctions.h>
#include <ATen/NamedTensorUtils.h>
#include <ATen/Utils.h>
#include <ATen/WrapDimUtils.h>
#include <ATen/Dispatch.h>
#include <c10/util/Half.h>
#include <c10/core/UndefinedTensorImpl.h>
#include <c10/util/Optional.h>
#include <ATen/Tensor.h>
#include <ATen/Functions.h>
#include <ATen/native/Resize.h>
#include <ATen/core/op_registration/adaption.h>
#include <cstddef>
#include <functional>
#include <memory>
#include <utility>
#include <ATen/Config.h>
#include <torch/library.h>
#include <torch/csrc/autograd/function.h>
#include <torch/csrc/jit/frontend/tracer.h>
#include "torch_npu/csrc/aten/NPUNativeFunctions.h"
#include "torch_npu/csrc/aten/VariableType.h"
#include "torch_npu/csrc/core/npu/NPUException.h"
#include "torch_npu/csrc/core/npu/NPURecovery.h"
#include "op_plugin/OpInterface.h"
namespace at_npu {
namespace native {
${custom_op_definitions}
namespace {
TORCH_LIBRARY(npu, m) {
${custom_schema_registrations}
}
} // anonymous namespace
namespace {
TORCH_LIBRARY_IMPL(npu, PrivateUse1, m) {
${custom_impl_registrations}
}
} // anonymous namespace
} // namespace native
} // namespace at_npu
-16
View File
@@ -1,16 +0,0 @@
#include <torch/library.h>
${include_headers}
namespace {
// Register fallthrough for Autograd backends dispatch keys
// NB: But not the private use ones; maybe the extension wants
// to override it themselves!
// (Ascend) TORCH_LIBRARY_IMPL
TORCH_LIBRARY_IMPL(aten, PrivateUse1, m) {
${foreach_kernel}
}
}
@@ -1,108 +0,0 @@
// ${generated_comment}
#include <ATen/core/LegacyTypeDispatch.h>
#include <ATen/EmptyTensor.h>
#include <ATen/FunctionalTensorWrapper.h>
#include <ATen/MemoryOverlap.h>
#include <torch/library.h>
#include <ATen/Operators.h>
#include <ATen/NativeFunctions.h>
#include "torch_npu/csrc/aten/CustomFunctions.h"
#include "torch_npu/csrc/core/npu/NPUException.h"
namespace at_npu {
namespace functionalization {
// This keyset is used by functionalization when it calls into meta kernels
// to accurately propagate stride metadata.
// Exclude any modes: the purpose of calling into meta kernels is only as an implementation
// detail to perform shape inference, and we don't want any modal keys to run.
// Specifically, we want to prevent functionalization and Python modes from running.
constexpr auto exclude_keys_for_meta_dispatch =
c10::functorch_transforms_ks |
c10::DispatchKeySet({
c10::DispatchKey::FuncTorchDynamicLayerBackMode,
c10::DispatchKey::FuncTorchDynamicLayerFrontMode,
c10::DispatchKey::Python
});
// Helper around at::has_internal_overlap.
// The ATen util is used in hot-path eager mode: it's always fast,
// but might return TOO_HARD sometimes.
// During functionalization, we're ok taking a bit longer
// to detect memory overlap.
inline bool has_internal_overlap_helper(const at::Tensor t)
{
auto has_overlap = at::has_internal_overlap(t);
if (has_overlap == at::MemOverlap::Yes) {
return true;
}
if (has_overlap == at::MemOverlap::No) {
return false;
}
return false;
}
inline at::Tensor to_meta(const at::Tensor& t)
{
if (!t.defined()) return t;
return at::native::empty_strided_meta_symint(t.sym_sizes(), t.sym_strides(),
c10::make_optional(t.scalar_type()) /* dtype */, c10::make_optional(t.layout() /* layout */),
c10::make_optional(c10::Device(at::kMeta)) /* device */, c10::nullopt /* pin_memory */);
}
inline c10::optional<at::Tensor> to_meta(const c10::optional<at::Tensor>& t)
{
if (t.has_value()) {
return c10::make_optional<at::Tensor>(to_meta(*t));
}
return c10::nullopt;
}
inline std::vector<at::Tensor> to_meta(at::ITensorListRef t_list)
{
std::vector<at::Tensor> outputs;
outputs.reserve(t_list.size());
for (const auto& tensor : t_list) {
outputs.push_back(to_meta(tensor));
}
return outputs;
}
inline c10::List<at::Tensor> to_meta(const c10::List<at::Tensor>& t_list)
{
c10::List<at::Tensor> outputs;
outputs.reserve(t_list.size());
for (const auto i : c10::irange(t_list.size())) {
outputs.push_back(to_meta(t_list[i]));
}
return outputs;
}
inline c10::List<c10::optional<at::Tensor>> to_meta(const c10::List<c10::optional<at::Tensor>>& t_list)
{
c10::List<c10::optional<at::Tensor>> outputs;
outputs.reserve(t_list.size());
for (const auto i : c10::irange(t_list.size())) {
outputs.push_back(to_meta(t_list[i]));
}
return outputs;
}
${func_definitions}
} // namespace functionalization
namespace {
TORCH_LIBRARY_IMPL(npu, Functionalize, m) {
${func_registrations};
}
} // namespace
} // namespace at_npu
-6
View File
@@ -1,6 +0,0 @@
import warnings
import torch
import torch_npu
${custom_ops}
-48
View File
@@ -1,48 +0,0 @@
import unittest
from collections import defaultdict
import torch
from torch.testing._internal.common_methods_invocations import op_db, python_ref_db
from torch.testing._internal.opinfo.core import DecorateInfo
"""
strategy: Due to the restriction of NPU operators.
patch the data classes to avoid unsupported cases.
"""
skip_list = {${skip_detail}}
def update_skip_list():
for item in op_db:
op_name = item.name
if op_name in skip_list:
if isinstance(item.skips, tuple):
new_skips = tuple(skip_list[op_name]) + item.skips
elif isinstance(item.skips, list):
new_skips = skip_list[op_name] + item.skips
else:
new_skips = tuple(skip_list[op_name])
item.skips = new_skips
for item in python_ref_db:
op_name = item.name
if op_name in skip_list:
if isinstance(item.skips, tuple):
new_skips = tuple(skip_list[op_name]) + item.skips
elif isinstance(item.skips, list):
new_skips = skip_list[op_name] + item.skips
else:
new_skips = tuple(skip_list[op_name])
item.skips = new_skips
def get_decorators(self, test_class, test_name, device, dtype, param_kwargs):
self.decorators = (*self.decorators, *self.skips)
result = []
for decorator in self.decorators:
if isinstance(decorator, DecorateInfo):
if decorator.is_active(test_class, test_name, device, dtype, param_kwargs):
result.extend(decorator.decorators)
else:
result.append(decorator)
return result
-759
View File
@@ -1,759 +0,0 @@
# Copyright (c) 2023 Huawei Technologies Co., Ltd
# All rights reserved.
#
# Licensed under the BSD 3-Clause License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://opensource.org/licenses/BSD-3-Clause
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
import stat
import traceback
import warnings
import itertools
from typing import List, Optional, Set, Dict, Union, Sequence, Iterator
from collections import defaultdict
from dataclasses import dataclass
import yaml
import torch
from torchgen.api.types.signatures import NativeSignature
from torchgen.context import native_function_manager
from torchgen.code_template import CodeTemplate
from torchgen.model import (
Arguments,
BackendIndex,
BackendMetadata,
DispatchKey,
is_cuda_dispatch_key,
NativeFunction,
NativeFunctionsGroup,
FunctionSchema,
OperatorName,
TensorOptionsArguments,
SchemaKind,
DeviceCheckType,
Argument,
)
from torchgen.native_function_generation import pre_group_native_functions
from torchgen.utils import concatMap
from torchgen.api import cpp
from torchgen.api.translate import translate
from torchgen.api.types import Binding, CppSignatureGroup, kernel_signature
from torchgen.utils import Target
from torchgen.dest.register_dispatch_key import RegisterDispatchKey
GLOBAL_STRUCTURED_OP_INFO_CACHE = defaultdict(str)
GLOBAL_OPAPI_INFO_CACHE = set()
GLOBAL_INTERNAL_FORMAT_OPAPI_INFO_CACHE = set()
CUSTOM_YAML_NAME = "npu_native_functions_by_codegen.yaml"
FIELDS_TO_USE = ["func", "tags", "dispatch", "device_check"]
DEVICE_NOCHECK_SET = set()
DEVICE_CHECK_NOTSUPPORT_TYPE = {"Tensor[]?"}
class PathManager:
@classmethod
def check_path_owner_consistent(cls, path: str):
"""
Function Description:
check whether the path belong to process owner
Parameter:
path: the path to check
Exception Description:
when invalid path, prompt the user
"""
if not os.path.exists(path):
msg = f"The path does not exist: {path}"
raise RuntimeError(msg)
if os.stat(path).st_uid != os.getuid():
warnings.warn(f"Warning: The {path} owner does not match the current user.")
@classmethod
def check_directory_path_readable(cls, path):
"""
Function Description:
check whether the path is writable
Parameter:
path: the path to check
Exception Description:
when invalid data throw exception
"""
cls.check_path_owner_consistent(path)
if os.path.islink(path):
msg = f"Invalid path is a soft chain: {path}"
raise RuntimeError(msg)
if not os.access(path, os.R_OK):
msg = f"The path permission check failed: {path}"
raise RuntimeError(msg)
@classmethod
def remove_path_safety(cls, path: str):
if os.path.islink(path):
raise RuntimeError(f"Invalid path is a soft chain: {path}")
if os.path.exists(path):
os.remove(path)
def parse_npu_yaml(custom_path: str) -> Dict:
if not os.path.exists(custom_path):
return {}
from io import StringIO
f_str = StringIO()
PathManager.check_directory_path_readable(custom_path)
with open(custom_path, 'r') as f:
for line in f:
if ':' not in line:
continue
f_str.write(line)
f_str.seek(0)
source_es = yaml.safe_load(f_str)
return source_es
def merge_yaml(base_data, additional_data):
"""Merge two YAML data structures. If there's a conflict, the base data will take precedence."""
map_dict = {"official": "supported"}
def key_map(x):
if x in map_dict:
return map_dict[x]
else:
return x
if isinstance(base_data, dict):
for key, value in additional_data.items():
if key_map(key) not in base_data:
base_data[key_map(key)] = value
else:
base_data[key_map(key)] = merge_yaml(base_data[key_map(key)], value)
elif isinstance(base_data, list):
for item in additional_data:
if item not in base_data:
base_data.append(item)
return base_data
def merge_custom_yaml(pta_path, op_plugin_path):
PathManager.check_directory_path_readable(pta_path)
with open(pta_path, 'r') as pta_file:
pta_es = yaml.safe_load(pta_file)
PathManager.check_directory_path_readable(op_plugin_path)
with open(op_plugin_path, 'r') as op_plugin_file:
op_es = yaml.safe_load(op_plugin_file)
merged_yaml = merge_yaml(pta_es, op_es)
merged_yaml_path = gen_custom_yaml_path(pta_path)
PathManager.remove_path_safety(merged_yaml_path)
with os.fdopen(os.open(merged_yaml_path, os.O_RDWR | os.O_CREAT, stat.S_IWUSR | stat.S_IRUSR), "w") as outfile:
yaml.dump(merged_yaml, outfile, default_flow_style=False, width=float("inf"))
os.chmod(merged_yaml_path, stat.S_IRUSR | stat.S_IEXEC | stat.S_IRGRP | stat.S_IXGRP)
return merged_yaml
def field_tag(custom_es):
for i, es in enumerate(custom_es):
if not isinstance(es, dict):
continue
custom_es[i] = {key: custom_es[i][key] for key in FIELDS_TO_USE if key in custom_es[i]}
return custom_es
def filt_exposed_api(custom_path: str):
source_es = parse_npu_yaml(custom_path)
custom_es = source_es.get('custom', []) + source_es.get('custom_autograd', [])
exposed_set = set()
for es in custom_es:
if es.get('exposed', False):
exposed_set.add(es.get('func').split('(')[0].split('.')[0])
return list(exposed_set)
# Different implements of ops from origin torch.
# Native ops with dispatchkey CompositeImplicitAutograd but implemented as a kernel op in pta
COMPOSITEIMPLICITAUTOGRAD_EXCEPT_LIST = [
'isclose',
'isfinite',
]
def filt_dispath_key(api_name: str) -> List:
dispatch_dump = torch._C._dispatch_dump(f"aten::{api_name}")
return [dump.split(":")[0] for dump in dispatch_dump.split('\n')]
def filt_compositeimplicitautograd_api(native_yaml_path, npu_supported):
PathManager.check_directory_path_readable(native_yaml_path)
with open(native_yaml_path, 'r') as f:
es = yaml.safe_load(f)
from codegen.autograd.utils import TORCH_AUTOGRAD_FUNCTION
supported_autograd = []
for e in es:
api_name = e['func'].split('(')[0]
dispatch_keys = filt_dispath_key(api_name)
is_compositekey = "CompositeImplicitAutograd[alias]" in dispatch_keys and \
"Autograd[alias]" not in dispatch_keys and \
api_name not in TORCH_AUTOGRAD_FUNCTION
is_npu_api = api_name in npu_supported and api_name not in COMPOSITEIMPLICITAUTOGRAD_EXCEPT_LIST
if is_npu_api and is_compositekey:
supported_autograd.append(api_name)
return supported_autograd
def rename_privateuse1_dispatch_key():
# rename DispatcherKey about PrivateUse1
custom_backend = "NPU"
def PrivateUse1Str(self):
return self.name.replace("PrivateUse1", custom_backend)
@staticmethod
def parse(value: str) -> "DispatchKey":
for k, v in DispatchKey.__members__.items():
if k == value.replace(custom_backend, "PrivateUse1"):
return v
raise AssertionError(f"unknown dispatch key {value}")
DispatchKey.__str__ = PrivateUse1Str
DispatchKey.parse = parse
def get_torchgen_dir():
# get path of torchgen, then get tags.yaml and native_functions.yaml
try:
import torchgen
return os.path.dirname(os.path.realpath(torchgen.__file__))
except Exception:
_, _, exc_traceback = sys.exc_info()
frame_summary = traceback.extract_tb(exc_traceback)[-1]
return os.path.dirname(frame_summary.filename)
# This function is to add profiler information for each operator, which is later extended in the official
def gen_unstructured(
self, f: NativeFunction, g: Optional[NativeFunctionsGroup] = None
) -> Optional[str]:
with native_function_manager(f):
inplace_meta = False
gets_out_inplace_wrapper = False
if not self.backend_index.has_kernel(f):
return None
if f.manual_kernel_registration:
return None
if (
self.target is Target.REGISTRATION
and not self.selector.is_native_function_selected(f)
):
return None
sig = self.wrapper_kernel_sig(f)
name = sig.name()
returns_type = sig.returns_type().cpp_type()
args = sig.arguments()
args_str = ", ".join(a.defn() for a in args)
op_name = str(f.func.name.name)
force_aclnn = f"at_npu::native::ForceAclnn::GetInstance().IsForceAclnnOp(\"{op_name}\")"
# See Note [Direct dispatch bindings]
cpp_sig_group = CppSignatureGroup.from_native_function(
f, method=False, fallback_binding=False
)
if self.target is Target.NAMESPACED_DECLARATION:
result = ""
for cpp_sig in cpp_sig_group.signatures(symint=self.symint):
result += f"TORCH_API {cpp_sig.decl()};\n"
return result
elif self.target is Target.NAMESPACED_DEFINITION:
def generate_defn(cpp_sig: CppSignature) -> str:
return f"""
{cpp_sig.defn()} {{
return {sig.name()}({', '.join(e.expr for e in translate(cpp_sig.arguments(), sig.arguments()))});
}}
"""
result = ""
for cpp_sig in cpp_sig_group.signatures(symint=self.symint):
result += generate_defn(cpp_sig)
return result
elif self.target is Target.ANONYMOUS_DEFINITION:
# short circuit for inplace_meta
if inplace_meta:
if f.func.arguments.self_arg is None:
raise ValueError("f.func.arguments.self_arg is None")
self_arg_name = f.func.arguments.self_arg.argument.name
return f"""
{returns_type} {name}({args_str}) {{
TORCH_CHECK_NOT_IMPLEMENTED({self_arg_name}.is_meta(),
"Cannot inplace into non-meta tensor with meta tensor argument", OPS_ERROR(ErrCode::NOT_SUPPORT));
return {self_arg_name};
}}
"""
# short circuit for generated inplace/out wrappers
if gets_out_inplace_wrapper:
return self.gen_out_inplace_wrapper(f, g)
metadata = self.backend_index.get_kernel(f)
if metadata is None:
return None
if self.class_method_name is None:
impl_name = f"{metadata.cpp_namespace}::{metadata.kernel}"
else:
impl_name = f"{metadata.cpp_namespace}::{self.class_method_name}::{metadata.kernel}"
kernel_sig = kernel_signature(f, self.backend_index)
args_exprs_str = ", ".join(
e.expr
for e in translate(
sig.arguments(), kernel_sig.arguments(), method=False
)
)
device_check = " // No device check\n"
# Backends that require device guards presumably also require device checks.
if self.backend_index.device_guard and str(f.func.name) not in DEVICE_NOCHECK_SET:
device_check_args = itertools.chain(
f.func.arguments.out, f.func.arguments.flat_positional
)
device_check = RegisterDispatchKey.gen_device_check(
f.device_check, list(device_check_args), name
)
device_guard = "// DeviceGuard omitted" # default
record_func_def = """
#ifndef BUILD_LIBTORCH
torch_npu::profiler::NPURecordFunction guard;
#endif
"""
unsafe_tensor_check = """ // No data check"""
if self.backend_index.device_guard:
has_tensor_options = any(
isinstance(a, TensorOptionsArguments)
for a in f.func.arguments.non_out
)
# There is precedence for which argument we use to do
# device guard. This describes the precedence order.
self_arg = (
[f.func.arguments.self_arg.argument]
if f.func.arguments.self_arg is not None
else []
)
candidate_args = itertools.chain(
self_arg,
f.func.arguments.out,
f.func.arguments.flat_positional,
)
candidate_tensor_args = []
for a in candidate_args:
if a.type.is_tensor_like():
candidate_tensor_args.append(f"{a.name}")
candidate_tensor_args = list(set(candidate_tensor_args))
unsafe_tensor_check = """// No data check."""
if len(candidate_tensor_args) > 0:
unsafe_tensor_check = """
if (c10_npu::get_npu_data_unsafe_flag()) {"""
if name in ["wrapper_NPU__copy_", "wrapper_NPU___foreach_copy_"]:
tensor_arg = candidate_tensor_args[0] + ", " +\
candidate_tensor_args[1]
unsafe_tensor_check = unsafe_tensor_check + f"""
c10_npu::check_and_update_npu_tensor_for_copy(self, src);"""
else:
for tensor_arg in candidate_tensor_args:
unsafe_tensor_check = unsafe_tensor_check + f"""
c10_npu::check_npu_tensor_is_safe({tensor_arg});"""
if len(candidate_tensor_args) > 0:
unsafe_tensor_check = unsafe_tensor_check + """
}
"""
candidate_args = itertools.chain(
self_arg,
f.func.arguments.out,
f.func.arguments.flat_positional,
)
# Only tensor like arguments are eligible
device_of = next(
(
f"{a.name}"
for a in candidate_args
if a.type.is_tensor_like()
),
None,
)
if has_tensor_options and device_of is not None:
device_guard = f"""
OptionalDeviceGuard device_guard(device_of({device_of}));
if (device.has_value()) {{
device_guard.reset_device(device_or_default(device));
}}
"""
elif has_tensor_options:
# kernel is creating a tensor
device_guard = """
const DeviceGuard device_guard(device_or_default(device));"""
elif device_of is not None:
# kernel is operating on existing tensors
device_guard = f"const OptionalDeviceGuard device_guard(device_of({device_of}));"
op_key = str(f.func.name)
if enable_opplugin():
if op_key in GLOBAL_STRUCTURED_OP_INFO_CACHE:
impl_name = f"op_plugin::{GLOBAL_STRUCTURED_OP_INFO_CACHE[op_key]}"
if is_opapi(op_key) and not is_op_valid(op_key):
op_api_impl_name = f"{metadata.cpp_namespace}::NPUNativeOpApiFunctions::{metadata.kernel}"
tensor_check_str = ""
tensor_check_list = []
for a in args:
if a.argument.type.is_tensor_like():
tensor_check_list.append(f"at_npu::native::FormatHelper::IsOpInputBaseFormat({a.name})")
if tensor_check_list:
tensor_check_str = f" && {' && '.join(tensor_check_list)}"
if not is_opapi_support_internal_format(op_key):
return_code = f"""\
if (({force_aclnn} || at_npu::native::env::CheckJitDisable()){tensor_check_str}) {{
return {op_api_impl_name}({args_exprs_str});
}} else {{
return {impl_name}({args_exprs_str});
}}
"""
else:
return_code = f"""\
if (({force_aclnn} || at_npu::native::env::CheckJitDisable())) {{
return {op_api_impl_name}({args_exprs_str});
}} else {{
return {impl_name}({args_exprs_str});
}}
"""
else:
return_code = f"""\
return {impl_name}({args_exprs_str});
"""
return f"""\
namespace {{
{returns_type} {name}({args_str}) {{
{device_check}
{unsafe_tensor_check}
{device_guard}
{record_func_def}
{return_code}
}}
}} // anonymous namespace
"""
elif self.target is Target.REGISTRATION:
if f.manual_kernel_registration or self.skip_dispatcher_op_registration:
return None
else:
payload = f"TORCH_FN({name})"
return f'm.impl("{f.func.name}",\n{payload});\n'
else:
assert_never(self.target)
def gen_device_check(
type: DeviceCheckType, args: List[Argument], method_name: str
) -> str:
if type == DeviceCheckType.NoCheck:
return " // No device check\n"
device_check = "c10::optional<at::Device> common_device = at::nullopt;\n"
device_check += "(void)common_device; // Suppress unused variable warning\n"
for arg in args:
# Only tensor like arguments are eligible
if arg.type.is_tensor_like() and str(arg.type) not in DEVICE_CHECK_NOTSUPPORT_TYPE:
device_check += \
f"""c10::impl::check_and_update_common_device(common_device, {arg.name}, "{method_name}", "{arg.name}");\n"""
return device_check
def arguments(
arguments: Arguments,
*,
faithful: bool,
symint: bool = False,
method: bool,
cpp_no_default_args: Set[str],
) -> List[Binding]:
args: List[Union[Argument, TensorOptionsArguments, SelfArgument]] = []
args.extend(arguments.non_out)
args.extend(arguments.out)
result = []
for a in args:
for r in cpp.argument(
a,
faithful=faithful,
symint=symint,
method=method,
has_tensor_options=arguments.tensor_options is not None,
cpp_no_default_args=cpp_no_default_args,
):
if faithful:
result.append(r.no_default())
else:
result.append(r)
return result
def add_header_to_template_file():
torchgen_path = get_torchgen_dir()
template_dir = os.path.join(torchgen_path, "packaged/ATen/templates/DispatchKeyNativeFunctions.h")
PathManager.check_directory_path_readable(template_dir)
with open(template_dir, "r") as file:
template_content = file.read()
if "#include <ATen/ATen.h>" not in template_content:
template_content = template_content.replace("#include <ATen/Tensor.h>",
"#include <ATen/Tensor.h>\n#include <ATen/ATen.h>")
with os.fdopen(os.open(template_dir, os.O_WRONLY, stat.S_IWUSR | stat.S_IRUSR), "w") as file:
file.write(template_content)
def enable_opplugin() -> bool:
# enable op_plugin, if path of third_party/op-plugin is valid.
base_dir = os.path.dirname(os.path.realpath(__file__))
op_plugin_path = os.path.join(base_dir, '../third_party/op-plugin/op_plugin')
return os.path.exists(op_plugin_path)
def is_op_valid(op_key: str) -> bool:
return True if op_key in GLOBAL_STRUCTURED_OP_INFO_CACHE else False
def get_opplugin_wrap_name(func) -> str:
op_key = str(func.func.name) if type(func) is NativeFunction else func
return GLOBAL_STRUCTURED_OP_INFO_CACHE.get(op_key, None)
def gen_custom_yaml_path(original_path, codegen_yaml_filename=CUSTOM_YAML_NAME):
new_path = os.path.join(os.path.dirname(original_path), codegen_yaml_filename)
return new_path
def update_opapi_info(op_info):
global GLOBAL_OPAPI_INFO_CACHE
if isinstance(op_info, str):
return
elif isinstance(op_info, dict):
if op_info.get("op_api", False):
GLOBAL_OPAPI_INFO_CACHE.add(op_info.get("func").split("(")[0])
else:
print(f"Warning: Unsupported parameter types, only str and dict is supported, but input is {type(op_info)}")
def is_opapi(op_key):
global GLOBAL_OPAPI_INFO_CACHE
return op_key in GLOBAL_OPAPI_INFO_CACHE
def update_internal_format_opapi_info(op_info):
global GLOBAL_INTERNAL_FORMAT_OPAPI_INFO_CACHE
if isinstance(op_info, str):
return
elif isinstance(op_info, dict):
if op_info.get("internal_format_opapi", False):
GLOBAL_INTERNAL_FORMAT_OPAPI_INFO_CACHE.add(op_info.get("func").split("(")[0])
else:
print(f"Warning: Unsupported parameter types, only str and dict is supported, but input is {type(op_info)}")
def is_opapi_support_internal_format(op_key):
global GLOBAL_INTERNAL_FORMAT_OPAPI_INFO_CACHE
return op_key in GLOBAL_INTERNAL_FORMAT_OPAPI_INFO_CACHE
def get_target_functions(yaml_path: str, target_op_type: str = None) -> List:
source_es = parse_npu_yaml(yaml_path)
custom = source_es.pop('custom', [])
if custom is None:
custom = [] # Allow an empty list of supported ops
official = source_es.pop('official', [])
if official is None:
official = [] # Allow an empty list of supported ops
support_ops = custom + official
symint = source_es.pop("symint", [])
if symint is None:
symint = []
symint = [op['func'] if isinstance(op, Dict) else op for op in symint]
symint_set = set([str(FunctionSchema.parse(op).name) for op in symint])
global GLOBAL_STRUCTURED_OP_INFO_CACHE
GLOBAL_STRUCTURED_OP_INFO_CACHE.clear()
target_funcs = []
for op in support_ops:
funcs = op.get("func", None)
if not isinstance(funcs, str):
raise TypeError(f'not a str : {funcs}')
func = FunctionSchema.parse(funcs)
wrap_name = cpp.name(func)
op_key = str(func.name)
if op_key in symint_set:
wrap_name += "_symint"
if target_op_type is not None:
if target_op_type not in op.keys():
continue
wrap_name += "_" + target_op_type
cur_wrap_name = GLOBAL_STRUCTURED_OP_INFO_CACHE.get(op_key, "")
if cur_wrap_name and cur_wrap_name != wrap_name:
print(f"Find different wrap_name for {cur_wrap_name} and {wrap_name} between pta and opplugin, ",
f"with {wrap_name} being used as the actual wrap_name")
GLOBAL_STRUCTURED_OP_INFO_CACHE[op_key] = wrap_name
target_funcs.append(func)
return target_funcs
def get_target_native_registration(
dispatch_key: DispatchKey,
backend_indices: Dict[DispatchKey, BackendIndex],
metadata: Dict[OperatorName, BackendMetadata],
native_functions: List[NativeFunction],
):
if native_functions is None:
return ""
cpu_dispatch_key = DispatchKey.parse(dispatch_key.name.replace("PrivateUse1", "CPU"))
cpu_backend_indices = backend_indices[cpu_dispatch_key]
cuda_dispatch_key = DispatchKey.parse(dispatch_key.name.replace("PrivateUse1", "CUDA"))
cuda_backend_indices = backend_indices[cuda_dispatch_key]
target_native_functions_kernels = {}
for op_name in cpu_backend_indices.index.keys():
if cpu_backend_indices.index[op_name].kernel == cuda_backend_indices.index[op_name].kernel \
and op_name not in metadata.keys():
target_native_functions_kernels[op_name] = cpu_backend_indices.index[op_name].kernel
target_native_functions = []
for f in native_functions:
if f.func.name in target_native_functions_kernels.keys():
target_native_functions.append(f)
native_functions_registration_template = CodeTemplate(
"""\
namespace {
${dispatch_helpers}
TORCH_LIBRARY_IMPL(aten, ${dispatch_key}, m) {
${native_kernels}
}
}
""")
def wrap_native_function(f):
kernel_name = target_native_functions_kernels[f.func.name]
wrap_func_name = f"wrap_{dispatch_key}_{str(f.func.name.name)}_{f.func.name.overload_name}"
with native_function_manager(f):
sig = NativeSignature(f.func, prefix='', symint=kernel_name.endswith('symint'))
args_exprs_str = ', '.join(a.name for a in sig.arguments())
return f"""{sig.decl(name=wrap_func_name)} {{
return at::native::{kernel_name}({args_exprs_str});
}}
"""
def register_wrap_native_function(f):
wrap_func_name = f"wrap_{dispatch_key}_{str(f.func.name.name)}_{f.func.name.overload_name}"
return f"m.impl(\"{f.func.name}\", TORCH_FN({wrap_func_name}));"
return native_functions_registration_template.substitute(
dispatch_helpers=[wrap_native_function(f) for f in target_native_functions],
dispatch_key=dispatch_key.name,
native_kernels=[register_wrap_native_function(f) for f in target_native_functions]
)
# A structured kernel is guaranteed to have a functional, optionally out variant and
# optionally an inplace variant.
@dataclass(frozen=True)
class NativeFunctionsGroupOptionalOut:
functional: NativeFunction
inplace: Optional[NativeFunction]
mutable: Optional[NativeFunction]
out: Optional[NativeFunction]
@property
def root_name(self) -> str:
return self.functional.root_name
def functions(self) -> Iterator[NativeFunction]:
yield self.functional
if self.out is not None:
yield self.out
if self.inplace is not None:
yield self.inplace
if self.mutable is not None:
yield self.mutable
@staticmethod
def from_dict(
d: Dict[SchemaKind, NativeFunction]
) -> Optional["NativeFunctionsGroupOptionalOut"]:
if len(d) == 0:
raise RuntimeError('The variable d is empty')
if len(d) == 1:
return None
d = dict(d) # non-destructive updates please
functional = d.pop(SchemaKind.functional, None)
inplace = d.pop(SchemaKind.inplace, None)
mutable = d.pop(SchemaKind.mutable, None)
out = d.pop(SchemaKind.out, None)
if len(d) != 0:
raise RuntimeError('The variable d is not empty after popping keys')
if functional is None:
raise RuntimeError('The variable functional is None')
return NativeFunctionsGroupOptionalOut(
functional=functional,
inplace=inplace,
mutable=mutable,
out=out,
)
def get_grouped_native_functions_optional_out(
native_functions: Sequence[NativeFunction],
) -> Sequence[Union[NativeFunction, NativeFunctionsGroupOptionalOut]]:
def flatten_pre_group(
d: Dict[SchemaKind, NativeFunction]
) -> Sequence[Union[NativeFunction, NativeFunctionsGroupOptionalOut]]:
r = NativeFunctionsGroupOptionalOut.from_dict(d)
if r is None:
# Invariant: any NativeFunctions that are code-generated
# should have been grouped into NativeFunctionsGroupOptionalOut objects
if any("generated" in f.tags for f in d.values()):
raise RuntimeError("The variable d contains 'generated' in function tags")
return list(d.values())
else:
return [r]
pre_grouped_native_functions = pre_group_native_functions(native_functions)
return list(
concatMap(flatten_pre_group, list(pre_grouped_native_functions.values()))
)
-728
View File
@@ -1,728 +0,0 @@
# FrameworkPTAdapter 3.0.RC2 Release Notes
- [FrameworkPTAdapter 3.0.RC2 Release Notes](#frameworkptadapter-30rc2-release-notes)
- [FrameworkPTAdapter 3.0.RC2](#frameworkptadapter-30rc2)
- [Before You Start](#before-you-start)
- [New Features](#new-features)
- [Modified Features](#modified-features)
- [Resolved Issues](#resolved-issues)
- [Known Issues](#known-issues)
- [Compatibility](#compatibility)
- [FrameworkPTAdapter 3.0.RC1](#frameworkptadapter-30rc1)
- [Before You Start](#before-you-start-1)
- [New Features](#new-features-1)
- [Modified Features](#modified-features-1)
- [Resolved Issues](#resolved-issues-1)
- [Known Issues](#known-issues-1)
- [Compatibility](#compatibility-1)
- [FrameworkPTAdapter 2.0.4](#frameworkptadapter-204)
- [Before You Start](#before-you-start-2)
- [New Features](#new-features-2)
- [Modified Features](#modified-features-2)
- [Resolved Issues](#resolved-issues-2)
- [Known Issues](#known-issues-2)
- [Compatibility](#compatibility-2)
- [FrameworkPTAdapter 2.0.3](#frameworkptadapter-203)
- [Before You Start](#before-you-start-3)
- [New Features](#new-features-3)
- [Modified Features](#modified-features-3)
- [Resolved Issues](#resolved-issues-3)
- [Known Issues](#known-issues-3)
- [Compatibility](#compatibility-3)
- [FrameworkPTAdapter 2.0.2](#frameworkptadapter-202)
- [Before You Start](#before-you-start-4)
- [New Features](#new-features-4)
- [Modified Features](#modified-features-4)
- [Resolved Issues](#resolved-issues-4)
- [Known Issues](#known-issues-4)
- [Compatibility](#compatibility-4)
## FrameworkPTAdapter 3.0.RC2
### Before You Start
This framework is modified based on the open-source PyTorch 1.5.0 and 1.8.1 developed by Facebook, inherits native PyTorch features, and uses NPUs for dynamic image training. Models are adapted by operator granularity, code can be reused, and current networks can be ported and used on NPUs with only device types or data types modified.
PyTorch 1.8.1 uses plug-in adaptation and is completely decoupled from the native PyTorch framework. The current functions and performance of PyTorch 1.8.1 are basically the same as those of PyTorch 1.5.0, providing good development experience for backend operator adaptation.
AOE-based tuning is supported.
### New Features
**Table 1** Features supported by PyTorch
<a name="t76c34275cbb74753970f7c5a9eb594fa"></a>
<table><thead align="left"><tr id="r0c10e7163bf54fe8816ab5ca2d77ccc4"><th class="cellrowborder" valign="top" width="10.459999999999999%" id="mcps1.2.4.1.1"><p id="a7888762cf8294977b7d114b1c898d1bd"><a name="a7888762cf8294977b7d114b1c898d1bd"></a><a name="a7888762cf8294977b7d114b1c898d1bd"></a>Level-1 Feature</p>
</th>
<th class="cellrowborder" valign="top" width="26.27%" id="mcps1.2.4.1.2"><p id="a4581ffde4a5f455faadfba144243a9d4"><a name="a4581ffde4a5f455faadfba144243a9d4"></a><a name="a4581ffde4a5f455faadfba144243a9d4"></a>Level-2 Feature</p>
</th>
<th class="cellrowborder" valign="top" width="63.27%" id="mcps1.2.4.1.3"><p id="a2a1562364b09433a83133fa10b3cf2b3"><a name="a2a1562364b09433a83133fa10b3cf2b3"></a><a name="a2a1562364b09433a83133fa10b3cf2b3"></a>Description</p>
</th>
</tr>
</thead>
<tbody>
<tr id="row7979351559"><td class="cellrowborder" rowspan="2" valign="top" width="10.459999999999999%" headers="mcps1.2.4.1.1 "><p id="p69836331553"><a name="p69836331553"></a><a name="p69836331553"></a>PyTorch 1.5.0 features adapted to NPUs</p>
</td>
</tr>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p109832331055"><a name="p109832331055"></a><a name="p109832331055"></a> Basic framework functions</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p109832331055"><a name="p109832331055"></a><a name="p109832331055"></a> Fixed a few bugs.</p>
</td>
</tr>
<tr id="row7979351559"><td class="cellrowborder" rowspan="3" valign="top" width="10.459999999999999%" headers="mcps1.2.4.1.1 "><p id="p69836331553"><a name="p69836331553"></a><a name="p69836331553"></a>PyTorch 1.8.1 features adapted to NPUs</p>
</td>
<td class="cellrowborder" valign="top" width="26.27%" headers="mcps1.2.4.1.2 "><p id="p149831333357"><a name="p149831333357"></a><a name="p149831333357"></a>Decoupled as plugins</p>
</td>
<td class="cellrowborder" valign="top" width="26.27%" headers="mcps1.2.4.1.2 "><p id="p149831333357"><a name="p149831333357"></a><a name="p149831333357"></a>Decoupled the torch_npu plugin from the native PyTorch framework completely.</p>
</td>
<tr>
<td class="cellrowborder" valign="top" width="26.27%" headers="mcps1.2.4.1.2 "><p id="p149831333357"><a name="p149831333357"></a><a name="p149831333357"></a>Performance optimization</p>
</td>
<td class="cellrowborder" valign="top" width="26.27%" headers="mcps1.2.4.1.2 "><p id="p149831333357"><a name="p149831333357"></a><a name="p149831333357"></a>Optimized the single-operator delivery and collective communication functions.</p>
</td>
</tr>
<td class="cellrowborder" valign="top" width="63.27%" headers="mcps1.2.4.1.3 "><p id="p1398313336511"><a name="p1398313336511"></a><a name="p1398313336511"></a>API satisfaction</p>
</td>
<td class="cellrowborder" valign="top" width="63.27%" headers="mcps1.2.4.1.3 "><p id="p1398313336511"><a name="p1398313336511"></a><a name="p1398313336511"></a>Added more APIs. (For details, see the API list.)</p>
</td>
</tr>
</tbody>
</table>
### Modified Features
N/A
### Resolved Issues
N/A
### Known Issues
<a name="table1969972073016"></a>
<table><thead align="left"><tr id="row3699162017307"><th class="cellrowborder" valign="top" width="18.22%" id="mcps1.1.3.1.1"><p id="p16992020153010"><a name="p16992020153010"></a><a name="p16992020153010"></a>Known Issue</p>
</th>
<th class="cellrowborder" valign="top" width="81.78%" id="mcps1.1.3.1.2"><p id="p269919203308"><a name="p269919203308"></a><a name="p269919203308"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row9699142003011"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p1769932017300"><a name="p1769932017300"></a><a name="p1769932017300"></a>Data type support</p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p13699152010301"><a name="p13699152010301"></a><a name="p13699152010301"></a>NPUs do not support the input or output of the inf/nan data of the float16 type</p>
</td>
</tr>
<tr id="row146991520153016"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p156997200308"><a name="p156997200308"></a><a name="p156997200308"></a>Data format</p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p10699182020308"><a name="p10699182020308"></a><a name="p10699182020308"></a>Dimensions cannot be reduced when the format larger than 4D is used.</p>
</td>
</tr>
<tr id="row11121205610549"><td class="cellrowborder" rowspan="3" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p1647216219558"><a name="p1647216219558"></a><a name="p1647216219558"></a>Restrictions on collective communication</p>
<p id="p0465121912402"><a name="p0465121912402"></a><a name="p0465121912402"></a></p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p3116115695415"><a name="p3116115695415"></a><a name="p3116115695415"></a>The graphs executed on different devices in a training job must be the same.</p>
</td>
</tr>
<tr id="row51211656105411"><td class="cellrowborder" valign="top" headers="mcps1.1.3.1.1 "><p id="p1311616560541"><a name="p1311616560541"></a><a name="p1311616560541"></a>Allocation at only 1, 2, 4, or 8 processors is supported.</p>
</td>
</tr>
<tr id="row8647195765419"><td class="cellrowborder" valign="top" headers="mcps1.1.3.1.1 "><p id="p2064225716544"><a name="p2064225716544"></a><a name="p2064225716544"></a>Only the int8, int32, float16, and float32 data types are supported.</p>
</td>
</tr>
<tr id="row4646195719548"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p4642195718541"><a name="p4642195718541"></a><a name="p4642195718541"></a>Apex function</p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p864205725412"><a name="p864205725412"></a><a name="p864205725412"></a>In the current version, Apex is implemented mainly using Python, and the customized optimization of CUDA kernel in Apex is not supported.</p>
</td>
</tr>
</tbody>
</table>
### Compatibility
Atlas 800 (model 9010): CentOS 7.6, Ubuntu 18.04/2.04, BC-Linux 7.6, Debian 9.9, Debian 10, openEuler 20.03 LTS
Atlas 800 (model 9000): CentOS 7.6, Ubuntu 18.04/2.04, EulerOS 2.8/2.10, Kylin V10, BC-Linux 7.6, openEuler 20.03 LTS, UOS 20 1020e
## FrameworkPTAdapter 3.0.RC1
### Before You Start
This framework is modified based on the open-source PyTorch 1.5.0 and 1.8.1 developed by Facebook, inherits native PyTorch features, and uses NPUs for dynamic image training. Models are adapted by operator granularity, code can be reused, and current networks can be ported and used on NPUs with only device types or data types modified.
PyTorch 1.8.1 adopts the plugin adaptation mode and inherits the features of PyTorch 1.5.0. Their functions are basically the same, but PyTorch 1.8.1 provides better development experience for backend operator adaptation. It supports AOE-based tuning.
### New Features
**Table 1** Features supported by PyTorch
<a name="t76c34275cbb74753970f7c5a9eb594fa"></a>
<table><thead align="left"><tr id="r0c10e7163bf54fe8816ab5ca2d77ccc4"><th class="cellrowborder" valign="top" width="10.459999999999999%" id="mcps1.2.4.1.1"><p id="a7888762cf8294977b7d114b1c898d1bd"><a name="a7888762cf8294977b7d114b1c898d1bd"></a><a name="a7888762cf8294977b7d114b1c898d1bd"></a>Level-1 Feature</p>
</th>
<th class="cellrowborder" valign="top" width="26.27%" id="mcps1.2.4.1.2"><p id="a4581ffde4a5f455faadfba144243a9d4"><a name="a4581ffde4a5f455faadfba144243a9d4"></a><a name="a4581ffde4a5f455faadfba144243a9d4"></a>Level-2 Feature</p>
</th>
<th class="cellrowborder" valign="top" width="63.27%" id="mcps1.2.4.1.3"><p id="a2a1562364b09433a83133fa10b3cf2b3"><a name="a2a1562364b09433a83133fa10b3cf2b3"></a><a name="a2a1562364b09433a83133fa10b3cf2b3"></a>Description</p>
</th>
</tr>
</thead>
<tbody>
<tr id="row7979351559"><td class="cellrowborder" rowspan="2" valign="top" width="10.459999999999999%" headers="mcps1.2.4.1.1 "><p id="p69836331553"><a name="p69836331553"></a><a name="p69836331553"></a>PyTorch 1.5.0 features adapted to NPUs</p>
</td>
<td class="cellrowborder" valign="top" width="26.27%" headers="mcps1.2.4.1.2 "><p id="p149831333357"><a name="p149831333357"></a><a name="p149831333357"></a>AOE-based tuning</p>
</td>
<td class="cellrowborder" valign="top" width="63.27%" headers="mcps1.2.4.1.3 "><p id="p1398313336511"><a name="p1398313336511"></a><a name="p1398313336511"></a>Supported the AOE auto tuning tool to improve the model performance.</p>
</td>
</tr>
<tr id="row13971435754"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p79831331353"><a name="p79831331353"></a><a name="p79831331353"></a>Basic framework functions</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p109832331055"><a name="p109832331055"></a><a name="p109832331055"></a> Added the function of adapted operator development. For details, see the API list.</p>
</td>
</tr>
<tr id="row7979351559"><td class="cellrowborder" rowspan="3" valign="top" width="10.459999999999999%" headers="mcps1.2.4.1.1 "><p id="p69836331553"><a name="p69836331553"></a><a name="p69836331553"></a>PyTorch 1.8.1 features adapted to NPUs</p>
</td>
<td class="cellrowborder" valign="top" width="26.27%" headers="mcps1.2.4.1.2 "><p id="p149831333357"><a name="p149831333357"></a><a name="p149831333357"></a>Plugin decoupling</p>
</td>
<td class="cellrowborder" valign="top" width="63.27%" headers="mcps1.2.4.1.3 "><p id="p1398313336511"><a name="p1398313336511"></a><a name="p1398313336511"></a>Decoupled the NPU-adapted code and ported it to the **torch_npu** plugin to decouple the Ascend-adapted code from the native PyTorch code.</p>
</td>
<tr>
<td class="cellrowborder" valign="top" width="26.27%" headers="mcps1.2.4.1.2 "><p id="p149831333357"><a name="p149831333357"></a><a name="p149831333357"></a>AOE-based tuning</p>
</td>
<td class="cellrowborder" valign="top" width="63.27%" headers="mcps1.2.4.1.3 "><p id="p1398313336511"><a name="p1398313336511"></a><a name="p1398313336511"></a>Supported the AOE auto tuning tool to improve the model performance.</p>
</td>
</tr>
<tr id="row109719353511"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p18983183315515"><a name="p18983183315515"></a><a name="p18983183315515"></a>Improvement of framework API satisfaction</p>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p836221112812"><a name="p836221112812"></a><a name="p836221112812"></a>Supported APIs that have been adapted to Ascend PyTorch 1.5.0. For details, see the API list.</p>
</td>
</tr>
</tbody>
</table>
### Modified Features
N/A
### Resolved Issues
N/A
### Known Issues
<a name="table1969972073016"></a>
<table><thead align="left"><tr id="row3699162017307"><th class="cellrowborder" valign="top" width="18.22%" id="mcps1.1.3.1.1"><p id="p16992020153010"><a name="p16992020153010"></a><a name="p16992020153010"></a>Known Issue</p>
</th>
<th class="cellrowborder" valign="top" width="81.78%" id="mcps1.1.3.1.2"><p id="p269919203308"><a name="p269919203308"></a><a name="p269919203308"></a>Symptom</p>
</th>
</tr>
</thead>
<tbody><tr id="row9699142003011"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p1769932017300"><a name="p1769932017300"></a><a name="p1769932017300"></a>Data type support</p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p13699152010301"><a name="p13699152010301"></a><a name="p13699152010301"></a>NPUs do not support the input or output of the inf/nan data of the float16 type.</p>
</td>
</tr>
<tr id="row146991520153016"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p156997200308"><a name="p156997200308"></a><a name="p156997200308"></a>Data format</p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p10699182020308"><a name="p10699182020308"></a><a name="p10699182020308"></a>Dimensions cannot be reduced when the format larger than 4D is used.</p>
</td>
</tr>
<tr id="row11121205610549"><td class="cellrowborder" rowspan="3" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p1647216219558"><a name="p1647216219558"></a><a name="p1647216219558"></a>Restrictions on collective communication</p>
<p id="p0465121912402"><a name="p0465121912402"></a><a name="p0465121912402"></a></p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p3116115695415"><a name="p3116115695415"></a><a name="p3116115695415"></a>The graphs executed on different devices in a training job must be the same.</p>
</td>
</tr>
<tr id="row51211656105411"><td class="cellrowborder" valign="top" headers="mcps1.1.3.1.1 "><p id="p1311616560541"><a name="p1311616560541"></a><a name="p1311616560541"></a>Allocation at only 1, 2, 4, or 8 processors is supported.</p>
</td>
</tr>
<tr id="row8647195765419"><td class="cellrowborder" valign="top" headers="mcps1.1.3.1.1 "><p id="p2064225716544"><a name="p2064225716544"></a><a name="p2064225716544"></a>Only the int8, int32, float16, and float32 data types are supported.</p>
</td>
</tr>
<tr id="row4646195719548"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p4642195718541"><a name="p4642195718541"></a><a name="p4642195718541"></a>Apex function</p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p864205725412"><a name="p864205725412"></a><a name="p864205725412"></a>In the current version, Apex is implemented mainly using Python, and the customized optimization of CUDA kernel in Apex is not supported.</p>
</td>
</tr>
</tbody>
</table>
### Compatibility
Atlas 800 (model 9010): CentOS 7.6, Ubuntu 18.04/2.04, BC-Linux 7.6, Debian 9.9, Debian 10, openEuler 20.03 LTS
Atlas 800 (model 9000): CentOS 7.6, Ubuntu 18.04/2.04, EulerOS 2.8/2.10, Kylin V10, BC-Linux 7.6, openEuler 20.03 LTS, UOS 20 1020e
## FrameworkPTAdapter 2.0.4
### Before You Start
This framework is modified based on the open-source PyTorch 1.5.0 and 1.8.1 developed by Facebook, inherits native PyTorch features, and uses NPUs for dynamic image training. Models are adapted by operator granularity, code can be reused, and current networks can be ported and used on NPUs with only device types or data types modified.
PyTorch 1.8.1 inherits the features of PyTorch 1.5.0. Their functions are basically the same, but PyTorch 1.8.1 provides better development experience for backend operator adaptation. Currently, PyTorch 1.8.1 supports only the ResNet-50 network model.
### New Features
**Table 1** Features supported by PyTorch
<table><thead align="left"><tr id="r0c10e7163bf54fe8816ab5ca2d77ccc4"><th class="cellrowborder" valign="top" width="10.459999999999999%" id="mcps1.2.4.1.1"><p id="a7888762cf8294977b7d114b1c898d1bd"><a name="a7888762cf8294977b7d114b1c898d1bd"></a><a name="a7888762cf8294977b7d114b1c898d1bd"></a>Level-1 Feature</p>
</th>
<th class="cellrowborder" valign="top" width="26.27%" id="mcps1.2.4.1.2"><p id="a4581ffde4a5f455faadfba144243a9d4"><a name="a4581ffde4a5f455faadfba144243a9d4"></a><a name="a4581ffde4a5f455faadfba144243a9d4"></a>Level-2 Feature</p>
</th>
<th class="cellrowborder" valign="top" width="63.27%" id="mcps1.2.4.1.3"><p id="a2a1562364b09433a83133fa10b3cf2b3"><a name="a2a1562364b09433a83133fa10b3cf2b3"></a><a name="a2a1562364b09433a83133fa10b3cf2b3"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row7979351559"><td class="cellrowborder" rowspan="3" valign="top" width="10.459999999999999%" headers="mcps1.2.4.1.1 "><p id="p69836331553"><a name="p69836331553"></a><a name="p69836331553"></a>PyTorch 1.5.0 features adapted to NPUs</p>
</td>
<td class="cellrowborder" valign="top" width="26.27%" headers="mcps1.2.4.1.2 "><p id="p149831333357"><a name="p149831333357"></a><a name="p149831333357"></a>Optimization of Model Accuracy Analyzer</p>
</td>
<td class="cellrowborder" valign="top" width="63.27%" headers="mcps1.2.4.1.3 "><p id="p1398313336511"><a name="p1398313336511"></a><a name="p1398313336511"></a>Supported mapping between IR and TBE operators and enabled the NPU dump data to be loaded to the GPU side for comparison.</p>
</td>
</tr>
<tr id="row109719353511"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p18983183315515"><a name="p18983183315515"></a><a name="p18983183315515"></a>E2E prof</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p836221112812"><a name="p836221112812"></a><a name="p836221112812"></a>Integrated the profile data obtained by the native PyTorch Profiling tool and CANN prof tool to implement end-to-end model and operator performance analysis.</p>
</td>
</tr>
<tr id="row13971435754"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p79831331353"><a name="p79831331353"></a><a name="p79831331353"></a>Basic framework functions</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p109832331055"><a name="p109832331055"></a><a name="p109832331055"></a>Added the function of adapted operator development. For details, see the operator list.</p>
</td>
</tr>
<tr id="row7979351559"><td class="cellrowborder" rowspan="2" valign="top" width="10.459999999999999%" headers="mcps1.2.4.1.1 "><p id="p69836331553"><a name="p69836331553"></a><a name="p69836331553"></a>PyTorch 1.8.1 features adapted to NPUs</p>
</td>
<td class="cellrowborder" valign="top" width="26.27%" headers="mcps1.2.4.1.2 "><p id="p149831333357"><a name="p149831333357"></a><a name="p149831333357"></a>AMP</p>
</td>
<td class="cellrowborder" valign="top" width="63.27%" headers="mcps1.2.4.1.3 "><p id="p1398313336511"><a name="p1398313336511"></a><a name="p1398313336511"></a>Supported the native training with automatic mixed precision (AMP) of PyTorch.</p>
</td>
</tr>
<tr id="row109719353511"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p18983183315515"><a name="p18983183315515"></a><a name="p18983183315515"></a>Profiling</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p836221112812"><a name="p836221112812"></a><a name="p836221112812"></a>Supported the native profiling function of PyTorch.</p>
</td>
</tr>
<tr id="row7979351559"><td class="cellrowborder" rowspan="2" valign="top" width="10.459999999999999%" headers="mcps1.2.4.1.1 "><p id="p69836331553"><a name="p69836331553"></a><a name="p69836331553"></a>OS compatibility</p>
</td>
<td class="cellrowborder" valign="top" width="26.27%" headers="mcps1.2.4.1.2 "><p id="p149831333357"><a name="p149831333357"></a><a name="p149831333357"></a>OS compatibility</p>
</td>
<td class="cellrowborder" valign="top" width="63.27%" headers="mcps1.2.4.1.3 "><p id="p1398313336511"><a name="p1398313336511"></a><a name="p1398313336511"></a>Supported Ubuntu 20.04 (x86 and ARM) and EulerOS 2.10 (ARM).</p>
</td>
<tr id="row13971435754"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p79831331353"><a name="p79831331353"></a><a name="p79831331353"></a>Python version compatibility</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p109832331055"><a name="p109832331055"></a><a name="p109832331055"></a>Supported compilation and use of Python 3.9 (only in PyTorch 1.8.1).</p>
</td>
</tr>
</tbody>
</table>
### Modified Features
N/A
### Resolved Issues
N/A
### Known Issues
<table><thead align="left"><tr id="row3699162017307"><th class="cellrowborder" valign="top" width="18.22%" id="mcps1.1.3.1.1"><p id="p16992020153010"><a name="p16992020153010"></a><a name="p16992020153010"></a>Known Issue</p>
</th>
<th class="cellrowborder" valign="top" width="81.78%" id="mcps1.1.3.1.2"><p id="p269919203308"><a name="p269919203308"></a><a name="p269919203308"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row9699142003011"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p1769932017300"><a name="p1769932017300"></a><a name="p1769932017300"></a>Data type support</p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p13699152010301"><a name="p13699152010301"></a><a name="p13699152010301"></a>NPUs do not support the input or output of the inf/nan data of the float16 type.</p>
</td>
</tr>
<tr id="row146991520153016"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p156997200308"><a name="p156997200308"></a><a name="p156997200308"></a>Data format</p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p10699182020308"><a name="p10699182020308"></a><a name="p10699182020308"></a>Dimensions cannot be reduced when the format larger than 4D is used.</p>
</td>
</tr>
<tr id="row11121205610549"><td class="cellrowborder" rowspan="3" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p1647216219558"><a name="p1647216219558"></a><a name="p1647216219558"></a>Restrictions on collective communication</p>
<p id="p0465121912402"><a name="p0465121912402"></a><a name="p0465121912402"></a></p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p3116115695415"><a name="p3116115695415"></a><a name="p3116115695415"></a>The graphs executed on different devices in a training job must be the same.</p>
</td>
</tr>
<tr id="row51211656105411"><td class="cellrowborder" valign="top" headers="mcps1.1.3.1.1 "><p id="p1311616560541"><a name="p1311616560541"></a><a name="p1311616560541"></a>Allocation at only 1, 2, 4, or 8 processors is supported.</p>
</td>
</tr>
<tr id="row8647195765419"><td class="cellrowborder" valign="top" headers="mcps1.1.3.1.1 "><p id="p2064225716544"><a name="p2064225716544"></a><a name="p2064225716544"></a>Only the int8, int32, float16, and float32 data types are supported.</p>
</td>
</tr>
<tr id="row4646195719548"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p4642195718541"><a name="p4642195718541"></a><a name="p4642195718541"></a>Apex function</p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p864205725412"><a name="p864205725412"></a><a name="p864205725412"></a>In the current version, Apex is implemented mainly using Python, and the customized optimization of CUDA kernel in Apex is not supported.</p>
</td>
</tr>
</tbody>
</table>
### Compatibility
Atlas 800 (model 9010): CentOS 7.6, Ubuntu 18.04/2.04, BC-Linux 7.6, Debian 9.9, Debian 10, openEuler 20.03 LTS
Atlas 800 (model 9000): CentOS 7.6, Ubuntu 18.04/2.04, EulerOS 2.8/2.10, Kylin V10, BC-Linux 7.6, openEuler 20.03 LTS, UOS 20 1020e
## FrameworkPTAdapter 2.0.3
### Before You Start
This framework is modified based on the open-source PyTorch 1.5.0 developed by Facebook, inherits native PyTorch features, and uses NPUs for dynamic image training. Models are adapted by operator granularity, code can be reused, and current networks can be ported and used on NPUs with only device types or data types modified.
PyTorch 1.8.1 is supported by this version and later, and this version inherits the features of PyTorch 1.5.0 and provides the same functions, except for the Profiling tool. In addition, it optimizes the backend operator adaptation. Currently, PyTorch 1.8.1 supports only the ResNet-50 network model.
### New Features
**Table 1** Features supported by PyTorch
<table><thead align="left"><tr id="r0c10e7163bf54fe8816ab5ca2d77ccc4"><th class="cellrowborder" valign="top" width="10.459999999999999%" id="mcps1.2.4.1.1"><p id="a7888762cf8294977b7d114b1c898d1bd"><a name="a7888762cf8294977b7d114b1c898d1bd"></a><a name="a7888762cf8294977b7d114b1c898d1bd"></a>Level-1 Feature</p>
</th>
<th class="cellrowborder" valign="top" width="26.27%" id="mcps1.2.4.1.2"><p id="a4581ffde4a5f455faadfba144243a9d4"><a name="a4581ffde4a5f455faadfba144243a9d4"></a><a name="a4581ffde4a5f455faadfba144243a9d4"></a>Level-2 Feature</p>
</th>
<th class="cellrowborder" valign="top" width="63.27%" id="mcps1.2.4.1.3"><p id="a2a1562364b09433a83133fa10b3cf2b3"><a name="a2a1562364b09433a83133fa10b3cf2b3"></a><a name="a2a1562364b09433a83133fa10b3cf2b3"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row7979351559"><td class="cellrowborder" rowspan="5" valign="top" width="10.459999999999999%" headers="mcps1.2.4.1.1 "><p id="p69836331553"><a name="p69836331553"></a><a name="p69836331553"></a>PyTorch features adapted to NPUs</p>
</td>
<td class="cellrowborder" valign="top" width="26.27%" headers="mcps1.2.4.1.2 "><p id="p149831333357"><a name="p149831333357"></a><a name="p149831333357"></a>PyTorch 1.8.1</p>
</td>
<td class="cellrowborder" valign="top" width="63.27%" headers="mcps1.2.4.1.3 "><p id="p1398313336511"><a name="p1398313336511"></a><a name="p1398313336511"></a>Added PyTorch 1.8.1. Currently, only the ResNet-50 network is supported, including the training scenario for distributed data parallel (DDP).</p>
</td>
</tr>
<tr id="row109719353511"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p18983183315515"><a name="p18983183315515"></a><a name="p18983183315515"></a>Python 3.8</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p836221112812"><a name="p836221112812"></a><a name="p836221112812"></a>Supported compilation and use of Python 3.8.</p>
</td>
</tr>
<tr id="row13971435754"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p79831331353"><a name="p79831331353"></a><a name="p79831331353"></a>Operator overflow/underflow detection tool</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p109832331055"><a name="p109832331055"></a><a name="p109832331055"></a>Supported IR-level operator overflow/underflow detection in the PyTorch framework. When an AI Core operator overflow/underflow occurs, the IR information is displayed.</p>
</td>
</tr>
<tr id="row185381431133610"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p953883153611"><a name="p953883153611"></a><a name="p953883153611"></a>OS compatibility</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p13538203153618"><a name="p13538203153618"></a><a name="p13538203153618"></a>Supported UOS 20 1020e ARM.</p>
</td>
</tr>
<tr id="row91681125173610"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p2168172519364"><a name="p2168172519364"></a><a name="p2168172519364"></a>Basic framework functions</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1416815259367"><a name="p1416815259367"></a><a name="p1416815259367"></a>Added the function of adapted operator development. For details, see the operator list.</p>
</td>
</tr>
<tr id="row11970351050"><td class="cellrowborder" rowspan="26" valign="top" width="10.459999999999999%" headers="mcps1.2.4.1.1 "><p id="p298314333514"><a name="p298314333514"></a><a name="p298314333514"></a>Model training</p>
</td>
<td class="cellrowborder" valign="top" width="26.27%" headers="mcps1.2.4.1.2 "><p id="p19984193312511"><a name="p19984193312511"></a><a name="p19984193312511"></a>CenterFace</p>
</td>
<td class="cellrowborder" valign="top" width="63.27%" headers="mcps1.2.4.1.3 "><p id="p7517351258"><a name="p7517351258"></a><a name="p7517351258"></a>-</p>
</td>
</tr>
<tr id="row9965351254"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1984033458"><a name="p1984033458"></a><a name="p1984033458"></a>PCBU</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p298411338513"><a name="p298411338513"></a><a name="p298411338513"></a>-</p>
</td>
</tr>
<tr id="row14966351959"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p198414331957"><a name="p198414331957"></a><a name="p198414331957"></a>Net++</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1798413331756"><a name="p1798413331756"></a><a name="p1798413331756"></a>-</p>
</td>
</tr>
<tr id="row20966351454"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p4984183317518"><a name="p4984183317518"></a><a name="p4984183317518"></a>FCN8S</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1698453311519"><a name="p1698453311519"></a><a name="p1698453311519"></a>-</p>
</td>
</tr>
<tr id="row19653517518"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1298483319512"><a name="p1298483319512"></a><a name="p1298483319512"></a>OSNetRetinaFace</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1798423312519"><a name="p1798423312519"></a><a name="p1798423312519"></a>-</p>
</td>
</tr>
<tr id="row39619351751"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1298414331513"><a name="p1298414331513"></a><a name="p1298414331513"></a>PSPnet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p10984633254"><a name="p10984633254"></a><a name="p10984633254"></a>-</p>
</td>
</tr>
<tr id="row496335654"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p19984433351"><a name="p19984433351"></a><a name="p19984433351"></a>EDSR</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p898473314517"><a name="p898473314517"></a><a name="p898473314517"></a>-</p>
</td>
</tr>
<tr id="row17953357517"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p14984123312515"><a name="p14984123312515"></a><a name="p14984123312515"></a>Tsm</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p159841033855"><a name="p159841033855"></a><a name="p159841033855"></a>-</p>
</td>
</tr>
<tr id="row16951435551"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p19984933457"><a name="p19984933457"></a><a name="p19984933457"></a>pnasnet5large</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p89846335512"><a name="p89846335512"></a><a name="p89846335512"></a>-</p>
</td>
</tr>
<tr id="row2095113520514"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1798416331952"><a name="p1798416331952"></a><a name="p1798416331952"></a>Gaitset</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p098417336516"><a name="p098417336516"></a><a name="p098417336516"></a>-</p>
</td>
</tr>
<tr id="row89516351511"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p11985153312516"><a name="p11985153312516"></a><a name="p11985153312516"></a>fcn</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p169858331155"><a name="p169858331155"></a><a name="p169858331155"></a>-</p>
</td>
</tr>
<tr id="row5953353513"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p18985103311514"><a name="p18985103311514"></a><a name="p18985103311514"></a>Albert</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p2098513334519"><a name="p2098513334519"></a><a name="p2098513334519"></a>-</p>
</td>
</tr>
<tr id="row119533516513"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p598511336511"><a name="p598511336511"></a><a name="p598511336511"></a>AdvancedEast</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p119850331513"><a name="p119850331513"></a><a name="p119850331513"></a>-</p>
</td>
</tr>
<tr id="row39511356512"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p698553311512"><a name="p698553311512"></a><a name="p698553311512"></a>ReidStrongBaseline</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1198514331659"><a name="p1198514331659"></a><a name="p1198514331659"></a>-</p>
</td>
</tr>
<tr id="row129463518517"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p99851633158"><a name="p99851633158"></a><a name="p99851633158"></a>Fast-scnn</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1298514331359"><a name="p1298514331359"></a><a name="p1298514331359"></a>-</p>
</td>
</tr>
<tr id="row9942035757"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p109854331151"><a name="p109854331151"></a><a name="p109854331151"></a>RDN</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1198583317511"><a name="p1198583317511"></a><a name="p1198583317511"></a>-</p>
</td>
</tr>
<tr id="row79415357517"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p6985833351"><a name="p6985833351"></a><a name="p6985833351"></a>SRFlow</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p29851033350"><a name="p29851033350"></a><a name="p29851033350"></a>-</p>
</td>
</tr>
<tr id="row12947357514"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p149859334518"><a name="p149859334518"></a><a name="p149859334518"></a>MGN</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p19851833850"><a name="p19851833850"></a><a name="p19851833850"></a>-</p>
</td>
</tr>
<tr id="row3941735855"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p898533316518"><a name="p898533316518"></a><a name="p898533316518"></a>Roberta</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p998553318518"><a name="p998553318518"></a><a name="p998553318518"></a>-</p>
</td>
</tr>
<tr id="row1093335856"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1985533451"><a name="p1985533451"></a><a name="p1985533451"></a>RegNetY</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p59851033355"><a name="p59851033355"></a><a name="p59851033355"></a>-</p>
</td>
</tr>
<tr id="row49373518516"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p19986173311512"><a name="p19986173311512"></a><a name="p19986173311512"></a>VoVNet-39</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p798683310515"><a name="p798683310515"></a><a name="p798683310515"></a>-</p>
</td>
</tr>
<tr id="row5930351357"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p189862336515"><a name="p189862336515"></a><a name="p189862336515"></a>RegNetX</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1398618331651"><a name="p1398618331651"></a><a name="p1398618331651"></a>-</p>
</td>
</tr>
<tr id="row169312351655"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p149863337513"><a name="p149863337513"></a><a name="p149863337513"></a>RefineNet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p2098615331959"><a name="p2098615331959"></a><a name="p2098615331959"></a>-</p>
</td>
</tr>
<tr id="row11931235957"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1198616331657"><a name="p1198616331657"></a><a name="p1198616331657"></a>RefineDet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1698611332518"><a name="p1698611332518"></a><a name="p1698611332518"></a>-</p>
</td>
</tr>
<tr id="row189215359511"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p16986183319512"><a name="p16986183319512"></a><a name="p16986183319512"></a>AlignedReID</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1898715331055"><a name="p1898715331055"></a><a name="p1898715331055"></a>-</p>
</td>
</tr>
<tr id="row89213351858"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p119878330511"><a name="p119878330511"></a><a name="p119878330511"></a>FaceBoxes</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p129878331158"><a name="p129878331158"></a><a name="p129878331158"></a>-</p>
</td>
</tr>
</tbody>
</table>
### Modified Features
N/A
### Resolved Issues
N/A
### Known Issues
<table><thead align="left"><tr id="row3699162017307"><th class="cellrowborder" valign="top" width="18.22%" id="mcps1.1.3.1.1"><p id="p16992020153010"><a name="p16992020153010"></a><a name="p16992020153010"></a>Known Issue</p>
</th>
<th class="cellrowborder" valign="top" width="81.78%" id="mcps1.1.3.1.2"><p id="p269919203308"><a name="p269919203308"></a><a name="p269919203308"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row9699142003011"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p1769932017300"><a name="p1769932017300"></a><a name="p1769932017300"></a>Data type support</p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p13699152010301"><a name="p13699152010301"></a><a name="p13699152010301"></a>NPUs do not support the input or output of the inf/nan data of the float16 type.</p>
</td>
</tr>
<tr id="row146991520153016"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p156997200308"><a name="p156997200308"></a><a name="p156997200308"></a>Data format</p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p10699182020308"><a name="p10699182020308"></a><a name="p10699182020308"></a>Dimensions cannot be reduced when the format larger than 4D is used.</p>
</td>
</tr>
<tr id="row11121205610549"><td class="cellrowborder" rowspan="3" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p1647216219558"><a name="p1647216219558"></a><a name="p1647216219558"></a>Restrictions on collective communication</p>
<p id="p0465121912402"><a name="p0465121912402"></a><a name="p0465121912402"></a></p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p3116115695415"><a name="p3116115695415"></a><a name="p3116115695415"></a>The graphs executed on different devices in a training job must be the same.</p>
</td>
</tr>
<tr id="row51211656105411"><td class="cellrowborder" valign="top" headers="mcps1.1.3.1.1 "><p id="p1311616560541"><a name="p1311616560541"></a><a name="p1311616560541"></a>Allocation at only 1, 2, 4, or 8 processors is supported.</p>
</td>
</tr>
<tr id="row8647195765419"><td class="cellrowborder" valign="top" headers="mcps1.1.3.1.1 "><p id="p2064225716544"><a name="p2064225716544"></a><a name="p2064225716544"></a>Only the int8, int32, float16, and float32 data types are supported.</p>
</td>
</tr>
<tr id="row4646195719548"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p4642195718541"><a name="p4642195718541"></a><a name="p4642195718541"></a>Apex function</p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p864205725412"><a name="p864205725412"></a><a name="p864205725412"></a>In the current version, Apex is implemented mainly using Python, and the customized optimization of CUDA kernel in Apex is not supported.</p>
</td>
</tr>
</tbody>
</table>
### Compatibility
Atlas 800 (model 9010): CentOS 7.6, Ubuntu 18.04, BC-Linux 7.6, Debian 9.9, Debian 10, openEuler 20.03 LTS
Atlas 800 (model 9000): CentOS 7.6, Euler 2.8, Kylin v10, BC-Linux 7.6, openEuler 20.03 LTS, UOS 20 1020e
## FrameworkPTAdapter 2.0.2
### Before You Start
This framework is modified based on the open-source PyTorch 1.5.0 primarily developed by Facebook, inherits native PyTorch features, and uses NPUs for dynamic image training. Models are adapted by operator granularity, code can be reused, and current networks can be ported and used on NPUs with only device types or data types modified.
### New Features
**Table 1** Features supported by PyTorch
<table><thead align="left"><tr id="r0c10e7163bf54fe8816ab5ca2d77ccc4"><th class="cellrowborder" valign="top" width="10.489999999999998%" id="mcps1.2.4.1.1"><p id="a7888762cf8294977b7d114b1c898d1bd"><a name="a7888762cf8294977b7d114b1c898d1bd"></a><a name="a7888762cf8294977b7d114b1c898d1bd"></a>Level-1 Feature</p>
</th>
<th class="cellrowborder" valign="top" width="26.3%" id="mcps1.2.4.1.2"><p id="a4581ffde4a5f455faadfba144243a9d4"><a name="a4581ffde4a5f455faadfba144243a9d4"></a><a name="a4581ffde4a5f455faadfba144243a9d4"></a>Level-2 Feature</p>
</th>
<th class="cellrowborder" valign="top" width="63.21%" id="mcps1.2.4.1.3"><p id="a2a1562364b09433a83133fa10b3cf2b3"><a name="a2a1562364b09433a83133fa10b3cf2b3"></a><a name="a2a1562364b09433a83133fa10b3cf2b3"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row171322953713"><td class="cellrowborder" rowspan="7" valign="top" width="10.489999999999998%" headers="mcps1.2.4.1.1 "><p id="p10237517181"><a name="p10237517181"></a><a name="p10237517181"></a>Adapted training models</p>
</td>
<td class="cellrowborder" valign="top" width="26.3%" headers="mcps1.2.4.1.2 "><p id="p6134294377"><a name="p6134294377"></a><a name="p6134294377"></a>YOLOv4</p>
</td>
<td class="cellrowborder" valign="top" width="63.21%" headers="mcps1.2.4.1.3 "><p id="p314533811397"><a name="p314533811397"></a><a name="p314533811397"></a>-</p>
</td>
</tr>
<tr id="row15990182233714"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p399019224374"><a name="p399019224374"></a><a name="p399019224374"></a>YOLOv3</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1714553816396"><a name="p1714553816396"></a><a name="p1714553816396"></a>-</p>
</td>
</tr>
<tr id="row5301255373"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1530325123719"><a name="p1530325123719"></a><a name="p1530325123719"></a>DB</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p5146193819390"><a name="p5146193819390"></a><a name="p5146193819390"></a>-</p>
</td>
</tr>
<tr id="row274203413712"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p197423343379"><a name="p197423343379"></a><a name="p197423343379"></a>RFCN</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p15828941153919"><a name="p15828941153919"></a><a name="p15828941153919"></a>-</p>
</td>
</tr>
<tr id="row78671918163714"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p188671318183713"><a name="p188671318183713"></a><a name="p188671318183713"></a>CRNN</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p10828241123917"><a name="p10828241123917"></a><a name="p10828241123917"></a>-</p>
</td>
</tr>
<tr id="row16912221171"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p6913132676"><a name="p6913132676"></a><a name="p6913132676"></a>Densenset161</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p209131221474"><a name="p209131221474"></a><a name="p209131221474"></a>-</p>
</td>
</tr>
<tr id="row1016073314719"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p3160153320717"><a name="p3160153320717"></a><a name="p3160153320717"></a>Densenset191</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1516012331173"><a name="p1516012331173"></a><a name="p1516012331173"></a>-</p>
</td>
</tr>
<tr id="row9627165910386"><td class="cellrowborder" rowspan="4" valign="top" width="10.489999999999998%" headers="mcps1.2.4.1.1 "><p id="p1561535993811"><a name="p1561535993811"></a><a name="p1561535993811"></a>PyTorch features adapted to NPUs</p>
</td>
<td class="cellrowborder" valign="top" width="26.3%" headers="mcps1.2.4.1.2 "><p id="p136151659163819"><a name="p136151659163819"></a><a name="p136151659163819"></a>Basic framework functions</p>
</td>
<td class="cellrowborder" valign="top" width="63.21%" headers="mcps1.2.4.1.3 "><p id="p1661535983813"><a name="p1661535983813"></a><a name="p1661535983813"></a>Added the function of adapted operator development. For details, see the operator list.</p>
</td>
</tr>
<tr id="row7627155917380"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1561525916383"><a name="p1561525916383"></a><a name="p1561525916383"></a>Model Accuracy Analyzer</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p19616115953816"><a name="p19616115953816"></a><a name="p19616115953816"></a>Added the Model Accuracy Analyzer and supported training accuracy demarcation.</p>
</td>
</tr>
<tr id="row46269593383"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p0616559163819"><a name="p0616559163819"></a><a name="p0616559163819"></a>Ascend 710 AI Processor</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p186161459193813"><a name="p186161459193813"></a><a name="p186161459193813"></a>Supported the online inference on Ascend 710 AI Processors.</p>
</td>
</tr>
<tr id="row76261059153817"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p11616175953812"><a name="p11616175953812"></a><a name="p11616175953812"></a>OS compatibility</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p8935115971714"><a name="p8935115971714"></a><a name="p8935115971714"></a>Supported Ubuntu 18.04.5 and openEuler 20.03 LTS.</p>
</td>
</tr>
</tbody>
</table>
### Modified Features
N/A
### Resolved Issues
N/A
### Known Issues
<table><thead align="left"><tr id="row3699162017307"><th class="cellrowborder" valign="top" width="18.22%" id="mcps1.1.3.1.1"><p id="p16992020153010"><a name="p16992020153010"></a><a name="p16992020153010"></a>Known Issue</p>
</th>
<th class="cellrowborder" valign="top" width="81.78%" id="mcps1.1.3.1.2"><p id="p269919203308"><a name="p269919203308"></a><a name="p269919203308"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row9699142003011"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p1769932017300"><a name="p1769932017300"></a><a name="p1769932017300"></a>Data type support</p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p13699152010301"><a name="p13699152010301"></a><a name="p13699152010301"></a>NPUs do not support the input or output of the inf/nan data of the float16 type.</p>
</td>
</tr>
<tr id="row146991520153016"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p156997200308"><a name="p156997200308"></a><a name="p156997200308"></a>Data format</p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p10699182020308"><a name="p10699182020308"></a><a name="p10699182020308"></a>Dimensions cannot be reduced when the format larger than 4D is used.</p>
</td>
</tr>
<tr id="row11121205610549"><td class="cellrowborder" rowspan="3" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p1647216219558"><a name="p1647216219558"></a><a name="p1647216219558"></a>Restrictions on collective communication</p>
<p id="p0465121912402"><a name="p0465121912402"></a><a name="p0465121912402"></a></p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p3116115695415"><a name="p3116115695415"></a><a name="p3116115695415"></a>The graphs executed on different devices in a training job must be the same.</p>
</td>
</tr>
<tr id="row51211656105411"><td class="cellrowborder" valign="top" headers="mcps1.1.3.1.1 "><p id="p1311616560541"><a name="p1311616560541"></a><a name="p1311616560541"></a>Allocation at only 1, 2, 4, or 8 processors is supported.</p>
</td>
</tr>
<tr id="row8647195765419"><td class="cellrowborder" valign="top" headers="mcps1.1.3.1.1 "><p id="p2064225716544"><a name="p2064225716544"></a><a name="p2064225716544"></a>Only the int8, int32, float16, and float32 data types are supported.</p>
</td>
</tr>
<tr id="row4646195719548"><td class="cellrowborder" valign="top" width="18.22%" headers="mcps1.1.3.1.1 "><p id="p4642195718541"><a name="p4642195718541"></a><a name="p4642195718541"></a>Apex function</p>
</td>
<td class="cellrowborder" valign="top" width="81.78%" headers="mcps1.1.3.1.2 "><p id="p864205725412"><a name="p864205725412"></a><a name="p864205725412"></a>In the current version, Apex is implemented mainly using Python, and the customized optimization CUDA kernel in Apex is not supported.</p>
</td>
</tr>
</tbody>
</table>
### Compatibility
Atlas 800 (model 9010): CentOS 7.6/Ubuntu 18.04/BC-Linux 7.6/Debian 9.9/Debian 10/openEuler 20.03 LTS
Atlas 800 (model 9000): CentOS 7.6/EulerOS 2.8/Kylin v10/BC-Linux 7.6/openEuler 20.03 LTS
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,900 @@
# Overview
Users can obtain PyTorch training models from Ascend ModelZoo, but the models do not support multi-server multi-device training. You need to modify the models based on the actual model code. This document describes how to quickly train a PyTorch model in Distributed Data Parallel (DDP) mode in multi-server multi-device scenario.
# Training Workflow
The process of training a PyTorch model in multi-server multi-device scenario includes environment preparation, model preparation, model modification, and training startup.
1. Environment Preparation
Prepare the software, hardware, and network environment for multi-server multi-device training, including setting up the development and operating environment, connecting the cluster network, setting the processor IP address, and setting the firewall.
2. Model Preparation
Prepare a PyTorch model, data loader, and optimizer for training. You can download them from the open source community (https://gitee.com/ascend/modelzoo/tree/master/built-in/PyTorch) or prepare them by yourself.
3. Model Modification
Modify the basic model and add the code and environment variables required by DDP to enable the multi-server multi-device training.
4. Training Startup
Start model training in the multi-server multi-device scenario and view training logs.
# Quick Start
## Overview
The example presented in this document helps you quickly understand how a PyTorch model is trained in multi-server multi-device scenario. The example uses a custom model for training in two-computer eight-device scenario. The two computers are named AI Server0 and AI Server1. The eight Ascend 910 Processors on each computer are named device0 to device7.
## Preparing the Environment
At least two computers with Ascend 910 Processors installed are required, and the NPU firmware and driver are correctly installed on each computer.
1. Prepare the development and operating environment on each computer.
- Install the CANN development and operating environment. For details, see the *CANN Software Installation Guide*. Use CANN later than 5.0.3.
- Install the PyTorch that adapts to NPU. For details, see the *PyTorch Installation Guide*.
2. Prepare the network.
Set up the network by directly connecting switches or optical ports. For details, see the *Ascend Data Center Solution Networking Guide* at https://support.huawei.com/enterprise/en/doc/EDOC1100221995/229cc0e4.
In this example, two computers with eight devices are used for training, so optical ports are used for network connection.
3. Configure the device IP address.
Configure the device IP address on AI Server0.
```shell
hccn_tool -i 0 -ip -s address 192.168.100.101 netmask 255.255.255.0
hccn_tool -i 1 -ip -s address 192.168.101.101 netmask 255.255.255.0
hccn_tool -i 2 -ip -s address 192.168.102.101 netmask 255.255.255.0
hccn_tool -i 3 -ip -s address 192.168.103.101 netmask 255.255.255.0
hccn_tool -i 4 -ip -s address 192.168.100.100 netmask 255.255.255.0
hccn_tool -i 5 -ip -s address 192.168.101.100 netmask 255.255.255.0
hccn_tool -i 6 -ip -s address 192.168.102.100 netmask 255.255.255.0
hccn_tool -i 7 -ip -s address 192.168.103.100 netmask 255.255.255.0
```
Configure the device IP address on AI Server1.
```shell
hccn_tool -i 0 -ip -s address 192.168.100.111 netmask 255.255.255.0
hccn_tool -i 1 -ip -s address 192.168.101.111 netmask 255.255.255.0
hccn_tool -i 2 -ip -s address 192.168.102.111 netmask 255.255.255.0
hccn_tool -i 3 -ip -s address 192.168.103.111 netmask 255.255.255.0
hccn_tool -i 4 -ip -s address 192.168.100.110 netmask 255.255.255.0
hccn_tool -i 5 -ip -s address 192.168.101.110 netmask 255.255.255.0
hccn_tool -i 6 -ip -s address 192.168.102.110 netmask 255.255.255.0
hccn_tool -i 7 -ip -s address 192.168.103.110 netmask 255.255.255.0
```
4. Configure the firewall.
- Command for disabling the firewall on Ubuntu:
```shell
ufw disable
```
```
- Command for disabling the firewall on Red Hat or CentOS 7:
```shell
systemctl stop firewalld
```
## Preparing a Model
This example creates a simple model for you to quickly understand multi-server multi-device training. You can also obtain the Ascend NPU-based PyTorch training model from the open source community (https://gitee.com/ascend/modelzoo/tree/master/built-in/PyTorch).
1. Prepare a DDP model.
The following is an example of main.py for multi-server multi-device training.
```python
import argparse
import os
import torch
import torchvision
import torch.nn as nn
import torch.nn.functional as F
import torch.distributed as dist
from torch.nn.parallel import DistributedDataParallel as DDP
### 1. Perform basic operations. ###
# Build a model.
class ToyModel(nn.Module):
def __init__(self):
super(ToyModel, self).__init__()
self.conv1 = nn.Conv2d(3, 6, 5)
self.pool = nn.MaxPool2d(2, 2)
self.conv2 = nn.Conv2d(6, 16, 5)
self.fc1 = nn.Linear(16 * 5 * 5, 120)
self.fc2 = nn.Linear(120, 84)
self.fc3 = nn.Linear(84, 10)
def forward(self, x):
x = self.pool(F.relu(self.conv1(x)))
x = self.pool(F.relu(self.conv2(x)))
x = x.view(-1, 16 * 5 * 5)
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return x
# Obtain a dataset.
def get_dataset():
transform = torchvision.transforms.Compose([
torchvision.transforms.ToTensor(),
torchvision.transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
])
my_trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
download=True, transform=transform)
train_sampler = torch.utils.data.distributed.DistributedSampler(my_trainset)
trainloader = torch.utils.data.DataLoader(my_trainset,
batch_size=16, num_workers=2, sampler=train_sampler)
return trainloader
### 2. Initialize the parameters, data, model, loss function, and optimizer. ####
# Obtain local_rank and addr.
parser = argparse.ArgumentParser()
parser.add_argument("--local_rank", default=-1, type=int)
parser.add_argument("--addr", default='127.0.0.1', type=str, help='master addr')
FLAGS = parser.parse_args()
local_rank = FLAGS.local_rank
addr = FLAGS.addr
# Set the IP address and port of the master node.
os.environ['MASTER_ADDR'] = addr
os.environ['MASTER_PORT'] = '29501'
# Initialize the DDP backend.
loc = 'npu:{}'.format(local_rank)
torch.npu.set_device(loc)
dist.init_process_group(backend='hccl') # HCCL is the backend of the NPU device.
# Prepare data after DDP initialization.
trainloader = get_dataset()
# Instantiate the model.
model = ToyModel().to(loc)
# Load the model weight. The weight needs to be loaded only on the master node before the DDP model is built.
ckpt_path = None
if dist.get_rank() == 0 and ckpt_path is not None:
model.load_state_dict(torch.load(ckpt_path))
# Build the DDP model.
model = DDP(model, device_ids=[local_rank], output_device=local_rank)
# Initialize the optimizer. After the DDP model is built, use the model to initialize the optimizer.
optimizer = torch.optim.SGD(model.parameters(), lr=0.001)
# Initialize the loss function.
loss_func = nn.CrossEntropyLoss().to(loc)
### 3. Train the network.
model.train()
iterator = range(100)
for epoch in iterator:
trainloader.sampler.set_epoch(epoch)
for data, label in trainloader:
data, label = data.to(local_rank), label.to(local_rank)
optimizer.zero_grad()
prediction = model(data)
loss = loss_func(prediction, label)
loss.backward()
print("loss = %0.3f \n" % loss)
optimizer.step()
# 1. Similar to the DP mode, when you save a model, note that model.module instead of model is saved.
# That is because the model actually refers to a DDP model, and the parameters are packaged by `model=DDP(model)`.
# 2. You only need to save the model on process 0 once to avoid repeated saving.
if dist.get_rank() == 0:
torch.save(model.module.state_dict(), "%d.ckpt" % epoch)
```
2. Ensure that the model is correct for training in the single-server multi-device scenario.
1. The Python third-party library is required if you install the model script yourself.
2. Configure NPU environment variables. For information about the **env_npu.sh** script, see the appendix.
```shell
source env_npu.sh
```
3. Execute **torch.distributed.launch** to run the following main.py command to train a model in single-server multi-device scenario.
```shell
python -m torch.distributed.launch --nproc_per_node 8 main.py
```
`--nproc_per_node` indicates the number of training cards.
After the command is run successfully, the model is trained on the eight NPUs of the device.
## Modifying the Model
The example provided in "Quick Start" is adapted to the multi-server multi-device training. You do not need to modify the script. For details about how to modify other models, see section "Multi-server Multi-device Training".
## Starting the Training
1. Upload main.py model script to any directory on AI Server0 and AI Server1.
2. Query the host IP addresses of the servers.
```shell
hostname -I
```
All IP addresses are displayed, and the first IP address is the host IP address of the current server.
For example, the host IP address of AI Server0 is **192.168.*xx*.22**, and that of AI Server1 is **192.168.*xx*.23**.
3. Use AI Server0 as the master node, and start the 2 x 8 cluster.
Startup commands for AI Server0:
```shell
# Set environment variables. Obtain the env_npu.sh script content from the appendix.
source env_npu.sh
# Disable the trustlist of HCCL channel.
export HCCL_WHITELIST_DISABLE=1
# Initialize the IP address of the HCCL communication NIC, and set the IP address to the host IP address of the current server.
export HCCL_IF_IP=192.168.xx.22
#
python3.7 -m torch.distributed.launch --nnodes=2 --node_rank=0 --nproc_per_node 8 --master_addr 192.168.xx.22 --master_port 29501 main.py --addr 192.168.xx.22
```
Startup commands for AI Server1:
```shell
# Set environment variables. Obtain the env_npu.sh script content from the appendix.
source env_npu.sh
# Disable the trustlist of HCCL channel.
export HCCL_WHITELIST_DISABLE=1
# Initialize the IP address of the HCCL communication NIC, and set the IP address to the host IP address of the current server.
export HCCL_IF_IP=192.168.xx.23
python3.7 -m torch.distributed.launch --nnodes=2 --node_rank=1 --nproc_per_node 8 --master_addr 192.168.xx.22 --master_port 29501 main.py --addr 192.168.xx.22
```
Parameter description:
--nnode: specifies the number of nodes used for distributed training scripts.
--node_rank: specifies the rank of the current node during multi-node distributed training.
--nproc_per_node: specifies the number of GPU-based training processes on the current node.
--master_addr: address of the master node (rank is 0). The value can be the IP address or the host name of node 0.
--master_port: specifies the port number used by the master node during distributed training.
--addr: input parameter of the main.py script, specifying the host IP address of the master node.
3. View the host logs.
Host logs are stored in the `~/ascend/log` directory. You can go to this directory to view the device logs of each host.
# Multi-server Multi-device Training
## Common Concepts and Parameters
Basic concepts for PyTorch distributed training
| Basic Concept | Description |
| :-----------: | ------------------------------------------------------------ |
| AI Server | Computer with an Ascend 910 Processors. Multiple computers are identified as AI Server +serial number, for example, AI Server0 and AI Server1. |
| device | Ascend 910 Processors on the AI server. Multiple processors are represented as device 0, device 1, ..., and device 7. |
| host | AI server host. |
| master | Select one of multiple AI servers as the master node for data communication. |
| group | Process group. By default, there is only one group. Use the default value. |
| world size | Number of global parallel processes, which can be obtained by running **torch.distributed.get_world_size()**. The value is the same for different processes. |
| rank | Sequence number of the current process, which is used for communication between processes. For example, for a 2 x 8 cluster, the **world size** is 16, and the rank in each process is [0, 1, 2, ..., 15]. |
| local_rank | Sequence number of processes on each host, for example, there are processes 0-7 on each host. Generally, **local_rank** is used to set the GPU/NPU on which the current model runs. |
Parameters for executing **torch.distributed.launch** to start multi-device training
| Parameter | Description |
| ------------------ | ------------------------------------------------------------ |
| **nnodes** | Specifies the number of nodes used for distributed training scripts. |
| **node_rank** | Specifies the rank of the current node during multi-node distributed training. |
| **nproc_per_node** | Specifies the number of GPU-based training processes on the current node. You are advised to set this parameter to the number of GPUs on the current node. In this way, each process can independently control a GPU to achieve the highest efficiency. |
| **master_addr** | Address of the master node (rank is 0). The value can be the IP address or the host name of node 0. For single-node multi-process training, set this parameter to **127.0.0.1**. |
| **master_port**: | Specifies the port number used by the master node during distributed training. The port number must be different from the port numbers of other applications. |
## Multi-server Multi-device Training Process
### Preparing the Environment
At least two computers with Ascend 910 Processors installed are required, and the NPU firmware and driver are correctly installed on each server.
1. Prepare the development and operating environment on each computer.
- Install the CANN development and operating environment. For details, see the *CANN Software Installation Guide*. Use CANN later than 5.0.3.
- Install the PyTorch that adapts to NPU. For details, see the *PyTorch Installation Guide.*
2. Prepare the network.
Cluster training is completed by multiple computers (a maximum of 128) with Ascend 910 Processors installed. The computers need to work with switches to form a fully-connected active/standby network on the data plane. The 8 x *n*-device training is supported. Two computers can be directly connected through optical ports. For details, see the *Ascend Data Center Solution Networking Guide * at https://support.huawei.com/enterprise/en/doc/EDOC1100221995/229cc0e4.
3. Configure the device IP address.
Use hccn_tool to configure the device IP address. hccn_tool is provided by CANN.
```shell
hccn_tool -i 0 -ip -s address 192.168.100.111 netmask 255.255.255.0
```
Observe the following rules when configuring the device IP address:
1. On the AI servers, devices 0/4, 1/5, 2/6, and 3/7 must be in the same network segment. But devices 0, 1, 2, and 3 must be in different network segments, and devices 4, 5, 6, and 7 must be in different network segments.
2. In the cluster scenario, the devices corresponding to each AI server must be in the same network segment. NICs 0 and 1 of AI Server0 and AI Server1 must be in the same network segment.
3. Each IP address must be unique. IP addresses in the same network segment must be distinguished by the last eight bits.
Use hccn_tool to check whether the device IP address is correct.
- Query the IP address of each device.
```shell
hccn_tool -i 0 -ip –g
```
The IP addresses are displayed:
> ipaddr:192.168.100.101
>
> netmask:255.255.255.0
- Use hccn_tool to ensure that the devices of the two hosts are correctly connected by performing the test for eight times from device0 to devcie7.
```shell
hccn_tool -i 0 -netdetect -s address xx.xx.xx.xx
hccn_tool -i 0 -net_health –g
```
**-i**: device ID.
**-s address**: ***xx.xx.xx.xx*** is the IP address of device *i* on the other host.
If `success` is returned, the connection is successful.
4. Configure the firewall.
During HCCL communication, the firewall may intercept the communication port, causing communication timeout. Therefore, you need to disable the firewall on the server for PyTorch cluster training.
- Command for disabling the firewall on Ubuntu:
```shell
ufw disable
```
- Command for disabling the firewall on Red Hat or CentOS 7:
```shell
systemctl stop firewalld
```
### Preparing a Model
There are two methods for preparing a model.
- Download a PyTorch training model from the open source community (https://gitee.com/ascend/modelzoo/tree/master/built-in/PyTorch).
The model obtained from the open source community supports single-server multi-device training. Modify the model based on the related parameters described in section "Modifying the Model".
- Manually build a PyTorch training model.
1. Prepare a PyTorch training model and data loader.
Prepare a PyTorch model:
```python
class ToyModel(nn.Module):
def __init__(self):
...
def forward(self,x):
...
```
Prepare data:
```python
def get_dataset():
transform = torchvision.transforms.Compose([
torchvision.transforms.ToTensor(),
torchvision.transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
])
my_trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
download=True, transform=transform)
trainloader = torch.utils.data.DataLoader(my_trainset,batch_size=16,)
return trainloader
trainloader=get_dataset()
```
2. Instantiate the model.
```python
# Instantiate the model.
model = ToyModel().to(loc)
# Load the model weight
if ckpt_path is not None:
model.load_state_dict(torch.load(ckpt_path))
```
3. Prepare the loss function and optimizer.
```python
# Initialize the optimizer. After the DDP model is built, use the model to initialize the optimizer.
optimizer = torch.optim.SGD(model.parameters(), lr=0.001)
# Initialize the loss function.
loss_func = nn.CrossEntropyLoss().to(loc)
```
4. Train the model.
```python
### 3. Train the network.
model.train()
iterator = range(100)
for epoch in iterator:
for data, label in trainloader:
data, label = data.to(local_rank), label.to(local_rank)
optimizer.zero_grad()
prediction = model(data)
loss = loss_func(prediction, label)
loss.backward()
print("loss = %0.3f \n" % loss)
optimizer.step()
torch.save(model.state_dict(), "%d.ckpt" % epoch)
```
### Modifying the Model
Modify the IP address and port of the master node, initialize the **distributed ** function, model DDP, data DDP, and optimizer, and modify the DDP model training method based on the initial model code.
1. Set the IP address and port for the master node. In the NPU distributed training, HCCL is used for communication, while in PyTorch, the HCCL communication mechanism that is detected by automatic topology is used. That is, **RANK_TABLE_FLIE** is not required, but the communication depends on the NIC on the host side. Therefore, you need to set environment variables in the code to set the communication NIC.
```python
os.environ['MASTER_ADDR'] = xxx.xxx.xxx.xxx
os.environ['MASTER_PORT'] = 'xxx'
```
**MASTER_ADDR**: Set this parameter to the IP address of the master node in the cluster. (Select any host as the master node.)
**MASTER_PORT**: Set this parameter to the idle port of the master node.
In the model code, the IP address and port number of the master node are generally presented as transferred parameters. In some open-source code, the IP address and port number may be presented as **127.0.0.1**. In this case, you need to modify them.
The preceding variables must be declared before **torch.distributed.init_process_group()** is invoked.
2. Initialize **distributed**.
In PyTorch, `dist.init_process_group(backend='hccl', world_size=world_size, rank=rank)` is used to initialize thread groups. The parameters are described as follows:
`backend`: communication protocol used for distributed training. Only hccl can be used on the NPU.
`world_size`: total number of devices used for training.
`rank`: rank ID of the currently initialized device, that is, the global logical ID.
There are two methods to start multi-device training:
- **torch.distributed.launch**:
```python
import torch.distributed as dist
dist.init_process_group(backend='hccl') # HCCL is the backend of the NPU device.
```
- **mp.spawn**:
```python
import torch.distributed as dist
def main_worker(pid_idx, device_nums_per_node, args):
args.distributed_rank = args.rank * device_nums_per_node + pid_idx
dist.init_process_group(backend=args.dist_backend, world_size=args.distributed_world_size, rank=args.distributed_rank)
```
In the preceding commands:
`pid_idx`: device ID.
`device_nums_per_node`: number of devices on each AI server.
3. Initialize the model DDP.
```python
# Instantiate the model.
model = ToyModel().to(loc)
# Load the model weight. It needs to be loaded only on the master node before the DDP model is built.
if dist.get_rank() == 0 and ckpt_path is not None:
model.load_state_dict(torch.load(ckpt_path))
# Build the DDP model.
model = DDP(model, device_ids=[local_rank], output_device=local_rank)
```
4. Initialize the data DDP.
```python
def get_dataset():
transform = torchvision.transforms.Compose([
torchvision.transforms.ToTensor(),
torchvision.transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
])
my_trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
download=True, transform=transform)
train_sampler = torch.utils.data.distributed.DistributedSampler(my_trainset)
trainloader = torch.utils.data.DataLoader(my_trainset,
batch_size=16, num_workers=2, sampler=train_sampler)
return trainloader
trainloader = get_dataset()
```
5. Initialize the loss function and optimizer.
```python
# Initialize the optimizer. After the DDP model is built, use the model to initialize the optimizer.
optimizer = torch.optim.SGD(model.parameters(), lr=0.001)
# Initialize the loss function.
loss_func = nn.CrossEntropyLoss().to(loc)
```
6. Train the DDP model.
```python
model.train()
iterator = range(100)
for epoch in iterator:
# Set epoch.
trainloader.sampler.set_epoch(epoch)
for data, label in trainloader:
data, label = data.to(local_rank), label.to(local_rank)
optimizer.zero_grad()
prediction = model(data)
loss = loss_func(prediction, label)
loss.backward()
print("loss = %0.3f \n" % loss)
optimizer.step()
# 1. Similar to the DP mode, when you save a model, note that model.module instead of model is saved.
# That is because the model actually refers to a DDP model, and the parameters are packaged by `model=DDP(model)`.
# 2. You only need to save the model on process 0 once to avoid repeated saving.
if dist.get_rank() == 0:
torch.save(model.module.state_dict(), "%d.ckpt" % epoch)
```
### Start the Training
The training can be started manually or using the shell script.
- Start the training manually using **torch.distributed.launch**.
1. Configure NPU environment variables. For details, see the **env_npu.sh** script in the appendix.
2. Add environment variables. For multi-server training, add the `HCCL_WHITELIST_DISABLE` and `HCCL_IF_IP` environment variables.
- **HCCL_WHITELIST_DISABLE**: HCCL channel trustlist. The value **1** indicates that the trustlist is disabled.
- **HCCL_IF_IP**: initialized IP address of the HCCL communication NIC. Set it to the IP address of the host NIC IP of the current server.
3. Upload the modified model script to each AI server.
4. Install the required Python library on each AI server.
5. Select an AI server as the master node and query the IP address of each AI server.
6. Run the following commands on each AI server:
```
python3 -m torch.distributed.launch --nnodes=${nnodes} --node_rank=i --nproc_per_node 8 --master_addr 192.168.xx.22 --master_port 29501 main.py --addr 192.168.xx.22
```
In the preceding commands:
**--nnodes**: number of AI servers used for distributed training scripts.
**--node_rank**: AI server ID.
**--nproc_per_node**: number of devices of each AI server.
**--master_addr**: IP address of the AI server that functions as the master node.
**--master_port**: port number of the AI server that functions as the master node.
**main.py**: Change it to the name of the startup script.
**--addr**: indicates the IP address of the master node, which is a parameter transferred to the startup script.
- Start the training using Open MPI.
1. Install the PI open-source library.
In the multi-server multi-device scenario, distributed training deployment depends on the Open MPI open-source library, which must be installed on each server that participates in model training. Currently, Open MPI 4.0.1, 4.0.2, or 4.0.3 is required.
Run the **mpirun --version** command to check whether Open MPI has been installed. If `mpirun (Open MPI) 4.0.2 Report bugs to http://www.open-mpi.org/community/help/` is returned, Open MPI has been installed. If it has been installed and its version is 4.0.1, 4.0.2, or 4.0.3, you do not need to install it again.
Otherwise, perform the following steps to install it
1. Visit the following link to download the Open MPI software package, for example, openmpi-4.0.2.tar.bz2.
https://www.open-mpi.org/software/ompi/v4.0/
2. Log in to the installation environment as the root user.
3. Upload the downloaded Open MPI software package to a directory in the installation environment.
4. Go to the directory and run the following command to decompress the software package:
```shell
tar -jxvf openmpi-4.0.2.tar.bz2
```
5. Go to the directory generated after the decompression, and run the following commands to configure, compile, and install Open MPI:
```shell
./configure --prefix=/usr/local/mpirun4.0.2
make
make install
```
The **--prefix** parameter specifies the Open MPI installation path. Change it based on the site requirements.
6. Run the **vi ~/.bashrc** command to open the **.bashrc** file, and add the following environment variables to the end of the file:
```shell
export OPENMPI=/usr/local/mpirun4.0.2
export LD_LIBRARY_PATH=$OPENMPI/lib
export PATH=$OPENMPI/bin:$PATH
```
In the environment variables, **/usr/local/mpirun4.0.2** indicates the Open MPI installation path. Change it based on the site requirements.
Run the **:wq!** command to save the file and exit.
7. Make the configuration take effect.
```
source ~/.bashrc
```
8. After the installation is complete, run the following command to check the installation version. If the required version information is displayed, the installation is successful.
```
mpirun --version
```
2. Configure SSH password-free login for the AI servers.
If Open MPI is used for distributed training deployment in the multi-server multi-device scenario, you need to configure SSH password-free login between every two servers to ensure that the servers can communicate with each other. The procedure is as follows:
1. Log in to each server as the root user.
2. Configure the reliability among hosts in the cluster.
Open the **/etc/ssh/ssh_config** file and add the following fields to the end of the file:
```
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
```
3. Open the **/etc/hosts** file on each server and add the corresponding IP address and host name of the server to the first line of the file. If the file already contains the IP address and host name, skip this step. The following is an example of the content to be added:
```
xxx.xxx.xxx.111 ubuntu
```
In the preceding content, **xxx.xxx.xxx.111** is the IP address of the server, and **ubuntu** is the host name.
4. Run the following commands on the first server to generate a public key (Assume that the IP address of the first server is **xxx.xxx.xxx.111**.):
```
cd ~/.ssh/ # If the directory does not exist, run the ssh localhost command first.
ssh-keygen -t rsa # After the key is generated, a message is displayed. Press Enter for three consecutive times.
mv id_rsa.pub authorized_keys # Renames the generated key id_rsa.pub to authorized_keys.
```
5. Generate a key on each of the other servers, and copy the keys to the **authorized_keys** file on the first server.
1. Run the following commands on each of the other servers to generate a key:
cd ~/.ssh/
ssh-keygen -t rsa
2. Download the key file **id_rsa.pub** generated on each server to the local host and copy the key in the file.
3. On the first server, run the following command to open the authorized_keys file and copy the keys of each of other servers to the end of the public key of the first server.
```
vi ~/.ssh/authorized_keys
```
Run the **:wq!** command to save the file.
6. Run the following commands on each of the other servers to copy the public key of the first server to each of the other servers:
cd ~/.ssh/
scp root@xxx.xxx.xxx.111:~/.ssh/authorized_keys ./
7. Run the following command on each server to test password-free login:
```
ssh User name@IP address
```
For example, run the **ssh root@xxx.xxx.xxx.222** command to log in to the server whose IP address is xxx.xxx.xxx.222 from the first server whose IP address is xxx.xxx.xxx.111 without a password.
If information similar to the following is displayed, the login without a password is successful.
```
Linux ubuntu 4.19.28 #1 SMP Tue Jun 23 19:05:23 EDT 2020 x86_64
The programs included with the ubuntu GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
ubuntu GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Sep 15 14:37:21 2020 from 10.254.88.75
```
You can run the **exit** command to log out of the server. If information similar to the following is displayed, the logout is successful.
```
logout
Connection to xxx.xxx.xxx.222 closed.
```
3. Use Open MPI to start model training.
1. Compile a startup script for each AI server, for example, train.sh, and move the startup script to the same path of the corresponding AI server.
```
# Configure NPU environment variables. For information about the env_npu.sh script, see the appendix.
source env_npu.sh
#Disable the trustlist of HCCL channel.
export HCCL_WHITELIST_DISABLE=1
# Initialize the IP address of the HCCL communication NIC , and set the IP address to the host IP address of the current server.
export HCCL_IF_IP=xxx.xxx.xx.xxx
python3 -m torch.distributed.launch --nnodes=${nnodes} --node_rank=i --nproc_per_node 8 --master_addr xxx.xxx.xx.xxx --master_port 29501 main.py --addr xxx.xxx.xx.xxx
```
For details about the script parameters, see section "Start the training manually using **torch.distributed.launch**".
2. Compile the startup script.
```
# Configuring the mpirun environment variables.
export PATH=$PATH:/usr/local/mpirun4.0.2/bin
# Run the mpirun tool.
mpirun -H xxx.xxx.xxx.xxx:1,xxx.xxx.xxx.xxx:1 \
--bind-to none -map-by slot \
--mca btl_tcp_if_exclude lo,docker0,endvnic\
--allow-run-as-root \
--prefix /usr/local/mpirun4.0.2/ \
./train.sh
```
In the preceding command:
**-H**: IP address of each AI server and the number of started processes.
**--bind-to**: process-binding policy.
**--mca**: MCA parameter in a specific context. **arg0** is the parameter name, and **arg1** is the parameter value.
**--allow-run-as-root**: The root user is allowed to run this script.
**--prefix**: path of mpirun4.0.2.
**./train.sh**: path of the startup script of each AI server.
4. View the log information after the training succeeds.
Host logs are stored in the `~/ascend/log` directory. You can go to this directory to view the device logs of each host.
# Appendix
The following shows the NPU environment variable configuration script **env_npu.sh**, which can be used to configure the operating and development environment variables.
```shell
#!/bin/bash
export install_path=/usr/local/Ascend
if [ -d ${install_path}/toolkit ]; then
export LD_LIBRARY_PATH=/usr/include/hdf5/lib/:/usr/local/:/usr/local/lib/:/usr/lib/:${install_path}/fwkacllib/lib64/:${install_path}/driver/lib64/common/:${install_path}/driver/lib64/driver/:${install_path}/add-ons:${path_lib}:${LD_LIBRARY_PATH}
export PATH=${install_path}/fwkacllib/ccec_compiler/bin:${install_path}/fwkacllib/bin:$PATH
export PYTHONPATH=${install_path}/fwkacllib/python/site-packages:${install_path}/tfplugin/python/site-packages:${install_path}/toolkit/python/site-packages:$PYTHONPATH
export PYTHONPATH=/usr/local/python3.7.5/lib/python3.7/site-packages:$PYTHONPATH
export ASCEND_OPP_PATH=${install_path}/opp
else
if [ -d ${install_path}/nnae/latest ];then
export LD_LIBRARY_PATH=/usr/local/:/usr/local/python3.7.5/lib/:/usr/local/openblas/lib:/usr/local/lib/:/usr/lib64/:/usr/lib/:${install_path}/nnae/latest/fwkacllib/lib64/:${install_path}/driver/lib64/common/:${install_path}/driver/lib64/driver/:${install_path}/add-ons/:/usr/lib/aarch64_64-linux-gnu:$LD_LIBRARY_PATH
export PATH=$PATH:${install_path}/nnae/latest/fwkacllib/ccec_compiler/bin/:${install_path}/nnae/latest/toolkit/tools/ide_daemon/bin/
export ASCEND_OPP_PATH=${install_path}/nnae/latest/opp/
export OPTION_EXEC_EXTERN_PLUGIN_PATH=${install_path}/nnae/latest/fwkacllib/lib64/plugin/opskernel/libfe.so:${install_path}/nnae/latest/fwkacllib/lib64/plugin/opskernel/libaicpu_engine.so:${install_path}/nnae/latest/fwkacllib/lib64/plugin/opskernel/libge_local_engine.so
export PYTHONPATH=${install_path}/nnae/latest/fwkacllib/python/site-packages/:${install_path}/nnae/latest/fwkacllib/python/site-packages/auto_tune.egg/auto_tune:${install_path}/nnae/latest/fwkacllib/python/site-packages/schedule_search.egg:$PYTHONPATH
export ASCEND_AICPU_PATH=${install_path}/nnae/latest
else
export LD_LIBRARY_PATH=/usr/local/:/usr/local/lib/:/usr/lib64/:/usr/lib/:/usr/local/python3.7.5/lib/:/usr/local/openblas/lib:${install_path}/ascend-toolkit/latest/fwkacllib/lib64/:${install_path}/driver/lib64/common/:${install_path}/driver/lib64/driver/:${install_path}/add-ons/:/usr/lib/aarch64-linux-gnu:$LD_LIBRARY_PATH
export PATH=$PATH:${install_path}/ascend-toolkit/latest/fwkacllib/ccec_compiler/bin/:${install_path}/ascend-toolkit/latest/toolkit/tools/ide_daemon/bin/
export ASCEND_OPP_PATH=${install_path}/ascend-toolkit/latest/opp/
export OPTION_EXEC_EXTERN_PLUGIN_PATH=${install_path}/ascend-toolkit/latest/fwkacllib/lib64/plugin/opskernel/libfe.so:${install_path}/ascend-toolkit/latest/fwkacllib/lib64/plugin/opskernel/libaicpu_engine.so:${install_path}/ascend-toolkit/latest/fwkacllib/lib64/plugin/opskernel/libge_local_engine.so
export PYTHONPATH=${install_path}/ascend-toolkit/latest/fwkacllib/python/site-packages/:${install_path}/ascend-toolkit/latest/fwkacllib/python/site-packages/auto_tune.egg/auto_tune:${install_path}/ascend-toolkit/latest/fwkacllib/python/site-packages/schedule_search.egg:$PYTHONPATH
export ASCEND_AICPU_PATH=${install_path}/ascend-toolkit/latest
fi
fi
#Output host logs to the serial port. 0: disable; 1: enable.
export ASCEND_SLOG_PRINT_TO_STDOUT=0
#Set the default log level. 0: debug; 1: info; 2: warning; 3: error.
export ASCEND_GLOBAL_LOG_LEVEL=3
#Enable or disable the event log. 0: disable; 1: enable.
export ASCEND_GLOBAL_EVENT_ENABLE=0
#Enable or disable taskque. 0: disable; 1: enable.
export TASK_QUEUE_ENABLE=1
#Enable or disable the HCCL trustlist. 1: disable; 0: enable.
export HCCL_WHITELIST_DISABLE=1
#Set the device-side log to error.
${install_path}/driver/tools/msnpureport -g error -d 0
${install_path}/driver/tools/msnpureport -g error -d 1
${install_path}/driver/tools/msnpureport -g error -d 2
${install_path}/driver/tools/msnpureport -g error -d 3
${install_path}/driver/tools/msnpureport -g error -d 4
${install_path}/driver/tools/msnpureport -g error -d 5
${install_path}/driver/tools/msnpureport -g error -d 6
${install_path}/driver/tools/msnpureport -g error -d 7
#Disable the event log on the device side.
${install_path}/driver/tools/msnpureport -e disable
path_lib=$(python3.7 -c """
import sys
import re
result=''
for index in range(len(sys.path)):
match_sit = re.search('-packages', sys.path[index])
if match_sit is not None:
match_lib = re.search('lib', sys.path[index])
if match_lib is not None:
end=match_lib.span()[1]
result += sys.path[index][0:end] + ':'
result+=sys.path[index] + '/torch/lib:'
print(result)"""
)
echo ${path_lib}
export LD_LIBRARY_PATH=/usr/local/python3.7.5/lib/:${path_lib}:$LD_LIBRARY_PATH
```
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,486 @@
# PyTorch Installation Guide
- [Overview](#overview)
- [System Dependencies](#system-dependencies)
- [Ascend Auxiliary Software](#ascend-auxiliary-software)
- [Installation Methods](#installation-methods)
- [Running] (#running)
- [(Optional) Installing the Mixed Precision Module](#optional-installing-the-mixed-precision-module)
- [FAQ](#faq)
- [Release Notes](#release-notes)
# Overview<a name="Overview"></a>
This project develops the PyTorch Adapter plugin to adapt Ascend to the PyTorch framework so that developers who use the PyTorch framework can obtain powerful compute capabilities of Ascend AI Processors. When setting up the environment for model development and running under PyTorch, you can manually build and install modules adapted to the PyTorch framework on a server.
## Prerequisites
- The development or operating environment of CANN has been installed. For details, see the *CANN Software Installation Guide*.
- Python version: 3.7.5 or 3.8
# System Dependencies<a name="System Dependencies"></a>
## CentOS & EulerOS
yum install -y patch zlib-devel libffi-devel openssl-devel libjpeg-turbo-devel gcc-c++ sqlite-devel dos2unix openblas git dos2unix
yum install -y gcc==7.3.0 cmake==3.12.0
## Ubuntu
apt-get install -y patch g++ make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev m4 dos2unix libopenblas-dev git dos2unix
apt-get install -y gcc==7.3.0 cmake==3.12.0
>![](public_sys-resources/icon-note.gif) **NOTE:**
>If an error occurs during the installation of the GCC and CMake dependency commands, use the source code for installation. For details, see the FAQ.
# Ascend Auxiliary Software<a name="Ascend Auxiliary Software"></a>
| AscendPyTorch Version| CANN Version| Supported PyTorch Version| Gitee Branch|
| :------------ | :----------- | :----------- | ------------ |
| 2.0.2 | CANN 5.0.2 | 1.5.0.post2 | 2.0.2.tr5 |
| 2.0.3 | CANN 5.0.3 | 1.5.0.post3 | 2.0.3.tr5 |
| 2.0.4 | CANN 5.0.4 | 1.5.0.post4 | 2.0.4.tr5 |
| 3.0.rc1 | CANN 5.1.RC1 | 1.5.0.post5 | v1.5.0-3.0.rc1 |
| 3.0.rc1 | CANN 5.1.RC1 | 1.8.1.rc1 | v1.8.1-3.0.rc1 |
| 3.0.rc2 | CANN 5.1.RC2 | 1.5.0.post6 | v1.5.0-3.0.rc2 |
| 3.0.rc2 | CANN 5.1.RC2 | 1.8.1.rc2 | v1.8.1-3.0.rc2 |
# Installation Methods<a name="Installation Methods"></a>
## Installing the PyTorch Environment Dependencies
Obtain the PyTorch source code (from the current repository) that adapts to Ascend AI Processors.
```
git clone -b v1.5.0-3.0.rc2 https://gitee.com/ascend/pytorch.git
```
## Obtaining the Native PyTorch Source Code and Third-Party Code
Obtain the native PyTorch 1.5.0 source code from the root directory **/pytorch** of the current repository. Check whether there are fixed security-related issues in the Security and Issues categories in the PyTorch native repository. Update the native PyTorch code if there are any fixes.
```sh
cd pytorch
git clone -b v1.5.0 --depth=1 https://github.com/pytorch/pytorch.git
```
Go to the **pytorch/pytorch/** directory and obtain the passive dependency code of PyTorch. It takes a long time to obtain the code.
```sh
cd pytorch
git submodule sync
git submodule update --init --recursive
```
If no error is reported, the PyTorch and third-party code on which PyTorch depends is generated.
## Generating Full PyTorch Code That Adapts to Ascend AI Processors
Go to the **pytorch/scripts** directory and run the script of the selected version. (Note: The downloaded native PyTorch source code must match the following version. Otherwise, an error may occur.)
```sh
cd ../scripts/
bash gen.sh
```
The full code adapted to the NPU is generated in the **pytorch/pytorch/** directory.
## Installing the Python Dependency Library
Go to the **pytorch/pytorch/** directory and install the Python dependency library.
```python3
cd ../pytorch
pip3 install -r requirements.txt
```
## Compiling Torch Binary Package
In the **pytorch/pytorch/** directory, run the following command:
```sh
# Python 3.7
bash build.sh
or
bash build.sh --python=3.7 (recommended)
# Python 3.8
bash build.sh --python=3.8
```
The generated binary package is in the **pytorch/pytorch/dist/** directory.
## Installing PyTorch
**x86_64:**
**torch-1.5.0+ascend-cp37-cp37m-linux_x86_64.whl** (The actual name may contain the minor version number, for example, **torch-1.5.0.post2+ascend-cp37-cp37m-linux_x86_64.whl**.)
```shell
cd dist
pip3 uninstall torch
pip3 install --upgrade torch-1.5.0+ascend-cp37-cp37m-linux_x86_64.whl
```
**arm:**
**torch-1.5.0+ascend-cp37-cp37m-linux_aarch64.whl** (The actual name may contain the minor version number, for example, **torch-1.5.0.post2+ascend-cp37-cp37m-linux_aarch64.whl**.)
```shell
cd dist
pip3 uninstall torch
pip3 install --upgrade torch-1.5.0+ascend-cp37-cp37m-linux_aarch64.whl
```
# Running<a name="Running"></a>
## Executing Environment Variables
Run the script for setting environment variables in the **pytorch/pytorch/** directory.
```
cd ../
source env.sh
```
The following are optional environment variables that may affect running models:
```
export COMBINED_ENABLE=1 # (Optional) Discontinuous-to-continuous level-2 derivation optimization. To enable this function, set the value to **1**. When a large number of time-consuming AsStrided operators are called in the model, you can enable this function to improve the device execution efficiency.
export ACL_DUMP_DATA=1 # (Optional) Operator data dump function, which is used for debugging. To enable this function, set the value to **1**.
export TASK_QUEUE_ENABLE=1 # Delivered by an asynchronous task to asynchronously call the ACL interface. You are advised to enable this environment variable and set its value to **1**.
```
If the system is openEuler or its inherited OS, such as UOS, run the following command to cancel CPU core binding.
```
# unset GOMP_CPU_AFFINITY
```
**Table 1** Description of environment variables
<a name="zh-cn_topic_0000001152616261_table42017516135"></a>
<table><thead align="left"><tr id="zh-cn_topic_0000001152616261_row16198951191317"><th class="cellrowborder" valign="top" width="55.48%" id="mcps1.2.3.1.1"><p id="zh-cn_topic_0000001152616261_p51981251161315"><a name="zh-cn_topic_0000001152616261_p51981251161315"></a><a name="zh-cn_topic_0000001152616261_p51981251161315"></a>Environment Variable</p>
</th>
<th class="cellrowborder" valign="top" width="44.519999999999996%" id="mcps1.2.3.1.2"><p id="zh-cn_topic_0000001152616261_p9198135114133"><a name="zh-cn_topic_0000001152616261_p9198135114133"></a><a name="zh-cn_topic_0000001152616261_p9198135114133"></a>Description</p>
</td>
</tr>
<tr id="row78312162301"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="p1832171673019"><a name="p1832171673019"></a><a name="p1832171673019"></a>COMBINED_ENABLE</p>
</td>
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="p583261643014"><a name="p583261643014"></a><a name="p583261643014"></a>(Optional) Discontinuous-to-continuous level-2 derivation optimization. To enable this function, set the value to **1**. When a large number of time-consuming AsStrided operators are called in the model, you can enable this function to improve the device execution efficiency.</p>
</td>
</tr>
<tr id="row183041355123411"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="p730435533415"><a name="p730435533415"></a><a name="p730435533415"></a>ACL_DUMP_DATA</p>
</td>
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="p16304105533412"><a name="p16304105533412"></a><a name="p16304105533412"></a>(Optional) Operator data dump function, which is used for debugging. To enable this function, set the value to **1**.</p>
</td>
</tr>
<tr id="row19173161510309"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001152616261_p16711563237"><a name="zh-cn_topic_0000001152616261_p16711563237"></a><a name="zh-cn_topic_0000001152616261_p16711563237"></a>TASK_QUEUE_ENABLE</p>
</td>
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001152616261_p0711356152317"><a name="zh-cn_topic_0000001152616261_p0711356152317"></a><a name="zh-cn_topic_0000001152616261_p0711356152317"></a>(Optional) Use asynchronous task delivery to asynchronously invoke the ACL interface. To enable this function, set it to **1** (recommended default setting). </p>
</td>
</tbody>
</table>
## Running the Unit Test Script
Verify the running. The output is **OK**.
```shell
// Select a test script that matches the preceding version. The following uses the 1.5.0 version as an example.
cd ../
python3 pytorch1.5.0/test/test_npu/test_network_ops/test_div.py
```
# (Optional) Installing the Mixed Precision Module<a name="(Optional) Installing the Mixed Precision Module"></a>
Select the APEX module based on the following functions. For details about how to build and install the APEX module, see the [README.en](https://gitee.com/ascend/apex/tree/v1.5.0-3.0.rc2/).
- APEX
- O1 configuration mode: Conv and Matmul use the float16 precision for computing, and Softmax and BN use float32.
- O2 configuration mode: BN uses the float32 precision for computing, and others use float16.
- Static loss scale: Parameters are statically set to ensure the convergence of training with mixed precision.
- Dynamic loss scale: The loss scale value is dynamically calculated to determine whether overflow occurs.
# FAQ
## When PIP is set to the Huawei source, a Python environment error occurs after the typing dependency in the **requirements.txt** file is installed.
When PIP is set to the Huawei source, open the **requirements.txt** file, delete the typing dependency, and then run the following command:
```
pip3 install -r requirments.txt
```
## The **libhccl.so** cannot be found by **import torch**.
Environment variables are not configured. You need to configure them using the **env.sh** script.
```
source pytorch/pytorch1.5.0/src/env.sh
```
## The error message "no module named yaml/typing_extensions." is displayed when **bash build.sh** is run during compilation.
PyTorch compilation depends on the YAML and typing_extensions libraries, which need to be manually installed.
```
pip3 install pyyaml
pip3 install typing_extensions
```
After the installation is successful, run **make clean** and then **bash build.sh** to perform compilation. Otherwise, an unknown compilation error may occur due to the cache.
## TE cannot be found during running.
Development state:
```
cd /urs/local/Ascend/ascend-toolkit/latest/{arch}-linux/lib64 # {arch} is the architecture name.
pip3 install --upgrade topi-0.4.0-py3-none-any.whl
pip3 install --upgrade te-0.4.0-py3-none-any.whl
```
User state:
```
cd /urs/local/Ascend/nnae/latest/{arch}-linux/lib64 # {arch} is the architecture name.
pip3 install --upgrade topi-0.4.0-py3-none-any.whl
pip3 install --upgrade te-0.4.0-py3-none-any.whl
```
## During CMake installation through the CLI, an error is reported indicating that the package cannot be found. During CMake compilation, another error is reported indicating that the version is too early. In this cause, you can use the installation script or source code to compile and install CMake.
Method 1: Download the installation script and install CMake. (For details, see the CMake official website.)
​ x86_64 environment: cmake-3.12.0-Linux-x86_64.sh
​ AArch64 environment: cmake-3.12.0-Linux-aarch64.sh
1. Run the following command:
```
./cmake-3.12.0-Linux-{arch}.sh #{arch} indicates the architecture name.
```
2. Set the soft link.
```
ln -s /usr/local/cmake/bin/cmake /usr/bin/cmake
```
3. Run the following command to check whether CMake has been installed:
```
cmake --version
```
If the message "cmake version 3.12.0" is displayed, the installation is successful.
Method 2: Use the source code to compile and install.
1. Obtain the CMake software package.
```
wget https://cmake.org/files/v3.12/cmake-3.12.0.tar.gz --no-check-certificate
```
2. Decompress the package and go to the software package directory.
```
tar -xf cmake-3.12.0.tar.gz
cd cmake-3.12.0/
```
3. Run the configuration, compilation, and installation commands.
```
./configure --prefix=/usr/local/cmake
make && make install
```
4. Set the soft link.
```
ln -s /usr/local/cmake/bin/cmake /usr/bin/cmake
```
5. Run the following command to check whether CMake has been installed:
```
cmake --version
```
If the message "cmake version 3.12.0" is displayed, the installation is successful.
## During GCC installation through the CLI, an error is reported indicating that the package cannot be found. During GCC compilation, another error is reported.
When downloading GCC from some sources, you may be prompted by an error message indicating that the package cannot be found. In this case, use the source code to compile and install GCC.
Perform the following steps as the **root** user.
1. Download **gcc-7.3.0.tar.gz** from [https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz](https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz).
2. GCC installation requires adequate temporary space. Run the following command to clear the **/tmp** directory in advance:
```
sudo rm -rf /tmp/*
```
3. Install the dependency package. (CentOS and Ubuntu are used as examples.)
- For CentOS, run the following command:
```
yum install bzip2
```
- For Ubuntu, run the following command:
```
apt-get install bzip2
```
4. Compile and install GCC.
1. Go to the directory where the source package **gcc-7.3.0.tar.gz** is located and run the following command to decompress it:
```
tar -zxvf gcc-7.3.0.tar.gz
```
2. Go to the extracted directory and download the GCC dependency packages:
```
cd gcc-7.3.0
./contrib/download_prerequisites
```
If an error is reported during the command execution, run the following commands in the **gcc-7.3.0/** directory to download the dependency packages:
```
wget http://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2
wget http://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2
wget http://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz
wget http://gcc.gnu.org/pub/gcc/infrastructure/isl-0.16.1.tar.bz2
```
After the preceding dependencies are downloaded, run the following command again:
```
./contrib/download_prerequisites
```
If the verification fails, check whether there are duplicate dependency packages in the folder. If yes, delete duplicate ones.
3. <a name="zh-cn_topic_0000001135347812_zh-cn_topic_0000001173199577_zh-cn_topic_0000001172534867_zh-cn_topic_0276688294_li1649343041310"></a>Run the configuration, compilation, and installation commands.
```
./configure --enable-languages=c,c++ --disable-multilib --with-system-zlib --prefix=/usr/local/linux_gcc7.3.0
make -j15 # Check the number of CPUs by running **grep -w processor /proc/cpuinfo|wc -l**. In this example, the number is 15. You can set the parameters as required.
make install
```
> ![img](public_sys-resources/icon-notice.gif) **NOTE: **
>The **--prefix** option is used to specify the **linux_gcc7.3.0** installation path, which is configurable. Do not set it to **/usr/local** or **/usr,** which is the default installation path for the GCC installed by using the software source. Otherwise, a conflict occurs and the original GCC compilation environment of the system is damaged. In this example, the installation path is set to **/usr/local/linux_gcc7.3.0**.
4. Change the soft links.
```
ln -s ${install_path}/bin/gcc /usr/bin/gcc
ln -s ${install_path}/bin/g++ /usr/bin/g++
ln -s ${install_path}/bin/c++ /usr/bin/c++
```
5. Configure environment variables.
Training must be performed in the compilation environment with GCC upgraded. If you want to run training, configure the following environment variable in your training script:
```
export LD_LIBRARY_PATH=${install_path}/lib64:${LD_LIBRARY_PATH}
```
**${install_path}** indicates the GCC 7.3.0 installation path configured in [3.](#zh-cn_topic_0000001135347812_zh-cn_topic_0000001173199577_zh-cn_topic_0000001172534867_zh-cn_topic_0276688294_li1649343041310). In this example, the GCC 7.3.0 installation path is **/usr/local/linux_gcc7.3.0/**.
>![](public_sys-resources/icon-note.gif) **NOTE:**
>Skip this step if you do not need to use the compilation environment with GCC upgraded.
If the PyTorch compilation fails, check whether the soft link library is correct.
libstdc++->libstdc++.so.6.0.24(7.3.0)
## libblas.so cannot be found.
The OpenBLAS library is missing in the environment. You need to install it.
CentOS and EulerOS
```sh
yum -y install openblas
```
Ubuntu
```sh
apt install libopenblas-dev
```
## torchvision fails to be installed using pip in the Arm environment.
The source code can be used for installation. (You need to install the AscendPyTorch first and configure environment variables using **env.sh**.)
```
git clone -b v0.6.0 https://github.com/pytorch/vision.git
cd vision
python setup.py install
```
Verify that the torchvision is successfully installed.
```
python -c "import torchvision"
```
If no error is reported, the installation is successful.
For details about releases, see [Release Notes](https://gitee.com/ascend/pytorch/blob/v1.5.0-3.0.rc2/docs/zh/RELEASENOTE/RELEASENOTE.md).
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Before

Width:  |  Height:  |  Size: 580 B

After

Width:  |  Height:  |  Size: 580 B

Before

Width:  |  Height:  |  Size: 580 B

After

Width:  |  Height:  |  Size: 580 B

Before

Width:  |  Height:  |  Size: 394 B

After

Width:  |  Height:  |  Size: 394 B

Before

Width:  |  Height:  |  Size: 406 B

After

Width:  |  Height:  |  Size: 406 B

Before

Width:  |  Height:  |  Size: 253 B

After

Width:  |  Height:  |  Size: 253 B

Before

Width:  |  Height:  |  Size: 580 B

After

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 946 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 946 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 607 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Some files were not shown because too many files have changed in this diff Show More