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