diff --git a/test/test_network_ops/test___and__.py b/test/test_network_ops/test___and__.py index 03017da32004ae7302952b4a8ec3fbf990b85b78..f65ebd2cd0f6ca1fca5b5fdd2ebf8d8c19bb7d3b 100644 --- a/test/test_network_ops/test___and__.py +++ b/test/test_network_ops/test___and__.py @@ -14,8 +14,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test___ior__.py b/test/test_network_ops/test___ior__.py index 363aa108a81e125d6177a3c4ae7399ec4b1afca3..ae5488022ffb7fc292c174f4f37f065f6929b6d7 100644 --- a/test/test_network_ops/test___ior__.py +++ b/test/test_network_ops/test___ior__.py @@ -13,8 +13,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests diff --git a/test/test_network_ops/test___or__.py b/test/test_network_ops/test___or__.py index 74bd6c8d277e226a5002be8f347bb58376fa5014..496c923852df0b3bdfe501dff92059256422cbd6 100644 --- a/test/test_network_ops/test___or__.py +++ b/test/test_network_ops/test___or__.py @@ -15,8 +15,8 @@ import copy import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test__iRshift__.py b/test/test_network_ops/test__iRshift__.py index aae06cf435e99c9d01bd7f6cf18d3e2d90744ef7..0fa5ddc870a5ba190f1a9c97b21ef335f15bf09f 100644 --- a/test/test_network_ops/test__iRshift__.py +++ b/test/test_network_ops/test__iRshift__.py @@ -15,8 +15,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test__ilshift__.py b/test/test_network_ops/test__ilshift__.py index db2450246c7ad07345e0a2279e227afea91425c1..18f7906e276a922eb45d8fe103df46cdfe8a7db3 100644 --- a/test/test_network_ops/test__ilshift__.py +++ b/test/test_network_ops/test__ilshift__.py @@ -15,8 +15,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test__rshift__.py b/test/test_network_ops/test__rshift__.py index 72409eb46653311762f9acb0613fdc84384eccd2..44e85af201c85b9607e93b4018ce898c50884c97 100644 --- a/test/test_network_ops/test__rshift__.py +++ b/test/test_network_ops/test__rshift__.py @@ -15,8 +15,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test__svd_helper.py b/test/test_network_ops/test__svd_helper.py index da3b0e4a5a3034c9ee68d7ace448235bc49d2d96..9098310ec5e3e23f77daa463a75c693a7904003a 100644 --- a/test/test_network_ops/test__svd_helper.py +++ b/test/test_network_ops/test__svd_helper.py @@ -15,8 +15,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_abs.py b/test/test_network_ops/test_abs.py index e1e4de92c0691025266d26a00466b95ac85663aa..28db57266ef00b3f8811477309c281cb23aa4a5b 100644 --- a/test/test_network_ops/test_abs.py +++ b/test/test_network_ops/test_abs.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_adaptive_avg_pool1d.py b/test/test_network_ops/test_adaptive_avg_pool1d.py index af129c3e5fd82d9e332ce85c13f402aed2ff938e..7390fcf2a5c5df07d1051cf558f4438f9c44e8cf 100644 --- a/test/test_network_ops/test_adaptive_avg_pool1d.py +++ b/test/test_network_ops/test_adaptive_avg_pool1d.py @@ -13,9 +13,9 @@ # limitations under the License. import torch -import torch_npu import torch.nn as nn import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_adaptive_avg_pool2d_backward.py b/test/test_network_ops/test_adaptive_avg_pool2d_backward.py index 7037973c859f8c7058f0eb09f3ce73e5a133aabc..0f9a67e6733682a3cb2ecc2a8e4a75a73280e44c 100644 --- a/test/test_network_ops/test_adaptive_avg_pool2d_backward.py +++ b/test/test_network_ops/test_adaptive_avg_pool2d_backward.py @@ -13,9 +13,9 @@ # limitations under the License. import torch -import torch_npu import numpy as np from torch.nn import functional as F +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests diff --git a/test/test_network_ops/test_adaptive_avg_pool3d.py b/test/test_network_ops/test_adaptive_avg_pool3d.py index 83f39c5c183072a142bb2edf9912f6ba8ff6e988..e7c9eac1c3e3fba9336131d21865ede78de9afab 100644 --- a/test/test_network_ops/test_adaptive_avg_pool3d.py +++ b/test/test_network_ops/test_adaptive_avg_pool3d.py @@ -13,9 +13,9 @@ # limitations under the License. import torch -import torch_npu import torch.nn as nn import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_adaptive_avg_pool3d_backward.py b/test/test_network_ops/test_adaptive_avg_pool3d_backward.py index e5d3fde9f332a257c3effceb9817e4956077a31b..26bc5ad21cb812e84add19edb0190b5372c656ec 100644 --- a/test/test_network_ops/test_adaptive_avg_pool3d_backward.py +++ b/test/test_network_ops/test_adaptive_avg_pool3d_backward.py @@ -13,9 +13,9 @@ # limitations under the License. import torch -import torch_npu import numpy as np from torch.nn import functional as F +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_adaptive_max_pool2d.py b/test/test_network_ops/test_adaptive_max_pool2d.py index 0cfe2c8417d1357bdeeef8bdd55dd900e955de71..1d4b4180cd119b3f165b326f716f8734a2136955 100644 --- a/test/test_network_ops/test_adaptive_max_pool2d.py +++ b/test/test_network_ops/test_adaptive_max_pool2d.py @@ -13,8 +13,8 @@ # limitations under the License. import torch.nn as nn -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_adaptive_max_pool2d_backward.py b/test/test_network_ops/test_adaptive_max_pool2d_backward.py index 8fb62a32d563353abcbc839b6c93010f28af25f0..11f2564cee76fb2a95d574a12d31d260c9adfe21 100644 --- a/test/test_network_ops/test_adaptive_max_pool2d_backward.py +++ b/test/test_network_ops/test_adaptive_max_pool2d_backward.py @@ -13,9 +13,9 @@ # limitations under the License. import torch -import torch_npu import torch.nn as nn import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_add.py b/test/test_network_ops/test_add.py index bc5c9a9c99975499cf8ecc8a173c773f7b75a384..8700e39e62dd028fc2a01280484c1880e6e44fc4 100644 --- a/test/test_network_ops/test_add.py +++ b/test/test_network_ops/test_add.py @@ -13,8 +13,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_addbmm.py b/test/test_network_ops/test_addbmm.py index 7b3a380146291596f237fecb51ddc9bcb0a7a75f..2e98155470293a3176e761ac0e0d02d67497067d 100644 --- a/test/test_network_ops/test_addbmm.py +++ b/test/test_network_ops/test_addbmm.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_addmm.py b/test/test_network_ops/test_addmm.py index 58db41361ac7d12596980bd9c99145497ab5280c..06a849b74e20de02e7777942e057eefcbcb8c14f 100644 --- a/test/test_network_ops/test_addmm.py +++ b/test/test_network_ops/test_addmm.py @@ -13,8 +13,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_addmv.py b/test/test_network_ops/test_addmv.py index b59052a87c5d5382906ed866b223f3d29de81652..b0ae5f62b1deefe2fe80c0256f3ac4d4a85a9c3d 100644 --- a/test/test_network_ops/test_addmv.py +++ b/test/test_network_ops/test_addmv.py @@ -13,8 +13,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor @@ -22,7 +22,6 @@ from torch_npu.testing.common_utils import create_common_tensor class TestAddmv(TestCase): def cpu_op_exec(self, a, b, c, alpha, beta): - '''output = alpha * a @ b + beta * c''' output = torch.addmv(c, a, b, alpha=alpha, beta=beta) output = output.numpy() return output diff --git a/test/test_network_ops/test_addr.py b/test/test_network_ops/test_addr.py index 3d37459509a17300ee35214096ab9af462edd0cd..d1794d3f9ab3b45b7f787054bccd7fdfa75eecd2 100644 --- a/test/test_network_ops/test_addr.py +++ b/test/test_network_ops/test_addr.py @@ -13,8 +13,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_affine_grid_generator.py b/test/test_network_ops/test_affine_grid_generator.py index 1c62d975d7518e8b7128832794d2ac406ca6d1f0..6efa4604f86a16e22350a65f67f02fc5a6413a6c 100644 --- a/test/test_network_ops/test_affine_grid_generator.py +++ b/test/test_network_ops/test_affine_grid_generator.py @@ -15,9 +15,9 @@ # limitations under the License. import torch -import torch_npu import numpy as np from torch.nn import functional as F +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests diff --git a/test/test_network_ops/test_affine_grid_generator_backward.py b/test/test_network_ops/test_affine_grid_generator_backward.py index e13250aaf008a79b22e2101406d7b4442579b65e..1f67e08a102c771d02e6303d5871471c78fc21d7 100644 --- a/test/test_network_ops/test_affine_grid_generator_backward.py +++ b/test/test_network_ops/test_affine_grid_generator_backward.py @@ -13,9 +13,9 @@ # limitations under the License. import torch -import torch_npu import numpy as np from torch.nn import functional as F +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_all.py b/test/test_network_ops/test_all.py index df40ae454567838b5bdac9b7ea3944a2765e87ca..33bcd3d5744821b2294d7fefabe8562ed0a9bed1 100644 --- a/test/test_network_ops/test_all.py +++ b/test/test_network_ops/test_all.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests diff --git a/test/test_network_ops/test_anchorresponseflags.py b/test/test_network_ops/test_anchorresponseflags.py index 57847f467efc1e601a92b3b170b92ec368b86a82..8617af13359e9e2548363f1dd6347ae585e8ec56 100644 --- a/test/test_network_ops/test_anchorresponseflags.py +++ b/test/test_network_ops/test_anchorresponseflags.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. import torch -import torch_npu import numpy as np from torch.nn import functional as F +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_any.py b/test/test_network_ops/test_any.py index 6a2a34a1963aff61a40a4cd6da208c50ac0c080d..08d1a7ad034fbaec348a92ee4513f2e380daddde 100644 --- a/test/test_network_ops/test_any.py +++ b/test/test_network_ops/test_any.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests diff --git a/test/test_network_ops/test_arange.py b/test/test_network_ops/test_arange.py index c4aa1a13e5dc571847467856d128a51e3b6d53c5..87f33cf0180525a01b378aa42475c28d07958d03 100644 --- a/test/test_network_ops/test_arange.py +++ b/test/test_network_ops/test_arange.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_argmax.py b/test/test_network_ops/test_argmax.py index 5e0007727a8cff9e181d37666b62ae1fbe4fb6cb..aa88eba673f267eab966f27217fd800e9fd33e51 100644 --- a/test/test_network_ops/test_argmax.py +++ b/test/test_network_ops/test_argmax.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_argmin.py b/test/test_network_ops/test_argmin.py index d63c756e0cabe33af0f51eee081bdc2695f32d5f..0fd639981dcaa13c22170efe8ff59e6b04620171 100644 --- a/test/test_network_ops/test_argmin.py +++ b/test/test_network_ops/test_argmin.py @@ -15,8 +15,8 @@ # coding: utf-8 import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_argsort.py b/test/test_network_ops/test_argsort.py index e0fcfed5f8a964c93ed3e698ce5723a826a536c9..fae2234d97457855f66490ed7772e79270f43107 100644 --- a/test/test_network_ops/test_argsort.py +++ b/test/test_network_ops/test_argsort.py @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_asin.py b/test/test_network_ops/test_asin.py index 45d014c759eeb85986f92a7c2d4c819004effe98..7026cf0410a8cc238739573085340ebc0e69899a 100644 --- a/test/test_network_ops/test_asin.py +++ b/test/test_network_ops/test_asin.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_atan.py b/test/test_network_ops/test_atan.py index ad4289162208ebb7c7952ecf46bdfb67f5e8adb0..43d887e17a9c247debed28e3f20061b910bf31b3 100644 --- a/test/test_network_ops/test_atan.py +++ b/test/test_network_ops/test_atan.py @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_atan2.py b/test/test_network_ops/test_atan2.py index bded83715fdbf83336de102487adb99f3e2729f8..161d53db6736fd8e64b1e9a99743a6f1ec4113cc 100644 --- a/test/test_network_ops/test_atan2.py +++ b/test/test_network_ops/test_atan2.py @@ -13,8 +13,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_avg_pool2d.py b/test/test_network_ops/test_avg_pool2d.py index 4d1c4e432be74d5d7a1bcb019a548ac0c83b8f8b..59d063db6708f82e482bf7c1dcfedc9031f20579 100644 --- a/test/test_network_ops/test_avg_pool2d.py +++ b/test/test_network_ops/test_avg_pool2d.py @@ -13,9 +13,9 @@ # limitations under the License. import torch -import torch_npu import torch.nn as nn import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_avg_pool2d_backward.py b/test/test_network_ops/test_avg_pool2d_backward.py index fb89146df2ee551923d1728df89896ad44b467a2..556ac656888ec717cc2e5ae568609007e402402e 100644 --- a/test/test_network_ops/test_avg_pool2d_backward.py +++ b/test/test_network_ops/test_avg_pool2d_backward.py @@ -13,9 +13,9 @@ # limitations under the License. import torch -import torch_npu import torch.nn as nn import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_avg_pool3d.py b/test/test_network_ops/test_avg_pool3d.py index dd8e3188f44865f496508fa3c27ae814a86d1c7c..fe16fc3e1747ec0c95d69ebe00092a684a748002 100644 --- a/test/test_network_ops/test_avg_pool3d.py +++ b/test/test_network_ops/test_avg_pool3d.py @@ -15,8 +15,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor @@ -40,7 +40,6 @@ class TestAvgPool3D(TestCase): return output_data def test_avg_pool_3d_fp32(self, device="npu"): - # shape_format:[[dtype, (input_shape)], kernel_size, stride] shape_format = [ [[np.float32, -1, (20, 16, 50, 44, 31)], (3, 2, 2), (2, 1, 2)], [[np.float32, -1, (2, 1, 4, 4, 4)], 3, 2], @@ -55,7 +54,6 @@ class TestAvgPool3D(TestCase): self.assertRtolEqual(cpu_output, npu_output.cpu(), 1.e-3) def test_avg_pool_3d_fp16(self, device="npu"): - # shape_format:[[dtype, (input_shape)], kernel_size, stride] shape_format = [ [[np.float16, -1, (20, 16, 50, 44, 31)], (3, 2, 2), (2, 1, 2)], [[np.float16, -1, (2, 1, 4, 4, 4)], 3, 2], diff --git a/test/test_network_ops/test_avg_pool3d_backward.py b/test/test_network_ops/test_avg_pool3d_backward.py index e86ecc7d2b57afad31e89bf164a73e64954c4982..4e399f6fe85945b6ff5d74070bfb4af33791c053 100644 --- a/test/test_network_ops/test_avg_pool3d_backward.py +++ b/test/test_network_ops/test_avg_pool3d_backward.py @@ -15,8 +15,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_baddbmm.py b/test/test_network_ops/test_baddbmm.py index c419ff8a92aac98e79533ebbaa33429cc603dd3c..f171812215eeecf73432d21396cb3cb5f3c4cee3 100644 --- a/test/test_network_ops/test_baddbmm.py +++ b/test/test_network_ops/test_baddbmm.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. import torch -import torch_npu import numpy as np from torch.nn import functional as F +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_batch_norm_stats.py b/test/test_network_ops/test_batch_norm_stats.py index 22143b876a5b4fa9bc454f5bf944a2f8ef288120..1af3ea4324da5ab89a0ec8f63dd68f90d15bb112 100644 --- a/test/test_network_ops/test_batch_norm_stats.py +++ b/test/test_network_ops/test_batch_norm_stats.py @@ -13,8 +13,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_batchnorm3d_backward.py b/test/test_network_ops/test_batchnorm3d_backward.py index af1eaad3826ba297960d31ab44fbe8e1b449f9c5..bc95bc8af42b369fb19b863a3791ea8575223fd4 100644 --- a/test/test_network_ops/test_batchnorm3d_backward.py +++ b/test/test_network_ops/test_batchnorm3d_backward.py @@ -13,8 +13,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_batchnorm_backward.py b/test/test_network_ops/test_batchnorm_backward.py index de5e7d9bce0b97cf869bce05b82a2871c4f6c9d3..5e567bcac51f6443494195b091cf10f3f8e65425 100644 --- a/test/test_network_ops/test_batchnorm_backward.py +++ b/test/test_network_ops/test_batchnorm_backward.py @@ -13,8 +13,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_batchnorm_backward_eval.py b/test/test_network_ops/test_batchnorm_backward_eval.py index 5a8ae18f95214f7d4f76df092d3e17ff40970bbb..fe93eb4b019674420238b517aed43475031ddb4b 100644 --- a/test/test_network_ops/test_batchnorm_backward_eval.py +++ b/test/test_network_ops/test_batchnorm_backward_eval.py @@ -14,8 +14,8 @@ # limitations under the License. import torch -import torch_npu import torch.nn as nn +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests diff --git a/test/test_network_ops/test_batchnorm_backward_reduce.py b/test/test_network_ops/test_batchnorm_backward_reduce.py index 2a6e8ad3091d77d7d136a1739c7746134c2b75df..e252ff7bdf884d2138a98fa61d0274141984ff44 100644 --- a/test/test_network_ops/test_batchnorm_backward_reduce.py +++ b/test/test_network_ops/test_batchnorm_backward_reduce.py @@ -13,8 +13,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_batchnorm_gather_stats_with_counts.py b/test/test_network_ops/test_batchnorm_gather_stats_with_counts.py index 71f12c1f623fecd390693ce1d166bb185aa64b5a..8bf7442958c3ea8c26d90210b510313683f8ac56 100644 --- a/test/test_network_ops/test_batchnorm_gather_stats_with_counts.py +++ b/test/test_network_ops/test_batchnorm_gather_stats_with_counts.py @@ -13,8 +13,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor @@ -88,14 +88,18 @@ class TestBatchNormGatherStatsWithCounts(TestCase): else: cuda_output = self.expect_cuda_out_fp32() - npu_outputfp16 = self.npu_op_exec(npu_input1fp16, npu_mean, npu_invstd, npu_running_mean, npu_running_invstd, item[-4], item[-3], npu_counts) + npu_outputfp16 = self.npu_op_exec(npu_input1fp16, npu_mean, npu_invstd, + npu_running_mean, npu_running_invstd, + item[-4], item[-3], npu_counts) self.assertRtolEqual(npu_outputfp16[0], cuda_output[0]) self.assertRtolEqual(npu_outputfp16[1], cuda_output[1]) self.assertRtolEqual(npu_running_mean.cpu().numpy(), cuda_output[2]) self.assertRtolEqual(npu_running_invstd.cpu().numpy(), cuda_output[3]) if item[1][0] == np.float32: - npu_outputfp32 = self.npu_op_exec(npu_input1fp32, npu_mean, npu_invstd, npu_running_mean, npu_running_invstd, item[-4], item[-3], npu_counts) + npu_outputfp32 = self.npu_op_exec(npu_input1fp32, npu_mean, npu_invstd, + npu_running_mean, npu_running_invstd, + item[-4], item[-3], npu_counts) self.assertRtolEqual(npu_outputfp32[0], cuda_output[0]) self.assertRtolEqual(npu_outputfp32[1], cuda_output[1]) diff --git a/test/test_network_ops/test_bernoulli.py b/test/test_network_ops/test_bernoulli.py index 1f2ed2573b17cdf28ad65e7614de0554783cc39d..4458519caa8104d2d578353931f0cb5127b081b2 100644 --- a/test/test_network_ops/test_bernoulli.py +++ b/test/test_network_ops/test_bernoulli.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_binary_cross_entropy.py b/test/test_network_ops/test_binary_cross_entropy.py index d943017f87d93c88c36058862b93f7c2a0bdf6a0..4e0e94ec85b918bf71afcbc5432c79dbdb19bacc 100644 --- a/test/test_network_ops/test_binary_cross_entropy.py +++ b/test/test_network_ops/test_binary_cross_entropy.py @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests diff --git a/test/test_network_ops/test_binary_cross_entropy_backward.py b/test/test_network_ops/test_binary_cross_entropy_backward.py index e3ed88662d6de0608f03e51a413e296eca682d6b..daecd9529ece3f2ad90f90a71871728582ff61ea 100644 --- a/test/test_network_ops/test_binary_cross_entropy_backward.py +++ b/test/test_network_ops/test_binary_cross_entropy_backward.py @@ -16,8 +16,8 @@ import copy import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests @@ -37,7 +37,9 @@ class TestBinaryCrossEntropyBackward(TestCase): if weight is not None: weight = weight.to(torch.float32) input1.requires_grad_(True) - cpu_output = torch.nn.functional.binary_cross_entropy(input1, target, weight=weight, size_average=None, reduce=None, reduction=reduction) + cpu_output = torch.nn.functional.binary_cross_entropy(input1, target, + weight=weight, size_average=None, + reduce=None, reduction=reduction) input_cpu = cpu_output.detach().numpy() if reduction == 'none': w = torch.ones_like(input1) @@ -57,7 +59,9 @@ class TestBinaryCrossEntropyBackward(TestCase): if weight is not None: weight = weight.npu() input1.requires_grad_(True) - npu_output = torch.nn.functional.binary_cross_entropy(input1, target, weight=weight, size_average=None, reduce=None, reduction=reduction) + npu_output = torch.nn.functional.binary_cross_entropy(input1, target, + weight=weight, size_average=None, + reduce=None, reduction=reduction) npu_input = npu_output.cpu() npu_input = npu_input.detach().numpy() if reduction == 'none': diff --git a/test/test_network_ops/test_binary_cross_entropy_with_logits.py b/test/test_network_ops/test_binary_cross_entropy_with_logits.py index 8e0ce96ee13c2ae9f51bc51deb54b7838b26c3cf..3dc5533d46b84e7d2e6f0c3404736eab4659b893 100644 --- a/test/test_network_ops/test_binary_cross_entropy_with_logits.py +++ b/test/test_network_ops/test_binary_cross_entropy_with_logits.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests @@ -160,8 +160,10 @@ class TestBinaryCrossEntropyWithLogits(TestCase): weight = self.generate_one_input(0, 2, weight_shape, np.float32) if pos_weight_shape is not None: pos_weight = self.generate_one_input(0, 2, pos_weight_shape, np.float32) - cpu_output = self.cpu_op_func_exec(input1, target, weight=weight, pos_weight=pos_weight, reduction=reduction) - npu_output = self.npu_op_func_exec(input1, target, weight=weight, pos_weight=pos_weight, reduction=reduction) + cpu_output = self.cpu_op_func_exec(input1, target, weight=weight, + pos_weight=pos_weight, reduction=reduction) + npu_output = self.npu_op_func_exec(input1, target, weight=weight, + pos_weight=pos_weight, reduction=reduction) self.assertRtolEqual(cpu_output, npu_output) def test_binary_cross_with_logits_function_float16(self, device="npu"): @@ -195,9 +197,10 @@ class TestBinaryCrossEntropyWithLogits(TestCase): pos_weight = self.generate_one_input(0, 2, pos_weight_shape, np.float16) pos_weight_32 = pos_weight.type(torch.float32) - npu_output = self.npu_op_func_exec(input1, target, weight=weight, pos_weight=pos_weight, reduction=reduction) - cpu_output = self.cpu_op_func_exec(input_32, target_32, weight=weight_32, pos_weight=pos_weight_32, - reduction=reduction) + npu_output = self.npu_op_func_exec(input1, target, weight=weight, + pos_weight=pos_weight, reduction=reduction) + cpu_output = self.cpu_op_func_exec(input_32, target_32, weight=weight_32, + pos_weight=pos_weight_32, reduction=reduction) cpu_output = cpu_output.astype(np.float16) self.assertRtolEqual(cpu_output, npu_output) diff --git a/test/test_network_ops/test_binary_cross_entropy_with_logits_backward.py b/test/test_network_ops/test_binary_cross_entropy_with_logits_backward.py index 1e01253d07db20f1c511498f071713957188e840..9a64d8cdab31b2048585de6e8e508c96725a4866 100644 --- a/test/test_network_ops/test_binary_cross_entropy_with_logits_backward.py +++ b/test/test_network_ops/test_binary_cross_entropy_with_logits_backward.py @@ -13,9 +13,9 @@ # limitations under the License. import copy import torch -import torch_npu import torch.nn as nn import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests diff --git a/test/test_network_ops/test_bincount.py b/test/test_network_ops/test_bincount.py index 778b3f331c8a7b61170f25159dd13e1bc093b2a7..23a116335bc7ed8dff04a22adb611050440ca0bb 100644 --- a/test/test_network_ops/test_bincount.py +++ b/test/test_network_ops/test_bincount.py @@ -13,8 +13,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_bitwise_and.py b/test/test_network_ops/test_bitwise_and.py index 7299201eb52575aa00f5a14dfc9e6d0b33d67b2a..06b432865c174b74f8e27cd33d2d1630ba8ee19a 100644 --- a/test/test_network_ops/test_bitwise_and.py +++ b/test/test_network_ops/test_bitwise_and.py @@ -13,8 +13,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_bitwise_not.py b/test/test_network_ops/test_bitwise_not.py index 7ceccf49b276c372544fbf89ce27305f4dde51dd..4a6c62ac255d280c82c43ca847c5a1bd1406e331 100644 --- a/test/test_network_ops/test_bitwise_not.py +++ b/test/test_network_ops/test_bitwise_not.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests diff --git a/test/test_network_ops/test_bitwise_or.py b/test/test_network_ops/test_bitwise_or.py index adce35bf31319f3ff5686498c9df15481c9edf52..34faf7c90da376114e33770d7043a4072b2dfa3e 100644 --- a/test/test_network_ops/test_bitwise_or.py +++ b/test/test_network_ops/test_bitwise_or.py @@ -13,8 +13,8 @@ # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_bitwisexor.py b/test/test_network_ops/test_bitwisexor.py index 6dd619a14ec80b8122eb93a919b0b89cb5bf4215..8d896c2d66679d409bdf5ae20ede3ad0ee9f51bf 100644 --- a/test/test_network_ops/test_bitwisexor.py +++ b/test/test_network_ops/test_bitwisexor.py @@ -14,8 +14,8 @@ import random import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_bmm.py b/test/test_network_ops/test_bmm.py index 1391cb40020786df47f6dc9a0033935d8fc760bb..2ab0af4f582fdfcaa87d7116efe376a3a8453100 100644 --- a/test/test_network_ops/test_bmm.py +++ b/test/test_network_ops/test_bmm.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor diff --git a/test/test_network_ops/test_bmmV2.py b/test/test_network_ops/test_bmmV2.py index 3c732815a9bcdc0113bc6be2f934e238abb05064..d7c4ac4b30ba7ac92c036e9fac846e8aad257fc0 100644 --- a/test/test_network_ops/test_bmmV2.py +++ b/test/test_network_ops/test_bmmV2.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import torch -import torch_npu import numpy as np +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor