From 38cb91b5c19c45e24e3dcb834819ed85103c9b93 Mon Sep 17 00:00:00 2001 From: sunxing <346736790@qq.com> Date: Tue, 22 Mar 2022 10:02:03 +0800 Subject: [PATCH] =?UTF-8?q?[code=20check]=20a-b=20ut=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_network_ops/test___and__.py | 2 +- test/test_network_ops/test___ior__.py | 2 +- test/test_network_ops/test___or__.py | 2 +- test/test_network_ops/test__iRshift__.py | 2 +- test/test_network_ops/test__ilshift__.py | 2 +- test/test_network_ops/test__rshift__.py | 2 +- test/test_network_ops/test__svd_helper.py | 2 +- test/test_network_ops/test_abs.py | 2 +- test/test_network_ops/test_adaptive_avg_pool1d.py | 2 +- .../test_adaptive_avg_pool2d_backward.py | 2 +- test/test_network_ops/test_adaptive_avg_pool3d.py | 2 +- .../test_adaptive_avg_pool3d_backward.py | 2 +- test/test_network_ops/test_adaptive_max_pool2d.py | 2 +- .../test_adaptive_max_pool2d_backward.py | 2 +- test/test_network_ops/test_add.py | 2 +- test/test_network_ops/test_addbmm.py | 2 +- test/test_network_ops/test_addmm.py | 2 +- test/test_network_ops/test_addmv.py | 3 +-- test/test_network_ops/test_addr.py | 2 +- .../test_affine_grid_generator.py | 2 +- .../test_affine_grid_generator_backward.py | 2 +- test/test_network_ops/test_all.py | 2 +- test/test_network_ops/test_anchorresponseflags.py | 2 +- test/test_network_ops/test_any.py | 2 +- test/test_network_ops/test_arange.py | 2 +- test/test_network_ops/test_argmax.py | 2 +- test/test_network_ops/test_argmin.py | 2 +- test/test_network_ops/test_argsort.py | 2 +- test/test_network_ops/test_asin.py | 2 +- test/test_network_ops/test_atan.py | 2 +- test/test_network_ops/test_atan2.py | 2 +- test/test_network_ops/test_avg_pool2d.py | 2 +- test/test_network_ops/test_avg_pool2d_backward.py | 2 +- test/test_network_ops/test_avg_pool3d.py | 4 +--- test/test_network_ops/test_avg_pool3d_backward.py | 2 +- test/test_network_ops/test_baddbmm.py | 2 +- test/test_network_ops/test_batch_norm_stats.py | 2 +- .../test_network_ops/test_batchnorm3d_backward.py | 2 +- test/test_network_ops/test_batchnorm_backward.py | 2 +- .../test_batchnorm_backward_eval.py | 2 +- .../test_batchnorm_backward_reduce.py | 2 +- .../test_batchnorm_gather_stats_with_counts.py | 10 +++++++--- test/test_network_ops/test_bernoulli.py | 2 +- .../test_network_ops/test_binary_cross_entropy.py | 2 +- .../test_binary_cross_entropy_backward.py | 10 +++++++--- .../test_binary_cross_entropy_with_logits.py | 15 +++++++++------ ...t_binary_cross_entropy_with_logits_backward.py | 2 +- test/test_network_ops/test_bincount.py | 2 +- test/test_network_ops/test_bitwise_and.py | 2 +- test/test_network_ops/test_bitwise_not.py | 2 +- test/test_network_ops/test_bitwise_or.py | 2 +- test/test_network_ops/test_bitwisexor.py | 2 +- test/test_network_ops/test_bmm.py | 2 +- test/test_network_ops/test_bmmV2.py | 2 +- 54 files changed, 74 insertions(+), 66 deletions(-) diff --git a/test/test_network_ops/test___and__.py b/test/test_network_ops/test___and__.py index 03017da320..f65ebd2cd0 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 363aa108a8..ae5488022f 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 74bd6c8d27..496c923852 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 aae06cf435..0fa5ddc870 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 db2450246c..18f7906e27 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 72409eb466..44e85af201 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 da3b0e4a5a..9098310ec5 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 e1e4de92c0..28db57266e 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 af129c3e5f..7390fcf2a5 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 7037973c85..0f9a67e673 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 83f39c5c18..e7c9eac1c3 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 e5d3fde9f3..26bc5ad21c 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 0cfe2c8417..1d4b4180cd 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 8fb62a32d5..11f2564cee 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 bc5c9a9c99..8700e39e62 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 7b3a380146..2e98155470 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 58db41361a..06a849b74e 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 b59052a87c..b0ae5f62b1 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 3d37459509..d1794d3f9a 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 1c62d975d7..6efa4604f8 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 e13250aaf0..1f67e08a10 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 df40ae4545..33bcd3d574 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 57847f467e..8617af1335 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 6a2a34a196..08d1a7ad03 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 c4aa1a13e5..87f33cf018 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 5e0007727a..aa88eba673 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 d63c756e0c..0fd639981d 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 e0fcfed5f8..fae2234d97 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 45d014c759..7026cf0410 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 ad42891622..43d887e17a 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 bded83715f..161d53db67 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 4d1c4e432b..59d063db67 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 fb89146df2..556ac65688 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 dd8e3188f4..fe16fc3e17 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 e86ecc7d2b..4e399f6fe8 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 c419ff8a92..f171812215 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 22143b876a..1af3ea4324 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 af1eaad382..bc95bc8af4 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 de5e7d9bce..5e567bcac5 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 5a8ae18f95..fe93eb4b01 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 2a6e8ad309..e252ff7bdf 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 71f12c1f62..8bf7442958 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 1f2ed2573b..4458519caa 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 d943017f87..4e0e94ec85 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 e3ed88662d..daecd9529e 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 8e0ce96ee1..3dc5533d46 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 1e01253d07..9a64d8cdab 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 778b3f331c..23a116335b 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 7299201eb5..06b432865c 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 7ceccf49b2..4a6c62ac25 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 adce35bf31..34faf7c90d 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 6dd619a14e..8d896c2d66 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 1391cb4002..2ab0af4f58 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 3c732815a9..d7c4ac4b30 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 -- Gitee