diff --git a/test/test_network_ops/test_scatter.py b/test/test_network_ops/test_scatter.py index 1936d3761b2035b2c6073afe29bee2c083a15739..87caae98a20e078217eed494c243d89895e7c0e2 100644 --- a/test/test_network_ops/test_scatter.py +++ b/test/test_network_ops/test_scatter.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_scatter_add.py b/test/test_network_ops/test_scatter_add.py index 9443d71b754beeafd033130b931c6644fa57d851..398a4765e300ae050462160edcb987ea797c8340 100644 --- a/test/test_network_ops/test_scatter_add.py +++ b/test/test_network_ops/test_scatter_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 @@ -45,13 +45,13 @@ class TestScatterAdd(TestCase): def test_scatter_add_common_shape_format(self, device="npu"): shape_format = [ - [0, [np.int64, 0, [10, 20]], [np.float32, 0, [10, 20]], [np.float32, 0, [10, 20]]], - [1, [np.int64, 0, [10, 20]], [np.float32, 0, [10, 20]], [np.float32, 0, [10, 20]]], - [0, [np.int64, 0, [2, 6]], [np.float32, 0, [2, 6]], [np.float32, 0, [2, 6]]], - [1, [np.int64, 0, [2, 6]], [np.float32, 0, [2, 6]], [np.float32, 0, [2, 6]]], - [0, [np.int64, 0, [10, 20, 30]], [np.float32, 0, [10, 20, 30]], [np.float32, 0, [10, 20, 30]]], - [1, [np.int64, 0, [10, 20, 30]], [np.float32, 0, [10, 20, 30]], [np.float32, 0, [10, 20, 30]]], - [2, [np.int64, 0, [10, 20, 30]], [np.float32, 0, [10, 20, 30]], [np.float32, 0, [10, 20, 30]]], + [0, [np.int64, 0, [10, 20]], [np.float32, 0, [10, 20]], [np.float32, 0, [10, 20]]], + [1, [np.int64, 0, [10, 20]], [np.float32, 0, [10, 20]], [np.float32, 0, [10, 20]]], + [0, [np.int64, 0, [2, 6]], [np.float32, 0, [2, 6]], [np.float32, 0, [2, 6]]], + [1, [np.int64, 0, [2, 6]], [np.float32, 0, [2, 6]], [np.float32, 0, [2, 6]]], + [0, [np.int64, 0, [10, 20, 30]], [np.float32, 0, [10, 20, 30]], [np.float32, 0, [10, 20, 30]]], + [1, [np.int64, 0, [10, 20, 30]], [np.float32, 0, [10, 20, 30]], [np.float32, 0, [10, 20, 30]]], + [2, [np.int64, 0, [10, 20, 30]], [np.float32, 0, [10, 20, 30]], [np.float32, 0, [10, 20, 30]]], ] for item in shape_format: diff --git a/test/test_network_ops/test_selu.py b/test/test_network_ops/test_selu.py index c3c3dbe8e72f5397d3f68aa9c6fe00581d1780fe..c785ca21e4a40d183f2c0f63f5ac09114f6da679 100644 --- a/test/test_network_ops/test_selu.py +++ b/test/test_network_ops/test_selu.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_sigmoid.py b/test/test_network_ops/test_sigmoid.py index c47ab4165624b2816d794968c27a6a4935405a4e..c615642a74b3bcb3173cfa025f006fb3edf1ee4e 100644 --- a/test/test_network_ops/test_sigmoid.py +++ b/test/test_network_ops/test_sigmoid.py @@ -11,9 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import 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_sigmoid_backward.py b/test/test_network_ops/test_sigmoid_backward.py index a78d172d4d6307915b86cfd6dfeb296c35a362e9..b2e4614f8c1ae92cd2fde8d615c144d5b35f18c9 100644 --- a/test/test_network_ops/test_sigmoid_backward.py +++ b/test/test_network_ops/test_sigmoid_backward.py @@ -11,9 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import 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_sign.py b/test/test_network_ops/test_sign.py index 67a61ff8699b177e1ae823968927e586183e841e..87f951ec17807178f00f105f216494385cd6743b 100644 --- a/test/test_network_ops/test_sign.py +++ b/test/test_network_ops/test_sign.py @@ -11,9 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import 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_silu.py b/test/test_network_ops/test_silu.py index 0da283cafc8101b5547fed1e222836fa571065be..60153d4ff0787ff2ee6a827dc10e66f5a8e56666 100644 --- a/test/test_network_ops/test_silu.py +++ b/test/test_network_ops/test_silu.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_silu_backward.py b/test/test_network_ops/test_silu_backward.py index 9e4e319e81a7180540b8aaf9209a609bcac819a9..08d08bfb79e33b53e0291410577c10a6613b6b2f 100644 --- a/test/test_network_ops/test_silu_backward.py +++ b/test/test_network_ops/test_silu_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_sin.py b/test/test_network_ops/test_sin.py index 4252cafb90e6abc3a84b0609261d04b5fd0ebd36..07fa0ac08da72e5901b4bcdfc38c62b23c3c80ab 100644 --- a/test/test_network_ops/test_sin.py +++ b/test/test_network_ops/test_sin.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_sinh.py b/test/test_network_ops/test_sinh.py index 5915b0c48aa52067debcd8fd7ad72879398533bd..c00b9ccab3d0fefe77e1807ea01a0bcfd5bb460e 100644 --- a/test/test_network_ops/test_sinh.py +++ b/test/test_network_ops/test_sinh.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_slogdet.py b/test/test_network_ops/test_slogdet.py index 2ea343f4fd6b1cfee97901197630fe2108e2200f..c68abcb45d96ef4fb31b51a0320b89b752642d91 100644 --- a/test/test_network_ops/test_slogdet.py +++ b/test/test_network_ops/test_slogdet.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_slow_conv_dilated2d.py b/test/test_network_ops/test_slow_conv_dilated2d.py index 253019389e0cabd32e6a7fdfa51fe5ed87b345f3..5b73a9ccd41e508e4a6dc2923efc87b0f895d61b 100644 --- a/test/test_network_ops/test_slow_conv_dilated2d.py +++ b/test/test_network_ops/test_slow_conv_dilated2d.py @@ -13,9 +13,9 @@ # limitations under the License. import torch -import torch_npu import numpy as np import torch.nn as nn +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_slow_conv_dilated2d_backward.py b/test/test_network_ops/test_slow_conv_dilated2d_backward.py index 4b7981d506e6ff70a6c99d7aa16886fd4899581a..68b300104f3871cfb7673cc3570a38facb5c7ce1 100644 --- a/test/test_network_ops/test_slow_conv_dilated2d_backward.py +++ b/test/test_network_ops/test_slow_conv_dilated2d_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_slow_conv_transpose2d.py b/test/test_network_ops/test_slow_conv_transpose2d.py index 006312f473530fc80f4ca4038c927a0282893148..f53cd2c9f15d1cff062ddb37f92aef549f333d7b 100644 --- a/test/test_network_ops/test_slow_conv_transpose2d.py +++ b/test/test_network_ops/test_slow_conv_transpose2d.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_slow_conv_transpose2d_backward.py b/test/test_network_ops/test_slow_conv_transpose2d_backward.py index ec0ce0a1f60613b318bfc703f6992d7adfb4ce18..d5e02b90be102ce6e5d4b2e1d7499ce00d40b748 100644 --- a/test/test_network_ops/test_slow_conv_transpose2d_backward.py +++ b/test/test_network_ops/test_slow_conv_transpose2d_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_smooth_l1_loss_backward.py b/test/test_network_ops/test_smooth_l1_loss_backward.py index 0d37d9f84c165b6d50f1cbcd8b0acc30106e8e96..f97b64000ee07dcd373345d016c85ff35760e3f0 100644 --- a/test/test_network_ops/test_smooth_l1_loss_backward.py +++ b/test/test_network_ops/test_smooth_l1_loss_backward.py @@ -13,9 +13,9 @@ # limitations under the License. import torch -import torch_npu import numpy as np import torch.nn.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_smoothl1loss.py b/test/test_network_ops/test_smoothl1loss.py index 7dafcf0d21f2cf10d42ca45da6ffe228c6f9928e..945ad772343984c98859bd5fa340f1e2a995a063 100644 --- a/test/test_network_ops/test_smoothl1loss.py +++ b/test/test_network_ops/test_smoothl1loss.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_soft_margin_loss.py b/test/test_network_ops/test_soft_margin_loss.py index 599f3bacbee37cba1fd3795d45557c72bd1d584b..f4d22616b54b6f36e6d17c46769cdc0f93832e9f 100644 --- a/test/test_network_ops/test_soft_margin_loss.py +++ b/test/test_network_ops/test_soft_margin_loss.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_soft_margin_loss_backward.py b/test/test_network_ops/test_soft_margin_loss_backward.py index 0b690d9ff83233f5e55f6dfcc74069001c1c83dd..52f693532c57797001eb62fae1573956cd6db4fd 100644 --- a/test/test_network_ops/test_soft_margin_loss_backward.py +++ b/test/test_network_ops/test_soft_margin_loss_backward.py @@ -13,9 +13,9 @@ # limitations under the License. import torch -import torch_npu import numpy as np import torch.nn.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_softplus.py b/test/test_network_ops/test_softplus.py index 9b881b23df859fb29df3f4e7b427d2aa447c53ed..d0103c943859de766c607f2b3bc5defc3f966959 100644 --- a/test/test_network_ops/test_softplus.py +++ b/test/test_network_ops/test_softplus.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_softplus_backward.py b/test/test_network_ops/test_softplus_backward.py index 08b8cbdc75daee8e98f82f9254655460a94547b5..5eff4633bb21a7a908b14f737ff744f11e79ecf6 100644 --- a/test/test_network_ops/test_softplus_backward.py +++ b/test/test_network_ops/test_softplus_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_softshrink.py b/test/test_network_ops/test_softshrink.py index cee5d9709b8db4b6a10186044c05d0f7857f757f..1dab3ba6a22c4e0a41657e7d2db4ba82f412689c 100644 --- a/test/test_network_ops/test_softshrink.py +++ b/test/test_network_ops/test_softshrink.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_softshrink_backward.py b/test/test_network_ops/test_softshrink_backward.py index 1b3e86df0ee9d181d890d6d9cd4898ef83dc1ff9..0cc0383d62a369ded14e4154282c5f5021767b8e 100644 --- a/test/test_network_ops/test_softshrink_backward.py +++ b/test/test_network_ops/test_softshrink_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 diff --git a/test/test_network_ops/test_sort.py b/test/test_network_ops/test_sort.py index 27cc84ef1b4562e49c31a1941aa03f8cf674e083..2e154fbf876ab57ac67c948f9b309beebb399d5b 100644 --- a/test/test_network_ops/test_sort.py +++ b/test/test_network_ops/test_sort.py @@ -13,9 +13,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import 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_sort_without_indices.py b/test/test_network_ops/test_sort_without_indices.py index e53e1842ef8402600179c5c9a1570c7b052fbec0..7057aee7d1717028ce4a0715fa6a658be52dc88f 100644 --- a/test/test_network_ops/test_sort_without_indices.py +++ b/test/test_network_ops/test_sort_without_indices.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_stack.py b/test/test_network_ops/test_stack.py index b209bb3f653505ac0bc80dd82744c1b6abccaeed..e4ca4e21da2c611cd7321a3fd75b713c2ca39d48 100644 --- a/test/test_network_ops/test_stack.py +++ b/test/test_network_ops/test_stack.py @@ -11,9 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import 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_std.py b/test/test_network_ops/test_std.py index bfe8b8a95d41a04d0bde59b99b0e133a41201374..0237995f79ad522252a0cd31bc4cc1ee1812e2a9 100644 --- a/test/test_network_ops/test_std.py +++ b/test/test_network_ops/test_std.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_std_mean.py b/test/test_network_ops/test_std_mean.py index d49444561cbbb4f0309465771ec49d280fb06083..a3b37534c8e22554ac977c000a4c57982838a6d0 100644 --- a/test/test_network_ops/test_std_mean.py +++ b/test/test_network_ops/test_std_mean.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_sub_sample.py b/test/test_network_ops/test_sub_sample.py index a6ae808ccbccaac51b83101d4fe216593b20ae4b..06b38ba78653957e05e944ea9db0a52793b31f27 100644 --- a/test/test_network_ops/test_sub_sample.py +++ b/test/test_network_ops/test_sub_sample.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_sum.py b/test/test_network_ops/test_sum.py index 94bb384110da2eae24e78c41e599989dcdc7c45e..f14f6dc8842ec8f30c4a3410046a67d5e795bc80 100644 --- a/test/test_network_ops/test_sum.py +++ b/test/test_network_ops/test_sum.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_take.py b/test/test_network_ops/test_take.py index 7cbe07bd589703f532c247d91925a02da79a3804..58a1168a37b56d9927eb6edcad42a66e428bd648 100644 --- a/test/test_network_ops/test_take.py +++ b/test/test_network_ops/test_take.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_tan.py b/test/test_network_ops/test_tan.py index 4f5002e0e5fd4c219f956d8a3fe0e4106e14e88d..d7865bf5c0a436b0285ecf7574fcffd7097af40a 100644 --- a/test/test_network_ops/test_tan.py +++ b/test/test_network_ops/test_tan.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 diff --git a/test/test_network_ops/test_tanh.py b/test/test_network_ops/test_tanh.py index a1bcfb09c6a1ca3a6d6b3376447157a6a4037584..9e722a26275cf7bce78981060b956ab486c8ab8a 100644 --- a/test/test_network_ops/test_tanh.py +++ b/test/test_network_ops/test_tanh.py @@ -11,9 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import 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 @@ -83,7 +84,8 @@ class TestTanh(TestCase): [[np.float16, -1, (4, 44, 44)], 3450,34020], [[np.float16, -1, (65500, 3, 3)], -214748,-214746], [[np.float16, -1, (64, 4, 4)], -9.313225746154785e-10,9.313225746154785e-10], - [[np.float16, -1, (128, 3, 5)], -0.000000000000000000000000000000000000011754943508,0.000000000000000000000000000000000000011754943508], + [[np.float16, -1, (128, 3, 5)], + -0.000000000000000000000000000000000000011754943508,0.000000000000000000000000000000000000011754943508], [[np.float16, -1, (1, 1, 1)], 0.9283381566708346 , 16], [[np.float16, -1, (6, 3, 10)], 0.03133650248813469 , 37], [[np.float16, -1, (65500, 1, 1)], 95, 100 ], diff --git a/test/test_network_ops/test_tanh_backward.py b/test/test_network_ops/test_tanh_backward.py index 35f4642acae4d3ecab873fffb1a1fe280653afb1..fcff6f30c1f811ec0538ed2feffb804769e4f330 100644 --- a/test/test_network_ops/test_tanh_backward.py +++ b/test/test_network_ops/test_tanh_backward.py @@ -11,9 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import 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_thnn_conv_depthwise2d_backward.py b/test/test_network_ops/test_thnn_conv_depthwise2d_backward.py index b267e1e59effe246b03e99bd642939f21d56d88f..e07c36db8a2a5a488edf15193a1a0bd166a3d75f 100644 --- a/test/test_network_ops/test_thnn_conv_depthwise2d_backward.py +++ b/test/test_network_ops/test_thnn_conv_depthwise2d_backward.py @@ -15,9 +15,9 @@ # limitations under the License. import torch -import torch_npu import numpy as np import torch.nn as nn +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor @@ -41,7 +41,7 @@ class TestThnnConvDepthwise2d(TestCase): input1.register_hook(lambda grad: self.get_input_grad(grad)) bias1 = False - if bias != None: + if bias is not None: bias1 = True m1 = nn.Conv2d(in_channels, out_channels, kernel_size, stride, padding, dilation, bias=bias1, @@ -61,7 +61,7 @@ class TestThnnConvDepthwise2d(TestCase): input1.register_hook(lambda grad: self.get_input_grad(grad)) bias1 = False - if bias != None: + if bias is not None: bias1 = True m1 = nn.Conv2d(in_channels, out_channels, kernel_size, stride, padding, dilation, bias=bias1, diff --git a/test/test_network_ops/test_thnn_conv_depthwise2d_forward.py b/test/test_network_ops/test_thnn_conv_depthwise2d_forward.py index 10f1083a4ffb53651e5e43be496364388d1910f4..f5fe8f25c23279efc7c34acb227014699e211543 100644 --- a/test/test_network_ops/test_thnn_conv_depthwise2d_forward.py +++ b/test/test_network_ops/test_thnn_conv_depthwise2d_forward.py @@ -13,9 +13,9 @@ # limitations under the License. import torch -import torch_npu import numpy as np import torch.nn as nn +import torch_npu from torch_npu.testing.testcase import TestCase, run_tests from torch_npu.testing.common_utils import create_common_tensor @@ -31,13 +31,14 @@ class TestThnnConvDepthwise2d(TestCase): def get_input_grad(self, grad): self.input_grad.append(grad.to("cpu")) - def op_exec_cpu(self, input1, weight, in_channels, out_channels, kernel_size, padding=0, stride=1, dilation=1, bias=True, group=2): + def op_exec_cpu(self, input1, weight, in_channels, + out_channels, kernel_size, padding=0, stride=1, dilation=1, bias=True, group=2): weight1 = weight input1.requires_grad = True input1.register_hook(lambda grad: self.get_input_grad(grad)) bias1 = False - if bias != None: + if bias is not None: bias1 = True m1 = nn.Conv2d(in_channels, out_channels, kernel_size, stride, padding, dilation, bias=bias1, groups=group) @@ -50,13 +51,14 @@ class TestThnnConvDepthwise2d(TestCase): return cpuOutput - def op_exec_npu(self, input1, weight, in_channels, out_channels, kernel_size, padding=0, stride=1, dilation=1, bias=True, group=2): + def op_exec_npu(self, input1, weight, in_channels, + out_channels, kernel_size, padding=0, stride=1, dilation=1, bias=True, group=2): weight1 = weight input1.requires_grad = True input1.register_hook(lambda grad: self.get_input_grad(grad)) bias1 = False - if bias != None: + if bias is not None: bias1 = True m1 = nn.Conv2d(in_channels, out_channels, kernel_size, stride, padding, dilation, bias=bias1, groups=group) @@ -98,7 +100,7 @@ class TestThnnConvDepthwise2d(TestCase): padding=item[2], stride=item[3], dilation=item[4], bias=item[5], group=group) cpu_output = cpu_output.to(npu_output.dtype) - if item[5] == True: + if item[5] is True: self.assertRtolEqual(cpu_output.detach().numpy(), npu_output.detach().numpy(), 0.005 ) else: self.assertRtolEqual(cpu_output.detach().numpy(), npu_output.detach().numpy() ) diff --git a/test/test_network_ops/test_threshold.py b/test/test_network_ops/test_threshold.py index febb6cf36d0f48b1365c9e07a861a702ecdb4bb3..ec93408d7ba6699d2c392c33a12a6096fc92976c 100644 --- a/test/test_network_ops/test_threshold.py +++ b/test/test_network_ops/test_threshold.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_threshold_backward.py b/test/test_network_ops/test_threshold_backward.py index 1307e10ed3042c19683ef469b84df41c59384e8e..c999b751e81734484259e905176daa427fce6421 100644 --- a/test/test_network_ops/test_threshold_backward.py +++ b/test/test_network_ops/test_threshold_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_to.py b/test/test_network_ops/test_to.py index 3f8c7076be1c68195c3afb6bc7d624217e0178cc..9d70e624346f6383c0716504af79d15cfa69fbba 100644 --- a/test/test_network_ops/test_to.py +++ b/test/test_network_ops/test_to.py @@ -15,12 +15,13 @@ # 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 + class TestTo(TestCase): def cpu_op_exec(self, input1, target): output = input1.to(target) diff --git a/test/test_network_ops/test_topk.py b/test/test_network_ops/test_topk.py index 0d6975f66935be1a301bba36d7434fa400056346..89914e1ddfa85b72a607d478cfd20dec276c4b19 100644 --- a/test/test_network_ops/test_topk.py +++ b/test/test_network_ops/test_topk.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_transpose.py b/test/test_network_ops/test_transpose.py index 798d7d5e326b5ad7d988029251a1b9d793ae109a..681445ab915e3ef7f1d80712ae0674045e7cdbd8 100644 --- a/test/test_network_ops/test_transpose.py +++ b/test/test_network_ops/test_transpose.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_triangular_solve_helper.py b/test/test_network_ops/test_triangular_solve_helper.py index c2d028e92b052b9f7f30fa336ddde7d01d52e078..18c7e07b0ae1114f2c18d5d2cf507b740ecbbee7 100644 --- a/test/test_network_ops/test_triangular_solve_helper.py +++ b/test/test_network_ops/test_triangular_solve_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_tril.py b/test/test_network_ops/test_tril.py index 31195afcc4c8cc399f4e7522999986109663c962..05b6733bc3290e9c8f3fdff0303ffba8ff641499 100644 --- a/test/test_network_ops/test_tril.py +++ b/test/test_network_ops/test_tril.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_triu.py b/test/test_network_ops/test_triu.py index 6daa9ebe17ebb3ecd51a60f445d519c4c8648c83..f07101fa82550576e9d24cfec6d795e7f5af8b95 100644 --- a/test/test_network_ops/test_triu.py +++ b/test/test_network_ops/test_triu.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_true_divide.py b/test/test_network_ops/test_true_divide.py index e89e5096319051b465db00d2bfec9857ff0878ef..3f0cdd5231f183666c25f6264fa124cf9fd8b282 100644 --- a/test/test_network_ops/test_true_divide.py +++ b/test/test_network_ops/test_true_divide.py @@ -12,8 +12,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_trunc.py b/test/test_network_ops/test_trunc.py index 3d180f3433bfc3a53a543a34a4644a4d59966260..313abb7813668cffbe8636e040723f79aff477f3 100644 --- a/test/test_network_ops/test_trunc.py +++ b/test/test_network_ops/test_trunc.py @@ -13,12 +13,13 @@ # 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 + class TestTrunc(TestCase): def generate_single_data(self, min_d, max_d, shape, dtype): input1 = np.random.uniform(min_d, max_d, shape).astype(dtype) diff --git a/test/test_network_ops/test_unique2.py b/test/test_network_ops/test_unique2.py index 4f3c07d218dbdef9f65e0e3220b6fb8a16919ef7..003ae72d2f06d9aac30f64e81f7027d58e3b16cb 100644 --- a/test/test_network_ops/test_unique2.py +++ b/test/test_network_ops/test_unique2.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 diff --git a/test/test_network_ops/test_upsample_bicubic2d.py b/test/test_network_ops/test_upsample_bicubic2d.py index 38e16e922840105e05bf02bc1ac51e4cf3fc4b6e..cc2c268e3c8c72afff23246a8e1ea21b20635f22 100644 --- a/test/test_network_ops/test_upsample_bicubic2d.py +++ b/test/test_network_ops/test_upsample_bicubic2d.py @@ -15,12 +15,13 @@ # 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 + class TestUpsampleBicubic2d(TestCase): def cpu_op_exec(self, input1, output_size, align_corners, scale_h, scale_w): diff --git a/test/test_network_ops/test_upsample_bicubic2d_backward.py b/test/test_network_ops/test_upsample_bicubic2d_backward.py index ea37ece37d68720131f5ef3cc4d1e52f2fee37f4..7adfc577f11266c3525133d8797a87066cfa84a1 100644 --- a/test/test_network_ops/test_upsample_bicubic2d_backward.py +++ b/test/test_network_ops/test_upsample_bicubic2d_backward.py @@ -15,12 +15,13 @@ # 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 + class TestUpsampleBicubic2dBackward(TestCase): def cpu_op_exec(self, input1, output_size, align_corners, scale_h, scale_w): diff --git a/test/test_network_ops/test_upsample_bilinear2d.py b/test/test_network_ops/test_upsample_bilinear2d.py index d610e9dcbe758111ffc2dbc68da970741a43b2f9..0caf8692ab706829d5066ac03090f7ce45648891 100644 --- a/test/test_network_ops/test_upsample_bilinear2d.py +++ b/test/test_network_ops/test_upsample_bilinear2d.py @@ -11,9 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import 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_upsample_bilinear2d_backward.py b/test/test_network_ops/test_upsample_bilinear2d_backward.py index 92688d3ae7aa107ff44c982e88c411f6793764fa..c3b01fa5450e1dca9769dbb34b18f27d0a32e9bc 100644 --- a/test/test_network_ops/test_upsample_bilinear2d_backward.py +++ b/test/test_network_ops/test_upsample_bilinear2d_backward.py @@ -11,9 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import 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_upsample_linear1d.py b/test/test_network_ops/test_upsample_linear1d.py index 0232218341a79072d6b71c430c19a4252b6bc75c..89257947acaeea9d62b929115a09a65618302301 100644 --- a/test/test_network_ops/test_upsample_linear1d.py +++ b/test/test_network_ops/test_upsample_linear1d.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_upsample_linear1d_backward.py b/test/test_network_ops/test_upsample_linear1d_backward.py index ff7531669ab1b14161eeccd5dc04544598e95b73..c6970982d76d128bfaec680c8fd65eb54ca6ce04 100644 --- a/test/test_network_ops/test_upsample_linear1d_backward.py +++ b/test/test_network_ops/test_upsample_linear1d_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_upsample_nearest1d.py b/test/test_network_ops/test_upsample_nearest1d.py index bad0c52ebc8d508b11eb593e7695701125d2512b..60ca2095a1c4ac7da3e240154ed4cb6c6b40bde4 100644 --- a/test/test_network_ops/test_upsample_nearest1d.py +++ b/test/test_network_ops/test_upsample_nearest1d.py @@ -13,9 +13,9 @@ # limitations under the License. import torch -import torch_npu import numpy as np import torch.nn.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_upsample_nearest1d_backward.py b/test/test_network_ops/test_upsample_nearest1d_backward.py index c27181d33e91b87859f4a2297aad098ffe25eff1..82f8eb678c29e370bde6a73a5b5b5cdfd707c778 100644 --- a/test/test_network_ops/test_upsample_nearest1d_backward.py +++ b/test/test_network_ops/test_upsample_nearest1d_backward.py @@ -14,9 +14,9 @@ import math import torch -import torch_npu import numpy as np import torch.nn.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_upsample_nearest2d.py b/test/test_network_ops/test_upsample_nearest2d.py index a73cbc8bb8279ac3627df54c514cfd82fa80d975..3bebc640f76bc79f3c98282016632fa8cc8ff911 100644 --- a/test/test_network_ops/test_upsample_nearest2d.py +++ b/test/test_network_ops/test_upsample_nearest2d.py @@ -11,10 +11,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import torch -import torch_npu -import torch.nn.functional as F import numpy as np +import torch.nn.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_upsample_nearest2d_backward.py b/test/test_network_ops/test_upsample_nearest2d_backward.py index 6e74d03d5777a76cc00b932c23f57a198db23ce7..0522c4e3af0988f5e7bcd598c433959f10438028 100644 --- a/test/test_network_ops/test_upsample_nearest2d_backward.py +++ b/test/test_network_ops/test_upsample_nearest2d_backward.py @@ -11,10 +11,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import torch -import torch_npu -import torch.nn.functional as F import numpy as np +import torch.nn.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_upsample_nearest3d.py b/test/test_network_ops/test_upsample_nearest3d.py index 0d3c7ea4e043cd1b97ce641f5f50a79952ee41aa..b174ec7193e87ccd1746017c240f0539ef22787c 100644 --- a/test/test_network_ops/test_upsample_nearest3d.py +++ b/test/test_network_ops/test_upsample_nearest3d.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_upsample_nearest3d_backward.py b/test/test_network_ops/test_upsample_nearest3d_backward.py index d99b44e849e15d8303761f11c04c2568c841f398..db84e51219c4fd8ce55f5b67910fd52c58c43713 100644 --- a/test/test_network_ops/test_upsample_nearest3d_backward.py +++ b/test/test_network_ops/test_upsample_nearest3d_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_upsample_trilinear3d.py b/test/test_network_ops/test_upsample_trilinear3d.py index 4f6d98c13dc951ea185910bf620b4d7ef0ea0a50..ffc1aafdfefcdfa9c352f4208d456ef8416b7d6c 100644 --- a/test/test_network_ops/test_upsample_trilinear3d.py +++ b/test/test_network_ops/test_upsample_trilinear3d.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_upsample_trilinear3d_backward.py b/test/test_network_ops/test_upsample_trilinear3d_backward.py index c319622fcb39870672def96d17bfdf051d4c09b4..9fc0d32604dab750f1d0df340613a3340690f91d 100644 --- a/test/test_network_ops/test_upsample_trilinear3d_backward.py +++ b/test/test_network_ops/test_upsample_trilinear3d_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_var.py b/test/test_network_ops/test_var.py index 12482c7dc92d68210b8185996e308f335d949d22..092a6095bd43778e8d418b75946593826f3cb1af 100644 --- a/test/test_network_ops/test_var.py +++ b/test/test_network_ops/test_var.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_where.py b/test/test_network_ops/test_where.py index 4db59af042f71db8eaa9883e5b9df95cb76f67aa..88519347f456fd48eb71d07e00e2da79a9304673 100644 --- a/test/test_network_ops/test_where.py +++ b/test/test_network_ops/test_where.py @@ -11,9 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import 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 @@ -23,6 +24,7 @@ class TestWhere(TestCase): def cpu_op_exec(self, input1): output = torch.where(input1) output = list(output) + for i in range(len(output)): output[i] = output[i].numpy().astype(np.int32) return output @@ -30,6 +32,7 @@ class TestWhere(TestCase): def npu_op_exec(self, input1): output = torch.where(input1) output = list(output) + for i in range(len(output)): output[i] = output[i].to("cpu").numpy().astype(np.int32) return output diff --git a/test/test_network_ops/test_xor.py b/test/test_network_ops/test_xor.py index f0e254befeef509646bbd5053ad1fd5812b30dbc..d5dcf2f7332a8735a05ae964410e53628f7b0dcb 100644 --- a/test/test_network_ops/test_xor.py +++ b/test/test_network_ops/test_xor.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_zero.py b/test/test_network_ops/test_zero.py index cdce485d46da04a073a87f48ff7870fe749c61d1..7122cfdd01449436240015693e8d73423332a275 100644 --- a/test/test_network_ops/test_zero.py +++ b/test/test_network_ops/test_zero.py @@ -11,9 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import 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_zeros.py b/test/test_network_ops/test_zeros.py index 390994d7cc1a14cfcc666a033734eacfb6c6929d..248eaeca4f82e68635c0760a082fa323c953120a 100644 --- a/test/test_network_ops/test_zeros.py +++ b/test/test_network_ops/test_zeros.py @@ -11,10 +11,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import 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_zeroslike.py b/test/test_network_ops/test_zeroslike.py index a014707ab2fc1581286c5d9b5eb89f57ea6a2f2a..86b58704f7eb40ca40290bc2cbdbdf14f94c7478 100644 --- a/test/test_network_ops/test_zeroslike.py +++ b/test/test_network_ops/test_zeroslike.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