Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d73f7d15d1 | ||
|
|
64142762fb | ||
|
|
2671012415 | ||
|
|
9cb88c4ae8 | ||
|
|
3015977115 | ||
|
|
25e1415cb4 | ||
|
|
9276d4c441 | ||
|
|
3ab4642abd | ||
|
|
aa1466742a | ||
|
|
9bfd72d468 | ||
|
|
0fa13028d3 | ||
|
|
358cba8b6d | ||
|
|
c684b7c74a | ||
|
|
d836a9cb3c | ||
|
|
369ebefd2e | ||
|
|
e1b754a902 | ||
|
|
c6ad5c5cc5 | ||
|
|
54af470c20 | ||
|
|
c56e5299d5 | ||
|
|
edfe8b0306 | ||
|
|
0143c1c06e | ||
|
|
fe09035482 | ||
|
|
e8f0e0055c | ||
|
|
255e1b94f6 | ||
|
|
b184e1c1d3 | ||
|
|
a85cb62301 | ||
|
|
1500208c7f | ||
|
|
073ad70cc4 | ||
|
|
6741696481 | ||
|
|
48dd2489e0 | ||
|
|
7e0b4081ac | ||
|
|
88d5c2c545 | ||
|
|
c39847cbba | ||
|
|
8fa79690b2 | ||
|
|
b6464ff2b2 | ||
|
|
a12b0dd319 | ||
|
|
b9c513ed2d | ||
|
|
e7218aaf60 | ||
|
|
5de5ce6d04 | ||
|
|
62992d4000 | ||
|
|
34f84c6ca4 | ||
|
|
4ebeb1fd6a | ||
|
|
c4c5da1ed0 | ||
|
|
4ad96e17f4 | ||
|
|
f6bd4ea357 | ||
|
|
6c52cd2a5d | ||
|
|
11ee398a57 | ||
|
|
c4c9340104 | ||
|
|
931f3c3878 | ||
|
|
a48b4fd558 | ||
|
|
d44bc70aae | ||
|
|
021efdf1da | ||
|
|
1d607dcf4f | ||
|
|
b2afdd7871 | ||
|
|
37fc10168a | ||
|
|
6432bc6349 | ||
|
|
4160ab8ab6 | ||
|
|
afaa4d4e88 | ||
|
|
91014cd3b8 | ||
|
|
798f0c3b16 | ||
|
|
c28c47c9cd | ||
|
|
bda914c574 | ||
|
|
edb5c70443 | ||
|
|
4689a0514b | ||
|
|
63950d1412 | ||
|
|
16fb2692c6 | ||
|
|
193cd1f80d | ||
|
|
6b5302218a |
@@ -1,6 +1,7 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2021, 张昱杰
|
||||
Copyright (c) 2020, Huawei Technologies Co., Ltd
|
||||
Copyright (c) 2019, Facebook CORPORATION.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
@@ -13,4 +13,7 @@ reviewers:
|
||||
- wangyu0516
|
||||
- yskhhh
|
||||
- lvpeiyuan
|
||||
- xchu42
|
||||
- xchu42
|
||||
- weili10
|
||||
- goodjobwubai
|
||||
- fairwarning
|
||||
@@ -24,14 +24,11 @@ yum install -y cmake zlib-devel libffi-devel openssl-devel libjpeg-turbo-devel g
|
||||
apt-get install -y gcc 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 cmake dos2unix libopenblas-dev
|
||||
|
||||
|
||||
# python依赖库
|
||||
# Ascend配套软件
|
||||
|
||||
|
||||
依赖库安装:
|
||||
|
||||
```python3
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
| AscendPyTorch版本 | CANN版本 |
|
||||
| :------------ | :----------- |
|
||||
| 2.0.2 | CANN 5.0.2 |
|
||||
|
||||
|
||||
# 使用方式 --生成全量代码并编译
|
||||
@@ -63,6 +60,16 @@ bash gen.sh
|
||||
|
||||
会在pytorch/pytorch/目录中生成npu适配全量代码
|
||||
|
||||
|
||||
## python依赖库
|
||||
|
||||
进入到pytorch/pytorch/目录,依赖库安装:
|
||||
|
||||
```python3
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
|
||||
|
||||
## 编译torch的二进制包
|
||||
|
||||
进入到pytorch/pytorch/目录,执行
|
||||
|
||||
@@ -0,0 +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 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.
|
||||
@@ -1,3 +1,17 @@
|
||||
# Copyright (c) 2020 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.
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
import os
|
||||
|
||||
|
Before Width: | Height: | Size: 12 KiB |
@@ -173,21 +173,21 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p1391052114017"><a name="p1391052114017"></a><a name="p1391052114017"></a>torch.linspace</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p1491019204011"><a name="p1491019204011"></a><a name="p1491019204011"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p1491019204011"><a name="p1491019204011"></a><a name="p1491019204011"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row63881302531"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p24621823163717"><a name="p24621823163717"></a><a name="p24621823163717"></a>23</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p39104264014"><a name="p39104264014"></a><a name="p39104264014"></a>torch.logspace</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p29104214017"><a name="p29104214017"></a><a name="p29104214017"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p29104214017"><a name="p29104214017"></a><a name="p29104214017"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1038913095310"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p134621323173719"><a name="p134621323173719"></a><a name="p134621323173719"></a>24</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p17910162104012"><a name="p17910162104012"></a><a name="p17910162104012"></a>torch.eye</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p19108254016"><a name="p19108254016"></a><a name="p19108254016"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p19108254016"><a name="p19108254016"></a><a name="p19108254016"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1738918085317"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p54628235371"><a name="p54628235371"></a><a name="p54628235371"></a>25</p>
|
||||
@@ -229,7 +229,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p1091013217405"><a name="p1091013217405"></a><a name="p1091013217405"></a>torch.quantize_per_tensor</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p1891072184019"><a name="p1891072184019"></a><a name="p1891072184019"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p1891072184019"><a name="p1891072184019"></a><a name="p1891072184019"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row63901504535"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p154631423143719"><a name="p154631423143719"></a><a name="p154631423143719"></a>31</p>
|
||||
@@ -481,14 +481,14 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p127184309457"><a name="p127184309457"></a><a name="p127184309457"></a>torch.bernoulli</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p167181308456"><a name="p167181308456"></a><a name="p167181308456"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p167181308456"><a name="p167181308456"></a><a name="p167181308456"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row93863095319"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p16205517123920"><a name="p16205517123920"></a><a name="p16205517123920"></a>8</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p1371873074520"><a name="p1371873074520"></a><a name="p1371873074520"></a>torch.multinomial</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p7718103014515"><a name="p7718103014515"></a><a name="p7718103014515"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p7718103014515"><a name="p7718103014515"></a><a name="p7718103014515"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row53861002533"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p020512176391"><a name="p020512176391"></a><a name="p020512176391"></a>9</p>
|
||||
@@ -915,7 +915,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p3871632907"><a name="p3871632907"></a><a name="p3871632907"></a>torch.log10</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p14871143219012"><a name="p14871143219012"></a><a name="p14871143219012"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p14871143219012"><a name="p14871143219012"></a><a name="p14871143219012"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row339017014538"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p10621242164017"><a name="p10621242164017"></a><a name="p10621242164017"></a>35</p>
|
||||
@@ -1216,7 +1216,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p78741932907"><a name="p78741932907"></a><a name="p78741932907"></a>torch.allclose</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p208746327017"><a name="p208746327017"></a><a name="p208746327017"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p208746327017"><a name="p208746327017"></a><a name="p208746327017"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row153957075319"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p26237429405"><a name="p26237429405"></a><a name="p26237429405"></a>78</p>
|
||||
@@ -1279,7 +1279,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p128757327017"><a name="p128757327017"></a><a name="p128757327017"></a>torch.kthvalue</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p1487593212011"><a name="p1487593212011"></a><a name="p1487593212011"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p1487593212011"><a name="p1487593212011"></a><a name="p1487593212011"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row103961903533"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p5624124224011"><a name="p5624124224011"></a><a name="p5624124224011"></a>87</p>
|
||||
@@ -1433,7 +1433,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p1487819321201"><a name="p1487819321201"></a><a name="p1487819321201"></a>torch.cross</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p78783323016"><a name="p78783323016"></a><a name="p78783323016"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p78783323016"><a name="p78783323016"></a><a name="p78783323016"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row17399307538"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p1462594284015"><a name="p1462594284015"></a><a name="p1462594284015"></a>109</p>
|
||||
@@ -1447,7 +1447,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p78781832607"><a name="p78781832607"></a><a name="p78781832607"></a>torch.cummin</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p19878183219019"><a name="p19878183219019"></a><a name="p19878183219019"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p19878183219019"><a name="p19878183219019"></a><a name="p19878183219019"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row13996015537"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p14625144214010"><a name="p14625144214010"></a><a name="p14625144214010"></a>111</p>
|
||||
@@ -1461,7 +1461,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p138781032100"><a name="p138781032100"></a><a name="p138781032100"></a>torch.cumsum</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p198788321707"><a name="p198788321707"></a><a name="p198788321707"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p198788321707"><a name="p198788321707"></a><a name="p198788321707"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row103996085310"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p762534234011"><a name="p762534234011"></a><a name="p762534234011"></a>113</p>
|
||||
@@ -1482,7 +1482,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p178788321201"><a name="p178788321201"></a><a name="p178788321201"></a>torch.diagflat</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p5879183213013"><a name="p5879183213013"></a><a name="p5879183213013"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p5879183213013"><a name="p5879183213013"></a><a name="p5879183213013"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row204001504538"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p16625104224013"><a name="p16625104224013"></a><a name="p16625104224013"></a>116</p>
|
||||
@@ -1538,7 +1538,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p7879123213016"><a name="p7879123213016"></a><a name="p7879123213016"></a>torch.renorm</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p287919321105"><a name="p287919321105"></a><a name="p287919321105"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p287919321105"><a name="p287919321105"></a><a name="p287919321105"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row18400009533"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p1962654254018"><a name="p1962654254018"></a><a name="p1962654254018"></a>124</p>
|
||||
@@ -1720,7 +1720,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p16881632902"><a name="p16881632902"></a><a name="p16881632902"></a>torch.slogdet</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p9881133215014"><a name="p9881133215014"></a><a name="p9881133215014"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p9881133215014"><a name="p9881133215014"></a><a name="p9881133215014"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row24061102533"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p13627164217405"><a name="p13627164217405"></a><a name="p13627164217405"></a>150</p>
|
||||
@@ -1783,7 +1783,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p188219321603"><a name="p188219321603"></a><a name="p188219321603"></a>torch.mv</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p208821432407"><a name="p208821432407"></a><a name="p208821432407"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p126884235428"><a name="p126884235428"></a><a name="p126884235428"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row34071203537"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p5628342184015"><a name="p5628342184015"></a><a name="p5628342184015"></a>159</p>
|
||||
@@ -1811,7 +1811,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p1488253220014"><a name="p1488253220014"></a><a name="p1488253220014"></a>torch.qr</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p20882432402"><a name="p20882432402"></a><a name="p20882432402"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p20882432402"><a name="p20882432402"></a><a name="p20882432402"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row64071004534"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p3628042144017"><a name="p3628042144017"></a><a name="p3628042144017"></a>163</p>
|
||||
@@ -1860,7 +1860,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p2088319328011"><a name="p2088319328011"></a><a name="p2088319328011"></a>torch.trapz</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p168837321706"><a name="p168837321706"></a><a name="p168837321706"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p168837321706"><a name="p168837321706"></a><a name="p168837321706"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row11408180115316"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p7628164214408"><a name="p7628164214408"></a><a name="p7628164214408"></a>170</p>
|
||||
@@ -2147,7 +2147,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p85239393819"><a name="p85239393819"></a><a name="p85239393819"></a>torch.Tensor.addcmul_</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p165231398810"><a name="p165231398810"></a><a name="p165231398810"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p165231398810"><a name="p165231398810"></a><a name="p165231398810"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1495382217720"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p1773140104313"><a name="p1773140104313"></a><a name="p1773140104313"></a>24</p>
|
||||
@@ -2196,7 +2196,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p1252313917816"><a name="p1252313917816"></a><a name="p1252313917816"></a>torch.Tensor.allclose</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p752416391887"><a name="p752416391887"></a><a name="p752416391887"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p752416391887"><a name="p752416391887"></a><a name="p752416391887"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1195411220715"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p17470194316"><a name="p17470194316"></a><a name="p17470194316"></a>31</p>
|
||||
@@ -2539,7 +2539,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p25271539781"><a name="p25271539781"></a><a name="p25271539781"></a>torch.Tensor.cross</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p85272391881"><a name="p85272391881"></a><a name="p85272391881"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p85272391881"><a name="p85272391881"></a><a name="p85272391881"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row3957132217714"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p177190184318"><a name="p177190184318"></a><a name="p177190184318"></a>80</p>
|
||||
@@ -2560,7 +2560,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p65281639289"><a name="p65281639289"></a><a name="p65281639289"></a>torch.Tensor.cummin</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p12528139088"><a name="p12528139088"></a><a name="p12528139088"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p12528139088"><a name="p12528139088"></a><a name="p12528139088"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row16957522876"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p14770013438"><a name="p14770013438"></a><a name="p14770013438"></a>83</p>
|
||||
@@ -2574,7 +2574,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p1552811398810"><a name="p1552811398810"></a><a name="p1552811398810"></a>torch.Tensor.cumsum</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p17528133918810"><a name="p17528133918810"></a><a name="p17528133918810"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p17528133918810"><a name="p17528133918810"></a><a name="p17528133918810"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row119577224716"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p177714018434"><a name="p177714018434"></a><a name="p177714018434"></a>85</p>
|
||||
@@ -2623,7 +2623,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p952811392813"><a name="p952811392813"></a><a name="p952811392813"></a>torch.Tensor.diagflat</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p05281639389"><a name="p05281639389"></a><a name="p05281639389"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p05281639389"><a name="p05281639389"></a><a name="p05281639389"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row095772218711"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p87817014316"><a name="p87817014316"></a><a name="p87817014316"></a>92</p>
|
||||
@@ -2749,14 +2749,14 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p053011391483"><a name="p053011391483"></a><a name="p053011391483"></a>torch.Tensor.erfc</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p45301639887"><a name="p45301639887"></a><a name="p45301639887"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p45301639887"><a name="p45301639887"></a><a name="p45301639887"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row16959132214716"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p187918094316"><a name="p187918094316"></a><a name="p187918094316"></a>110</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p1553013910815"><a name="p1553013910815"></a><a name="p1553013910815"></a>torch.Tensor.erfc_</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p853033913811"><a name="p853033913811"></a><a name="p853033913811"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p853033913811"><a name="p853033913811"></a><a name="p853033913811"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row5959922375"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p1679403434"><a name="p1679403434"></a><a name="p1679403434"></a>111</p>
|
||||
@@ -3022,14 +3022,14 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p75331639881"><a name="p75331639881"></a><a name="p75331639881"></a>torch.Tensor.index_copy_</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p553383914815"><a name="p553383914815"></a><a name="p553383914815"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p553383914815"><a name="p553383914815"></a><a name="p553383914815"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row5961172211719"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p128340114315"><a name="p128340114315"></a><a name="p128340114315"></a>149</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p13533143911819"><a name="p13533143911819"></a><a name="p13533143911819"></a>torch.Tensor.index_copy</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p185334391187"><a name="p185334391187"></a><a name="p185334391187"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p185334391187"><a name="p185334391187"></a><a name="p185334391187"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row179613221674"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p383604430"><a name="p383604430"></a><a name="p383604430"></a>150</p>
|
||||
@@ -3169,7 +3169,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p10534539788"><a name="p10534539788"></a><a name="p10534539788"></a>torch.Tensor.kthvalue</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p1453417394816"><a name="p1453417394816"></a><a name="p1453417394816"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p1453417394816"><a name="p1453417394816"></a><a name="p1453417394816"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row189621022177"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p1085130154314"><a name="p1085130154314"></a><a name="p1085130154314"></a>170</p>
|
||||
@@ -3239,14 +3239,14 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p12535113920816"><a name="p12535113920816"></a><a name="p12535113920816"></a>torch.Tensor.log10</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p753519392080"><a name="p753519392080"></a><a name="p753519392080"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p753519392080"><a name="p753519392080"></a><a name="p753519392080"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row109631622570"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p186160154311"><a name="p186160154311"></a><a name="p186160154311"></a>180</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p17535183910816"><a name="p17535183910816"></a><a name="p17535183910816"></a>torch.Tensor.log10_</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p19535103911815"><a name="p19535103911815"></a><a name="p19535103911815"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p19535103911815"><a name="p19535103911815"></a><a name="p19535103911815"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1296322217716"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p11864044318"><a name="p11864044318"></a><a name="p11864044318"></a>181</p>
|
||||
@@ -3512,7 +3512,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p553817391788"><a name="p553817391788"></a><a name="p553817391788"></a>torch.Tensor.mv</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p95380391882"><a name="p95380391882"></a><a name="p95380391882"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p95380391882"><a name="p95380391882"></a><a name="p95380391882"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row149660221070"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p11908011433"><a name="p11908011433"></a><a name="p11908011433"></a>219</p>
|
||||
@@ -3701,7 +3701,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p1654283915817"><a name="p1654283915817"></a><a name="p1654283915817"></a>torch.Tensor.qr</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p254220391781"><a name="p254220391781"></a><a name="p254220391781"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p254220391781"><a name="p254220391781"></a><a name="p254220391781"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row149681222179"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p4948014317"><a name="p4948014317"></a><a name="p4948014317"></a>246</p>
|
||||
@@ -4905,7 +4905,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.50000000000001%" headers="mcps1.1.4.1.2 "><p id="p959911141519"><a name="p959911141519"></a><a name="p959911141519"></a>torch.nn.Conv3d</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p759912115154"><a name="p759912115154"></a><a name="p759912115154"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p759912115154"><a name="p759912115154"></a><a name="p759912115154"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row470965801214"><td class="cellrowborder" valign="top" width="8.000000000000002%" headers="mcps1.1.4.1.1 "><p id="p91281653134312"><a name="p91281653134312"></a><a name="p91281653134312"></a>60</p>
|
||||
@@ -4940,14 +4940,14 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.50000000000001%" headers="mcps1.1.4.1.2 "><p id="p1559911114150"><a name="p1559911114150"></a><a name="p1559911114150"></a>torch.nn.Fold</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p1459915117151"><a name="p1459915117151"></a><a name="p1459915117151"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p1459915117151"><a name="p1459915117151"></a><a name="p1459915117151"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row770925815121"><td class="cellrowborder" valign="top" width="8.000000000000002%" headers="mcps1.1.4.1.1 "><p id="p2128195324310"><a name="p2128195324310"></a><a name="p2128195324310"></a>65</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.50000000000001%" headers="mcps1.1.4.1.2 "><p id="p15599410156"><a name="p15599410156"></a><a name="p15599410156"></a>torch.nn.MaxPool1d</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p7599131181511"><a name="p7599131181511"></a><a name="p7599131181511"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p7599131181511"><a name="p7599131181511"></a><a name="p7599131181511"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row16709758121219"><td class="cellrowborder" valign="top" width="8.000000000000002%" headers="mcps1.1.4.1.1 "><p id="p15128453164319"><a name="p15128453164319"></a><a name="p15128453164319"></a>66</p>
|
||||
@@ -4961,7 +4961,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.50000000000001%" headers="mcps1.1.4.1.2 "><p id="p360015115159"><a name="p360015115159"></a><a name="p360015115159"></a>torch.nn.MaxPool3d</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p4600212159"><a name="p4600212159"></a><a name="p4600212159"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p4600212159"><a name="p4600212159"></a><a name="p4600212159"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row87091258121218"><td class="cellrowborder" valign="top" width="8.000000000000002%" headers="mcps1.1.4.1.1 "><p id="p1712855315438"><a name="p1712855315438"></a><a name="p1712855315438"></a>68</p>
|
||||
@@ -4975,7 +4975,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.50000000000001%" headers="mcps1.1.4.1.2 "><p id="p17600191111510"><a name="p17600191111510"></a><a name="p17600191111510"></a>torch.nn.MaxUnpool2d</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p46001814159"><a name="p46001814159"></a><a name="p46001814159"></a>是</p>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p935153282615"><a name="p935153282615"></a><a name="p935153282615"></a>否</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1770915813123"><td class="cellrowborder" valign="top" width="8.000000000000002%" headers="mcps1.1.4.1.1 "><p id="p812835394314"><a name="p812835394314"></a><a name="p812835394314"></a>70</p>
|
||||
@@ -5003,7 +5003,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.50000000000001%" headers="mcps1.1.4.1.2 "><p id="p1760021201512"><a name="p1760021201512"></a><a name="p1760021201512"></a>torch.nn.AvgPool3d</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p860019181515"><a name="p860019181515"></a><a name="p860019181515"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p860019181515"><a name="p860019181515"></a><a name="p860019181515"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row187109589121"><td class="cellrowborder" valign="top" width="8.000000000000002%" headers="mcps1.1.4.1.1 "><p id="p19129195310433"><a name="p19129195310433"></a><a name="p19129195310433"></a>74</p>
|
||||
@@ -5381,7 +5381,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.50000000000001%" headers="mcps1.1.4.1.2 "><p id="p96047151511"><a name="p96047151511"></a><a name="p96047151511"></a>torch.nn.InstanceNorm3d</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p186041113155"><a name="p186041113155"></a><a name="p186041113155"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p186041113155"><a name="p186041113155"></a><a name="p186041113155"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row371325810126"><td class="cellrowborder" valign="top" width="8.000000000000002%" headers="mcps1.1.4.1.1 "><p id="p813645384319"><a name="p813645384319"></a><a name="p813645384319"></a>128</p>
|
||||
@@ -5395,7 +5395,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.50000000000001%" headers="mcps1.1.4.1.2 "><p id="p3604915151"><a name="p3604915151"></a><a name="p3604915151"></a>torch.nn.LocalResponseNorm</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p4604513155"><a name="p4604513155"></a><a name="p4604513155"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p4604513155"><a name="p4604513155"></a><a name="p4604513155"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row371315881214"><td class="cellrowborder" valign="top" width="8.000000000000002%" headers="mcps1.1.4.1.1 "><p id="p51361953194313"><a name="p51361953194313"></a><a name="p51361953194313"></a>130</p>
|
||||
@@ -5563,21 +5563,21 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.50000000000001%" headers="mcps1.1.4.1.2 "><p id="p13606161151517"><a name="p13606161151517"></a><a name="p13606161151517"></a>torch.nn.Dropout2d</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p196066118158"><a name="p196066118158"></a><a name="p196066118158"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p196066118158"><a name="p196066118158"></a><a name="p196066118158"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row19714195881218"><td class="cellrowborder" valign="top" width="8.000000000000002%" headers="mcps1.1.4.1.1 "><p id="p14137195315432"><a name="p14137195315432"></a><a name="p14137195315432"></a>154</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.50000000000001%" headers="mcps1.1.4.1.2 "><p id="p1606171201516"><a name="p1606171201516"></a><a name="p1606171201516"></a>torch.nn.Dropout3d</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p17606713159"><a name="p17606713159"></a><a name="p17606713159"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p17606713159"><a name="p17606713159"></a><a name="p17606713159"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row187146583127"><td class="cellrowborder" valign="top" width="8.000000000000002%" headers="mcps1.1.4.1.1 "><p id="p1113715538433"><a name="p1113715538433"></a><a name="p1113715538433"></a>155</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.50000000000001%" headers="mcps1.1.4.1.2 "><p id="p560611110151"><a name="p560611110151"></a><a name="p560611110151"></a>torch.nn.AlphaDropout</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p176066113156"><a name="p176066113156"></a><a name="p176066113156"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p176066113156"><a name="p176066113156"></a><a name="p176066113156"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1071495811212"><td class="cellrowborder" valign="top" width="8.000000000000002%" headers="mcps1.1.4.1.1 "><p id="p191374537437"><a name="p191374537437"></a><a name="p191374537437"></a>156</p>
|
||||
@@ -5612,7 +5612,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.50000000000001%" headers="mcps1.1.4.1.2 "><p id="p56071215156"><a name="p56071215156"></a><a name="p56071215156"></a>torch.nn.CosineSimilarity</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p06074111515"><a name="p06074111515"></a><a name="p06074111515"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p06074111515"><a name="p06074111515"></a><a name="p06074111515"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row187151589123"><td class="cellrowborder" valign="top" width="8.000000000000002%" headers="mcps1.1.4.1.1 "><p id="p713775364320"><a name="p713775364320"></a><a name="p713775364320"></a>161</p>
|
||||
@@ -5647,7 +5647,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.50000000000001%" headers="mcps1.1.4.1.2 "><p id="p2607151161510"><a name="p2607151161510"></a><a name="p2607151161510"></a>torch.nn.CTCLoss</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p260721121515"><a name="p260721121515"></a><a name="p260721121515"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p260721121515"><a name="p260721121515"></a><a name="p260721121515"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row19715358171219"><td class="cellrowborder" valign="top" width="8.000000000000002%" headers="mcps1.1.4.1.1 "><p id="p1713865317437"><a name="p1713865317437"></a><a name="p1713865317437"></a>166</p>
|
||||
@@ -5661,7 +5661,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="71.50000000000001%" headers="mcps1.1.4.1.2 "><p id="p26071410155"><a name="p26071410155"></a><a name="p26071410155"></a>torch.nn.PoissonNLLLoss</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p12607111181517"><a name="p12607111181517"></a><a name="p12607111181517"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20.5%" headers="mcps1.1.4.1.3 "><p id="p12607111181517"><a name="p12607111181517"></a><a name="p12607111181517"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row107158582124"><td class="cellrowborder" valign="top" width="8.000000000000002%" headers="mcps1.1.4.1.1 "><p id="p18138105314315"><a name="p18138105314315"></a><a name="p18138105314315"></a>168</p>
|
||||
@@ -6739,7 +6739,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p182921654151714"><a name="p182921654151714"></a><a name="p182921654151714"></a>torch.nn.functional.conv3d</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p142921854111710"><a name="p142921854111710"></a><a name="p142921854111710"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p142921854111710"><a name="p142921854111710"></a><a name="p142921854111710"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row149120516169"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p2025115375442"><a name="p2025115375442"></a><a name="p2025115375442"></a>4</p>
|
||||
@@ -6774,7 +6774,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p1929214548179"><a name="p1929214548179"></a><a name="p1929214548179"></a>torch.nn.functional.fold</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p629265415170"><a name="p629265415170"></a><a name="p629265415170"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p629265415170"><a name="p629265415170"></a><a name="p629265415170"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1591213519165"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p152521637174419"><a name="p152521637174419"></a><a name="p152521637174419"></a>9</p>
|
||||
@@ -6795,14 +6795,14 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p329225481715"><a name="p329225481715"></a><a name="p329225481715"></a>torch.nn.functional.avg_pool3d</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p7292165420176"><a name="p7292165420176"></a><a name="p7292165420176"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p7292165420176"><a name="p7292165420176"></a><a name="p7292165420176"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row29128516164"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p825283716449"><a name="p825283716449"></a><a name="p825283716449"></a>12</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p429220540178"><a name="p429220540178"></a><a name="p429220540178"></a>torch.nn.functional.max_pool1d</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p829210544176"><a name="p829210544176"></a><a name="p829210544176"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p829210544176"><a name="p829210544176"></a><a name="p829210544176"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row10912051121618"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p7252133794418"><a name="p7252133794418"></a><a name="p7252133794418"></a>13</p>
|
||||
@@ -6816,7 +6816,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p1229385410170"><a name="p1229385410170"></a><a name="p1229385410170"></a>torch.nn.functional.max_pool3d</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p3293554181716"><a name="p3293554181716"></a><a name="p3293554181716"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p3293554181716"><a name="p3293554181716"></a><a name="p3293554181716"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row2912195191612"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p42521237134411"><a name="p42521237134411"></a><a name="p42521237134411"></a>15</p>
|
||||
@@ -6865,7 +6865,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p429318545177"><a name="p429318545177"></a><a name="p429318545177"></a>torch.nn.functional.adaptive_max_pool2d</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p152931454201719"><a name="p152931454201719"></a><a name="p152931454201719"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p152931454201719"><a name="p152931454201719"></a><a name="p152931454201719"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1991316512169"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p162521378441"><a name="p162521378441"></a><a name="p162521378441"></a>22</p>
|
||||
@@ -6893,7 +6893,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p1629395461716"><a name="p1629395461716"></a><a name="p1629395461716"></a>torch.nn.functional.adaptive_avg_pool3d</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p8294125417172"><a name="p8294125417172"></a><a name="p8294125417172"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p8294125417172"><a name="p8294125417172"></a><a name="p8294125417172"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1591365115165"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p425233734418"><a name="p425233734418"></a><a name="p425233734418"></a>26</p>
|
||||
@@ -6991,7 +6991,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p1029525413170"><a name="p1029525413170"></a><a name="p1029525413170"></a>torch.nn.functional.prelu</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p18295105416171"><a name="p18295105416171"></a><a name="p18295105416171"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p18295105416171"><a name="p18295105416171"></a><a name="p18295105416171"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row19914155119169"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p4256143764412"><a name="p4256143764412"></a><a name="p4256143764412"></a>40</p>
|
||||
@@ -7012,7 +7012,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p7295155413171"><a name="p7295155413171"></a><a name="p7295155413171"></a>torch.nn.functional.glu</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p182951654191715"><a name="p182951654191715"></a><a name="p182951654191715"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p182951654191715"><a name="p182951654191715"></a><a name="p182951654191715"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row19149515164"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p1625610377441"><a name="p1625610377441"></a><a name="p1625610377441"></a>43</p>
|
||||
@@ -7033,7 +7033,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p11295254111710"><a name="p11295254111710"></a><a name="p11295254111710"></a>torch.nn.functional.hardshrink</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p0295554111710"><a name="p0295554111710"></a><a name="p0295554111710"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p0295554111710"><a name="p0295554111710"></a><a name="p0295554111710"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row169141951171620"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p1425619370443"><a name="p1425619370443"></a><a name="p1425619370443"></a>46</p>
|
||||
@@ -7054,7 +7054,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p5295125416173"><a name="p5295125416173"></a><a name="p5295125416173"></a>torch.nn.functional.softplus</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p0295125412171"><a name="p0295125412171"></a><a name="p0295125412171"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p0295125412171"><a name="p0295125412171"></a><a name="p0295125412171"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row291425113164"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p52571037184414"><a name="p52571037184414"></a><a name="p52571037184414"></a>49</p>
|
||||
@@ -7124,14 +7124,14 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p13297115417174"><a name="p13297115417174"></a><a name="p13297115417174"></a>torch.nn.functional.layer_norm</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p1029735415179"><a name="p1029735415179"></a><a name="p1029735415179"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p1029735415179"><a name="p1029735415179"></a><a name="p1029735415179"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row11915151151610"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p19257173774419"><a name="p19257173774419"></a><a name="p19257173774419"></a>59</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p829718543174"><a name="p829718543174"></a><a name="p829718543174"></a>torch.nn.functional.local_response_norm</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p82971454151710"><a name="p82971454151710"></a><a name="p82971454151710"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p82971454151710"><a name="p82971454151710"></a><a name="p82971454151710"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row17915155118164"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p8257437194418"><a name="p8257437194418"></a><a name="p8257437194418"></a>60</p>
|
||||
@@ -7201,7 +7201,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p15297454131710"><a name="p15297454131710"></a><a name="p15297454131710"></a>torch.nn.functional.one_hot</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p192981054161719"><a name="p192981054161719"></a><a name="p192981054161719"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p192981054161719"><a name="p192981054161719"></a><a name="p192981054161719"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row09161651151613"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p1925843713448"><a name="p1925843713448"></a><a name="p1925843713448"></a>70</p>
|
||||
@@ -7215,14 +7215,14 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p162985549179"><a name="p162985549179"></a><a name="p162985549179"></a>torch.nn.functional.cosine_similarity</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p1429835471711"><a name="p1429835471711"></a><a name="p1429835471711"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p1429835471711"><a name="p1429835471711"></a><a name="p1429835471711"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row139161251191612"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p82581376444"><a name="p82581376444"></a><a name="p82581376444"></a>72</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p122981154181713"><a name="p122981154181713"></a><a name="p122981154181713"></a>torch.nn.functional.pdist</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p3298105415175"><a name="p3298105415175"></a><a name="p3298105415175"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p3298105415175"><a name="p3298105415175"></a><a name="p3298105415175"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row16916151171616"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p192582371445"><a name="p192582371445"></a><a name="p192582371445"></a>73</p>
|
||||
@@ -7257,7 +7257,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p14298185416176"><a name="p14298185416176"></a><a name="p14298185416176"></a>torch.nn.functional.cross_entropy</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p172981454151714"><a name="p172981454151714"></a><a name="p172981454151714"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p172981454151714"><a name="p172981454151714"></a><a name="p172981454151714"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row991635120169"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p20258237134414"><a name="p20258237134414"></a><a name="p20258237134414"></a>78</p>
|
||||
@@ -7306,7 +7306,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p8299175491720"><a name="p8299175491720"></a><a name="p8299175491720"></a>torch.nn.functional.multilabel_margin_loss</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p7299175421711"><a name="p7299175421711"></a><a name="p7299175421711"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p7299175421711"><a name="p7299175421711"></a><a name="p7299175421711"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row179161751131619"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p1725917372441"><a name="p1725917372441"></a><a name="p1725917372441"></a>85</p>
|
||||
@@ -7341,7 +7341,7 @@
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="70%" headers="mcps1.1.4.1.2 "><p id="p1629955416178"><a name="p1629955416178"></a><a name="p1629955416178"></a>torch.nn.functional.soft_margin_loss</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p42991454101717"><a name="p42991454101717"></a><a name="p42991454101717"></a>否</p>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.1.4.1.3 "><p id="p42991454101717"><a name="p42991454101717"></a><a name="p42991454101717"></a>是</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row691785121618"><td class="cellrowborder" valign="top" width="10%" headers="mcps1.1.4.1.1 "><p id="p72591937164412"><a name="p72591937164412"></a><a name="p72591937164412"></a>90</p>
|
||||
|
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 |
@@ -7,14 +7,10 @@
|
||||
- [样例参考](#样例参考.md)
|
||||
- [专题](#专题.md)
|
||||
- [混合精度](#混合精度.md)
|
||||
- [权重更新](#权重更新.md)
|
||||
- [FAQ](#FAQ.md)
|
||||
- [pip3.7 install Pillow==5.3.0安装失败](#pip3-7-install-Pillow-5-3-0安装失败.md)
|
||||
- [安装“torch-\*.whl ”提示“torch 1.5.0xxxx”与“torchvision”所依赖的版本不匹配](#安装-torch--whl-提示-torch-1-5-0xxxx-与-torchvision-所依赖的版本不匹配.md)
|
||||
- [安装7.3.0版本gcc](#安装7-3-0版本gcc.md)
|
||||
<h2 id="使用场景.md">使用场景</h2>
|
||||
|
||||
在线推理是在AI框架内执行推理的场景,例如在PyTorch框架上,加载模型后,通过model.eval\(\)执行推理。
|
||||
在线推理是在AI框架内执行推理的场景,例如在PyTorch框架上,加载模型后,通过“model.eval\(\)“将模型切换为推理模式。
|
||||
|
||||
相比于离线推理场景,使用在线推理可以方便将原来基于PyTorch框架做推理的应用快速迁移到昇腾AI处理器,适用于数据中心推理场景。
|
||||
|
||||
@@ -37,38 +33,27 @@
|
||||
|
||||
<h2 id="前提条件.md">前提条件</h2>
|
||||
|
||||
已完成PyTorch框架及混合精度模块的安装,详情请参考《PyTorch网络模型移植&训练指南》的"环境准备"章节。
|
||||
已完成PyTorch框架及混合精度模块的安装,详情请参见《PyTorch安装指南》进行PyTorch相关运行环境搭建。
|
||||
|
||||
<h2 id="在线推理流程.md">在线推理流程</h2>
|
||||
|
||||
在线推理流程如[图1](#fig13802941161818)所示:
|
||||
在线推理流程如[图1](#fig13802941161818)所示。
|
||||
|
||||
**图 1** 在线推理流程图<a name="fig13802941161818"></a>
|
||||

|
||||
|
||||
<h2 id="环境变量配置.md">环境变量配置</h2>
|
||||
|
||||
Pytorch在线推理进程启动所依赖的环境变量:
|
||||
|
||||
根据环境实际安装的软件包(toolkit或nnae),在下列场景中选择一个并运行对应的环境变量配置脚本。
|
||||
PyTorch在线推理进程启动所依赖的环境变量:
|
||||
|
||||
```
|
||||
# 场景一:昇腾设备安装部署开发套件包Ascend-cann-toolkit(此时开发环境可进行推理任务),可根据不同安装用户执行相应脚本。
|
||||
# 以root用户安装toolkit包
|
||||
. /usr/local/Ascend/ascend-toolkit/set_env.sh
|
||||
# 以非root用户安装toolkit包
|
||||
. ${HOME}/Ascend/ascend-toolkit/set_env.sh
|
||||
# 场景二:昇腾设备安装部署软件包Ascend-cann-nnae,可根据不同安装用户执行相应脚本。
|
||||
# 以root用户安装nnae包
|
||||
. /usr/local/Ascend/nnae/set_env.sh
|
||||
# 以非root用户安装nnae包
|
||||
. ${HOME}/Ascend/nnae/set_env.sh
|
||||
```
|
||||
# 请依据实际在下列场景中选择其一,进行在线推理依赖包安装路径的环境变量设置。具体如下(以HwHiAiUser用户安装,安装路径为默认路径为例):
|
||||
# 场景一:昇腾设备安装部署开发套件包Ascend-cann-toolkit(此时开发环境可进行推理任务)。
|
||||
. /home/HwHiAiUser/Ascend/ascend-toolkit/set_env.sh
|
||||
# 场景二:昇腾设备安装部署软件包Ascend-cann-nnae。
|
||||
. /home/HwHiAiUser/Ascend/nnae/set_env.sh
|
||||
|
||||
其他环境变量配置。
|
||||
|
||||
```
|
||||
# 若参见《PyTorch网络模型移植&训练指南》的"环境准备"章节进行环境搭建时安装python3.7.5,或存在多个python3版本时,需要在环境变量中配置python3.7.5的安装路径。
|
||||
# 若运行环境中存在多个python3版本时,需要在环境变量中配置python3.7.5的安装路径。
|
||||
export PATH=/usr/local/python3.7.5/bin:$PATH
|
||||
export LD_LIBRARY_PATH=/usr/local/python3.7.5/lib:$LD_LIBRARY_PATH
|
||||
|
||||
@@ -78,63 +63,65 @@ export ASCEND_DEVICE_ID=0
|
||||
# 输出日志信息,可根据实际修改
|
||||
export ASCEND_SLOG_PRINT_TO_STDOUT=1
|
||||
export ASCEND_GLOBAL_LOG_LEVEL=0
|
||||
|
||||
# TASK多线程下发
|
||||
export TASK_QUEUE_ENABLE=0
|
||||
```
|
||||
|
||||
**表 1**
|
||||
**表 1** 环境变量说明
|
||||
|
||||
<a name="table2072027194819"></a>
|
||||
<table><thead align="left"><tr id="row1173527114812"><th class="cellrowborder" valign="top" width="46.75467546754676%" id="mcps1.2.4.1.1"><p id="p073027114816"><a name="p073027114816"></a><a name="p073027114816"></a>配置项</p>
|
||||
<table><thead align="left"><tr id="row1173527114812"><th class="cellrowborder" valign="top" width="35.51355135513551%" id="mcps1.2.4.1.1"><p id="p073027114816"><a name="p073027114816"></a><a name="p073027114816"></a>配置项</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="43.18431843184319%" id="mcps1.2.4.1.2"><p id="p157362712480"><a name="p157362712480"></a><a name="p157362712480"></a>说明</p>
|
||||
<th class="cellrowborder" valign="top" width="54.42544254425443%" id="mcps1.2.4.1.2"><p id="p157362712480"><a name="p157362712480"></a><a name="p157362712480"></a>说明</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="10.061006100610062%" id="mcps1.2.4.1.3"><p id="p187392714485"><a name="p187392714485"></a><a name="p187392714485"></a>必选/可选</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="row2732273481"><td class="cellrowborder" valign="top" width="46.75467546754676%" headers="mcps1.2.4.1.1 "><p id="p57382719481"><a name="p57382719481"></a><a name="p57382719481"></a>LD_LIBRARY_PATH</p>
|
||||
<tbody><tr id="row2732273481"><td class="cellrowborder" valign="top" width="35.51355135513551%" headers="mcps1.2.4.1.1 "><p id="p57382719481"><a name="p57382719481"></a><a name="p57382719481"></a>LD_LIBRARY_PATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="43.18431843184319%" headers="mcps1.2.4.1.2 "><p id="p07319271480"><a name="p07319271480"></a><a name="p07319271480"></a>动态库的查找路径,参考上述举例配置。</p>
|
||||
<div class="note" id="note119943144912"><a name="note119943144912"></a><a name="note119943144912"></a><span class="notetitle"> 说明: </span><div class="notebody"><p id="p49933104915"><a name="p49933104915"></a><a name="p49933104915"></a>若系统环境升级了gcc版本(例如Centos、Debian和BClinux系统),需要配置gcc相关环境变量,详情请参见<a href="#安装7-3-0版本gcc.md#zh-cn_topic_0000001146754749_zh-cn_topic_0000001072593337_l5e5c9395407d46439788b12f0e6342bc">5</a>。</p>
|
||||
<td class="cellrowborder" valign="top" width="54.42544254425443%" headers="mcps1.2.4.1.2 "><p id="p07319271480"><a name="p07319271480"></a><a name="p07319271480"></a>动态库的查找路径,参考上述举例配置。</p>
|
||||
<div class="note" id="note119943144912"><a name="note119943144912"></a><a name="note119943144912"></a><span class="notetitle"> 说明: </span><div class="notebody"><p id="p49933104915"><a name="p49933104915"></a><a name="p49933104915"></a>若系统环境安装了gcc7.3.0(例如CentOS7.6、Debian和BClinux系统),需要配置gcc相关环境变量,详情请参见<a href="#安装7-3-0版本gcc.md#zh-cn_topic_0000001146754749_zh-cn_topic_0000001072593337_l5e5c9395407d46439788b12f0e6342bc">5</a>。</p>
|
||||
</div></div>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="10.061006100610062%" headers="mcps1.2.4.1.3 "><p id="p187352744817"><a name="p187352744817"></a><a name="p187352744817"></a>必选</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row17342744812"><td class="cellrowborder" valign="top" width="46.75467546754676%" headers="mcps1.2.4.1.1 "><p id="p4731227184818"><a name="p4731227184818"></a><a name="p4731227184818"></a>PATH</p>
|
||||
<tr id="row17342744812"><td class="cellrowborder" valign="top" width="35.51355135513551%" headers="mcps1.2.4.1.1 "><p id="p4731227184818"><a name="p4731227184818"></a><a name="p4731227184818"></a>PATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="43.18431843184319%" headers="mcps1.2.4.1.2 "><p id="p97310276484"><a name="p97310276484"></a><a name="p97310276484"></a>可执行程序的查找路径,参考上述举例配置。</p>
|
||||
<td class="cellrowborder" valign="top" width="54.42544254425443%" headers="mcps1.2.4.1.2 "><p id="p97310276484"><a name="p97310276484"></a><a name="p97310276484"></a>可执行程序的查找路径,参考上述举例配置。</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="10.061006100610062%" headers="mcps1.2.4.1.3 "><p id="p1573142711483"><a name="p1573142711483"></a><a name="p1573142711483"></a>必选</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row95241840165613"><td class="cellrowborder" valign="top" width="46.75467546754676%" headers="mcps1.2.4.1.1 "><p id="p15242404566"><a name="p15242404566"></a><a name="p15242404566"></a>ASCEND_DEVICE_ID</p>
|
||||
<tr id="row95241840165613"><td class="cellrowborder" valign="top" width="35.51355135513551%" headers="mcps1.2.4.1.1 "><p id="p15242404566"><a name="p15242404566"></a><a name="p15242404566"></a>ASCEND_DEVICE_ID</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="43.18431843184319%" headers="mcps1.2.4.1.2 "><p id="p688447526"><a name="p688447526"></a><a name="p688447526"></a>指定芯片的逻辑ID。</p>
|
||||
<td class="cellrowborder" valign="top" width="54.42544254425443%" headers="mcps1.2.4.1.2 "><p id="p688447526"><a name="p688447526"></a><a name="p688447526"></a>指定芯片的逻辑ID。</p>
|
||||
<p id="p178824712212"><a name="p178824712212"></a><a name="p178824712212"></a>取值范围[0,N-1],默认为0。其中N为当前物理机/虚拟机/容器内的设备总数。</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="10.061006100610062%" headers="mcps1.2.4.1.3 "><p id="p105245400562"><a name="p105245400562"></a><a name="p105245400562"></a>可选</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row203705529819"><td class="cellrowborder" valign="top" width="46.75467546754676%" headers="mcps1.2.4.1.1 "><p id="p53705522810"><a name="p53705522810"></a><a name="p53705522810"></a>ASCEND_SLOG_PRINT_TO_STDOUT</p>
|
||||
<tr id="row203705529819"><td class="cellrowborder" valign="top" width="35.51355135513551%" headers="mcps1.2.4.1.1 "><p id="p53705522810"><a name="p53705522810"></a><a name="p53705522810"></a>ASCEND_SLOG_PRINT_TO_STDOUT</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="43.18431843184319%" headers="mcps1.2.4.1.2 "><p id="zh-cn_topic_0000001073203258_p763102116322"><a name="zh-cn_topic_0000001073203258_p763102116322"></a><a name="zh-cn_topic_0000001073203258_p763102116322"></a>是否开启日志打屏。取值:</p>
|
||||
<td class="cellrowborder" valign="top" width="54.42544254425443%" headers="mcps1.2.4.1.2 "><p id="zh-cn_topic_0000001073203258_p763102116322"><a name="zh-cn_topic_0000001073203258_p763102116322"></a><a name="zh-cn_topic_0000001073203258_p763102116322"></a>是否开启日志打屏。取值:</p>
|
||||
<a name="zh-cn_topic_0000001073203258_ul95291245104113"></a><a name="zh-cn_topic_0000001073203258_ul95291245104113"></a><ul id="zh-cn_topic_0000001073203258_ul95291245104113"><li>0或不配置:关闭日志打屏</li><li>1:开启日志打屏</li></ul>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="10.061006100610062%" headers="mcps1.2.4.1.3 "><p id="p6370125217818"><a name="p6370125217818"></a><a name="p6370125217818"></a>可选</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row188405280914"><td class="cellrowborder" valign="top" width="46.75467546754676%" headers="mcps1.2.4.1.1 "><p id="p5840928594"><a name="p5840928594"></a><a name="p5840928594"></a>ASCEND_GLOBAL_LOG_LEVEL</p>
|
||||
<tr id="row188405280914"><td class="cellrowborder" valign="top" width="35.51355135513551%" headers="mcps1.2.4.1.1 "><p id="p5840928594"><a name="p5840928594"></a><a name="p5840928594"></a>ASCEND_GLOBAL_LOG_LEVEL</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="43.18431843184319%" headers="mcps1.2.4.1.2 "><p id="zh-cn_topic_0000001073521184_p763102116322"><a name="zh-cn_topic_0000001073521184_p763102116322"></a><a name="zh-cn_topic_0000001073521184_p763102116322"></a>设置日志的全局日志级别。取值:</p>
|
||||
<td class="cellrowborder" valign="top" width="54.42544254425443%" headers="mcps1.2.4.1.2 "><p id="zh-cn_topic_0000001073521184_p763102116322"><a name="zh-cn_topic_0000001073521184_p763102116322"></a><a name="zh-cn_topic_0000001073521184_p763102116322"></a>设置日志的全局日志级别。取值:</p>
|
||||
<a name="zh-cn_topic_0000001073521184_u4d735da6e0494e55abbf5eb6aefe988d"></a><a name="zh-cn_topic_0000001073521184_u4d735da6e0494e55abbf5eb6aefe988d"></a><ul id="zh-cn_topic_0000001073521184_u4d735da6e0494e55abbf5eb6aefe988d"><li>0:对应DEBUG级别。</li><li>1:对应INFO级别。</li><li>2:对应WARNING级别。</li><li>3:对应ERROR级别。</li><li>4:对应NULL级别,不输出日志。</li><li>其他值为非法值。</li></ul>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="10.061006100610062%" headers="mcps1.2.4.1.3 "><p id="p6841928598"><a name="p6841928598"></a><a name="p6841928598"></a>可选</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row17638114219104"><td class="cellrowborder" valign="top" width="46.75467546754676%" headers="mcps1.2.4.1.1 "><p id="p20638342191018"><a name="p20638342191018"></a><a name="p20638342191018"></a>TASK_QUEUE_ENABLE</p>
|
||||
<tr id="row17638114219104"><td class="cellrowborder" valign="top" width="35.51355135513551%" headers="mcps1.2.4.1.1 "><p id="p20638342191018"><a name="p20638342191018"></a><a name="p20638342191018"></a>TASK_QUEUE_ENABLE</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="43.18431843184319%" headers="mcps1.2.4.1.2 "><p id="p126381842151019"><a name="p126381842151019"></a><a name="p126381842151019"></a>s是否开启TASK多线程下发,绝大多数情况下,打开该功能会进一步提升整网训练性能。取值:</p>
|
||||
<td class="cellrowborder" valign="top" width="54.42544254425443%" headers="mcps1.2.4.1.2 "><p id="p126381842151019"><a name="p126381842151019"></a><a name="p126381842151019"></a>是否开启TASK多线程下发,绝大多数情况下,打开该功能会进一步提升整网训练性能。取值:</p>
|
||||
<a name="ul6194152711118"></a><a name="ul6194152711118"></a><ul id="ul6194152711118"><li>0或不配置:关闭TASK多线程下发。</li><li>1:开启TASK多线程下发。</li></ul>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="10.061006100610062%" headers="mcps1.2.4.1.3 "><p id="p86386423103"><a name="p86386423103"></a><a name="p86386423103"></a>可选</p>
|
||||
@@ -150,7 +137,9 @@ export TASK_QUEUE_ENABLE=0
|
||||
|
||||
## 样例代码<a name="section2017032418274"></a>
|
||||
|
||||
在进行推理应用时,应尽量保证应用在生命周期内不频繁初始化。推理模式通过模型model.eval\(\)进行设置,并且推理过程要在“with torch.no\_grad\(\):”代码分支下运行。本例中,我们将使用Resnet50网络的python代码进行说明。
|
||||
在进行推理应用时,应尽量保证应用在生命周期内不频繁初始化。推理模式通过模型model.eval\(\)进行设置,并且推理过程要在“with torch.no\_grad\(\):”代码分支下运行。
|
||||
|
||||
本例中,我们将使用Resnet50网络的python代码进行说明。
|
||||
|
||||
样例代码 resnet50\_infer\_for\_pytorch.py:
|
||||
|
||||
@@ -246,7 +235,7 @@ def main_worker(npu, args):
|
||||
print("=> creating model '{}'".format(args.arch))
|
||||
model = models.__dict__[args.arch](zero_init_residual=True)
|
||||
|
||||
# 将模型数据置于昇腾AI处理器中
|
||||
# 将模型数据复制到昇腾AI处理器中
|
||||
model = model.to(CALCULATE_DEVICE)
|
||||
|
||||
optimizer = torch.optim.SGD([
|
||||
@@ -256,12 +245,12 @@ def main_worker(npu, args):
|
||||
args.lr)
|
||||
|
||||
# =========================================================================
|
||||
# 初始化混合精度模型,使用后可加速运算,但推理结果的准确率可能会轻微降低。可根据实际场景选择使用
|
||||
# 初始化混合精度模型,使用后可加速运算,但结果的准确率可能会轻微降低。可根据实际场景选择使用
|
||||
# =========================================================================
|
||||
model, optimizer = amp.initialize(model, optimizer, opt_level="O2", loss_scale=1024, verbosity=1)
|
||||
|
||||
# =========================================================================
|
||||
# 加载训练好的模型参数:通过命令行参数“--resume checkpoint文件”
|
||||
# 加载训练好的模型参数
|
||||
# =========================================================================
|
||||
# 从模型文件中恢复模型参数
|
||||
if os.path.isfile(args.resume):
|
||||
@@ -278,7 +267,7 @@ def main_worker(npu, args):
|
||||
print("=> no checkpoint found at '{}'".format(args.resume))
|
||||
|
||||
# =========================================================================
|
||||
# 初始化推理数据集
|
||||
# 初始化数据集
|
||||
# =========================================================================
|
||||
# 图像数据加载与预处理
|
||||
valdir = os.path.join(args.data, 'val')
|
||||
@@ -296,7 +285,7 @@ def main_worker(npu, args):
|
||||
num_workers=args.workers, pin_memory=True)
|
||||
|
||||
# =========================================================================
|
||||
# 进入在线推理模式
|
||||
# 运行validate
|
||||
# =========================================================================
|
||||
validate(val_loader, model, args)
|
||||
|
||||
@@ -332,7 +321,7 @@ def validate(val_loader, model, args):
|
||||
# 计算输出
|
||||
output = model(images)
|
||||
|
||||
# 测量结果精度
|
||||
# 统计结果精度
|
||||
acc1, acc5 = accuracy(output, target, topk=(1, 5))
|
||||
top1.update(acc1[0], images.size(0))
|
||||
top5.update(acc5[0], images.size(0))
|
||||
@@ -344,7 +333,6 @@ def validate(val_loader, model, args):
|
||||
# 打印推理运算过程日志
|
||||
progress.display(i)
|
||||
|
||||
# TODO: this should also be done with the ProgressMeter
|
||||
print(' * Acc@1 {top1.avg:.3f} Acc@5 {top5.avg:.3f}'.format(top1=top1, top5=top5))
|
||||
|
||||
return top1.avg
|
||||
@@ -380,7 +368,7 @@ class AverageMeter(object):
|
||||
|
||||
|
||||
class ProgressMeter(object):
|
||||
"""记录模型运算过程"""
|
||||
"""记录模型运算过程信息"""
|
||||
def __init__(self, num_batches, meters, prefix=""):
|
||||
self.batch_fmtstr = self._get_batch_fmtstr(num_batches)
|
||||
self.meters = meters
|
||||
@@ -424,7 +412,7 @@ if __name__ == '__main__':
|
||||
|
||||
1. 下载预训练模型。
|
||||
|
||||
打开ModelZoo中[ResNet50详情页](https://ascend.huawei.com/zh/#/software/modelzoo/detail/C/cf20ab8b8bea4032a6b056ab503112e4),点击该页面的“下载模型“下载已训练好的模型文件。
|
||||
打开ModelZoo中[ResNet50详情页](https://ascend.huawei.com/zh/#/software/modelzoo/detail/C/cf20ab8b8bea4032a6b056ab503112e4),单击该页面的“下载模型“下载已训练好的模型文件。
|
||||
|
||||
2. 编辑推理脚本。
|
||||
|
||||
@@ -435,8 +423,10 @@ if __name__ == '__main__':
|
||||
参考[环境变量配置](#环境变量配置.md)设置环境变量,并执行命令:
|
||||
|
||||
```
|
||||
python3.7 pytorch-resnet50-apex.py --data /data/imagenet --npu 7 --epochs 90 --resume checkpoint_npu7_epoch53.pth.tar
|
||||
# 参数'--resume'加载训练好的权重参数文件,用户可根据实际模型名称修改
|
||||
python3 pytorch-resnet50-apex.py --data /data/imagenet \
|
||||
--npu 7 \
|
||||
--epochs 90 \
|
||||
--resume ./checkpoint.pth.tar # ./checkpoint.pth.tar为示例预训练模型文件路径
|
||||
```
|
||||
|
||||
> **说明:**
|
||||
@@ -447,8 +437,6 @@ if __name__ == '__main__':
|
||||
|
||||
- **[混合精度](#混合精度.md)**
|
||||
|
||||
- **[权重更新](#权重更新.md)**
|
||||
|
||||
|
||||
<h2 id="混合精度.md">混合精度</h2>
|
||||
|
||||
@@ -456,17 +444,15 @@ if __name__ == '__main__':
|
||||
|
||||
基于NPU芯片的架构特性,模型运算会涉及到混合精度,即混合使用float16和float32数据类型的应用场景。使用float16代替float32有如下好处:
|
||||
|
||||
●对于中间变量的内存占用更少,节省内存的使用。
|
||||
|
||||
●因内存使用会减少,所以数据传出的时间也会减半。
|
||||
|
||||
●float16的计算单元可以提供更快的计算性能。
|
||||
- 对于中间变量的内存占用更少,节省内存的使用。
|
||||
- 因内存使用会减少,所以数据传出的时间也会相应减少。
|
||||
- float16的计算单元可以提供更快的计算性能。
|
||||
|
||||
但是,混合精度训练受限于float16表达的精度范围,单纯将float32转换成float16会影响训练收敛情况,为了保证部分计算使用float16来进行加速的同时能保证训练收敛,这里采用混合精度模块Apex来达到以上效果。混合精度模块Apex是一个集优化性能、精度收敛于一身的综合优化库。
|
||||
|
||||
## 特性支持<a name="section175201458521"></a>
|
||||
|
||||
混合精度模块功能和优化描述如[表1](#zh-cn_topic_0278765773_table10717173813332)所示:
|
||||
混合精度模块功能和优化描述如[表1](#zh-cn_topic_0278765773_table10717173813332)所示。
|
||||
|
||||
**表 1** 混合精度模块功能
|
||||
|
||||
@@ -479,12 +465,12 @@ if __name__ == '__main__':
|
||||
</thead>
|
||||
<tbody><tr id="zh-cn_topic_0278765773_row1571763813334"><td class="cellrowborder" valign="top" width="32.269999999999996%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0278765773_p4502732153412"><a name="zh-cn_topic_0278765773_p4502732153412"></a><a name="zh-cn_topic_0278765773_p4502732153412"></a>O1配置模式</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="67.73%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0278765773_p640053920348"><a name="zh-cn_topic_0278765773_p640053920348"></a><a name="zh-cn_topic_0278765773_p640053920348"></a>Conv, Matmal等使用<span>float16</span>计算,其他如Softmax、BN使用<span>float32</span>。</p>
|
||||
<td class="cellrowborder" valign="top" width="67.73%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0278765773_p640053920348"><a name="zh-cn_topic_0278765773_p640053920348"></a><a name="zh-cn_topic_0278765773_p640053920348"></a>Conv, Matmul等使用float16计算,其他如Softmax、BN使用float32。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0278765773_row3717173817336"><td class="cellrowborder" valign="top" width="32.269999999999996%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0278765773_p11503103210344"><a name="zh-cn_topic_0278765773_p11503103210344"></a><a name="zh-cn_topic_0278765773_p11503103210344"></a>O2配置</p>
|
||||
<tr id="zh-cn_topic_0278765773_row3717173817336"><td class="cellrowborder" valign="top" width="32.269999999999996%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0278765773_p11503103210344"><a name="zh-cn_topic_0278765773_p11503103210344"></a><a name="zh-cn_topic_0278765773_p11503103210344"></a>O2配置模式</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="67.73%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0278765773_p164001639143419"><a name="zh-cn_topic_0278765773_p164001639143419"></a><a name="zh-cn_topic_0278765773_p164001639143419"></a>除了BN使用<span>float32</span>外,其他绝大部分使用<span>float16</span>。</p>
|
||||
<td class="cellrowborder" valign="top" width="67.73%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0278765773_p164001639143419"><a name="zh-cn_topic_0278765773_p164001639143419"></a><a name="zh-cn_topic_0278765773_p164001639143419"></a>BN使用float32,其他绝大部分使用float16。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0278765773_row14717193815334"><td class="cellrowborder" valign="top" width="32.269999999999996%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0278765773_p1950318328349"><a name="zh-cn_topic_0278765773_p1950318328349"></a><a name="zh-cn_topic_0278765773_p1950318328349"></a>静态Loss Scale功能</p>
|
||||
@@ -517,12 +503,11 @@ if __name__ == '__main__':
|
||||
model, optimizer = amp.initialize(model, optimizer)
|
||||
```
|
||||
|
||||
- 可参考[样例代码](#样例参考.md)中的“初始化混合精度模型”:
|
||||
|
||||
```
|
||||
model, optimizer = amp.initialize(model, optimizer, opt_level="O2", loss_scale=1024, verbosity=1)
|
||||
```
|
||||
也可参考[样例代码](#样例参考.md)中的“初始化混合精度模型”:
|
||||
|
||||
```
|
||||
model, optimizer = amp.initialize(model, optimizer, opt_level="O2", loss_scale=1024, verbosity=1)
|
||||
```
|
||||
|
||||
|
||||
## 混合精度推理<a name="section818071513288"></a>
|
||||
@@ -531,100 +516,29 @@ if __name__ == '__main__':
|
||||
|
||||
参考代码:可参考[样例代码](#样例参考.md)实现。
|
||||
|
||||
<h2 id="权重更新.md">权重更新</h2>
|
||||
|
||||
## 背景<a name="section67167596290"></a>
|
||||
|
||||
推理进行的同时,训练服务器不断训练得到新的权重。
|
||||
|
||||
如果希望使用最新的权重进行推理,可以采用在线推理方式,直接更新权重。
|
||||
|
||||
## 整体流程<a name="section83461954103018"></a>
|
||||
|
||||
**图 1** 权重更新流程示意图<a name="fig6243201383"></a>
|
||||

|
||||
|
||||
如[图1](#fig6243201383)所示,支持循环地更新权重与执行推理。主要流程:
|
||||
|
||||
1. 模型初始化;
|
||||
2. 权重加载/更新:获取在线推理模型和权重信息,例如从ckpt文件中加载,实际更新用的权重则来自于外部的key-value;
|
||||
3. 加载数据;
|
||||
4. 执行推理图模型。
|
||||
|
||||
## 样例参考<a name="section95391544013"></a>
|
||||
|
||||
请参考[样例参考](#样例参考.md)。
|
||||
|
||||
<h2 id="FAQ.md">FAQ</h2>
|
||||
|
||||
- **[pip3.7 install Pillow==5.3.0安装失败](#pip3-7-install-Pillow-5-3-0安装失败.md)**
|
||||
|
||||
- **[安装“torch-\*.whl ”提示“torch 1.5.0xxxx”与“torchvision”所依赖的版本不匹配](#安装-torch--whl-提示-torch-1-5-0xxxx-与-torchvision-所依赖的版本不匹配.md)**
|
||||
|
||||
|
||||
<h2 id="pip3-7-install-Pillow-5-3-0安装失败.md">pip3.7 install Pillow==5.3.0安装失败</h2>
|
||||
|
||||
## 现象描述<a name="zh-cn_topic_0277124533_zh-cn_topic_0175549220_section197270431505"></a>
|
||||
|
||||
pip3.7 install pillow==5.3.0安装失败。
|
||||
|
||||
## 可能原因<a name="zh-cn_topic_0277124533_zh-cn_topic_0175549220_section169499490501"></a>
|
||||
|
||||
缺少必要的依赖,如:libjpeg、python-devel、 zlib-devel 、libjpeg-turbo-devel等等。
|
||||
|
||||
## 处理方法<a name="zh-cn_topic_0277124533_section108142031907"></a>
|
||||
|
||||
安装相关依赖,通过如下命令安装:
|
||||
|
||||
- CentOS/EulerOS/Tlinux/BClinux/Suse
|
||||
|
||||
**yum install libjpeg python-devel zlib-devel libjpeg-turbo-devel**
|
||||
|
||||
- Ubuntu/Debian/UOS
|
||||
|
||||
**apt-get install libjpeg python-devel zlib-devel libjpeg-turbo-devel**
|
||||
|
||||
|
||||
<h2 id="安装-torch--whl-提示-torch-1-5-0xxxx-与-torchvision-所依赖的版本不匹配.md">安装“torch-\*.whl ”提示“torch 1.5.0xxxx”与“torchvision”所依赖的版本不匹配</h2>
|
||||
|
||||
## 现象描述<a name="zh-cn_topic_0277124535_zh-cn_topic_0175549220_section197270431505"></a>
|
||||
|
||||
安装“torch-\*.whl”时,提示"ERROR:torchvision 0.6.0 has requirement torch==1.5.0, but you'll have torch 1.5.0a0+1977093 which is incompatible"。
|
||||
|
||||

|
||||
|
||||
## 可能原因<a name="zh-cn_topic_0277124535_zh-cn_topic_0175549220_section169499490501"></a>
|
||||
|
||||
安装torch时,会自动触发torchvision进行依赖版本检查,环境中安装的torchvision版本为0.6.0,检查时发现我们安装的torch-\*.whl的版本号与要求的1.5.0不一致,所以提示报错,但实际安装成功。
|
||||
|
||||
## 处理方法<a name="zh-cn_topic_0277124535_section108142031907"></a>
|
||||
|
||||
对实际结果无影响,无需处理。
|
||||
|
||||
<h2 id="安装7-3-0版本gcc.md">安装7.3.0版本gcc</h2>
|
||||
|
||||
以下步骤请在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目录:
|
||||
2. 安装gcc时候会占用大量临时空间,请先执行下面的命令清空/tmp目录:
|
||||
|
||||
```
|
||||
sudo rm -rf /tmp/*
|
||||
```
|
||||
|
||||
3. 安装依赖。
|
||||
3. 安装依赖(以CentOS和Ubuntu系统为例)。
|
||||
- CentOS执行如下命令安装。
|
||||
|
||||
centos/bclinux执行如下命令安装。
|
||||
```
|
||||
yum install bzip2
|
||||
```
|
||||
|
||||
```
|
||||
yum install bzip2
|
||||
```
|
||||
- Ubuntu执行如下命令安装。
|
||||
|
||||
ubuntu/debian执行如下命令安装。
|
||||
|
||||
```
|
||||
apt-get install bzip2
|
||||
```
|
||||
```
|
||||
apt-get install bzip2
|
||||
```
|
||||
|
||||
4. 编译安装gcc。
|
||||
1. 进入gcc-7.3.0.tar.gz源码包所在目录,解压源码包,命令为:
|
||||
@@ -665,7 +579,7 @@ pip3.7 install pillow==5.3.0安装失败。
|
||||
make install
|
||||
```
|
||||
|
||||
> **注意:**
|
||||
> **须知:**
|
||||
>其中“--prefix“参数用于指定linux\_gcc7.3.0安装路径,用户可自行配置,但注意不要配置为“/usr/local“及“/usr“,因为会与系统使用软件源默认安装的gcc相冲突,导致系统原始gcc编译环境被破坏。示例指定为“/usr/local/linux\_gcc7.3.0“。
|
||||
|
||||
|
||||
@@ -677,7 +591,7 @@ pip3.7 install pillow==5.3.0安装失败。
|
||||
export LD_LIBRARY_PATH=${install_path}/lib64:${LD_LIBRARY_PATH}
|
||||
```
|
||||
|
||||
其中$\{install\_path\}为[3.](#zh-cn_topic_0000001146754749_zh-cn_topic_0000001072593337_l75d31a2874534a2092e80a5f865b46f0)中配置的gcc7.3.0安装路径,本示例为“/usr/local/gcc7.3.0/“。
|
||||
其中$\{install\_path\}为[3.](#zh-cn_topic_0000001146754749_zh-cn_topic_0000001072593337_l75d31a2874534a2092e80a5f865b46f0)中配置的gcc7.3.0安装路径,本示例为“/usr/local/linux\_gcc7.3.0/“。
|
||||
|
||||
> **说明:**
|
||||
>本步骤为用户在需要用到gcc升级后的编译环境时才配置环境变量。
|
||||
|
After Width: | Height: | Size: 17 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 |
@@ -0,0 +1,568 @@
|
||||
# PyTorch安装指南
|
||||
- [简介](#简介.md)
|
||||
- [手动编译安装](#手动编译安装.md)
|
||||
- [前提条件](#前提条件.md)
|
||||
- [安装PyTorch框架](#安装PyTorch框架.md)
|
||||
- [配置环境变量](#配置环境变量.md)
|
||||
- [安装混合精度模块](#安装混合精度模块.md)
|
||||
- [使用Ascend Hub镜像](#使用Ascend-Hub镜像.md)
|
||||
- [Ascend Hub获取PyTorch镜像](#Ascend-Hub获取PyTorch镜像.md)
|
||||
- [配置环境变量](#配置环境变量-0.md)
|
||||
- [参考信息](#参考信息.md)
|
||||
- [CMake安装方法](#CMake安装方法.md)
|
||||
- [安装7.3.0版本gcc](#安装7-3-0版本gcc.md)
|
||||
- [安装“torch-\*.whl ”提示“torch 1.5.0xxxx”与“torchvision”所依赖的版本不匹配](#安装-torch--whl-提示-torch-1-5-0xxxx-与-torchvision-所依赖的版本不匹配.md)
|
||||
<h2 id="简介.md">简介</h2>
|
||||
|
||||
用户在准备相关环境进行基于PyTorch框架模型的开发、运行时,可以选择在服务器中手动编译安装PyTorch框架相关模块,或直接获取Ascend Hub镜像中心提供的基础镜像(镜像中已安装PyTorch模块和混合精度模块),进行模型的开发、运行。
|
||||
|
||||
**图 1** 环境准备流程图<a name="zh-cn_topic_0000001119176876_fig1938918396117"></a>
|
||||

|
||||
|
||||
<h2 id="手动编译安装.md">手动编译安装</h2>
|
||||
|
||||
- **[前提条件](#前提条件.md)**
|
||||
|
||||
- **[安装PyTorch框架](#安装PyTorch框架.md)**
|
||||
|
||||
- **[配置环境变量](#配置环境变量.md)**
|
||||
|
||||
- **[安装混合精度模块](#安装混合精度模块.md)**
|
||||
|
||||
|
||||
<h2 id="前提条件.md">前提条件</h2>
|
||||
|
||||
## 前提条件<a name="zh-cn_topic_0000001105856382_zh-cn_topic_0275872734_section108914373254"></a>
|
||||
|
||||
- 需完成CANN开发或运行环境的安装,具体操作请参考《CANN 软件安装指南》。
|
||||
- 需安装3.12.0以上版本的CMake,安装方法请参考[CMake安装方法](#CMake安装方法.md)。
|
||||
- 需确保已安装7.3.0以上版本的gcc,7.3.0版本gcc具体安装及使用方式请参考[安装7.3.0版本gcc](#安装7-3-0版本gcc.md)。
|
||||
- 需确保环境中已安装patch、git工具,以Ubuntu和CentOS系统为例,命令如下:
|
||||
- Ubuntu系统
|
||||
|
||||
```
|
||||
apt-get install patch
|
||||
apt-get install git
|
||||
```
|
||||
|
||||
- CentOS系统
|
||||
|
||||
```
|
||||
yum install patch
|
||||
yum install git
|
||||
```
|
||||
|
||||
|
||||
|
||||
<h2 id="安装PyTorch框架.md">安装PyTorch框架</h2>
|
||||
|
||||
## 安装流程<a name="zh-cn_topic_0000001152776301_section1611810384557"></a>
|
||||
|
||||
1. 以root或非root用户登录服务器。
|
||||
2. 依次执行如下命令安装PyTorch依赖环境。
|
||||
|
||||
如果使用非root用户安装Python及其依赖,用户需要在本步骤中的每句命令结尾加上**--user**,命令示例为:**pip3.7 install pyyaml --user**
|
||||
|
||||
```
|
||||
pip3 install pyyaml
|
||||
pip3 install wheel
|
||||
```
|
||||
|
||||
3. 获取PyTorch源代码。
|
||||
|
||||
1. 运行如下命令,获取适配昇腾AI处理器的PyTorch源代码。
|
||||
|
||||
```
|
||||
git clone https://gitee.com/ascend/pytorch.git
|
||||
```
|
||||
|
||||
下载的源码主要目录结构如下所示:
|
||||
|
||||
```
|
||||
pytorch
|
||||
│ ├─patch # 昇腾AI处理器适配补丁目录
|
||||
│ ├─npu.patch
|
||||
│ ├─scripts # 编译构建目录
|
||||
│ ├─gen.sh
|
||||
│ ├─src # 源码目录
|
||||
│ ├─test # 测试用例存放目录
|
||||
│ ├─README.md
|
||||
```
|
||||
|
||||
2. 运行如下命令,进入“pytorch“目录,并获取原生PyTorch源代码。
|
||||
|
||||
```
|
||||
cd pytorch
|
||||
git clone -b v1.5.0 --depth=1 https://github.com/pytorch/pytorch.git
|
||||
```
|
||||
|
||||
下载原生pytorch源码后,代码主要目录结构如下所示:
|
||||
|
||||
```
|
||||
pytorch
|
||||
│ ├─patch # 昇腾AI处理器适配补丁目录
|
||||
│ ├─npu.patch
|
||||
│ ├─pytorch # 原生pytorch代码目录
|
||||
│ ├─scripts # 编译构建目录
|
||||
│ ├─gen.sh
|
||||
│ ├─src # 源码目录
|
||||
│ ├─test # 测试用例存放目录
|
||||
│ ├─README.md
|
||||
```
|
||||
|
||||
3. 运行如下命令,进入原生pytorch代码目录“pytorch“,并获取PyTorch被动依赖代码。
|
||||
|
||||
```
|
||||
cd pytorch
|
||||
git submodule sync
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
> **说明:**
|
||||
>受网络波动影响,源码获取时间可能较长,下载过程中请耐心等待。 下载完成之后若没有报错,即生成了PyTorch及其依赖的第三方代码。
|
||||
|
||||
4. 编译生成适配昇腾AI处理器的PyTorch安装包。
|
||||
1. 进入“pytorch/scripts“文件夹,执行转换脚本,生成适配昇腾AI处理器的全量代码。
|
||||
|
||||
```
|
||||
cd ../scripts
|
||||
bash gen.sh
|
||||
```
|
||||
|
||||
将在"pytorch/pytorch"目录中生成适配昇腾AI处理器的全量代码。
|
||||
|
||||
2. 进入适配后的全量代码目录,即“pytorch/pytorch“目录,编译生成pytorch的二进制安装包。
|
||||
|
||||
```
|
||||
cd ../pytorch
|
||||
bash build.sh
|
||||
```
|
||||
|
||||
生成的二进制包在当前的dist目录下,即“pytorch/pytorch/dist”文件夹目录下。
|
||||
|
||||
5. <a name="zh-cn_topic_0000001152776301_li49671667141"></a>安装PyTorch。
|
||||
|
||||
进入“pytorch/pytorch/dist“文件夹目录,执行如下命令安装。
|
||||
|
||||
```
|
||||
pip3 install --upgrade torch-1.5.0+ascend-cp37-cp37m-linux_{arch}.whl
|
||||
```
|
||||
|
||||
**\{arch\}**表示架构信息,为aarch64或x86\_64。
|
||||
|
||||
> **说明:**
|
||||
>若对环境中的PyTorch进行升级时,需要先卸载环境中已安装的PyTorch软件包再执行[5. 安装PyTorch。](#zh-cn_topic_0000001152776301_li49671667141)可以通过执行如下命令查询环境上是否已安装PyTorch。
|
||||
>**pip3 list | grep torch**
|
||||
|
||||
|
||||
<h2 id="配置环境变量.md">配置环境变量</h2>
|
||||
|
||||
安装完软件包后,需要配置环境变量才能正常使用昇腾PyTorch。建议构建启动脚本,例如构建set\_env.sh脚本,使用source set\_env.sh配置当前窗口的环境变量。set\_env.sh脚本内容如下(以root用户安装,,安装路径为默认路径,python版本为3.7.5为例,用户可根据软件包实际安装路径修改配置项。)。
|
||||
|
||||
```
|
||||
cpu_type=$(echo $HOSTTYPE)
|
||||
|
||||
if [ x"${cpu_type}" == x"x86_64" ];then
|
||||
cpu_type=x86_64-linux
|
||||
else
|
||||
cpu_type=arm64-linux
|
||||
fi
|
||||
if [ -d /usr/local/Ascend/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/:/usr/local/Ascend/nnae/latest/fwkacllib/lib64/:/usr/local/Ascend/driver/lib64/common/:/usr/local/Ascend/driver/lib64/driver/:/usr/local/Ascend/add-ons/:/usr/lib/aarch64_64-linux-gnu:$LD_LIBRARY_PATH
|
||||
export PATH=$PATH:/usr/local/Ascend/nnae/latest/fwkacllib/ccec_compiler/bin/:/usr/local/Ascend/nnae/latest/toolkit/tools/ide_daemon/bin/
|
||||
export ASCEND_OPP_PATH=/usr/local/Ascend/nnae/latest/opp/
|
||||
export OPTION_EXEC_EXTERN_PLUGIN_PATH=/usr/local/Ascend/nnae/latest/fwkacllib/lib64/plugin/opskernel/libfe.so:/usr/local/Ascend/nnae/latest/fwkacllib/lib64/plugin/opskernel/libaicpu_engine.so:/usr/local/Ascend/nnae/latest/fwkacllib/lib64/plugin/opskernel/libge_local_engine.so
|
||||
export PYTHONPATH=/usr/local/Ascend/nnae/latest/fwkacllib/python/site-packages/:/usr/local/Ascend/nnae/latest/fwkacllib/python/site-packages/auto_tune.egg/auto_tune:/usr/local/Ascend/nnae/latest/fwkacllib/python/site-packages/schedule_search.egg:$PYTHONPATH
|
||||
export ASCEND_AICPU_PATH=/usr/local/Ascend/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:/usr/local/Ascend/ascend-toolkit/latest/fwkacllib/lib64/:/usr/local/Ascend/driver/lib64/common/:/usr/local/Ascend/driver/lib64/driver/:/usr/local/Ascend/add-ons/:/usr/lib/aarch64-linux-gnu:$LD_LIBRARY_PATH
|
||||
export PATH=$PATH:/usr/local/Ascend/ascend-toolkit/latest/fwkacllib/ccec_compiler/bin/:/usr/local/Ascend/ascend-toolkit/latest/toolkit/tools/ide_daemon/bin/
|
||||
export ASCEND_OPP_PATH=/usr/local/Ascend/ascend-toolkit/latest/opp/
|
||||
export OPTION_EXEC_EXTERN_PLUGIN_PATH=/usr/local/Ascend/ascend-toolkit/latest/fwkacllib/lib64/plugin/opskernel/libfe.so:/usr/local/Ascend/ascend-toolkit/latest/fwkacllib/lib64/plugin/opskernel/libaicpu_engine.so:/usr/local/Ascend/ascend-toolkit/latest/fwkacllib/lib64/plugin/opskernel/libge_local_engine.so
|
||||
export PYTHONPATH=/usr/local/Ascend/ascend-toolkit/latest/fwkacllib/python/site-packages/:/usr/local/Ascend/ascend-toolkit/latest/fwkacllib/python/site-packages/auto_tune.egg/auto_tune:/usr/local/Ascend/ascend-toolkit/latest/fwkacllib/python/site-packages/schedule_search.egg:$PYTHONPATH
|
||||
export ASCEND_AICPU_PATH=/usr/local/Ascend/ascend-toolkit/latest/${cpu_type}
|
||||
fi
|
||||
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)"""
|
||||
)
|
||||
export LD_LIBRARY_PATH=/usr/local/python3.7.5/lib/:${path_lib}:$LD_LIBRARY_PATH
|
||||
export TASK_QUEUE_ENABLE=1
|
||||
|
||||
# (可选)当系统为openeuler时,需设置此命令,取消CPU绑核。
|
||||
# unset GOMP_CPU_AFFINITY
|
||||
|
||||
# 请依据实际,在下列场景中选择合适的HCCL初始化方式,并配置相应环境变量。具体如下:
|
||||
# 场景一:单机场景
|
||||
export HCCL_WHITELIST_DISABLE=1 # 关闭HCCL通信白名单
|
||||
# 场景二:多机场景。
|
||||
export HCCL_WHITELIST_DISABLE=1 # 关闭HCCL通信白名单
|
||||
export HCCL_IF_IP="1.1.1.1" # “1.1.1.1”为示例使用的host网卡IP,请根据实际修改。需要保证使用的网卡IP在集群内是互通的。
|
||||
```
|
||||
|
||||
相关参数介绍参见[表1](#zh-cn_topic_0000001152616261_table42017516135)。
|
||||
|
||||
**表 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>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="zh-cn_topic_0000001152616261_row6882121917329"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001152616261_p688241953218"><a name="zh-cn_topic_0000001152616261_p688241953218"></a><a name="zh-cn_topic_0000001152616261_p688241953218"></a>LD_LIBRARY_PATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001152616261_p1888291915322"><a name="zh-cn_topic_0000001152616261_p1888291915322"></a><a name="zh-cn_topic_0000001152616261_p1888291915322"></a>动态库的查找路径,参考上述举例配置。</p>
|
||||
<p id="p1292181892120"><a name="p1292181892120"></a><a name="p1292181892120"></a>若训练所在系统环境需要升级gcc(例如CentOS、Debian和BClinux系统),则<span class="parmname" id="parmname795020446318"><a name="parmname795020446318"></a><a name="parmname795020446318"></a>“LD_LIBRARY_PATH”</span>配置项处动态库查找路径需要添加<span class="filepath" id="zh-cn_topic_0256062644_filepath115819811512"><a name="zh-cn_topic_0256062644_filepath115819811512"></a><a name="zh-cn_topic_0256062644_filepath115819811512"></a>“${install_path}/lib64”</span>,其中<span class="filepath" id="zh-cn_topic_0256062644_filepath195951574421"><a name="zh-cn_topic_0256062644_filepath195951574421"></a><a name="zh-cn_topic_0256062644_filepath195951574421"></a>“{install_path}”</span>为gcc升级安装路径。请参见<a href="#安装7-3-0版本gcc.md#zh-cn_topic_0000001135347812_zh-cn_topic_0000001173199577_zh-cn_topic_0000001172534867_zh-cn_topic_0276688294_li9745165315131">5</a>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001152616261_row16194175523010"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001152616261_p16195185523019"><a name="zh-cn_topic_0000001152616261_p16195185523019"></a><a name="zh-cn_topic_0000001152616261_p16195185523019"></a>PYTHONPATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001152616261_p19637083322"><a name="zh-cn_topic_0000001152616261_p19637083322"></a><a name="zh-cn_topic_0000001152616261_p19637083322"></a>Python搜索路径,参考上述举例配置。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001152616261_row2954102119329"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001152616261_p195452113218"><a name="zh-cn_topic_0000001152616261_p195452113218"></a><a name="zh-cn_topic_0000001152616261_p195452113218"></a>PATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001152616261_p964914893211"><a name="zh-cn_topic_0000001152616261_p964914893211"></a><a name="zh-cn_topic_0000001152616261_p964914893211"></a>可执行程序的查找路径,参考上述举例配置。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001152616261_row58592816294"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001152616261_p1886016892913"><a name="zh-cn_topic_0000001152616261_p1886016892913"></a><a name="zh-cn_topic_0000001152616261_p1886016892913"></a>ASCEND_OPP_PATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001152616261_p28608892915"><a name="zh-cn_topic_0000001152616261_p28608892915"></a><a name="zh-cn_topic_0000001152616261_p28608892915"></a>算子根目录,参考上述举例配置。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001152616261_row144592037903"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001152616261_p104601373014"><a name="zh-cn_topic_0000001152616261_p104601373014"></a><a name="zh-cn_topic_0000001152616261_p104601373014"></a>OPTION_EXEC_EXTERN_PLUGIN_PATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001152616261_p1046013716017"><a name="zh-cn_topic_0000001152616261_p1046013716017"></a><a name="zh-cn_topic_0000001152616261_p1046013716017"></a>算子信息库路径。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001152616261_row16184379493"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001152616261_p131851873492"><a name="zh-cn_topic_0000001152616261_p131851873492"></a><a name="zh-cn_topic_0000001152616261_p131851873492"></a>ASCEND_AICPU_PATH</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001152616261_p181851575497"><a name="zh-cn_topic_0000001152616261_p181851575497"></a><a name="zh-cn_topic_0000001152616261_p181851575497"></a>aicpu算子包路径。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001152616261_row234714854615"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001152616261_p2034724894619"><a name="zh-cn_topic_0000001152616261_p2034724894619"></a><a name="zh-cn_topic_0000001152616261_p2034724894619"></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_p53477489462"><a name="zh-cn_topic_0000001152616261_p53477489462"></a><a name="zh-cn_topic_0000001152616261_p53477489462"></a>使用异步任务下发,异步调用acl接口。建议开启,开启设置为1。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001152616261_row1680820246202"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001152616261_p4809112415207"><a name="zh-cn_topic_0000001152616261_p4809112415207"></a><a name="zh-cn_topic_0000001152616261_p4809112415207"></a>HCCL_WHITELIST_DISABLE</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001152616261_p952814428206"><a name="zh-cn_topic_0000001152616261_p952814428206"></a><a name="zh-cn_topic_0000001152616261_p952814428206"></a>配置在使用HCCL时是否开启通信白名单。</p>
|
||||
<a name="ul928845132310"></a><a name="ul928845132310"></a><ul id="ul928845132310"><li>0:开启白名单,无需校验HCCL通信白名单。</li><li>1:关闭白名单,需校验HCCL通信白名单。</li></ul>
|
||||
<p id="zh-cn_topic_0000001152616261_p5809162416201"><a name="zh-cn_topic_0000001152616261_p5809162416201"></a><a name="zh-cn_topic_0000001152616261_p5809162416201"></a>缺省值为0,默认开启白名单。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001152616261_row0671137162115"><td class="cellrowborder" valign="top" width="55.48%" headers="mcps1.2.3.1.1 "><p id="zh-cn_topic_0000001152616261_p4671203792114"><a name="zh-cn_topic_0000001152616261_p4671203792114"></a><a name="zh-cn_topic_0000001152616261_p4671203792114"></a>HCCL_IF_IP</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="44.519999999999996%" headers="mcps1.2.3.1.2 "><p id="zh-cn_topic_0000001152616261_p1822165982114"><a name="zh-cn_topic_0000001152616261_p1822165982114"></a><a name="zh-cn_topic_0000001152616261_p1822165982114"></a>配置HCCL的初始化通信网卡IP。</p>
|
||||
<a name="ul2676102292415"></a><a name="ul2676102292415"></a><ul id="ul2676102292415"><li>ip格式为点分十进制。</li><li>暂只支持host网卡。</li></ul>
|
||||
<p id="zh-cn_topic_0000001152616261_p1167163719217"><a name="zh-cn_topic_0000001152616261_p1167163719217"></a><a name="zh-cn_topic_0000001152616261_p1167163719217"></a>缺省时,按照以下优先级选定host通信网卡名:docker/local以外网卡(网卡名字字典序升序排列)>docker 网卡 > local网卡</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001152616261_row1371356152313"><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>unset GOMP_CPU_AFFINITY</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>(可选)当系统为openeuler时,需设置此命令,取消CPU绑核。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2 id="安装混合精度模块.md">安装混合精度模块</h2>
|
||||
|
||||
## 前提条件<a name="zh-cn_topic_0000001106176190_section3225481020"></a>
|
||||
|
||||
1. 请确保运行环境中适配昇腾AI处理器的PyTorch框架能正常使用。
|
||||
2. 编译安装Apex前,需参见[配置环境变量](#配置环境变量.md)配置好编译过程依赖的环境变量。
|
||||
|
||||
## 安装流程<a name="zh-cn_topic_0000001106176190_section11880164819567"></a>
|
||||
|
||||
1. 以root或非root用户登录服务器。
|
||||
2. 获取apex源代码。
|
||||
|
||||
1. 运行如下命令,获取适配昇腾AI处理器的apex源代码。
|
||||
|
||||
```
|
||||
git clone https://gitee.com/ascend/apex.git
|
||||
```
|
||||
|
||||
下载的源码主要目录结构如下所示:
|
||||
|
||||
```
|
||||
apex
|
||||
│ ├─patch # 昇腾AI处理器适配补丁目录
|
||||
│ ├─npu.patch
|
||||
│ ├─scripts # 编译构建目录
|
||||
│ ├─gen.sh
|
||||
│ ├─src # 源码目录
|
||||
│ ├─tests # 测试用例存放目录
|
||||
│ ├─README.md
|
||||
```
|
||||
|
||||
2. 运行如下命令,进入“apex“目录,并获取原生apex源代码。
|
||||
|
||||
```
|
||||
cd apex
|
||||
git clone https://github.com/NVIDIA/apex.git
|
||||
```
|
||||
|
||||
下载原生apex源码后,代码主要目录结构如下所示:
|
||||
|
||||
```
|
||||
apex
|
||||
│ ├─apex # 原生apex代码目录
|
||||
│ ├─patch # 昇腾AI处理器适配补丁目录
|
||||
│ ├─npu.patch
|
||||
│ ├─scripts # 编译构建目录
|
||||
│ ├─gen.sh
|
||||
│ ├─src # 源码目录
|
||||
│ ├─tests # 测试用例存放目录
|
||||
│ ├─README.md
|
||||
```
|
||||
|
||||
3. 进入原生apex代码目录,即“apex/apex“目录。切换至commitid为4ef930c1c884fdca5f472ab2ce7cb9b505d26c1a的代码分支。
|
||||
|
||||
```
|
||||
cd apex
|
||||
git checkout 4ef930c1c884fdca5f472ab2ce7cb9b505d26c1a
|
||||
cd ..
|
||||
```
|
||||
|
||||
> **说明:**
|
||||
>受网络波动影响,源码获取时间可能较长,下载过程中请耐心等待。
|
||||
|
||||
3. 编译生成适配昇腾AI处理器的apex安装包。
|
||||
1. 进入“apex/scripts“文件夹,执行转换脚本,生成适配昇腾AI处理器的全量代码。
|
||||
|
||||
```
|
||||
cd ../scripts
|
||||
bash gen.sh
|
||||
```
|
||||
|
||||
将在"apex/apex"目录中生成适配昇腾AI处理器的全量代码。
|
||||
|
||||
2. 进入适配后的全量代码目录,即“apex/apex“目录,编译生成apex的二进制安装包。
|
||||
|
||||
```
|
||||
cd ../apex
|
||||
python3 setup.py --cpp_ext --npu_float_status bdist_wheel
|
||||
```
|
||||
|
||||
生成的二进制包在当前的dist目录下,即“apex/apex/dist”文件夹目录下。
|
||||
|
||||
4. <a name="zh-cn_topic_0000001106176190_li425495374416"></a>安装apex。
|
||||
|
||||
进入“apex/apex/dist“文件夹目录,执行如下命令安装。
|
||||
|
||||
```
|
||||
pip3.7 install --upgrade apex-0.1+ascend-cp37-cp37m-linux_{arch}.whl
|
||||
```
|
||||
|
||||
**\{arch\}**表示架构信息,为aarch64或x86\_64。
|
||||
|
||||
> **说明:**
|
||||
>若对环境中的Apex进行升级时,需要先卸载环境中已安装的PyTorch软件包再执行[4. 安装apex。](#zh-cn_topic_0000001106176190_li425495374416)可以通过执行如下命令查询环境上是否已安装PyTorch。
|
||||
>**pip3 list | grep apex**
|
||||
|
||||
|
||||
<h2 id="使用Ascend-Hub镜像.md">使用Ascend Hub镜像</h2>
|
||||
|
||||
- **[Ascend Hub获取PyTorch镜像](#Ascend-Hub获取PyTorch镜像.md)**
|
||||
|
||||
- **[配置环境变量](#配置环境变量-0.md)**
|
||||
|
||||
|
||||
<h2 id="Ascend-Hub获取PyTorch镜像.md">Ascend Hub获取PyTorch镜像</h2>
|
||||
|
||||
## 前提条件<a name="zh-cn_topic_0000001118701830_zh-cn_topic_0275872734_section108914373254"></a>
|
||||
|
||||
- 已准备好相应硬件环境驱动和固件的安装,请参见各硬件产品[“驱动和固件安装升级指南”](https://support.huawei.com/enterprise/zh/category/ai-computing-platform-pid-1557196528909)。需要在硬件设备上安装与CANN版本配套的固件与驱动。
|
||||
- 宿主机上已安装Docker。
|
||||
|
||||
## 获取并使用镜像<a name="zh-cn_topic_0000001118701830_section108941734162613"></a>
|
||||
|
||||
用户可登录[Ascend Hub](https://ascendhub.huawei.com/#/home)获取相应镜像(首次申请需要激活账号)。
|
||||
|
||||
当前支持的镜像列表如[表1](#zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_table1519011227314)所示。用户可根据实际选择所需的镜像进行下载并使用。
|
||||
|
||||
**表 1** 镜像列表
|
||||
|
||||
<a name="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_table1519011227314"></a>
|
||||
<table><thead align="left"><tr id="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_row0190152218319"><th class="cellrowborder" valign="top" width="55.00000000000001%" id="mcps1.2.4.1.1"><p id="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_p1419132211315"><a name="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_p1419132211315"></a><a name="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_p1419132211315"></a>镜像名称</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="20%" id="mcps1.2.4.1.2"><p id="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_p75071327115313"><a name="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_p75071327115313"></a><a name="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_p75071327115313"></a>镜像版本</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="25%" id="mcps1.2.4.1.3"><p id="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_p1024411406234"><a name="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_p1024411406234"></a><a name="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_p1024411406234"></a>配套CANN版本</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_row71915221134"><td class="cellrowborder" valign="top" width="55.00000000000001%" headers="mcps1.2.4.1.1 "><a name="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_ul81691515131910"></a><a name="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_ul81691515131910"></a><ul id="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_ul81691515131910"><li>ARM架构:<a href="https://ascendhub.huawei.com/#/detail?name=ascend-pytorch-arm" target="_blank" rel="noopener noreferrer">ascend-pytorch-arm</a></li><li>x86架构:<a href="https://ascendhub.huawei.com/#/detail?name=ascend-pytorch-x86" target="_blank" rel="noopener noreferrer">ascend-pytorch-x86</a></li></ul>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.2.4.1.2 "><p id="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_p14648161414516"><a name="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_p14648161414516"></a><a name="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_p14648161414516"></a>21.0.2</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.2.4.1.3 "><p id="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_p1264815147514"><a name="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_p1264815147514"></a><a name="zh-cn_topic_0000001118701830_zh-cn_topic_0000001074498056_p1264815147514"></a><a href="https://support.huawei.com/enterprise/zh/ascend-computing/cann-pid-251168373" target="_blank" rel="noopener noreferrer">5.0.2</a></p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2 id="配置环境变量-0.md">配置环境变量</h2>
|
||||
|
||||
启动并进入镜像容器后,请参见[配置环境变量](#配置环境变量.md)配置模型训练依赖的环境变量。
|
||||
|
||||
<h2 id="参考信息.md">参考信息</h2>
|
||||
|
||||
- **[CMake安装方法](#CMake安装方法.md)**
|
||||
|
||||
- **[安装7.3.0版本gcc](#安装7-3-0版本gcc.md)**
|
||||
|
||||
- **[安装“torch-\*.whl ”提示“torch 1.5.0xxxx”与“torchvision”所依赖的版本不匹配](#安装-torch--whl-提示-torch-1-5-0xxxx-与-torchvision-所依赖的版本不匹配.md)**
|
||||
|
||||
|
||||
<h2 id="CMake安装方法.md">CMake安装方法</h2>
|
||||
|
||||
CMake版本升级为3.12.1的方法
|
||||
|
||||
1. 获取Cmake软件包。
|
||||
|
||||
```
|
||||
wget https://cmake.org/files/v3.12/cmake-3.12.1.tar.gz --no-check-certificate
|
||||
```
|
||||
|
||||
2. 解压并进入软件包目录。
|
||||
|
||||
```
|
||||
tar -xf cmake-3.12.1.tar.gz
|
||||
cd cmake-3.12.1/
|
||||
```
|
||||
|
||||
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.1”则表示安装成功。
|
||||
|
||||
|
||||
<h2 id="安装7-3-0版本gcc.md">安装7.3.0版本gcc</h2>
|
||||
|
||||
以下步骤请在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
|
||||
```
|
||||
|
||||
> **须知:**
|
||||
>其中“--prefix“参数用于指定linux\_gcc7.3.0安装路径,用户可自行配置,但注意不要配置为“/usr/local“及“/usr“,因为会与系统使用软件源默认安装的gcc相冲突,导致系统原始gcc编译环境被破坏。示例指定为“/usr/local/linux\_gcc7.3.0“。
|
||||
|
||||
|
||||
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/“。
|
||||
|
||||
> **说明:**
|
||||
>本步骤为用户在需要用到gcc升级后的编译环境时才配置环境变量。
|
||||
|
||||
|
||||
<h2 id="安装-torch--whl-提示-torch-1-5-0xxxx-与-torchvision-所依赖的版本不匹配.md">安装“torch-\*.whl ”提示“torch 1.5.0xxxx”与“torchvision”所依赖的版本不匹配</h2>
|
||||
|
||||
## 现象描述<a name="zh-cn_topic_0000001105856364_zh-cn_topic_0175549220_section197270431505"></a>
|
||||
|
||||
安装“torch-\*.whl”时,提示"ERROR:torchvision 0.6.0 has requirement torch==1.5.0, but you'll have torch 1.5.0a0+1977093 which is incompatible"。
|
||||
|
||||

|
||||
|
||||
## 可能原因<a name="zh-cn_topic_0000001105856364_zh-cn_topic_0175549220_section169499490501"></a>
|
||||
|
||||
安装torch时,会自动触发torchvision进行依赖版本检查,环境中安装的torchvision版本为0.6.0,检查时发现我们安装的torch-\*.whl的版本号与要求的1.5.0不一致,所以提示报错,但实际安装成功 。
|
||||
|
||||
## 处理方法<a name="zh-cn_topic_0000001105856364_section108142031907"></a>
|
||||
|
||||
对实际结果无影响,无需处理。
|
||||
|
||||
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 29 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 |
@@ -8,8 +8,8 @@
|
||||
- [前提条件](#前提条件.md)
|
||||
- [获取PyTorch源码](#获取PyTorch源码.md)
|
||||
- [注册算子开发](#注册算子开发.md)
|
||||
- [算子适配开发](#算子适配开发-0.md)
|
||||
- [编译安装PyTorch框架](#编译安装PyTorch框架.md)
|
||||
- [算子适配插件开发](#算子适配插件开发.md)
|
||||
- [编译和安装PyTorch框架](#编译和安装PyTorch框架.md)
|
||||
- [算子功能验证](#算子功能验证.md)
|
||||
- [概述](#概述.md)
|
||||
- [实现过程](#实现过程.md)
|
||||
@@ -17,11 +17,9 @@
|
||||
- [Pillow==5.3.0安装失败](#Pillow-5-3-0安装失败.md)
|
||||
- [pip3.7 install torchvision安装失败](#pip3-7-install-torchvision安装失败.md)
|
||||
- [安装“torch-\*.whl ”提示“torch 1.5.0xxxx”与“torchvision”所依赖的版本不匹配](#安装-torch--whl-提示-torch-1-5-0xxxx-与-torchvision-所依赖的版本不匹配.md)
|
||||
- [执行算子功能验证用例,结果成功,但会报一个错误“THPModule\_npu\_shutdown failed.”](#执行算子功能验证用例-结果成功-但会报一个错误-THPModule_npu_shutdown-failed.md)
|
||||
- [如何查看测试的运行日志](#如何查看测试的运行日志.md)
|
||||
- [测试运行输出的NPU错误码是什么意思,有无对应的含义解释?](#测试运行输出的NPU错误码是什么意思-有无对应的含义解释.md)
|
||||
- [为什么我实现的“自定义TBE算子”无法调用到?](#为什么我实现的-自定义TBE算子-无法调用到.md)
|
||||
- [如何确定“TBE算子”是否被“PyTorch适配”正确调用?](#如何确定-TBE算子-是否被-PyTorch适配-正确调用.md)
|
||||
- [如何确定“TBE算子”是否被“PyTorch适配”正确调用](#如何确定-TBE算子-是否被-PyTorch适配-正确调用.md)
|
||||
- [PyTorch编译失败,提示“error: ld returned 1 exit status”](#PyTorch编译失败-提示-error-ld-returned-1-exit-status.md)
|
||||
- [PyTorch编译失败,提示“error: call of overload ....”](#PyTorch编译失败-提示-error-call-of-overload.md)
|
||||
- [附录](#附录.md)
|
||||
@@ -31,7 +29,7 @@
|
||||
|
||||
## 概述<a name="zh-cn_topic_0000001125558589_section7405182695312"></a>
|
||||
|
||||
用户通过完成TBE自定义算子适配PyTorch框架,实现PyTorch框架中算子在昇腾AI处理器上运行。
|
||||
为了实现PyTorch深度学习框架在昇腾AI处理器上运行,需要将框架算子用TBE自定义开发。
|
||||
|
||||
<h2 id="算子开发流程.md">算子开发流程</h2>
|
||||
|
||||
@@ -39,7 +37,7 @@ Pytorch算子开发包含TBE算子开发和PyTorch框架下的算子适配。
|
||||
|
||||
1. TBE算子开发:昇腾AI软件栈中不包含相应的算子,需要先完成TBE算子的开发,再进行PyTorch框架下的算子适配。
|
||||
|
||||
TBE算子开发流程及方法请参见《CANN TBE自定义算子开发指南](https://support.huawei.com/enterprise/zh/doc/EDOC1100191916)》。
|
||||
TBE算子开发流程及方法请参见《CANN TBE自定义算子开发指南》。
|
||||
|
||||
2. PyTorch框架下的算子适配:昇腾AI软件栈中已实现了相应的TBE算子,可直接进行PyTorch框架适配。
|
||||
|
||||
@@ -76,7 +74,7 @@ Pytorch算子开发包含TBE算子开发和PyTorch框架下的算子适配。
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.5.1.2 "><p id="zh-cn_topic_0000001105032530_p1346749990"><a name="zh-cn_topic_0000001105032530_p1346749990"></a><a name="zh-cn_topic_0000001105032530_p1346749990"></a>算子速查</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.5.1.3 "><p id="zh-cn_topic_0000001105032530_p1767111499129"><a name="zh-cn_topic_0000001105032530_p1767111499129"></a><a name="zh-cn_topic_0000001105032530_p1767111499129"></a>查看TBE算子支持列表和PyTorch算子适配列表。</p>
|
||||
<a name="zh-cn_topic_0000001105032530_ul03431749101318"></a><a name="zh-cn_topic_0000001105032530_ul03431749101318"></a><ul id="zh-cn_topic_0000001105032530_ul03431749101318"><li>当前<span id="zh-cn_topic_0000001105032530_ph1748571571010"><a name="zh-cn_topic_0000001105032530_ph1748571571010"></a><a name="zh-cn_topic_0000001105032530_ph1748571571010"></a>昇腾AI处理器</span>支持的算子列表及支持的算子的详细规格约束。</li><li>当前PyTorch适配的算子列表</li></ul>
|
||||
<a name="zh-cn_topic_0000001105032530_ul03431749101318"></a><a name="zh-cn_topic_0000001105032530_ul03431749101318"></a><ul id="zh-cn_topic_0000001105032530_ul03431749101318"><li>当前<span id="zh-cn_topic_0000001105032530_ph1748571571010"><a name="zh-cn_topic_0000001105032530_ph1748571571010"></a><a name="zh-cn_topic_0000001105032530_ph1748571571010"></a>昇腾AI处理器</span>支持的算子列表及支持的算子的详细规格约束。</li><li>当前PyTorch适配的算子列表。</li></ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001105032530_zh-cn_topic_0228422310_row411025743119"><td class="cellrowborder" valign="top" width="6.811326262527976%" headers="mcps1.2.5.1.1 "><p id="zh-cn_topic_0000001105032530_p156991054952"><a name="zh-cn_topic_0000001105032530_p156991054952"></a><a name="zh-cn_topic_0000001105032530_p156991054952"></a>3</p>
|
||||
@@ -86,9 +84,6 @@ Pytorch算子开发包含TBE算子开发和PyTorch框架下的算子适配。
|
||||
<td class="cellrowborder" valign="top" width="55.55123090396029%" headers="mcps1.2.5.1.3 "><p id="zh-cn_topic_0000001105032530_zh-cn_topic_0228422310_p381282212"><a name="zh-cn_topic_0000001105032530_zh-cn_topic_0228422310_p381282212"></a><a name="zh-cn_topic_0000001105032530_zh-cn_topic_0228422310_p381282212"></a>获取昇腾社区PyTorch源码。</p>
|
||||
</td>
|
||||
<td class="cellrowborder" rowspan="4" valign="top" width="19.772307093509777%" headers="mcps1.2.5.1.4 "><p id="zh-cn_topic_0000001105032530_p10679152717175"><a name="zh-cn_topic_0000001105032530_p10679152717175"></a><a name="zh-cn_topic_0000001105032530_p10679152717175"></a><a href="#算子开发准备.md">算子适配开发</a></p>
|
||||
<p id="zh-cn_topic_0000001105032530_zh-cn_topic_0228422310_p158114465518"><a name="zh-cn_topic_0000001105032530_zh-cn_topic_0228422310_p158114465518"></a><a name="zh-cn_topic_0000001105032530_zh-cn_topic_0228422310_p158114465518"></a></p>
|
||||
<p id="zh-cn_topic_0000001105032530_zh-cn_topic_0228422310_p187638695511"><a name="zh-cn_topic_0000001105032530_zh-cn_topic_0228422310_p187638695511"></a><a name="zh-cn_topic_0000001105032530_zh-cn_topic_0228422310_p187638695511"></a></p>
|
||||
<p id="zh-cn_topic_0000001105032530_p06411821710"><a name="zh-cn_topic_0000001105032530_p06411821710"></a><a name="zh-cn_topic_0000001105032530_p06411821710"></a></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001105032530_row1184984391512"><td class="cellrowborder" valign="top" headers="mcps1.2.5.1.1 "><p id="zh-cn_topic_0000001105032530_p1054075616153"><a name="zh-cn_topic_0000001105032530_p1054075616153"></a><a name="zh-cn_topic_0000001105032530_p1054075616153"></a>4</p>
|
||||
@@ -109,12 +104,12 @@ Pytorch算子开发包含TBE算子开发和PyTorch框架下的算子适配。
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.5.1.2 "><p id="zh-cn_topic_0000001105032530_p963085451515"><a name="zh-cn_topic_0000001105032530_p963085451515"></a><a name="zh-cn_topic_0000001105032530_p963085451515"></a>编译安装PyTorch框架</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.5.1.3 "><p id="zh-cn_topic_0000001105032530_p1463431151811"><a name="zh-cn_topic_0000001105032530_p1463431151811"></a><a name="zh-cn_topic_0000001105032530_p1463431151811"></a>编译适配开发后的Pytorch源码,并安装编译的源码包。</p>
|
||||
<td class="cellrowborder" valign="top" headers="mcps1.2.5.1.3 "><p id="zh-cn_topic_0000001105032530_p1463431151811"><a name="zh-cn_topic_0000001105032530_p1463431151811"></a><a name="zh-cn_topic_0000001105032530_p1463431151811"></a>编译适配开发后的PyTorch源码,并安装编译的源码包。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="zh-cn_topic_0000001105032530_zh-cn_topic_0228422310_row162484372491"><td class="cellrowborder" valign="top" width="6.811326262527976%" headers="mcps1.2.5.1.1 "><p id="zh-cn_topic_0000001105032530_p454075611155"><a name="zh-cn_topic_0000001105032530_p454075611155"></a><a name="zh-cn_topic_0000001105032530_p454075611155"></a>7</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="17.865135740001946%" headers="mcps1.2.5.1.2 "><p id="zh-cn_topic_0000001105032530_p11630135413155"><a name="zh-cn_topic_0000001105032530_p11630135413155"></a><a name="zh-cn_topic_0000001105032530_p11630135413155"></a>算子验证</p>
|
||||
<td class="cellrowborder" valign="top" width="17.865135740001946%" headers="mcps1.2.5.1.2 "><p id="zh-cn_topic_0000001105032530_p11630135413155"><a name="zh-cn_topic_0000001105032530_p11630135413155"></a><a name="zh-cn_topic_0000001105032530_p11630135413155"></a>算子功能验证</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="55.55123090396029%" headers="mcps1.2.5.1.3 "><p id="zh-cn_topic_0000001105032530_zh-cn_topic_0228422310_p4952132615216"><a name="zh-cn_topic_0000001105032530_zh-cn_topic_0228422310_p4952132615216"></a><a name="zh-cn_topic_0000001105032530_zh-cn_topic_0228422310_p4952132615216"></a>在真实的硬件环境中验证算子功能。</p>
|
||||
</td>
|
||||
@@ -135,23 +130,27 @@ Pytorch算子开发包含TBE算子开发和PyTorch框架下的算子适配。
|
||||
|
||||
## 前提条件<a name="zh-cn_topic_0000001125736787_section12464163765320"></a>
|
||||
|
||||
- 已完成CANN开发或运行环境的安装,具体操作请参考《CANN 软件安装指南](https://support.huawei.com/enterprise/zh/ascend-computing/cann-pid-251168373)》。
|
||||
- 需安装3.12.0以上版本的CMake,安装方法请参考[CMake安装方法](#CMake安装方法.md)。
|
||||
- 需确保已安装7.3.0以上版本的gcc,7.3.0版本gcc具体安装及使用方式请参见《CANN 软件安装指南](https://support.huawei.com/enterprise/zh/ascend-computing/cann-pid-251168373)》中的“安装7.3.0版本gcc”章节。
|
||||
- 需完成CANN开发或运行环境的安装,具体操作请参考《CANN 软件安装指南》。
|
||||
- 需安装3.12.0及以上版本的CMake,安装方法请参考[CMake安装方法](#CMake安装方法.md)。
|
||||
- 需确保已安装7.3.0以上版本的gcc,7.3.0版本gcc具体安装及使用方式请参见《CANN 软件安装指南》中的“安装7.3.0版本gcc”章节。
|
||||
- 需确保环境中已安装git工具,以Ubuntu和CentOS系统为例,命令如下:
|
||||
- Ubuntu系统
|
||||
|
||||
**apt-get install git**
|
||||
```
|
||||
apt-get install git
|
||||
```
|
||||
|
||||
- CentOS系统
|
||||
|
||||
**yum install git**
|
||||
```
|
||||
yum install git
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 安装PyTorch依赖环境<a name="zh-cn_topic_0000001125736787_section18699192116550"></a>
|
||||
|
||||
如果使用非root用户安装Python及其依赖,用户需要在每句命令结尾加上**--user**,保证安装的正常进行。命令示例为:**pip3.7 install pyyaml --user**
|
||||
如果使用非root用户安装Python及其依赖,用户需要在每句命令末尾加上**--user**,保证安装的正常进行。命令示例为:**pip3.7 install pyyaml --user**
|
||||
|
||||
```
|
||||
pip3.7 install pyyaml
|
||||
@@ -166,11 +165,17 @@ pip3.7 install Pillow==5.3.0
|
||||
|
||||
进行算子开发时,您可以查询当前昇腾AI处理器中支持的算子列表和当前PyTorch适配的算子列表。根据查询结果进行算子开发或PyTorch算子适配。
|
||||
|
||||
- 当前昇腾AI处理器中支持的算子以及对应的算子约束可以通过以下两种方式查询。
|
||||
- 命令行开发方式下,您可以参见《CANN 算子清单 \(Ascend 910\)](https://support.huawei.com/enterprise/zh/doc/EDOC1100191920)》进行离线查询。
|
||||
- MindStudio开发方式下,您可以通过MindStudio进行在线查询,详细查看方法可参见《MindStudio 用户指南](https://support.huaweicloud.com/mindstudio301/index.html)》中的“算子&模型速查”章节。
|
||||
- 若昇腾AI处理器不支持算子,则需要进行TBE算子开发和PyTorch框架算子适配。
|
||||
- 若昇腾AI处理器支持算子但PyTorch框架没有算子适配,仅需要进行PyTorch框架下算子适配。
|
||||
- 若PyTorch框架已经适配算子,直接使用算子即可,不需要开发和适配。
|
||||
|
||||
- 当前PyTorch适配的算子列表可以参见《PyTorch适配算子清单](https://support.huawei.com/enterprise/zh/doc/EDOC1100191773)》
|
||||
昇腾AI处理器和PyTorch适配的算子查询方式如下。
|
||||
|
||||
- 当前昇腾AI处理器中支持的算子以及对应的算子约束可以通过以下两种方式查询。
|
||||
- 命令行开发方式下,您可以参见《CANN 算子清单 \(Ascend 910\)》进行离线查询。
|
||||
- MindStudio开发方式下,您可以通过MindStudio进行在线查询,详细查看方法可参见《MindStudio 用户指南》中的“算子&模型速查”章节。
|
||||
|
||||
- 当前PyTorch适配的算子列表可以参见《PyTorch适配算子清单》。
|
||||
|
||||
<h2 id="算子适配开发.md">算子适配开发</h2>
|
||||
|
||||
@@ -180,22 +185,22 @@ pip3.7 install Pillow==5.3.0
|
||||
|
||||
- **[注册算子开发](#注册算子开发.md)**
|
||||
|
||||
- **[算子适配开发](#算子适配开发-0.md)**
|
||||
- **[算子适配插件开发](#算子适配插件开发.md)**
|
||||
|
||||
- **[编译安装PyTorch框架](#编译安装PyTorch框架.md)**
|
||||
- **[编译和安装PyTorch框架](#编译和安装PyTorch框架.md)**
|
||||
|
||||
|
||||
<h2 id="前提条件.md">前提条件</h2>
|
||||
|
||||
1. 完成开发及运行环境准备及相关依赖的安装,详情请参见[环境准备](#zh-cn_topic_0000001125736787.md)。
|
||||
2. 完成相关的TBE算子开发及部署,详情请参见《CANN TBE自定义算子开发指南](https://support.huawei.com/enterprise/zh/doc/EDOC1100191916)》。
|
||||
- 完成开发及运行环境准备及相关依赖的安装,详情请参见[环境准备](#环境准备.md)。
|
||||
- 完成相关的TBE算子开发及部署,详情请参见《CANN TBE自定义算子开发指南》。
|
||||
|
||||
<h2 id="获取PyTorch源码.md">获取PyTorch源码</h2>
|
||||
|
||||
从gitee上获取适配昇腾AI处理器的PyTorch源代码,获取地址为: [https://gitee.com/ascend/pytorch](https://gitee.com/ascend/pytorch) 。用户可以通过执行下面git命令行下载源代码。
|
||||
从gitee上获取适配昇腾AI处理器的PyTorch源代码,获取地址为: [https://gitee.com/ascend/pytorch-develop](https://gitee.com/ascend/pytorch-develop) 。用户可以通过执行下面git命令行下载源代码。
|
||||
|
||||
```
|
||||
git clone https://gitee.com/ascend/pytorch.git --deepth=1
|
||||
git clone https://gitee.com/ascend/pytorch-develop.git --deepth=1
|
||||
```
|
||||
|
||||
下载成功后,得到pytorch文件目录。
|
||||
@@ -228,7 +233,6 @@ git clone https://gitee.com/ascend/pytorch.git --deepth=1
|
||||
- func:适配算子名称(输入参数信息) -> 返回类型
|
||||
```
|
||||
|
||||
|
||||
3. 修改native\_functions.yaml文件,添加实现该算子相关函数的分发描述。
|
||||
|
||||
yaml 文件编写规范:
|
||||
@@ -247,7 +251,6 @@ git clone https://gitee.com/ascend/pytorch.git --deepth=1
|
||||
NPU: NPU_Adapt_Fun_Name
|
||||
```
|
||||
|
||||
|
||||
> **说明:**
|
||||
>NPU\_Adapt\_Fun\_Name的格式为 :
|
||||
>- 如果原Fun\_Name无"\_"后缀,则格式:Fun\_Name + "\_" + "npu",如:add --\> add\_npu。
|
||||
@@ -260,7 +263,7 @@ git clone https://gitee.com/ascend/pytorch.git --deepth=1
|
||||
以torch.add\(\)算子为例介绍注册算子开发过程。
|
||||
|
||||
1. 打开native\_functions.yaml文件。
|
||||
2. 确定相关函数
|
||||
2. 确定相关函数。
|
||||
|
||||
在yaml中搜索add,找到与add算子相关的函数。
|
||||
|
||||
@@ -341,7 +344,7 @@ git clone https://gitee.com/ascend/pytorch.git --deepth=1
|
||||
|
||||
|
||||
|
||||
<h2 id="算子适配开发-0.md">算子适配开发</h2>
|
||||
<h2 id="算子适配插件开发.md">算子适配插件开发</h2>
|
||||
|
||||
## 简介<a name="zh-cn_topic_0000001125315877_section16410139174517"></a>
|
||||
|
||||
@@ -349,11 +352,11 @@ git clone https://gitee.com/ascend/pytorch.git --deepth=1
|
||||
|
||||
## 适配插件实现<a name="zh-cn_topic_0000001125315877_section1174074518456"></a>
|
||||
|
||||
1. 创建适配插件文件
|
||||
1. 创建适配插件文件。
|
||||
|
||||
NPU TBE算子适配文件保存在pytorch/aten/src/ATen/native/npu目录下,命名风格采用大驼峰,命名格式:<算子名\> + <KernelNpu\>.cpp,如:AddKernelNpu.cpp。
|
||||
|
||||
2. 引入依赖头文件
|
||||
2. 引入依赖头文件。
|
||||
|
||||
适配昇腾AI处理器的PyTorch源代码在ATen/native/npu/utils中提供适配常用的工具供用户使用。
|
||||
|
||||
@@ -362,7 +365,7 @@ git clone https://gitee.com/ascend/pytorch.git --deepth=1
|
||||
|
||||
3. 定义算子适配主体函数。
|
||||
|
||||
根据注册算子开发中的分发函数确定自定义算子适配主题函数。
|
||||
根据注册算子开发中的分发函数确定自定义算子适配主体函数。
|
||||
|
||||
4. 分别实现适配主体函数。
|
||||
|
||||
@@ -373,11 +376,11 @@ git clone https://gitee.com/ascend/pytorch.git --deepth=1
|
||||
|
||||
以torch.add\(\)算子为例介绍算子适配开发过程。
|
||||
|
||||
1. 创建适配插件文件
|
||||
1. 创建适配插件文件。
|
||||
|
||||
在pytorch/aten/src/ATen/native/npu目录下创建AddKernelNpu.cpp适配文件
|
||||
在pytorch/aten/src/ATen/native/npu目录下创建AddKernelNpu.cpp适配文件。
|
||||
|
||||
2. 引入依赖头文件
|
||||
2. 引入依赖头文件。
|
||||
|
||||
```
|
||||
#include <c10/npu/OptionsManager.h>
|
||||
@@ -386,7 +389,6 @@ git clone https://gitee.com/ascend/pytorch.git --deepth=1
|
||||
```
|
||||
|
||||
> **说明:**
|
||||
>" OptionsManager.h"中主要包含类型动态shape相关的函数。
|
||||
>" CalcuOpUtil.h "中主要包含类型转换和判别的函数。
|
||||
>" OpAdapter.h"文件中主要包含适配关联的头文件。
|
||||
|
||||
@@ -527,7 +529,7 @@ git clone https://gitee.com/ascend/pytorch.git --deepth=1
|
||||
> **说明:**
|
||||
>AddKernelNpu.cpp的详细实现代码请参见pytorch/aten/src/ATen/native/npu/AddKernelNpu.cpp文档。
|
||||
|
||||
<h2 id="编译安装PyTorch框架.md">编译安装PyTorch框架</h2>
|
||||
<h2 id="编译和安装PyTorch框架.md">编译和安装PyTorch框架</h2>
|
||||
|
||||
## 编译PyTorch框架<a name="zh-cn_topic_0000001125736777_section470105143317"></a>
|
||||
|
||||
@@ -540,32 +542,32 @@ git clone https://gitee.com/ascend/pytorch.git --deepth=1
|
||||
|
||||
**./build.sh**
|
||||
|
||||
4. 编译成功后,会在“**pytorch/dist**” 下会生成 torch-\*.whl 包,例如:torch-1.5.0a0-cp37-cp37m-linux\_x86.whl
|
||||
> **说明:**
|
||||
>首次编译持续的时间较长,可能超过30分钟,建议:若无必要,无需执行"make clean"。
|
||||
|
||||
> **说明:**
|
||||
>首次编译持续的时间较长,可能超过30分钟,建议:若无必要,无需执行"make clean"。
|
||||
4. 编译成功后,会在“**pytorch/dist**” 下生成 torch-\*.whl 包,例如:torch-1.5.0a0-cp37-cp37m-linux\_x86.whl。
|
||||
|
||||
## 安装PyTorch框架<a name="zh-cn_topic_0000001125736777_section119821419153412"></a>
|
||||
|
||||
1. 将[编译安装PyTorch框架](#编译安装PyTorch框架.md)生成的torch-\*.whl包上传到服务器任一路径。
|
||||
1. 将[编译和安装PyTorch框架](#编译和安装PyTorch框架.md)生成的torch-\*.whl包上传到服务器任一路径。
|
||||
2. 进入torch-\*.whl 所在的目录,使用pip命令完成torch安装。
|
||||
|
||||
当前登录用户为root用户时,执行:
|
||||
|
||||
```
|
||||
pip3.7.5 install torch-*.whl
|
||||
pip3.7 install torch-*.whl
|
||||
```
|
||||
|
||||
当前登录用户为非root用户时,执行:
|
||||
|
||||
```
|
||||
pip3.7.5 install torch-*.whl --user
|
||||
pip3.7 install torch-*.whl --user
|
||||
```
|
||||
|
||||
|
||||
> **说明:**
|
||||
>1. 修改代码之后,需要重新执行“编译”和“安装”PyTorch过程。
|
||||
>2. 安装过程中,可能会出现错误提示"torchvision 0.6.0" 版本不匹配,此问题无影响,忽略即可。
|
||||
>- 修改代码之后,需要重新执行“编译”和“安装”PyTorch过程。
|
||||
>- 安装过程中,可能会出现错误提示"torchvision 0.6.0" 版本不匹配,此问题无影响,忽略即可。
|
||||
|
||||
<h2 id="算子功能验证.md">算子功能验证</h2>
|
||||
|
||||
@@ -586,7 +588,7 @@ git clone https://gitee.com/ascend/pytorch.git --deepth=1
|
||||
|
||||
进行自定义算子功能验证,通过PyTorch前端构造自定义算子的函数并运行验证。
|
||||
|
||||
在https://gitee.com/ascend/pytorch中 "pytorch/test/test\_npu/test\_network\_ops"目录下提供了测试用例及测试工具,供用户参考。
|
||||
在https://gitee.com/ascend/pytorch-develop中 "pytorch/test/test\_npu/test\_network\_ops"目录下提供了测试用例及测试工具,供用户参考。
|
||||
|
||||
<h2 id="实现过程.md">实现过程</h2>
|
||||
|
||||
@@ -599,17 +601,13 @@ git clone https://gitee.com/ascend/pytorch.git --deepth=1
|
||||
1. 设置环境变量。
|
||||
|
||||
```
|
||||
export install_path=/home/HwHiAiUser/Ascend/ascend-toolkit/latest
|
||||
export PATH={install_path}/fwkacllib/ccec_compiler/bin:{install_path}/fwkacllib/bin:{install_path}/toolkit/bin:$PATH
|
||||
export LD_LIBRARY_PATH={install_path}/fwkacllib/lib64:$LD_LIBRARY_PATH
|
||||
export PYTHONPATH={install_path}/fwkacllib/python/site-packages:{install_path}/toolkit/python/site-packages:$PYTHONPATH
|
||||
export ASCEND_OPP_PATH={install_path}/opp/
|
||||
export ASCEND_AICPU_PATH={install_path}/x86_64-linux/
|
||||
# 进行环境变量设置。具体如下(以HwHiAiUser用户安装,安装路径为默认路径为例):
|
||||
. /home/HwHiAiUser/Ascend/ascend-toolkit/set_env.sh
|
||||
```
|
||||
|
||||
install\_path请修改为Toolkit的实际安装路径。
|
||||
|
||||
2. 编写测试脚本。以add算子为例,在“pytorch/test/test\_npu/test\_network\_ops“路径下编写测试脚本文件: testcase\_add.py。
|
||||
2. 编写测试脚本。以add算子为例,在“pytorch/test/test\_npu/test\_network\_ops“路径下编写测试脚本文件: test\_add.py。
|
||||
|
||||
以下示例仅为一个简单的用例实现供用户参考,具体测试用例的实现,需要根据算子定义进行完整的覆盖才能保证功能的基本正确。
|
||||
|
||||
@@ -655,7 +653,7 @@ git clone https://gitee.com/ascend/pytorch.git --deepth=1
|
||||
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")
|
||||
@@ -668,10 +666,10 @@ git clone https://gitee.com/ascend/pytorch.git --deepth=1
|
||||
|
||||
3. 执行测试用例脚本
|
||||
|
||||
进入add\_testcase.py所在的目录,执行:
|
||||
进入test\_add.py所在的目录,执行:
|
||||
|
||||
```
|
||||
python3.7.5 testcase_add.py
|
||||
python3.7 test_add.py
|
||||
```
|
||||
|
||||
|
||||
@@ -683,15 +681,11 @@ git clone https://gitee.com/ascend/pytorch.git --deepth=1
|
||||
|
||||
- **[安装“torch-\*.whl ”提示“torch 1.5.0xxxx”与“torchvision”所依赖的版本不匹配](#安装-torch--whl-提示-torch-1-5-0xxxx-与-torchvision-所依赖的版本不匹配.md)**
|
||||
|
||||
- **[执行算子功能验证用例,结果成功,但会报一个错误“THPModule\_npu\_shutdown failed.”](#执行算子功能验证用例-结果成功-但会报一个错误-THPModule_npu_shutdown-failed.md)**
|
||||
|
||||
- **[如何查看测试的运行日志](#如何查看测试的运行日志.md)**
|
||||
|
||||
- **[测试运行输出的NPU错误码是什么意思,有无对应的含义解释?](#测试运行输出的NPU错误码是什么意思-有无对应的含义解释.md)**
|
||||
|
||||
- **[为什么我实现的“自定义TBE算子”无法调用到?](#为什么我实现的-自定义TBE算子-无法调用到.md)**
|
||||
|
||||
- **[如何确定“TBE算子”是否被“PyTorch适配”正确调用?](#如何确定-TBE算子-是否被-PyTorch适配-正确调用.md)**
|
||||
- **[如何确定“TBE算子”是否被“PyTorch适配”正确调用](#如何确定-TBE算子-是否被-PyTorch适配-正确调用.md)**
|
||||
|
||||
- **[PyTorch编译失败,提示“error: ld returned 1 exit status”](#PyTorch编译失败-提示-error-ld-returned-1-exit-status.md)**
|
||||
|
||||
@@ -710,7 +704,11 @@ pillow==5.3.0安装失败。
|
||||
|
||||
## 处理方法<a name="zh-cn_topic_0000001125315879_section108142031907"></a>
|
||||
|
||||
apt-get install libjpeg python-devel zlib-devel libjpeg-turbo-devel。
|
||||
执行以下命令安装所需依赖。
|
||||
|
||||
```
|
||||
apt-get install libjpeg python-devel zlib-devel libjpeg-turbo-devel
|
||||
```
|
||||
|
||||
<h2 id="pip3-7-install-torchvision安装失败.md">pip3.7 install torchvision安装失败</h2>
|
||||
|
||||
@@ -724,7 +722,11 @@ torch与torchvision版本不匹配。
|
||||
|
||||
## 处理方法<a name="zh-cn_topic_0000001125641109_section108142031907"></a>
|
||||
|
||||
执行以下命令。
|
||||
|
||||
```
|
||||
pip3.7 install torchvision --no-deps
|
||||
```
|
||||
|
||||
<h2 id="安装-torch--whl-提示-torch-1-5-0xxxx-与-torchvision-所依赖的版本不匹配.md">安装“torch-\*.whl ”提示“torch 1.5.0xxxx”与“torchvision”所依赖的版本不匹配</h2>
|
||||
|
||||
@@ -732,7 +734,7 @@ pip3.7 install torchvision --no-deps
|
||||
|
||||
安装“torch-\*.whl”时,提示"ERROR:torchvision 0.6.0 has requirement torch==1.5.0, but you'll have torch 1.5.0a0+1977093 which is incompatible"。
|
||||
|
||||

|
||||

|
||||
|
||||
但实际安装成功
|
||||
|
||||
@@ -744,39 +746,11 @@ pip3.7 install torchvision --no-deps
|
||||
|
||||
对实际结果无影响,无需处理。
|
||||
|
||||
<h2 id="执行算子功能验证用例-结果成功-但会报一个错误-THPModule_npu_shutdown-failed.md">执行算子功能验证用例,结果成功,但会报一个错误“THPModule\_npu\_shutdown failed.”</h2>
|
||||
|
||||
## 现象描述<a name="zh-cn_topic_0000001125558575_zh-cn_topic_0175549220_section197270431505"></a>
|
||||
|
||||
执行算子功能验证用例,结果成功,但会报一个错误“THPModule\_npu\_shutdown failed.”。
|
||||
|
||||

|
||||
|
||||
## 可能原因<a name="zh-cn_topic_0000001125558575_zh-cn_topic_0175549220_section169499490501"></a>
|
||||
|
||||
可能是框架影响,待进一步定位 。
|
||||
|
||||
## 处理方法<a name="zh-cn_topic_0000001125558575_section108142031907"></a>
|
||||
|
||||
对实际结果无影响,无需处理,忽略此问题。
|
||||
|
||||
<h2 id="如何查看测试的运行日志.md">如何查看测试的运行日志</h2>
|
||||
|
||||
测试运行过程提示错误,但直接可参考的信息太少,如何才能看到更详细的运行日志?
|
||||
|
||||
方式一:直接查看运行日志
|
||||
|
||||
1. 进入 "/var/log/npu"目录
|
||||
|
||||
在此目录下,对于算子功能测试运行,主要的涉及日志路径为“oplog”和“slog”,建议优先查看“oplog”中的日志,这里记录了算子运行过程中的关键信息;slog下的日志记录系统的运行过程及异常信息,具体日志信息内容,参考[日志文件](https://support.huaweicloud.com/lr-A800_9000_9010/atlaslog_24_0003.html)描述。
|
||||
|
||||
2. 进入对应的日志目录,使用vi等工具打开最新的日志文件,进行日志查看。
|
||||
|
||||
> **说明:**
|
||||
>以“/var/log/npu/oplog”为例,"vi oplog.log",可以查看到很多日志信息。但由于可能存在很多开发者同时操作设备进行测试,所有会包含其他开发者的运行日志信息,需要开发者通过“时间”等信息,识别出相关的日志。建议使用“方式二”
|
||||
|
||||
|
||||
方式二:设置日志输出到屏幕,重定向到指定文本文件
|
||||
设置日志输出到屏幕,重定向到指定文本文件
|
||||
|
||||
1. 设置环境变量,将当前用户的日志到屏幕。
|
||||
|
||||
@@ -789,14 +763,10 @@ pip3.7 install torchvision --no-deps
|
||||
2. <a name="zh-cn_topic_0000001125315889_li168732325719"></a>运行测试用例时,将日志重定向到指定文件。
|
||||
|
||||
```
|
||||
python3.7.5 add_testcase.py > test_log.txt
|
||||
python3.7 test_add.py > test_log.txt
|
||||
```
|
||||
|
||||
|
||||
<h2 id="测试运行输出的NPU错误码是什么意思-有无对应的含义解释.md">测试运行输出的NPU错误码是什么意思,有无对应的含义解释?</h2>
|
||||
|
||||
参考“[错误码定义](https://support.huaweicloud.com/adevg-A300_3000_3010/atlasdevelopment_01_0256.html)”。
|
||||
|
||||
<h2 id="为什么我实现的-自定义TBE算子-无法调用到.md">为什么我实现的“自定义TBE算子”无法调用到?</h2>
|
||||
|
||||
## 现象描述<a name="zh-cn_topic_0000001125736795_zh-cn_topic_0175549220_section197270431505"></a>
|
||||
@@ -805,58 +775,53 @@ pip3.7 install torchvision --no-deps
|
||||
|
||||
## 可能原因<a name="zh-cn_topic_0000001125736795_zh-cn_topic_0175549220_section169499490501"></a>
|
||||
|
||||
1. 环境变量没有正确设置;
|
||||
2. yaml存在错误,导致没有正确分发;
|
||||
3. 自定义TBE算子实现存在问题,导致无法调用到。
|
||||
- 环境变量没有正确设置。
|
||||
- yaml存在错误,导致没有正确分发。
|
||||
- 自定义TBE算子实现存在问题,导致无法调用到。
|
||||
|
||||
## 处理方法<a name="zh-cn_topic_0000001125736795_section108142031907"></a>
|
||||
|
||||
1. 参考“[算子功能验证](#算子功能验证.md)”章节,完成运行环境设置,特别注意:
|
||||
|
||||
```
|
||||
export ASCEND_OPP_PATH=~/.local/Ascend/opp
|
||||
export CUSTOM_OP_LIB_PATH=~/.local/Ascend/opp/framework/custom/tensorflow
|
||||
. /home/HwHiAiUser/Ascend/ascend-toolkit/set_env.sh
|
||||
```
|
||||
|
||||
2. 检查yaml文件中对应算子的分发配置,是否正确的完整分发;
|
||||
3. 分析排查代码实现,建议手段:
|
||||
1. 修改"pytorch"中的算子适配实现,让"add\_testcase.py"可以调用到“自定义算子包”中的TBE算子;
|
||||
1. 修改"pytorch"中的算子适配实现,让“test\_add.py”可以调用到“自定义算子包”中的TBE算子;
|
||||
|
||||
"pytorch/aten/src/ATen/native/npu/AddKernelNpu.cpp"
|
||||
|
||||

|
||||

|
||||
|
||||
2. 修改"cann"中的"add"算子实现\(建议此时不要包含新开发的“自定义TBE算子”,方便对比\),在算子入口增加日志打印,作为运行标识;
|
||||
|
||||
"cann/ops/contrib/ops/custom/tbe/impl/add.py"
|
||||
|
||||
3. 完成上两步的编译、安装,调用"python3.7.5 add\_testcase.py"进行测试;
|
||||
2. 完成上两步的编译、安装,调用“python3.7 test\_add.py”进行测试。
|
||||
|
||||
```
|
||||
cd 至"add_testcase.py" 所在路径,调用
|
||||
add_testcase.py
|
||||
cd 至"test_add.py" 所在路径,调用
|
||||
test_add.py
|
||||
进行测试
|
||||
```
|
||||
|
||||
至此步骤,不应该有错误,屏幕应该输出 "add" 中增加的日志打印。若出错,请完成代码清理排查,保证无新开发的代码影响测试。
|
||||
|
||||
4. 将新开发的“自定义TBE算子”合并到"cann"中,在对应的在算子入口增加日志打印,作为运行标识;
|
||||
5. 完成上面的"cann"编译、安装,调用"python3.7.5 add\_testcase.py"进行测试;
|
||||
3. 将新开发的“自定义TBE算子”合并到"cann"中,在对应的在算子入口增加日志打印,作为运行标识。
|
||||
4. 完成上面的"cann"编译、安装,调用“python3.7.5 test\_add.py”进行测试。
|
||||
|
||||
> **说明:**
|
||||
>1、背景知识:根据Ascend的设计逻辑,用户开发安装的“custom”算子包优先级高于“built-in”的内置算子包,在运行加载时,会优先加载调度“custom”包中的算子。过程中,若解析“custom”中的算子信息文件失败,则会跳过“custom”算子包,不加载调度任何“custom”算子包中的任何算子。
|
||||
>2、若此步骤出错,或屏幕未输出 "add" 中增加的日志打印,则说明新开发的“自定义TBE算子”有错误,影响了“自定义算子包”的加载,建议**优先排查新开发的“自定义TBE算子”中的“算子信息定义”是否正确**。
|
||||
>3、若此步骤正确,至少说明 **新开发的“自定义TBE算子”中的“算子信息定义”不影响运行**。
|
||||
>根据Ascend的设计逻辑,用户开发安装的“custom”算子包优先级高于“built-in”的内置算子包,在运行加载时,会优先加载调度“custom”包中的算子。过程中,若解析“custom”中的算子信息文件失败,则会跳过“custom”算子包,不加载调度任何“custom”算子包中的任何算子。
|
||||
>- 若此步骤出错,或屏幕未输出 "add" 中增加的日志打印,则说明新开发的“自定义TBE算子”有错误,影响了“自定义算子包”的加载,建议**优先排查新开发的“自定义TBE算子”中的“算子信息定义”是否正确**。
|
||||
>- 若此步骤正确,至少说明 **新开发的“自定义TBE算子”中的“算子信息定义”不影响运行**。
|
||||
|
||||
6. 调用"python3.7.5 xxx\_testcase.py"进行测试;
|
||||
5. 调用“python3.7.5 xxx\_testcase.py”进行测试;
|
||||
|
||||
> **说明:**
|
||||
>1、若屏幕正常输出新开发的“自定义TBE算子”中增加的日志打印,则至少说明调度到了新开发的算子。
|
||||
>2、若屏幕未输出新开发的“自定义TBE算子”中增加的日志打印,则问题可能出现在"PyTorch适配"中,需要排查这一部分的实现代码,较多的可能会出现在“XxxxKernelNpu.cpp”中的输入、输出未能正确适配。
|
||||
>- 若屏幕正常输出新开发的“自定义TBE算子”中增加的日志打印,则至少说明调度到了新开发的算子。
|
||||
>- 若屏幕未输出新开发的“自定义TBE算子”中增加的日志打印,则问题可能出现在“PyTorch适配”中,需要排查这一部分的实现代码,较多的可能会出现在“XxxxKernelNpu.cpp”中的输入、输出未能正确适配。
|
||||
|
||||
|
||||
|
||||
<h2 id="如何确定-TBE算子-是否被-PyTorch适配-正确调用.md">如何确定“TBE算子”是否被“PyTorch适配”正确调用?</h2>
|
||||
<h2 id="如何确定-TBE算子-是否被-PyTorch适配-正确调用.md">如何确定“TBE算子”是否被“PyTorch适配”正确调用</h2>
|
||||
|
||||
不管是“custom”算子,还是“built-in”算子,在安装后,都是以\*.py源码的方式存放在安装目录下,所以我们可以通过编辑源码,在API入口增加日志的方式,打印输出入参,确定输入的参数是否正确。
|
||||
|
||||
@@ -865,7 +830,7 @@ pip3.7 install torchvision --no-deps
|
||||
|
||||
下面以"built-in"算子中的"zn\_2\_nchw"算子为例:
|
||||
|
||||
1. 打开安装在用户目录下的算子包安装目录
|
||||
1. 打开安装在用户目录下的算子包安装目录。
|
||||
|
||||
```
|
||||
cd ~/.local/Ascend/opp/op_impl/built-in/ai_core/tbe/impl
|
||||
@@ -874,7 +839,7 @@ pip3.7 install torchvision --no-deps
|
||||
|
||||
可以看到相应的算子\*.py源码文件均为“只读”,即此时不可编辑。
|
||||
|
||||

|
||||

|
||||
|
||||
2. 修改算子\*.py源码文件属性,增加“可写”权限。
|
||||
|
||||
@@ -883,7 +848,7 @@ pip3.7 install torchvision --no-deps
|
||||
ll
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
3. 打开算子\*.py源码文件,增加日志,保存退出。
|
||||
|
||||
@@ -891,7 +856,7 @@ pip3.7 install torchvision --no-deps
|
||||
vi zn_2_nchw.py
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
上面例子只加了个标识,实际调测时,可以增加打印输入参数信息。
|
||||
|
||||
@@ -903,7 +868,7 @@ pip3.7 install torchvision --no-deps
|
||||
sudo chmod -w zn_2_nchw.py
|
||||
```
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
<h2 id="PyTorch编译失败-提示-error-ld-returned-1-exit-status.md">PyTorch编译失败,提示“error: ld returned 1 exit status”</h2>
|
||||
@@ -912,13 +877,13 @@ pip3.7 install torchvision --no-deps
|
||||
|
||||
PyTorch编译失败,提示“ error: ld returned 1 exit status”。
|
||||
|
||||

|
||||

|
||||
|
||||
## 可能原因<a name="zh-cn_topic_0000001125315885_zh-cn_topic_0175549220_section169499490501"></a>
|
||||
|
||||
通过日志分析,大概原因为XxxxKernelNpu.cpp中实现的适配函数,与PyTorch框架算子要求的分发实现接口参数不匹配。在上面的例子中,是“binary\_cross\_entropy\_npu”,打开对应的XxxxKernelNpu.cpp文件,找到相应的适配函数。
|
||||
|
||||

|
||||

|
||||
|
||||
可以看出实现中,最后一个参数是"int" ,与要求的“long”不匹配。
|
||||
|
||||
@@ -930,17 +895,17 @@ PyTorch编译失败,提示“ error: ld returned 1 exit status”。
|
||||
|
||||
## 现象描述<a name="zh-cn_topic_0000001125641113_zh-cn_topic_0175549220_section197270431505"></a>
|
||||
|
||||
PyTorch编译失败,提示“error: call of overload ....”
|
||||
PyTorch编译失败,提示“error: call of overload ....”。
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
## 可能原因<a name="zh-cn_topic_0000001125641113_zh-cn_topic_0175549220_section169499490501"></a>
|
||||
|
||||
通过日志分析,错误出在XxxxKernelNpu.cpp中30行位置,NPUAttrDesc的参数不合法。在上面的例子中,是“binary\_cross\_entropy\_attr”,打开对应的XxxxKernelNpu.cpp文件,找到相应的适配函数。
|
||||
|
||||

|
||||

|
||||
|
||||
可以看出实现中,NPUAttrDesc的入参,第二个参数是"int" ,与NPUAttrDesc定义不匹配。
|
||||
|
||||
@@ -959,7 +924,7 @@ PyTorch编译失败,提示“error: call of overload ....”
|
||||
|
||||
<h2 id="CMake安装方法.md">CMake安装方法</h2>
|
||||
|
||||
CMake版本升级为3.12.1的方法
|
||||
以CMake版本升级为3.12.1为例说明。
|
||||
|
||||
1. 获取Cmake软件包。
|
||||
|
||||
@@ -993,7 +958,7 @@ CMake版本升级为3.12.1的方法
|
||||
cmake --version
|
||||
```
|
||||
|
||||
如显示“cmake version 3.12.1”则表示安装成功。
|
||||
显示“cmake version 3.12.1”则表示安装成功。
|
||||
|
||||
|
||||
<h2 id="自定义算子导出方法.md">自定义算子导出方法</h2>
|
||||
@@ -1010,7 +975,7 @@ PyTorch训练模型中包含自定义算子,将自定义算子导出成onnx单
|
||||
|
||||
TBE算子导出有两种方式。
|
||||
|
||||
第一种方式。
|
||||
方式一:
|
||||
|
||||
1. 定义和注册算子
|
||||
|
||||
@@ -1077,7 +1042,7 @@ TBE算子导出有两种方式。
|
||||
```
|
||||
|
||||
|
||||
第二种方式。
|
||||
方式二:
|
||||
|
||||
1. 定义方法类
|
||||
|
||||
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 580 B |
|
After Width: | Height: | Size: 580 B |
|
After Width: | Height: | Size: 394 B |
|
After Width: | Height: | Size: 406 B |
|
After Width: | Height: | Size: 253 B |
|
After Width: | Height: | Size: 580 B |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 946 B After Width: | Height: | Size: 946 B |
|
Before Width: | Height: | Size: 356 B After Width: | Height: | Size: 356 B |
|
Before Width: | Height: | Size: 946 B After Width: | Height: | Size: 946 B |
|
Before Width: | Height: | Size: 356 B After Width: | Height: | Size: 356 B |
|
Before Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 580 B |
|
After Width: | Height: | Size: 580 B |
|
After Width: | Height: | Size: 394 B |
|
After Width: | Height: | Size: 406 B |
|
After Width: | Height: | Size: 253 B |
|
After Width: | Height: | Size: 580 B |
|
After Width: | Height: | Size: 580 B |
|
After Width: | Height: | Size: 580 B |
|
After Width: | Height: | Size: 394 B |
|
After Width: | Height: | Size: 406 B |
|
After Width: | Height: | Size: 253 B |
|
After Width: | Height: | Size: 580 B |
@@ -0,0 +1,48 @@
|
||||
From https://gitee.com/ascend/pytorch
|
||||
* branch master -> FETCH_HEAD
|
||||
Already up to date.
|
||||
From https://gitee.com/ascend/pytorch
|
||||
* branch master -> FETCH_HEAD
|
||||
Already up to date.
|
||||
From https://gitee.com/ascend/pytorch
|
||||
* branch master -> FETCH_HEAD
|
||||
Already up to date.
|
||||
From https://gitee.com/ascend/pytorch
|
||||
* branch master -> FETCH_HEAD
|
||||
Already up to date.
|
||||
From https://gitee.com/ascend/pytorch
|
||||
* branch master -> FETCH_HEAD
|
||||
Already up to date.
|
||||
From https://gitee.com/ascend/pytorch
|
||||
* branch master -> FETCH_HEAD
|
||||
Already up to date.
|
||||
From https://gitee.com/ascend/pytorch
|
||||
* branch master -> FETCH_HEAD
|
||||
Already up to date.
|
||||
From https://gitee.com/ascend/pytorch
|
||||
* branch master -> FETCH_HEAD
|
||||
Already up to date.
|
||||
From https://gitee.com/ascend/pytorch
|
||||
* branch master -> FETCH_HEAD
|
||||
Already up to date.
|
||||
From https://gitee.com/ascend/pytorch
|
||||
* branch master -> FETCH_HEAD
|
||||
Already up to date.
|
||||
From https://gitee.com/ascend/pytorch
|
||||
* branch master -> FETCH_HEAD
|
||||
Already up to date.
|
||||
From https://gitee.com/ascend/pytorch
|
||||
* branch master -> FETCH_HEAD
|
||||
Already up to date.
|
||||
From https://gitee.com/ascend/pytorch
|
||||
* branch master -> FETCH_HEAD
|
||||
Already up to date.
|
||||
From https://gitee.com/ascend/pytorch
|
||||
* branch master -> FETCH_HEAD
|
||||
Already up to date.
|
||||
From https://gitee.com/ascend/pytorch
|
||||
* branch master -> FETCH_HEAD
|
||||
Already up to date.
|
||||
From https://gitee.com/ascend/pytorch
|
||||
* branch master -> FETCH_HEAD
|
||||
Already up to date.
|
||||
@@ -1,3 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright (c) 2020, 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.
|
||||
|
||||
CUR_DIR=$(dirname $(readlink -f $0))
|
||||
ROOT_DIR=$CUR_DIR/..
|
||||
|
||||
@@ -1 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright (c) 2020, 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.
|
||||
|
||||
diff -Nur --exclude=.git* --exclude=.jenkins --exclude=android --exclude=OWNERS --exclude=third_party --exclude=README* -Nur pytorch-v1.5.0 pytorch-develop >npu.patch
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright (c) 2020, 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.
|
||||
|
||||
CUR_DIR=$(dirname $(readlink -f $0))
|
||||
ROOT_DIR=$CUR_DIR/..
|
||||
@@ -52,9 +68,6 @@ mv $SRC_DIR/torch/lib/c10d/ProcessGroupHCCL* src/torch/lib/c10d
|
||||
mv $SRC_DIR/env.sh src
|
||||
mv $SRC_DIR/build.sh src # where
|
||||
|
||||
## fuzzy compile
|
||||
mv $SRC_DIR/aten/src/ATen/native/GlobalStep* src/aten/src/ATen/native
|
||||
|
||||
## dump util
|
||||
mv $SRC_DIR/aten/src/ATen/utils src/aten/src/ATen
|
||||
mv $SRC_DIR/torch/utils/dumper.py src/torch/utils
|
||||
|
||||
@@ -980,6 +980,8 @@
|
||||
NPU: conv_transpose2d_npu_
|
||||
|
||||
- func: conv_transpose3d.input(Tensor input, Tensor weight, Tensor? bias=None, int[3] stride=1, int[3] padding=0, int[3] output_padding=0, int groups=1, int[3] dilation=1) -> Tensor
|
||||
npu_dispatch:
|
||||
NPU: conv_transpose3d_npu_
|
||||
|
||||
- func: copy_(Tensor(a!) self, Tensor src, bool non_blocking=False) -> Tensor(a!)
|
||||
manual_kernel_registration: True
|
||||
@@ -1112,11 +1114,19 @@
|
||||
|
||||
- func: npu_conv_transpose2d(Tensor input, Tensor weight, Tensor? bias, int[] padding, int[] output_padding, int[] stride, int[] dilation, int groups) -> Tensor
|
||||
npu_dispatch_only:
|
||||
NPU: convolution_transpose_npu
|
||||
NPU: conv_transpose2d_npu
|
||||
|
||||
- func: npu_convolution_transpose_backward(Tensor input, Tensor grad_output, Tensor weight, int[] padding, int[] output_padding, int[] stride, int[] dilation, int groups, bool[3] output_mask) -> (Tensor, Tensor, Tensor)
|
||||
npu_dispatch_only:
|
||||
NPU: convolution_transpose_backward_npu
|
||||
NPU: npu_convolution_transpose_backward
|
||||
|
||||
- func: npu_conv_transpose2d_backward(Tensor input, Tensor grad_output, Tensor weight, int[] padding, int[] output_padding, int[] stride, int[] dilation, int groups, bool[3] output_mask) -> (Tensor, Tensor, Tensor)
|
||||
npu_dispatch_only:
|
||||
NPU: conv_transpose2d_backward_npu
|
||||
|
||||
- func: npu_conv_transpose3d_backward(Tensor input, Tensor grad_output, Tensor weight, int[] padding, int[] output_padding, int[] stride, int[] dilation, int groups, bool[3] output_mask) -> (Tensor, Tensor, Tensor)
|
||||
npu_dispatch_only:
|
||||
NPU: conv_transpose3d_backward_npu
|
||||
|
||||
- func: npu_convolution(Tensor input, Tensor weight, Tensor? bias, int[] stride, int[] padding, int[] dilation, int groups) -> Tensor
|
||||
npu_dispatch_only:
|
||||
@@ -1126,6 +1136,10 @@
|
||||
npu_dispatch_only:
|
||||
NPU: npu_convolution_backward
|
||||
|
||||
- func: npu_convolution_double_backward(Tensor? ggI, Tensor? ggW, Tensor? ggb, Tensor input, Tensor gO, Tensor weight, int[] stride, int[] padding, int[] dilation, int groups, bool[3] output_mask) -> (Tensor, Tensor, Tensor)
|
||||
npu_dispatch_only:
|
||||
NPU: npu_convolution_double_backward
|
||||
|
||||
- func: npu_conv2d(Tensor input, Tensor weight, Tensor? bias, int[] stride, int[] padding, int[] dilation, int groups) -> Tensor
|
||||
npu_dispatch_only:
|
||||
NPU: conv2d_npu
|
||||
@@ -1179,34 +1193,30 @@
|
||||
dispatch:
|
||||
CPU: cummax_helper_cpu
|
||||
CUDA: cummax_helper_cuda
|
||||
npu_dispatch:
|
||||
NPU: cummax_helper_npu
|
||||
|
||||
- func: cummin(Tensor self, int dim) -> (Tensor values, Tensor indices)
|
||||
supports_named_tensor: True
|
||||
variants: function, method
|
||||
npu_dispatch:
|
||||
NPU: cummin_npu
|
||||
|
||||
- func: cummin.out(Tensor self, int dim, *, Tensor(a!) values, Tensor(b!) indices) -> (Tensor(a!) values, Tensor(b!) indices)
|
||||
supports_named_tensor: True
|
||||
npu_dispatch:
|
||||
NPU: cummin_out_npu
|
||||
|
||||
- func: cummin.dimname(Tensor self, Dimname dim) -> (Tensor values, Tensor indices)
|
||||
supports_named_tensor: True
|
||||
variants: function, method
|
||||
npu_dispatch:
|
||||
NPU: cummin_npu
|
||||
|
||||
- func: cummin.dimname_out(Tensor self, Dimname dim, *, Tensor(a!) values, Tensor(b!) indices) -> (Tensor(a!) values, Tensor(b!) indices)
|
||||
supports_named_tensor: True
|
||||
npu_dispatch:
|
||||
NPU: cummin_out_npu
|
||||
|
||||
- func: _cummin_helper(Tensor self, Tensor(a!) values, Tensor(b!) indices, int dim) -> ()
|
||||
variants: function
|
||||
dispatch:
|
||||
CPU: cummin_helper_cpu
|
||||
CUDA: cummin_helper_cuda
|
||||
npu_dispatch:
|
||||
NPU: cummin_helper_npu
|
||||
|
||||
- func: cumprod(Tensor self, int dim, *, ScalarType? dtype=None) -> Tensor
|
||||
supports_named_tensor: True
|
||||
@@ -1508,6 +1518,8 @@
|
||||
use_c10_dispatcher: full
|
||||
supports_named_tensor: True
|
||||
variants: function, method
|
||||
npu_dispatch:
|
||||
NPU: erfc_npu
|
||||
|
||||
- func: erfc_(Tensor(a!) self) -> Tensor(a!)
|
||||
supports_named_tensor: True
|
||||
@@ -1515,12 +1527,16 @@
|
||||
dispatch:
|
||||
CPU: _erfc__cpu
|
||||
CUDA: _erfc__cuda
|
||||
npu_dispatch:
|
||||
NPU: erfc_npu_
|
||||
|
||||
- func: erfc.out(Tensor self, *, Tensor(a!) out) -> Tensor(a!)
|
||||
supports_named_tensor: True
|
||||
dispatch:
|
||||
CPU: _erfc_out_cpu
|
||||
CUDA: _erfc_out_cuda
|
||||
npu_dispatch:
|
||||
NPU: erfc_out_npu
|
||||
|
||||
- func: exp(Tensor self) -> Tensor
|
||||
use_c10_dispatcher: full
|
||||
@@ -5154,6 +5170,8 @@
|
||||
dispatch:
|
||||
CPU: __lshift__
|
||||
CUDA: __lshift__
|
||||
npu_dispatch:
|
||||
NPU: __lshift___npu
|
||||
|
||||
- func: __lshift__.Tensor(Tensor self, Tensor other) -> Tensor
|
||||
use_c10_dispatcher: full
|
||||
@@ -5161,18 +5179,24 @@
|
||||
dispatch:
|
||||
CPU: __lshift__
|
||||
CUDA: __lshift__
|
||||
npu_dispatch:
|
||||
NPU: __lshift___npu
|
||||
|
||||
- func: __ilshift__.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
|
||||
variants: method
|
||||
dispatch:
|
||||
CPU: __ilshift__
|
||||
CUDA: __ilshift__
|
||||
npu_dispatch:
|
||||
NPU: __iLshift___npu
|
||||
|
||||
- func: __ilshift__.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)
|
||||
variants: method
|
||||
dispatch:
|
||||
CPU: __ilshift__
|
||||
CUDA: __ilshift__
|
||||
npu_dispatch:
|
||||
NPU: __iLshift___npu
|
||||
|
||||
- func: __rshift__.Scalar(Tensor self, Scalar other) -> Tensor
|
||||
use_c10_dispatcher: full
|
||||
@@ -5180,6 +5204,8 @@
|
||||
dispatch:
|
||||
CPU: __rshift__
|
||||
CUDA: __rshift__
|
||||
npu_dispatch:
|
||||
NPU: __rshift___npu
|
||||
|
||||
- func: __rshift__.Tensor(Tensor self, Tensor other) -> Tensor
|
||||
use_c10_dispatcher: full
|
||||
@@ -5187,18 +5213,24 @@
|
||||
dispatch:
|
||||
CPU: __rshift__
|
||||
CUDA: __rshift__
|
||||
npu_dispatch:
|
||||
NPU: __rshift___npu
|
||||
|
||||
- func: __irshift__.Scalar(Tensor(a!) self, Scalar other) -> Tensor(a!)
|
||||
variants: method
|
||||
dispatch:
|
||||
CPU: __irshift__
|
||||
CUDA: __irshift__
|
||||
npu_dispatch:
|
||||
NPU: __iRshift___npu
|
||||
|
||||
- func: __irshift__.Tensor(Tensor(a!) self, Tensor other) -> Tensor(a!)
|
||||
variants: method
|
||||
dispatch:
|
||||
CPU: __irshift__
|
||||
CUDA: __irshift__
|
||||
npu_dispatch:
|
||||
NPU: __iRshift___npu
|
||||
|
||||
- func: lgamma_(Tensor(a!) self) -> Tensor(a!)
|
||||
supports_named_tensor: True
|
||||
@@ -5442,11 +5474,15 @@
|
||||
dispatch:
|
||||
CPU: tril_indices_cpu
|
||||
CUDA: tril_indices_cuda
|
||||
npu_dispatch:
|
||||
NPU: tril_indices_npu
|
||||
|
||||
- func: triu_indices(int row, int col, int offset=0, *, ScalarType? dtype=long, Layout? layout=None, Device? device=None, bool? pin_memory=None) -> Tensor
|
||||
dispatch:
|
||||
CPU: triu_indices_cpu
|
||||
CUDA: triu_indices_cuda
|
||||
npu_dispatch:
|
||||
NPU: triu_indices_npu
|
||||
|
||||
- func: trace(Tensor self) -> Tensor
|
||||
use_c10_dispatcher: full
|
||||
@@ -5856,6 +5892,8 @@
|
||||
dispatch:
|
||||
CPU: _triangular_solve_helper_cpu
|
||||
CUDA: _triangular_solve_helper_cuda
|
||||
npu_dispatch:
|
||||
NPU: _triangular_solve_helper_npu
|
||||
|
||||
- func: symeig.e(Tensor self, bool eigenvectors=False, bool upper=True, *, Tensor(a!) e, Tensor(b!) V) -> (Tensor(a!) eigenvalues, Tensor(b!) eigenvectors)
|
||||
|
||||
@@ -5867,6 +5905,8 @@
|
||||
dispatch:
|
||||
CPU: _symeig_helper_cpu
|
||||
CUDA: _symeig_helper_cuda
|
||||
npu_dispatch:
|
||||
NPU: _symeig_helper_npu
|
||||
|
||||
- func: eig.e(Tensor self, bool eigenvectors=False, *, Tensor(a!) e, Tensor(b!) v) -> (Tensor(a!) eigenvalues, Tensor(b!) eigenvectors)
|
||||
dispatch:
|
||||
@@ -5889,6 +5929,8 @@
|
||||
dispatch:
|
||||
CPU: _svd_helper_cpu
|
||||
CUDA: _svd_helper_cuda
|
||||
npu_dispatch:
|
||||
NPU: _svd_helper_npu
|
||||
|
||||
- func: cholesky.out(Tensor self, bool upper=False, *, Tensor(a!) out) -> Tensor(a!)
|
||||
|
||||
@@ -7118,22 +7160,30 @@
|
||||
dispatch:
|
||||
CPU: rrelu_with_noise_out_cpu
|
||||
CUDA: legacy::cuda::_thnn_rrelu_with_noise_forward_out
|
||||
npu_dispatch:
|
||||
NPU: rrelu_with_noise_out_npu
|
||||
|
||||
- func: rrelu_with_noise(Tensor self, Tensor noise, Scalar lower=0.125, Scalar upper=0.3333333333333333, bool training=False, Generator? generator=None) -> Tensor
|
||||
python_module: nn
|
||||
dispatch:
|
||||
CPU: rrelu_with_noise_cpu
|
||||
CUDA: legacy::cuda::_thnn_rrelu_with_noise_forward
|
||||
npu_dispatch:
|
||||
NPU: rrelu_with_noise_npu
|
||||
|
||||
- func: rrelu_with_noise_backward(Tensor grad_output, Tensor self, Tensor noise, Scalar lower, Scalar upper, bool training, bool self_is_result) -> Tensor
|
||||
use_c10_dispatcher: full
|
||||
python_module: nn
|
||||
npu_dispatch:
|
||||
NPU: rrelu_with_noise_backward_npu
|
||||
|
||||
- func: rrelu_with_noise_(Tensor(a!) self, Tensor noise, Scalar lower=0.125, Scalar upper=0.3333333333333333, bool training=False, Generator? generator=None) -> Tensor(a!)
|
||||
python_module: nn
|
||||
dispatch:
|
||||
CPU: rrelu_with_noise_cpu_
|
||||
CUDA: legacy::cuda::_thnn_rrelu_with_noise_forward_
|
||||
npu_dispatch:
|
||||
NPU: rrelu_with_noise_npu_
|
||||
|
||||
- func: softplus.out(Tensor self, Scalar beta=1, Scalar threshold=20, *, Tensor(a!) out) -> Tensor(a!)
|
||||
python_module: nn
|
||||
@@ -8090,19 +8140,27 @@
|
||||
|
||||
- func: slow_conv3d.out(Tensor self, Tensor weight, int[3] kernel_size, Tensor? bias=None, int[3] stride=1, int[3] padding=0, *, Tensor(a!) out) -> Tensor(a!)
|
||||
python_module: nn
|
||||
npu_dispatch:
|
||||
NPU: slow_conv3d_out_npu
|
||||
|
||||
- func: slow_conv3d(Tensor self, Tensor weight, int[3] kernel_size, Tensor? bias=None, int[3] stride=1, int[3] padding=0) -> Tensor
|
||||
python_module: nn
|
||||
npu_dispatch:
|
||||
NPU: slow_conv3d_npu
|
||||
|
||||
- func: slow_conv3d_forward.output(Tensor self, Tensor weight, int[3] kernel_size, Tensor? bias, int[3] stride, int[3] padding, *, Tensor(a!) output, Tensor(b!) finput, Tensor(c!) fgrad_input) -> (Tensor(a!), Tensor(b!), Tensor(c!))
|
||||
python_module: nn
|
||||
dispatch:
|
||||
CPU: slow_conv3d_forward_out_cpu
|
||||
npu_dispatch:
|
||||
NPU: slow_conv3d_forward_out_npu
|
||||
|
||||
- func: slow_conv3d_forward(Tensor self, Tensor weight, int[3] kernel_size, Tensor? bias, int[3] stride, int[3] padding) -> (Tensor output, Tensor finput, Tensor fgrad_input)
|
||||
python_module: nn
|
||||
dispatch:
|
||||
CPU: slow_conv3d_forward_cpu
|
||||
npu_dispatch:
|
||||
NPU: slow_conv3d_forward_npu
|
||||
|
||||
- func: slow_conv3d_backward.grad_input(Tensor grad_output, Tensor self, Tensor weight, int[3] kernel_size, int[3] stride, int[3] padding, Tensor finput, Tensor fgrad_input, *, Tensor(a!)? grad_input, Tensor(b!)? grad_weight, Tensor(c!)? grad_bias) -> (Tensor(a!), Tensor(b!), Tensor(c!))
|
||||
python_module: nn
|
||||
@@ -8414,12 +8472,12 @@
|
||||
npu_dispatch_only:
|
||||
NPU: dropout_backward_npu
|
||||
|
||||
- func: npu_indexing(Tensor self, int[] begin, int[] end, int[] strides) -> Tensor
|
||||
- func: npu_indexing(Tensor self, int[] begin, int[] end, int[] strides, int begin_mask=0, int end_mask=0, int ellipsis_mask=0, int new_axis_mask=0, int shrink_axis_mask=0) -> Tensor
|
||||
variants: function, method
|
||||
npu_dispatch_only:
|
||||
NPU: indexing_npu
|
||||
|
||||
- func: npu_indexing.out(Tensor self, int[] begin, int[] end, int[] strides, *, Tensor(a!) out) -> Tensor(a!)
|
||||
- func: npu_indexing.out(Tensor self, int[] begin, int[] end, int[] strides, int begin_mask=0, int end_mask=0, int ellipsis_mask=0, int new_axis_mask=0, int shrink_axis_mask=0, *, Tensor(a!) out) -> Tensor(a!)
|
||||
npu_dispatch_only:
|
||||
NPU: indexing_out_npu
|
||||
|
||||
@@ -8548,4 +8606,12 @@
|
||||
|
||||
- func: npu_bert_apply_adam(Tensor(a!) var, Tensor(b!) m, Tensor(c!) v, Scalar lr, Scalar beta1, Scalar beta2, Scalar epsilon, Tensor grad, Scalar max_grad_norm, Scalar global_grad_norm, Scalar weight_decay) -> (Tensor(a!), Tensor(b!), Tensor(c!))
|
||||
npu_dispatch_only:
|
||||
NPU: bert_apply_adam_npu
|
||||
NPU: bert_apply_adam_npu
|
||||
|
||||
- func: npu_giou(Tensor self, Tensor gtboxes, bool trans=False, bool is_cross=False, int mode=0) -> Tensor
|
||||
npu_dispatch_only:
|
||||
NPU: giou_npu
|
||||
|
||||
- func: npu_giou_backward(Tensor grad, Tensor bboxes, Tensor gtboxes, bool trans=False, bool is_cross=False, int mode=0) -> (Tensor, Tensor)
|
||||
npu_dispatch_only:
|
||||
NPU: giou_backward_npu
|
||||
@@ -30,7 +30,7 @@ inline Tensor& any_out_npu_nocheck(
|
||||
OpCommand cmd;
|
||||
cmd.Name("ReduceAny")
|
||||
.Input(self)
|
||||
.Input(dimList, at::kInt)
|
||||
.Input(dimList)
|
||||
.Output(result)
|
||||
.Attr("keep_dims", keepdim)
|
||||
.Run();
|
||||
|
||||
@@ -32,10 +32,10 @@ Tensor argmin_npu(const Tensor& self, optional<int64_t> dim, bool keepdim) {
|
||||
auto outputSize = reduce_ops_npu_output_size(input, realDim, realKeepDim);
|
||||
|
||||
// construct the output tensor of the NPU
|
||||
Tensor result = OpPreparation::ApplyTensor(
|
||||
Tensor result = OpPreparation::ApplyTensorWithFormat(
|
||||
outputSize,
|
||||
self.options().dtype(at::kInt),
|
||||
self);
|
||||
ACL_FORMAT_ND);
|
||||
SmallVector<int64_t, N> DimVec = {realDim};
|
||||
// calculate the output result of the NPU
|
||||
OpCommand cmd;
|
||||
|
||||
@@ -27,10 +27,13 @@ Tensor& bmm_out_npu(Tensor& result, const Tensor& self, const Tensor& mat2) {
|
||||
|
||||
Tensor contiguousSelf = self;
|
||||
Tensor contiguousMat2 = mat2;
|
||||
if(! CalcuOpUtil::is_transpose_last_two_dims(self)){
|
||||
bool isSelfT = CalcuOpUtil::is_transpose_last_two_dims(self);
|
||||
bool isMat2T = CalcuOpUtil::is_transpose_last_two_dims(mat2);
|
||||
|
||||
if(!isSelfT){
|
||||
contiguousSelf = NpuUtils::format_contiguous_add_copy_optimize(self);
|
||||
}
|
||||
if(! CalcuOpUtil::is_transpose_last_two_dims(mat2)){
|
||||
if(!isMat2T){
|
||||
contiguousMat2 = NpuUtils::format_contiguous_add_copy_optimize(mat2);
|
||||
}
|
||||
|
||||
@@ -43,9 +46,6 @@ Tensor& bmm_out_npu(Tensor& result, const Tensor& self, const Tensor& mat2) {
|
||||
return std::tie(pass, contiguousMat2);
|
||||
};
|
||||
|
||||
bool isSelfT = CalcuOpUtil::is_transpose_last_two_dims(self);
|
||||
bool isMat2T = CalcuOpUtil::is_transpose_last_two_dims(mat2);
|
||||
|
||||
// executing the NPU operator
|
||||
OpCommand cmd;
|
||||
cmd.Name("BatchMatMul")
|
||||
|
||||
@@ -57,7 +57,7 @@ Tensor& dtype_cast_npu_(Tensor& self, const Tensor& src) {
|
||||
}
|
||||
|
||||
if (!NpuUtils::check_match(&self)) {
|
||||
Tensor contiguousSelf = NpuUtils::format_contiguous(self);
|
||||
Tensor contiguousSelf = OpPreparation::ApplyTensor(self.sizes(), self.options().dtype(self.dtype()), self);
|
||||
Tensor result = cast_nocheck(contiguousSelf, src);
|
||||
NpuUtils::format_fresh_view(self, result);
|
||||
} else {
|
||||
|
||||
@@ -154,6 +154,20 @@ Tensor& _cat_out_npu(Tensor& result, TensorList tensors, int64_t dim) {
|
||||
}
|
||||
|
||||
Tensor& cat_out_npu(Tensor& result, TensorList tensors, int64_t dim) {
|
||||
SmallVector<Tensor, N> inputTensors = cat_dest_tensor_list(tensors);
|
||||
|
||||
int64_t dim_post_expr = 0;
|
||||
if (inputTensors.size() > 0) {
|
||||
dim_post_expr = inputTensors[0].dim();
|
||||
}
|
||||
dim = CalcuOpUtil::make_wrap_dim(dim, dim_post_expr);
|
||||
auto outputSize = cat_npu_output_size(inputTensors, dim);
|
||||
OpPreparation::CheckOut(
|
||||
{tensors[0]},
|
||||
result,
|
||||
ACL_FORMAT_ND,
|
||||
tensors[0].scalar_type(),
|
||||
outputSize);
|
||||
return at::_cat_out(result, tensors, dim);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,13 +88,21 @@ Tensor constant_pad_nd_npu(const Tensor& self, IntArrayRef pad, Scalar value){
|
||||
}
|
||||
|
||||
if (is_backward(pad)) {
|
||||
TORCH_CHECK(self.dim() == 4, "only support 4D now, but self.dim is",self.dim());
|
||||
TORCH_CHECK(pad.size() == 4, "Length of pad must is 4 now, but pad.size() is", pad.size());
|
||||
TORCH_CHECK(self.dim() == 4 || self.dim() == 5,
|
||||
"Only support 4D and 5D now, but self.dim is",self.dim());
|
||||
TORCH_CHECK(pad.size() == 4 || pad.size() == 6,
|
||||
"Length of pad must is 4 or 6 now, but pad.size() is", pad.size());
|
||||
|
||||
SmallVector<int64_t, SIZE> begin_list = {0, 0, -pad[2], -pad[0]};
|
||||
SmallVector<int64_t, SIZE> end_list = {self.size(0), self.size(1), self.size(-2) + pad[3], self.size(-1) + pad[1]};
|
||||
SmallVector<int64_t, SIZE> strides = {1, 1, 1, 1};
|
||||
|
||||
if (self.dim() == 5) {
|
||||
begin_list = {0, 0, -pad[4], -pad[2], -pad[0]};
|
||||
end_list = {self.size(0), self.size(1), self.size(-3) + pad[5], self.size(-2) + pad[3], self.size(-1) + pad[1]};
|
||||
strides = {1, 1, 1, 1, 1};
|
||||
}
|
||||
|
||||
return at::npu_indexing(self, begin_list, end_list, strides);
|
||||
}
|
||||
|
||||
@@ -109,4 +117,4 @@ Tensor constant_pad_nd_npu(const Tensor& self, IntArrayRef pad, Scalar value){
|
||||
}
|
||||
|
||||
} // namespace native
|
||||
} // namespace at
|
||||
} // namespace at
|
||||
|
||||
@@ -58,7 +58,7 @@ Tensor ctc_loss_backward_npu(
|
||||
auto inputLengthsTensor = at::tensor(inputLengths, targetsCast.options().dtype(at::kInt));
|
||||
auto targetLengthsTensor = at::tensor(targetLengths, targetsCast.options().dtype(at::kInt));
|
||||
|
||||
auto outputSize = {logProbs.size(1), logProbs.size(0), logProbs.size(2)};
|
||||
auto outputSize = input_same_output_size(logProbs);
|
||||
|
||||
// construct the output tensor of the NPU
|
||||
Tensor grad = OpPreparation::ApplyTensor(logProbsNeed, outputSize);
|
||||
@@ -81,8 +81,7 @@ Tensor ctc_loss_backward_npu(
|
||||
grad = grad.to(ScalarType::Half);
|
||||
}
|
||||
|
||||
//return grad;
|
||||
return grad.permute({1,0,2});
|
||||
return grad;
|
||||
}
|
||||
} // namespace native
|
||||
} // namespace at
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
// 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.
|
||||
|
||||
#include "ATen/native/npu/utils/OpAdapter.h"
|
||||
|
||||
namespace at {
|
||||
namespace native {
|
||||
using namespace at::native::npu;
|
||||
|
||||
void cummax_out_npu_nocheck (
|
||||
Tensor& values,
|
||||
Tensor& indices,
|
||||
const Tensor& self,
|
||||
int64_t dim) {
|
||||
OpCommand cmd;
|
||||
cmd.Name("Cummax")
|
||||
.Input(self)
|
||||
.Output(values)
|
||||
.Output(indices)
|
||||
.Attr("dim", dim)
|
||||
.Run();
|
||||
}
|
||||
|
||||
void cummax_helper_npu(const Tensor& self, Tensor& values, Tensor& indices, int64_t dim) {
|
||||
Tensor valuesTemp = OpPreparation::ApplyTensor(self);
|
||||
Tensor indicesTemp = OpPreparation::ApplyTensor(self, self.options().dtype(kLong));
|
||||
|
||||
cummax_out_npu_nocheck(valuesTemp, indicesTemp, self, dim);
|
||||
|
||||
values.copy_(valuesTemp);
|
||||
indices.copy_(indicesTemp);
|
||||
}
|
||||
|
||||
}}
|
||||
@@ -14,125 +14,64 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "ATen/native/npu/utils/OpAdapter.h"
|
||||
#include "ATen/native/npu/utils/CalcuOpUtil.h"
|
||||
#include "ATen/native/npu/utils/KernelNpuOutputSize.h"
|
||||
#include "ATen/native/npu/utils/NpuUtils.h"
|
||||
|
||||
namespace at {
|
||||
namespace native {
|
||||
using namespace at::native::npu;
|
||||
|
||||
SmallVector<NPUTensorDesc, N> cummin_npu_input(
|
||||
const SmallVector<Tensor, N>& inputTensor) {
|
||||
return CalcuOpUtil::create_npu_input_tensor_desc(inputTensor);
|
||||
void cummin_out_npu_nocheck (
|
||||
Tensor& values,
|
||||
Tensor& indices,
|
||||
const Tensor& self,
|
||||
int64_t dim) {
|
||||
OpCommand cmd;
|
||||
cmd.Name("Cummin")
|
||||
.Input(self)
|
||||
.Output(values)
|
||||
.Output(indices)
|
||||
.Attr("dim", dim)
|
||||
.Run();
|
||||
}
|
||||
|
||||
SmallVector<NPUTensorDesc, N> cummin_npu_output(
|
||||
const SmallVector<Tensor, N>& outputTensor) {
|
||||
return CalcuOpUtil::create_npu_output_tensor_desc(outputTensor);
|
||||
}
|
||||
|
||||
SmallVector<NPUAttrDesc, N> cummin_npu_attr(int64_t dim) {
|
||||
NPUAttrDesc npuAttrDim = NPUAttrDesc("dim", dim);
|
||||
SmallVector<NPUAttrDesc, N> attrs = {npuAttrDim};
|
||||
return attrs;
|
||||
}
|
||||
|
||||
tuple<Tensor&, Tensor&> cummin_out_npu_no_transpose (
|
||||
Tensor& values,
|
||||
Tensor& indices,
|
||||
const Tensor& self,
|
||||
int64_t dim) {
|
||||
// constructs the input and output NPUTensorDesc
|
||||
auto inputs = cummin_npu_input({self});
|
||||
auto outputs = cummin_npu_output({values, indices});
|
||||
// constructs the attr of the NPUAttrDesc
|
||||
auto attrs = cummin_npu_attr(dim);
|
||||
|
||||
// executing the NPU operator
|
||||
CalcuOpUtil::execute_npu_operate("Cummin", inputs, outputs, attrs);
|
||||
return std::tie(values, indices);
|
||||
}
|
||||
|
||||
tuple<Tensor&, Tensor&> cummin_out_npu (
|
||||
Tensor& values,
|
||||
Tensor& indices,
|
||||
const Tensor& self,
|
||||
int64_t dim) {
|
||||
auto indices_dtype = indices.scalar_type();
|
||||
if(indices_dtype != c10::ScalarType::Long) {
|
||||
AT_ERROR("indices must be int64 type.");
|
||||
}
|
||||
Tensor indices_int32 = indices.to(at::kInt);
|
||||
const auto names = self.names();
|
||||
Tensor self_no_name = self.rename(nullopt);
|
||||
dim = CalcuOpUtil::make_wrap_dim(dim, self.dim());
|
||||
int64_t firstDim = CalcuOpUtil::make_wrap_dim(0, self.dim());
|
||||
if (dim != firstDim) {
|
||||
SmallVector<int64_t, SHAPE_SIZE> perm;
|
||||
for (int64_t i = 0; i < self.dim(); i++) {
|
||||
perm.emplace_back(i);
|
||||
}
|
||||
std::swap(perm[dim], perm[firstDim]);
|
||||
// construct the output tensor of the NPU
|
||||
Tensor transposeSelf = at::npu_transpose(self_no_name, perm);
|
||||
auto outputSize = transpose_npu_output_size(values, perm);
|
||||
Tensor transposeValue = at::empty_with_format(
|
||||
outputSize,
|
||||
values.options(),
|
||||
CalcuOpUtil::get_tensor_npu_format(values));
|
||||
Tensor transposeIndices = at::empty_with_format(
|
||||
outputSize,
|
||||
indices_int32.options(),
|
||||
CalcuOpUtil::get_tensor_npu_format(indices_int32));
|
||||
cummin_out_npu_no_transpose(
|
||||
transposeValue,
|
||||
transposeIndices,
|
||||
transposeSelf,
|
||||
firstDim);
|
||||
at::npu_transpose_out(values, transposeValue, perm);
|
||||
at::npu_transpose_out(indices_int32, transposeIndices, perm);
|
||||
void cummin_helper_npu(const Tensor& self, Tensor& values, Tensor& indices, int64_t dim) {
|
||||
//process aicpu
|
||||
if(self.scalar_type() == ScalarType::Long){
|
||||
Tensor valuesTemp = OpPreparation::ApplyTensor(self);
|
||||
Tensor indicesTemp = OpPreparation::ApplyTensor(self, self.options().dtype(kLong));
|
||||
cummin_out_npu_nocheck(valuesTemp, indicesTemp, self, dim);
|
||||
values.copy_(valuesTemp);
|
||||
indices.copy_(indicesTemp);
|
||||
} else {
|
||||
cummin_out_npu_no_transpose(
|
||||
values, indices_int32, self, firstDim);
|
||||
}
|
||||
indices.npu_dtype_cast_(indices_int32);
|
||||
values.rename_(names);
|
||||
indices.rename_(names);
|
||||
return std::tie(values, indices);
|
||||
//process aicore
|
||||
int64_t firstDim = CalcuOpUtil::make_wrap_dim(0, self.dim());
|
||||
if (dim != firstDim) {
|
||||
SmallVector<int64_t, SHAPE_SIZE> perm;
|
||||
for (int64_t i = 0; i < self.dim(); i++) {
|
||||
perm.emplace_back(i);
|
||||
}
|
||||
std::swap(perm[dim], perm[firstDim]);
|
||||
|
||||
Tensor transposeSelf = at::npu_transpose(self, perm);
|
||||
auto outputSize = transpose_npu_output_size(values, perm);
|
||||
Tensor transposeValue = OpPreparation::ApplyTensor(self, outputSize);
|
||||
Tensor transposeIndices = OpPreparation::ApplyTensor(outputSize, self.options().dtype(kInt), self);
|
||||
|
||||
cummin_out_npu_nocheck(transposeValue, transposeIndices, transposeSelf, firstDim);
|
||||
//Indices must to be long
|
||||
transposeIndices = transposeIndices.to(kLong);
|
||||
at::npu_transpose_out(values, transposeValue, perm);
|
||||
at::npu_transpose_out(indices, transposeIndices, perm);
|
||||
} else {
|
||||
Tensor valuesTemp = OpPreparation::ApplyTensor(self);
|
||||
Tensor indicesTemp = OpPreparation::ApplyTensor(self, self.options().dtype(kInt));
|
||||
cummin_out_npu_nocheck(valuesTemp, indicesTemp, self, dim);
|
||||
indicesTemp = indicesTemp.to(kLong);
|
||||
values.copy_(valuesTemp);
|
||||
indices.copy_(indicesTemp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tuple<Tensor, Tensor> cummin_npu(const Tensor& self, int64_t dim) {
|
||||
// calculate the output size
|
||||
auto outputSize = input_same_output_size(self);
|
||||
|
||||
Tensor values = at::empty_with_format(
|
||||
outputSize,
|
||||
self.options(),
|
||||
CalcuOpUtil::get_tensor_npu_format(self));
|
||||
Tensor indices = at::empty_with_format(
|
||||
outputSize,
|
||||
self.options().dtype(kLong),
|
||||
CalcuOpUtil::get_tensor_npu_format(self));
|
||||
|
||||
cummin_out_npu(values, indices, self, dim);
|
||||
|
||||
return std::tie(values, indices);
|
||||
}
|
||||
|
||||
tuple<Tensor&, Tensor&> cummin_out_npu(
|
||||
Tensor& values,
|
||||
Tensor& indices,
|
||||
const Tensor& self,
|
||||
Dimname dim) {
|
||||
// dimname_to_position(self, dim) : Dimname --> Int
|
||||
return cummin_out_npu(
|
||||
values, indices, self, dimname_to_position(self, dim));
|
||||
}
|
||||
|
||||
tuple<Tensor, Tensor> cummin_npu(const Tensor& self, Dimname dim) {
|
||||
return cummin_npu(self, dimname_to_position(self, dim));
|
||||
}
|
||||
|
||||
} // namespace native
|
||||
} // namespace at
|
||||
}}
|
||||
|
||||
@@ -20,12 +20,19 @@ using namespace at::native::npu;
|
||||
|
||||
Tensor& _cumsum_out_npu(Tensor& result, const Tensor& self, int64_t dim) {
|
||||
OpCommand cmd;
|
||||
if (!c10::npu::OptionsManager::CheckDynamicEnable()){
|
||||
SmallVector<int64_t, N> dimvec = {dim};
|
||||
if (!c10::npu::OptionsManager::CheckDynamicEnable()) {
|
||||
// if dim = 0, performance in Aicpu is better than Aicore
|
||||
// if dim > INT32_MAX, we should use long to store dim for ensuring function correctness.
|
||||
// use host memory instead of scalar to improve delivery performance
|
||||
Scalar dimScalar(dim);
|
||||
cmd.Name("Cumsum")
|
||||
.Input(self)
|
||||
.Input(dimvec, at::kInt)
|
||||
.Output(result)
|
||||
.Input(self);
|
||||
if (dim == 0 || dim > INT32_MAX) {
|
||||
cmd.Input(dimScalar, at::kLong, MemoryType::MEMORY_HOST);
|
||||
} else {
|
||||
cmd.Input(dimScalar, at::kInt, MemoryType::MEMORY_HOST);
|
||||
}
|
||||
cmd.Output(result)
|
||||
.Run();
|
||||
} else {
|
||||
cmd.Name("CumsumD")
|
||||
@@ -39,16 +46,12 @@ Tensor& _cumsum_out_npu(Tensor& result, const Tensor& self, int64_t dim) {
|
||||
}
|
||||
|
||||
Tensor _cumsum_npu(const Tensor& self, int64_t dim) {
|
||||
Tensor input = self;
|
||||
if(self.scalar_type() == ScalarType::Long){
|
||||
input = self.to(ScalarType::Int);
|
||||
}
|
||||
// calculate the output size
|
||||
auto outputSize = input_same_output_size(self);
|
||||
// construct the output tensor of the NPU
|
||||
Tensor result = OpPreparation::ApplyTensor(input, outputSize);
|
||||
Tensor result = OpPreparation::ApplyTensor(self, outputSize);
|
||||
// calculate the output result of the NPU
|
||||
_cumsum_out_npu(result, input, dim);
|
||||
_cumsum_out_npu(result, self, dim);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// Copyright (c) 2020 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.
|
||||
#include "ATen/native/npu/utils/CalcuOpUtil.h"
|
||||
#include "ATen/native/npu/utils/KernelNpuOutputSize.h"
|
||||
#include "ATen/native/npu/utils/NpuUtils.h"
|
||||
|
||||
@@ -44,12 +44,9 @@ Tensor dropout_gen_mask(const Tensor& self, const Tensor& prob) {
|
||||
Tensor mask = at::empty_with_format(
|
||||
{length / 8},
|
||||
self.options().dtype(at::kByte),
|
||||
CalcuOpUtil::get_tensor_npu_format(self));
|
||||
ACL_FORMAT_ND);
|
||||
|
||||
Tensor cpu_shape =
|
||||
from_blob((void*)self.sizes().data(), {self.dim()}, at::kLong)
|
||||
.to(at::kInt);
|
||||
Tensor npu_shape = CalcuOpUtil::copy_tensor_host_to_device(cpu_shape);
|
||||
IntArrayRef selfShape = self.sizes();
|
||||
|
||||
OpCommand cmd;
|
||||
// If either seed or seed2 are set to be non-zero, the random number generator
|
||||
@@ -57,7 +54,7 @@ Tensor dropout_gen_mask(const Tensor& self, const Tensor& prob) {
|
||||
int64_t seed = 0;
|
||||
int64_t seed2 = 0;
|
||||
cmd.Name("DropOutGenMask")
|
||||
.InputPair(npu_shape, /*cpu_input=*/cpu_shape)
|
||||
.Input(selfShape)
|
||||
.Input(prob)
|
||||
.Output(mask)
|
||||
.Attr("seed", seed)
|
||||
@@ -77,9 +74,6 @@ std::tuple<Tensor, Tensor> dropout_v1_npu_impl(
|
||||
TORCH_CHECK(
|
||||
at::isFloatingType(self.scalar_type()),
|
||||
"dropout only supports floating-point dtypes");
|
||||
|
||||
// dropout only supports NCHW foramt(aicpu restriction)
|
||||
Tensor selfFormatCast = self.npu_format_cast(ACL_FORMAT_ND);
|
||||
|
||||
double retain = 1. - p;
|
||||
Tensor prob;
|
||||
@@ -91,25 +85,22 @@ std::tuple<Tensor, Tensor> dropout_v1_npu_impl(
|
||||
// same time, according to the one-stream-one-pool principle, memory is also
|
||||
// alloced from the pool of the secondary stream.
|
||||
c10::npu::SecondaryStreamGuard guard(c10::npu::getCurrentSecondaryStream());
|
||||
prob = CalcuOpUtil::CopyScalarToDevice(retain, selfFormatCast.scalar_type());
|
||||
mask = dropout_gen_mask(selfFormatCast, prob);
|
||||
prob = scalar_to_tensor(retain).to(self.scalar_type());
|
||||
mask = dropout_gen_mask(self, prob);
|
||||
}
|
||||
// When tasks on multiple streams read and write the same block of memory,
|
||||
// recordStream needs to be called to ensure the correctness of memory reuse.
|
||||
c10::npu::NPUCachingAllocator::recordStream(prob.storage().data_ptr(), original_stream);
|
||||
c10::npu::NPUCachingAllocator::recordStream(mask.storage().data_ptr(), original_stream);
|
||||
dropout_do_mask(result, selfFormatCast, mask, prob);
|
||||
dropout_do_mask(result, self, mask, prob);
|
||||
|
||||
return std::tie(result, mask);
|
||||
}
|
||||
std::tuple<Tensor, Tensor> _dropout_npu(
|
||||
const Tensor& self,
|
||||
double p) {
|
||||
Tensor selfFormatCast = self.npu_format_cast(ACL_FORMAT_ND);
|
||||
auto outputSize = input_same_output_size(selfFormatCast);
|
||||
Tensor result = at::empty_with_format(
|
||||
outputSize, self.options(), CalcuOpUtil::get_tensor_npu_format(selfFormatCast));
|
||||
return dropout_v1_npu_impl(result, selfFormatCast, p);
|
||||
Tensor result = OpPreparation::ApplyTensor(self);
|
||||
return dropout_v1_npu_impl(result, self, p);
|
||||
}
|
||||
|
||||
std::tuple<Tensor, Tensor> _dropout_npu_inplace(
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// Copyright (c) 2020 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.
|
||||
#include "ATen/native/npu/utils/CalcuOpUtil.h"
|
||||
#include "ATen/native/npu/utils/KernelNpuOutputSize.h"
|
||||
#include "ATen/native/npu/utils/NpuUtils.h"
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// Copyright (c) 2020 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.
|
||||
#include "ATen/native/npu/utils/CalcuOpUtil.h"
|
||||
#include "ATen/native/npu/utils/KernelNpuOutputSize.h"
|
||||
#include "ATen/native/npu/utils/NpuUtils.h"
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// Copyright (c) 2020 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.
|
||||
#include "ATen/native/npu/utils/OpAdapter.h"
|
||||
|
||||
namespace at {
|
||||
|
||||
@@ -12,71 +12,39 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "ATen/native/npu/utils/CalcuOpUtil.h"
|
||||
#include "ATen/native/npu/utils/KernelNpuOutputSize.h"
|
||||
#include "ATen/native/npu/utils/NpuUtils.h"
|
||||
#include "ATen/native/npu/utils/OpAdapter.h"
|
||||
|
||||
namespace at {
|
||||
namespace native {
|
||||
using namespace at::native::npu;
|
||||
|
||||
SmallVector<NPUTensorDesc, N> embedding_renorm_npu_input(
|
||||
const SmallVector<Tensor, N>& inputTensor) {
|
||||
return CalcuOpUtil::create_npu_input_tensor_desc(inputTensor);
|
||||
}
|
||||
|
||||
SmallVector<NPUTensorDesc, N> embedding_renorm_npu_output(
|
||||
const SmallVector<Tensor, N>& outputTensor) {
|
||||
return CalcuOpUtil::create_npu_output_tensor_desc(outputTensor);
|
||||
}
|
||||
|
||||
SmallVector<NPUAttrDesc, N> embedding_renorm_npu_attr(
|
||||
double max_norm,
|
||||
double norm_type){
|
||||
int64_t dim = 0;
|
||||
float max_norm_float = (float) max_norm;
|
||||
float norm_type_float = (float) norm_type;
|
||||
NPUAttrDesc npuAttrScalarP = NPUAttrDesc("p", norm_type_float);
|
||||
NPUAttrDesc npuAttrScalarMaxnorm = NPUAttrDesc("maxnorm", max_norm_float);
|
||||
NPUAttrDesc npuAttrDim = NPUAttrDesc("dim", dim);
|
||||
SmallVector<NPUAttrDesc, N> attrs = {npuAttrScalarP, npuAttrDim, npuAttrScalarMaxnorm};
|
||||
return attrs;
|
||||
}
|
||||
SmallVector<NPUAttrDesc, N> embedding_gather2d_npu_attr() {
|
||||
NPUAttrDesc npuAttrAxis = NPUAttrDesc("axis", (int64_t)0);
|
||||
SmallVector<NPUAttrDesc, N> attrs = {npuAttrAxis};
|
||||
return attrs;
|
||||
}
|
||||
|
||||
SmallVector<NPUAttrDesc, N> embedding_renorm_scatter_update_npu_attr(){
|
||||
NPUAttrDesc npuAttrAxis = NPUAttrDesc("use_locking", false);
|
||||
SmallVector<NPUAttrDesc, N> attrs = {npuAttrAxis};
|
||||
return attrs;
|
||||
}
|
||||
|
||||
Tensor& embedding_renorm_gather2d_out_npu(
|
||||
Tensor& result,
|
||||
const Tensor& self,
|
||||
const Tensor& indices
|
||||
){
|
||||
// execute the NPU operate GatherV2D
|
||||
auto inputs = embedding_renorm_npu_input({self, indices});
|
||||
auto outputs = embedding_renorm_npu_output({result});
|
||||
auto attrs = embedding_gather2d_npu_attr();
|
||||
CalcuOpUtil::execute_npu_operate("GatherV2D", inputs, outputs, attrs);
|
||||
const Tensor& indices) {
|
||||
OpCommand cmd;
|
||||
cmd.Name("GatherV2D")
|
||||
.Input(self)
|
||||
.Input(indices)
|
||||
.Output(result)
|
||||
.Attr("axis", (int64_t)0)
|
||||
.Run();
|
||||
return result;
|
||||
}
|
||||
|
||||
Tensor& embedding_renorm_execute_out_npu(
|
||||
Tensor& result,
|
||||
const Tensor& self,
|
||||
double max_norm,
|
||||
double norm_type){
|
||||
//execute the NPU operate Renorm
|
||||
auto inputs = embedding_renorm_npu_input({self});
|
||||
auto outputs = embedding_renorm_npu_output({result});
|
||||
auto attrs = embedding_renorm_npu_attr(max_norm, norm_type);
|
||||
CalcuOpUtil::execute_npu_operate("Renorm", inputs, outputs, attrs);
|
||||
double max_norm,
|
||||
double norm_type) {
|
||||
OpCommand cmd;
|
||||
cmd.Name("Renorm")
|
||||
.Input(self)
|
||||
.Output(result)
|
||||
.Attr("p", (float)norm_type)
|
||||
.Attr("dim", (int64_t)0)
|
||||
.Attr("maxnorm", (float)max_norm)
|
||||
.Run();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -85,82 +53,84 @@ Tensor& embedding_renorm_scatter_update_out_npu(
|
||||
Tensor& result,
|
||||
const Tensor& self,
|
||||
const Tensor& indices,
|
||||
const Tensor& update){
|
||||
auto inputs = embedding_renorm_npu_input({self, indices, update});
|
||||
auto outputs = embedding_renorm_npu_output({result});
|
||||
auto attrs = embedding_renorm_scatter_update_npu_attr();
|
||||
CalcuOpUtil::execute_npu_operate("ScatterUpdate", inputs, outputs, attrs);
|
||||
const Tensor& update) {
|
||||
OpCommand cmd;
|
||||
cmd.Name("ScatterUpdate")
|
||||
.Input(self)
|
||||
.Input(indices)
|
||||
.Input(update)
|
||||
.Output(result)
|
||||
.Attr("use_locking", false)
|
||||
.Run();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Tensor& embedding_renorm_out_npu(
|
||||
Tensor& result,
|
||||
const Tensor& self,
|
||||
const Tensor& indices,
|
||||
Tensor& mid_input,
|
||||
Tensor& mid_output,
|
||||
double max_norm,
|
||||
double max_norm,
|
||||
double norm_type){
|
||||
// execute the NPU operate GatherV2D,generate new tensor by indices
|
||||
embedding_renorm_gather2d_out_npu(
|
||||
mid_input,
|
||||
self,
|
||||
indices);
|
||||
//execute the NPU operate Renorm
|
||||
embedding_renorm_execute_out_npu(
|
||||
mid_output,
|
||||
mid_input,
|
||||
max_norm,
|
||||
norm_type);
|
||||
// executing the NPU operator ScatterUpdate
|
||||
embedding_renorm_scatter_update_out_npu(
|
||||
result,
|
||||
self,
|
||||
indices,
|
||||
mid_output);
|
||||
|
||||
//get the outSize of GatherV2 , the middle tensor
|
||||
SmallVector<int64_t, SIZE> midSize = {indices.size(0), self.size(1)};
|
||||
Tensor mid_input = OpPreparation::ApplyTensor(self, midSize);
|
||||
Tensor mid_output = OpPreparation::ApplyTensor(self, midSize);
|
||||
|
||||
// execute the NPU operate GatherV2D, generate new tensor by indices
|
||||
embedding_renorm_gather2d_out_npu(mid_input,self,indices);
|
||||
|
||||
//execute the NPU operate Renorm
|
||||
embedding_renorm_execute_out_npu(mid_output, mid_input, max_norm, norm_type);
|
||||
|
||||
//execute the NPU operate ZerosLike or RangeD, generate new tensor by indices.numel()
|
||||
Tensor mid_output_copy = mid_output.clone();
|
||||
auto num_indices = indices.numel();
|
||||
Tensor input_indices;
|
||||
|
||||
// RangeD not support range(0,0)
|
||||
if (num_indices - 1 == 0) {
|
||||
input_indices = at::zeros({1}, self.options()).to(at::kLong);
|
||||
} else {
|
||||
input_indices = at::range(0, num_indices-1, self.options()).to(at::kLong);
|
||||
}
|
||||
|
||||
//execute the NPU operate MUL, generate change result
|
||||
auto num_mid_output = mid_output.numel();
|
||||
resize_npu_(mid_output_copy, num_mid_output);
|
||||
Tensor scalar_out = OpPreparation::ApplyTensor(self, {num_indices, 1});
|
||||
embedding_renorm_gather2d_out_npu(scalar_out, mid_output_copy, input_indices);
|
||||
Tensor out_res = mid_input * scalar_out;
|
||||
|
||||
// executing the NPU operator ScatterUpdate
|
||||
embedding_renorm_scatter_update_out_npu(result, self, indices, out_res);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Tensor& embedding_renorm_npu_(
|
||||
Tensor& self,
|
||||
const Tensor& indices,
|
||||
double max_norm,
|
||||
double max_norm,
|
||||
double norm_type) {
|
||||
|
||||
//check dim and type
|
||||
//check dim and type
|
||||
auto self_arg = TensorArg(self, "self", 1);
|
||||
auto indices_arg = TensorArg(indices, "indices", 2);
|
||||
checkDim("embedding_renorm_", self_arg, 2);
|
||||
checkScalarType("embedding_renorm_", indices_arg, kLong);
|
||||
|
||||
// indices must be int64 in pytorch, but npu can only support int32
|
||||
auto indices_int32 = indices.to("cpu");
|
||||
indices_int32 = indices_int32.to(at::kInt);
|
||||
indices_int32 = indices_int32.to("npu");
|
||||
|
||||
//resize indices to 1D
|
||||
//resize indices to 1D
|
||||
Tensor indices_copy = indices.clone();
|
||||
auto num_indices = indices.numel();
|
||||
resize_npu_(indices_copy, num_indices);
|
||||
|
||||
SmallVector<Tensor, N> inputs = {self};
|
||||
SmallVector<Tensor, N> outputs = {self};
|
||||
CalcuOpUtil::check_memory_over_laps(inputs, outputs);
|
||||
|
||||
//get the outSize of GatherV2 , the middle tensor
|
||||
auto midSize = embedding_renorm_mid_npu_output_size(self, indices_copy);
|
||||
Tensor mid = at::empty_with_format(midSize, self.options(), CalcuOpUtil::get_tensor_npu_format(self));
|
||||
Tensor mid1 = at::empty_with_format(midSize, self.options(), CalcuOpUtil::get_tensor_npu_format(self));
|
||||
|
||||
//inplace operate
|
||||
if (!NpuUtils::check_match(&self)) {
|
||||
Tensor contiguousSelf = NpuUtils::format_contiguous(self);
|
||||
Tensor result = embedding_renorm_out_npu(contiguousSelf, contiguousSelf, indices_copy, mid, mid1, max_norm, norm_type);
|
||||
NpuUtils::format_fresh_view(self, result);
|
||||
} else {
|
||||
embedding_renorm_out_npu(self, self, indices_copy, mid, mid1, max_norm, norm_type);
|
||||
}
|
||||
OpPipeWithDefinedOut pipe;
|
||||
pipe.CheckMemory({self, indices_copy}, {self})
|
||||
.Func([&self, &indices_copy, max_norm, norm_type](Tensor& result){
|
||||
embedding_renorm_out_npu(self, self, indices_copy, max_norm, norm_type);})
|
||||
.Call(self);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
// 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.
|
||||
|
||||
#include "ATen/native/npu/utils/OpAdapter.h"
|
||||
|
||||
namespace at {
|
||||
namespace native {
|
||||
using namespace at::native::npu;
|
||||
|
||||
Tensor& erfc_out_npu_no_check(Tensor& out, const Tensor& self){
|
||||
OpCommand cmd;
|
||||
cmd.Name("Erfc")
|
||||
.Input(self)
|
||||
.Output(out)
|
||||
.Run();
|
||||
return out;
|
||||
}
|
||||
|
||||
Tensor& erfc_out_npu(Tensor& out, const Tensor& self) {
|
||||
OpPreparation::CheckOut(
|
||||
{self},
|
||||
out,
|
||||
self,
|
||||
self.sizes());
|
||||
|
||||
OpPipeWithDefinedOut pipe;
|
||||
return pipe.CheckMemory({self}, {out})
|
||||
.Func([&self](Tensor& out){erfc_out_npu_no_check(out, self);})
|
||||
.Call(out);
|
||||
}
|
||||
|
||||
Tensor erfc_npu(const Tensor& self) {
|
||||
Tensor result = OpPreparation::ApplyTensor(self);
|
||||
erfc_out_npu_no_check(result, self);
|
||||
return result;
|
||||
}
|
||||
|
||||
Tensor& erfc_npu_(Tensor& self) {
|
||||
erfc_out_npu(self, self);
|
||||
return self;
|
||||
}
|
||||
|
||||
} // native
|
||||
} // at
|
||||
@@ -23,7 +23,12 @@ using namespace at::native::npu;
|
||||
|
||||
Tensor& fill_out_npu(Tensor& result, Tensor& self, const Tensor& other) {
|
||||
if (!c10::npu::OptionsManager::CheckDynamicEnable()) {
|
||||
SmallVector<int64_t, N> dims = array_to_small_vector(self.sizes());
|
||||
SmallVector<int64_t, N> dims;
|
||||
if (self.dim() != 0){
|
||||
dims = array_to_small_vector(self.sizes());
|
||||
} {
|
||||
dims = {1};
|
||||
}
|
||||
OpCommand cmd;
|
||||
cmd.Name("Fill")
|
||||
.Input(dims, at::kLong)
|
||||
|
||||