diff --git a/tests/ut/cpp/python_input/gtest_input/ir/manager_test.py b/tests/ut/cpp/python_input/gtest_input/ir/manager_test.py index dda7dd14f9cbaf6a1c161e1bdd33fadcd357209b..8aad56050cdae6edaab3f0da591255c4190191dd 100644 --- a/tests/ut/cpp/python_input/gtest_input/ir/manager_test.py +++ b/tests/ut/cpp/python_input/gtest_input/ir/manager_test.py @@ -44,7 +44,7 @@ def test_calls(x): # pylint: disable=unused-argument def test_unused_param(x, y): return x * x - + def test_cannot_replace_return(x): return x * x diff --git a/tests/ut/cpp/python_input/gtest_input/mem_reuse/mem_reuse_test.py b/tests/ut/cpp/python_input/gtest_input/mem_reuse/mem_reuse_test.py index 074aaf4a889c4c088ecd032cabc7008eac1c321a..73ec6ef4e7491a369669c72b8c4b9451b08ae69c 100644 --- a/tests/ut/cpp/python_input/gtest_input/mem_reuse/mem_reuse_test.py +++ b/tests/ut/cpp/python_input/gtest_input/mem_reuse/mem_reuse_test.py @@ -13,8 +13,6 @@ # limitations under the License. # ============================================================================ from mindspore.ops import operations as P -from mindspore.ops import Primitive -import mindspore as ms add = P.TensorAdd() reshape = P.Reshape() @@ -26,6 +24,6 @@ def test_shape_add(x1, x2, y1, y2, z1, z2): reshape_sum1 = reshape(sum1, (2, 2, 3, 1)) reshape_sum2 = reshape(sum2, (2, 2, 3, 1)) reshape_sum3 = reshape(sum3, (2, 2, 3, 1)) - sum = add(reshape_sum1, reshape_sum2) - sum = add(sum, reshape_sum3) - return sum + result = add(reshape_sum1, reshape_sum2) + result = add(result, reshape_sum3) + return result diff --git a/tests/ut/cpp/python_input/gtest_input/optimizer/ad/__init__.py b/tests/ut/cpp/python_input/gtest_input/optimizer/ad/__init__.py index 0bc75849679194db77b5ed73616cf4aebae8c332..b398453910e4458929a7eab24fa587f60b6a37a5 100644 --- a/tests/ut/cpp/python_input/gtest_input/optimizer/ad/__init__.py +++ b/tests/ut/cpp/python_input/gtest_input/optimizer/ad/__init__.py @@ -1,9 +1,8 @@ """ @File : __init__.py @Author: -@Date : 2019-01-23 16:36 -@Desc : +@Date : 2019-01-23 16:36 +@Desc : """ from .ad_test import * - diff --git a/tests/ut/cpp/python_input/gtest_input/optimizer/ad/ad_test.py b/tests/ut/cpp/python_input/gtest_input/optimizer/ad/ad_test.py index 154b0635e4170037b71088add7f934d17d44d999..882c5f0effabb004fd13f18d84ac1ff81a8660aa 100644 --- a/tests/ut/cpp/python_input/gtest_input/optimizer/ad/ad_test.py +++ b/tests/ut/cpp/python_input/gtest_input/optimizer/ad/ad_test.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ +from dataclasses import dataclass import numpy as np import mindspore as ms -from dataclasses import dataclass from mindspore.common.tensor import Tensor from mindspore.ops import Primitive from mindspore.model_zoo.resnet import resnet50 @@ -106,7 +106,7 @@ def test_closure(a): def x1(b): def x4(c): - return b + return c * b return x4 x2 = x1(a) x3 = x2(1.0) @@ -117,21 +117,18 @@ def test_if(a, b): # if statement, so I prefer to name the test 'test_if' if a > b: return a - else: - return b + return b def test_if2(a, b): if a > b: return a * a - else: - return b + b + return b + b def test_fact(x): def fact(n): if n <= 1: return 1 - else: - return n * fact(n - 1) + return n * fact(n - 1) return fact(x) def test_while(x): diff --git a/tests/ut/cpp/python_input/gtest_input/optimizer/opt_test.py b/tests/ut/cpp/python_input/gtest_input/optimizer/opt_test.py index d494ad27d38b718a7a5e9e9324c1d96a47fdd701..836a586ca73fd68a064c66c0e561fce6931bdb37 100644 --- a/tests/ut/cpp/python_input/gtest_input/optimizer/opt_test.py +++ b/tests/ut/cpp/python_input/gtest_input/optimizer/opt_test.py @@ -13,11 +13,11 @@ # limitations under the License. # ============================================================================ """ opt_test """ +import numpy as np from mindspore.ops import Primitive, PrimitiveWithInfer from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G from mindspore import Tensor -import numpy as np # pylint: disable=unused-variable @@ -790,9 +790,9 @@ def test_convert_switch_ops(tag): return z @fns def after(cond, x, y): - sw1 =ge_switch(x, cond) - sw2 =ge_switch(y, cond) - sw3 =ge_switch(y, cond) + sw1 = ge_switch(x, cond) + sw2 = ge_switch(y, cond) + sw3 = ge_switch(y, cond) sw1_t = tuple_getitem(sw1, 1) sw2_t = tuple_getitem(sw2, 1) sw3_f = tuple_getitem(sw3, 0) diff --git a/tests/ut/cpp/python_input/gtest_input/pipeline/infer/__init__.py b/tests/ut/cpp/python_input/gtest_input/pipeline/infer/__init__.py index d840342dd1e8a90b30217f782bb518a3b0b4e3bc..f8b8c7c23a210e1a0d6c42677b31aa84a1ebe39a 100644 --- a/tests/ut/cpp/python_input/gtest_input/pipeline/infer/__init__.py +++ b/tests/ut/cpp/python_input/gtest_input/pipeline/infer/__init__.py @@ -13,4 +13,4 @@ # limitations under the License. # ============================================================================ from .primitive_test import * -from .infer_test import * \ No newline at end of file +from .infer_test import * diff --git a/tests/ut/cpp/python_input/gtest_input/pipeline/infer/infer_test.py b/tests/ut/cpp/python_input/gtest_input/pipeline/infer/infer_test.py index e93c8bdb8747a08bcf274972f8d5bbb9e61da643..3c3674747a2346635a4dc37bc5d45dd1f86ebb6a 100644 --- a/tests/ut/cpp/python_input/gtest_input/pipeline/infer/infer_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pipeline/infer/infer_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -import mindspore.nn as nn from dataclasses import dataclass +import mindspore.nn as nn from mindspore.ops import Primitive from mindspore.ops import functional as F from mindspore.ops import operations as P diff --git a/tests/ut/cpp/python_input/gtest_input/pipeline/infer/primitive_test.py b/tests/ut/cpp/python_input/gtest_input/pipeline/infer/primitive_test.py index 06ab870ce2a931e0d85d9fc28687409e35f1447d..9f583d589a333a857f8de842d3b7256b9ca38dc2 100644 --- a/tests/ut/cpp/python_input/gtest_input/pipeline/infer/primitive_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pipeline/infer/primitive_test.py @@ -14,7 +14,7 @@ # ============================================================================ import mindspore.nn as nn from mindspore.common import dtype -from mindspore.ops import Primitive, prim_attr_register, PrimitiveWithInfer +from mindspore.ops import prim_attr_register, PrimitiveWithInfer from mindspore.ops import operations as P def get_add(a, b): @@ -55,15 +55,15 @@ def get_tensor_to_scalar(logits, labels): conv2d = P.Conv2D(64, - (3, 3), - pad_mode="pad", - pad=1, - stride=2) + (3, 3), + pad_mode="pad", + pad=1, + stride=2) def get_conv2d(x, w): return conv2d(x, w) -conv2dNative = P.DepthwiseConv2dNative(3, (3,3), pad_mode="pad", pad=1, stride=2) +conv2dNative = P.DepthwiseConv2dNative(3, (3, 3), pad_mode="pad", pad=1, stride=2) def get_conv2d_native(x, w): return conv2dNative(x, w) @@ -74,8 +74,8 @@ def get_bias_add(x, b): def test_conv2d(out_channel, kernel_size, pad, stride, dilation): - conv = P.Conv2D(out_channel=out_channel, kernel_size=kernel_size, pad_mode= "pad", pad=pad, - stride=stride, dilation= dilation) + conv = P.Conv2D(out_channel=out_channel, kernel_size=kernel_size, pad_mode="pad", pad=pad, + stride=stride, dilation=dilation) def get_conv(x, w): return conv(x, w) return get_conv @@ -83,7 +83,7 @@ def test_conv2d(out_channel, kernel_size, pad, stride, dilation): def test_dropout(): dropOutGenMask = P.DropoutGenMask() - dropoutDoMask = P.DropoutDoMask() + dropoutDoMask = P.DropoutDoMask() shape = P.Shape() def get_dropout(x, prob): mask = dropOutGenMask(shape(x), prob) diff --git a/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_test.py b/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_test.py index d0ed8a147389197a63869956d60a6d342701139a..fd7a500da766199a75434436155b8f138c5e1920 100644 --- a/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_test.py @@ -154,12 +154,12 @@ def test_lambda(x, y): return t def test_funcdef(x, y): - def max(a, b): + def mymax(a, b): if a > b: return a else: return b - t = max(x, y) + t = mymax(x, y) return t def test_tuple_fn(x, y): @@ -225,7 +225,7 @@ def test_simple_closure(a, b): return b + 2.0 return f() * g() -def test_assign_tuple(x,y): +def test_assign_tuple(x, y): a = 1 b = 2 t = a, b @@ -282,8 +282,8 @@ def test_subscript_setitem(): return t def test_dict(): - dict = {"a": 1, "b": 2} - return dict + ret = {"a": 1, "b": 2} + return ret def func_call(x, y, *var, a=0, b=1, **kwargs): return x + y + var[0] + a + b + kwargs["z"] diff --git a/tests/ut/cpp/python_input/gtest_input/session/session_test.py b/tests/ut/cpp/python_input/gtest_input/session/session_test.py index ee034a1ae01d2f6a326676d4518c15fe22971659..3ee0415fc5b2edf8bfd82a78a2847d374766a1d4 100644 --- a/tests/ut/cpp/python_input/gtest_input/session/session_test.py +++ b/tests/ut/cpp/python_input/gtest_input/session/session_test.py @@ -25,13 +25,13 @@ tuple_getitem = Primitive('tuple_getitem') max_pool = P.MaxPoolWithArgmax(padding="same", ksize=3, strides=2) def test_addn_cast(x, y, z): - sum = addn((x, y)) - res = cast(sum, ms.float16) + mysum = addn((x, y)) + res = cast(mysum, ms.float16) return res def test_addn_with_max_pool(x, y): - sum = addn((x, y)) - output = max_pool(sum) + mysum = addn((x, y)) + output = max_pool(mysum) res = tuple_getitem(output, 0) return res @@ -43,6 +43,6 @@ def test_shape_add(x1, x2, y1, y2, z1, z2): reshape_sum1 = reshape(sum1, (2, 2, 3, 1)) reshape_sum2 = reshape(sum2, (2, 2, 3, 1)) reshape_sum3 = reshape(sum3, (2, 2, 3, 1)) - sum = add(reshape_sum1, reshape_sum2) - sum = add(sum, reshape_sum3) - return sum + mysum = add(reshape_sum1, reshape_sum2) + mysum = add(mysum, reshape_sum3) + return mysum diff --git a/tests/ut/python/pipeline/infer/test_range.py b/tests/ut/python/pipeline/infer/test_range.py index 29070e228adac87c4fb58be68d09946c5386029b..646740e902b510ddbaeb5f65a4ec9bc94f32056a 100644 --- a/tests/ut/python/pipeline/infer/test_range.py +++ b/tests/ut/python/pipeline/infer/test_range.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.common.api import ms_function import numpy as np from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.ops import operations as P diff --git a/tests/ut/python/pipeline/parse/test_dtype.py b/tests/ut/python/pipeline/parse/test_dtype.py index 645eba8004e2652d9a3ff62691b342bea45e3c1c..2f0311118945e58fa4e2dfb2037fb3f3f50ca67f 100644 --- a/tests/ut/python/pipeline/parse/test_dtype.py +++ b/tests/ut/python/pipeline/parse/test_dtype.py @@ -13,7 +13,6 @@ # limitations under the License. # ============================================================================ """ test_dtype """ -import pytest from mindspore._c_expression import typing from mindspore.common.api import ms_function diff --git a/tests/ut/python/pipeline/parse/test_graph_return_const_param.py b/tests/ut/python/pipeline/parse/test_graph_return_const_param.py index 495519b1a512bcdb7d8a2756ac4665a7ad33a4b6..d12e99b7b62e25dc05461c89bdaea6a964849f2e 100644 --- a/tests/ut/python/pipeline/parse/test_graph_return_const_param.py +++ b/tests/ut/python/pipeline/parse/test_graph_return_const_param.py @@ -19,8 +19,6 @@ import mindspore.nn as nn from mindspore import context import mindspore.common.dtype as mstype from mindspore.common.tensor import Tensor -from mindspore.common.parameter import Parameter -from mindspore.common.api import ms_function context.set_context(mode=context.GRAPH_MODE) diff --git a/tests/ut/python/pipeline/parse/test_operator.py b/tests/ut/python/pipeline/parse/test_operator.py index 19d70b20a157e73a9fb464ebeda54de451e131b2..5356fb176fe2025dcd752ebc42d6b517ccf2b11f 100644 --- a/tests/ut/python/pipeline/parse/test_operator.py +++ b/tests/ut/python/pipeline/parse/test_operator.py @@ -200,6 +200,3 @@ def test_in_dict(): z = Tensor(np.random.randint(low=20, high=30, size=(2, 3, 4), dtype=np.int32)) context.set_context(mode=context.GRAPH_MODE) net(x, y, z) - - - diff --git a/tests/ut/python/pynative_mode/ge/ops/test_tensor_add.py b/tests/ut/python/pynative_mode/ge/ops/test_tensor_add.py index 8bde09e02d1f016b2b0a7aac78d7e457b7a2ce43..0ea463c8486c8f31ca659f611b80c2c476590b6c 100644 --- a/tests/ut/python/pynative_mode/ge/ops/test_tensor_add.py +++ b/tests/ut/python/pynative_mode/ge/ops/test_tensor_add.py @@ -38,5 +38,5 @@ def test_tensor_orign_ops(): assert np.all(z.asnumpy() - (x.asnumpy() + y.asnumpy()) < 0.0001) z = x * y assert np.all(z.asnumpy() - (x.asnumpy() * y.asnumpy()) < 0.0001) - assert (x == y) - assert (x != 'zero') + assert x == y + assert x != 'zero' diff --git a/tests/ut/python/pynative_mode/nn/test_cell.py b/tests/ut/python/pynative_mode/nn/test_cell.py index 2d5196b80d8c5ca87631669913d557fd63362366..be56b99cd8b3e6e7d1c4f39cd1be78b1c3aa5d15 100644 --- a/tests/ut/python/pynative_mode/nn/test_cell.py +++ b/tests/ut/python/pynative_mode/nn/test_cell.py @@ -297,4 +297,3 @@ def test_net_call(): input_x = Tensor( np.random.randint(0, 255, [1, 3, net.image_h, net.image_w]).astype(np.float32)) output = net.construct(input_x) - diff --git a/tests/ut/python/pynative_mode/nn/test_dropout.py b/tests/ut/python/pynative_mode/nn/test_dropout.py index ef026b5fc83060a9ce7cd633cfe10a02b416f418..cea530db41dd5dd6b9abd3c9bbe23a647b3f9f94 100644 --- a/tests/ut/python/pynative_mode/nn/test_dropout.py +++ b/tests/ut/python/pynative_mode/nn/test_dropout.py @@ -14,7 +14,6 @@ # ============================================================================ """ test_dropout """ import numpy as np -import pytest from mindspore.common.api import _executor import mindspore.nn as nn from mindspore import Tensor diff --git a/tests/ut/python/pynative_mode/nn/test_pooling.py b/tests/ut/python/pynative_mode/nn/test_pooling.py index f8df3ada3f24ec4e51395419f46bc6135be8106f..881685d8b6ed37959e7c6525b27f6ab915255cf9 100644 --- a/tests/ut/python/pynative_mode/nn/test_pooling.py +++ b/tests/ut/python/pynative_mode/nn/test_pooling.py @@ -57,6 +57,3 @@ def test_maxpool2d(): output = max_pool(input_data) output_np = output.asnumpy() assert isinstance(output_np[0][0][0][0], (np.float32, np.float64)) - - - diff --git a/tests/ut/python/pynative_mode/ops/test_grad.py b/tests/ut/python/pynative_mode/ops/test_grad.py index b927da5b04f30e68d0a33a9288595a63bb513c21..b4c87389c49114adf13b7e80253e8b9cb0e4f642 100644 --- a/tests/ut/python/pynative_mode/ops/test_grad.py +++ b/tests/ut/python/pynative_mode/ops/test_grad.py @@ -20,7 +20,6 @@ from mindspore import Tensor from mindspore.ops import composite as C from mindspore.ops.composite import grad_all_with_sens from mindspore.common.dtype import get_py_obj_dtype -import mindspore.nn as nn import mindspore.ops.operations as P from mindspore.ops import functional as F from ...ut_filter import non_graph_engine @@ -174,7 +173,7 @@ def test_select_grad(): assert np.all(gout[0].asnumpy() == expect_cond) assert np.all(gout[1].asnumpy() == expect_x) assert np.all(gout[2].asnumpy() == expect_y) - + def test_SubGrad(): """ test_SubGrad """ @@ -201,10 +200,10 @@ def test_MulGrad(): """ test_MulGrad """ input_x = Tensor(np.array([[2, 2], [2, 2]], np.float32)) input_y = Tensor(np.array([[3, 3], [3, 3]], np.float32)) - mul = P.Mul() + mymul = P.Mul() def fn(x, y): - output = mul(x, y) + output = mymul(x, y) return output out = fn(input_x, input_y) diff --git a/tests/ut/python/pynative_mode/ops/test_hypermap.py b/tests/ut/python/pynative_mode/ops/test_hypermap.py index 1744555327a9f0d07c6c08dae1f5ac8b2535b35b..141490da8abe6786124d8b7911ae5c1250b49b90 100644 --- a/tests/ut/python/pynative_mode/ops/test_hypermap.py +++ b/tests/ut/python/pynative_mode/ops/test_hypermap.py @@ -17,7 +17,6 @@ import numpy as np from mindspore.common.api import ms_function from mindspore import Tensor -from mindspore import context from mindspore.ops import Primitive from mindspore.ops import composite as C from mindspore.ops import operations as P diff --git a/tests/ut/python/pynative_mode/test_bprop.py b/tests/ut/python/pynative_mode/test_bprop.py index c8360d6c96e056b72a4bf54447d86078deb99852..dfe84f817362d154da44adf4c44cbccc622c6310 100644 --- a/tests/ut/python/pynative_mode/test_bprop.py +++ b/tests/ut/python/pynative_mode/test_bprop.py @@ -19,8 +19,8 @@ from mindspore import context from mindspore.ops import operations as P from mindspore.common.parameter import Parameter from mindspore.common import Tensor -from ....mindspore_test_framework.utils.bprop_util import bprop from mindspore.common.api import ms_function +from ....mindspore_test_framework.utils.bprop_util import bprop def setup_module(module): context.set_context(mode=context.PYNATIVE_MODE) diff --git a/tests/ut/python/pynative_mode/test_cell_bprop.py b/tests/ut/python/pynative_mode/test_cell_bprop.py index bd9f46d21d12a9bf568dc7305ab7ba9b6e4b98f9..d170e7fdea11a0b1de3675dd3ae0fdc601a931de 100644 --- a/tests/ut/python/pynative_mode/test_cell_bprop.py +++ b/tests/ut/python/pynative_mode/test_cell_bprop.py @@ -88,7 +88,7 @@ class WithNoBprop(nn.Cell): def test_with_no_bprop(): with_no_bprop = WithNoBprop() - C.grad_all(with_no_bprop)(1, 2) == (2, 1) + assert C.grad_all(with_no_bprop)(1, 2) == (2, 1) def test_grad_in_bprop_1(): class GradInBprop_1(nn.Cell): @@ -189,8 +189,8 @@ class OneInputBprop(nn.Cell): def test_grad_one_input_bprop(): net = OneInputBprop() - input = Tensor(np.ones([2, 2]).astype(np.float32)) - grad = C.grad_all(net)(input) + input1 = Tensor(np.ones([2, 2]).astype(np.float32)) + grad = C.grad_all(net)(input1) assert (grad[0].asnumpy() == np.array([5, 5]).astype(np.float32)).all() diff --git a/tests/ut/python/pynative_mode/test_context.py b/tests/ut/python/pynative_mode/test_context.py index 4b002eb0c819336c630e01219f1d73a162a7208f..cece0c14514604d376313cfc448ba1a21b2aa533 100644 --- a/tests/ut/python/pynative_mode/test_context.py +++ b/tests/ut/python/pynative_mode/test_context.py @@ -68,9 +68,9 @@ def test_dump_target(): with pytest.raises(TypeError): context.set_context(save_dump_path=1) context.set_context(enable_dump=False) - assert context.get_context("enable_dump") == False + assert not context.get_context("enable_dump") context.set_context(enable_dump=True) - assert context.get_context("enable_dump") == True + assert context.get_context("enable_dump") assert context.get_context("save_dump_path") == "." diff --git a/tests/ut/python/pynative_mode/test_framstruct.py b/tests/ut/python/pynative_mode/test_framstruct.py index 355ce85bb9bef88d1385d953b2f56ab34fc9f458..1b9c13646a63953506b921fbd36c2d8ab1b2ccb1 100644 --- a/tests/ut/python/pynative_mode/test_framstruct.py +++ b/tests/ut/python/pynative_mode/test_framstruct.py @@ -15,23 +15,17 @@ """ test_framstruct """ import pytest import numpy as np -import mindspore as ms import mindspore.nn as nn from mindspore import context from mindspore.ops import composite as C from mindspore.ops import operations as P from mindspore.common.tensor import Tensor from mindspore.common.parameter import Parameter, ParameterTuple -from mindspore.common.initializer import initializer from mindspore.common import dtype as mstype -import mindspore.nn as nn -from mindspore.nn.wrap.cell_wrapper import WithGradCell, WithLossCell from ..ut_filter import non_graph_engine from ....mindspore_test_framework.utils.check_gradient import ( ms_function, check_jacobian, Tensor, NNGradChecker, OperationGradChecker, check_gradient, ScalarGradChecker) -from ....mindspore_test_framework.utils.bprop_util import bprop -import mindspore.context as context from mindspore.ops._grad.grad_base import bprop_getters from mindspore.ops.primitive import prim_attr_register, PrimitiveWithInfer @@ -299,22 +293,22 @@ def test_dont_unroll_while(): assert res == 3 class ConvNet(nn.Cell): - def __init__(self): - super(ConvNet, self).__init__() - out_channel = 16 - kernel_size = 3 - self.conv = P.Conv2D(out_channel, - kernel_size, - mode=1, - pad_mode="pad", - pad=0, - stride=1, - dilation=2, - group=1) - self.w = Parameter(Tensor(np.ones([16, 16, 3, 3]).astype(np.float32)), name='w') - - def construct(self, x): - return self.conv(x, self.w) + def __init__(self): + super(ConvNet, self).__init__() + out_channel = 16 + kernel_size = 3 + self.conv = P.Conv2D(out_channel, + kernel_size, + mode=1, + pad_mode="pad", + pad=0, + stride=1, + dilation=2, + group=1) + self.w = Parameter(Tensor(np.ones([16, 16, 3, 3]).astype(np.float32)), name='w') + + def construct(self, x): + return self.conv(x, self.w) conv = ConvNet() c1 = Tensor([2], mstype.float32) @@ -674,7 +668,7 @@ def grad_refactor_6(a, b): def test_grad_refactor_6(): - C.grad_all(grad_refactor_6)(3, 2) == (3, 1) + assert C.grad_all(grad_refactor_6)(3, 2) == (3, 1) def grad_refactor_while(x):