From d7e1ab1445879b591fbb29da629d32dbdf544dbc Mon Sep 17 00:00:00 2001 From: Yi Huaijie <yihuaijie@huawei.com> Date: Sat, 30 May 2020 11:29:19 +0800 Subject: [PATCH] clean pylint warnings --- tests/st/auto_parallel/resnet50_expand_loss.py | 4 +--- .../python/parallel/test_auto_parallel_flag.py | 18 +++++++++--------- .../ut/python/parallel/test_embeddinglookup.py | 2 -- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/tests/st/auto_parallel/resnet50_expand_loss.py b/tests/st/auto_parallel/resnet50_expand_loss.py index 0a74752b2d4..f46bb587fba 100644 --- a/tests/st/auto_parallel/resnet50_expand_loss.py +++ b/tests/st/auto_parallel/resnet50_expand_loss.py @@ -15,7 +15,6 @@ import os import numpy as np -import pytest import mindspore.common.dtype as mstype import mindspore.context as context @@ -113,8 +112,7 @@ class ResidualBlock(nn.Cell): def __init__(self, in_channels, out_channels, - stride=1, - momentum=0.9): + stride=1): super(ResidualBlock, self).__init__() out_chls = out_channels // self.expansion diff --git a/tests/ut/python/parallel/test_auto_parallel_flag.py b/tests/ut/python/parallel/test_auto_parallel_flag.py index d18ae7687cb..4b26d3321b1 100644 --- a/tests/ut/python/parallel/test_auto_parallel_flag.py +++ b/tests/ut/python/parallel/test_auto_parallel_flag.py @@ -39,10 +39,10 @@ class MindDataSet(MindData): if self._size < self._iter_num: raise StopIteration self._iter_num += 1 - next = [] - for shape, type in zip(self._output_shapes, self._np_types): - next.append(Tensor(np.ones(shape).astype(type))) - return tuple(next) + next_ = [] + for shape, type_ in zip(self._output_shapes, self._np_types): + next_.append(Tensor(np.ones(shape).astype(type_))) + return tuple(next_) class Net(nn.Cell): @@ -53,8 +53,8 @@ class Net(nn.Cell): self.matmul = P.MatMul() self.add = P.TensorAdd() - def construct(self, input): - output = self.add(self.matmul(input, self.weight), self.bias) + def construct(self, input_): + output = self.add(self.matmul(input_, self.weight), self.bias) return output @@ -67,9 +67,9 @@ class NetFP16(nn.Cell): self.add = P.TensorAdd() self.cast = P.Cast() - def construct(self, input): + def construct(self, input_): output = self.cast( - self.add(self.matmul(self.cast(input, mstype.float16), self.cast(self.weight, mstype.float16)), + self.add(self.matmul(self.cast(input_, mstype.float16), self.cast(self.weight, mstype.float16)), self.cast(self.bias, mstype.float16)), mstype.float32) return output @@ -107,5 +107,5 @@ def test_auto_parallel_flag(): optimizer = Momentum(net.trainable_params(), learning_rate=0.1, momentum=0.9) model = Model(net, loss_fn=loss, optimizer=optimizer, metrics=None, loss_scale_manager=scale_manager) model.train(2, dataset) - assert(model._train_network.get_flags()["auto_parallel"] == True) + assert model._train_network.get_flags()["auto_parallel"] context.reset_auto_parallel_context() diff --git a/tests/ut/python/parallel/test_embeddinglookup.py b/tests/ut/python/parallel/test_embeddinglookup.py index 9b7e36c6f1c..b934028a480 100644 --- a/tests/ut/python/parallel/test_embeddinglookup.py +++ b/tests/ut/python/parallel/test_embeddinglookup.py @@ -17,9 +17,7 @@ import numpy as np import mindspore as ms import mindspore.nn as nn from mindspore import Tensor -from mindspore import context from mindspore.common.api import _executor -from mindspore.ops import composite as C from mindspore.ops import operations as P from tests.ut.python.ops.test_math_ops import VirtualLoss