diff --git a/tests/dataset_mock.py b/tests/dataset_mock.py index c5668facdc0..237e38a9d31 100644 --- a/tests/dataset_mock.py +++ b/tests/dataset_mock.py @@ -14,6 +14,7 @@ # ============================================================================ '''Remove after MindData merge to MindSpore ''' import numpy as np + from mindspore import Tensor diff --git a/tests/mindspore_test_framework/apps/bert_attention_submodules.py b/tests/mindspore_test_framework/apps/bert_attention_submodules.py index 8a6de09d7f9..7e49ce43d14 100644 --- a/tests/mindspore_test_framework/apps/bert_attention_submodules.py +++ b/tests/mindspore_test_framework/apps/bert_attention_submodules.py @@ -19,13 +19,14 @@ import math import numpy as np + import mindspore.common.dtype as mstype import mindspore.ops.functional as F from mindspore import nn from mindspore.common.initializer import TruncatedNormal -from mindspore.ops import operations as P from mindspore.common.tensor import Tensor from mindspore.model_zoo.Bert_NEZHA.bert_model import SaturateCast, RelaPosEmbeddingsGenerator +from mindspore.ops import operations as P class BertAttentionQueryKeyMul(nn.Cell): diff --git a/tests/mindspore_test_framework/apps/test_bert_check_gradient.py b/tests/mindspore_test_framework/apps/test_bert_check_gradient.py index f404f9f81db..fac20be48d8 100644 --- a/tests/mindspore_test_framework/apps/test_bert_check_gradient.py +++ b/tests/mindspore_test_framework/apps/test_bert_check_gradient.py @@ -17,22 +17,19 @@ import numpy as np +import mindspore.common.dtype as mstype +from mindspore import context, nn from mindspore.model_zoo.Bert_NEZHA import GetNextSentenceOutput, BertNetworkWithLoss from mindspore.model_zoo.Bert_NEZHA.bert_model import BertConfig, \ EmbeddingLookup, EmbeddingPostprocessor, BertOutput, \ BertAttention, BertSelfAttention, SaturateCast, TruncatedNormal, \ BertEncoderCell, BertTransformer, CreateAttentionMaskFromInputMask, BertModel - -from mindspore import context, nn -import mindspore.common.dtype as mstype - +from .bert_attention_submodules import BertAttentionQueryKeyMul, BertAttentionRelativePositionKeys, \ + BertAttentionMaskBackward, BertAttentionSoftmax, BertAttentionRelativePositionValues, BertDense +from ..mindspore_test import mindspore_test from ..pipeline.gradient.compare_gradient import \ pipeline_for_compare_inputs_grad_with_numerical_diff_for_group_by_group_config, \ pipeline_for_compare_params_grad_with_numerical_diff_for_group_by_group_config -from ..mindspore_test import mindspore_test - -from .bert_attention_submodules import BertAttentionQueryKeyMul, BertAttentionRelativePositionKeys, \ - BertAttentionMaskBackward, BertAttentionSoftmax, BertAttentionRelativePositionValues, BertDense verification_set = { 'inputs': [ diff --git a/tests/mindspore_test_framework/apps/test_bert_compare_with_npy.py b/tests/mindspore_test_framework/apps/test_bert_compare_with_npy.py index 99cc588c86b..f003164a6bb 100644 --- a/tests/mindspore_test_framework/apps/test_bert_compare_with_npy.py +++ b/tests/mindspore_test_framework/apps/test_bert_compare_with_npy.py @@ -16,6 +16,7 @@ """Test bert compare with npy.""" import numpy as np + import mindspore.common.dtype as mstype from mindspore import context from mindspore.model_zoo.Bert_NEZHA.bert_model import BertAttention, SaturateCast, \ @@ -25,12 +26,11 @@ from mindspore.model_zoo.Bert_NEZHA.bert_model import BertAttention, SaturateCas BertSelfAttention, CreateAttentionMaskFromInputMask, \ RelaPosMatrixGenerator, BertOutput, \ RelaPosEmbeddingsGenerator - +from .bert_attention_submodules import BertAttentionQueryKeyMul, BertAttentionRelativePositionKeys, BertAttentionMask, \ + BertAttentionSoftmax, BertAttentionRelativePositionValues, BertDense from ..mindspore_test import mindspore_test from ..pipeline.forward.compare_forward import \ pipeline_for_compare_forward_with_npy_for_group_by_group_config_using_group_policy -from .bert_attention_submodules import BertAttentionQueryKeyMul, BertAttentionRelativePositionKeys, BertAttentionMask, \ - BertAttentionSoftmax, BertAttentionRelativePositionValues, BertDense verification_set = { 'inputs': [ diff --git a/tests/mindspore_test_framework/apps/test_bert_ops_check_gradient.py b/tests/mindspore_test_framework/apps/test_bert_ops_check_gradient.py index 58d44ba8566..312ebc34973 100644 --- a/tests/mindspore_test_framework/apps/test_bert_ops_check_gradient.py +++ b/tests/mindspore_test_framework/apps/test_bert_ops_check_gradient.py @@ -17,11 +17,10 @@ from mindspore import context from mindspore.ops import operations as P - +from ..mindspore_test import mindspore_test from ..pipeline.gradient.compare_gradient import \ pipeline_for_compare_inputs_grad_with_numerical_diff_for_group_by_group_config, \ pipeline_for_compare_inputs_jacobian_with_numerical_diff_for_group_by_group_config -from ..mindspore_test import mindspore_test # from ...vm_impl import * diff --git a/tests/mindspore_test_framework/apps/test_bert_parts.py b/tests/mindspore_test_framework/apps/test_bert_parts.py index dcc679b5288..c45e4b2ab73 100644 --- a/tests/mindspore_test_framework/apps/test_bert_parts.py +++ b/tests/mindspore_test_framework/apps/test_bert_parts.py @@ -15,20 +15,20 @@ """Test bert submodules.""" -import os import numpy as np +import os + +from mindspore import Tensor +from mindspore import nn, context from mindspore.model_zoo.Bert_NEZHA import EmbeddingLookup, GetMaskedLMOutput, \ BertConfig, BertPreTraining, BertNetworkWithLoss from mindspore.model_zoo.Bert_NEZHA.bert_model import BertModel - -from mindspore import nn, context -from mindspore import Tensor -from ..utils.block_util import get_output_cell from ..mindspore_test import mindspore_test from ..pipeline.forward.compile_forward import pipeline_for_compile_forward_anf_graph_for_case_by_case_config, \ pipeline_for_compile_forward_ge_graph_for_case_by_case_config from ..pipeline.gradient.compile_gradient import pipeline_for_compile_grad_anf_graph_for_case_by_case_config, \ pipeline_for_compile_grad_ge_graph_for_case_by_case_config +from ..utils.block_util import get_output_cell from ...dataset_mock import MindData # pylint: disable=missing-docstring, W0612, arguments-differ diff --git a/tests/mindspore_test_framework/apps/test_lamb_check_loss.py b/tests/mindspore_test_framework/apps/test_lamb_check_loss.py index c73a0d7e19a..44989596208 100644 --- a/tests/mindspore_test_framework/apps/test_lamb_check_loss.py +++ b/tests/mindspore_test_framework/apps/test_lamb_check_loss.py @@ -18,9 +18,9 @@ from mindspore import context from mindspore.nn.optim import Lamb from ..mindspore_test import mindspore_test +from ..pipeline.gradient.check_training import pipeline_for_check_model_loss_for_case_by_case_config from ..utils.model_util import Linreg from ..utils.model_util import SquaredLoss -from ..pipeline.gradient.check_training import pipeline_for_check_model_loss_for_case_by_case_config network = Linreg(2) num_epochs = 1000 diff --git a/tests/mindspore_test_framework/apps/test_reid_gradient_compare_with_pytorch.py b/tests/mindspore_test_framework/apps/test_reid_gradient_compare_with_pytorch.py index 9b87b77e805..46450d048cd 100644 --- a/tests/mindspore_test_framework/apps/test_reid_gradient_compare_with_pytorch.py +++ b/tests/mindspore_test_framework/apps/test_reid_gradient_compare_with_pytorch.py @@ -19,7 +19,6 @@ import numpy as np from mindspore import context from mindspore.ops import operations as P - from ..mindspore_test import mindspore_test from ..pipeline.gradient.compare_gradient import pipeline_for_compare_inputs_grad_with_npy_for_case_by_case_config from ...vm_impl import * diff --git a/tests/mindspore_test_framework/components/executor/check_exceptions.py b/tests/mindspore_test_framework/components/executor/check_exceptions.py index e466926ca81..450f95bc612 100644 --- a/tests/mindspore_test_framework/components/executor/check_exceptions.py +++ b/tests/mindspore_test_framework/components/executor/check_exceptions.py @@ -15,8 +15,8 @@ """Component that Check if the function raises the expected Exception.""" -import sys import pytest +import sys from ...components.icomponent import IExectorComponent from ...utils import keyword diff --git a/tests/mindspore_test_framework/components/executor/exec_and_verify_model_loss.py b/tests/mindspore_test_framework/components/executor/exec_and_verify_model_loss.py index 1f5ae7dd584..19a559cd67c 100644 --- a/tests/mindspore_test_framework/components/executor/exec_and_verify_model_loss.py +++ b/tests/mindspore_test_framework/components/executor/exec_and_verify_model_loss.py @@ -16,8 +16,8 @@ """Component that verify if the model can converge to expected loss.""" from ...components.icomponent import IExectorComponent -from ...utils.model_util import Model from ...utils import keyword +from ...utils.model_util import Model class LossVerifierEC(IExectorComponent): diff --git a/tests/mindspore_test_framework/components/facade/me_facade.py b/tests/mindspore_test_framework/components/facade/me_facade.py index 457037509e6..7545afcb4f3 100644 --- a/tests/mindspore_test_framework/components/facade/me_facade.py +++ b/tests/mindspore_test_framework/components/facade/me_facade.py @@ -18,8 +18,8 @@ import numpy as np from ...components.icomponent import IFacadeComponent -from ...utils.facade_util import get_block_config, fill_block_config from ...utils import keyword +from ...utils.facade_util import get_block_config, fill_block_config class MeFacadeFC(IFacadeComponent): diff --git a/tests/mindspore_test_framework/components/inputs/generate_dataset_for_linear_regression.py b/tests/mindspore_test_framework/components/inputs/generate_dataset_for_linear_regression.py index 0d7de396a8a..52d437346ec 100644 --- a/tests/mindspore_test_framework/components/inputs/generate_dataset_for_linear_regression.py +++ b/tests/mindspore_test_framework/components/inputs/generate_dataset_for_linear_regression.py @@ -16,8 +16,8 @@ """Component that generate dataset for linear regression.""" from ...components.icomponent import IDataComponent -from ...utils.dataset_util import generate_dataset_for_linear_regression from ...utils import keyword +from ...utils.dataset_util import generate_dataset_for_linear_regression class GenerateDataSetForLRDC(IDataComponent): diff --git a/tests/mindspore_test_framework/components/inputs/generate_inputs_from_shape.py b/tests/mindspore_test_framework/components/inputs/generate_inputs_from_shape.py index cb725ca6482..4a5ea464dcd 100644 --- a/tests/mindspore_test_framework/components/inputs/generate_inputs_from_shape.py +++ b/tests/mindspore_test_framework/components/inputs/generate_inputs_from_shape.py @@ -16,12 +16,12 @@ """Component that generate inputs for specified shape type.""" import numpy as np -from mindspore.common.tensor import Tensor +from mindspore.common.tensor import Tensor from ...components.icomponent import IDataComponent -from ...utils.other_util import shape2tensor -from ...utils.config_util import get_input_config from ...utils import keyword +from ...utils.config_util import get_input_config +from ...utils.other_util import shape2tensor class GenerateFromShapeDC(IDataComponent): diff --git a/tests/mindspore_test_framework/components/inputs/load_inputs_from_npy.py b/tests/mindspore_test_framework/components/inputs/load_inputs_from_npy.py index 4e3b6b0ec62..78afd79c6d8 100644 --- a/tests/mindspore_test_framework/components/inputs/load_inputs_from_npy.py +++ b/tests/mindspore_test_framework/components/inputs/load_inputs_from_npy.py @@ -16,8 +16,8 @@ """Component that load inputs from npy file.""" from ...components.icomponent import IDataComponent -from ...utils.npy_util import load_data_from_npy_or_shape from ...utils import keyword +from ...utils.npy_util import load_data_from_npy_or_shape class LoadFromNpyDC(IDataComponent): diff --git a/tests/mindspore_test_framework/components/verifier/compare_forward.py b/tests/mindspore_test_framework/components/verifier/compare_forward.py index 196fc263f8d..fe305952d9f 100644 --- a/tests/mindspore_test_framework/components/verifier/compare_forward.py +++ b/tests/mindspore_test_framework/components/verifier/compare_forward.py @@ -16,8 +16,8 @@ """Component that comparing forward result with baseline functions.""" from ...components.icomponent import IVerifierComponent -from ...utils.compare_util import compare from ...utils import keyword +from ...utils.compare_util import compare class CompareWithVC(IVerifierComponent): diff --git a/tests/mindspore_test_framework/components/verifier/compare_gradient.py b/tests/mindspore_test_framework/components/verifier/compare_gradient.py index 45f39d3d420..2c53b30f35d 100644 --- a/tests/mindspore_test_framework/components/verifier/compare_gradient.py +++ b/tests/mindspore_test_framework/components/verifier/compare_gradient.py @@ -16,8 +16,8 @@ """Component that comparing gradients with baseline functions.""" from ...components.icomponent import IVerifierComponent -from ...utils.compare_util import compare from ...utils import keyword +from ...utils.compare_util import compare class CompareGradientWithVC(IVerifierComponent): diff --git a/tests/mindspore_test_framework/components/verifier/verify_expect_from_npy.py b/tests/mindspore_test_framework/components/verifier/verify_expect_from_npy.py index e4523fdaf9c..5deb9c95f71 100644 --- a/tests/mindspore_test_framework/components/verifier/verify_expect_from_npy.py +++ b/tests/mindspore_test_framework/components/verifier/verify_expect_from_npy.py @@ -16,11 +16,12 @@ """Component that comparing results with expectation serialized as npy file.""" import numpy as np + from ...components.icomponent import IVerifierComponent -from ...utils.other_util import to_numpy_list, to_numpy -from ...utils.npy_util import load_data_from_npy_or_shape -from ...utils.verifier_util import tolerance_assert from ...utils import keyword +from ...utils.npy_util import load_data_from_npy_or_shape +from ...utils.other_util import to_numpy_list, to_numpy +from ...utils.verifier_util import tolerance_assert class LoadFromNpyVC(IVerifierComponent): diff --git a/tests/mindspore_test_framework/components/verifier/verify_shapetype.py b/tests/mindspore_test_framework/components/verifier/verify_shapetype.py index bf6548197b1..97e5863a7ad 100644 --- a/tests/mindspore_test_framework/components/verifier/verify_shapetype.py +++ b/tests/mindspore_test_framework/components/verifier/verify_shapetype.py @@ -16,8 +16,8 @@ """Component that verify shape and type.""" from ...components.icomponent import IVerifierComponent -from ...utils.other_util import to_numpy_list from ...utils import keyword +from ...utils.other_util import to_numpy_list class ShapeTypeVC(IVerifierComponent): diff --git a/tests/mindspore_test_framework/mindspore_test.py b/tests/mindspore_test_framework/mindspore_test.py index 0413d20c961..7a310ffdf52 100644 --- a/tests/mindspore_test_framework/mindspore_test.py +++ b/tests/mindspore_test_framework/mindspore_test.py @@ -17,6 +17,7 @@ import logging import pytest + from .components.icomponent import IDataComponent, IBuilderComponent, IExectorComponent, \ IVerifierComponent, IFIPolicyComponent, IERPolicyComponent, IComponent, \ IFacadeComponent diff --git a/tests/mindspore_test_framework/pipeline/forward/compare_forward.py b/tests/mindspore_test_framework/pipeline/forward/compare_forward.py index 184e99dccd8..485af12c150 100644 --- a/tests/mindspore_test_framework/pipeline/forward/compare_forward.py +++ b/tests/mindspore_test_framework/pipeline/forward/compare_forward.py @@ -15,18 +15,18 @@ """Pipelines for forward comparison.""" -from ...components.expect_result_policy.cartesian_product_on_id_for_expect_result import IdCartesianProductERPC -from ...components.function_inputs_policy.cartesian_product_on_id_for_function_inputs import IdCartesianProductFIPC from ...components.executor.exec_forward import IdentityEC -from ...components.function.run_block import RunBlockBC -from ...components.inputs.generate_inputs_from_shape import GenerateFromShapeDC -from ...components.verifier.compare_forward import CompareWithVC +from ...components.expect_result_policy.cartesian_product_on_id_for_expect_result import IdCartesianProductERPC from ...components.facade.me_facade import MeFacadeFC -from ...components.inputs.load_inputs_from_npy import LoadFromNpyDC -from ...components.verifier.verify_expect_from_npy import LoadFromNpyVC from ...components.function.init_params_with_rand_and_run_block import RunBlockWithRandParamBC +from ...components.function.run_block import RunBlockBC from ...components.function_inputs_policy.cartesian_product_on_group_for_function_inputs import \ GroupCartesianProductFIPC +from ...components.function_inputs_policy.cartesian_product_on_id_for_function_inputs import IdCartesianProductFIPC +from ...components.inputs.generate_inputs_from_shape import GenerateFromShapeDC +from ...components.inputs.load_inputs_from_npy import LoadFromNpyDC +from ...components.verifier.compare_forward import CompareWithVC +from ...components.verifier.verify_expect_from_npy import LoadFromNpyVC # pylint: disable=W0105 """ diff --git a/tests/mindspore_test_framework/pipeline/forward/compile_forward.py b/tests/mindspore_test_framework/pipeline/forward/compile_forward.py index a103f3d5fc5..467d1072009 100644 --- a/tests/mindspore_test_framework/pipeline/forward/compile_forward.py +++ b/tests/mindspore_test_framework/pipeline/forward/compile_forward.py @@ -15,13 +15,13 @@ """Pipelines for forward computing.""" -from ...components.facade.me_facade import MeFacadeFC -from ...components.inputs.generate_inputs_from_shape import GenerateFromShapeDC -from ...components.executor.exec_forward import IdentityEC from ...components.executor.check_exceptions import CheckExceptionsEC -from ...components.function_inputs_policy.cartesian_product_on_id_for_function_inputs import IdCartesianProductFIPC +from ...components.executor.exec_forward import IdentityEC +from ...components.facade.me_facade import MeFacadeFC from ...components.function.compile_block import CompileBlockBC from ...components.function.run_block import RunBlockBC +from ...components.function_inputs_policy.cartesian_product_on_id_for_function_inputs import IdCartesianProductFIPC +from ...components.inputs.generate_inputs_from_shape import GenerateFromShapeDC # pylint: disable=W0105 """ diff --git a/tests/mindspore_test_framework/pipeline/forward/verify_exception.py b/tests/mindspore_test_framework/pipeline/forward/verify_exception.py index ac7261a5bf9..ee9e3d4a0d7 100644 --- a/tests/mindspore_test_framework/pipeline/forward/verify_exception.py +++ b/tests/mindspore_test_framework/pipeline/forward/verify_exception.py @@ -16,10 +16,10 @@ """Pipelines for exception checking.""" from ...components.executor.check_exceptions import CheckExceptionsEC -from ...components.inputs.get_inputs_from_config import IdentityDC -from ...components.function.get_function_from_config import IdentityBC from ...components.facade.me_facade import MeFacadeFC +from ...components.function.get_function_from_config import IdentityBC from ...components.function_inputs_policy.cartesian_product_on_id_for_function_inputs import IdCartesianProductFIPC +from ...components.inputs.get_inputs_from_config import IdentityDC # pylint: disable=W0105 """ diff --git a/tests/mindspore_test_framework/pipeline/forward/verify_shapetype.py b/tests/mindspore_test_framework/pipeline/forward/verify_shapetype.py index 79890bf506d..ad297ea1f65 100644 --- a/tests/mindspore_test_framework/pipeline/forward/verify_shapetype.py +++ b/tests/mindspore_test_framework/pipeline/forward/verify_shapetype.py @@ -15,13 +15,13 @@ """Pipelines for shape and type checking.""" -from ...components.inputs.get_inputs_from_config import IdentityDC -from ...components.function.get_function_from_config import IdentityBC from ...components.executor.exec_forward import IdentityEC from ...components.expect_result_policy.cartesian_product_on_group_for_expect_result \ import GroupCartesianProductERPC +from ...components.function.get_function_from_config import IdentityBC from ...components.function_inputs_policy.cartesian_product_on_group_for_function_inputs \ import GroupCartesianProductFIPC +from ...components.inputs.get_inputs_from_config import IdentityDC from ...components.verifier.verify_shapetype import ShapeTypeVC # pylint: disable=W0105 diff --git a/tests/mindspore_test_framework/pipeline/gradient/check_training.py b/tests/mindspore_test_framework/pipeline/gradient/check_training.py index 6ad36af9c36..135b162ec77 100644 --- a/tests/mindspore_test_framework/pipeline/gradient/check_training.py +++ b/tests/mindspore_test_framework/pipeline/gradient/check_training.py @@ -15,11 +15,11 @@ """Pipelines for loss checking.""" -from ...components.function_inputs_policy.cartesian_product_on_id_for_function_inputs import IdCartesianProductFIPC +from ...components.executor.exec_and_verify_model_loss import LossVerifierEC from ...components.facade.me_facade import MeFacadeFC from ...components.function.get_function_from_config import IdentityBC +from ...components.function_inputs_policy.cartesian_product_on_id_for_function_inputs import IdCartesianProductFIPC from ...components.inputs.generate_dataset_for_linear_regression import GenerateDataSetForLRDC -from ...components.executor.exec_and_verify_model_loss import LossVerifierEC # pylint: disable=W0105 """ diff --git a/tests/mindspore_test_framework/pipeline/gradient/compare_gradient.py b/tests/mindspore_test_framework/pipeline/gradient/compare_gradient.py index f6ff1322941..53483f3876a 100644 --- a/tests/mindspore_test_framework/pipeline/gradient/compare_gradient.py +++ b/tests/mindspore_test_framework/pipeline/gradient/compare_gradient.py @@ -15,20 +15,20 @@ """Pipelines for gradients comparison.""" -from ...components.expect_result_policy.cartesian_product_on_id_for_expect_result import IdCartesianProductERPC -from ...components.function_inputs_policy.cartesian_product_on_id_for_function_inputs import IdCartesianProductFIPC -from ...components.executor.exec_gradient import IdentityBackwardEC -from ...components.function.run_gradient_wrt_inputs import RunBackwardBlockWrtInputsBC -from ...components.function.run_gradient_wrt_params import RunBackwardBlockWrtParamsBC -from ...components.inputs.generate_inputs_from_shape import GenerateFromShapeDC -from ...components.verifier.compare_gradient import CompareGradientWithVC -from ...components.facade.me_facade import MeFacadeFC -from ...components.inputs.load_inputs_from_npy import LoadFromNpyDC -from ...components.verifier.verify_expect_from_npy import LoadFromNpyVC -from ...components.function.get_function_from_config import IdentityBC from ...components.executor.check_gradient_wrt_inputs import CheckGradientWrtInputsEC from ...components.executor.check_gradient_wrt_params import CheckGradientWrtParamsEC from ...components.executor.check_jacobian_wrt_inputs import CheckJacobianWrtInputsEC +from ...components.executor.exec_gradient import IdentityBackwardEC +from ...components.expect_result_policy.cartesian_product_on_id_for_expect_result import IdCartesianProductERPC +from ...components.facade.me_facade import MeFacadeFC +from ...components.function.get_function_from_config import IdentityBC +from ...components.function.run_gradient_wrt_inputs import RunBackwardBlockWrtInputsBC +from ...components.function.run_gradient_wrt_params import RunBackwardBlockWrtParamsBC +from ...components.function_inputs_policy.cartesian_product_on_id_for_function_inputs import IdCartesianProductFIPC +from ...components.inputs.generate_inputs_from_shape import GenerateFromShapeDC +from ...components.inputs.load_inputs_from_npy import LoadFromNpyDC +from ...components.verifier.compare_gradient import CompareGradientWithVC +from ...components.verifier.verify_expect_from_npy import LoadFromNpyVC # pylint: disable=W0105 """ diff --git a/tests/mindspore_test_framework/pipeline/gradient/compile_gradient.py b/tests/mindspore_test_framework/pipeline/gradient/compile_gradient.py index 95219a71fd2..2ce6160152d 100644 --- a/tests/mindspore_test_framework/pipeline/gradient/compile_gradient.py +++ b/tests/mindspore_test_framework/pipeline/gradient/compile_gradient.py @@ -15,12 +15,12 @@ """Pipelines for gradients.""" -from ...components.facade.me_facade import MeFacadeFC -from ...components.inputs.generate_inputs_from_shape import GenerateFromShapeDC from ...components.executor.exec_gradient import IdentityBackwardEC -from ...components.function_inputs_policy.cartesian_product_on_id_for_function_inputs import IdCartesianProductFIPC +from ...components.facade.me_facade import MeFacadeFC from ...components.function.compile_gradient_wrt_inputs import CompileBackwardBlockWrtInputsBC from ...components.function.run_gradient_wrt_inputs import RunBackwardBlockWrtInputsBC +from ...components.function_inputs_policy.cartesian_product_on_id_for_function_inputs import IdCartesianProductFIPC +from ...components.inputs.generate_inputs_from_shape import GenerateFromShapeDC # pylint: disable=W0105 """ diff --git a/tests/mindspore_test_framework/utils/block_util.py b/tests/mindspore_test_framework/utils/block_util.py index 3ff6d27c142..faf7143f4b7 100644 --- a/tests/mindspore_test_framework/utils/block_util.py +++ b/tests/mindspore_test_framework/utils/block_util.py @@ -19,13 +19,13 @@ import numpy as np +from mindspore import ParameterTuple +from mindspore import nn, context from mindspore.common.api import _executor, ms_function from mindspore.common.tensor import Tensor -from mindspore import nn, context -from mindspore.ops.composite import GradOperation from mindspore.ops import functional as F from mindspore.ops import operations as P -from mindspore import ParameterTuple +from mindspore.ops.composite import GradOperation from . import keyword diff --git a/tests/mindspore_test_framework/utils/bprop_util.py b/tests/mindspore_test_framework/utils/bprop_util.py index a8831031903..1fbbd4dded2 100644 --- a/tests/mindspore_test_framework/utils/bprop_util.py +++ b/tests/mindspore_test_framework/utils/bprop_util.py @@ -15,11 +15,11 @@ """Utils for computing gradients.""" -from mindspore.ops.composite.base import GradOperation from mindspore import context -from mindspore.nn import Cell from mindspore.common import ParameterTuple from mindspore.common.api import ms_function +from mindspore.nn import Cell +from mindspore.ops.composite.base import GradOperation class Bprop(Cell): diff --git a/tests/mindspore_test_framework/utils/check_gradient.py b/tests/mindspore_test_framework/utils/check_gradient.py index 921c973c65f..660395e2986 100644 --- a/tests/mindspore_test_framework/utils/check_gradient.py +++ b/tests/mindspore_test_framework/utils/check_gradient.py @@ -16,14 +16,15 @@ """Implementation of Numerical gradients checking.""" # pylint: disable=missing-docstring -from typing import Callable, List, Any +import mindspore._c_expression as _c_expression import numpy as np -from mindspore import Tensor -from mindspore.ops.composite import GradOperation +from typing import Callable, List, Any + from mindspore import ParameterTuple +from mindspore import Tensor from mindspore import context from mindspore.common.api import ms_function -import mindspore._c_expression as _c_expression +from mindspore.ops.composite import GradOperation from .block_util import get_output_cell, gen_net, gen_grad_net, \ get_uniform_with_shape, set_block_phase, get_output_reduce_cell, set_block_param_with_rand diff --git a/tests/mindspore_test_framework/utils/compare_util.py b/tests/mindspore_test_framework/utils/compare_util.py index 2c13301a79a..84f259d95c8 100644 --- a/tests/mindspore_test_framework/utils/compare_util.py +++ b/tests/mindspore_test_framework/utils/compare_util.py @@ -16,8 +16,9 @@ """Utils for baseline comparison test.""" import numpy as np -from .other_util import to_numpy_list + from . import keyword +from .other_util import to_numpy_list def compare(expect, func_result, baseline): diff --git a/tests/mindspore_test_framework/utils/dataset_util.py b/tests/mindspore_test_framework/utils/dataset_util.py index 8953b5d81ad..334c7248f6a 100644 --- a/tests/mindspore_test_framework/utils/dataset_util.py +++ b/tests/mindspore_test_framework/utils/dataset_util.py @@ -15,8 +15,9 @@ """Dataset utils.""" -import random import numpy as np +import random + from mindspore import Tensor diff --git a/tests/mindspore_test_framework/utils/debug_util.py b/tests/mindspore_test_framework/utils/debug_util.py index 2aadb28cee8..ee826fa21a2 100644 --- a/tests/mindspore_test_framework/utils/debug_util.py +++ b/tests/mindspore_test_framework/utils/debug_util.py @@ -18,6 +18,7 @@ # pylint: disable=missing-docstring, unused-argument import logging + import mindspore.nn as nn from mindspore.ops import operations as P from mindspore.ops._grad.grad_base import bprop_getters diff --git a/tests/mindspore_test_framework/utils/model_util.py b/tests/mindspore_test_framework/utils/model_util.py index ca35fdb6809..674b4581ef6 100644 --- a/tests/mindspore_test_framework/utils/model_util.py +++ b/tests/mindspore_test_framework/utils/model_util.py @@ -18,11 +18,12 @@ # pylint: disable=arguments-differ import numpy as np -from mindspore import Parameter, ParameterTuple, Tensor + import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore.ops import functional as F +from mindspore import Parameter, ParameterTuple, Tensor from mindspore.ops import composite as C +from mindspore.ops import functional as F +from mindspore.ops import operations as P class SquaredLoss(nn.Cell): diff --git a/tests/mindspore_test_framework/utils/npy_util.py b/tests/mindspore_test_framework/utils/npy_util.py index b27b7575378..f3223b657f8 100644 --- a/tests/mindspore_test_framework/utils/npy_util.py +++ b/tests/mindspore_test_framework/utils/npy_util.py @@ -18,9 +18,8 @@ import numpy as np from mindspore.common.tensor import Tensor - -from .other_util import shape2tensor from .config_util import get_expect_config +from .other_util import shape2tensor def load_npy(p): diff --git a/tests/mindspore_test_framework/utils/other_util.py b/tests/mindspore_test_framework/utils/other_util.py index fb66519e5a2..1698eefd1df 100644 --- a/tests/mindspore_test_framework/utils/other_util.py +++ b/tests/mindspore_test_framework/utils/other_util.py @@ -15,9 +15,9 @@ """Other utils.""" +import mindspore._c_expression as _c_expression import numpy as np -import mindspore._c_expression as _c_expression from mindspore.common.tensor import Tensor diff --git a/tests/ops_common.py b/tests/ops_common.py index 7278d7da4f9..bd389cfafa1 100644 --- a/tests/ops_common.py +++ b/tests/ops_common.py @@ -14,6 +14,7 @@ # ============================================================================ """ test ops """ import numpy as np + import mindspore.nn as nn import mindspore.ops.composite as C import mindspore.ops.functional as F diff --git a/tests/perf_test/mindrecord/imagenet/perf_read_imagenet.py b/tests/perf_test/mindrecord/imagenet/perf_read_imagenet.py index f4ce3a904fa..54bb3b7c4b1 100644 --- a/tests/perf_test/mindrecord/imagenet/perf_read_imagenet.py +++ b/tests/perf_test/mindrecord/imagenet/perf_read_imagenet.py @@ -13,9 +13,8 @@ # limitations under the License. # ============================================================================ """test dataset performance about mindspore.MindDataset, mindspore.TFRecordDataset, tf.data.TFRecordDataset""" -import time - import tensorflow as tf +import time import mindspore.dataset as ds from mindspore.mindrecord import FileReader diff --git a/tests/st/auto_parallel/onehot_model_parallel.py b/tests/st/auto_parallel/onehot_model_parallel.py index 2931d6f0f89..d553bb15ee2 100644 --- a/tests/st/auto_parallel/onehot_model_parallel.py +++ b/tests/st/auto_parallel/onehot_model_parallel.py @@ -13,15 +13,16 @@ # limitations under the License. # ============================================================================ +import numpy as np import os import pytest -import numpy as np + import mindspore as ms +import mindspore.communication.management as distributedTool +import mindspore.context as context +from mindspore.common.tensor import Tensor from mindspore.nn import Cell from mindspore.ops import operations as P -from mindspore.common.tensor import Tensor -import mindspore.context as context -import mindspore.communication.management as distributedTool device_num = 2 device_id = int(os.getenv('DEVICE_ID')) diff --git a/tests/st/auto_parallel/soft_entropy_loss_expand_parallel.py b/tests/st/auto_parallel/soft_entropy_loss_expand_parallel.py index ee37fc921d6..b58e713a1de 100644 --- a/tests/st/auto_parallel/soft_entropy_loss_expand_parallel.py +++ b/tests/st/auto_parallel/soft_entropy_loss_expand_parallel.py @@ -13,22 +13,23 @@ # limitations under the License. # ============================================================================ +import numpy as np import os import pytest -import numpy as np -import mindspore as ms from numpy import allclose -from mindspore.nn import Cell -from mindspore import context -from mindspore.ops import operations as P -from mindspore.ops import functional as F -from mindspore.common.tensor import Tensor + +import mindspore as ms import mindspore.communication.management as distributedTool -from mindspore.common.parameter import ParameterTuple, Parameter -from mindspore.ops import composite as C +from mindspore import context from mindspore.common import dtype as mstype -from mindspore.train import Model, ParallelMode +from mindspore.common.parameter import ParameterTuple, Parameter +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell from mindspore.nn.optim.momentum import Momentum +from mindspore.ops import composite as C +from mindspore.ops import functional as F +from mindspore.ops import operations as P +from mindspore.train import Model, ParallelMode from mindspore.train.callback import Callback np.set_printoptions(threshold=np.inf) diff --git a/tests/st/auto_parallel/test_resnet50_expand_loss_2p.py b/tests/st/auto_parallel/test_resnet50_expand_loss_2p.py index c5c1f8c1fb9..cb03a5b0326 100644 --- a/tests/st/auto_parallel/test_resnet50_expand_loss_2p.py +++ b/tests/st/auto_parallel/test_resnet50_expand_loss_2p.py @@ -13,22 +13,23 @@ # limitations under the License. # ============================================================================ -import os import numpy as np +import os import pytest + +import mindspore.common.dtype as mstype import mindspore.context as context import mindspore.nn as nn -import mindspore.common.dtype as mstype -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.nn.optim.momentum import Momentum -from mindspore.common.initializer import One -from mindspore.train.model import Model, ParallelMode -from mindspore.communication.management import init import mindspore.ops.functional as F +from mindspore import Tensor +from mindspore.common.initializer import One +from mindspore.communication.management import init from mindspore.nn.loss.loss import _Loss -from mindspore.train.callback import Callback +from mindspore.nn.optim.momentum import Momentum +from mindspore.ops import operations as P from mindspore.parallel import set_algo_parameters +from mindspore.train.callback import Callback +from mindspore.train.model import Model, ParallelMode context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") context.set_context(device_id=int(os.getenv('DEVICE_ID'))) diff --git a/tests/st/control/test_cont_break.py b/tests/st/control/test_cont_break.py index dafac487c21..faced4e4264 100644 --- a/tests/st/control/test_cont_break.py +++ b/tests/st/control/test_cont_break.py @@ -13,10 +13,11 @@ # limitations under the License. # ============================================================================ """ test_cont_break """ -import pytest import numpy as np -from mindspore.nn import Cell +import pytest + from mindspore import Tensor, Model, context +from mindspore.nn import Cell def run_test(netclass, count, dev): diff --git a/tests/st/control/test_multigraph_sink.py b/tests/st/control/test_multigraph_sink.py index c34ba8ae788..1b48a1b905c 100644 --- a/tests/st/control/test_multigraph_sink.py +++ b/tests/st/control/test_multigraph_sink.py @@ -14,10 +14,11 @@ # ============================================================================ """ test_multigraph_sink """ import pytest + import mindspore.context as context -from mindspore.common.tensor import Tensor from mindspore.common import dtype as mstype from mindspore.common import ms_function +from mindspore.common.tensor import Tensor def setup_module(module): diff --git a/tests/st/control/test_while.py b/tests/st/control/test_while.py index 0e578764d40..f753052cf6a 100644 --- a/tests/st/control/test_while.py +++ b/tests/st/control/test_while.py @@ -13,6 +13,7 @@ # limitations under the License. # ============================================================================ import numpy as np + import mindspore.context as context import mindspore.nn as nn from mindspore import Tensor, ms_function diff --git a/tests/st/fusion/test_add_relu_buffer_fusion.py b/tests/st/fusion/test_add_relu_buffer_fusion.py index d63c8b355d2..4a428beaf0a 100644 --- a/tests/st/fusion/test_add_relu_buffer_fusion.py +++ b/tests/st/fusion/test_add_relu_buffer_fusion.py @@ -13,9 +13,10 @@ # limitations under the License. # ============================================================================ import numpy as np + +import mindspore.common.dtype as mstype import mindspore.context as context import mindspore.nn as nn -import mindspore.common.dtype as mstype from mindspore import Tensor, ms_function from mindspore.ops import operations as P diff --git a/tests/st/fusion/test_conv_bn1_fusion.py b/tests/st/fusion/test_conv_bn1_fusion.py index 36f7775de56..79d8f08ceaf 100644 --- a/tests/st/fusion/test_conv_bn1_fusion.py +++ b/tests/st/fusion/test_conv_bn1_fusion.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ import numpy as np + import mindspore.context as context import mindspore.nn as nn from mindspore import Tensor, Parameter, Model, ms_function -from mindspore.ops import operations as P from mindspore.common.initializer import initializer from mindspore.nn.loss import SoftmaxCrossEntropyWithLogits from mindspore.nn.optim import Momentum +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/fusion/test_tbe_eltwise_fusion_1.py b/tests/st/fusion/test_tbe_eltwise_fusion_1.py index 5d4fd09d30a..4f4494c49e6 100644 --- a/tests/st/fusion/test_tbe_eltwise_fusion_1.py +++ b/tests/st/fusion/test_tbe_eltwise_fusion_1.py @@ -12,8 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -import pytest import numpy as np +import pytest + import mindspore.context as context import mindspore.nn as nn from mindspore import Tensor diff --git a/tests/st/fusion/test_tbe_eltwise_fusion_2.py b/tests/st/fusion/test_tbe_eltwise_fusion_2.py index 3ae754d3850..ee74a214b70 100644 --- a/tests/st/fusion/test_tbe_eltwise_fusion_2.py +++ b/tests/st/fusion/test_tbe_eltwise_fusion_2.py @@ -12,8 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -import pytest import numpy as np +import pytest + import mindspore.context as context import mindspore.nn as nn from mindspore import Tensor diff --git a/tests/st/fusion/test_tbe_multi_inout_eltwise_fusion.py b/tests/st/fusion/test_tbe_multi_inout_eltwise_fusion.py index 76cf639da01..b770a867a9f 100644 --- a/tests/st/fusion/test_tbe_multi_inout_eltwise_fusion.py +++ b/tests/st/fusion/test_tbe_multi_inout_eltwise_fusion.py @@ -13,6 +13,7 @@ # limitations under the License. # ============================================================================ import numpy as np + import mindspore.context as context import mindspore.nn as nn from mindspore import Tensor diff --git a/tests/st/fusion/test_tbe_reduce_eltwise_fusion.py b/tests/st/fusion/test_tbe_reduce_eltwise_fusion.py index 93c7174b529..9b7328fd9b2 100644 --- a/tests/st/fusion/test_tbe_reduce_eltwise_fusion.py +++ b/tests/st/fusion/test_tbe_reduce_eltwise_fusion.py @@ -12,8 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -import pytest import numpy as np +import pytest + import mindspore.context as context import mindspore.nn as nn from mindspore import Tensor diff --git a/tests/st/gnn/aggregator.py b/tests/st/gnn/aggregator.py index 8dfe2d32e3b..214bb719bab 100644 --- a/tests/st/gnn/aggregator.py +++ b/tests/st/gnn/aggregator.py @@ -14,13 +14,13 @@ # ============================================================================ """Aggregator.""" import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore.ops import functional as F -from mindspore._extends import cell_attr_register from mindspore import Tensor, Parameter -from mindspore.common.initializer import initializer from mindspore._checkparam import check_int_positive, check_bool +from mindspore._extends import cell_attr_register +from mindspore.common.initializer import initializer from mindspore.nn.layer.activation import get_activation +from mindspore.ops import functional as F +from mindspore.ops import operations as P class GNNFeatureTransform(nn.Cell): diff --git a/tests/st/gnn/test_gnn_aggregator.py b/tests/st/gnn/test_gnn_aggregator.py index c244b3cb8a5..2087b16299d 100644 --- a/tests/st/gnn/test_gnn_aggregator.py +++ b/tests/st/gnn/test_gnn_aggregator.py @@ -14,13 +14,13 @@ # ============================================================================ """test gnn aggregator.""" import numpy as np +from aggregator import MeanAggregator, AttentionHead, AttentionAggregator -import mindspore.nn as nn import mindspore.context as context +import mindspore.nn as nn +import mindspore.ops.composite as C from mindspore import Tensor from mindspore.common.api import _executor -import mindspore.ops.composite as C -from aggregator import MeanAggregator, AttentionHead, AttentionAggregator context.set_context(mode=context.GRAPH_MODE) diff --git a/tests/st/mem_reuse/check_file.py b/tests/st/mem_reuse/check_file.py index 30b3b690a45..152dfebe795 100644 --- a/tests/st/mem_reuse/check_file.py +++ b/tests/st/mem_reuse/check_file.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -import os import filecmp +import os curr_path = os.path.abspath(os.curdir) file_memreuse = curr_path + "/mem_reuse_check/memreuse.ir" diff --git a/tests/st/mem_reuse/resnet.py b/tests/st/mem_reuse/resnet.py index 1c1b880b573..f4e2d491e55 100644 --- a/tests/st/mem_reuse/resnet.py +++ b/tests/st/mem_reuse/resnet.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================ import numpy as np + import mindspore.nn as nn from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.common.initializer import initializer from mindspore.common import dtype as mstype +from mindspore.common.initializer import initializer +from mindspore.ops import operations as P def weight_variable(shape): diff --git a/tests/st/mem_reuse/resnet_cifar_memreuse.py b/tests/st/mem_reuse/resnet_cifar_memreuse.py index c25fb957e2c..93ee5f8393a 100644 --- a/tests/st/mem_reuse/resnet_cifar_memreuse.py +++ b/tests/st/mem_reuse/resnet_cifar_memreuse.py @@ -13,24 +13,25 @@ # limitations under the License. # ============================================================================ import argparse -import os import numpy as np -import mindspore.context as context -import mindspore.nn as nn +import os +import random +from resnet import resnet50 + import mindspore.common.dtype as mstype -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.ops import functional as F -from mindspore.nn.optim.momentum import Momentum -from mindspore.train.model import Model, ParallelMode -from mindspore.train.callback import ModelCheckpoint, CheckpointConfig, LossMonitor -from mindspore.train.serialization import load_checkpoint, load_param_into_net +import mindspore.context as context import mindspore.dataset as de import mindspore.dataset.transforms.c_transforms as C import mindspore.dataset.transforms.vision.c_transforms as vision +import mindspore.nn as nn +from mindspore import Tensor from mindspore.communication.management import init -from resnet import resnet50 -import random +from mindspore.nn.optim.momentum import Momentum +from mindspore.ops import functional as F +from mindspore.ops import operations as P +from mindspore.train.callback import ModelCheckpoint, CheckpointConfig, LossMonitor +from mindspore.train.model import Model, ParallelMode +from mindspore.train.serialization import load_checkpoint, load_param_into_net random.seed(1) np.random.seed(1) diff --git a/tests/st/mem_reuse/resnet_cifar_normal.py b/tests/st/mem_reuse/resnet_cifar_normal.py index 96af53f2253..aa2262d2238 100644 --- a/tests/st/mem_reuse/resnet_cifar_normal.py +++ b/tests/st/mem_reuse/resnet_cifar_normal.py @@ -13,24 +13,25 @@ # limitations under the License. # ============================================================================ import argparse -import os import numpy as np -import mindspore.context as context -import mindspore.nn as nn +import os +import random +from resnet import resnet50 + import mindspore.common.dtype as mstype -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.ops import functional as F -from mindspore.nn.optim.momentum import Momentum -from mindspore.train.model import Model, ParallelMode -from mindspore.train.callback import ModelCheckpoint, CheckpointConfig, LossMonitor -from mindspore.train.serialization import load_checkpoint, load_param_into_net +import mindspore.context as context import mindspore.dataset as de import mindspore.dataset.transforms.c_transforms as C import mindspore.dataset.transforms.vision.c_transforms as vision +import mindspore.nn as nn +from mindspore import Tensor from mindspore.communication.management import init -from resnet import resnet50 -import random +from mindspore.nn.optim.momentum import Momentum +from mindspore.ops import functional as F +from mindspore.ops import operations as P +from mindspore.train.callback import ModelCheckpoint, CheckpointConfig, LossMonitor +from mindspore.train.model import Model, ParallelMode +from mindspore.train.serialization import load_checkpoint, load_param_into_net random.seed(1) np.random.seed(1) diff --git a/tests/st/nccl/test_nccl_all_gather_op.py b/tests/st/nccl/test_nccl_all_gather_op.py index 0a37a692da0..5fb71d9ce55 100644 --- a/tests/st/nccl/test_nccl_all_gather_op.py +++ b/tests/st/nccl/test_nccl_all_gather_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ import numpy as np + import mindspore.context as context import mindspore.nn as nn from mindspore import Tensor -from mindspore.ops import operations as P from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter from mindspore.communication.management import init, NCCL_WORLD_COMM_GROUP, get_rank, get_group_size +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target='GPU') diff --git a/tests/st/nccl/test_nccl_all_reduce_op.py b/tests/st/nccl/test_nccl_all_reduce_op.py index a1a732fd087..6dee522e3fe 100644 --- a/tests/st/nccl/test_nccl_all_reduce_op.py +++ b/tests/st/nccl/test_nccl_all_reduce_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ import numpy as np + import mindspore.context as context import mindspore.nn as nn from mindspore import Tensor -from mindspore.ops import operations as P from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter from mindspore.communication.management import init, NCCL_WORLD_COMM_GROUP, get_rank, get_group_size +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target='GPU') diff --git a/tests/st/nccl/test_nccl_lenet.py b/tests/st/nccl/test_nccl_lenet.py index ae15a9e3ac9..a5d7f2e3b41 100644 --- a/tests/st/nccl/test_nccl_lenet.py +++ b/tests/st/nccl/test_nccl_lenet.py @@ -14,14 +14,15 @@ # ============================================================================ import datetime import numpy as np + import mindspore.context as context import mindspore.nn as nn from mindspore import Tensor -from mindspore.nn.optim import Momentum -from mindspore.nn import TrainOneStepCell, WithLossCell -from mindspore.ops import operations as P -from mindspore.communication.management import init, get_rank, get_group_size from mindspore.common import dtype as mstype +from mindspore.communication.management import init, get_rank, get_group_size +from mindspore.nn import TrainOneStepCell, WithLossCell +from mindspore.nn.optim import Momentum +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="GPU") init('nccl') diff --git a/tests/st/nccl/test_nccl_reduce_scatter_op.py b/tests/st/nccl/test_nccl_reduce_scatter_op.py index 76f2022b787..8409d947af7 100644 --- a/tests/st/nccl/test_nccl_reduce_scatter_op.py +++ b/tests/st/nccl/test_nccl_reduce_scatter_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ import numpy as np + import mindspore.context as context import mindspore.nn as nn from mindspore import Tensor -from mindspore.ops import operations as P from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter from mindspore.communication.management import init, NCCL_WORLD_COMM_GROUP, get_rank, get_group_size +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target='GPU') diff --git a/tests/st/networks/models/alexnet.py b/tests/st/networks/models/alexnet.py index f74d09353cc..a31182a8322 100644 --- a/tests/st/networks/models/alexnet.py +++ b/tests/st/networks/models/alexnet.py @@ -13,8 +13,8 @@ # limitations under the License. # ============================================================================ import mindspore.nn as nn -from mindspore.ops import operations as P from mindspore.nn import Dense +from mindspore.ops import operations as P class AlexNet(nn.Cell): diff --git a/tests/st/networks/models/bert/bert_tdt_lossscale.py b/tests/st/networks/models/bert/bert_tdt_lossscale.py index ee7e8281a77..ec9b711cd9f 100644 --- a/tests/st/networks/models/bert/bert_tdt_lossscale.py +++ b/tests/st/networks/models/bert/bert_tdt_lossscale.py @@ -15,21 +15,22 @@ """train bert network without lossscale""" +import numpy as np import os import pytest -import numpy as np from numpy import allclose + import mindspore.common.dtype as mstype import mindspore.dataset.engine.datasets as de import mindspore.dataset.transforms.c_transforms as C from mindspore import context +from mindspore import log as logger from mindspore.common.tensor import Tensor -from mindspore.train.model import Model -from mindspore.train.callback import Callback, LossMonitor -from mindspore.train.loss_scale_manager import DynamicLossScaleManager from mindspore.model_zoo.Bert_NEZHA import BertConfig, BertNetworkWithLoss, BertTrainOneStepWithLossScaleCell from mindspore.nn.optim import Momentum -from mindspore import log as logger +from mindspore.train.callback import Callback, LossMonitor +from mindspore.train.loss_scale_manager import DynamicLossScaleManager +from mindspore.train.model import Model _current_dir = os.path.dirname(os.path.realpath(__file__)) DATA_DIR = ["/home/workspace/mindspore_dataset/bert/example/examples.tfrecord"] diff --git a/tests/st/networks/models/lenet.py b/tests/st/networks/models/lenet.py index 8f6b969cd7c..5f95145e177 100644 --- a/tests/st/networks/models/lenet.py +++ b/tests/st/networks/models/lenet.py @@ -13,10 +13,11 @@ # limitations under the License. # ============================================================================ import numpy as np + import mindspore.nn as nn from mindspore import Tensor -from mindspore.ops import operations as P from mindspore.nn import Dense +from mindspore.ops import operations as P class LeNet(nn.Cell): diff --git a/tests/st/networks/models/resnetv1_5.py b/tests/st/networks/models/resnetv1_5.py index 604389547e1..6cf671d57e3 100644 --- a/tests/st/networks/models/resnetv1_5.py +++ b/tests/st/networks/models/resnetv1_5.py @@ -13,6 +13,7 @@ # limitations under the License. # ============================================================================ import numpy as np + import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P diff --git a/tests/st/networks/test_cpu_lenet.py b/tests/st/networks/test_cpu_lenet.py index 7101e29aa95..9a11b23c87a 100644 --- a/tests/st/networks/test_cpu_lenet.py +++ b/tests/st/networks/test_cpu_lenet.py @@ -12,8 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -import pytest import numpy as np +import pytest + import mindspore.context as context import mindspore.nn as nn from mindspore import Tensor diff --git a/tests/st/networks/test_gpu_alexnet.py b/tests/st/networks/test_gpu_alexnet.py index 2693192381d..10099814642 100644 --- a/tests/st/networks/test_gpu_alexnet.py +++ b/tests/st/networks/test_gpu_alexnet.py @@ -17,15 +17,16 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import pytest import numpy as np +import pytest + import mindspore.context as context import mindspore.nn as nn from mindspore import Tensor +from mindspore.common.initializer import initializer +from mindspore.nn import TrainOneStepCell, WithLossCell from mindspore.nn.optim import Momentum from mindspore.ops import operations as P -from mindspore.nn import TrainOneStepCell, WithLossCell -from mindspore.common.initializer import initializer context.set_context(mode=context.GRAPH_MODE, device_target="GPU") diff --git a/tests/st/networks/test_gpu_lenet.py b/tests/st/networks/test_gpu_lenet.py index 723a45cbff3..d2e1c909818 100644 --- a/tests/st/networks/test_gpu_lenet.py +++ b/tests/st/networks/test_gpu_lenet.py @@ -13,26 +13,26 @@ # limitations under the License. # ============================================================================ +import numpy as np import os import pytest -import numpy as np -from mindspore import Tensor + import mindspore.context as context -from mindspore.ops import operations as P +import mindspore.dataset as ds +import mindspore.dataset.transforms.c_transforms as C +import mindspore.dataset.transforms.vision.c_transforms as CV import mindspore.nn as nn -from mindspore.nn import Dense, TrainOneStepCell, WithLossCell -from mindspore.nn.optim import Momentum -from mindspore.nn.metrics import Accuracy -from mindspore.train import Model +from mindspore import Tensor from mindspore.common import dtype as mstype from mindspore.common.initializer import initializer -from mindspore.model_zoo.lenet import LeNet5 -from mindspore.train.callback import LossMonitor - -import mindspore.dataset as ds -import mindspore.dataset.transforms.vision.c_transforms as CV -import mindspore.dataset.transforms.c_transforms as C from mindspore.dataset.transforms.vision import Inter +from mindspore.model_zoo.lenet import LeNet5 +from mindspore.nn import Dense, TrainOneStepCell, WithLossCell +from mindspore.nn.metrics import Accuracy +from mindspore.nn.optim import Momentum +from mindspore.ops import operations as P +from mindspore.train import Model +from mindspore.train.callback import LossMonitor context.set_context(mode=context.GRAPH_MODE, device_target="GPU") diff --git a/tests/st/networks/test_gpu_lstm.py b/tests/st/networks/test_gpu_lstm.py index a5fe4387451..c85bcede804 100644 --- a/tests/st/networks/test_gpu_lstm.py +++ b/tests/st/networks/test_gpu_lstm.py @@ -13,17 +13,18 @@ # limitations under the License. # ============================================================================ -import pytest import numpy as np +import pytest + import mindspore.context as context import mindspore.nn as nn from mindspore import Tensor -from mindspore.nn.optim import Momentum -from mindspore.ops import operations as P -from mindspore.nn import TrainOneStepCell, WithLossCell -from mindspore.nn import Dense from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.nn import Dense +from mindspore.nn import TrainOneStepCell, WithLossCell +from mindspore.nn.optim import Momentum +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="GPU") diff --git a/tests/st/networks/test_gpu_resnet.py b/tests/st/networks/test_gpu_resnet.py index 906bdbb2d03..716c08123ce 100644 --- a/tests/st/networks/test_gpu_resnet.py +++ b/tests/st/networks/test_gpu_resnet.py @@ -17,22 +17,23 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import pytest import numpy as np +import pytest + import mindspore.context as context import mindspore.nn as nn from mindspore import Tensor +from mindspore import amp +from mindspore.nn import Dense +from mindspore.nn import TrainOneStepCell, WithLossCell from mindspore.nn.cell import Cell -from mindspore.nn.layer.conv import Conv2d from mindspore.nn.layer.basic import Flatten +from mindspore.nn.layer.conv import Conv2d from mindspore.nn.layer.normalization import BatchNorm2d from mindspore.nn.layer.pooling import MaxPool2d -from mindspore.ops.operations import TensorAdd from mindspore.nn.optim import Momentum from mindspore.ops import operations as P -from mindspore.nn import TrainOneStepCell, WithLossCell -from mindspore.nn import Dense -from mindspore import amp +from mindspore.ops.operations import TensorAdd context.set_context(mode=context.GRAPH_MODE, device_target="GPU") diff --git a/tests/st/networks/test_network_main.py b/tests/st/networks/test_network_main.py index 79bd46d87ae..3216d25bfea 100644 --- a/tests/st/networks/test_network_main.py +++ b/tests/st/networks/test_network_main.py @@ -18,18 +18,19 @@ Function: Usage: python test_network_main.py --net lenet --target Ascend """ +import argparse +import numpy as np import os import time -import numpy as np -import argparse +from models.alexnet import AlexNet +from models.lenet import LeNet +from models.resnetv1_5 import resnet50 + import mindspore.context as context import mindspore.nn as nn from mindspore import Tensor from mindspore.nn import TrainOneStepCell, WithLossCell from mindspore.nn.optim import Momentum -from models.lenet import LeNet -from models.resnetv1_5 import resnet50 -from models.alexnet import AlexNet context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_add.py b/tests/st/ops/ascend/test_add.py index 093f9e72d76..0fa8e2d204d 100644 --- a/tests/st/ops/ascend/test_add.py +++ b/tests/st/ops/ascend/test_add.py @@ -12,11 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ +import numpy as np + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_addn.py b/tests/st/ops/ascend/test_addn.py index 82cf82010a1..efca046b546 100644 --- a/tests/st/ops/ascend/test_addn.py +++ b/tests/st/ops/ascend/test_addn.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_aicpu_ops/test_expand_dims.py b/tests/st/ops/ascend/test_aicpu_ops/test_expand_dims.py index 664fa2c9509..22969303b98 100644 --- a/tests/st/ops/ascend/test_aicpu_ops/test_expand_dims.py +++ b/tests/st/ops/ascend/test_aicpu_ops/test_expand_dims.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(mode=context.PYNATIVE_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_aicpu_ops/test_flatten.py b/tests/st/ops/ascend/test_aicpu_ops/test_flatten.py index b7c24ac41e1..02f591702e2 100644 --- a/tests/st/ops/ascend/test_aicpu_ops/test_flatten.py +++ b/tests/st/ops/ascend/test_aicpu_ops/test_flatten.py @@ -12,11 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ +import numpy as np + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context context.set_context(mode=context.PYNATIVE_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_aicpu_ops/test_is_finite.py b/tests/st/ops/ascend/test_aicpu_ops/test_is_finite.py index 7de73cd8539..2dcff2013cc 100644 --- a/tests/st/ops/ascend/test_aicpu_ops/test_is_finite.py +++ b/tests/st/ops/ascend/test_aicpu_ops/test_is_finite.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(mode=context.PYNATIVE_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_aicpu_ops/test_reshape.py b/tests/st/ops/ascend/test_aicpu_ops/test_reshape.py index 6839c96e506..0e62404f9dc 100644 --- a/tests/st/ops/ascend/test_aicpu_ops/test_reshape.py +++ b/tests/st/ops/ascend/test_aicpu_ops/test_reshape.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(mode=context.PYNATIVE_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_aicpu_ops/test_squeeze.py b/tests/st/ops/ascend/test_aicpu_ops/test_squeeze.py index 58b6a3f07c6..9af7275f86d 100644 --- a/tests/st/ops/ascend/test_aicpu_ops/test_squeeze.py +++ b/tests/st/ops/ascend/test_aicpu_ops/test_squeeze.py @@ -12,11 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ +import numpy as np + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context context.set_context(mode=context.PYNATIVE_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_apply_momentum.py b/tests/st/ops/ascend/test_apply_momentum.py index 2cae2d2ff66..603dc23cfea 100644 --- a/tests/st/ops/ascend/test_apply_momentum.py +++ b/tests/st/ops/ascend/test_apply_momentum.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_argmax.py b/tests/st/ops/ascend/test_argmax.py index d7d1aa46d2a..c29841c1357 100644 --- a/tests/st/ops/ascend/test_argmax.py +++ b/tests/st/ops/ascend/test_argmax.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_biasAddGrad.py b/tests/st/ops/ascend/test_biasAddGrad.py index 83e51c71e5b..90282e22071 100644 --- a/tests/st/ops/ascend/test_biasAddGrad.py +++ b/tests/st/ops/ascend/test_biasAddGrad.py @@ -12,15 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.ops.operations import _grad_ops as G -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P +from mindspore.ops.operations import _grad_ops as G context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_bias_add_grad.py b/tests/st/ops/ascend/test_bias_add_grad.py index 85e27b76005..2b95b0a2d28 100644 --- a/tests/st/ops/ascend/test_bias_add_grad.py +++ b/tests/st/ops/ascend/test_bias_add_grad.py @@ -12,15 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.ops.operations import _grad_ops as G -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P +from mindspore.ops.operations import _grad_ops as G context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_conv.py b/tests/st/ops/ascend/test_conv.py index 3984cb33f7c..6b80fcffa93 100644 --- a/tests/st/ops/ascend/test_conv.py +++ b/tests/st/ops/ascend/test_conv.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_conv2dGradFilter.py b/tests/st/ops/ascend/test_conv2dGradFilter.py index 945533426df..293cc0e65e0 100644 --- a/tests/st/ops/ascend/test_conv2dGradFilter.py +++ b/tests/st/ops/ascend/test_conv2dGradFilter.py @@ -12,15 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.ops.operations import _grad_ops as G -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P +from mindspore.ops.operations import _grad_ops as G context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_conv_grad.py b/tests/st/ops/ascend/test_conv_grad.py index 0d6de26afcc..efc9cd9dea8 100644 --- a/tests/st/ops/ascend/test_conv_grad.py +++ b/tests/st/ops/ascend/test_conv_grad.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P from mindspore.ops.composite import GradOperation context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_dense.py b/tests/st/ops/ascend/test_dense.py index c3652237ce8..48623b0df01 100644 --- a/tests/st/ops/ascend/test_dense.py +++ b/tests/st/ops/ascend/test_dense.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_dense_grad.py b/tests/st/ops/ascend/test_dense_grad.py index 071a2e87734..d5f88c1c21f 100644 --- a/tests/st/ops/ascend/test_dense_grad.py +++ b/tests/st/ops/ascend/test_dense_grad.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P from mindspore.ops.composite import GradOperation context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_drop_out_gen_mask.py b/tests/st/ops/ascend/test_drop_out_gen_mask.py index 3d3e2ca237a..64360a6e24d 100644 --- a/tests/st/ops/ascend/test_drop_out_gen_mask.py +++ b/tests/st/ops/ascend/test_drop_out_gen_mask.py @@ -12,11 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ +import numpy as np + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_equal_count.py b/tests/st/ops/ascend/test_equal_count.py index 6790fd7b6ee..a204a48c6b3 100644 --- a/tests/st/ops/ascend/test_equal_count.py +++ b/tests/st/ops/ascend/test_equal_count.py @@ -12,11 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ +import numpy as np + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_full_connection.py b/tests/st/ops/ascend/test_full_connection.py index 534c5d80889..ca8d62eacb1 100644 --- a/tests/st/ops/ascend/test_full_connection.py +++ b/tests/st/ops/ascend/test_full_connection.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_fused_batchnorm.py b/tests/st/ops/ascend/test_fused_batchnorm.py index a5248203ebf..bf0b7ffd4fa 100644 --- a/tests/st/ops/ascend/test_fused_batchnorm.py +++ b/tests/st/ops/ascend/test_fused_batchnorm.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_fused_batchnorm_grad.py b/tests/st/ops/ascend/test_fused_batchnorm_grad.py index 3d13bd8b541..47adc2d0659 100644 --- a/tests/st/ops/ascend/test_fused_batchnorm_grad.py +++ b/tests/st/ops/ascend/test_fused_batchnorm_grad.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P from mindspore.ops.composite import GradOperation # context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_image_gradients.py b/tests/st/ops/ascend/test_image_gradients.py index 8d1fbd6ac2a..8b9eb2dceac 100644 --- a/tests/st/ops/ascend/test_image_gradients.py +++ b/tests/st/ops/ascend/test_image_gradients.py @@ -13,9 +13,10 @@ # limitations under the License. # ============================================================================ import numpy as np -import mindspore.nn as nn -import mindspore.context as context + import mindspore.common.dtype as mstype +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.common.api import ms_function diff --git a/tests/st/ops/ascend/test_matmul.py b/tests/st/ops/ascend/test_matmul.py index 01701f52850..d0fecfed23c 100644 --- a/tests/st/ops/ascend/test_matmul.py +++ b/tests/st/ops/ascend/test_matmul.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_maxpool.py b/tests/st/ops/ascend/test_maxpool.py index da1f2b9caef..91fe6ef942d 100644 --- a/tests/st/ops/ascend/test_maxpool.py +++ b/tests/st/ops/ascend/test_maxpool.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_maxpool_grad.py b/tests/st/ops/ascend/test_maxpool_grad.py index 402d6f719bd..810d544bb4a 100644 --- a/tests/st/ops/ascend/test_maxpool_grad.py +++ b/tests/st/ops/ascend/test_maxpool_grad.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P from mindspore.ops.composite import GradOperation context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_maxpool_with_argmax.py b/tests/st/ops/ascend/test_maxpool_with_argmax.py index a6c875a9e8e..abd1c4005f8 100644 --- a/tests/st/ops/ascend/test_maxpool_with_argmax.py +++ b/tests/st/ops/ascend/test_maxpool_with_argmax.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_maxpool_with_argmax_grad.py b/tests/st/ops/ascend/test_maxpool_with_argmax_grad.py index 180dc088a88..0d21ee82054 100644 --- a/tests/st/ops/ascend/test_maxpool_with_argmax_grad.py +++ b/tests/st/ops/ascend/test_maxpool_with_argmax_grad.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P from mindspore.ops.composite import GradOperation context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_relu.py b/tests/st/ops/ascend/test_relu.py index 1b6ed298d37..0da6347fa3b 100644 --- a/tests/st/ops/ascend/test_relu.py +++ b/tests/st/ops/ascend/test_relu.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_relu_grad.py b/tests/st/ops/ascend/test_relu_grad.py index 5839218b42d..72b70bddb89 100644 --- a/tests/st/ops/ascend/test_relu_grad.py +++ b/tests/st/ops/ascend/test_relu_grad.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P from mindspore.ops.composite import GradOperation context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_reshape.py b/tests/st/ops/ascend/test_reshape.py index 66f2dd743bf..33c228f1fda 100644 --- a/tests/st/ops/ascend/test_reshape.py +++ b/tests/st/ops/ascend/test_reshape.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_simplemean.py b/tests/st/ops/ascend/test_simplemean.py index b1280aec726..c61ed6300e1 100644 --- a/tests/st/ops/ascend/test_simplemean.py +++ b/tests/st/ops/ascend/test_simplemean.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_simplemean_grad.py b/tests/st/ops/ascend/test_simplemean_grad.py index bdffa32e66c..c7116f47299 100644 --- a/tests/st/ops/ascend/test_simplemean_grad.py +++ b/tests/st/ops/ascend/test_simplemean_grad.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P from mindspore.ops.composite import GradOperation context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_softmax.py b/tests/st/ops/ascend/test_softmax.py index 67d4ac92d90..80ee64a095a 100644 --- a/tests/st/ops/ascend/test_softmax.py +++ b/tests/st/ops/ascend/test_softmax.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_sparseSoftmaxCrossEntropyWithLogits.py b/tests/st/ops/ascend/test_sparseSoftmaxCrossEntropyWithLogits.py index f4f801a685a..ced2c5492ef 100644 --- a/tests/st/ops/ascend/test_sparseSoftmaxCrossEntropyWithLogits.py +++ b/tests/st/ops/ascend/test_sparseSoftmaxCrossEntropyWithLogits.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_sparse_softmax_cross_entropy_with_logits.py b/tests/st/ops/ascend/test_sparse_softmax_cross_entropy_with_logits.py index 292196e8cd2..5850722cdd8 100644 --- a/tests/st/ops/ascend/test_sparse_softmax_cross_entropy_with_logits.py +++ b/tests/st/ops/ascend/test_sparse_softmax_cross_entropy_with_logits.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_sparse_softmax_cross_entropy_with_logits_grad.py b/tests/st/ops/ascend/test_sparse_softmax_cross_entropy_with_logits_grad.py index fd5b31564f5..20f459aa58c 100644 --- a/tests/st/ops/ascend/test_sparse_softmax_cross_entropy_with_logits_grad.py +++ b/tests/st/ops/ascend/test_sparse_softmax_cross_entropy_with_logits_grad.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_AssignAdd.py b/tests/st/ops/ascend/test_tbe_ops/test_AssignAdd.py index f8e14a5b67e..a6f09b8bd62 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_AssignAdd.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_AssignAdd.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_AssignSub.py b/tests/st/ops/ascend/test_tbe_ops/test_AssignSub.py index fd733254011..6f01e9deea4 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_AssignSub.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_AssignSub.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_ReduceMean.py b/tests/st/ops/ascend/test_tbe_ops/test_ReduceMean.py index 91a50e3f282..f6cfc6863e4 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_ReduceMean.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_ReduceMean.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_add.py b/tests/st/ops/ascend/test_tbe_ops/test_add.py index b58a7859ab9..6ca1aaf1e3e 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_add.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_add.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P class Net(nn.Cell): diff --git a/tests/st/ops/ascend/test_tbe_ops/test_addn.py b/tests/st/ops/ascend/test_tbe_ops/test_addn.py index 1765d50fd10..793fff1f009 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_addn.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_addn.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_apply_adam.py b/tests/st/ops/ascend/test_tbe_ops/test_apply_adam.py index c2ae91f862b..8d256384309 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_apply_adam.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_apply_adam.py @@ -13,12 +13,12 @@ # limitations under the License. # ============================================================================ import numpy as np -from mindspore import Tensor -import mindspore.nn as nn -from mindspore.nn import Dense, SoftmaxCrossEntropyWithLogits -from mindspore.nn import TrainOneStepCell, WithLossCell import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.nn import Dense, SoftmaxCrossEntropyWithLogits +from mindspore.nn import TrainOneStepCell, WithLossCell context.set_context(mode=context.GRAPH_MODE, device_target="Ascend", impl_type="tbe") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_apply_momentum.py b/tests/st/ops/ascend/test_tbe_ops/test_apply_momentum.py index 0db4d9e9729..9e1aa6f0aae 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_apply_momentum.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_apply_momentum.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P class Net(nn.Cell): diff --git a/tests/st/ops/ascend/test_tbe_ops/test_batchmatmul.py b/tests/st/ops/ascend/test_tbe_ops/test_batchmatmul.py index 72fb57a0fac..ee2af00d3f1 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_batchmatmul.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_batchmatmul.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ import numpy as np -from mindspore.common.tensor import Tensor -from mindspore.ops import operations as P -from mindspore.nn import Cell -from mindspore.train.model import Model import pytest + from mindspore import context +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P +from mindspore.train.model import Model context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_batchnorm.py b/tests/st/ops/ascend/test_tbe_ops/test_batchnorm.py index 24153310509..9a185501c4d 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_batchnorm.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_batchnorm.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P class Net(nn.Cell): diff --git a/tests/st/ops/ascend/test_tbe_ops/test_batchnorm_grad.py b/tests/st/ops/ascend/test_tbe_ops/test_batchnorm_grad.py index bd4bdcdf487..394670790c8 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_batchnorm_grad.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_batchnorm_grad.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P from mindspore.ops.composite import GradOperation # context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_bias_add.py b/tests/st/ops/ascend/test_tbe_ops/test_bias_add.py index 94adfcb7e66..e982140f7fa 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_bias_add.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_bias_add.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_bias_add_grad.py b/tests/st/ops/ascend/test_tbe_ops/test_bias_add_grad.py index cafecb9fd93..773ab083715 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_bias_add_grad.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_bias_add_grad.py @@ -12,15 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.ops.operations import _grad_ops as G -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P +from mindspore.ops.operations import _grad_ops as G context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_concat.py b/tests/st/ops/ascend/test_tbe_ops/test_concat.py index 72e67f5ee58..42110c7bacd 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_concat.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_concat.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_conv.py b/tests/st/ops/ascend/test_tbe_ops/test_conv.py index 2cec372b035..1c628a3893b 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_conv.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_conv.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P class Net(nn.Cell): diff --git a/tests/st/ops/ascend/test_tbe_ops/test_conv2d_backprop_filter.py b/tests/st/ops/ascend/test_tbe_ops/test_conv2d_backprop_filter.py index f2137963bbf..3d112d24518 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_conv2d_backprop_filter.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_conv2d_backprop_filter.py @@ -12,15 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.ops.operations import _grad_ops as G -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P +from mindspore.ops.operations import _grad_ops as G context.set_context(device_target='Ascend') diff --git a/tests/st/ops/ascend/test_tbe_ops/test_conv2d_backprop_input.py b/tests/st/ops/ascend/test_tbe_ops/test_conv2d_backprop_input.py index 1787cc25b4f..d0ef791b9da 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_conv2d_backprop_input.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_conv2d_backprop_input.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_dropout_do_mask.py b/tests/st/ops/ascend/test_tbe_ops/test_dropout_do_mask.py index 4e223b2ce03..bec6783749f 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_dropout_do_mask.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_dropout_do_mask.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") from mindspore import log as logger diff --git a/tests/st/ops/ascend/test_tbe_ops/test_gelu.py b/tests/st/ops/ascend/test_tbe_ops/test_gelu.py index 346823eaedf..aadb48415e9 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_gelu.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_gelu.py @@ -12,15 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -import numpy as np -from mindspore.nn import GELU, Cell -from mindspore.common.tensor import Tensor -from mindspore.train.model import Model -from mindspore.ops import operations as P import math +import numpy as np import pytest + from mindspore import context from mindspore import log as logger +from mindspore.common.tensor import Tensor +from mindspore.nn import GELU, Cell +from mindspore.ops import operations as P +from mindspore.train.model import Model context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_gelu_grad_sens.py b/tests/st/ops/ascend/test_tbe_ops/test_gelu_grad_sens.py index 3041d331668..68c1b2b53d8 100755 --- a/tests/st/ops/ascend/test_tbe_ops/test_gelu_grad_sens.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_gelu_grad_sens.py @@ -12,16 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -import numpy as np -from mindspore.common.tensor import Tensor -from mindspore.ops.composite import GradOperation -from mindspore.nn import Cell, GELU -from mindspore import context -import pytest import math -from mindspore.ops import operations as P +import numpy as np +import pytest + import mindspore as ms +from mindspore import context from mindspore import log as logger +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell, GELU +from mindspore.ops import operations as P +from mindspore.ops.composite import GradOperation context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_greater.py b/tests/st/ops/ascend/test_tbe_ops/test_greater.py index 793b7208f46..6d34cd59f69 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_greater.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_greater.py @@ -14,12 +14,13 @@ # ============================================================================ import numpy as np import pytest -from mindspore.ops import operations as P -from mindspore.nn import Cell -from mindspore.common.tensor import Tensor -from mindspore.train.model import Model -from mindspore import log as logger + from mindspore import context +from mindspore import log as logger +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P +from mindspore.train.model import Model context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_layernorm.py b/tests/st/ops/ascend/test_tbe_ops/test_layernorm.py index 4ef32dee6ea..f0532cec5bc 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_layernorm.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_layernorm.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ import numpy as np -from mindspore.nn import LayerNorm +import pytest + +from mindspore import context +from mindspore import log as logger from mindspore.common.tensor import Tensor from mindspore.nn import Cell +from mindspore.nn import LayerNorm from mindspore.train.model import Model -from mindspore import log as logger -import pytest -from mindspore import context context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_layernorm_grad.py b/tests/st/ops/ascend/test_tbe_ops/test_layernorm_grad.py index b9d706e25e2..aeb248b2887 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_layernorm_grad.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_layernorm_grad.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ import numpy as np -from mindspore.nn import LayerNorm + +from mindspore import context +from mindspore import log as logger from mindspore.common.tensor import Tensor from mindspore.nn import Cell +from mindspore.nn import LayerNorm from mindspore.ops.composite import GradOperation -from mindspore import log as logger -from mindspore import context context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_less.py b/tests/st/ops/ascend/test_tbe_ops/test_less.py index 65926ef6d7c..ccffaaf5f12 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_less.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_less.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_less_equal.py b/tests/st/ops/ascend/test_tbe_ops/test_less_equal.py index bca00bd678d..d6af031905f 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_less_equal.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_less_equal.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_logical_and.py b/tests/st/ops/ascend/test_tbe_ops/test_logical_and.py index 650de5d3bfd..429e3eeb425 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_logical_and.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_logical_and.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_logical_not.py b/tests/st/ops/ascend/test_tbe_ops/test_logical_not.py index 2b78a089c39..4fb6bc7fdb0 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_logical_not.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_logical_not.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_logical_or.py b/tests/st/ops/ascend/test_tbe_ops/test_logical_or.py index e7dc6a2723b..734e0a9485e 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_logical_or.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_logical_or.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_matmul.py b/tests/st/ops/ascend/test_tbe_ops/test_matmul.py index 8c8b2c380f3..9defdbbf72a 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_matmul.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_matmul.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P class Net(nn.Cell): diff --git a/tests/st/ops/ascend/test_tbe_ops/test_matmul_failed.py b/tests/st/ops/ascend/test_tbe_ops/test_matmul_failed.py index 8aebb7bd7ed..5f12b91836e 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_matmul_failed.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_matmul_failed.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_maximum.py b/tests/st/ops/ascend/test_tbe_ops/test_maximum.py index b5a868c39a7..d6f0e8acf89 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_maximum.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_maximum.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ import numpy as np -import mindspore.nn as nn -import mindspore.context as context + import mindspore as ms +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor -from mindspore.train.model import Model from mindspore.ops import operations as P +from mindspore.train.model import Model context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_maximum_grad.py b/tests/st/ops/ascend/test_tbe_ops/test_maximum_grad.py index 7c32e01b455..35252dfabbe 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_maximum_grad.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_maximum_grad.py @@ -13,6 +13,7 @@ # limitations under the License. # ============================================================================ import numpy as np + import mindspore.context as context from mindspore import Tensor from mindspore.nn import Cell diff --git a/tests/st/ops/ascend/test_tbe_ops/test_maxpool.py b/tests/st/ops/ascend/test_tbe_ops/test_maxpool.py index 625eb0dc5ca..9cca14bc3bd 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_maxpool.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_maxpool.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P class Net(nn.Cell): diff --git a/tests/st/ops/ascend/test_tbe_ops/test_maxpool_grad.py b/tests/st/ops/ascend/test_tbe_ops/test_maxpool_grad.py index d9436ea2d2c..2bc1b45730d 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_maxpool_grad.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_maxpool_grad.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P from mindspore.ops.composite import GradOperation context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_minimum.py b/tests/st/ops/ascend/test_tbe_ops/test_minimum.py index 80a9bc8c3f9..3dce61b997e 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_minimum.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_minimum.py @@ -12,15 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + +import mindspore as ms import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter -import mindspore as ms +from mindspore.ops import operations as P from mindspore.train.model import Model context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_minimum_grad.py b/tests/st/ops/ascend/test_tbe_ops/test_minimum_grad.py index fc22e2a859d..dbde426728e 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_minimum_grad.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_minimum_grad.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -import mindspore.nn as nn import numpy as np + import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.nn import Cell from mindspore.ops import composite as C diff --git a/tests/st/ops/ascend/test_tbe_ops/test_mul.py b/tests/st/ops/ascend/test_tbe_ops/test_mul.py index d8030ffdc00..1018728872c 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_mul.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_mul.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_npu_alloc_float_status.py b/tests/st/ops/ascend/test_tbe_ops/test_npu_alloc_float_status.py index 2de0015fe54..42f1c86823a 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_npu_alloc_float_status.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_npu_alloc_float_status.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_npu_clear_float_status.py b/tests/st/ops/ascend/test_tbe_ops/test_npu_clear_float_status.py index 5f92b2b7ede..3955c049eff 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_npu_clear_float_status.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_npu_clear_float_status.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_npu_get_float_status.py b/tests/st/ops/ascend/test_tbe_ops/test_npu_get_float_status.py index 9e539eae86e..27bf9e3921f 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_npu_get_float_status.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_npu_get_float_status.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_pad.py b/tests/st/ops/ascend/test_tbe_ops/test_pad.py index 727939b7cde..113fcd0eef8 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_pad.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_pad.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_pow.py b/tests/st/ops/ascend/test_tbe_ops/test_pow.py index a0c3a94af4b..8acf5284704 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_pow.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_pow.py @@ -12,16 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np -from mindspore.nn import Cell + +import mindspore as ms import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter -import mindspore as ms +from mindspore.nn import Cell +from mindspore.ops import operations as P from mindspore.train.model import Model context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_realdiv.py b/tests/st/ops/ascend/test_tbe_ops/test_realdiv.py index 00e4ba0911d..f855c27b972 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_realdiv.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_realdiv.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_reciprocal.py b/tests/st/ops/ascend/test_tbe_ops/test_reciprocal.py index 278adc1dc2e..9249e24eefa 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_reciprocal.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_reciprocal.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_relu.py b/tests/st/ops/ascend/test_tbe_ops/test_relu.py index cc07c5d58a3..9ada58e6420 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_relu.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_relu.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_relu_grad.py b/tests/st/ops/ascend/test_tbe_ops/test_relu_grad.py index aef8aeb2141..94150db0710 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_relu_grad.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_relu_grad.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P from mindspore.ops.composite import GradOperation context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_relu_v2_grad.py b/tests/st/ops/ascend/test_tbe_ops/test_relu_v2_grad.py index ae736a5c4a5..351e7f617af 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_relu_v2_grad.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_relu_v2_grad.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P from mindspore.ops.composite import GradOperation context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_resize_nearest_neighbor.py b/tests/st/ops/ascend/test_tbe_ops/test_resize_nearest_neighbor.py index 62dc123b480..def0f928485 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_resize_nearest_neighbor.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_resize_nearest_neighbor.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_resize_nearest_neighbor_grad.py b/tests/st/ops/ascend/test_tbe_ops/test_resize_nearest_neighbor_grad.py index 115989e2729..4603fc59d86 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_resize_nearest_neighbor_grad.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_resize_nearest_neighbor_grad.py @@ -12,13 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.ops.composite import GradOperation -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P +from mindspore.ops.composite import GradOperation context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_scatter_nd.py b/tests/st/ops/ascend/test_tbe_ops/test_scatter_nd.py index e518e14d765..d79cca38469 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_scatter_nd.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_scatter_nd.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_select.py b/tests/st/ops/ascend/test_tbe_ops/test_select.py index b409b91b88f..5f149a590f1 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_select.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_select.py @@ -12,16 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np -from mindspore.nn import Cell + +import mindspore as ms import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter -import mindspore as ms +from mindspore.nn import Cell +from mindspore.ops import operations as P from mindspore.train.model import Model context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_sigmoid.py b/tests/st/ops/ascend/test_tbe_ops/test_sigmoid.py index 489b56a98c2..223a41135c2 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_sigmoid.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_sigmoid.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_sigmoid_cross_entropy_with_logits.py b/tests/st/ops/ascend/test_tbe_ops/test_sigmoid_cross_entropy_with_logits.py index 8014c687fc9..33f23a9b826 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_sigmoid_cross_entropy_with_logits.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_sigmoid_cross_entropy_with_logits.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_sigmoid_cross_entropy_with_logits_grad.py b/tests/st/ops/ascend/test_tbe_ops/test_sigmoid_cross_entropy_with_logits_grad.py index 4018c3c080b..f3eaef5b869 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_sigmoid_cross_entropy_with_logits_grad.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_sigmoid_cross_entropy_with_logits_grad.py @@ -12,13 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function -from mindspore.ops.composite import GradOperation import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P +from mindspore.ops.composite import GradOperation context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_sigmoid_grad.py b/tests/st/ops/ascend/test_tbe_ops/test_sigmoid_grad.py index 7813f7f8465..8e68ac3235b 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_sigmoid_grad.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_sigmoid_grad.py @@ -12,13 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.ops.composite import GradOperation -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P +from mindspore.ops.composite import GradOperation context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_slice.py b/tests/st/ops/ascend/test_tbe_ops/test_slice.py index 945da861b2a..afef248a20c 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_slice.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_slice.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_smooth_l1_loss.py b/tests/st/ops/ascend/test_tbe_ops/test_smooth_l1_loss.py index 1a751038dd9..9335bace876 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_smooth_l1_loss.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_smooth_l1_loss.py @@ -14,8 +14,9 @@ # ============================================================================ import numpy as np -import mindspore.nn as nn + import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P diff --git a/tests/st/ops/ascend/test_tbe_ops/test_smooth_l1_loss_grad.py b/tests/st/ops/ascend/test_tbe_ops/test_smooth_l1_loss_grad.py index bf4a5d89fe9..7d30ae4bed5 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_smooth_l1_loss_grad.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_smooth_l1_loss_grad.py @@ -14,11 +14,12 @@ # ============================================================================ import numpy as np -import mindspore.nn as nn + import mindspore.context as context -from mindspore.ops.composite import GradOperation +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P +from mindspore.ops.composite import GradOperation context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_softmax.py b/tests/st/ops/ascend/test_tbe_ops/test_softmax.py index 308e7d85edd..3c3cf776b2b 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_softmax.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_softmax.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_softmax_cross_entropy_with_logits.py b/tests/st/ops/ascend/test_tbe_ops/test_softmax_cross_entropy_with_logits.py index 32a66054261..1c08f194076 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_softmax_cross_entropy_with_logits.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_softmax_cross_entropy_with_logits.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_split.py b/tests/st/ops/ascend/test_tbe_ops/test_split.py index a31c126147f..51279d6de06 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_split.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_split.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_sqrt.py b/tests/st/ops/ascend/test_tbe_ops/test_sqrt.py index 37d5b6962a2..207dcce6b1a 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_sqrt.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_sqrt.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_square.py b/tests/st/ops/ascend/test_tbe_ops/test_square.py index 3a9b10c9bef..64005672c34 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_square.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_square.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_stridedslice.py b/tests/st/ops/ascend/test_tbe_ops/test_stridedslice.py index 1195d1352c0..8908cb1d5f2 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_stridedslice.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_stridedslice.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ import numpy as np -from mindspore.common.tensor import Tensor +import pytest + +import mindspore.context as context import mindspore.ops.operations as P +from mindspore.common.tensor import Tensor from mindspore.nn import Cell from mindspore.train.model import Model -import pytest -import mindspore.context as context context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_stridedslice_grad.py b/tests/st/ops/ascend/test_tbe_ops/test_stridedslice_grad.py index 4bf4bee31a6..9e693c78daa 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_stridedslice_grad.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_stridedslice_grad.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ import numpy as np -from mindspore.common.tensor import Tensor -from mindspore.ops import operations as P -from mindspore.nn import Cell -from mindspore.ops.composite import GradOperation -from mindspore import context import pytest +from mindspore import context +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P +from mindspore.ops.composite import GradOperation + context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_sub.py b/tests/st/ops/ascend/test_tbe_ops/test_sub.py index ae2fede2128..97248082e82 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_sub.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_sub.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_tanh.py b/tests/st/ops/ascend/test_tbe_ops/test_tanh.py index e8894013781..5af2d296001 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_tanh.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_tanh.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================ import numpy as np -import mindspore.nn as nn + import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor -from mindspore.train.model import Model from mindspore.ops import operations as P +from mindspore.train.model import Model context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_tanh_grad.py b/tests/st/ops/ascend/test_tbe_ops/test_tanh_grad.py index 4dcf79e6478..04ada07d6ce 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_tanh_grad.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_tanh_grad.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ import numpy as np -import mindspore.nn as nn + import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor -from mindspore.train.model import Model from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G +from mindspore.train.model import Model context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_tile.py b/tests/st/ops/ascend/test_tbe_ops/test_tile.py index b613fb8fa5a..02e5b5890bd 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_tile.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_tile.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_topk.py b/tests/st/ops/ascend/test_tbe_ops/test_topk.py index 4ca22b211c7..907c8534150 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_topk.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_topk.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_transpose_d.py b/tests/st/ops/ascend/test_tbe_ops/test_transpose_d.py index 14bed5fbf09..3f1367cc6f1 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_transpose_d.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_transpose_d.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================ import numpy as np -import mindspore.nn as nn + import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor -from mindspore.train.model import Model from mindspore.ops import operations as P +from mindspore.train.model import Model context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tbe_ops/test_unsorted_segment_sum.py b/tests/st/ops/ascend/test_tbe_ops/test_unsorted_segment_sum.py index 9a98f94bc56..75ce11d935f 100644 --- a/tests/st/ops/ascend/test_tbe_ops/test_unsorted_segment_sum.py +++ b/tests/st/ops/ascend/test_tbe_ops/test_unsorted_segment_sum.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================ import numpy as np -import mindspore.nn as nn + import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor -from mindspore.train.model import Model from mindspore.ops import operations as P +from mindspore.train.model import Model context.set_context(device_target="Ascend") diff --git a/tests/st/ops/ascend/test_tdt_data_ms.py b/tests/st/ops/ascend/test_tdt_data_ms.py index fb42a28a2fc..e4e1b1cf734 100644 --- a/tests/st/ops/ascend/test_tdt_data_ms.py +++ b/tests/st/ops/ascend/test_tdt_data_ms.py @@ -12,16 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -import mindspore.dataset as ds -import mindspore.dataset.transforms.vision.c_transforms as vision -from mindspore.dataset.transforms.vision import Inter import numpy as np import sys import mindspore.context as context +import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as vision import mindspore.nn as nn -from mindspore.common.tensor import Tensor from mindspore.common.api import _executor +from mindspore.common.tensor import Tensor +from mindspore.dataset.transforms.vision import Inter from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/cpu/test_argmax_op.py b/tests/st/ops/cpu/test_argmax_op.py index b3d8fed4660..01481e427a7 100644 --- a/tests/st/ops/cpu/test_argmax_op.py +++ b/tests/st/ops/cpu/test_argmax_op.py @@ -13,15 +13,16 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor from mindspore.common import dtype as mstype from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="CPU") diff --git a/tests/st/ops/cpu/test_bias_add.py b/tests/st/ops/cpu/test_bias_add.py index 11e7cd36629..0d65cf06208 100644 --- a/tests/st/ops/cpu/test_bias_add.py +++ b/tests/st/ops/cpu/test_bias_add.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context context.set_context(mode=context.GRAPH_MODE, device_target='CPU') diff --git a/tests/st/ops/cpu/test_bias_add_grad.py b/tests/st/ops/cpu/test_bias_add_grad.py index 01253fd03b7..bb3d7411005 100644 --- a/tests/st/ops/cpu/test_bias_add_grad.py +++ b/tests/st/ops/cpu/test_bias_add_grad.py @@ -12,13 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G -import mindspore.nn as nn -import numpy as np -import mindspore.context as context context.set_context(mode=context.GRAPH_MODE, device_target='CPU') diff --git a/tests/st/ops/cpu/test_conv2d_backprop_filter_op.py b/tests/st/ops/cpu/test_conv2d_backprop_filter_op.py index bde48446acd..a422468b2e1 100644 --- a/tests/st/ops/cpu/test_conv2d_backprop_filter_op.py +++ b/tests/st/ops/cpu/test_conv2d_backprop_filter_op.py @@ -13,15 +13,16 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.ops.operations import _grad_ops as G -import mindspore.nn as nn import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P +from mindspore.ops.operations import _grad_ops as G context.set_context(mode=context.GRAPH_MODE, device_target='CPU') diff --git a/tests/st/ops/cpu/test_conv2d_backprop_input_op.py b/tests/st/ops/cpu/test_conv2d_backprop_input_op.py index 952bef41e58..a75e676507f 100644 --- a/tests/st/ops/cpu/test_conv2d_backprop_input_op.py +++ b/tests/st/ops/cpu/test_conv2d_backprop_input_op.py @@ -13,14 +13,15 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target='CPU') diff --git a/tests/st/ops/cpu/test_conv2d_op.py b/tests/st/ops/cpu/test_conv2d_op.py index 061115e12af..627a722b5b8 100644 --- a/tests/st/ops/cpu/test_conv2d_op.py +++ b/tests/st/ops/cpu/test_conv2d_op.py @@ -13,14 +13,15 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target='CPU') diff --git a/tests/st/ops/cpu/test_equalcount_op.py b/tests/st/ops/cpu/test_equalcount_op.py index 5d16008a2b0..040e8a99caf 100644 --- a/tests/st/ops/cpu/test_equalcount_op.py +++ b/tests/st/ops/cpu/test_equalcount_op.py @@ -13,14 +13,15 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="CPU") diff --git a/tests/st/ops/cpu/test_maxpool_grad_op.py b/tests/st/ops/cpu/test_maxpool_grad_op.py index ed2a699bca2..d1e1032d1ca 100644 --- a/tests/st/ops/cpu/test_maxpool_grad_op.py +++ b/tests/st/ops/cpu/test_maxpool_grad_op.py @@ -13,15 +13,16 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.ops.operations import _grad_ops as G -import mindspore.nn as nn import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P +from mindspore.ops.operations import _grad_ops as G context.set_context(mode=context.GRAPH_MODE, device_target='CPU') diff --git a/tests/st/ops/cpu/test_maxpool_op.py b/tests/st/ops/cpu/test_maxpool_op.py index c9240dba673..d13e1cecb9f 100644 --- a/tests/st/ops/cpu/test_maxpool_op.py +++ b/tests/st/ops/cpu/test_maxpool_op.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -import mindspore.nn as nn import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor context.set_context(mode=context.GRAPH_MODE, device_target="CPU") diff --git a/tests/st/ops/cpu/test_momentum_op.py b/tests/st/ops/cpu/test_momentum_op.py index 445fe4e38ea..862e8eae770 100644 --- a/tests/st/ops/cpu/test_momentum_op.py +++ b/tests/st/ops/cpu/test_momentum_op.py @@ -13,15 +13,16 @@ # limitations under the License. # ============================================================================ -import pytest import numpy as np +import pytest + +import mindspore.context as context import mindspore.nn as nn +from mindspore import Tensor +from mindspore.nn import Dense +from mindspore.nn import TrainOneStepCell, WithLossCell from mindspore.nn.optim import Momentum from mindspore.ops import operations as P -from mindspore.nn import TrainOneStepCell, WithLossCell -from mindspore.nn import Dense -from mindspore import Tensor -import mindspore.context as context context.set_context(mode=context.GRAPH_MODE, device_target="CPU") diff --git a/tests/st/ops/cpu/test_mul_op.py b/tests/st/ops/cpu/test_mul_op.py index c5051fe92ae..ee9120505a1 100644 --- a/tests/st/ops/cpu/test_mul_op.py +++ b/tests/st/ops/cpu/test_mul_op.py @@ -13,15 +13,16 @@ # limitations under the License. # == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P x = np.random.uniform(-2, 2, (2, 3, 4, 4)).astype(np.float32) y = np.random.uniform(-2, 2, (1, 1, 1, 1)).astype(np.float32) diff --git a/tests/st/ops/cpu/test_one_hot_op.py b/tests/st/ops/cpu/test_one_hot_op.py index 3f2c54b3cb6..3383049db7c 100644 --- a/tests/st/ops/cpu/test_one_hot_op.py +++ b/tests/st/ops/cpu/test_one_hot_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target='CPU') diff --git a/tests/st/ops/cpu/test_relu_grad_op.py b/tests/st/ops/cpu/test_relu_grad_op.py index a4b2bb98c55..2eb0ef4693d 100644 --- a/tests/st/ops/cpu/test_relu_grad_op.py +++ b/tests/st/ops/cpu/test_relu_grad_op.py @@ -13,15 +13,16 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.ops.operations import _grad_ops as G -import mindspore.nn as nn import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P +from mindspore.ops.operations import _grad_ops as G context.set_context(mode=context.GRAPH_MODE, device_target='CPU') diff --git a/tests/st/ops/cpu/test_relu_op.py b/tests/st/ops/cpu/test_relu_op.py index 9ef3f0af063..b2b64eb61aa 100644 --- a/tests/st/ops/cpu/test_relu_op.py +++ b/tests/st/ops/cpu/test_relu_op.py @@ -13,14 +13,15 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target='CPU') diff --git a/tests/st/ops/cpu/test_softmax_op.py b/tests/st/ops/cpu/test_softmax_op.py index 2a360f55b2a..ca3fef003da 100644 --- a/tests/st/ops/cpu/test_softmax_op.py +++ b/tests/st/ops/cpu/test_softmax_op.py @@ -13,14 +13,15 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target='CPU') diff --git a/tests/st/ops/cpu/test_softmax_with_cross_entropy_op.py b/tests/st/ops/cpu/test_softmax_with_cross_entropy_op.py index a6166b472b4..b00dc9e3238 100644 --- a/tests/st/ops/cpu/test_softmax_with_cross_entropy_op.py +++ b/tests/st/ops/cpu/test_softmax_with_cross_entropy_op.py @@ -13,14 +13,15 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target='CPU') diff --git a/tests/st/ops/custom_ops_tbe/conv2d.py b/tests/st/ops/custom_ops_tbe/conv2d.py index 182b33ba7c0..ded0e77b81d 100755 --- a/tests/st/ops/custom_ops_tbe/conv2d.py +++ b/tests/st/ops/custom_ops_tbe/conv2d.py @@ -13,12 +13,14 @@ # limitations under the License. # ============================================================================ from __future__ import absolute_import + import te.lang.cce +from te import platform as cce from te.platform.fusion_manager import fusion_manager +from topi.cce import util + from .conv_layer import conv_layer_cce from .conv_layer_fast import conv_layer_fast_cce -from topi.cce import util -from te import platform as cce Nonetype = type(None) diff --git a/tests/st/ops/custom_ops_tbe/cus_conv2d.py b/tests/st/ops/custom_ops_tbe/cus_conv2d.py index 11b6b771692..8cf8177ecba 100644 --- a/tests/st/ops/custom_ops_tbe/cus_conv2d.py +++ b/tests/st/ops/custom_ops_tbe/cus_conv2d.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -import numpy as np import math +import numpy as np from functools import reduce -from mindspore.ops import prim_attr_register, PrimitiveWithInfer + from mindspore import Tensor from mindspore._checkparam import ParamValidator as validator from mindspore._checkparam import Rel, check_bool, check_int_positive, twice from mindspore.common import dtype as mstype +from mindspore.ops import prim_attr_register, PrimitiveWithInfer class Cus_Conv2D(PrimitiveWithInfer): diff --git a/tests/st/ops/custom_ops_tbe/cus_conv2d_impl.py b/tests/st/ops/custom_ops_tbe/cus_conv2d_impl.py index 04ac7c2ff70..1e27ab754f7 100644 --- a/tests/st/ops/custom_ops_tbe/cus_conv2d_impl.py +++ b/tests/st/ops/custom_ops_tbe/cus_conv2d_impl.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from tests.st.ops.custom_ops_tbe.conv2d import conv2d from mindspore.ops.op_info_register import op_info_register, TBERegOp, DataType +from tests.st.ops.custom_ops_tbe.conv2d import conv2d cus_conv2D_op_info = TBERegOp("Cus_Conv2D") \ .fusion_type("CONVLUTION") \ diff --git a/tests/st/ops/custom_ops_tbe/cus_square.py b/tests/st/ops/custom_ops_tbe/cus_square.py index a0cfd1dd14d..48f9f5e43fc 100644 --- a/tests/st/ops/custom_ops_tbe/cus_square.py +++ b/tests/st/ops/custom_ops_tbe/cus_square.py @@ -13,8 +13,9 @@ # limitations under the License. # ============================================================================ import numpy as np -from mindspore.ops import prim_attr_register, PrimitiveWithInfer + from mindspore import Tensor +from mindspore.ops import prim_attr_register, PrimitiveWithInfer # y = x^2 diff --git a/tests/st/ops/custom_ops_tbe/square_impl.py b/tests/st/ops/custom_ops_tbe/square_impl.py index f3a1e0751de..cd8e368e9ae 100644 --- a/tests/st/ops/custom_ops_tbe/square_impl.py +++ b/tests/st/ops/custom_ops_tbe/square_impl.py @@ -13,11 +13,13 @@ # limitations under the License. # ============================================================================ from __future__ import absolute_import -from te import tvm -from topi import generic + import te.lang.cce -from topi.cce import util +from te import tvm from te.platform.fusion_manager import fusion_manager +from topi import generic +from topi.cce import util + from mindspore.ops.op_info_register import op_info_register, TBERegOp, DataType # shape size limit for aicore is 2**31 diff --git a/tests/st/ops/custom_ops_tbe/test_cus_conv.py b/tests/st/ops/custom_ops_tbe/test_cus_conv.py index 5205dd8b6b7..5f460584db5 100644 --- a/tests/st/ops/custom_ops_tbe/test_cus_conv.py +++ b/tests/st/ops/custom_ops_tbe/test_cus_conv.py @@ -12,11 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore import Tensor -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter from .cus_conv2d import Cus_Conv2D diff --git a/tests/st/ops/custom_ops_tbe/test_square.py b/tests/st/ops/custom_ops_tbe/test_square.py index 189c710bbcc..ec60974f9a5 100644 --- a/tests/st/ops/custom_ops_tbe/test_square.py +++ b/tests/st/ops/custom_ops_tbe/test_square.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================ import numpy as np -import mindspore.nn as nn -import mindspore.context as context -from mindspore import Tensor -from cus_square import CusSquare import pytest +from cus_square import CusSquare + +import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") diff --git a/tests/st/ops/gpu/test_addn_op.py b/tests/st/ops/gpu/test_addn_op.py index 8dd6682f2d5..45926742a94 100644 --- a/tests/st/ops/gpu/test_addn_op.py +++ b/tests/st/ops/gpu/test_addn_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target='GPU') diff --git a/tests/st/ops/gpu/test_argmax_op.py b/tests/st/ops/gpu/test_argmax_op.py index 33e573c01c7..96f94c54f3a 100644 --- a/tests/st/ops/gpu/test_argmax_op.py +++ b/tests/st/ops/gpu/test_argmax_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ -import pytest import numpy as np -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.common import dtype as mstype -import mindspore.nn as nn +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common import dtype as mstype +from mindspore.ops import operations as P class NetArgmax(nn.Cell): diff --git a/tests/st/ops/gpu/test_assign_add_op.py b/tests/st/ops/gpu/test_assign_add_op.py index 93d9b7d53fd..8fd7f6b1340 100644 --- a/tests/st/ops/gpu/test_assign_add_op.py +++ b/tests/st/ops/gpu/test_assign_add_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor, Parameter from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class AssignAdd(nn.Cell): diff --git a/tests/st/ops/gpu/test_assign_op.py b/tests/st/ops/gpu/test_assign_op.py index f7bf5ebb944..74c2ebafbff 100644 --- a/tests/st/ops/gpu/test_assign_op.py +++ b/tests/st/ops/gpu/test_assign_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor, Parameter from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class Net(nn.Cell): diff --git a/tests/st/ops/gpu/test_batch_matmul.py b/tests/st/ops/gpu/test_batch_matmul.py index 4eff96f4124..ee7ab249951 100644 --- a/tests/st/ops/gpu/test_batch_matmul.py +++ b/tests/st/ops/gpu/test_batch_matmul.py @@ -13,16 +13,17 @@ # limitations under the License. # ============================================================================ -import pytest import numpy as np +import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor -from mindspore.ops import operations as P +from mindspore.common import dtype as mstype from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter -import mindspore.nn as nn -import mindspore.context as context -from mindspore.common import dtype as mstype +from mindspore.ops import operations as P @pytest.mark.level0 diff --git a/tests/st/ops/gpu/test_batchnorm_fold2_op.py b/tests/st/ops/gpu/test_batchnorm_fold2_op.py index 0440e92a8dc..eaaf10ef07b 100644 --- a/tests/st/ops/gpu/test_batchnorm_fold2_op.py +++ b/tests/st/ops/gpu/test_batchnorm_fold2_op.py @@ -15,11 +15,12 @@ import numpy as np import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target='GPU') diff --git a/tests/st/ops/gpu/test_batchnorm_fold_grad_op.py b/tests/st/ops/gpu/test_batchnorm_fold_grad_op.py index 8e55f6a473f..8bf623371d2 100644 --- a/tests/st/ops/gpu/test_batchnorm_fold_grad_op.py +++ b/tests/st/ops/gpu/test_batchnorm_fold_grad_op.py @@ -15,11 +15,12 @@ import numpy as np import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target='GPU') diff --git a/tests/st/ops/gpu/test_batchnorm_fold_op.py b/tests/st/ops/gpu/test_batchnorm_fold_op.py index c4abf152a62..f7e1a2deb8c 100644 --- a/tests/st/ops/gpu/test_batchnorm_fold_op.py +++ b/tests/st/ops/gpu/test_batchnorm_fold_op.py @@ -15,11 +15,12 @@ import numpy as np import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target='GPU') diff --git a/tests/st/ops/gpu/test_batchnorm_op.py b/tests/st/ops/gpu/test_batchnorm_op.py index a7ff153016d..28689bfe0eb 100644 --- a/tests/st/ops/gpu/test_batchnorm_op.py +++ b/tests/st/ops/gpu/test_batchnorm_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ -import pytest import numpy as np -from mindspore.nn import Cell -from mindspore.nn import BatchNorm2d -from mindspore.common.tensor import Tensor -from mindspore.ops import composite as C +import pytest + import mindspore.context as context +from mindspore.common.tensor import Tensor +from mindspore.nn import BatchNorm2d +from mindspore.nn import Cell +from mindspore.ops import composite as C class Batchnorm_Net(Cell): diff --git a/tests/st/ops/gpu/test_broadcast_op.py b/tests/st/ops/gpu/test_broadcast_op.py index b124543fe70..e102d17ff36 100644 --- a/tests/st/ops/gpu/test_broadcast_op.py +++ b/tests/st/ops/gpu/test_broadcast_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest -from mindspore.ops import operations as P -from mindspore.nn import Cell -from mindspore.common.tensor import Tensor + import mindspore.common.dtype as mstype import mindspore.context as context -import numpy as np +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P @pytest.mark.level0 diff --git a/tests/st/ops/gpu/test_cast_op.py b/tests/st/ops/gpu/test_cast_op.py index 0855be1a83b..e7a0563b15b 100644 --- a/tests/st/ops/gpu/test_cast_op.py +++ b/tests/st/ops/gpu/test_cast_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest -from mindspore.ops import operations as P -from mindspore.nn import Cell -from mindspore.common.tensor import Tensor + import mindspore.common.dtype as mstype import mindspore.context as context -import numpy as np +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P class Net(Cell): diff --git a/tests/st/ops/gpu/test_concatv2_op.py b/tests/st/ops/gpu/test_concatv2_op.py index 0c461fe49f5..dc71e9622b8 100644 --- a/tests/st/ops/gpu/test_concatv2_op.py +++ b/tests/st/ops/gpu/test_concatv2_op.py @@ -13,15 +13,16 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(device_target='GPU') diff --git a/tests/st/ops/gpu/test_conv2d_backprop_filter_op.py b/tests/st/ops/gpu/test_conv2d_backprop_filter_op.py index aa9abb2b902..a545bd841ab 100644 --- a/tests/st/ops/gpu/test_conv2d_backprop_filter_op.py +++ b/tests/st/ops/gpu/test_conv2d_backprop_filter_op.py @@ -13,14 +13,15 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G -import mindspore.nn as nn -from mindspore.common.api import ms_function -import numpy as np -import mindspore.context as context context.set_context(device_target='GPU') diff --git a/tests/st/ops/gpu/test_conv2d_backprop_input_op.py b/tests/st/ops/gpu/test_conv2d_backprop_input_op.py index dcc6846100b..bbe672a0796 100644 --- a/tests/st/ops/gpu/test_conv2d_backprop_input_op.py +++ b/tests/st/ops/gpu/test_conv2d_backprop_input_op.py @@ -13,15 +13,16 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(device_target='GPU') diff --git a/tests/st/ops/gpu/test_conv2d_op.py b/tests/st/ops/gpu/test_conv2d_op.py index 1bac156c373..850c8968a2c 100644 --- a/tests/st/ops/gpu/test_conv2d_op.py +++ b/tests/st/ops/gpu/test_conv2d_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ -import pytest import numpy as np +import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import mindspore.context as context class NetConv2d(nn.Cell): diff --git a/tests/st/ops/gpu/test_correction_mul_grad_op.py b/tests/st/ops/gpu/test_correction_mul_grad_op.py index ab434447ef6..531e51ed2ea 100644 --- a/tests/st/ops/gpu/test_correction_mul_grad_op.py +++ b/tests/st/ops/gpu/test_correction_mul_grad_op.py @@ -14,13 +14,14 @@ # ============================================================================ import numpy as np -import pytest import os -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target='GPU') diff --git a/tests/st/ops/gpu/test_correction_mul_op.py b/tests/st/ops/gpu/test_correction_mul_op.py index 01389e148cc..9a5ab6728b0 100644 --- a/tests/st/ops/gpu/test_correction_mul_op.py +++ b/tests/st/ops/gpu/test_correction_mul_op.py @@ -15,11 +15,12 @@ import numpy as np import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target='GPU') diff --git a/tests/st/ops/gpu/test_dense_op.py b/tests/st/ops/gpu/test_dense_op.py index 2789e3e9f6d..700f41ea322 100644 --- a/tests/st/ops/gpu/test_dense_op.py +++ b/tests/st/ops/gpu/test_dense_op.py @@ -13,15 +13,16 @@ # limitations under the License. # ============================================================================ -import pytest import numpy as np -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn +import pytest + import mindspore.context as context -from mindspore.ops.composite import GradOperation +import mindspore.nn as nn +from mindspore import Tensor from mindspore.common.parameter import ParameterTuple from mindspore.ops import composite as C +from mindspore.ops import operations as P +from mindspore.ops.composite import GradOperation class BiasAdd(nn.Cell): diff --git a/tests/st/ops/gpu/test_equal_op.py b/tests/st/ops/gpu/test_equal_op.py index cf0f7463693..62dfeee1eb0 100644 --- a/tests/st/ops/gpu/test_equal_op.py +++ b/tests/st/ops/gpu/test_equal_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore.ops import operations as P -from mindspore.nn import Cell -from mindspore.common.tensor import Tensor -import mindspore.context as context import numpy as np +import pytest + +import mindspore.context as context +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P class NetEqual(Cell): diff --git a/tests/st/ops/gpu/test_equalcount_op.py b/tests/st/ops/gpu/test_equalcount_op.py index 7cd55de4466..a3f629e7cc6 100644 --- a/tests/st/ops/gpu/test_equalcount_op.py +++ b/tests/st/ops/gpu/test_equalcount_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ -import pytest import numpy as np +import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import mindspore.context as context class NetEqualCount(nn.Cell): diff --git a/tests/st/ops/gpu/test_exp_op.py b/tests/st/ops/gpu/test_exp_op.py index ddab7975453..d87ea47c6c0 100644 --- a/tests/st/ops/gpu/test_exp_op.py +++ b/tests/st/ops/gpu/test_exp_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class NetExp(nn.Cell): diff --git a/tests/st/ops/gpu/test_flatten_grad_op.py b/tests/st/ops/gpu/test_flatten_grad_op.py index 68150ea5940..d55c59c3841 100644 --- a/tests/st/ops/gpu/test_flatten_grad_op.py +++ b/tests/st/ops/gpu/test_flatten_grad_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class NetFlattenGrad(nn.Cell): diff --git a/tests/st/ops/gpu/test_flatten_op.py b/tests/st/ops/gpu/test_flatten_op.py index 258cc53b9fa..1c033a471a3 100644 --- a/tests/st/ops/gpu/test_flatten_op.py +++ b/tests/st/ops/gpu/test_flatten_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class NetFlatten(nn.Cell): diff --git a/tests/st/ops/gpu/test_float_status_op.py b/tests/st/ops/gpu/test_float_status_op.py index 2b474187e95..5ba20130581 100644 --- a/tests/st/ops/gpu/test_float_status_op.py +++ b/tests/st/ops/gpu/test_float_status_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class Net(nn.Cell): diff --git a/tests/st/ops/gpu/test_gather_op.py b/tests/st/ops/gpu/test_gather_op.py index 758a5ca654a..8d11cb32c6a 100644 --- a/tests/st/ops/gpu/test_gather_op.py +++ b/tests/st/ops/gpu/test_gather_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class GatherNet(nn.Cell): diff --git a/tests/st/ops/gpu/test_gelu_grad_op.py b/tests/st/ops/gpu/test_gelu_grad_op.py index 9e04c79366c..24137c241dc 100644 --- a/tests/st/ops/gpu/test_gelu_grad_op.py +++ b/tests/st/ops/gpu/test_gelu_grad_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ -import pytest import numpy as np -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor from mindspore.ops import composite as C +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="GPU") diff --git a/tests/st/ops/gpu/test_gelu_op.py b/tests/st/ops/gpu/test_gelu_op.py index 612df1530a4..d56f3e662d0 100644 --- a/tests/st/ops/gpu/test_gelu_op.py +++ b/tests/st/ops/gpu/test_gelu_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context context.set_context(mode=context.GRAPH_MODE, device_target="GPU") diff --git a/tests/st/ops/gpu/test_layer_norm_grad_op.py b/tests/st/ops/gpu/test_layer_norm_grad_op.py index f4cd907990d..91397a2fd23 100644 --- a/tests/st/ops/gpu/test_layer_norm_grad_op.py +++ b/tests/st/ops/gpu/test_layer_norm_grad_op.py @@ -13,14 +13,15 @@ # limitations under the License. # ============================================================================ -import pytest import numpy as np +import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor +from mindspore.ops import composite as C from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G -from mindspore.ops import composite as C -import mindspore.nn as nn -import mindspore.context as context context.set_context(mode=context.GRAPH_MODE, device_target="GPU") diff --git a/tests/st/ops/gpu/test_layer_norm_op.py b/tests/st/ops/gpu/test_layer_norm_op.py index 3a39577f3ce..776201735bd 100644 --- a/tests/st/ops/gpu/test_layer_norm_op.py +++ b/tests/st/ops/gpu/test_layer_norm_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ -import pytest import numpy as np +import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import mindspore.context as context context.set_context(mode=context.GRAPH_MODE, device_target="GPU") diff --git a/tests/st/ops/gpu/test_lessequal_op.py b/tests/st/ops/gpu/test_lessequal_op.py index 09b04815f0b..40281af2e1d 100644 --- a/tests/st/ops/gpu/test_lessequal_op.py +++ b/tests/st/ops/gpu/test_lessequal_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore.ops import operations as P -from mindspore.nn import Cell -from mindspore.common.tensor import Tensor -import mindspore.context as context import numpy as np +import pytest + +import mindspore.context as context +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P class Net(Cell): diff --git a/tests/st/ops/gpu/test_log_op.py b/tests/st/ops/gpu/test_log_op.py index e3de1232c9c..33ab09af9d3 100644 --- a/tests/st/ops/gpu/test_log_op.py +++ b/tests/st/ops/gpu/test_log_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class NetLog(nn.Cell): diff --git a/tests/st/ops/gpu/test_logical_op.py b/tests/st/ops/gpu/test_logical_op.py index 4af58ce43ed..015238783e0 100644 --- a/tests/st/ops/gpu/test_logical_op.py +++ b/tests/st/ops/gpu/test_logical_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore.ops import operations as P -from mindspore.nn import Cell -from mindspore.common.tensor import Tensor -import mindspore.context as context import numpy as np +import pytest + +import mindspore.context as context +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P class NetAnd(Cell): diff --git a/tests/st/ops/gpu/test_logsoftmax_op.py b/tests/st/ops/gpu/test_logsoftmax_op.py index ee54f763547..83e59beb636 100644 --- a/tests/st/ops/gpu/test_logsoftmax_op.py +++ b/tests/st/ops/gpu/test_logsoftmax_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ -import pytest import numpy as np -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.ops import composite as C -import mindspore.nn as nn +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.ops import composite as C +from mindspore.ops import operations as P @pytest.mark.level0 diff --git a/tests/st/ops/gpu/test_lstm_op.py b/tests/st/ops/gpu/test_lstm_op.py index f42ca5d1f10..e796a526d31 100644 --- a/tests/st/ops/gpu/test_lstm_op.py +++ b/tests/st/ops/gpu/test_lstm_op.py @@ -13,17 +13,18 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context import mindspore.nn as nn from mindspore.common.api import ms_function -import numpy as np -import mindspore.context as context from mindspore.common.initializer import initializer -from mindspore.ops import functional as F -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 ParameterTuple, Parameter +from mindspore.common.tensor import Tensor +from mindspore.ops import composite as C +from mindspore.ops import functional as F +from mindspore.ops import operations as P context.set_context(device_target='GPU') diff --git a/tests/st/ops/gpu/test_maximum_op.py b/tests/st/ops/gpu/test_maximum_op.py index 7f6c03d7188..6b869d981ea 100644 --- a/tests/st/ops/gpu/test_maximum_op.py +++ b/tests/st/ops/gpu/test_maximum_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore.ops import operations as P -from mindspore.ops import composite as C -from mindspore.nn import Cell -from mindspore.common.tensor import Tensor -import mindspore.context as context import numpy as np +import pytest + +import mindspore.context as context +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import composite as C +from mindspore.ops import operations as P class Net(Cell): diff --git a/tests/st/ops/gpu/test_maxpool_gpu_op.py b/tests/st/ops/gpu/test_maxpool_gpu_op.py index 2fc0afff5d8..c83a9f16154 100644 --- a/tests/st/ops/gpu/test_maxpool_gpu_op.py +++ b/tests/st/ops/gpu/test_maxpool_gpu_op.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -import mindspore.nn as nn import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor class Net_Pool(nn.Cell): diff --git a/tests/st/ops/gpu/test_maxpool_grad_gpu_op.py b/tests/st/ops/gpu/test_maxpool_grad_gpu_op.py index 40bc965e551..6a99591f045 100644 --- a/tests/st/ops/gpu/test_maxpool_grad_gpu_op.py +++ b/tests/st/ops/gpu/test_maxpool_grad_gpu_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class Net_Pool_Grad(nn.Cell): diff --git a/tests/st/ops/gpu/test_minimum_op.py b/tests/st/ops/gpu/test_minimum_op.py index 4297c1a77d6..b071b1759d9 100644 --- a/tests/st/ops/gpu/test_minimum_op.py +++ b/tests/st/ops/gpu/test_minimum_op.py @@ -13,14 +13,15 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest -from mindspore.ops import operations as P -from mindspore.ops import composite as C -from mindspore.nn import Cell -from mindspore.common.tensor import Tensor + import mindspore.common.dtype as mstype import mindspore.context as context -import numpy as np +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import composite as C +from mindspore.ops import operations as P class MinimumNet(Cell): diff --git a/tests/st/ops/gpu/test_momentum_op.py b/tests/st/ops/gpu/test_momentum_op.py index b3e248c2c97..2ce6f9ee6e4 100644 --- a/tests/st/ops/gpu/test_momentum_op.py +++ b/tests/st/ops/gpu/test_momentum_op.py @@ -13,16 +13,17 @@ # limitations under the License. # ============================================================================ -import pytest import numpy as np +import pytest + +import mindspore.context as context import mindspore.nn as nn -from mindspore.nn.optim import Momentum -from mindspore.ops import operations as P -from mindspore.nn import TrainOneStepCell, WithLossCell -from mindspore.nn import Dense from mindspore import Tensor from mindspore.common.initializer import initializer -import mindspore.context as context +from mindspore.nn import Dense +from mindspore.nn import TrainOneStepCell, WithLossCell +from mindspore.nn.optim import Momentum +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="GPU") diff --git a/tests/st/ops/gpu/test_mul_op.py b/tests/st/ops/gpu/test_mul_op.py index d0ebd7e5000..d5929e5b3ae 100644 --- a/tests/st/ops/gpu/test_mul_op.py +++ b/tests/st/ops/gpu/test_mul_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class NetMul(nn.Cell): diff --git a/tests/st/ops/gpu/test_neg_op.py b/tests/st/ops/gpu/test_neg_op.py index 4602d0985c2..6e34de4453b 100644 --- a/tests/st/ops/gpu/test_neg_op.py +++ b/tests/st/ops/gpu/test_neg_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class NetNeg(nn.Cell): diff --git a/tests/st/ops/gpu/test_one_hot_op.py b/tests/st/ops/gpu/test_one_hot_op.py index cf670154a7f..052e6ea34b9 100644 --- a/tests/st/ops/gpu/test_one_hot_op.py +++ b/tests/st/ops/gpu/test_one_hot_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P context.set_context(device_target='GPU') diff --git a/tests/st/ops/gpu/test_realdiv_op.py b/tests/st/ops/gpu/test_realdiv_op.py index ce911e2bb65..f911d784891 100644 --- a/tests/st/ops/gpu/test_realdiv_op.py +++ b/tests/st/ops/gpu/test_realdiv_op.py @@ -13,15 +13,16 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P class NetRealDiv(nn.Cell): diff --git a/tests/st/ops/gpu/test_reciprocal_op.py b/tests/st/ops/gpu/test_reciprocal_op.py index c90dad5f547..83d9b52ece6 100644 --- a/tests/st/ops/gpu/test_reciprocal_op.py +++ b/tests/st/ops/gpu/test_reciprocal_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class NetReciprocal(nn.Cell): diff --git a/tests/st/ops/gpu/test_reduce_max_op.py b/tests/st/ops/gpu/test_reduce_max_op.py index cf6973e76ab..600e872b5de 100644 --- a/tests/st/ops/gpu/test_reduce_max_op.py +++ b/tests/st/ops/gpu/test_reduce_max_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P x0 = np.random.rand(2, 3, 4, 4).astype(np.float32) axis0 = 3 diff --git a/tests/st/ops/gpu/test_reduce_mean_op.py b/tests/st/ops/gpu/test_reduce_mean_op.py index 8ef045c9261..ca4b3ea027b 100644 --- a/tests/st/ops/gpu/test_reduce_mean_op.py +++ b/tests/st/ops/gpu/test_reduce_mean_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P x0 = np.random.rand(2, 3, 4, 4).astype(np.float32) axis0 = 3 diff --git a/tests/st/ops/gpu/test_reduce_sum_op.py b/tests/st/ops/gpu/test_reduce_sum_op.py index 34af1fcb6d6..94a9ea3de2e 100644 --- a/tests/st/ops/gpu/test_reduce_sum_op.py +++ b/tests/st/ops/gpu/test_reduce_sum_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.ops import operations as P x0 = np.random.rand(2, 3, 4, 4).astype(np.float32) axis0 = 3 diff --git a/tests/st/ops/gpu/test_relu6_grad_op.py b/tests/st/ops/gpu/test_relu6_grad_op.py index a589366372e..dba788c2714 100644 --- a/tests/st/ops/gpu/test_relu6_grad_op.py +++ b/tests/st/ops/gpu/test_relu6_grad_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class NetReLU6Grad(nn.Cell): diff --git a/tests/st/ops/gpu/test_relu6_op.py b/tests/st/ops/gpu/test_relu6_op.py index 6be7921b2da..f491fe985fa 100644 --- a/tests/st/ops/gpu/test_relu6_op.py +++ b/tests/st/ops/gpu/test_relu6_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class NetReLU6(nn.Cell): diff --git a/tests/st/ops/gpu/test_relu_grad_op.py b/tests/st/ops/gpu/test_relu_grad_op.py index 7c3369f756f..5fb1fb6ad0b 100644 --- a/tests/st/ops/gpu/test_relu_grad_op.py +++ b/tests/st/ops/gpu/test_relu_grad_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class NetReluGrad(nn.Cell): diff --git a/tests/st/ops/gpu/test_relu_op.py b/tests/st/ops/gpu/test_relu_op.py index 229f837a9a8..ddd0fa6574e 100644 --- a/tests/st/ops/gpu/test_relu_op.py +++ b/tests/st/ops/gpu/test_relu_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class NetRelu(nn.Cell): diff --git a/tests/st/ops/gpu/test_select_op.py b/tests/st/ops/gpu/test_select_op.py index 924f44504c1..610b03e1982 100644 --- a/tests/st/ops/gpu/test_select_op.py +++ b/tests/st/ops/gpu/test_select_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class Net(nn.Cell): diff --git a/tests/st/ops/gpu/test_slice.py b/tests/st/ops/gpu/test_slice.py index 110c7c87b96..490898ce4b7 100644 --- a/tests/st/ops/gpu/test_slice.py +++ b/tests/st/ops/gpu/test_slice.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class Slice(nn.Cell): diff --git a/tests/st/ops/gpu/test_slice_grad.py b/tests/st/ops/gpu/test_slice_grad.py index 8e12320c346..7a0c73ce1b5 100644 --- a/tests/st/ops/gpu/test_slice_grad.py +++ b/tests/st/ops/gpu/test_slice_grad.py @@ -13,14 +13,15 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G -import mindspore.nn as nn -from mindspore.common.api import ms_function -import numpy as np -import mindspore.context as context context.set_context(device_target='GPU') diff --git a/tests/st/ops/gpu/test_softmax_cross_entropy_with_logits_op.py b/tests/st/ops/gpu/test_softmax_cross_entropy_with_logits_op.py index 32034456afe..3e9714faadd 100644 --- a/tests/st/ops/gpu/test_softmax_cross_entropy_with_logits_op.py +++ b/tests/st/ops/gpu/test_softmax_cross_entropy_with_logits_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter diff --git a/tests/st/ops/gpu/test_softmax_op.py b/tests/st/ops/gpu/test_softmax_op.py index 2e204432a3b..c1803b47193 100644 --- a/tests/st/ops/gpu/test_softmax_op.py +++ b/tests/st/ops/gpu/test_softmax_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ -import pytest import numpy as np -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.ops import composite as C -import mindspore.nn as nn +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.ops import composite as C +from mindspore.ops import operations as P class NetSoftmax(nn.Cell): diff --git a/tests/st/ops/gpu/test_sparse_softmax_cross_entropy_with_logits_op.py b/tests/st/ops/gpu/test_sparse_softmax_cross_entropy_with_logits_op.py index a4afc081b60..7daa9e38dfe 100644 --- a/tests/st/ops/gpu/test_sparse_softmax_cross_entropy_with_logits_op.py +++ b/tests/st/ops/gpu/test_sparse_softmax_cross_entropy_with_logits_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function class NetSparseSoftmaxCrossEntropyWithLogits(nn.Cell): diff --git a/tests/st/ops/gpu/test_sqrt_op.py b/tests/st/ops/gpu/test_sqrt_op.py index ea892798cbd..b6f2f423356 100644 --- a/tests/st/ops/gpu/test_sqrt_op.py +++ b/tests/st/ops/gpu/test_sqrt_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context @pytest.mark.level0 diff --git a/tests/st/ops/gpu/test_stridedslice_grad_op.py b/tests/st/ops/gpu/test_stridedslice_grad_op.py index 48caa1bd4f1..2ab81368570 100644 --- a/tests/st/ops/gpu/test_stridedslice_grad_op.py +++ b/tests/st/ops/gpu/test_stridedslice_grad_op.py @@ -13,14 +13,15 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G -import mindspore.nn as nn -from mindspore.common.api import ms_function -import numpy as np -import mindspore.context as context context.set_context(mode=context.GRAPH_MODE, device_target='GPU') diff --git a/tests/st/ops/gpu/test_stridedslice_op.py b/tests/st/ops/gpu/test_stridedslice_op.py index c5cb285678f..d6e4776931b 100644 --- a/tests/st/ops/gpu/test_stridedslice_op.py +++ b/tests/st/ops/gpu/test_stridedslice_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context context.set_context(mode=context.GRAPH_MODE, device_target='GPU') diff --git a/tests/st/ops/gpu/test_sub_op.py b/tests/st/ops/gpu/test_sub_op.py index 44125e475b4..a65d02d9b34 100644 --- a/tests/st/ops/gpu/test_sub_op.py +++ b/tests/st/ops/gpu/test_sub_op.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context class Net(nn.Cell): diff --git a/tests/st/ops/gpu/test_tanh_op.py b/tests/st/ops/gpu/test_tanh_op.py index dc020b7d56d..2e9fa8811db 100644 --- a/tests/st/ops/gpu/test_tanh_op.py +++ b/tests/st/ops/gpu/test_tanh_op.py @@ -13,13 +13,14 @@ # limitations under the License. # ============================================================================ -import pytest import numpy as np +import pytest + +import mindspore.context as context import mindspore.nn as nn from mindspore import Tensor -from mindspore.ops import operations as P from mindspore.ops import composite as C -import mindspore.context as context +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE, device_target="GPU") diff --git a/tests/st/ops/gpu/test_tensoradd.py b/tests/st/ops/gpu/test_tensoradd.py index 7b73f512dc7..24958f10b26 100644 --- a/tests/st/ops/gpu/test_tensoradd.py +++ b/tests/st/ops/gpu/test_tensoradd.py @@ -13,15 +13,16 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(device_target='GPU') diff --git a/tests/st/ops/gpu/test_tile_op.py b/tests/st/ops/gpu/test_tile_op.py index 57c6ae95f6f..cc2145b8f1e 100644 --- a/tests/st/ops/gpu/test_tile_op.py +++ b/tests/st/ops/gpu/test_tile_op.py @@ -13,15 +13,16 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest -from mindspore.ops.operations import Tile -from mindspore.nn import Cell -from mindspore.common.tensor import Tensor -from mindspore.common.api import ms_function + import mindspore.context as context +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter -import numpy as np +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops.operations import Tile context.set_context(mode=context.GRAPH_MODE, device_target="GPU") diff --git a/tests/st/ops/gpu/test_transpose_op.py b/tests/st/ops/gpu/test_transpose_op.py index af94dfffcbc..87c2d86ee63 100644 --- a/tests/st/ops/gpu/test_transpose_op.py +++ b/tests/st/ops/gpu/test_transpose_op.py @@ -13,15 +13,16 @@ # limitations under the License. # ============================================================================ -import pytest import numpy as np +import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor -from mindspore.ops import operations as P from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter -import mindspore.nn as nn -import mindspore.context as context +from mindspore.ops import operations as P context.set_context(device_target='GPU') diff --git a/tests/st/ops/gpu/test_unsorted_segment_sum.py b/tests/st/ops/gpu/test_unsorted_segment_sum.py index 49e0099f6a4..62267d03834 100644 --- a/tests/st/ops/gpu/test_unsorted_segment_sum.py +++ b/tests/st/ops/gpu/test_unsorted_segment_sum.py @@ -13,16 +13,17 @@ # limitations under the License. # ============================================================================ -import pytest import numpy as np +import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor -from mindspore.ops import operations as P +from mindspore.common import dtype as mstype from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter -import mindspore.nn as nn -import mindspore.context as context -from mindspore.common import dtype as mstype +from mindspore.ops import operations as P context.set_context(device_target='GPU') diff --git a/tests/st/ops/gpu/test_zeroslike_op.py b/tests/st/ops/gpu/test_zeroslike_op.py index 50cfb0b4244..3532776876e 100644 --- a/tests/st/ops/gpu/test_zeroslike_op.py +++ b/tests/st/ops/gpu/test_zeroslike_op.py @@ -13,15 +13,16 @@ # limitations under the License. # ============================================================================ -import pytest -from mindspore import Tensor -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.api import ms_function import numpy as np +import pytest + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P context.set_context(mode=context.PYNATIVE_MODE, device_target="GPU") diff --git a/tests/st/ops/test_rmsprop.py b/tests/st/ops/test_rmsprop.py index 8732da75465..7f61ebb8941 100644 --- a/tests/st/ops/test_rmsprop.py +++ b/tests/st/ops/test_rmsprop.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================ +import numpy as np import pytest + +import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P -import mindspore.nn as nn -import numpy as np -import mindspore.context as context context.set_context(mode=context.GRAPH_MODE, device_target="GPU") diff --git a/tests/st/pynative/test_ascend_lenet.py b/tests/st/pynative/test_ascend_lenet.py index 4c1b854144c..284a3235cfc 100644 --- a/tests/st/pynative/test_ascend_lenet.py +++ b/tests/st/pynative/test_ascend_lenet.py @@ -12,20 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -import pytest -import numpy as np -import time import math +import numpy as np +import pytest +import time + import mindspore.nn as nn from mindspore import context, Tensor, ParameterTuple -from mindspore.ops import operations as P -from mindspore.common.initializer import TruncatedNormal -from mindspore.ops import functional as F -from mindspore.ops import composite as C from mindspore.common import dtype as mstype - -from mindspore.nn.wrap.cell_wrapper import WithLossCell +from mindspore.common.initializer import TruncatedNormal from mindspore.nn.optim import Momentum +from mindspore.nn.wrap.cell_wrapper import WithLossCell +from mindspore.ops import composite as C +from mindspore.ops import functional as F +from mindspore.ops import operations as P np.random.seed(1) diff --git a/tests/st/summary/test_davinci_summary.py b/tests/st/summary/test_davinci_summary.py index 2ee9e35aead..e12bc25f5ef 100644 --- a/tests/st/summary/test_davinci_summary.py +++ b/tests/st/summary/test_davinci_summary.py @@ -13,19 +13,19 @@ # limitations under the License. # ============================================================================ """ test model train """ -import os import numpy as np +import os +from apply_momentum import ApplyMomentum +import mindspore.context as context import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore.common.initializer import initializer +import mindspore.nn as wrap from mindspore import Tensor, Parameter, Model +from mindspore.common.api import ms_function +from mindspore.common.initializer import initializer from mindspore.nn.loss import SoftmaxCrossEntropyWithLogits from mindspore.nn.optim import Momentum -from mindspore.common.api import ms_function -import mindspore.nn as wrap -import mindspore.context as context -from apply_momentum import ApplyMomentum +from mindspore.ops import operations as P from mindspore.train.summary.summary_record import SummaryRecord CUR_DIR = os.getcwd() diff --git a/tests/st/summary/test_gpu_summary.py b/tests/st/summary/test_gpu_summary.py index 49ed76eb535..455941fd9b4 100644 --- a/tests/st/summary/test_gpu_summary.py +++ b/tests/st/summary/test_gpu_summary.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -import pytest -import os -import time -import shutil -import random import numpy as np -import mindspore.nn as nn +import os +import pytest +import random +import shutil +import time + import mindspore.context as context +import mindspore.nn as nn from mindspore.common.tensor import Tensor from mindspore.ops import operations as P from mindspore.train.summary.summary_record import SummaryRecord diff --git a/tests/st/tbe_networks/export_geir.py b/tests/st/tbe_networks/export_geir.py index e305476e390..f709d52b3d5 100644 --- a/tests/st/tbe_networks/export_geir.py +++ b/tests/st/tbe_networks/export_geir.py @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -import os import numpy as np +import os from resnet_torch import resnet50 -from mindspore import Tensor +from mindspore import Tensor from mindspore.train.serialization import save, load, _check_filedir_or_create, _chg_model_file_name_if_same_exist, \ _read_file_last_line, context, export diff --git a/tests/st/tbe_networks/resnet.py b/tests/st/tbe_networks/resnet.py index 4f2ff79a868..ef75b4509ef 100644 --- a/tests/st/tbe_networks/resnet.py +++ b/tests/st/tbe_networks/resnet.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================ import numpy as np + import mindspore.nn as nn from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.common.initializer import initializer from mindspore.common import dtype as mstype +from mindspore.common.initializer import initializer +from mindspore.ops import operations as P def weight_variable(shape): diff --git a/tests/st/tbe_networks/resnet_cifar.py b/tests/st/tbe_networks/resnet_cifar.py index be9e01bd2da..42a767d2281 100644 --- a/tests/st/tbe_networks/resnet_cifar.py +++ b/tests/st/tbe_networks/resnet_cifar.py @@ -13,25 +13,26 @@ # limitations under the License. # ============================================================================ import argparse -import mindspore.nn as nn -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.nn.optim.momentum import Momentum -from mindspore.train.model import Model, ParallelMode -from mindspore import context -import mindspore.common.dtype as mstype -import os import numpy as np -import mindspore.ops.functional as F -from mindspore.train.callback import ModelCheckpoint, CheckpointConfig, LossMonitor -from mindspore.train.serialization import load_checkpoint, load_param_into_net +import os +import random +from resnet import resnet50 + +import mindspore.common.dtype as mstype import mindspore.dataset as ds import mindspore.dataset.transforms.c_transforms as C import mindspore.dataset.transforms.vision.c_transforms as vision +import mindspore.nn as nn +import mindspore.ops.functional as F +from mindspore import Tensor +from mindspore import context from mindspore.communication.management import init +from mindspore.nn.optim.momentum import Momentum +from mindspore.ops import operations as P from mindspore.parallel._auto_parallel_context import auto_parallel_context -from resnet import resnet50 -import random +from mindspore.train.callback import ModelCheckpoint, CheckpointConfig, LossMonitor +from mindspore.train.model import Model, ParallelMode +from mindspore.train.serialization import load_checkpoint, load_param_into_net random.seed(1) np.random.seed(1) diff --git a/tests/st/tbe_networks/test_resnet_cifar_1p.py b/tests/st/tbe_networks/test_resnet_cifar_1p.py index af9f866209f..5d8c9578ef3 100644 --- a/tests/st/tbe_networks/test_resnet_cifar_1p.py +++ b/tests/st/tbe_networks/test_resnet_cifar_1p.py @@ -13,25 +13,26 @@ # limitations under the License. # ============================================================================ -import pytest -import mindspore.nn as nn -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.nn.optim.momentum import Momentum -from mindspore.train.model import Model -from mindspore import context -import mindspore.common.dtype as mstype -import os import numpy as np -import mindspore.ops.functional as F -from mindspore.train.callback import ModelCheckpoint, CheckpointConfig, Callback -from mindspore.train.serialization import load_checkpoint, load_param_into_net +import os +import pytest +import random +import time +from resnet import resnet50 + +import mindspore.common.dtype as mstype import mindspore.dataset as ds import mindspore.dataset.transforms.c_transforms as C import mindspore.dataset.transforms.vision.c_transforms as vision -from resnet import resnet50 -import random -import time +import mindspore.nn as nn +import mindspore.ops.functional as F +from mindspore import Tensor +from mindspore import context +from mindspore.nn.optim.momentum import Momentum +from mindspore.ops import operations as P +from mindspore.train.callback import ModelCheckpoint, CheckpointConfig, Callback +from mindspore.train.model import Model +from mindspore.train.serialization import load_checkpoint, load_param_into_net random.seed(1) np.random.seed(1) diff --git a/tests/st/tbe_networks/test_resnet_cifar_8p.py b/tests/st/tbe_networks/test_resnet_cifar_8p.py index 0033c944061..c27ce14c1be 100644 --- a/tests/st/tbe_networks/test_resnet_cifar_8p.py +++ b/tests/st/tbe_networks/test_resnet_cifar_8p.py @@ -13,26 +13,27 @@ # limitations under the License. # ============================================================================ -import pytest -import mindspore.nn as nn -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.nn.optim.momentum import Momentum -from mindspore.train.model import Model, ParallelMode -from mindspore import context -import mindspore.common.dtype as mstype -import os import numpy as np -import mindspore.ops.functional as F -from mindspore.train.callback import Callback +import os +import pytest +import random +from multiprocessing import Process, Queue +from resnet import resnet50 + +import mindspore.common.dtype as mstype import mindspore.dataset as ds import mindspore.dataset.transforms.c_transforms as C import mindspore.dataset.transforms.vision.c_transforms as vision +import mindspore.nn as nn +import mindspore.ops.functional as F +from mindspore import Tensor +from mindspore import context from mindspore.communication.management import init +from mindspore.nn.optim.momentum import Momentum +from mindspore.ops import operations as P from mindspore.parallel._auto_parallel_context import auto_parallel_context -from resnet import resnet50 -import random -from multiprocessing import Process, Queue +from mindspore.train.callback import Callback +from mindspore.train.model import Model, ParallelMode random.seed(1) np.random.seed(1) 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 d945d7286c8..9e7185a70b9 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,13 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from dataclasses import dataclass import numpy as np +from dataclasses import dataclass import mindspore as ms from mindspore.common.tensor import Tensor -from mindspore.ops import Primitive from mindspore.model_zoo.resnet import resnet50 +from mindspore.ops import Primitive scala_add = Primitive('scalar_add') 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 d79cd85aeb7..6b302841430 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 @@ -14,10 +14,11 @@ # ============================================================================ """ opt_test """ import numpy as np + +from mindspore import Tensor 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 # pylint: disable=unused-variable 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 f8b8c7c23a2..082759ac1bb 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 @@ -12,5 +12,5 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from .primitive_test import * from .infer_test import * +from .primitive_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 77fd75dce16..0ea1f03285d 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 @@ -13,6 +13,7 @@ # limitations under the License. # ============================================================================ from dataclasses import dataclass + import mindspore.nn as nn from mindspore.ops import Primitive from mindspore.ops import functional as F 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 d34b1d49719..cfa84b80024 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,8 +14,8 @@ # ============================================================================ import mindspore.nn as nn from mindspore.common import dtype -from mindspore.ops import prim_attr_register, PrimitiveWithInfer from mindspore.ops import operations as P +from mindspore.ops import prim_attr_register, PrimitiveWithInfer def get_add(a, b): diff --git a/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_class.py b/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_class.py index a5f8245d719..8e5609bb562 100644 --- a/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_class.py +++ b/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_class.py @@ -23,8 +23,8 @@ import numpy as np import mindspore.nn as nn from mindspore.common.api import _executor -from mindspore.common.tensor import Tensor from mindspore.common.parameter import Parameter +from mindspore.common.tensor import Tensor log = logging.getLogger("test") log.setLevel(level=logging.ERROR) diff --git a/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_primitive.py b/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_primitive.py index df09228efae..047284b1866 100644 --- a/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_primitive.py +++ b/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parse_primitive.py @@ -18,14 +18,14 @@ @Date : 2019-03-23 14:22 @Desc : parser class method function. """ -import sys -from collections import * import logging import numpy as np +import sys +from collections import * import mindspore.nn as nn -from mindspore.common.tensor import Tensor from mindspore.common.parameter import Parameter +from mindspore.common.tensor import Tensor from mindspore.ops import Primitive, prim_attr_register from mindspore.ops import functional as F from mindspore.train.model import Model diff --git a/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_integrate.py b/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_integrate.py index bd8b11cd9e9..da46cc93ad0 100644 --- a/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_integrate.py +++ b/tests/ut/cpp/python_input/gtest_input/pipeline/parse/parser_integrate.py @@ -15,16 +15,16 @@ """ file: parser_integrate.py """ +import mindspore._c_expression as me import numpy as np -import mindspore._c_expression as me import mindspore.nn as nn -from mindspore.common.api import ms_function, _executor from mindspore.common import dtype -from mindspore.common.tensor import Tensor +from mindspore.common.api import ms_function, _executor from mindspore.common.parameter import Parameter -from mindspore.ops import functional as F +from mindspore.common.tensor import Tensor from mindspore.model_zoo.resnet import resnet50 +from mindspore.ops import functional as F from mindspore.train.model import Model diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/adam_apply_one_fusion_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/adam_apply_one_fusion_test.py index 225964ee387..27cfe38b8f0 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/adam_apply_one_fusion_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/adam_apply_one_fusion_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P Add = P.TensorAdd() Sub = P.Sub() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/adam_apply_one_with_decay_rule.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/adam_apply_one_with_decay_rule.py index a73183573b6..539b91404d0 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/adam_apply_one_with_decay_rule.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/adam_apply_one_with_decay_rule.py @@ -13,8 +13,8 @@ # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P mul = P.Mul() add = P.TensorAdd() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/add_memcpy_async.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/add_memcpy_async.py index 5be1c7b0e55..e087530acd8 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/add_memcpy_async.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/add_memcpy_async.py @@ -13,8 +13,8 @@ # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P all_reduce = P.AllReduce() memcpy_async = Primitive('memcpy_async') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/addn_fission_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/addn_fission_test.py index 76d7e73a800..0aef7ee3cb7 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/addn_fission_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/addn_fission_test.py @@ -13,8 +13,8 @@ # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P addn = P.AddN() make_tuple = Primitive('make_tuple') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/batch_norm_bert_fission_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/batch_norm_bert_fission_test.py index 21c1409d361..e991c00a941 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/batch_norm_bert_fission_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/batch_norm_bert_fission_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P make_tuple = Primitive('make_tuple') tuple_getitem = Primitive('tuple_getitem') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/batch_norm_grad_infer_fission_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/batch_norm_grad_infer_fission_test.py index 6d63dd24da2..f6bd83a99db 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/batch_norm_grad_infer_fission_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/batch_norm_grad_infer_fission_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops.operations import _grad_ops as G from mindspore.ops import Primitive +from mindspore.ops.operations import _grad_ops as G make_tuple = Primitive('make_tuple') tuple_getitem = Primitive('tuple_getitem') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/batch_norm_grad_split.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/batch_norm_grad_split.py index 68824a81d1f..e67fbe5ec13 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/batch_norm_grad_split.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/batch_norm_grad_split.py @@ -13,8 +13,8 @@ # limitations under the License. # ============================================================================ -from mindspore.ops.operations import _grad_ops as G from mindspore.ops import Primitive +from mindspore.ops.operations import _grad_ops as G batch_norm_grad = G.BatchNormGrad(is_training=True) bn_training_update_grad = Primitive('BNTrainingUpdateGrad') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/batchnorm_to_bninfer.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/batchnorm_to_bninfer.py index 6912ce41465..7abbd683fb1 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/batchnorm_to_bninfer.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/batchnorm_to_bninfer.py @@ -13,8 +13,8 @@ # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P batch_norm = P.BatchNorm(is_training=False) bn_infer = Primitive('BNInfer') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/batchnormgrad_to_bninfergrad.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/batchnormgrad_to_bninfergrad.py index c9852d91faf..b71f6383422 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/batchnormgrad_to_bninfergrad.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/batchnormgrad_to_bninfergrad.py @@ -13,9 +13,9 @@ # limitations under the License. # ============================================================================ +from mindspore.ops import Primitive from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G -from mindspore.ops import Primitive batch_norm_grad = G.BatchNormGrad(is_training=False) bn_infer_grad = Primitive('BNInferGrad') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/bn_grad_split.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/bn_grad_split.py index 053a768db6a..614e139d3c3 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/bn_grad_split.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/bn_grad_split.py @@ -13,8 +13,8 @@ # limitations under the License. # ============================================================================ -from mindspore.ops.operations import _grad_ops as G from mindspore.ops import Primitive +from mindspore.ops.operations import _grad_ops as G make_tuple = Primitive('make_tuple') tuple_getitem = Primitive('tuple_getitem') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/bn_split.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/bn_split.py index b6056392297..22059f9ca75 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/bn_split.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/bn_split.py @@ -13,8 +13,8 @@ # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P make_tuple = Primitive('make_tuple') tuple_getitem = Primitive('tuple_getitem') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/buffer_fusion_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/buffer_fusion_test.py index bbd72c799fb..bc20a0eb439 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/buffer_fusion_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/buffer_fusion_test.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ +import mindspore.common.dtype as mstype +from mindspore.ops import Primitive from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G -from mindspore.ops import Primitive -import mindspore.common.dtype as mstype Conv = P.Conv2D(out_channel=64, kernel_size=7, mode=1, pad_mode="valid", pad=0, stride=1, dilation=1, group=1) Relu = P.ReLU() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/clip_by_norm_no_div_square_sum_fusion.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/clip_by_norm_no_div_square_sum_fusion.py index 6890cd949c1..2a87acffdd7 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/clip_by_norm_no_div_square_sum_fusion.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/clip_by_norm_no_div_square_sum_fusion.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P select = P.Select() maximum = P.Maximum() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/clip_by_value_fusion.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/clip_by_value_fusion.py index 148bb2d3bd4..d7d70ce9771 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/clip_by_value_fusion.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/clip_by_value_fusion.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P maximum = P.Maximum() minimum = P.Minimum() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/confusion_mul_grad_fusion.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/confusion_mul_grad_fusion.py index fbe43522a8f..2c7f555c5df 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/confusion_mul_grad_fusion.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/confusion_mul_grad_fusion.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P mul = P.Mul() reduce_sum = P.ReduceSum() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/confusion_softmax_grad_rule.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/confusion_softmax_grad_rule.py index cd71eb5d0b5..db435712f81 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/confusion_softmax_grad_rule.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/confusion_softmax_grad_rule.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P mul = P.Mul() reduce_sum = P.ReduceSum() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/conv_bn_relu_fusion.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/conv_bn_relu_fusion.py index 605591560c9..d9d29085913 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/conv_bn_relu_fusion.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/conv_bn_relu_fusion.py @@ -13,8 +13,8 @@ # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P make_tuple = Primitive('make_tuple') tuple_getitem = Primitive('tuple_getitem') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/convert_const_input_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/convert_const_input_test.py index e6da72fdb1f..ef2925826b5 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/convert_const_input_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/convert_const_input_test.py @@ -12,12 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P -from mindspore.ops.operations import _grad_ops as G -from mindspore.ops import Primitive import mindspore as ms import mindspore.common.dtype as mstype from mindspore.common.tensor import Tensor +from mindspore.ops import Primitive +from mindspore.ops import operations as P +from mindspore.ops.operations import _grad_ops as G make_tuple = Primitive('make_tuple') reshape = P.Reshape() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/convert_tuple_input_to_dynamic_input_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/convert_tuple_input_to_dynamic_input_test.py index d0190d85a3f..c698143f21f 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/convert_tuple_input_to_dynamic_input_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/convert_tuple_input_to_dynamic_input_test.py @@ -13,9 +13,10 @@ # limitations under the License. # ============================================================================ import numpy as np -from mindspore.ops import operations as P -from mindspore.ops import Primitive + from mindspore.common.tensor import Tensor +from mindspore.ops import Primitive +from mindspore.ops import operations as P make_tuple = Primitive('make_tuple') concat = P.Concat() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/convert_tuple_output_to_maketuple_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/convert_tuple_output_to_maketuple_test.py index c32df513d8e..b2338deeadc 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/convert_tuple_output_to_maketuple_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/convert_tuple_output_to_maketuple_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P make_tuple = Primitive('make_tuple') tuple_get_item = Primitive("tuple_getitem") diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/derelu_fusion.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/derelu_fusion.py index 9aae005e9df..906dca42ad2 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/derelu_fusion.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/derelu_fusion.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P relu = P.ReLU() relu_grad = Primitive('ReluGrad') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/eliminate_redundant_op_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/eliminate_redundant_op_test.py index c40af821b92..329894ab5a8 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/eliminate_redundant_op_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/eliminate_redundant_op_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P add = P.TensorAdd() sub = P.Sub() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/fused_batch_norm_fusion_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/fused_batch_norm_fusion_test.py index f510956b21e..5b286e358b9 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/fused_batch_norm_fusion_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/fused_batch_norm_fusion_test.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P -from mindspore.ops import Primitive import mindspore.common.dtype as mstype from mindspore.common.tensor import Tensor +from mindspore.ops import Primitive +from mindspore.ops import operations as P AssignSub = P.AssignSub() Mul = P.Mul() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/getnext_memcpy_elimination_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/getnext_memcpy_elimination_test.py index e246fbf0ed9..61310d186f9 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/getnext_memcpy_elimination_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/getnext_memcpy_elimination_test.py @@ -13,9 +13,9 @@ # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P -from mindspore.ops import Primitive import mindspore as ms +from mindspore.ops import Primitive +from mindspore.ops import operations as P get_next = P.GetNext([ms.float32], [[1, 64, 112, 112]], 1, "") memcpy_async_attr = Primitive('memcpy_async') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/hw_opt_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/hw_opt_test.py index 977382e317a..dc6cdf74521 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/hw_opt_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/hw_opt_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P tuple_getitem = Primitive('tuple_getitem') depend = Primitive('depend') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/insert_memcpy_async_for_getnext.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/insert_memcpy_async_for_getnext.py index f0320fef79a..a901d0f4b6d 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/insert_memcpy_async_for_getnext.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/insert_memcpy_async_for_getnext.py @@ -13,9 +13,9 @@ # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P -from mindspore.ops import Primitive import mindspore as ms +from mindspore.ops import Primitive +from mindspore.ops import operations as P get_next = P.GetNext([ms.float32, ms.int32], [[32, 64], [32]], 2, "") memcpy_async = Primitive('memcpy_async') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/insert_trans_op_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/insert_trans_op_test.py index a24501e8b14..f1a85541b11 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/insert_trans_op_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/insert_trans_op_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P tuple_getitem = Primitive('tuple_getitem') add = P.TensorAdd() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/ir_fusion_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/ir_fusion_test.py index 5c30de48782..32bf5ff6290 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/ir_fusion_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/ir_fusion_test.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ +from mindspore.ops import Primitive from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G -from mindspore.ops import Primitive # pylint: disable=unused-variable diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_next_mv_rule_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_next_mv_rule_test.py index 3daaa3f4fbc..21b236d6943 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_next_mv_rule_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_next_mv_rule_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P Add = P.TensorAdd() Mul = P.Mul() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_next_mv_with_decay_rule_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_next_mv_with_decay_rule_test.py index fd11175eb6c..2c8a0d03edf 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_next_mv_with_decay_rule_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_next_mv_with_decay_rule_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P Add = P.TensorAdd() Mul = P.Mul() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_next_mv_with_decay_v1_rule.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_next_mv_with_decay_v1_rule.py index b433cd44b2c..859905beb0f 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_next_mv_with_decay_v1_rule.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_next_mv_with_decay_v1_rule.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P add = P.TensorAdd() mul = P.Mul() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_next_right_rule_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_next_right_rule_test.py index 78803cdb264..ab6369bb637 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_next_right_rule_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_next_right_rule_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P Add = P.TensorAdd() Mul = P.Mul() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_update_with_lr_rule_fusion.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_update_with_lr_rule_fusion.py index 0e8f231e2d7..974aab9a7ed 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_update_with_lr_rule_fusion.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_update_with_lr_rule_fusion.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P select = P.Select() maximum = P.Maximum() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_update_with_lr_v2_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_update_with_lr_v2_test.py index e1bd3df4f0e..92b14c6c904 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_update_with_lr_v2_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/lamb_update_with_lr_v2_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P Sub = P.Sub() Mul = P.Mul() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/lars_v2_fission_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/lars_v2_fission_test.py index 75fcb5be531..a144f0677e2 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/lars_v2_fission_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/lars_v2_fission_test.py @@ -21,6 +21,7 @@ lars_v2_update = Primitive('LarsV2Update') make_tuple = Primitive('make_tuple') tuple_getitem = Primitive('tuple_getitem') + class FnDict: def __init__(self): self.fnDict = {} @@ -31,6 +32,7 @@ class FnDict: def __getitem__(self, name): return self.fnDict[name] + def test_lars_v2_fission(tag): fns = FnDict() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/layer_norm_beta_gamma_backprop_fusion_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/layer_norm_beta_gamma_backprop_fusion_test.py index 68def800f3e..e4d2d922450 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/layer_norm_beta_gamma_backprop_fusion_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/layer_norm_beta_gamma_backprop_fusion_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P Add = P.TensorAdd() Cast = P.Cast() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/layer_norm_grad_split.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/layer_norm_grad_split.py index faf31d11fce..7eb85c33a58 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/layer_norm_grad_split.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/layer_norm_grad_split.py @@ -13,8 +13,8 @@ # limitations under the License. # ============================================================================ -from mindspore.ops.operations import _grad_ops as G from mindspore.ops import Primitive +from mindspore.ops.operations import _grad_ops as G make_tuple = Primitive('make_tuple') tuple_getitem = Primitive('tuple_getitem') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/matmul_biasadd_fusion_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/matmul_biasadd_fusion_test.py index 03d476b701b..15fb5344e88 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/matmul_biasadd_fusion_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/matmul_biasadd_fusion_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P MatMul = P.MatMul() BiasAdd = P.BiasAdd() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/mixed_precision_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/mixed_precision_test.py index 7069cca1e08..8c6796cf7a2 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/mixed_precision_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/mixed_precision_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P tuple_getitem = Primitive('tuple_getitem') depend = Primitive('depend') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/momentum_lossscale_fusion_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/momentum_lossscale_fusion_test.py index b2464ecc46b..3302daa8790 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/momentum_lossscale_fusion_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/momentum_lossscale_fusion_test.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P -from mindspore.ops import Primitive import mindspore.common.dtype as mstype from mindspore.common.tensor import Tensor +from mindspore.ops import Primitive +from mindspore.ops import operations as P Mul = P.Mul() ApplyMomentum = P.ApplyMomentum() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/mul_add_fusion_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/mul_add_fusion_test.py index ba7e8738b19..6b2c9daf4b0 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/mul_add_fusion_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/mul_add_fusion_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P add = P.TensorAdd() mul = P.Mul() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/mul_addn_fusion_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/mul_addn_fusion_test.py index 8ce64109c6d..e278068fdb8 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/mul_addn_fusion_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/mul_addn_fusion_test.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P -from mindspore.ops import Primitive import mindspore.common.dtype as mstype from mindspore.common.tensor import Tensor +from mindspore.ops import Primitive +from mindspore.ops import operations as P addn = P.AddN() mul = P.Mul() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/optimize_dependence_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/optimize_dependence_test.py index 663b17afbf1..4faa5f3f71c 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/optimize_dependence_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/optimize_dependence_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P depend = Primitive('depend') TransData = Primitive('TransData') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/reshape_transpose_fusion_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/reshape_transpose_fusion_test.py index f5c7c5f3bba..9351d3acbe4 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/reshape_transpose_fusion_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/reshape_transpose_fusion_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P Transpose = P.Transpose() Reshape = P.Reshape() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/square_sum_fusion.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/square_sum_fusion.py index 26c82fb8f71..23fb56e3e8a 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/square_sum_fusion.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/square_sum_fusion.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P make_tuple = Primitive('make_tuple') tuple_getitem = Primitive('tuple_getitem') diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/transdata_split_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/transdata_split_test.py index 30e8015259a..d10bd88889e 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/transdata_split_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/transdata_split_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P tuple_getitem = Primitive('tuple_getitem') add = P.TensorAdd() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/transpose_reshape_fusion_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/transpose_reshape_fusion_test.py index a266d335f17..405bcf0cec1 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/transpose_reshape_fusion_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/transpose_reshape_fusion_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P Transpose = P.Transpose() Reshape = P.Reshape() diff --git a/tests/ut/cpp/python_input/gtest_input/pre_activate/transpose_transdata_fusion_test.py b/tests/ut/cpp/python_input/gtest_input/pre_activate/transpose_transdata_fusion_test.py index 48050ea03b7..8bb6baa11f8 100644 --- a/tests/ut/cpp/python_input/gtest_input/pre_activate/transpose_transdata_fusion_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pre_activate/transpose_transdata_fusion_test.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P from mindspore.ops import Primitive +from mindspore.ops import operations as P tuple_getitem = Primitive('tuple_getitem') add = P.TensorAdd() diff --git a/tests/ut/cpp/python_input/gtest_input/pynative/ops_test.py b/tests/ut/cpp/python_input/gtest_input/pynative/ops_test.py index 05964bcfd45..be31b0f7092 100644 --- a/tests/ut/cpp/python_input/gtest_input/pynative/ops_test.py +++ b/tests/ut/cpp/python_input/gtest_input/pynative/ops_test.py @@ -14,9 +14,10 @@ # ============================================================================ """ ops_test """ import numpy as np + +from mindspore.common.tensor import Tensor from mindspore.ops import operations as P from mindspore.ops.vm_impl_registry import vm_impl_registry as vm_impl_getters -from mindspore.common.tensor import Tensor def im2col(img, filter_h, filter_w, stride=1, pad=0, dilation=1): 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 edd3dc6e9bc..6a33d246ec5 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 @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from mindspore.ops import operations as P -from mindspore.ops import Primitive import mindspore as ms +from mindspore.ops import Primitive +from mindspore.ops import operations as P addn = P.AddN() add = P.TensorAdd() diff --git a/tests/ut/python/communication/test_comm.py b/tests/ut/python/communication/test_comm.py index 291998a30cd..c9d20674f36 100644 --- a/tests/ut/python/communication/test_comm.py +++ b/tests/ut/python/communication/test_comm.py @@ -14,19 +14,20 @@ """ test Communicate """ import numpy as np -from mindspore.ops.operations.comm_ops import AllReduce, AllGather, _AlltoAll, ReduceOp, ReduceScatter -from mindspore.ops.operations.comm_ops import Broadcast -from mindspore.communication.management import HCCL_WORLD_COMM_GROUP, NCCL_WORLD_COMM_GROUP, GlobalComm, init -from mindspore.communication._comm_helper import Backend -from mindspore import Tensor + +import mindspore.context as context import mindspore.nn as nn -from mindspore.ops.operations import Split +from mindspore import Tensor from mindspore.common.api import _executor +from mindspore.communication._comm_helper import Backend +from mindspore.communication.management import HCCL_WORLD_COMM_GROUP, NCCL_WORLD_COMM_GROUP, GlobalComm, init from mindspore.nn import Dense +from mindspore.nn import Momentum from mindspore.nn import ReLU from mindspore.nn import TrainOneStepCell, WithLossCell -from mindspore.nn import Momentum -import mindspore.context as context +from mindspore.ops.operations import Split +from mindspore.ops.operations.comm_ops import AllReduce, AllGather, _AlltoAll, ReduceOp, ReduceScatter +from mindspore.ops.operations.comm_ops import Broadcast # pylint: disable=W0212 # W0212: protected-access diff --git a/tests/ut/python/communication/test_data_parallel_dense.py b/tests/ut/python/communication/test_data_parallel_dense.py index 0fc46e08016..ef042e3f394 100644 --- a/tests/ut/python/communication/test_data_parallel_dense.py +++ b/tests/ut/python/communication/test_data_parallel_dense.py @@ -17,14 +17,15 @@ @Desc : test data parallel dense """ import numpy as np -import mindspore.nn as nn -from mindspore.common.api import _executor -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.nn import TrainOneStepCell, WithLossCell -from mindspore.nn import Momentum -from mindspore.train.parallel_utils import ParallelMode + import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common.api import _executor +from mindspore.nn import Momentum +from mindspore.nn import TrainOneStepCell, WithLossCell +from mindspore.ops import operations as P +from mindspore.train.parallel_utils import ParallelMode class DenseMMNet(nn.Cell): diff --git a/tests/ut/python/communication/test_data_parallel_lenet.py b/tests/ut/python/communication/test_data_parallel_lenet.py index b3043aa25fe..a9840cd7340 100755 --- a/tests/ut/python/communication/test_data_parallel_lenet.py +++ b/tests/ut/python/communication/test_data_parallel_lenet.py @@ -16,14 +16,14 @@ @File : test_data_parallel_lenet.py @Desc : test data parallel lenet """ -import os import numpy as np +import os -import mindspore.nn as nn import mindspore.context as context -from mindspore.ops import operations as P +import mindspore.nn as nn from mindspore import Tensor, Model, ParallelMode from mindspore.nn.optim import Momentum +from mindspore.ops import operations as P _current_dir = os.path.dirname(os.path.realpath(__file__)) + "/../test_data" diff --git a/tests/ut/python/communication/test_data_parallel_resnet.py b/tests/ut/python/communication/test_data_parallel_resnet.py index 220e553b4f8..fa798c0616b 100644 --- a/tests/ut/python/communication/test_data_parallel_resnet.py +++ b/tests/ut/python/communication/test_data_parallel_resnet.py @@ -17,11 +17,11 @@ resnet50 example """ import numpy as np -from mindspore import Tensor, Model, ParallelMode -from mindspore.ops.operations import TensorAdd -import mindspore.nn as nn import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor, Model, ParallelMode from mindspore.nn.optim import Momentum +from mindspore.ops.operations import TensorAdd from ....dataset_mock import MindData diff --git a/tests/ut/python/dataset/test_2ops.py b/tests/ut/python/dataset/test_2ops.py index 627f3657152..cdf59ecf220 100644 --- a/tests/ut/python/dataset/test_2ops.py +++ b/tests/ut/python/dataset/test_2ops.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== +from util import save_and_check + import mindspore.dataset as ds from mindspore import log as logger -from util import save_and_check DATA_DIR = ["../data/dataset/testTFTestAllTypes/test.data"] SCHEMA_DIR = "../data/dataset/testTFTestAllTypes/datasetSchema.json" diff --git a/tests/ut/python/dataset/test_HWC2CHW.py b/tests/ut/python/dataset/test_HWC2CHW.py index 9cc33f83bb2..b15cedd726a 100644 --- a/tests/ut/python/dataset/test_HWC2CHW.py +++ b/tests/ut/python/dataset/test_HWC2CHW.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================== import numpy as np +from util import diff_mse, visualize, save_and_check_md5 + +import mindspore.dataset as ds import mindspore.dataset.transforms.vision.c_transforms as c_vision import mindspore.dataset.transforms.vision.py_transforms as py_vision -import mindspore.dataset as ds from mindspore import log as logger -from util import diff_mse, visualize, save_and_check_md5 GENERATE_GOLDEN = False diff --git a/tests/ut/python/dataset/test_apply.py b/tests/ut/python/dataset/test_apply.py index 5993e9a58b5..2c3e690e5a2 100644 --- a/tests/ut/python/dataset/test_apply.py +++ b/tests/ut/python/dataset/test_apply.py @@ -12,11 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== -import mindspore.dataset as ds -from mindspore import log as logger -import mindspore.dataset.transforms.vision.c_transforms as vision import numpy as np +import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as vision +from mindspore import log as logger + DATA_DIR = "../data/dataset/testPK/data" diff --git a/tests/ut/python/dataset/test_autocontrast.py b/tests/ut/python/dataset/test_autocontrast.py index c60f7ff3faf..457fe458fe8 100644 --- a/tests/ut/python/dataset/test_autocontrast.py +++ b/tests/ut/python/dataset/test_autocontrast.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================== -import numpy as np import matplotlib.pyplot as plt -from mindspore import log as logger +import numpy as np + import mindspore.dataset.engine as de import mindspore.dataset.transforms.vision.py_transforms as F +from mindspore import log as logger DATA_DIR = "../data/dataset/testImageNetData/train/" diff --git a/tests/ut/python/dataset/test_center_crop.py b/tests/ut/python/dataset/test_center_crop.py index 11b85592b27..c0731c855db 100644 --- a/tests/ut/python/dataset/test_center_crop.py +++ b/tests/ut/python/dataset/test_center_crop.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================== import numpy as np +from util import diff_mse, visualize, save_and_check_md5 + +import mindspore.dataset as ds import mindspore.dataset.transforms.vision.c_transforms as vision import mindspore.dataset.transforms.vision.py_transforms as py_vision -import mindspore.dataset as ds from mindspore import log as logger -from util import diff_mse, visualize, save_and_check_md5 GENERATE_GOLDEN = False diff --git a/tests/ut/python/dataset/test_concat.py b/tests/ut/python/dataset/test_concat.py index db6ffebb596..465554869ec 100644 --- a/tests/ut/python/dataset/test_concat.py +++ b/tests/ut/python/dataset/test_concat.py @@ -12,13 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== -import mindspore.dataset as ds -import mindspore.dataset.transforms.vision.py_transforms as F -import mindspore.dataset.transforms.c_transforms as C -import mindspore.common.dtype as mstype -from mindspore import log as logger import numpy as np +import mindspore.common.dtype as mstype +import mindspore.dataset as ds +import mindspore.dataset.transforms.c_transforms as C +import mindspore.dataset.transforms.vision.py_transforms as F +from mindspore import log as logger + # In generator dataset: Number of rows is 3, its value is 0, 1, 2 def generator(): diff --git a/tests/ut/python/dataset/test_config.py b/tests/ut/python/dataset/test_config.py index 10f00b36061..f17b830edd3 100644 --- a/tests/ut/python/dataset/test_config.py +++ b/tests/ut/python/dataset/test_config.py @@ -20,11 +20,10 @@ import glob import numpy as np import os -from mindspore import log as logger - import mindspore.dataset as ds import mindspore.dataset.transforms.vision.c_transforms as vision import mindspore.dataset.transforms.vision.py_transforms as py_vision +from mindspore import log as logger DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] SCHEMA_DIR = "../data/dataset/test_tf_file_3_images/datasetSchema.json" diff --git a/tests/ut/python/dataset/test_datasets_celeba.py b/tests/ut/python/dataset/test_datasets_celeba.py index 11c5fcb67a7..393f0ba974c 100644 --- a/tests/ut/python/dataset/test_datasets_celeba.py +++ b/tests/ut/python/dataset/test_datasets_celeba.py @@ -13,8 +13,8 @@ # limitations under the License. import mindspore.dataset as ds import mindspore.dataset.transforms.vision.c_transforms as vision -from mindspore.dataset.transforms.vision import Inter from mindspore import log as logger +from mindspore.dataset.transforms.vision import Inter DATA_DIR = "../data/dataset/testCelebAData/" diff --git a/tests/ut/python/dataset/test_datasets_imagenet.py b/tests/ut/python/dataset/test_datasets_imagenet.py index 80a0705fd37..08d922d4536 100644 --- a/tests/ut/python/dataset/test_datasets_imagenet.py +++ b/tests/ut/python/dataset/test_datasets_imagenet.py @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== -import mindspore.dataset.transforms.vision.c_transforms as vision -import mindspore.dataset.transforms.c_transforms as data_trans import pytest import mindspore.dataset as ds +import mindspore.dataset.transforms.c_transforms as data_trans +import mindspore.dataset.transforms.vision.c_transforms as vision from mindspore import log as logger DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] diff --git a/tests/ut/python/dataset/test_datasets_imagenet_distribution.py b/tests/ut/python/dataset/test_datasets_imagenet_distribution.py index 3487562ea0f..65d432edaf8 100644 --- a/tests/ut/python/dataset/test_datasets_imagenet_distribution.py +++ b/tests/ut/python/dataset/test_datasets_imagenet_distribution.py @@ -13,6 +13,7 @@ # limitations under the License. # ============================================================================== import pytest + import mindspore.dataset as ds from mindspore import log as logger diff --git a/tests/ut/python/dataset/test_datasets_manifestop.py b/tests/ut/python/dataset/test_datasets_manifestop.py index c1e011a9009..01f54d64476 100644 --- a/tests/ut/python/dataset/test_datasets_manifestop.py +++ b/tests/ut/python/dataset/test_datasets_manifestop.py @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== -import mindspore.dataset.transforms.vision.c_transforms as vision -import mindspore.dataset.transforms.c_transforms as data_trans import numpy as np import mindspore.dataset as ds +import mindspore.dataset.transforms.c_transforms as data_trans +import mindspore.dataset.transforms.vision.c_transforms as vision from mindspore import log as logger DATA_FILE = "../data/dataset/testManifestData/test.manifest" diff --git a/tests/ut/python/dataset/test_datasets_textfileop.py b/tests/ut/python/dataset/test_datasets_textfileop.py index b2551802789..172c51ba89c 100644 --- a/tests/ut/python/dataset/test_datasets_textfileop.py +++ b/tests/ut/python/dataset/test_datasets_textfileop.py @@ -13,8 +13,8 @@ # limitations under the License. # ============================================================================== import mindspore.dataset as ds -from mindspore import log as logger import mindspore.dataset.transforms.nlp.utils as nlp +from mindspore import log as logger DATA_FILE = "../data/dataset/testTextFileDataset/1.txt" DATA_ALL_FILE = "../data/dataset/testTextFileDataset/*" diff --git a/tests/ut/python/dataset/test_datasets_voc.py b/tests/ut/python/dataset/test_datasets_voc.py index 3dd71ec90eb..a6802cdf917 100644 --- a/tests/ut/python/dataset/test_datasets_voc.py +++ b/tests/ut/python/dataset/test_datasets_voc.py @@ -12,9 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== -import mindspore.dataset.transforms.vision.c_transforms as vision - import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as vision DATA_DIR = "../data/dataset/testVOC2012" IMAGE_SHAPE = [2268, 2268, 2268, 2268, 642, 607, 561, 596, 612, 2268] diff --git a/tests/ut/python/dataset/test_decode.py b/tests/ut/python/dataset/test_decode.py index 5d9d1f39f5f..0adc2a027b9 100644 --- a/tests/ut/python/dataset/test_decode.py +++ b/tests/ut/python/dataset/test_decode.py @@ -16,12 +16,13 @@ Testing Decode op in DE """ import cv2 -import mindspore.dataset.transforms.vision.c_transforms as vision import numpy as np -import mindspore.dataset as ds -from mindspore import log as logger from util import diff_mse +import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as vision +from mindspore import log as logger + DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] SCHEMA_DIR = "../data/dataset/test_tf_file_3_images/datasetSchema.json" diff --git a/tests/ut/python/dataset/test_deviceop_cpu.py b/tests/ut/python/dataset/test_deviceop_cpu.py index 21262fe8ea7..1c701c3e40a 100644 --- a/tests/ut/python/dataset/test_deviceop_cpu.py +++ b/tests/ut/python/dataset/test_deviceop_cpu.py @@ -12,9 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== -import mindspore.dataset.transforms.vision.c_transforms as vision - import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as vision from mindspore import log as logger DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] diff --git a/tests/ut/python/dataset/test_equalize.py b/tests/ut/python/dataset/test_equalize.py index c98d2e67d30..36d25bfb2c2 100644 --- a/tests/ut/python/dataset/test_equalize.py +++ b/tests/ut/python/dataset/test_equalize.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================== -import numpy as np import matplotlib.pyplot as plt -from mindspore import log as logger +import numpy as np + import mindspore.dataset.engine as de import mindspore.dataset.transforms.vision.py_transforms as F +from mindspore import log as logger DATA_DIR = "../data/dataset/testImageNetData/train/" diff --git a/tests/ut/python/dataset/test_exceptions.py b/tests/ut/python/dataset/test_exceptions.py index 1fb2aef9982..8dcca8160e6 100644 --- a/tests/ut/python/dataset/test_exceptions.py +++ b/tests/ut/python/dataset/test_exceptions.py @@ -13,6 +13,7 @@ # limitations under the License. # ============================================================================== import pytest + import mindspore.dataset as ds import mindspore.dataset.transforms.vision.c_transforms as vision from mindspore import log as logger diff --git a/tests/ut/python/dataset/test_filterop.py b/tests/ut/python/dataset/test_filterop.py index 2550970c8e9..db89fe381b0 100644 --- a/tests/ut/python/dataset/test_filterop.py +++ b/tests/ut/python/dataset/test_filterop.py @@ -14,10 +14,11 @@ # ============================================================================== import numpy as np -import mindspore.dataset as ds -import mindspore.dataset.transforms.vision.c_transforms as cde -import mindspore.dataset.transforms.c_transforms as C + import mindspore.common.dtype as mstype +import mindspore.dataset as ds +import mindspore.dataset.transforms.c_transforms as C +import mindspore.dataset.transforms.vision.c_transforms as cde from mindspore import log as logger DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] diff --git a/tests/ut/python/dataset/test_flat_map.py b/tests/ut/python/dataset/test_flat_map.py index 0e2e01d3eaf..a532e550f04 100644 --- a/tests/ut/python/dataset/test_flat_map.py +++ b/tests/ut/python/dataset/test_flat_map.py @@ -13,6 +13,7 @@ # limitations under the License. # ============================================================================== import numpy as np + import mindspore.dataset as ds DATA_FILE = "../data/dataset/test_flat_map/images1.txt" diff --git a/tests/ut/python/dataset/test_invert.py b/tests/ut/python/dataset/test_invert.py index 2faafa292bb..06e64dc9473 100644 --- a/tests/ut/python/dataset/test_invert.py +++ b/tests/ut/python/dataset/test_invert.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================== -import numpy as np import matplotlib.pyplot as plt -from mindspore import log as logger +import numpy as np + import mindspore.dataset.engine as de import mindspore.dataset.transforms.vision.py_transforms as F +from mindspore import log as logger DATA_DIR = "../data/dataset/testImageNetData/train/" diff --git a/tests/ut/python/dataset/test_iterator.py b/tests/ut/python/dataset/test_iterator.py index d61405a3526..735c9417c7e 100644 --- a/tests/ut/python/dataset/test_iterator.py +++ b/tests/ut/python/dataset/test_iterator.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== +import copy import numpy as np import pytest -import copy + import mindspore.dataset as ds from mindspore.dataset.engine.iterators import ITERATORS_LIST, _cleanup diff --git a/tests/ut/python/dataset/test_minddataset.py b/tests/ut/python/dataset/test_minddataset.py index ca252351e78..57c19fbd80b 100644 --- a/tests/ut/python/dataset/test_minddataset.py +++ b/tests/ut/python/dataset/test_minddataset.py @@ -17,17 +17,16 @@ This is the test module for mindrecord """ import collections import json +import numpy as np import os +import pytest import re import string -import mindspore.dataset.transforms.vision.c_transforms as vision -import numpy as np -import pytest -from mindspore.dataset.transforms.vision import Inter -from mindspore import log as logger - import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as vision +from mindspore import log as logger +from mindspore.dataset.transforms.vision import Inter from mindspore.mindrecord import FileWriter FILES_NUM = 4 diff --git a/tests/ut/python/dataset/test_minddataset_exception.py b/tests/ut/python/dataset/test_minddataset_exception.py index 0c6af8f5799..bf374cd7319 100644 --- a/tests/ut/python/dataset/test_minddataset_exception.py +++ b/tests/ut/python/dataset/test_minddataset_exception.py @@ -15,7 +15,6 @@ # ============================================================================== import os - import pytest import mindspore.dataset as ds diff --git a/tests/ut/python/dataset/test_minddataset_multi_images_and_ndarray.py b/tests/ut/python/dataset/test_minddataset_multi_images_and_ndarray.py index 47215dc0a7d..b3036329eec 100644 --- a/tests/ut/python/dataset/test_minddataset_multi_images_and_ndarray.py +++ b/tests/ut/python/dataset/test_minddataset_multi_images_and_ndarray.py @@ -20,7 +20,6 @@ import os import mindspore.dataset as ds from mindspore import log as logger - from mindspore.mindrecord import FileWriter FILES_NUM = 1 diff --git a/tests/ut/python/dataset/test_minddataset_sampler.py b/tests/ut/python/dataset/test_minddataset_sampler.py index 71fda5682eb..b2453244b18 100644 --- a/tests/ut/python/dataset/test_minddataset_sampler.py +++ b/tests/ut/python/dataset/test_minddataset_sampler.py @@ -17,17 +17,16 @@ This is the test module for mindrecord """ import collections import json +import numpy as np import os +import pytest import re import string -import mindspore.dataset.transforms.vision.c_transforms as vision -import numpy as np -import pytest -from mindspore.dataset.transforms.vision import Inter -from mindspore import log as logger - import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as vision +from mindspore import log as logger +from mindspore.dataset.transforms.vision import Inter from mindspore.mindrecord import FileWriter FILES_NUM = 4 diff --git a/tests/ut/python/dataset/test_mixup_label_smoothing.py b/tests/ut/python/dataset/test_mixup_label_smoothing.py index 69065962dfc..4a3539ce083 100644 --- a/tests/ut/python/dataset/test_mixup_label_smoothing.py +++ b/tests/ut/python/dataset/test_mixup_label_smoothing.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================== import numpy as np -import mindspore.dataset.transforms.vision.py_transforms as py_vision -import mindspore.dataset.transforms.py_transforms as f + import mindspore.dataset as ds import mindspore.dataset.transforms.c_transforms as c +import mindspore.dataset.transforms.py_transforms as f import mindspore.dataset.transforms.vision.c_transforms as c_vision +import mindspore.dataset.transforms.vision.py_transforms as py_vision from mindspore import log as logger DATA_DIR = "../data/dataset/testImageNetData/train" diff --git a/tests/ut/python/dataset/test_normalizeOp.py b/tests/ut/python/dataset/test_normalizeOp.py index c080b001052..e1b5948fb55 100644 --- a/tests/ut/python/dataset/test_normalizeOp.py +++ b/tests/ut/python/dataset/test_normalizeOp.py @@ -13,10 +13,11 @@ # limitations under the License. # ============================================================================== -import mindspore.dataset.transforms.vision.c_transforms as vision -import numpy as np import matplotlib.pyplot as plt +import numpy as np + import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as vision from mindspore import log as logger DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] diff --git a/tests/ut/python/dataset/test_onehot_op.py b/tests/ut/python/dataset/test_onehot_op.py index 2ee40b5a5c6..47567edcc85 100644 --- a/tests/ut/python/dataset/test_onehot_op.py +++ b/tests/ut/python/dataset/test_onehot_op.py @@ -15,11 +15,11 @@ """ Testing the one_hot op in DE """ -import mindspore.dataset.transforms.vision.c_transforms as vision -import mindspore.dataset.transforms.c_transforms as data_trans import numpy as np import mindspore.dataset as ds +import mindspore.dataset.transforms.c_transforms as data_trans +import mindspore.dataset.transforms.vision.c_transforms as vision from mindspore import log as logger DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] diff --git a/tests/ut/python/dataset/test_pad.py b/tests/ut/python/dataset/test_pad.py index 6d2f92d1e39..47e3dd0e243 100644 --- a/tests/ut/python/dataset/test_pad.py +++ b/tests/ut/python/dataset/test_pad.py @@ -16,13 +16,13 @@ Testing Pad op in DE """ import matplotlib.pyplot as plt -import mindspore.dataset.transforms.vision.c_transforms as c_vision import numpy as np +from util import diff_mse import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as c_vision import mindspore.dataset.transforms.vision.py_transforms as py_vision from mindspore import log as logger -from util import diff_mse DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] SCHEMA_DIR = "../data/dataset/test_tf_file_3_images/datasetSchema.json" diff --git a/tests/ut/python/dataset/test_pad_batch.py b/tests/ut/python/dataset/test_pad_batch.py index 7cfc34e7189..72e941ffd7a 100644 --- a/tests/ut/python/dataset/test_pad_batch.py +++ b/tests/ut/python/dataset/test_pad_batch.py @@ -13,10 +13,11 @@ # limitations under the License. # ============================================================================== -import mindspore.dataset as ds import numpy as np import time +import mindspore.dataset as ds + # This UT test tests the following cases diff --git a/tests/ut/python/dataset/test_project.py b/tests/ut/python/dataset/test_project.py index 554476fd0fa..18211657983 100644 --- a/tests/ut/python/dataset/test_project.py +++ b/tests/ut/python/dataset/test_project.py @@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== +from util import save_and_check_tuple + import mindspore.dataset as ds import mindspore.dataset.transforms.c_transforms as C from mindspore.common import dtype as mstype -from util import save_and_check_tuple DATA_DIR_TF = ["../data/dataset/testTFTestAllTypes/test.data"] SCHEMA_DIR_TF = "../data/dataset/testTFTestAllTypes/datasetSchema.json" diff --git a/tests/ut/python/dataset/test_random_color.py b/tests/ut/python/dataset/test_random_color.py index 90fc881b392..378107b41a6 100644 --- a/tests/ut/python/dataset/test_random_color.py +++ b/tests/ut/python/dataset/test_random_color.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================== -import numpy as np import matplotlib.pyplot as plt -from mindspore import log as logger +import numpy as np + import mindspore.dataset.engine as de import mindspore.dataset.transforms.vision.py_transforms as F +from mindspore import log as logger DATA_DIR = "../data/dataset/testImageNetData/train/" diff --git a/tests/ut/python/dataset/test_random_color_adjust.py b/tests/ut/python/dataset/test_random_color_adjust.py index 39ebf2f1a3f..ebda48074ac 100644 --- a/tests/ut/python/dataset/test_random_color_adjust.py +++ b/tests/ut/python/dataset/test_random_color_adjust.py @@ -16,13 +16,13 @@ Testing RandomColorAdjust op in DE """ import matplotlib.pyplot as plt -import mindspore.dataset.transforms.vision.c_transforms as c_vision import numpy as np +from util import diff_mse import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as c_vision import mindspore.dataset.transforms.vision.py_transforms as py_vision from mindspore import log as logger -from util import diff_mse DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] SCHEMA_DIR = "../data/dataset/test_tf_file_3_images/datasetSchema.json" diff --git a/tests/ut/python/dataset/test_random_crop.py b/tests/ut/python/dataset/test_random_crop.py index 55dd7ffb074..9647f31a366 100644 --- a/tests/ut/python/dataset/test_random_crop.py +++ b/tests/ut/python/dataset/test_random_crop.py @@ -16,10 +16,10 @@ Testing RandomCropAndResize op in DE """ import matplotlib.pyplot as plt -import mindspore.dataset.transforms.vision.c_transforms as vision -from mindspore import log as logger import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as vision +from mindspore import log as logger DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] SCHEMA_DIR = "../data/dataset/test_tf_file_3_images/datasetSchema.json" diff --git a/tests/ut/python/dataset/test_random_crop_and_resize.py b/tests/ut/python/dataset/test_random_crop_and_resize.py index f1deef42df7..8138e9e4318 100644 --- a/tests/ut/python/dataset/test_random_crop_and_resize.py +++ b/tests/ut/python/dataset/test_random_crop_and_resize.py @@ -17,10 +17,10 @@ Testing RandomCropAndResize op in DE """ import cv2 import matplotlib.pyplot as plt -import mindspore.dataset.transforms.vision.c_transforms as vision import numpy as np import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as vision from mindspore import log as logger DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] diff --git a/tests/ut/python/dataset/test_random_crop_decode_resize.py b/tests/ut/python/dataset/test_random_crop_decode_resize.py index ffca9326e69..bfb1c2f81ef 100644 --- a/tests/ut/python/dataset/test_random_crop_decode_resize.py +++ b/tests/ut/python/dataset/test_random_crop_decode_resize.py @@ -17,10 +17,10 @@ Testing RandomCropDecodeResize op in DE """ import cv2 import matplotlib.pyplot as plt -import mindspore.dataset.transforms.vision.c_transforms as vision import numpy as np import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as vision from mindspore import log as logger DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] diff --git a/tests/ut/python/dataset/test_random_dataset.py b/tests/ut/python/dataset/test_random_dataset.py index b0fdffd4e26..c35b440d059 100644 --- a/tests/ut/python/dataset/test_random_dataset.py +++ b/tests/ut/python/dataset/test_random_dataset.py @@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== +from pathlib import Path + import mindspore.common.dtype as mstype import mindspore.dataset as ds from mindspore import log as logger -from pathlib import Path # just a basic test with parallel random data op diff --git a/tests/ut/python/dataset/test_random_horizontal_flip.py b/tests/ut/python/dataset/test_random_horizontal_flip.py index 68d95a063a2..236706ee162 100644 --- a/tests/ut/python/dataset/test_random_horizontal_flip.py +++ b/tests/ut/python/dataset/test_random_horizontal_flip.py @@ -16,10 +16,10 @@ Testing the random horizontal flip op in DE """ import matplotlib.pyplot as plt -import mindspore.dataset.transforms.vision.c_transforms as vision import numpy as np import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as vision from mindspore import log as logger DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] diff --git a/tests/ut/python/dataset/test_random_resize.py b/tests/ut/python/dataset/test_random_resize.py index 9d6a2495982..775f18616c5 100644 --- a/tests/ut/python/dataset/test_random_resize.py +++ b/tests/ut/python/dataset/test_random_resize.py @@ -16,8 +16,9 @@ Testing the resize op in DE """ import matplotlib.pyplot as plt -import mindspore.dataset.transforms.vision.c_transforms as vision + import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as vision from mindspore import log as logger DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] diff --git a/tests/ut/python/dataset/test_random_rotation.py b/tests/ut/python/dataset/test_random_rotation.py index 0654f9b863c..e0b36e5bb0c 100644 --- a/tests/ut/python/dataset/test_random_rotation.py +++ b/tests/ut/python/dataset/test_random_rotation.py @@ -17,10 +17,10 @@ Testing RandomRotation op in DE """ import cv2 import matplotlib.pyplot as plt -import mindspore.dataset.transforms.vision.c_transforms as c_vision import numpy as np import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as c_vision import mindspore.dataset.transforms.vision.py_transforms as py_vision from mindspore import log as logger diff --git a/tests/ut/python/dataset/test_random_sharpness.py b/tests/ut/python/dataset/test_random_sharpness.py index 880d0acb1e6..cd7a717da2b 100644 --- a/tests/ut/python/dataset/test_random_sharpness.py +++ b/tests/ut/python/dataset/test_random_sharpness.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================== -import numpy as np import matplotlib.pyplot as plt -from mindspore import log as logger +import numpy as np + import mindspore.dataset.engine as de import mindspore.dataset.transforms.vision.py_transforms as F +from mindspore import log as logger DATA_DIR = "../data/dataset/testImageNetData/train/" diff --git a/tests/ut/python/dataset/test_random_vertical_flip.py b/tests/ut/python/dataset/test_random_vertical_flip.py index 0d7404d1a29..36c55f6ecf5 100644 --- a/tests/ut/python/dataset/test_random_vertical_flip.py +++ b/tests/ut/python/dataset/test_random_vertical_flip.py @@ -16,10 +16,10 @@ Testing the random vertical flip op in DE """ import matplotlib.pyplot as plt -import mindspore.dataset.transforms.vision.c_transforms as vision import numpy as np import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as vision from mindspore import log as logger DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] diff --git a/tests/ut/python/dataset/test_rename.py b/tests/ut/python/dataset/test_rename.py index cc802845b94..cbdc65d7eab 100644 --- a/tests/ut/python/dataset/test_rename.py +++ b/tests/ut/python/dataset/test_rename.py @@ -13,6 +13,7 @@ # limitations under the License. # ============================================================================== import numpy as np + import mindspore.dataset as ds from mindspore import log as logger diff --git a/tests/ut/python/dataset/test_repeat.py b/tests/ut/python/dataset/test_repeat.py index 9edbc683bd6..4bdde7beeb9 100644 --- a/tests/ut/python/dataset/test_repeat.py +++ b/tests/ut/python/dataset/test_repeat.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== -import mindspore.dataset.transforms.vision.c_transforms as vision -import mindspore.dataset as ds import numpy as np -from mindspore import log as logger from util import save_and_check +import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as vision +from mindspore import log as logger + DATA_DIR_TF = ["../data/dataset/testTFTestAllTypes/test.data"] SCHEMA_DIR_TF = "../data/dataset/testTFTestAllTypes/datasetSchema.json" COLUMNS_TF = ["col_1d", "col_2d", "col_3d", "col_binary", "col_float", diff --git a/tests/ut/python/dataset/test_rescale_op.py b/tests/ut/python/dataset/test_rescale_op.py index 4d265e0aab9..9e85fe27091 100644 --- a/tests/ut/python/dataset/test_rescale_op.py +++ b/tests/ut/python/dataset/test_rescale_op.py @@ -16,10 +16,10 @@ Testing the rescale op in DE """ import matplotlib.pyplot as plt -import mindspore.dataset.transforms.vision.c_transforms as vision import numpy as np import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as vision from mindspore import log as logger DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] diff --git a/tests/ut/python/dataset/test_rgb_hsv.py b/tests/ut/python/dataset/test_rgb_hsv.py index 20d501dc47a..025e060ec2a 100644 --- a/tests/ut/python/dataset/test_rgb_hsv.py +++ b/tests/ut/python/dataset/test_rgb_hsv.py @@ -16,9 +16,9 @@ Testing RgbToHsv and HsvToRgb op in DE """ +import colorsys import numpy as np from numpy.testing import assert_allclose -import colorsys import mindspore.dataset as ds import mindspore.dataset.transforms.vision.py_transforms as vision diff --git a/tests/ut/python/dataset/test_sampler.py b/tests/ut/python/dataset/test_sampler.py index 93518b3f9cb..cb2b88684b5 100644 --- a/tests/ut/python/dataset/test_sampler.py +++ b/tests/ut/python/dataset/test_sampler.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== +import numpy as np + import mindspore.dataset as ds from mindspore import log as logger -import numpy as np # test5trainimgs.json contains 5 images whose un-decoded shape is [83554, 54214, 65512, 54214, 64631] diff --git a/tests/ut/python/dataset/test_serdes_dataset.py b/tests/ut/python/dataset/test_serdes_dataset.py index 62e8649ed07..1fe4d7cb072 100644 --- a/tests/ut/python/dataset/test_serdes_dataset.py +++ b/tests/ut/python/dataset/test_serdes_dataset.py @@ -18,15 +18,15 @@ Testing dataset serialize and deserialize in DE import filecmp import glob import json +import numpy as np import os import pytest -import numpy as np import mindspore.dataset as ds import mindspore.dataset.transforms.c_transforms as c import mindspore.dataset.transforms.vision.c_transforms as vision -from mindspore.dataset.transforms.vision import Inter from mindspore import log as logger +from mindspore.dataset.transforms.vision import Inter def test_imagefolder(remove_json_files=True): diff --git a/tests/ut/python/dataset/test_skip.py b/tests/ut/python/dataset/test_skip.py index f2574263643..1cf868bd855 100644 --- a/tests/ut/python/dataset/test_skip.py +++ b/tests/ut/python/dataset/test_skip.py @@ -14,8 +14,8 @@ # ============================================================================== import numpy as np -import mindspore.dataset.transforms.vision.c_transforms as vision import mindspore.dataset as ds +import mindspore.dataset.transforms.vision.c_transforms as vision from mindspore import log as logger DATA_DIR_TF2 = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] diff --git a/tests/ut/python/dataset/test_sync_wait.py b/tests/ut/python/dataset/test_sync_wait.py index 552782a849b..34bde8a3fef 100644 --- a/tests/ut/python/dataset/test_sync_wait.py +++ b/tests/ut/python/dataset/test_sync_wait.py @@ -13,10 +13,11 @@ # limitations under the License. # ============================================================================== +import numpy as np +import time + import mindspore.dataset as ds from mindspore import log as logger -import time -import numpy as np def gen(): diff --git a/tests/ut/python/dataset/test_take.py b/tests/ut/python/dataset/test_take.py index cd0a443439e..4494d5caefb 100644 --- a/tests/ut/python/dataset/test_take.py +++ b/tests/ut/python/dataset/test_take.py @@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== +import numpy as np + import mindspore.dataset as ds import mindspore.dataset.transforms.vision.c_transforms as vision from mindspore import log as logger -import numpy as np # In generator dataset: Number of rows is 3, its value is 0, 1, 2 diff --git a/tests/ut/python/dataset/test_tensor_string.py b/tests/ut/python/dataset/test_tensor_string.py index 3fe21ba5700..e7b6917a0b0 100644 --- a/tests/ut/python/dataset/test_tensor_string.py +++ b/tests/ut/python/dataset/test_tensor_string.py @@ -13,10 +13,10 @@ # limitations under the License. # ============================================================================== import mindspore._c_dataengine as cde -import mindspore.dataset as ds +import numpy as np import pytest -import numpy as np +import mindspore.dataset as ds def test_basic(): diff --git a/tests/ut/python/dataset/test_tfreader_op.py b/tests/ut/python/dataset/test_tfreader_op.py index 67d54385e9b..e4c991eef21 100644 --- a/tests/ut/python/dataset/test_tfreader_op.py +++ b/tests/ut/python/dataset/test_tfreader_op.py @@ -13,12 +13,12 @@ # limitations under the License. # ============================================================================== import numpy as np +import pytest from util import save_and_check import mindspore.common.dtype as mstype import mindspore.dataset as ds from mindspore import log as logger -import pytest FILES = ["../data/dataset/testTFTestAllTypes/test.data"] DATASET_ROOT = "../data/dataset/testTFTestAllTypes/" diff --git a/tests/ut/python/dataset/test_type_cast.py b/tests/ut/python/dataset/test_type_cast.py index 95a935bf034..64820250cf0 100644 --- a/tests/ut/python/dataset/test_type_cast.py +++ b/tests/ut/python/dataset/test_type_cast.py @@ -15,14 +15,13 @@ """ Testing TypeCast op in DE """ -import mindspore.dataset.transforms.vision.c_transforms as c_vision -import mindspore.dataset.transforms.vision.py_transforms as py_vision -import mindspore.dataset.transforms.c_transforms as data_util - import numpy as np import mindspore.common.dtype as mstype import mindspore.dataset as ds +import mindspore.dataset.transforms.c_transforms as data_util +import mindspore.dataset.transforms.vision.c_transforms as c_vision +import mindspore.dataset.transforms.vision.py_transforms as py_vision from mindspore import log as logger DATA_DIR = ["../data/dataset/test_tf_file_3_images/train-0000-of-0001.data"] diff --git a/tests/ut/python/dataset/test_uniform_augment.py b/tests/ut/python/dataset/test_uniform_augment.py index adda8560b52..088b796f1a1 100644 --- a/tests/ut/python/dataset/test_uniform_augment.py +++ b/tests/ut/python/dataset/test_uniform_augment.py @@ -13,12 +13,13 @@ # limitations under the License. # ============================================================================== -import numpy as np import matplotlib.pyplot as plt -from mindspore import log as logger +import numpy as np + import mindspore.dataset.engine as de -import mindspore.dataset.transforms.vision.py_transforms as F import mindspore.dataset.transforms.vision.c_transforms as C +import mindspore.dataset.transforms.vision.py_transforms as F +from mindspore import log as logger DATA_DIR = "../data/dataset/testImageNetData/train/" diff --git a/tests/ut/python/dataset/test_var_batch_map.py b/tests/ut/python/dataset/test_var_batch_map.py index 8031446ddac..4095183c5db 100644 --- a/tests/ut/python/dataset/test_var_batch_map.py +++ b/tests/ut/python/dataset/test_var_batch_map.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== +import numpy as np + import mindspore.dataset as ds from mindspore import log as logger -import numpy as np def test_batch_corner_cases(): diff --git a/tests/ut/python/dataset/test_zip.py b/tests/ut/python/dataset/test_zip.py index 557c12f6831..94c84a1af38 100644 --- a/tests/ut/python/dataset/test_zip.py +++ b/tests/ut/python/dataset/test_zip.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== +from util import save_and_check_dict, save_and_check_md5 + import mindspore.dataset as ds from mindspore import log as logger -from util import save_and_check_dict, save_and_check_md5 # Dataset in DIR_1 has 5 rows and 5 columns DATA_DIR_1 = ["../data/dataset/testTFBert5Rows1/5TFDatas.data"] diff --git a/tests/ut/python/dataset/util.py b/tests/ut/python/dataset/util.py index 66c42ded668..3212a11dc32 100644 --- a/tests/ut/python/dataset/util.py +++ b/tests/ut/python/dataset/util.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================== -import json -import os import hashlib -import numpy as np +import json import matplotlib.pyplot as plt +import numpy as np +import os + # import jsbeautifier from mindspore import log as logger diff --git a/tests/ut/python/ir/test_dtype.py b/tests/ut/python/ir/test_dtype.py index ef1f660207f..704d09258fb 100644 --- a/tests/ut/python/ir/test_dtype.py +++ b/tests/ut/python/ir/test_dtype.py @@ -13,10 +13,9 @@ # limitations under the License. # ============================================================================ """test_dtype""" -from dataclasses import dataclass - import numpy as np import pytest +from dataclasses import dataclass import mindspore as ms from mindspore.common import dtype diff --git a/tests/ut/python/metrics/test_accuracy.py b/tests/ut/python/metrics/test_accuracy.py index 47a4dcfbd13..ec3c582d16f 100644 --- a/tests/ut/python/metrics/test_accuracy.py +++ b/tests/ut/python/metrics/test_accuracy.py @@ -14,7 +14,6 @@ # ============================================================================ """test accuracy""" import math - import numpy as np import pytest diff --git a/tests/ut/python/metrics/test_error.py b/tests/ut/python/metrics/test_error.py index 2e6b37591d2..74ad0b58c67 100644 --- a/tests/ut/python/metrics/test_error.py +++ b/tests/ut/python/metrics/test_error.py @@ -14,7 +14,6 @@ # ============================================================================ """test error""" import math - import numpy as np import pytest diff --git a/tests/ut/python/metrics/test_metric_factory.py b/tests/ut/python/metrics/test_metric_factory.py index c7300238a1a..8ddc05f3356 100644 --- a/tests/ut/python/metrics/test_metric_factory.py +++ b/tests/ut/python/metrics/test_metric_factory.py @@ -14,7 +14,6 @@ # ============================================================================ """test_metric_factory""" import math - import numpy as np from mindspore import Tensor diff --git a/tests/ut/python/metrics/test_precision.py b/tests/ut/python/metrics/test_precision.py index 6eac9474b40..2b2d4d0853f 100644 --- a/tests/ut/python/metrics/test_precision.py +++ b/tests/ut/python/metrics/test_precision.py @@ -14,7 +14,6 @@ # ============================================================================ """test_precision""" import math - import numpy as np import pytest diff --git a/tests/ut/python/metrics/test_recall.py b/tests/ut/python/metrics/test_recall.py index 6ef3c93cca9..682ba52097d 100644 --- a/tests/ut/python/metrics/test_recall.py +++ b/tests/ut/python/metrics/test_recall.py @@ -14,7 +14,6 @@ # ============================================================================ """test recall""" import math - import numpy as np import pytest diff --git a/tests/ut/python/metrics/test_topk.py b/tests/ut/python/metrics/test_topk.py index 5f13bec7f6a..07739ee9465 100644 --- a/tests/ut/python/metrics/test_topk.py +++ b/tests/ut/python/metrics/test_topk.py @@ -14,7 +14,6 @@ # ============================================================================ """test topk""" import math - import numpy as np import pytest diff --git a/tests/ut/python/mindrecord/skip_test_issue.py b/tests/ut/python/mindrecord/skip_test_issue.py index 75a55e543d9..1ec10b005c8 100644 --- a/tests/ut/python/mindrecord/skip_test_issue.py +++ b/tests/ut/python/mindrecord/skip_test_issue.py @@ -15,12 +15,13 @@ """test issue""" import os import pytest -from mindspore.mindrecord import ShardHeader, SUCCESS, FAILED, ParamValueError -from mindspore.mindrecord import ShardWriter, ShardIndexGenerator, ShardReader +from utils import get_data, get_nlp_data, get_mkv_data + +from mindspore import log as logger from mindspore.mindrecord import FileWriter, FileReader from mindspore.mindrecord import MRMAddIndexError -from mindspore import log as logger -from utils import get_data, get_nlp_data, get_mkv_data +from mindspore.mindrecord import ShardHeader, SUCCESS, FAILED, ParamValueError +from mindspore.mindrecord import ShardWriter, ShardIndexGenerator, ShardReader FILES_NUM = 4 CV_FILE_NAME = "./imagenet.mindrecord" diff --git a/tests/ut/python/mindrecord/skip_test_mindrecord_shard.py b/tests/ut/python/mindrecord/skip_test_mindrecord_shard.py index 0e3711e71c7..dfe496ca961 100644 --- a/tests/ut/python/mindrecord/skip_test_mindrecord_shard.py +++ b/tests/ut/python/mindrecord/skip_test_mindrecord_shard.py @@ -15,10 +15,11 @@ """test internal shard api""" import os import random +from utils import get_data, get_nlp_data, get_mkv_data + +from mindspore import log as logger from mindspore.mindrecord import ShardHeader, SUCCESS from mindspore.mindrecord import ShardWriter, ShardIndexGenerator, ShardReader, ShardSegment -from mindspore import log as logger -from utils import get_data, get_nlp_data, get_mkv_data FILES_NUM = 4 CV_FILE_NAME = "./imagenet.mindrecord" diff --git a/tests/ut/python/mindrecord/test_cifar100_to_mindrecord.py b/tests/ut/python/mindrecord/test_cifar100_to_mindrecord.py index 6b1fcfdc258..0662356eecd 100644 --- a/tests/ut/python/mindrecord/test_cifar100_to_mindrecord.py +++ b/tests/ut/python/mindrecord/test_cifar100_to_mindrecord.py @@ -15,11 +15,12 @@ """test cifar100 to mindrecord tool""" import os import pytest + +from mindspore import log as logger from mindspore.mindrecord import Cifar100ToMR from mindspore.mindrecord import FileReader from mindspore.mindrecord import MRMOpenError from mindspore.mindrecord import SUCCESS -from mindspore import log as logger CIFAR100_DIR = "../data/mindrecord/testCifar100Data" MINDRECORD_FILE = "./cifar100.mindrecord" diff --git a/tests/ut/python/mindrecord/test_cifar10_to_mindrecord.py b/tests/ut/python/mindrecord/test_cifar10_to_mindrecord.py index a86b716cd0a..aab17c78638 100644 --- a/tests/ut/python/mindrecord/test_cifar10_to_mindrecord.py +++ b/tests/ut/python/mindrecord/test_cifar10_to_mindrecord.py @@ -15,10 +15,11 @@ """test cifar10 to mindrecord tool""" import os import pytest + +from mindspore import log as logger from mindspore.mindrecord import Cifar10ToMR from mindspore.mindrecord import FileReader from mindspore.mindrecord import MRMOpenError, SUCCESS -from mindspore import log as logger CIFAR10_DIR = "../data/mindrecord/testCifar10Data" MINDRECORD_FILE = "./cifar10.mindrecord" diff --git a/tests/ut/python/mindrecord/test_imagenet_to_mindrecord.py b/tests/ut/python/mindrecord/test_imagenet_to_mindrecord.py index 6e01b904b6c..385192bbda8 100644 --- a/tests/ut/python/mindrecord/test_imagenet_to_mindrecord.py +++ b/tests/ut/python/mindrecord/test_imagenet_to_mindrecord.py @@ -15,9 +15,10 @@ """test imagenet to mindrecord tool""" import os import pytest -from mindspore.mindrecord import ImageNetToMR -from mindspore.mindrecord import FileReader + from mindspore import log as logger +from mindspore.mindrecord import FileReader +from mindspore.mindrecord import ImageNetToMR IMAGENET_MAP_FILE = "../data/mindrecord/testImageNetDataWhole/labels_map.txt" IMAGENET_IMAGE_DIR = "../data/mindrecord/testImageNetDataWhole/images" diff --git a/tests/ut/python/mindrecord/test_mindrecord_base.py b/tests/ut/python/mindrecord/test_mindrecord_base.py index 75762cefbc9..65f4b9a305d 100644 --- a/tests/ut/python/mindrecord/test_mindrecord_base.py +++ b/tests/ut/python/mindrecord/test_mindrecord_base.py @@ -16,10 +16,11 @@ import numpy as np import os import uuid -from mindspore.mindrecord import FileWriter, FileReader, MindPage, SUCCESS -from mindspore import log as logger from utils import get_data, get_nlp_data +from mindspore import log as logger +from mindspore.mindrecord import FileWriter, FileReader, MindPage, SUCCESS + FILES_NUM = 4 CV_FILE_NAME = "./imagenet.mindrecord" CV2_FILE_NAME = "./imagenet_loop.mindrecord" diff --git a/tests/ut/python/mindrecord/test_mindrecord_exception.py b/tests/ut/python/mindrecord/test_mindrecord_exception.py index 7388409ba95..2eef72cebed 100644 --- a/tests/ut/python/mindrecord/test_mindrecord_exception.py +++ b/tests/ut/python/mindrecord/test_mindrecord_exception.py @@ -15,11 +15,12 @@ """test mindrecord exception""" import os import pytest +from utils import get_data + +from mindspore import log as logger from mindspore.mindrecord import FileWriter, FileReader, MindPage, SUCCESS from mindspore.mindrecord import MRMOpenError, MRMGenerateIndexError, ParamValueError, MRMGetMetaError, \ MRMFetchDataError -from mindspore import log as logger -from utils import get_data CV_FILE_NAME = "./imagenet.mindrecord" NLP_FILE_NAME = "./aclImdb.mindrecord" diff --git a/tests/ut/python/mindrecord/test_mindrecord_multi_images.py b/tests/ut/python/mindrecord/test_mindrecord_multi_images.py index dd464c5fb44..99abfd27b4b 100644 --- a/tests/ut/python/mindrecord/test_mindrecord_multi_images.py +++ b/tests/ut/python/mindrecord/test_mindrecord_multi_images.py @@ -14,10 +14,11 @@ """test write multiple images""" import numpy as np import os -from mindspore.mindrecord import FileReader, FileWriter -from mindspore import log as logger from utils import get_two_bytes_data, get_multi_bytes_data +from mindspore import log as logger +from mindspore.mindrecord import FileReader, FileWriter + MAP_FILE_NAME = "../data/mindrecord/testTwoImageData/cityscapes_train_19.txt" MAP_FILE_FAKE_NAME = "../data/mindrecord/testTwoImageData/cityscapes_train_19_fake.txt" DIFF_SHAPE_FILE_NAME = "../data/mindrecord/testImageNetData/cityscapes_train_19_fake.txt" diff --git a/tests/ut/python/mindrecord/test_mnist_to_mr.py b/tests/ut/python/mindrecord/test_mnist_to_mr.py index 505b0d6b432..55376f3dcb4 100644 --- a/tests/ut/python/mindrecord/test_mnist_to_mr.py +++ b/tests/ut/python/mindrecord/test_mnist_to_mr.py @@ -12,14 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. """test mnist to mindrecord tool""" -import os -import gzip import cv2 +import gzip import numpy as np +import os -from mindspore.mindrecord import MnistToMR -from mindspore.mindrecord import FileReader from mindspore import log as logger +from mindspore.mindrecord import FileReader +from mindspore.mindrecord import MnistToMR MNIST_DIR = "../data/mindrecord/testMnistData" FILE_NAME = "mnist" diff --git a/tests/ut/python/mindrecord/utils.py b/tests/ut/python/mindrecord/utils.py index 729680cd4b2..be6855bbe22 100644 --- a/tests/ut/python/mindrecord/utils.py +++ b/tests/ut/python/mindrecord/utils.py @@ -16,10 +16,10 @@ import collections import json +import numpy as np import os import re import string -import numpy as np from mindspore import log as logger diff --git a/tests/ut/python/model/test_bert_cell.py b/tests/ut/python/model/test_bert_cell.py index a7257dced0c..3de6073787d 100644 --- a/tests/ut/python/model/test_bert_cell.py +++ b/tests/ut/python/model/test_bert_cell.py @@ -14,7 +14,6 @@ # ============================================================================ """ test bert of graph compile """ import functools - import numpy as np import mindspore.common.dtype as mstype diff --git a/tests/ut/python/nn/optim/test_lars.py b/tests/ut/python/nn/optim/test_lars.py index 2088f65f934..c34033d884b 100644 --- a/tests/ut/python/nn/optim/test_lars.py +++ b/tests/ut/python/nn/optim/test_lars.py @@ -12,9 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -from collections import Counter - import numpy as np +from collections import Counter import mindspore.nn as nn from mindspore import Tensor, Parameter diff --git a/tests/ut/python/nn/test_container.py b/tests/ut/python/nn/test_container.py index 4103f203fa9..cd3e34a2fa9 100644 --- a/tests/ut/python/nn/test_container.py +++ b/tests/ut/python/nn/test_container.py @@ -13,10 +13,9 @@ # limitations under the License. # ============================================================================ """ test container """ -from collections import OrderedDict - import numpy as np import pytest +from collections import OrderedDict import mindspore.nn as nn from mindspore import Tensor diff --git a/tests/ut/python/onnx/test_onnx.py b/tests/ut/python/onnx/test_onnx.py index b89a70c9e47..a3de151ae90 100644 --- a/tests/ut/python/onnx/test_onnx.py +++ b/tests/ut/python/onnx/test_onnx.py @@ -13,13 +13,12 @@ # limitations under the License. # ============================================================================ """ut for model serialize(save/load)""" +import numpy as np import os +import pytest import stat import time -import numpy as np -import pytest - import mindspore.common.dtype as mstype import mindspore.nn as nn from mindspore import context diff --git a/tests/ut/python/ops/test_array_ops.py b/tests/ut/python/ops/test_array_ops.py index 90856a0b395..083d5b1c314 100644 --- a/tests/ut/python/ops/test_array_ops.py +++ b/tests/ut/python/ops/test_array_ops.py @@ -14,19 +14,19 @@ # ============================================================================ """ test array ops """ import functools -import pytest import numpy as np +import pytest +from mindspore._c_expression import signature_dtype as sig_dtype +from mindspore._c_expression import signature_kind as sig_kind +from mindspore._c_expression import signature_rw as sig_rw + import mindspore as ms from mindspore import Tensor +from mindspore.common import dtype as mstype from mindspore.nn import Cell from mindspore.ops import operations as P from mindspore.ops import prim_attr_register -from mindspore.common import dtype as mstype from mindspore.ops.primitive import Primitive, PrimitiveWithInfer -from mindspore._c_expression import signature_dtype as sig_dtype -from mindspore._c_expression import signature_rw as sig_rw -from mindspore._c_expression import signature_kind as sig_kind - from ..ut_filter import non_graph_engine from ....mindspore_test_framework.mindspore_test import mindspore_test from ....mindspore_test_framework.pipeline.forward.compile_forward \ diff --git a/tests/ut/python/ops/test_array_ops_check.py b/tests/ut/python/ops/test_array_ops_check.py index 1cea5979cba..015b6b03c07 100755 --- a/tests/ut/python/ops/test_array_ops_check.py +++ b/tests/ut/python/ops/test_array_ops_check.py @@ -15,18 +15,18 @@ """ test ops """ import functools import numpy as np + +import mindspore.nn as nn +import mindspore.ops.composite as C +from mindspore import Tensor from mindspore import ops +from mindspore.common import dtype as mstype +from mindspore.common.api import _executor +from mindspore.common.parameter import Parameter from mindspore.ops import functional as F from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G -import mindspore.ops.composite as C -import mindspore.nn as nn -from mindspore import Tensor -from mindspore.common import dtype as mstype -from mindspore.common.parameter import Parameter from ..ut_filter import non_graph_engine -from mindspore.common.api import _executor - from ....mindspore_test_framework.mindspore_test import mindspore_test from ....mindspore_test_framework.pipeline.forward.compile_forward \ import (pipeline_for_compile_forward_ge_graph_for_case_by_case_config, diff --git a/tests/ut/python/ops/test_bprop_disorder.py b/tests/ut/python/ops/test_bprop_disorder.py index 96ecb55d16f..0760d9f2bb7 100644 --- a/tests/ut/python/ops/test_bprop_disorder.py +++ b/tests/ut/python/ops/test_bprop_disorder.py @@ -15,11 +15,12 @@ """ test bprop disorder """ import functools import numpy as np + import mindspore.nn as nn from mindspore import Tensor, Parameter +from mindspore.common.parameter import ParameterTuple from mindspore.ops import composite as C from mindspore.ops import operations as P -from mindspore.common.parameter import ParameterTuple from ..ut_filter import non_graph_engine from ....mindspore_test_framework.mindspore_test import mindspore_test from ....mindspore_test_framework.pipeline.forward.compile_forward \ diff --git a/tests/ut/python/ops/test_control_ops.py b/tests/ut/python/ops/test_control_ops.py index 27743656f0a..8d81811d9b5 100644 --- a/tests/ut/python/ops/test_control_ops.py +++ b/tests/ut/python/ops/test_control_ops.py @@ -14,14 +14,15 @@ # ============================================================================ """ test control ops """ import numpy as np + import mindspore as ms -from mindspore import nn from mindspore import Tensor from mindspore import context -from mindspore.ops import operations as P +from mindspore import nn +from mindspore.common.parameter import Parameter, ParameterTuple from mindspore.ops import composite as C from mindspore.ops import functional as F -from mindspore.common.parameter import Parameter, ParameterTuple +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE) diff --git a/tests/ut/python/ops/test_list.py b/tests/ut/python/ops/test_list.py index 1f44b783d5d..35ff469a31c 100644 --- a/tests/ut/python/ops/test_list.py +++ b/tests/ut/python/ops/test_list.py @@ -14,6 +14,7 @@ # ============================================================================ import functools import numpy as np + import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import operations as P diff --git a/tests/ut/python/ops/test_math_ops.py b/tests/ut/python/ops/test_math_ops.py index 2fef51d9136..33ae04486ef 100755 --- a/tests/ut/python/ops/test_math_ops.py +++ b/tests/ut/python/ops/test_math_ops.py @@ -15,23 +15,24 @@ """ test math ops """ import functools import numpy as np +import pytest + import mindspore as ms -import mindspore.nn as nn -from mindspore.common.api import _executor -from mindspore.common import dtype as mstype -from mindspore.ops import prim_attr_register, PrimitiveWithInfer -from mindspore import Tensor -from mindspore.ops import composite as C -from mindspore.ops import operations as P -from mindspore.ops import functional as F import mindspore.context as context +import mindspore.nn as nn +from mindspore import Tensor +from mindspore.common import dtype as mstype +from mindspore.common.api import _executor +from mindspore.ops import composite as C +from mindspore.ops import functional as F +from mindspore.ops import operations as P +from mindspore.ops import prim_attr_register, PrimitiveWithInfer from ..ut_filter import non_graph_engine from ....mindspore_test_framework.mindspore_test import mindspore_test from ....mindspore_test_framework.pipeline.forward.compile_forward \ import pipeline_for_compile_forward_ge_graph_for_case_by_case_config from ....mindspore_test_framework.pipeline.forward.verify_exception \ import pipeline_for_verify_exception_for_case_by_case_config -import pytest # pylint: disable=W0613 diff --git a/tests/ut/python/ops/test_math_ops_check.py b/tests/ut/python/ops/test_math_ops_check.py index 9521f180315..14bbe493bda 100755 --- a/tests/ut/python/ops/test_math_ops_check.py +++ b/tests/ut/python/ops/test_math_ops_check.py @@ -15,18 +15,18 @@ """ test ops """ import functools import numpy as np + +import mindspore.nn as nn +import mindspore.ops.composite as C +from mindspore import Tensor from mindspore import ops +from mindspore.common import dtype as mstype +from mindspore.common.api import _executor +from mindspore.common.parameter import Parameter from mindspore.ops import functional as F from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G -import mindspore.ops.composite as C -import mindspore.nn as nn -from mindspore import Tensor -from mindspore.common import dtype as mstype -from mindspore.common.parameter import Parameter from ..ut_filter import non_graph_engine -from mindspore.common.api import _executor - from ....mindspore_test_framework.mindspore_test import mindspore_test from ....mindspore_test_framework.pipeline.forward.compile_forward \ import (pipeline_for_compile_forward_ge_graph_for_case_by_case_config, diff --git a/tests/ut/python/ops/test_momentum.py b/tests/ut/python/ops/test_momentum.py index f86f6e7d976..e6aeaab8ce9 100644 --- a/tests/ut/python/ops/test_momentum.py +++ b/tests/ut/python/ops/test_momentum.py @@ -15,11 +15,12 @@ """ test_momentum """ import functools import numpy as np + import mindspore.nn as nn -from mindspore.ops import functional as F -from mindspore.ops import composite as C -from mindspore.ops import operations as P from mindspore import Parameter, ParameterTuple, Tensor +from mindspore.ops import composite as C +from mindspore.ops import functional as F +from mindspore.ops import operations as P from ..ut_filter import non_graph_engine from ....mindspore_test_framework.mindspore_test import mindspore_test from ....mindspore_test_framework.pipeline.forward.compile_forward \ diff --git a/tests/ut/python/ops/test_multitype_ops.py b/tests/ut/python/ops/test_multitype_ops.py index c640501c9a2..eecdf359be9 100644 --- a/tests/ut/python/ops/test_multitype_ops.py +++ b/tests/ut/python/ops/test_multitype_ops.py @@ -13,8 +13,9 @@ # limitations under the License. # ============================================================================ """multitype_ops directory test case""" -from functools import partial, reduce import numpy as np +from functools import partial, reduce + import mindspore.nn as nn from mindspore import Tensor from mindspore.ops import functional as F, composite as C diff --git a/tests/ut/python/ops/test_nn_ops.py b/tests/ut/python/ops/test_nn_ops.py index c9746128a27..05bc9a6c3c6 100644 --- a/tests/ut/python/ops/test_nn_ops.py +++ b/tests/ut/python/ops/test_nn_ops.py @@ -15,18 +15,16 @@ """ test nn ops """ import functools import numpy as np + import mindspore - -import mindspore.nn as nn import mindspore.context as context - +import mindspore.nn as nn from mindspore import Tensor, Parameter from mindspore.common.initializer import initializer from mindspore.ops import Primitive from mindspore.ops import composite as C from mindspore.ops import operations as P from mindspore.ops import prim_attr_register, PrimitiveWithInfer - from ..ut_filter import non_graph_engine from ....mindspore_test_framework.mindspore_test import mindspore_test from ....mindspore_test_framework.pipeline.forward.compile_forward \ diff --git a/tests/ut/python/ops/test_nn_ops_check.py b/tests/ut/python/ops/test_nn_ops_check.py index 8f7f04b0787..e52af518593 100755 --- a/tests/ut/python/ops/test_nn_ops_check.py +++ b/tests/ut/python/ops/test_nn_ops_check.py @@ -15,18 +15,18 @@ """ test ops """ import functools import numpy as np -from mindspore import ops -from mindspore.ops import functional as F -from mindspore.ops import operations as P -from mindspore.ops import composite as C -from mindspore.ops.operations import _grad_ops as G + import mindspore.nn as nn from mindspore import Tensor +from mindspore import ops from mindspore.common import dtype as mstype -from mindspore.common.parameter import Parameter -from ..ut_filter import non_graph_engine from mindspore.common.api import _executor - +from mindspore.common.parameter import Parameter +from mindspore.ops import composite as C +from mindspore.ops import functional as F +from mindspore.ops import operations as P +from mindspore.ops.operations import _grad_ops as G +from ..ut_filter import non_graph_engine from ....mindspore_test_framework.mindspore_test import mindspore_test from ....mindspore_test_framework.pipeline.forward.compile_forward \ import (pipeline_for_compile_forward_ge_graph_for_case_by_case_config, diff --git a/tests/ut/python/ops/test_ops.py b/tests/ut/python/ops/test_ops.py index 4793d1fca9c..5fc201f9517 100755 --- a/tests/ut/python/ops/test_ops.py +++ b/tests/ut/python/ops/test_ops.py @@ -15,16 +15,16 @@ """ test ops """ import functools import numpy as np + +import mindspore.nn as nn +import mindspore.ops.composite as C +from mindspore import Tensor from mindspore import ops, Parameter, context +from mindspore.common import dtype as mstype from mindspore.ops import functional as F from mindspore.ops import operations as P from mindspore.ops.operations import _grad_ops as G -import mindspore.ops.composite as C -import mindspore.nn as nn -from mindspore import Tensor -from mindspore.common import dtype as mstype from ..ut_filter import non_graph_engine - from ....mindspore_test_framework.mindspore_test import mindspore_test from ....mindspore_test_framework.pipeline.forward.compile_forward \ import (pipeline_for_compile_forward_ge_graph_for_case_by_case_config, diff --git a/tests/ut/python/ops/test_ops_check.py b/tests/ut/python/ops/test_ops_check.py index 0a4a2fb5e2e..418e54c4c86 100644 --- a/tests/ut/python/ops/test_ops_check.py +++ b/tests/ut/python/ops/test_ops_check.py @@ -17,10 +17,11 @@ import functools import logging import numpy as np import pytest -from mindspore import nn + from mindspore import Tensor -from mindspore.ops import operations as P +from mindspore import nn from mindspore.common.api import _executor +from mindspore.ops import operations as P from ..ut_filter import non_graph_engine from ....mindspore_test_framework.mindspore_test import mindspore_test from ....mindspore_test_framework.pipeline.forward.compile_forward \ diff --git a/tests/ut/python/ops/test_ops_reid.py b/tests/ut/python/ops/test_ops_reid.py index 57a595eca9e..741f631ab6f 100644 --- a/tests/ut/python/ops/test_ops_reid.py +++ b/tests/ut/python/ops/test_ops_reid.py @@ -16,15 +16,14 @@ import functools import numpy as np -from mindspore.ops import operations as P import mindspore.nn as nn -from ....ops_common import convert - +from mindspore.ops import operations as P from ....mindspore_test_framework.mindspore_test import mindspore_test from ....mindspore_test_framework.pipeline.forward.compile_forward \ import pipeline_for_compile_forward_ge_graph_for_case_by_case_config from ....mindspore_test_framework.pipeline.gradient.compile_gradient \ import pipeline_for_compile_grad_ge_graph_for_case_by_case_config +from ....ops_common import convert class SeqConvBnRelu(nn.Cell): diff --git a/tests/ut/python/ops/test_python_operators.py b/tests/ut/python/ops/test_python_operators.py index 9e9877e6c95..cab6fef68c0 100644 --- a/tests/ut/python/ops/test_python_operators.py +++ b/tests/ut/python/ops/test_python_operators.py @@ -15,12 +15,13 @@ """ test control ops """ import functools import numpy as np + import mindspore as ms -from mindspore import nn from mindspore import Tensor from mindspore import context -from mindspore.ops import operations as P +from mindspore import nn from mindspore.common import dtype as mstype +from mindspore.ops import operations as P from ....mindspore_test_framework.mindspore_test import mindspore_test from ....mindspore_test_framework.pipeline.forward.compile_forward \ import pipeline_for_compile_forward_ge_graph_for_case_by_case_config diff --git a/tests/ut/python/ops/test_tensor_slice.py b/tests/ut/python/ops/test_tensor_slice.py index 5d0c76b4479..d07f1a35a94 100644 --- a/tests/ut/python/ops/test_tensor_slice.py +++ b/tests/ut/python/ops/test_tensor_slice.py @@ -20,7 +20,6 @@ from mindspore import Tensor from mindspore import context from mindspore import dtype as mstype from mindspore.nn import Cell - from ....mindspore_test_framework.mindspore_test import mindspore_test from ....mindspore_test_framework.pipeline.forward.compile_forward \ import pipeline_for_compile_forward_ge_graph_for_case_by_case_config diff --git a/tests/ut/python/ops/test_tuple.py b/tests/ut/python/ops/test_tuple.py index f0cd7fc59b0..9e6b0b92029 100644 --- a/tests/ut/python/ops/test_tuple.py +++ b/tests/ut/python/ops/test_tuple.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -import mindspore.context as context import functools import numpy as np + +import mindspore.context as context import mindspore.nn as nn from mindspore import Tensor +from mindspore import context from mindspore import dtype as mstype from mindspore.ops import operations as P -from mindspore import context from ..ut_filter import non_graph_engine from ....mindspore_test_framework.mindspore_test import mindspore_test from ....mindspore_test_framework.pipeline.forward.compile_forward \ diff --git a/tests/ut/python/ops/test_tuple_slice.py b/tests/ut/python/ops/test_tuple_slice.py index 2c0bde7eef7..eeb7f382e19 100644 --- a/tests/ut/python/ops/test_tuple_slice.py +++ b/tests/ut/python/ops/test_tuple_slice.py @@ -16,10 +16,9 @@ import numpy as np import pytest +import mindspore.ops.operations as P from mindspore import Tensor from mindspore.nn import Cell -import mindspore.ops.operations as P - from ....mindspore_test_framework.mindspore_test import mindspore_test from ....mindspore_test_framework.pipeline.forward.compile_forward \ import pipeline_for_compile_forward_ge_graph_for_case_by_case_config diff --git a/tests/ut/python/parallel/__init__.py b/tests/ut/python/parallel/__init__.py index da0f047f70f..653fde4f3ff 100644 --- a/tests/ut/python/parallel/__init__.py +++ b/tests/ut/python/parallel/__init__.py @@ -15,8 +15,8 @@ import mindspore.context as context from mindspore.parallel._auto_parallel_context import auto_parallel_context from mindspore.parallel._cost_model_context import reset_cost_model_context -from mindspore.parallel.algo_parameter_config import reset_algo_parameters from mindspore.parallel._utils import _reset_op_id +from mindspore.parallel.algo_parameter_config import reset_algo_parameters def setup_module(module): diff --git a/tests/ut/python/parallel/conftest.py b/tests/ut/python/parallel/conftest.py index 75d16a5ca08..847d6216d5c 100644 --- a/tests/ut/python/parallel/conftest.py +++ b/tests/ut/python/parallel/conftest.py @@ -12,11 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. import pytest + import mindspore.context as context from mindspore.parallel._auto_parallel_context import auto_parallel_context from mindspore.parallel._cost_model_context import reset_cost_model_context -from mindspore.parallel.algo_parameter_config import reset_algo_parameters from mindspore.parallel._utils import _reset_op_id +from mindspore.parallel.algo_parameter_config import reset_algo_parameters @pytest.fixture(scope="function", autouse="True") diff --git a/tests/ut/python/parallel/parallel_end_to_end/add_relu/_test_add_relu_parallel_4p.py b/tests/ut/python/parallel/parallel_end_to_end/add_relu/_test_add_relu_parallel_4p.py index 0feaff24d1b..32e19be33ca 100644 --- a/tests/ut/python/parallel/parallel_end_to_end/add_relu/_test_add_relu_parallel_4p.py +++ b/tests/ut/python/parallel/parallel_end_to_end/add_relu/_test_add_relu_parallel_4p.py @@ -12,15 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +import numpy as np import os import pytest -import numpy as np + import mindspore as ms -from mindspore.nn import Cell -from mindspore import context -from mindspore.ops import operations as P -from mindspore.common.tensor import Tensor import mindspore.communication.management as distributedTool +from mindspore import context +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P from mindspore.ops.composite import grad_all_with_sens device_num = 4 diff --git a/tests/ut/python/parallel/parallel_end_to_end/batch_parallel/_test_conv2d_parallel_4p.py b/tests/ut/python/parallel/parallel_end_to_end/batch_parallel/_test_conv2d_parallel_4p.py index e6f196b3a52..0a839f45e85 100644 --- a/tests/ut/python/parallel/parallel_end_to_end/batch_parallel/_test_conv2d_parallel_4p.py +++ b/tests/ut/python/parallel/parallel_end_to_end/batch_parallel/_test_conv2d_parallel_4p.py @@ -12,17 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os import numpy as np -import mindspore.communication.management as distributedTool +import os from numpy import allclose + +import mindspore.communication.management as distributedTool from mindspore import context -from mindspore.nn import Cell -from mindspore.ops import operations as P -from mindspore.common.tensor import Tensor -from mindspore.common.parameter import Parameter from mindspore._checkparam import check_bool, twice from mindspore.common.initializer import initializer +from mindspore.common.parameter import Parameter +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P from mindspore.ops.composite import grad_all_with_sens device_num = 4 diff --git a/tests/ut/python/parallel/parallel_end_to_end/dropout/_test_dropout_parallel_4p.py b/tests/ut/python/parallel/parallel_end_to_end/dropout/_test_dropout_parallel_4p.py index 0e1c7e2dce2..44b361bcc54 100644 --- a/tests/ut/python/parallel/parallel_end_to_end/dropout/_test_dropout_parallel_4p.py +++ b/tests/ut/python/parallel/parallel_end_to_end/dropout/_test_dropout_parallel_4p.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os import numpy as np +import os + import mindspore as ms import mindspore.communication.management as distributedTool -from mindspore.nn import Cell from mindspore import context -from mindspore.nn import Dropout from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.nn import Dropout device_num = 4 device_id = int(os.environ["RANK_ID"]) diff --git a/tests/ut/python/parallel/parallel_end_to_end/hcom/_test_allgather_4p.py b/tests/ut/python/parallel/parallel_end_to_end/hcom/_test_allgather_4p.py index b0e4aba2ffc..006cc6925dd 100644 --- a/tests/ut/python/parallel/parallel_end_to_end/hcom/_test_allgather_4p.py +++ b/tests/ut/python/parallel/parallel_end_to_end/hcom/_test_allgather_4p.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os import numpy as np +import os + import mindspore as ms -from mindspore.nn import Cell -from mindspore import context -from mindspore.ops import operations as P -from mindspore.common.tensor import Tensor import mindspore.communication.management as distributedTool +from mindspore import context +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P from mindspore.ops.composite import grad_all_with_sens device_num = 4 diff --git a/tests/ut/python/parallel/parallel_end_to_end/hcom/_test_allreduce_4p.py b/tests/ut/python/parallel/parallel_end_to_end/hcom/_test_allreduce_4p.py index 8b6d9b138e8..b2067469306 100644 --- a/tests/ut/python/parallel/parallel_end_to_end/hcom/_test_allreduce_4p.py +++ b/tests/ut/python/parallel/parallel_end_to_end/hcom/_test_allreduce_4p.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os import numpy as np +import os + import mindspore as ms -from mindspore.nn import Cell -from mindspore import context -from mindspore.ops import operations as P -from mindspore.common.tensor import Tensor import mindspore.communication.management as distributedTool +from mindspore import context +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P from mindspore.ops.composite import grad_all_with_sens device_num = 4 diff --git a/tests/ut/python/parallel/parallel_end_to_end/l2normalize/_test_l2normalize_parallel_4p.py b/tests/ut/python/parallel/parallel_end_to_end/l2normalize/_test_l2normalize_parallel_4p.py index 00f924ab004..a9cd30cccf3 100644 --- a/tests/ut/python/parallel/parallel_end_to_end/l2normalize/_test_l2normalize_parallel_4p.py +++ b/tests/ut/python/parallel/parallel_end_to_end/l2normalize/_test_l2normalize_parallel_4p.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +import numpy as np import os import pytest -import numpy as np -from mindspore.nn import Cell -from mindspore import context -from mindspore.ops import operations as P -from mindspore.common.tensor import Tensor + import mindspore.communication.management as distributedTool +from mindspore import context +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P from mindspore.ops.composite import grad_all_with_sens device_num = 4 diff --git a/tests/ut/python/parallel/parallel_end_to_end/loss/_test_loss_parallel_4p.py b/tests/ut/python/parallel/parallel_end_to_end/loss/_test_loss_parallel_4p.py index dd2c16d79f1..b26b7180688 100644 --- a/tests/ut/python/parallel/parallel_end_to_end/loss/_test_loss_parallel_4p.py +++ b/tests/ut/python/parallel/parallel_end_to_end/loss/_test_loss_parallel_4p.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +import numpy as np import os import pytest -import numpy as np -from mindspore.nn import Cell -from mindspore import context -from mindspore.ops import operations as P -from mindspore.common.tensor import Tensor + import mindspore.communication.management as distributedTool +from mindspore import context +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P from mindspore.ops.composite import grad_all device_num = 4 diff --git a/tests/ut/python/parallel/parallel_end_to_end/matmul/_test_matmul_parallel_4p.py b/tests/ut/python/parallel/parallel_end_to_end/matmul/_test_matmul_parallel_4p.py index 3cdd878ef3a..8ce6860495f 100644 --- a/tests/ut/python/parallel/parallel_end_to_end/matmul/_test_matmul_parallel_4p.py +++ b/tests/ut/python/parallel/parallel_end_to_end/matmul/_test_matmul_parallel_4p.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os import numpy as np +import os from numpy import allclose + +import mindspore.communication.management as distributedTool from mindspore import context +from mindspore.common.tensor import Tensor from mindspore.nn import Cell from mindspore.ops import operations as P -from mindspore.common.tensor import Tensor -import mindspore.communication.management as distributedTool from mindspore.ops.composite import grad_all_with_sens device_num = 4 diff --git a/tests/ut/python/parallel/parallel_end_to_end/max/_test_max_parallel_4p.py b/tests/ut/python/parallel/parallel_end_to_end/max/_test_max_parallel_4p.py index 648692226a3..017ee7ebc33 100644 --- a/tests/ut/python/parallel/parallel_end_to_end/max/_test_max_parallel_4p.py +++ b/tests/ut/python/parallel/parallel_end_to_end/max/_test_max_parallel_4p.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +import numpy as np import os import pytest -import numpy as np + +import mindspore.communication.management as distributedTool from mindspore import context +from mindspore.common.tensor import Tensor from mindspore.nn import Cell from mindspore.ops import operations as P -from mindspore.common.tensor import Tensor -import mindspore.communication.management as distributedTool from mindspore.ops.composite import grad_all_with_sens device_num = 4 diff --git a/tests/ut/python/parallel/parallel_end_to_end/mul_softmax/need_fix_test_mul_softmax_parallel_4p.py b/tests/ut/python/parallel/parallel_end_to_end/mul_softmax/need_fix_test_mul_softmax_parallel_4p.py index f005d577ce0..f37e6176d6b 100644 --- a/tests/ut/python/parallel/parallel_end_to_end/mul_softmax/need_fix_test_mul_softmax_parallel_4p.py +++ b/tests/ut/python/parallel/parallel_end_to_end/mul_softmax/need_fix_test_mul_softmax_parallel_4p.py @@ -12,16 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +import numpy as np import os import pytest -import numpy as np -import mindspore as ms from numpy import allclose -from mindspore.nn import Cell -from mindspore import context -from mindspore.ops import operations as P -from mindspore.common.tensor import Tensor + +import mindspore as ms import mindspore.communication.management as distributedTool +from mindspore import context +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P from mindspore.ops.composite import grad_all_with_sens device_num = 4 diff --git a/tests/ut/python/parallel/parallel_end_to_end/onehot/_test_onehot_parallel_4p.py b/tests/ut/python/parallel/parallel_end_to_end/onehot/_test_onehot_parallel_4p.py index c9995ead956..9c79a0b05f7 100644 --- a/tests/ut/python/parallel/parallel_end_to_end/onehot/_test_onehot_parallel_4p.py +++ b/tests/ut/python/parallel/parallel_end_to_end/onehot/_test_onehot_parallel_4p.py @@ -12,16 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +import numpy as np import os import pytest -import numpy as np -import mindspore as ms from numpy import allclose -from mindspore.nn import Cell -from mindspore import context -from mindspore.ops import operations as P -from mindspore.common.tensor import Tensor + +import mindspore as ms import mindspore.communication.management as distributedTool +from mindspore import context +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P device_num = 4 device_id = int(os.environ["RANK_ID"]) diff --git a/tests/ut/python/parallel/parallel_end_to_end/prelu/_test_prelu_parallel_4p.py b/tests/ut/python/parallel/parallel_end_to_end/prelu/_test_prelu_parallel_4p.py index 100f1cd7c2c..161b25430d0 100644 --- a/tests/ut/python/parallel/parallel_end_to_end/prelu/_test_prelu_parallel_4p.py +++ b/tests/ut/python/parallel/parallel_end_to_end/prelu/_test_prelu_parallel_4p.py @@ -12,16 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +import numpy as np import os import pytest -import numpy as np +from numpy import allclose + import mindspore as ms import mindspore.communication.management as distributedTool -from numpy import allclose from mindspore import context +from mindspore.common.tensor import Tensor from mindspore.nn import Cell from mindspore.ops import operations as P -from mindspore.common.tensor import Tensor from mindspore.ops.composite import grad_all_with_sens device_num = 4 diff --git a/tests/ut/python/parallel/parallel_end_to_end/reducemean/_test_reducemean_parallel_4p.py b/tests/ut/python/parallel/parallel_end_to_end/reducemean/_test_reducemean_parallel_4p.py index e07c473f033..82ab74d38d2 100644 --- a/tests/ut/python/parallel/parallel_end_to_end/reducemean/_test_reducemean_parallel_4p.py +++ b/tests/ut/python/parallel/parallel_end_to_end/reducemean/_test_reducemean_parallel_4p.py @@ -12,16 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +import numpy as np import os import pytest -import numpy as np +from numpy import allclose as allclose_nparray + import mindspore as ms import mindspore.communication.management as distributedTool -from mindspore.nn import Cell from mindspore import context -from mindspore.ops import operations as P from mindspore.common.tensor import Tensor -from numpy import allclose as allclose_nparray +from mindspore.nn import Cell +from mindspore.ops import operations as P from mindspore.ops.composite import grad_all_with_sens device_num = 4 diff --git a/tests/ut/python/parallel/parallel_end_to_end/reshape/_test_reshape_parallel_4p.py b/tests/ut/python/parallel/parallel_end_to_end/reshape/_test_reshape_parallel_4p.py index a4d1eb08082..70532e5c81a 100644 --- a/tests/ut/python/parallel/parallel_end_to_end/reshape/_test_reshape_parallel_4p.py +++ b/tests/ut/python/parallel/parallel_end_to_end/reshape/_test_reshape_parallel_4p.py @@ -12,15 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +import numpy as np import os import pytest -import numpy as np -import mindspore.communication.management as distributedTool -from mindspore.nn import Cell -from mindspore import context -from mindspore.ops import operations as P -from mindspore.common.tensor import Tensor from numpy import allclose as allclose_nparray + +import mindspore.communication.management as distributedTool +from mindspore import context +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P from mindspore.ops.composite import grad_all_with_sens device_num = 4 diff --git a/tests/ut/python/parallel/parallel_end_to_end/transpose/_test_transpose_parallel_4p.py b/tests/ut/python/parallel/parallel_end_to_end/transpose/_test_transpose_parallel_4p.py index 2efccab47d4..7fd5462200f 100644 --- a/tests/ut/python/parallel/parallel_end_to_end/transpose/_test_transpose_parallel_4p.py +++ b/tests/ut/python/parallel/parallel_end_to_end/transpose/_test_transpose_parallel_4p.py @@ -12,15 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +import numpy as np import os import pytest -import numpy as np -import mindspore.communication.management as distributedTool -from mindspore.nn import Cell -from mindspore import context -from mindspore.ops import operations as P -from mindspore.common.tensor import Tensor from numpy import allclose as allclose_nparray + +import mindspore.communication.management as distributedTool +from mindspore import context +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell +from mindspore.ops import operations as P from mindspore.ops.composite import grad_all_with_sens device_num = 4 diff --git a/tests/ut/python/parallel/test_add_relu_redistribution.py b/tests/ut/python/parallel/test_add_relu_redistribution.py index 1288efe29e6..7a9934fe398 100644 --- a/tests/ut/python/parallel/test_add_relu_redistribution.py +++ b/tests/ut/python/parallel/test_add_relu_redistribution.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class AddRelu(nn.Cell): diff --git a/tests/ut/python/parallel/test_allreduce_fusion.py b/tests/ut/python/parallel/test_allreduce_fusion.py index 6c5413105f8..c5938694307 100644 --- a/tests/ut/python/parallel/test_allreduce_fusion.py +++ b/tests/ut/python/parallel/test_allreduce_fusion.py @@ -12,18 +12,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mindspore.train import Model, ParallelMode -from mindspore.nn.loss import SoftmaxCrossEntropyWithLogits -from mindspore.nn.optim.momentum import Momentum -from mindspore import Tensor, context -import mindspore as ms import numpy as np + +import mindspore as ms import mindspore.nn as nn -from tests.dataset_mock import MindData +from mindspore import Tensor, context from mindspore import context from mindspore.common.api import _executor +from mindspore.nn.loss import SoftmaxCrossEntropyWithLogits +from mindspore.nn.optim.momentum import Momentum from mindspore.parallel import _cost_model_context as cost_model_context from mindspore.parallel._auto_parallel_context import auto_parallel_context +from mindspore.train import Model, ParallelMode +from tests.dataset_mock import MindData class Dataset(MindData): diff --git a/tests/ut/python/parallel/test_alltoall.py b/tests/ut/python/parallel/test_alltoall.py index 9ac42091735..7f9fcbfa766 100644 --- a/tests/ut/python/parallel/test_alltoall.py +++ b/tests/ut/python/parallel/test_alltoall.py @@ -12,19 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mindspore.train import Model, ParallelMode +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.common.parameter import Parameter from mindspore.nn.loss import SoftmaxCrossEntropyWithLogits from mindspore.nn.optim.momentum import Momentum -from mindspore import Tensor -import mindspore as ms -import numpy as np from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.parameter import Parameter -from tests.dataset_mock import MindData -from mindspore import context from mindspore.parallel._utils import _reset_op_id -from mindspore.common.api import _executor +from mindspore.train import Model, ParallelMode +from tests.dataset_mock import MindData class Dataset(MindData): diff --git a/tests/ut/python/parallel/test_arithmetic.py b/tests/ut/python/parallel/test_arithmetic.py index 3856dd55ff8..d4a926f0f4e 100644 --- a/tests/ut/python/parallel/test_arithmetic.py +++ b/tests/ut/python/parallel/test_arithmetic.py @@ -13,12 +13,13 @@ # limitations under the License. import numpy as np + import mindspore as ms -from mindspore import Parameter, Tensor, context import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore.ops import composite as C +from mindspore import Parameter, Tensor, 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 diff --git a/tests/ut/python/parallel/test_auto_parallel_BN_PReLU.py b/tests/ut/python/parallel/test_auto_parallel_BN_PReLU.py index 4b6dbb6c18e..02f0b9c77d9 100644 --- a/tests/ut/python/parallel/test_auto_parallel_BN_PReLU.py +++ b/tests/ut/python/parallel/test_auto_parallel_BN_PReLU.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_arithmetic.py b/tests/ut/python/parallel/test_auto_parallel_arithmetic.py index e0d763e5249..7eb8ddccd3d 100644 --- a/tests/ut/python/parallel/test_auto_parallel_arithmetic.py +++ b/tests/ut/python/parallel/test_auto_parallel_arithmetic.py @@ -13,16 +13,17 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + import mindspore as ms +import mindspore.nn as nn +from mindspore import Tensor +from mindspore import context +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 mindspore.parallel._utils import _reset_op_id as reset_op_id -from mindspore import context +from tests.ut.python.ops.test_math_ops import VirtualLoss context.set_context(mode=context.GRAPH_MODE) diff --git a/tests/ut/python/parallel/test_auto_parallel_assign_sub_with_ref_key.py b/tests/ut/python/parallel/test_auto_parallel_assign_sub_with_ref_key.py index 240e0730e60..d95473d9935 100644 --- a/tests/ut/python/parallel/test_auto_parallel_assign_sub_with_ref_key.py +++ b/tests/ut/python/parallel/test_auto_parallel_assign_sub_with_ref_key.py @@ -12,17 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -import re import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss +import re + 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 mindspore.parallel._utils import _reset_op_id as reset_op_id +from tests.ut.python.ops.test_math_ops import VirtualLoss class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_cast.py b/tests/ut/python/parallel/test_auto_parallel_cast.py index 3bd8d5a5af0..cac452de960 100644 --- a/tests/ut/python/parallel/test_auto_parallel_cast.py +++ b/tests/ut/python/parallel/test_auto_parallel_cast.py @@ -13,16 +13,17 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + import mindspore as ms +import mindspore.nn as nn +from mindspore import Tensor +from mindspore import context from mindspore.common import dtype as mstype from mindspore.common.api import _executor from mindspore.ops import composite as C +from mindspore.ops import operations as P from mindspore.parallel._utils import _reset_op_id as reset_op_id +from tests.ut.python.ops.test_math_ops import VirtualLoss class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_common_parameter.py b/tests/ut/python/parallel/test_auto_parallel_common_parameter.py index 46e08935caf..b2e09b2b84f 100644 --- a/tests/ut/python/parallel/test_auto_parallel_common_parameter.py +++ b/tests/ut/python/parallel/test_auto_parallel_common_parameter.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_double_star.py b/tests/ut/python/parallel/test_auto_parallel_double_star.py index b31c8663962..6969aaded83 100644 --- a/tests/ut/python/parallel/test_auto_parallel_double_star.py +++ b/tests/ut/python/parallel/test_auto_parallel_double_star.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_double_subgraphs.py b/tests/ut/python/parallel/test_auto_parallel_double_subgraphs.py index a08e45ec0fb..0c1b7dc81be 100644 --- a/tests/ut/python/parallel/test_auto_parallel_double_subgraphs.py +++ b/tests/ut/python/parallel/test_auto_parallel_double_subgraphs.py @@ -1,14 +1,15 @@ import numpy as np -from mindspore import context + import mindspore as ms import mindspore.nn as nn -from mindspore.nn.optim import Adam, FTRL -from mindspore.ops import operations as P -from mindspore.ops import functional as F from mindspore import Tensor, Parameter, ParameterTuple -from mindspore.ops import composite as C -from mindspore.parallel import _cost_model_context as cost_model_context +from mindspore import context from mindspore.common.api import _executor +from mindspore.nn.optim import Adam, FTRL +from mindspore.ops import composite as C +from mindspore.ops import functional as F +from mindspore.ops import operations as P +from mindspore.parallel import _cost_model_context as cost_model_context from mindspore.parallel import set_algo_parameters, get_algo_parameters, reset_algo_parameters from mindspore.parallel._utils import _reset_op_id as reset_op_id diff --git a/tests/ut/python/parallel/test_auto_parallel_fc_nobias.py b/tests/ut/python/parallel/test_auto_parallel_fc_nobias.py index fd7d4ff527c..3449511e89c 100644 --- a/tests/ut/python/parallel/test_auto_parallel_fc_nobias.py +++ b/tests/ut/python/parallel/test_auto_parallel_fc_nobias.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_four_matmul.py b/tests/ut/python/parallel/test_auto_parallel_four_matmul.py index a12d41b0b9b..6cb9b6f7a2a 100644 --- a/tests/ut/python/parallel/test_auto_parallel_four_matmul.py +++ b/tests/ut/python/parallel/test_auto_parallel_four_matmul.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_inference.py b/tests/ut/python/parallel/test_auto_parallel_inference.py index 162dbf626e2..ac8d4fc4738 100644 --- a/tests/ut/python/parallel/test_auto_parallel_inference.py +++ b/tests/ut/python/parallel/test_auto_parallel_inference.py @@ -2,9 +2,9 @@ import numpy as np import mindspore.nn as nn from mindspore import Tensor, context -from mindspore.ops import operations as P -from mindspore.nn import WithLossCell, TrainOneStepCell from mindspore.nn import Momentum +from mindspore.nn import WithLossCell, TrainOneStepCell +from mindspore.ops import operations as P from mindspore.parallel._cost_model_context import set_cost_model_context diff --git a/tests/ut/python/parallel/test_auto_parallel_l2normalize.py b/tests/ut/python/parallel/test_auto_parallel_l2normalize.py index 8ba645fa114..09763d91395 100644 --- a/tests/ut/python/parallel/test_auto_parallel_l2normalize.py +++ b/tests/ut/python/parallel/test_auto_parallel_l2normalize.py @@ -13,15 +13,16 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 mindspore.parallel._utils import _reset_op_id as reset_op_id +from tests.ut.python.ops.test_math_ops import VirtualLoss class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_matmul_drop.py b/tests/ut/python/parallel/test_auto_parallel_matmul_drop.py index 51360cfaf9e..fd102577c53 100644 --- a/tests/ut/python/parallel/test_auto_parallel_matmul_drop.py +++ b/tests/ut/python/parallel/test_auto_parallel_matmul_drop.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_matmul_prelu.py b/tests/ut/python/parallel/test_auto_parallel_matmul_prelu.py index cf6d4ac40ff..0c5caa38b8e 100644 --- a/tests/ut/python/parallel/test_auto_parallel_matmul_prelu.py +++ b/tests/ut/python/parallel/test_auto_parallel_matmul_prelu.py @@ -12,17 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -import re import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss +import re + 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 mindspore.parallel._utils import _reset_op_id as reset_op_id +from tests.ut.python.ops.test_math_ops import VirtualLoss class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_onehot.py b/tests/ut/python/parallel/test_auto_parallel_onehot.py index 175e12aec1e..b82cd49e5bc 100644 --- a/tests/ut/python/parallel/test_auto_parallel_onehot.py +++ b/tests/ut/python/parallel/test_auto_parallel_onehot.py @@ -13,18 +13,19 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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.common.parameter import Parameter -from tests.dataset_mock import MindData -from mindspore.train import Model, ParallelMode from mindspore.nn.optim.momentum import Momentum +from mindspore.ops import composite as C +from mindspore.ops import operations as P +from mindspore.train import Model, ParallelMode +from tests.dataset_mock import MindData +from tests.ut.python.ops.test_math_ops import VirtualLoss context.set_context(mode=context.GRAPH_MODE) diff --git a/tests/ut/python/parallel/test_auto_parallel_parameter_cast.py b/tests/ut/python/parallel/test_auto_parallel_parameter_cast.py index d179c94f273..3f4b093d636 100644 --- a/tests/ut/python/parallel/test_auto_parallel_parameter_cast.py +++ b/tests/ut/python/parallel/test_auto_parallel_parameter_cast.py @@ -13,18 +13,19 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + import mindspore as ms +import mindspore.nn as nn +from mindspore import Tensor +from mindspore import Tensor, Parameter +from mindspore import context from mindspore.common import dtype as mstype from mindspore.common.api import _executor from mindspore.ops import composite as C -from mindspore import Tensor, Parameter -from mindspore.parallel._utils import _reset_op_id as reset_op_id +from mindspore.ops import operations as P from mindspore.parallel import set_algo_parameters +from mindspore.parallel._utils import _reset_op_id as reset_op_id +from tests.ut.python.ops.test_math_ops import VirtualLoss class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_partial_strategy.py b/tests/ut/python/parallel/test_auto_parallel_partial_strategy.py index 96f5205aff9..32267cf73b9 100644 --- a/tests/ut/python/parallel/test_auto_parallel_partial_strategy.py +++ b/tests/ut/python/parallel/test_auto_parallel_partial_strategy.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_reduce_method.py b/tests/ut/python/parallel/test_auto_parallel_reduce_method.py index e53354d492e..9af55db3be8 100644 --- a/tests/ut/python/parallel/test_auto_parallel_reduce_method.py +++ b/tests/ut/python/parallel/test_auto_parallel_reduce_method.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_reshape.py b/tests/ut/python/parallel/test_auto_parallel_reshape.py index e41138bd0db..ce308cf485a 100644 --- a/tests/ut/python/parallel/test_auto_parallel_reshape.py +++ b/tests/ut/python/parallel/test_auto_parallel_reshape.py @@ -13,15 +13,16 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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.common.parameter import Parameter +from mindspore.ops import composite as C +from mindspore.ops import operations as P +from tests.ut.python.ops.test_math_ops import VirtualLoss class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_resnet.py b/tests/ut/python/parallel/test_auto_parallel_resnet.py index 07ad2016a6d..c373135a411 100644 --- a/tests/ut/python/parallel/test_auto_parallel_resnet.py +++ b/tests/ut/python/parallel/test_auto_parallel_resnet.py @@ -13,22 +13,23 @@ # limitations under the License. import numpy as np -import mindspore.nn as nn +import re + import mindspore.common.dtype as mstype +import mindspore.nn as nn +import mindspore.ops.functional as F from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.nn.optim.momentum import Momentum +from mindspore import context +from mindspore.common.api import _executor from mindspore.common.initializer import TruncatedNormal from mindspore.communication.management import init -from mindspore.train.model import Model, ParallelMode -from mindspore import context -import re -import mindspore.ops.functional as F from mindspore.nn.loss.loss import _Loss -from mindspore.parallel._utils import _reset_op_id as resset_op_id -from mindspore.common.api import _executor -from mindspore.parallel import set_algo_parameters +from mindspore.nn.optim.momentum import Momentum +from mindspore.ops import operations as P from mindspore.parallel import _cost_model_context as cost_model_context +from mindspore.parallel import set_algo_parameters +from mindspore.parallel._utils import _reset_op_id as resset_op_id +from mindspore.train.model import Model, ParallelMode context.set_context(mode=context.GRAPH_MODE, device_target="Ascend") context.set_context(device_id=0) diff --git a/tests/ut/python/parallel/test_auto_parallel_rhombus.py b/tests/ut/python/parallel/test_auto_parallel_rhombus.py index 83006a12e8f..fd0d2cba43d 100644 --- a/tests/ut/python/parallel/test_auto_parallel_rhombus.py +++ b/tests/ut/python/parallel/test_auto_parallel_rhombus.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor, Parameter -from tests.ut.python.ops.test_math_ops import VirtualLoss + import mindspore as ms +import mindspore.nn as nn +from mindspore import Tensor, Parameter +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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_softmax_loss.py b/tests/ut/python/parallel/test_auto_parallel_softmax_loss.py index fa8dbc91d0a..c63a0d378df 100644 --- a/tests/ut/python/parallel/test_auto_parallel_softmax_loss.py +++ b/tests/ut/python/parallel/test_auto_parallel_softmax_loss.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_transformer.py b/tests/ut/python/parallel/test_auto_parallel_transformer.py index 3f476126811..dd4734c5a31 100644 --- a/tests/ut/python/parallel/test_auto_parallel_transformer.py +++ b/tests/ut/python/parallel/test_auto_parallel_transformer.py @@ -13,13 +13,14 @@ # limitations under the License. import numpy as np -from mindspore import context + import mindspore.nn as nn -from mindspore.common.api import _executor from mindspore import Tensor, Parameter +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 -from mindspore.ops import composite as C class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_transpose.py b/tests/ut/python/parallel/test_auto_parallel_transpose.py index 357c88cec3c..e0195de37b6 100644 --- a/tests/ut/python/parallel/test_auto_parallel_transpose.py +++ b/tests/ut/python/parallel/test_auto_parallel_transpose.py @@ -13,15 +13,16 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 mindspore.parallel._utils import _reset_op_id as reset_op_id +from tests.ut.python.ops.test_math_ops import VirtualLoss class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_tuple_depend.py b/tests/ut/python/parallel/test_auto_parallel_tuple_depend.py index 2ef21c8904b..ab6fdcb5cef 100644 --- a/tests/ut/python/parallel/test_auto_parallel_tuple_depend.py +++ b/tests/ut/python/parallel/test_auto_parallel_tuple_depend.py @@ -13,15 +13,16 @@ # limitations under the License. import numpy as np -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 mindspore.ops.operations.comm_ops import _VirtualDataset -from mindspore import context +from tests.ut.python.ops.test_math_ops import VirtualLoss class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_two_bn.py b/tests/ut/python/parallel/test_auto_parallel_two_bn.py index 6cd2cbfdc49..c6c01be5c1d 100644 --- a/tests/ut/python/parallel/test_auto_parallel_two_bn.py +++ b/tests/ut/python/parallel/test_auto_parallel_two_bn.py @@ -1,14 +1,15 @@ import numpy as np -from mindspore import context +import re + import mindspore as ms import mindspore.nn as nn -from mindspore.ops import operations as P from mindspore import Tensor +from mindspore import context from mindspore.common.api import _executor -from tests.ut.python.ops.test_math_ops import VirtualLoss +from mindspore.ops import operations as P from mindspore.parallel import set_algo_parameters from mindspore.parallel._utils import _reset_op_id as reset_op_id -import re +from tests.ut.python.ops.test_math_ops import VirtualLoss class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_two_matmul.py b/tests/ut/python/parallel/test_auto_parallel_two_matmul.py index 05159d74a7e..c5352fc1c74 100644 --- a/tests/ut/python/parallel/test_auto_parallel_two_matmul.py +++ b/tests/ut/python/parallel/test_auto_parallel_two_matmul.py @@ -13,17 +13,18 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 mindspore.parallel import _cost_model_context as cost_model_context from mindspore.parallel import set_algo_parameters, get_algo_parameters, reset_algo_parameters from mindspore.parallel._utils import _reset_op_id as reset_op_id +from tests.ut.python.ops.test_math_ops import VirtualLoss class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_two_partial_matmul.py b/tests/ut/python/parallel/test_auto_parallel_two_partial_matmul.py index 894a1f0df84..8b54e514ba2 100644 --- a/tests/ut/python/parallel/test_auto_parallel_two_partial_matmul.py +++ b/tests/ut/python/parallel/test_auto_parallel_two_partial_matmul.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor, Parameter -from tests.ut.python.ops.test_math_ops import VirtualLoss + import mindspore as ms +import mindspore.nn as nn +from mindspore import Tensor, Parameter +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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_parallel_zig_zag.py b/tests/ut/python/parallel/test_auto_parallel_zig_zag.py index 3453a12b3f4..8fc995171e4 100644 --- a/tests/ut/python/parallel/test_auto_parallel_zig_zag.py +++ b/tests/ut/python/parallel/test_auto_parallel_zig_zag.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_auto_star_elimination.py b/tests/ut/python/parallel/test_auto_star_elimination.py index 2bf52e33086..b8919c2b945 100644 --- a/tests/ut/python/parallel/test_auto_star_elimination.py +++ b/tests/ut/python/parallel/test_auto_star_elimination.py @@ -11,21 +11,22 @@ # 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. -from mindspore.nn.loss.loss import _Loss -from mindspore.ops import operations as P -from mindspore.ops import functional as F -from mindspore import Tensor, Parameter -from mindspore.common import dtype as mstype -from mindspore.common.initializer import initializer -import mindspore.nn as nn import math import numpy as np import os -from tests.ut.python.ops.test_math_ops import VirtualLoss -from mindspore.ops import composite as C -from mindspore import context -from mindspore.common.api import _executor + import mindspore as ms +import mindspore.nn as nn +from mindspore import Tensor, Parameter +from mindspore import context +from mindspore.common import dtype as mstype +from mindspore.common.api import _executor +from mindspore.common.initializer import initializer +from mindspore.nn.loss.loss import _Loss +from mindspore.ops import composite as C +from mindspore.ops import functional as F +from mindspore.ops import operations as P +from tests.ut.python.ops.test_math_ops import VirtualLoss class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_batch_matmul.py b/tests/ut/python/parallel/test_batch_matmul.py index 82b9a1b6f19..7ed4029b51c 100644 --- a/tests/ut/python/parallel/test_batch_matmul.py +++ b/tests/ut/python/parallel/test_batch_matmul.py @@ -13,11 +13,12 @@ # limitations under the License. import numpy as np + import mindspore as ms from mindspore import context, Tensor, Parameter +from mindspore.common.api import _executor from mindspore.nn import Cell, TrainOneStepCell, Momentum from mindspore.ops import operations as P -from mindspore.common.api import _executor class Net(Cell): diff --git a/tests/ut/python/parallel/test_batch_parallel.py b/tests/ut/python/parallel/test_batch_parallel.py index e01afe14ab8..6e505f2e462 100644 --- a/tests/ut/python/parallel/test_batch_parallel.py +++ b/tests/ut/python/parallel/test_batch_parallel.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_batch_parallel_dropout.py b/tests/ut/python/parallel/test_batch_parallel_dropout.py index 7aa2a049bba..5e4a189ca95 100644 --- a/tests/ut/python/parallel/test_batch_parallel_dropout.py +++ b/tests/ut/python/parallel/test_batch_parallel_dropout.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_batch_parallel_tensoradd.py b/tests/ut/python/parallel/test_batch_parallel_tensoradd.py index 13bbdd69d81..271ee9a98dd 100644 --- a/tests/ut/python/parallel/test_batch_parallel_tensoradd.py +++ b/tests/ut/python/parallel/test_batch_parallel_tensoradd.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_batchnorm_batch_parallel.py b/tests/ut/python/parallel/test_batchnorm_batch_parallel.py index 78887818f1d..d395a56a067 100644 --- a/tests/ut/python/parallel/test_batchnorm_batch_parallel.py +++ b/tests/ut/python/parallel/test_batchnorm_batch_parallel.py @@ -12,20 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mindspore.train import Model, ParallelMode -from mindspore.nn.loss import SoftmaxCrossEntropyWithLogits -from mindspore.nn.optim.momentum import Momentum -import mindspore as ms import numpy as np + +import mindspore as ms from mindspore import context +from mindspore.common.parameter import Parameter from mindspore.common.tensor import Tensor -from mindspore.nn.layer.activation import ReLU from mindspore.nn.cell import Cell +from mindspore.nn.layer.activation import ReLU from mindspore.nn.layer.conv import Conv2d from mindspore.nn.layer.normalization import BatchNorm2d from mindspore.nn.layer.pooling import MaxPool2d +from mindspore.nn.loss import SoftmaxCrossEntropyWithLogits +from mindspore.nn.optim.momentum import Momentum from mindspore.ops import operations as P -from mindspore.common.parameter import Parameter +from mindspore.train import Model, ParallelMode from tests.dataset_mock import MindData dev_num = 8 diff --git a/tests/ut/python/parallel/test_bias_add.py b/tests/ut/python/parallel/test_bias_add.py index d5d24f71bfc..321810b1ae1 100644 --- a/tests/ut/python/parallel/test_bias_add.py +++ b/tests/ut/python/parallel/test_bias_add.py @@ -13,10 +13,11 @@ # limitations under the License. import numpy as np -from mindspore import context + import mindspore.nn as nn -from mindspore.ops import operations as P from mindspore import Tensor +from mindspore import context +from mindspore.ops import operations as P from mindspore.train.model import Model diff --git a/tests/ut/python/parallel/test_bn_prelu_cell.py b/tests/ut/python/parallel/test_bn_prelu_cell.py index 78cd8b20bf8..e5c94bd2410 100644 --- a/tests/ut/python/parallel/test_bn_prelu_cell.py +++ b/tests/ut/python/parallel/test_bn_prelu_cell.py @@ -12,22 +12,23 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mindspore.train.model import Model +import numpy as np + +import mindspore as ms +import mindspore.common.dtype as DT +import mindspore.nn as nn +from mindspore import Tensor +from mindspore import context +from mindspore.common.initializer import initializer +from mindspore.common.parameter import Parameter +from mindspore.nn import WithLossCell from mindspore.nn.loss import SoftmaxCrossEntropyWithLogits from mindspore.nn.optim.momentum import Momentum -from mindspore import Tensor -import mindspore as ms -import numpy as np -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.parameter import Parameter -from mindspore.common.initializer import initializer from mindspore.ops import functional as F -from mindspore.nn import WithLossCell -import mindspore.common.dtype as DT -from tests.dataset_mock import MindData +from mindspore.ops import operations as P +from mindspore.train.model import Model from mindspore.train.parallel_utils import ParallelMode -from mindspore import context +from tests.dataset_mock import MindData class Dataset(MindData): diff --git a/tests/ut/python/parallel/test_bool_grad.py b/tests/ut/python/parallel/test_bool_grad.py index 2334ebc430f..6ce4e9be942 100644 --- a/tests/ut/python/parallel/test_bool_grad.py +++ b/tests/ut/python/parallel/test_bool_grad.py @@ -12,16 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mindspore import Tensor -import mindspore as ms import numpy as np -from mindspore.ops import operations as P + +import mindspore as ms import mindspore.nn as nn -from mindspore.common.parameter import Parameter -from tests.dataset_mock import MindData +from mindspore import Tensor from mindspore import context -from mindspore.train import Model, ParallelMode +from mindspore.common.parameter import Parameter from mindspore.nn.optim import Momentum +from mindspore.ops import operations as P +from mindspore.train import Model, ParallelMode +from tests.dataset_mock import MindData context.set_context(mode=context.GRAPH_MODE) diff --git a/tests/ut/python/parallel/test_broadcast_dict.py b/tests/ut/python/parallel/test_broadcast_dict.py index 709dbb72987..ccc299a93f6 100644 --- a/tests/ut/python/parallel/test_broadcast_dict.py +++ b/tests/ut/python/parallel/test_broadcast_dict.py @@ -13,11 +13,12 @@ # limitations under the License. import numpy as np -import mindspore.nn as nn + import mindspore.context as context +import mindspore.nn as nn from mindspore import Tensor, Parameter -from mindspore.ops import operations as P from mindspore.communication.management import init +from mindspore.ops import operations as P class DataParallelNet(nn.Cell): diff --git a/tests/ut/python/parallel/test_combined_tensor.py b/tests/ut/python/parallel/test_combined_tensor.py index 046c67db00d..acd590cafc6 100644 --- a/tests/ut/python/parallel/test_combined_tensor.py +++ b/tests/ut/python/parallel/test_combined_tensor.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mindspore.parallel._tensor import _reshape_param_data from mindspore import Tensor +from mindspore.parallel._tensor import _reshape_param_data def test_reshape_param_data(): diff --git a/tests/ut/python/parallel/test_comparison_function_info.py b/tests/ut/python/parallel/test_comparison_function_info.py index 5194152009d..4ac4e4cbcb0 100644 --- a/tests/ut/python/parallel/test_comparison_function_info.py +++ b/tests/ut/python/parallel/test_comparison_function_info.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np + import mindspore as ms -from mindspore import context import mindspore.nn as nn -from mindspore.ops import operations as P from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss +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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_dataset.py b/tests/ut/python/parallel/test_dataset.py index 7e35207ac83..c4f2e68b5f0 100644 --- a/tests/ut/python/parallel/test_dataset.py +++ b/tests/ut/python/parallel/test_dataset.py @@ -13,10 +13,11 @@ # limitations under the License. import numpy as np + import mindspore.nn as nn -from mindspore.ops import operations as P from mindspore import Tensor from mindspore.common.api import _executor +from mindspore.ops import operations as P from mindspore.ops.operations.comm_ops import _VirtualDataset diff --git a/tests/ut/python/parallel/test_dataset_interface.py b/tests/ut/python/parallel/test_dataset_interface.py index ebfae6939b2..6b1d1bcbb88 100644 --- a/tests/ut/python/parallel/test_dataset_interface.py +++ b/tests/ut/python/parallel/test_dataset_interface.py @@ -12,18 +12,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mindspore.train import Model, ParallelMode +import numpy as np + +import mindspore as ms +import mindspore.nn as nn +from mindspore import Tensor +from mindspore import context +from mindspore.common.parameter import Parameter, ParameterTuple from mindspore.nn.loss import SoftmaxCrossEntropyWithLogits from mindspore.nn.optim.momentum import Momentum -from mindspore import Tensor -import mindspore as ms -import numpy as np -import mindspore.nn as nn -from tests.dataset_mock import MindData -from mindspore import context -from mindspore.train.loss_scale_manager import DynamicLossScaleManager from mindspore.ops import composite as C, functional as F, operations as P -from mindspore.common.parameter import Parameter, ParameterTuple +from mindspore.train import Model, ParallelMode +from mindspore.train.loss_scale_manager import DynamicLossScaleManager +from tests.dataset_mock import MindData context.set_context(mode=context.GRAPH_MODE) diff --git a/tests/ut/python/parallel/test_dataset_util.py b/tests/ut/python/parallel/test_dataset_util.py index 21d90c78428..9f81e62b02d 100644 --- a/tests/ut/python/parallel/test_dataset_util.py +++ b/tests/ut/python/parallel/test_dataset_util.py @@ -13,9 +13,10 @@ # limitations under the License. import numpy as np -from mindspore.train._utils import _to_full_shapes, _to_full_tensor -from mindspore import Tensor + import mindspore as ms +from mindspore import Tensor +from mindspore.train._utils import _to_full_shapes, _to_full_tensor def test_to_full_shapes(): diff --git a/tests/ut/python/parallel/test_dense_matmul.py b/tests/ut/python/parallel/test_dense_matmul.py index 2ee9ab0eece..48ee5c8d529 100644 --- a/tests/ut/python/parallel/test_dense_matmul.py +++ b/tests/ut/python/parallel/test_dense_matmul.py @@ -13,9 +13,10 @@ # limitations under the License. import numpy as np + import mindspore.nn as nn -from mindspore.common.api import _executor from mindspore import Tensor, context +from mindspore.common.api import _executor from mindspore.ops import operations as P from ....train_step_wrap import train_step_with_loss_warp diff --git a/tests/ut/python/parallel/test_different_type_for_div_op.py b/tests/ut/python/parallel/test_different_type_for_div_op.py index 14ccee61a28..31af23e1006 100644 --- a/tests/ut/python/parallel/test_different_type_for_div_op.py +++ b/tests/ut/python/parallel/test_different_type_for_div_op.py @@ -13,13 +13,14 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor + 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 class GradWrap(nn.Cell): diff --git a/tests/ut/python/parallel/test_dropout_do_mask.py b/tests/ut/python/parallel/test_dropout_do_mask.py index c22a07fc310..03bcf3c1b6a 100644 --- a/tests/ut/python/parallel/test_dropout_do_mask.py +++ b/tests/ut/python/parallel/test_dropout_do_mask.py @@ -13,11 +13,12 @@ # limitations under the License. import numpy as np + import mindspore as ms from mindspore import context, Tensor, Parameter +from mindspore.common.api import _executor from mindspore.nn import Cell, TrainOneStepCell, Momentum from mindspore.ops import operations as P -from mindspore.common.api import _executor class Net(Cell): diff --git a/tests/ut/python/parallel/test_element_wise_function.py b/tests/ut/python/parallel/test_element_wise_function.py index aefd980b0d5..89a68933479 100644 --- a/tests/ut/python/parallel/test_element_wise_function.py +++ b/tests/ut/python/parallel/test_element_wise_function.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np + import mindspore as ms -from mindspore import context import mindspore.nn as nn -from mindspore.ops import operations as P from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss +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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_expand_dims.py b/tests/ut/python/parallel/test_expand_dims.py index 6048eea7313..649adcdbe9e 100644 --- a/tests/ut/python/parallel/test_expand_dims.py +++ b/tests/ut/python/parallel/test_expand_dims.py @@ -13,11 +13,12 @@ # limitations under the License. import numpy as np + import mindspore as ms from mindspore import context, Tensor, Parameter +from mindspore.common.api import _executor from mindspore.nn import Cell, TrainOneStepCell, Momentum from mindspore.ops import operations as P -from mindspore.common.api import _executor class Net(Cell): diff --git a/tests/ut/python/parallel/test_forward_graph.py b/tests/ut/python/parallel/test_forward_graph.py index 577ee51a9b6..f84dfe05d6b 100644 --- a/tests/ut/python/parallel/test_forward_graph.py +++ b/tests/ut/python/parallel/test_forward_graph.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================ import numpy as np + import mindspore as ms from mindspore import context, Tensor, Parameter +from mindspore.common.api import _executor from mindspore.nn import Cell from mindspore.ops import operations as P -from mindspore.common.api import _executor class Net(Cell): diff --git a/tests/ut/python/parallel/test_gather_v2.py b/tests/ut/python/parallel/test_gather_v2.py index 7b3a91b64ec..6d943be5110 100644 --- a/tests/ut/python/parallel/test_gather_v2.py +++ b/tests/ut/python/parallel/test_gather_v2.py @@ -13,14 +13,15 @@ # limitations under the License. # ============================================================================ import numpy as np + import mindspore as ms +import mindspore.nn as nn from mindspore import Tensor from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore.ops import composite as C from mindspore.common import dtype as mstype 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 diff --git a/tests/ut/python/parallel/test_gather_v2_primitive.py b/tests/ut/python/parallel/test_gather_v2_primitive.py index 2174efc735f..a416923759d 100644 --- a/tests/ut/python/parallel/test_gather_v2_primitive.py +++ b/tests/ut/python/parallel/test_gather_v2_primitive.py @@ -13,20 +13,21 @@ # limitations under the License. # ============================================================================ import numpy as np -from mindspore.ops import composite as C -from mindspore.common.parameter import ParameterTuple -from mindspore.nn.optim import Momentum -from mindspore.communication.management import init -from mindspore.train import Model, ParallelMode + import mindspore as ms import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore.ops import functional as F -from mindspore.nn.loss.loss import _Loss from mindspore import Tensor -from mindspore.common import dtype as mstype -from mindspore.nn import Dense, Cell from mindspore import context +from mindspore.common import dtype as mstype +from mindspore.common.parameter import ParameterTuple +from mindspore.communication.management import init +from mindspore.nn import Dense, Cell +from mindspore.nn.loss.loss import _Loss +from mindspore.nn.optim import Momentum +from mindspore.ops import composite as C +from mindspore.ops import functional as F +from mindspore.ops import operations as P +from mindspore.train import Model, ParallelMode context.set_context(mode=context.GRAPH_MODE) device_number = 32 diff --git a/tests/ut/python/parallel/test_get_next.py b/tests/ut/python/parallel/test_get_next.py index 71faa569758..0ab5b5aa71c 100644 --- a/tests/ut/python/parallel/test_get_next.py +++ b/tests/ut/python/parallel/test_get_next.py @@ -13,17 +13,18 @@ # limitations under the License. import numpy as np -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + import mindspore as ms -from mindspore.common.api import _executor -from mindspore.ops import composite as C -from mindspore.common.parameter import Parameter, ParameterTuple -from mindspore.ops.operations.comm_ops import _VirtualDataset +import mindspore.nn as nn +from mindspore import Tensor from mindspore import context +from mindspore.common.api import _executor from mindspore.common.initializer import initializer +from mindspore.common.parameter import Parameter, ParameterTuple +from mindspore.ops import composite as C +from mindspore.ops import operations as P +from mindspore.ops.operations.comm_ops import _VirtualDataset +from tests.ut.python.ops.test_math_ops import VirtualLoss context.set_context(mode=context.GRAPH_MODE) diff --git a/tests/ut/python/parallel/test_get_parameter_layout.py b/tests/ut/python/parallel/test_get_parameter_layout.py index 6a3b729c1b6..9713d9f0bcf 100644 --- a/tests/ut/python/parallel/test_get_parameter_layout.py +++ b/tests/ut/python/parallel/test_get_parameter_layout.py @@ -13,12 +13,13 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor, Parameter + import mindspore as ms import mindspore.common.api as me +import mindspore.nn as nn +from mindspore import Tensor, Parameter +from mindspore import context +from mindspore.ops import operations as P def test_get_parameter_layout(): diff --git a/tests/ut/python/parallel/test_hybird_parallel_activation.py b/tests/ut/python/parallel/test_hybird_parallel_activation.py index f4c9863d235..dded194bf19 100644 --- a/tests/ut/python/parallel/test_hybird_parallel_activation.py +++ b/tests/ut/python/parallel/test_hybird_parallel_activation.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np + import mindspore as ms -from mindspore import context import mindspore.nn as nn -from mindspore.ops import operations as P from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss +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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_l2normalize.py b/tests/ut/python/parallel/test_l2normalize.py index e1c00176152..26b7283a321 100644 --- a/tests/ut/python/parallel/test_l2normalize.py +++ b/tests/ut/python/parallel/test_l2normalize.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_layer_norm.py b/tests/ut/python/parallel/test_layer_norm.py index ece4fa8e308..ce834a58f0b 100644 --- a/tests/ut/python/parallel/test_layer_norm.py +++ b/tests/ut/python/parallel/test_layer_norm.py @@ -14,12 +14,13 @@ # ============================================================================ import numpy as np import pytest + import mindspore as ms from mindspore import context, Tensor, Parameter -from mindspore.nn import Cell, TrainOneStepCell, Momentum -from mindspore.ops import operations as P from mindspore.common.api import _executor from mindspore.common.initializer import initializer +from mindspore.nn import Cell, TrainOneStepCell, Momentum +from mindspore.ops import operations as P class Net(Cell): diff --git a/tests/ut/python/parallel/test_linear.py b/tests/ut/python/parallel/test_linear.py index 2c1e5513799..efa6f58c613 100644 --- a/tests/ut/python/parallel/test_linear.py +++ b/tests/ut/python/parallel/test_linear.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_load_tensor.py b/tests/ut/python/parallel/test_load_tensor.py index 6335a2da905..85bf5529a4c 100644 --- a/tests/ut/python/parallel/test_load_tensor.py +++ b/tests/ut/python/parallel/test_load_tensor.py @@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mindspore.parallel._tensor import _load_tensor -from mindspore import Tensor from hccl_test.manage.api import Hccl +from mindspore import Tensor +from mindspore.parallel._tensor import _load_tensor + def test_load_tensor(): hccl = Hccl() diff --git a/tests/ut/python/parallel/test_loop_two_matmul.py b/tests/ut/python/parallel/test_loop_two_matmul.py index ec3078688ef..8cf87bd8127 100644 --- a/tests/ut/python/parallel/test_loop_two_matmul.py +++ b/tests/ut/python/parallel/test_loop_two_matmul.py @@ -12,16 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -import numpy as np import math -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss +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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_loss_and_optimizer.py b/tests/ut/python/parallel/test_loss_and_optimizer.py index 7ab87a5e835..6a2e9bc65da 100644 --- a/tests/ut/python/parallel/test_loss_and_optimizer.py +++ b/tests/ut/python/parallel/test_loss_and_optimizer.py @@ -13,15 +13,16 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor, Parameter + import mindspore as ms +import mindspore.nn as nn +from mindspore import Tensor, Parameter +from mindspore import context from mindspore.common.api import _executor -from mindspore.ops import composite as C -from mindspore.nn.optim import Momentum, LARS from mindspore.nn import TrainOneStepCell, WithLossCell +from mindspore.nn.optim import Momentum, LARS +from mindspore.ops import composite as C +from mindspore.ops import operations as P class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_matmul_dropout.py b/tests/ut/python/parallel/test_matmul_dropout.py index 8d6276db17a..846dbd8d9ad 100644 --- a/tests/ut/python/parallel/test_matmul_dropout.py +++ b/tests/ut/python/parallel/test_matmul_dropout.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_matmul_tensor.py b/tests/ut/python/parallel/test_matmul_tensor.py index a8211f2d19e..4af9fabbf4d 100644 --- a/tests/ut/python/parallel/test_matmul_tensor.py +++ b/tests/ut/python/parallel/test_matmul_tensor.py @@ -13,16 +13,17 @@ # limitations under the License. import numpy as np -from mindspore.context import set_auto_parallel_context -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + import mindspore as ms -from mindspore.common.api import _executor -from mindspore.ops import composite as C import mindspore.common.dtype as mstype +import mindspore.nn as nn +from mindspore import Tensor +from mindspore import context +from mindspore.common.api import _executor +from mindspore.context import set_auto_parallel_context +from mindspore.ops import composite as C +from mindspore.ops import operations as P +from tests.ut.python.ops.test_math_ops import VirtualLoss class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_mix_precision_hybrid_parallel.py b/tests/ut/python/parallel/test_mix_precision_hybrid_parallel.py index 6349e486885..fdbf087ed29 100644 --- a/tests/ut/python/parallel/test_mix_precision_hybrid_parallel.py +++ b/tests/ut/python/parallel/test_mix_precision_hybrid_parallel.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_neg.py b/tests/ut/python/parallel/test_neg.py index 09d5f7171e7..a44b851a746 100644 --- a/tests/ut/python/parallel/test_neg.py +++ b/tests/ut/python/parallel/test_neg.py @@ -13,11 +13,12 @@ # limitations under the License. import numpy as np + import mindspore as ms from mindspore import context, Tensor, Parameter +from mindspore.common.api import _executor from mindspore.nn import Cell, TrainOneStepCell, Momentum from mindspore.ops import operations as P -from mindspore.common.api import _executor class Net(Cell): diff --git a/tests/ut/python/parallel/test_one_dev.py b/tests/ut/python/parallel/test_one_dev.py index e5f8eefdae6..86626aabf1d 100644 --- a/tests/ut/python/parallel/test_one_dev.py +++ b/tests/ut/python/parallel/test_one_dev.py @@ -12,20 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. +import numpy as np import re -from mindspore.train import Model, ParallelMode + +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.common.parameter import Parameter from mindspore.nn.loss import SoftmaxCrossEntropyWithLogits from mindspore.nn.optim.momentum import Momentum -from mindspore import Tensor -import mindspore as ms -import numpy as np from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.parameter import Parameter -from tests.dataset_mock import MindData -from mindspore import context from mindspore.parallel._utils import _reset_op_id -from mindspore.common.api import _executor +from mindspore.train import Model, ParallelMode +from tests.dataset_mock import MindData context.set_context(mode=context.GRAPH_MODE) diff --git a/tests/ut/python/parallel/test_one_hot_net.py b/tests/ut/python/parallel/test_one_hot_net.py index bed8c57c164..ba067781a62 100644 --- a/tests/ut/python/parallel/test_one_hot_net.py +++ b/tests/ut/python/parallel/test_one_hot_net.py @@ -12,21 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mindspore.ops import operations as P -from mindspore.ops import functional as F -from mindspore import Tensor, Parameter -from mindspore.common import dtype as mstype -import mindspore.nn as nn import numpy as np -from mindspore.nn.cell import Cell -from tests.dataset_mock import MindData -from mindspore.nn.optim.momentum import Momentum -from mindspore.train import Model, ParallelMode -from tests.ut.python.ops.test_math_ops import VirtualLoss -from mindspore.ops import composite as C + import mindspore as ms -from mindspore.common.api import _executor +import mindspore.nn as nn +from mindspore import Tensor, Parameter from mindspore import context +from mindspore.common import dtype as mstype +from mindspore.common.api import _executor +from mindspore.nn.cell import Cell +from mindspore.nn.optim.momentum import Momentum +from mindspore.ops import composite as C +from mindspore.ops import functional as F +from mindspore.ops import operations as P +from mindspore.train import Model, ParallelMode +from tests.dataset_mock import MindData +from tests.ut.python.ops.test_math_ops import VirtualLoss device_num = 16 device_id = 2 diff --git a/tests/ut/python/parallel/test_one_weight_parameter.py b/tests/ut/python/parallel/test_one_weight_parameter.py index a0ad9402706..7ba812f24ae 100644 --- a/tests/ut/python/parallel/test_one_weight_parameter.py +++ b/tests/ut/python/parallel/test_one_weight_parameter.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor, Parameter, ParameterTuple + import mindspore as ms +import mindspore.nn as nn +from mindspore import Tensor, Parameter, ParameterTuple +from mindspore import context from mindspore.common.api import _executor from mindspore.ops import composite as C from mindspore.ops import functional as F +from mindspore.ops import operations as P class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_onehot.py b/tests/ut/python/parallel/test_onehot.py index e4e6ebb9c54..68983c3dc90 100644 --- a/tests/ut/python/parallel/test_onehot.py +++ b/tests/ut/python/parallel/test_onehot.py @@ -13,13 +13,14 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor + 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 mindspore.ops.operations.comm_ops import _VirtualDataset context.set_context(mode=context.GRAPH_MODE) diff --git a/tests/ut/python/parallel/test_operator_model_parallel.py b/tests/ut/python/parallel/test_operator_model_parallel.py index 8b63673ea48..cb7d013c51e 100644 --- a/tests/ut/python/parallel/test_operator_model_parallel.py +++ b/tests/ut/python/parallel/test_operator_model_parallel.py @@ -12,25 +12,26 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mindspore.train import Model, ParallelMode -from mindspore.nn.loss import SoftmaxCrossEntropyWithLogits -from mindspore.nn.optim.momentum import Momentum -import mindspore as ms import numpy as np + +import mindspore as ms import mindspore.ops.operations.math_ops as M +from mindspore import context +from mindspore.common.initializer import initializer +from mindspore.common.parameter import Parameter +from mindspore.common.tensor import Tensor +from mindspore.nn.cell import Cell +from mindspore.nn.layer.activation import ReLU from mindspore.nn.layer.basic import Dense from mindspore.nn.layer.basic import Flatten -from mindspore.ops.operations import TensorAdd -from mindspore.common.tensor import Tensor -from mindspore.nn.layer.activation import ReLU -from mindspore.nn.cell import Cell from mindspore.nn.layer.conv import Conv2d from mindspore.nn.layer.normalization import BatchNorm2d from mindspore.nn.layer.pooling import MaxPool2d +from mindspore.nn.loss import SoftmaxCrossEntropyWithLogits +from mindspore.nn.optim.momentum import Momentum from mindspore.ops import operations as P -from mindspore.common.initializer import initializer -from mindspore.common.parameter import Parameter -from mindspore import context +from mindspore.ops.operations import TensorAdd +from mindspore.train import Model, ParallelMode from tests.dataset_mock import MindData dev_num = 8 diff --git a/tests/ut/python/parallel/test_optimizer.py b/tests/ut/python/parallel/test_optimizer.py index 4ef4f891a40..10e8e261542 100644 --- a/tests/ut/python/parallel/test_optimizer.py +++ b/tests/ut/python/parallel/test_optimizer.py @@ -13,15 +13,16 @@ # limitations under the License. import numpy as np -import mindspore.nn as nn + import mindspore.context as context -from mindspore.common.api import _executor -from mindspore.nn import Dense -from mindspore.nn import TrainOneStepCell, WithLossCell -from mindspore.nn import Momentum +import mindspore.nn as nn from mindspore import Tensor, Parameter -from mindspore.ops import operations as P +from mindspore.common.api import _executor from mindspore.communication.management import init +from mindspore.nn import Dense +from mindspore.nn import Momentum +from mindspore.nn import TrainOneStepCell, WithLossCell +from mindspore.ops import operations as P from mindspore.train.parallel_utils import ParallelMode diff --git a/tests/ut/python/parallel/test_optimizer_clone_weight.py b/tests/ut/python/parallel/test_optimizer_clone_weight.py index defe3adb683..8570aede2fc 100644 --- a/tests/ut/python/parallel/test_optimizer_clone_weight.py +++ b/tests/ut/python/parallel/test_optimizer_clone_weight.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor, Parameter + import mindspore as ms +import mindspore.nn as nn +from mindspore import Tensor, Parameter +from mindspore import context from mindspore.common.api import _Executor -from mindspore.nn.optim import AdamWeightDecay from mindspore.nn import TrainOneStepCell +from mindspore.nn.optim import AdamWeightDecay +from mindspore.ops import operations as P class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_parameter_init.py b/tests/ut/python/parallel/test_parameter_init.py index 250d5e0db97..1daf3be7a5f 100644 --- a/tests/ut/python/parallel/test_parameter_init.py +++ b/tests/ut/python/parallel/test_parameter_init.py @@ -13,11 +13,12 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor, Parameter + import mindspore as ms +import mindspore.nn as nn +from mindspore import Tensor, Parameter +from mindspore import context +from mindspore.ops import operations as P class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_prelu.py b/tests/ut/python/parallel/test_prelu.py index 19acc07f99c..ac84c1364c2 100644 --- a/tests/ut/python/parallel/test_prelu.py +++ b/tests/ut/python/parallel/test_prelu.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_prelu_cell.py b/tests/ut/python/parallel/test_prelu_cell.py index 4ab7ec57fa0..40f8ab27015 100644 --- a/tests/ut/python/parallel/test_prelu_cell.py +++ b/tests/ut/python/parallel/test_prelu_cell.py @@ -12,19 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mindspore.train import Model, ParallelMode +import numpy as np + +import mindspore as ms +import mindspore.nn as nn +from mindspore import Tensor +from mindspore import context +from mindspore.common.initializer import initializer +from mindspore.common.parameter import Parameter from mindspore.nn.loss import SoftmaxCrossEntropyWithLogits from mindspore.nn.optim.momentum import Momentum -from mindspore import Tensor -import mindspore as ms -import numpy as np -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.parameter import Parameter -from tests.dataset_mock import MindData -from mindspore import context from mindspore.ops import functional as F -from mindspore.common.initializer import initializer +from mindspore.ops import operations as P +from mindspore.train import Model, ParallelMode +from tests.dataset_mock import MindData context.set_context(mode=context.GRAPH_MODE) diff --git a/tests/ut/python/parallel/test_reduce_method_info.py b/tests/ut/python/parallel/test_reduce_method_info.py index 87c994c1951..530454fc1a5 100644 --- a/tests/ut/python/parallel/test_reduce_method_info.py +++ b/tests/ut/python/parallel/test_reduce_method_info.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_reshape.py b/tests/ut/python/parallel/test_reshape.py index 903b6521128..f3e4160b01f 100644 --- a/tests/ut/python/parallel/test_reshape.py +++ b/tests/ut/python/parallel/test_reshape.py @@ -12,25 +12,26 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mindspore.train import Model, ParallelMode +import numpy as np + +import mindspore as ms +import mindspore.nn as nn +from mindspore import Tensor +from mindspore import context +from mindspore.common import dtype as mstype +from mindspore.common.api import _executor +from mindspore.common.parameter import Parameter +from mindspore.common.parameter import ParameterTuple from mindspore.nn.loss import SoftmaxCrossEntropyWithLogits from mindspore.nn.optim.momentum import Momentum -from mindspore import Tensor -import mindspore as ms -import numpy as np -from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.parameter import Parameter -from tests.dataset_mock import MindData -from mindspore import context -from tests.ut.python.ops.test_math_ops import VirtualLoss -from mindspore.common.api import _executor from mindspore.ops import composite as C -from mindspore.ops.operations.comm_ops import _VirtualDataset from mindspore.ops import functional as F -from mindspore.common.parameter import ParameterTuple -from mindspore.common import dtype as mstype +from mindspore.ops import operations as P +from mindspore.ops.operations.comm_ops import _VirtualDataset from mindspore.parallel import set_algo_parameters +from mindspore.train import Model, ParallelMode +from tests.dataset_mock import MindData +from tests.ut.python.ops.test_math_ops import VirtualLoss context.set_context(mode=context.GRAPH_MODE) context.reset_auto_parallel_context() diff --git a/tests/ut/python/parallel/test_reshape_parameter.py b/tests/ut/python/parallel/test_reshape_parameter.py index bfd35d9c0de..214b6cb50d3 100644 --- a/tests/ut/python/parallel/test_reshape_parameter.py +++ b/tests/ut/python/parallel/test_reshape_parameter.py @@ -12,15 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +import numpy as np + import mindspore as ms import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore.ops import composite as C 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 -import numpy as np class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_scalar_loss.py b/tests/ut/python/parallel/test_scalar_loss.py index 5aeac960b20..90fd966422d 100644 --- a/tests/ut/python/parallel/test_scalar_loss.py +++ b/tests/ut/python/parallel/test_scalar_loss.py @@ -13,15 +13,16 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 functional as F +from mindspore.ops import operations as P +from tests.ut.python.ops.test_math_ops import VirtualLoss class GradWrap(nn.Cell): diff --git a/tests/ut/python/parallel/test_semi_auto_two_subgraphs.py b/tests/ut/python/parallel/test_semi_auto_two_subgraphs.py index b58fe78604b..b25d86a6e47 100644 --- a/tests/ut/python/parallel/test_semi_auto_two_subgraphs.py +++ b/tests/ut/python/parallel/test_semi_auto_two_subgraphs.py @@ -12,15 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License +import numpy as np + import mindspore as ms from mindspore import Tensor, Parameter, ParameterTuple, context from mindspore import nn from mindspore.common.api import _executor from mindspore.nn.optim import Adam, FTRL -from mindspore.ops import operations as P from mindspore.ops import composite as C from mindspore.ops import functional as F -import numpy as np +from mindspore.ops import operations as P class Net(nn.Cell): diff --git a/tests/ut/python/parallel/test_set_auto_parallel_context.py b/tests/ut/python/parallel/test_set_auto_parallel_context.py index 1ad717b8807..9df9833b166 100644 --- a/tests/ut/python/parallel/test_set_auto_parallel_context.py +++ b/tests/ut/python/parallel/test_set_auto_parallel_context.py @@ -13,9 +13,10 @@ # limitations under the License. import pytest -from mindspore.parallel._auto_parallel_context import auto_parallel_context + from mindspore import context from mindspore.parallel import set_algo_parameters +from mindspore.parallel._auto_parallel_context import auto_parallel_context def test_set_auto_parallel_context(): diff --git a/tests/ut/python/parallel/test_sigmoid_cross_entropy_with_logits.py b/tests/ut/python/parallel/test_sigmoid_cross_entropy_with_logits.py index f51958370f8..c905950df2a 100644 --- a/tests/ut/python/parallel/test_sigmoid_cross_entropy_with_logits.py +++ b/tests/ut/python/parallel/test_sigmoid_cross_entropy_with_logits.py @@ -13,11 +13,12 @@ # limitations under the License. import numpy as np + import mindspore as ms from mindspore import context, Tensor, Parameter +from mindspore.common.api import _executor from mindspore.nn import Cell, TrainOneStepCell, Momentum from mindspore.ops import operations as P -from mindspore.common.api import _executor class Net(Cell): diff --git a/tests/ut/python/parallel/test_softmax_cross_entropy_expand.py b/tests/ut/python/parallel/test_softmax_cross_entropy_expand.py index 395018abd6c..4116a92cee6 100644 --- a/tests/ut/python/parallel/test_softmax_cross_entropy_expand.py +++ b/tests/ut/python/parallel/test_softmax_cross_entropy_expand.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mindspore.nn.loss.loss import SoftmaxCrossEntropyExpand +import numpy as np + from mindspore import Tensor +from mindspore import context from mindspore.common import dtype as mstype from mindspore.common.api import _executor -from mindspore import context -import numpy as np +from mindspore.nn.loss.loss import SoftmaxCrossEntropyExpand def test_SoftmaxCrossEntropy(): diff --git a/tests/ut/python/parallel/test_softmax_cross_entropy_loss.py b/tests/ut/python/parallel/test_softmax_cross_entropy_loss.py index cf80a1fef12..d6c20729185 100644 --- a/tests/ut/python/parallel/test_softmax_cross_entropy_loss.py +++ b/tests/ut/python/parallel/test_softmax_cross_entropy_loss.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_split_grad_sens.py b/tests/ut/python/parallel/test_split_grad_sens.py index 2bdd74bca37..47e95dc4549 100644 --- a/tests/ut/python/parallel/test_split_grad_sens.py +++ b/tests/ut/python/parallel/test_split_grad_sens.py @@ -13,15 +13,16 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + import mindspore as ms +import mindspore.common.dtype as mstype +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 -import mindspore.common.dtype as mstype +from mindspore.ops import operations as P +from tests.ut.python.ops.test_math_ops import VirtualLoss class GradWrap(nn.Cell): diff --git a/tests/ut/python/parallel/test_square.py b/tests/ut/python/parallel/test_square.py index 49dd5343563..fff9f1770d6 100644 --- a/tests/ut/python/parallel/test_square.py +++ b/tests/ut/python/parallel/test_square.py @@ -13,11 +13,12 @@ # limitations under the License. import numpy as np + import mindspore as ms from mindspore import context, Tensor, Parameter +from mindspore.common.api import _executor from mindspore.nn import Cell, TrainOneStepCell, Momentum from mindspore.ops import operations as P -from mindspore.common.api import _executor class Net(Cell): diff --git a/tests/ut/python/parallel/test_squeeze_info.py b/tests/ut/python/parallel/test_squeeze_info.py index 8590f37619d..eba77db3e67 100644 --- a/tests/ut/python/parallel/test_squeeze_info.py +++ b/tests/ut/python/parallel/test_squeeze_info.py @@ -13,11 +13,12 @@ # limitations under the License. import numpy as np + import mindspore as ms from mindspore import context, Tensor, Parameter +from mindspore.common.api import _executor from mindspore.nn import Cell, TrainOneStepCell, Momentum from mindspore.ops import operations as P -from mindspore.common.api import _executor class Net(Cell): diff --git a/tests/ut/python/parallel/test_step_parallel.py b/tests/ut/python/parallel/test_step_parallel.py index 4f65e8e9d62..5a8cc978b9d 100644 --- a/tests/ut/python/parallel/test_step_parallel.py +++ b/tests/ut/python/parallel/test_step_parallel.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np + import mindspore as ms -from mindspore import context import mindspore.nn as nn -from mindspore.ops import operations as P from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss +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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_strategy_checkpoint.py b/tests/ut/python/parallel/test_strategy_checkpoint.py index 1aabb7736cc..7dc856a4a30 100644 --- a/tests/ut/python/parallel/test_strategy_checkpoint.py +++ b/tests/ut/python/parallel/test_strategy_checkpoint.py @@ -13,15 +13,16 @@ # limitations under the License. import numpy as np -from mindspore import context -from mindspore.context import set_auto_parallel_context, reset_auto_parallel_context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor, Parameter -from tests.ut.python.ops.test_math_ops import VirtualLoss + import mindspore as ms +import mindspore.nn as nn +from mindspore import Tensor, Parameter +from mindspore import context from mindspore.common.api import _executor +from mindspore.context import set_auto_parallel_context, reset_auto_parallel_context from mindspore.ops import composite as C +from mindspore.ops import operations as P +from tests.ut.python.ops.test_math_ops import VirtualLoss # model_parallel test diff --git a/tests/ut/python/parallel/test_sum_as_loss.py b/tests/ut/python/parallel/test_sum_as_loss.py index 9a498497d26..336783f5760 100644 --- a/tests/ut/python/parallel/test_sum_as_loss.py +++ b/tests/ut/python/parallel/test_sum_as_loss.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class GradWrap(nn.Cell): diff --git a/tests/ut/python/parallel/test_transpose.py b/tests/ut/python/parallel/test_transpose.py index 8865a72a50e..f712416323e 100644 --- a/tests/ut/python/parallel/test_transpose.py +++ b/tests/ut/python/parallel/test_transpose.py @@ -12,17 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -from mindspore.train import Model, ParallelMode +import numpy as np + +import mindspore as ms +import mindspore.nn as nn +from mindspore import Tensor, context +from mindspore import context +from mindspore.common.parameter import Parameter from mindspore.nn.loss import SoftmaxCrossEntropyWithLogits from mindspore.nn.optim.momentum import Momentum -from mindspore import Tensor, context -import mindspore as ms -import numpy as np from mindspore.ops import operations as P -import mindspore.nn as nn -from mindspore.common.parameter import Parameter +from mindspore.train import Model, ParallelMode from tests.dataset_mock import MindData -from mindspore import context class Dataset(MindData): diff --git a/tests/ut/python/parallel/test_two_matmul.py b/tests/ut/python/parallel/test_two_matmul.py index 89256815888..6e8b2085b67 100644 --- a/tests/ut/python/parallel/test_two_matmul.py +++ b/tests/ut/python/parallel/test_two_matmul.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + 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 class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_two_weights_parameter.py b/tests/ut/python/parallel/test_two_weights_parameter.py index e7005f654d5..b010049b144 100644 --- a/tests/ut/python/parallel/test_two_weights_parameter.py +++ b/tests/ut/python/parallel/test_two_weights_parameter.py @@ -13,14 +13,15 @@ # limitations under the License. import numpy as np -from mindspore import context -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor, Parameter, ParameterTuple + import mindspore as ms +import mindspore.nn as nn +from mindspore import Tensor, Parameter, ParameterTuple +from mindspore import context from mindspore.common.api import _executor from mindspore.ops import composite as C from mindspore.ops import functional as F +from mindspore.ops import operations as P class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/parallel/test_using_seed_for_initializer.py b/tests/ut/python/parallel/test_using_seed_for_initializer.py index 0efea48cc98..9e601efccdd 100644 --- a/tests/ut/python/parallel/test_using_seed_for_initializer.py +++ b/tests/ut/python/parallel/test_using_seed_for_initializer.py @@ -13,10 +13,11 @@ # limitations under the License. import numpy as np +from numpy import allclose + +import mindspore.common.initializer as init import mindspore.nn as nn from mindspore import Parameter -import mindspore.common.initializer as init -from numpy import allclose parameter_shape = [16, 4] diff --git a/tests/ut/python/parallel/test_virtual_dataset_3_input.py b/tests/ut/python/parallel/test_virtual_dataset_3_input.py index 583dca7db33..95aec05d32b 100644 --- a/tests/ut/python/parallel/test_virtual_dataset_3_input.py +++ b/tests/ut/python/parallel/test_virtual_dataset_3_input.py @@ -13,16 +13,17 @@ # limitations under the License. import numpy as np -import mindspore.nn as nn -from mindspore.ops import operations as P -from mindspore import Tensor -from tests.ut.python.ops.test_math_ops import VirtualLoss + import mindspore as ms -from mindspore.common.api import _executor -from mindspore.ops import composite as C -from mindspore.ops.operations.comm_ops import _VirtualDataset -from mindspore.nn.wrap.cell_wrapper import VirtualDatasetCellTriple +import mindspore.nn as nn +from mindspore import Tensor from mindspore import context +from mindspore.common.api import _executor +from mindspore.nn.wrap.cell_wrapper import VirtualDatasetCellTriple +from mindspore.ops import composite as C +from mindspore.ops import operations as P +from mindspore.ops.operations.comm_ops import _VirtualDataset +from tests.ut.python.ops.test_math_ops import VirtualLoss class NetWithLoss(nn.Cell): diff --git a/tests/ut/python/pipeline/infer/infer.py b/tests/ut/python/pipeline/infer/infer.py index b2fe0a80425..5bd9ea8161c 100644 --- a/tests/ut/python/pipeline/infer/infer.py +++ b/tests/ut/python/pipeline/infer/infer.py @@ -13,11 +13,10 @@ # limitations under the License. # ============================================================================ """ infer """ -from argparse import ArgumentParser import numpy as np +from argparse import ArgumentParser from mindspore import Tensor - from ....dataset_mock import MindData __factory = { diff --git a/tests/ut/python/pipeline/infer/test_hypermap_specialize.py b/tests/ut/python/pipeline/infer/test_hypermap_specialize.py index 287cc214dc6..f2363884371 100644 --- a/tests/ut/python/pipeline/infer/test_hypermap_specialize.py +++ b/tests/ut/python/pipeline/infer/test_hypermap_specialize.py @@ -15,13 +15,13 @@ """ test_hypermap_partial """ import numpy as np +import mindspore.common.dtype as mstype import mindspore.nn as nn from mindspore import Tensor, context -import mindspore.common.dtype as mstype -from mindspore.ops import composite as C -from mindspore.ops import operations as P -from mindspore.ops import functional as F from mindspore.common.api import ms_function +from mindspore.ops import composite as C +from mindspore.ops import functional as F +from mindspore.ops import operations as P context.set_context(mode=context.GRAPH_MODE) diff --git a/tests/ut/python/pipeline/infer/test_range.py b/tests/ut/python/pipeline/infer/test_range.py index 646740e902b..df41648c00c 100644 --- a/tests/ut/python/pipeline/infer/test_range.py +++ b/tests/ut/python/pipeline/infer/test_range.py @@ -13,6 +13,7 @@ # limitations under the License. # ============================================================================ 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/infer/test_scalar_add_grad.py b/tests/ut/python/pipeline/infer/test_scalar_add_grad.py index 3e030573f6b..027cfdb779e 100644 --- a/tests/ut/python/pipeline/infer/test_scalar_add_grad.py +++ b/tests/ut/python/pipeline/infer/test_scalar_add_grad.py @@ -14,11 +14,12 @@ # ============================================================================ """ test_scalar_add_grad """ import numpy as np -from mindspore.nn import Cell -from mindspore.common.tensor import Tensor -from mindspore.ops import composite as C + from mindspore import context +from mindspore.common.tensor import Tensor +from mindspore.nn import Cell from mindspore.nn import ReLU +from mindspore.ops import composite as C from mindspore.ops.operations import TensorAdd context.set_context(mode=context.GRAPH_MODE) diff --git a/tests/ut/python/pipeline/parse/test_celllist.py b/tests/ut/python/pipeline/parse/test_celllist.py index d2d866c7b0f..c3f435c6968 100644 --- a/tests/ut/python/pipeline/parse/test_celllist.py +++ b/tests/ut/python/pipeline/parse/test_celllist.py @@ -14,13 +14,14 @@ # ============================================================================ """ test_celllist """ import numpy as np -from mindspore.nn import Cell -from mindspore.nn import ReLU -from mindspore.nn import Flatten + from mindspore import Tensor, Model -from mindspore.nn import SequentialCell -from mindspore.nn import AvgPool2d from mindspore import context +from mindspore.nn import AvgPool2d +from mindspore.nn import Cell +from mindspore.nn import Flatten +from mindspore.nn import ReLU +from mindspore.nn import SequentialCell from ...ut_filter import non_graph_engine diff --git a/tests/ut/python/pipeline/parse/test_cont_break.py b/tests/ut/python/pipeline/parse/test_cont_break.py index 23e468acacf..422d93cfd2d 100644 --- a/tests/ut/python/pipeline/parse/test_cont_break.py +++ b/tests/ut/python/pipeline/parse/test_cont_break.py @@ -14,8 +14,9 @@ # ============================================================================ """ test_cont_break """ import numpy as np -from mindspore.nn import Cell + from mindspore import Tensor, Model, context +from mindspore.nn import Cell from ...ut_filter import non_graph_engine diff --git a/tests/ut/python/pipeline/parse/test_create_obj.py b/tests/ut/python/pipeline/parse/test_create_obj.py index 0807c601e9f..11e78076945 100644 --- a/tests/ut/python/pipeline/parse/test_create_obj.py +++ b/tests/ut/python/pipeline/parse/test_create_obj.py @@ -23,11 +23,12 @@ """ import logging import numpy as np + import mindspore.nn as nn from mindspore import context -from mindspore.ops import operations as P from mindspore.common.api import ms_function from mindspore.common.tensor import Tensor +from mindspore.ops import operations as P from ...ut_filter import non_graph_engine log = logging.getLogger("test") diff --git a/tests/ut/python/pipeline/parse/test_dtype.py b/tests/ut/python/pipeline/parse/test_dtype.py index 2f031111894..70ee3e5a03a 100644 --- a/tests/ut/python/pipeline/parse/test_dtype.py +++ b/tests/ut/python/pipeline/parse/test_dtype.py @@ -14,6 +14,7 @@ # ============================================================================ """ test_dtype """ from mindspore._c_expression import typing + from mindspore.common.api import ms_function number = typing.Number() diff --git a/tests/ut/python/pipeline/parse/test_fix_bug.py b/tests/ut/python/pipeline/parse/test_fix_bug.py index 8d256bda588..5bf7db3798e 100644 --- a/tests/ut/python/pipeline/parse/test_fix_bug.py +++ b/tests/ut/python/pipeline/parse/test_fix_bug.py @@ -15,6 +15,7 @@ """ test_fix_bug """ import numpy as np import pytest + import mindspore.nn as nn from mindspore import Tensor from mindspore.common.api import _executor diff --git a/tests/ut/python/pipeline/parse/test_for_stmt.py b/tests/ut/python/pipeline/parse/test_for_stmt.py index f6cce1969d4..995d4fc88bd 100644 --- a/tests/ut/python/pipeline/parse/test_for_stmt.py +++ b/tests/ut/python/pipeline/parse/test_for_stmt.py @@ -13,11 +13,12 @@ # limitations under the License. # ============================================================================ """ test_for_stmt """ -from dataclasses import dataclass import numpy as np -from mindspore.nn import ReLU -from mindspore.nn import Cell +from dataclasses import dataclass + from mindspore import Tensor, Model, context +from mindspore.nn import Cell +from mindspore.nn import ReLU from ...ut_filter import non_graph_engine 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 befb3ee5a48..3d89d72d238 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 @@ -15,9 +15,10 @@ """ test_return_const_or_parameter """ import numpy as np + +import mindspore.common.dtype as mstype import mindspore.nn as nn from mindspore import context -import mindspore.common.dtype as mstype from mindspore.common.tensor import Tensor context.set_context(mode=context.GRAPH_MODE) diff --git a/tests/ut/python/pipeline/parse/test_list.py b/tests/ut/python/pipeline/parse/test_list.py index c8456ff131a..f86c844e087 100644 --- a/tests/ut/python/pipeline/parse/test_list.py +++ b/tests/ut/python/pipeline/parse/test_list.py @@ -14,10 +14,11 @@ # ============================================================================ """ test_list """ import numpy as np + import mindspore.nn as nn -from mindspore.nn import Cell from mindspore import Tensor from mindspore.common.api import _executor +from mindspore.nn import Cell class Net1(Cell): diff --git a/tests/ut/python/pipeline/parse/test_operator.py b/tests/ut/python/pipeline/parse/test_operator.py index 8dab3296f36..aa1a76f347f 100644 --- a/tests/ut/python/pipeline/parse/test_operator.py +++ b/tests/ut/python/pipeline/parse/test_operator.py @@ -14,10 +14,11 @@ # ============================================================================ """ test_operator """ import numpy as np -from mindspore.ops import operations as P -from mindspore.nn import ReLU -from mindspore.nn import Cell + from mindspore import Tensor, Model, context +from mindspore.nn import Cell +from mindspore.nn import ReLU +from mindspore.ops import operations as P from ...ut_filter import non_graph_engine diff --git a/tests/ut/python/pipeline/parse/test_serialize.py b/tests/ut/python/pipeline/parse/test_serialize.py index db76b4e9346..0e3e9df42a3 100644 --- a/tests/ut/python/pipeline/parse/test_serialize.py +++ b/tests/ut/python/pipeline/parse/test_serialize.py @@ -18,6 +18,7 @@ @Desc : """ import os + from mindspore._extends.parse import dump_obj from mindspore._extends.parse import load_obj diff --git a/tests/ut/python/predict/test_predict_save_model.py b/tests/ut/python/predict/test_predict_save_model.py index 63b71e9a1ff..20744eaf5ac 100644 --- a/tests/ut/python/predict/test_predict_save_model.py +++ b/tests/ut/python/predict/test_predict_save_model.py @@ -19,12 +19,13 @@ Usage: python test_predict_save_model.py --path ./ """ -import os import argparse import numpy as np +import os + +import mindspore.context as context import mindspore.nn as nn import mindspore.ops.operations as P -import mindspore.context as context from mindspore.common.tensor import Tensor from mindspore.train.serialization import export, load_checkpoint, load_param_into_net diff --git a/tests/ut/python/pynative_mode/engine/test_cell_wrapper.py b/tests/ut/python/pynative_mode/engine/test_cell_wrapper.py index c1f43f3e7fa..5cec1f09752 100644 --- a/tests/ut/python/pynative_mode/engine/test_cell_wrapper.py +++ b/tests/ut/python/pynative_mode/engine/test_cell_wrapper.py @@ -14,11 +14,12 @@ # ============================================================================ """ test_cell_wrapper """ import numpy as np + import mindspore.nn as nn -from mindspore import Parameter, Tensor -from mindspore.nn import WithLossCell import mindspore.ops.operations as P +from mindspore import Parameter, Tensor from mindspore.nn import SoftmaxCrossEntropyWithLogits +from mindspore.nn import WithLossCell from ...ut_filter import non_graph_engine diff --git a/tests/ut/python/pynative_mode/ge/model/test_lenet_model.py b/tests/ut/python/pynative_mode/ge/model/test_lenet_model.py index a34241d7910..f684a175c83 100644 --- a/tests/ut/python/pynative_mode/ge/model/test_lenet_model.py +++ b/tests/ut/python/pynative_mode/ge/model/test_lenet_model.py @@ -17,9 +17,9 @@ import numpy as np import mindspore.nn as nn from mindspore.common.tensor import Tensor -from mindspore.ops import operations as P -from mindspore.nn.optim import Momentum from mindspore.nn import WithGradCell, WithLossCell +from mindspore.nn.optim import Momentum +from mindspore.ops import operations as P from ....ut_filter import non_graph_engine diff --git a/tests/ut/python/pynative_mode/ge/ops/test_dense.py b/tests/ut/python/pynative_mode/ge/ops/test_dense.py index 102d44ae48f..650c4f40928 100644 --- a/tests/ut/python/pynative_mode/ge/ops/test_dense.py +++ b/tests/ut/python/pynative_mode/ge/ops/test_dense.py @@ -14,6 +14,7 @@ # ============================================================================ """ test_dense """ import numpy as np + from mindspore import Tensor from mindspore.nn import Dense from ....ut_filter import non_graph_engine diff --git a/tests/ut/python/pynative_mode/nn/test_cell.py b/tests/ut/python/pynative_mode/nn/test_cell.py index 3894c9c60e6..68bda4f1e5f 100644 --- a/tests/ut/python/pynative_mode/nn/test_cell.py +++ b/tests/ut/python/pynative_mode/nn/test_cell.py @@ -15,6 +15,7 @@ """ test_cell """ import numpy as np import pytest + import mindspore.nn as nn from mindspore import Tensor, Parameter from ...ut_filter import non_graph_engine diff --git a/tests/ut/python/pynative_mode/nn/test_container.py b/tests/ut/python/pynative_mode/nn/test_container.py index 8b2e537b5c7..175389c3bb5 100644 --- a/tests/ut/python/pynative_mode/nn/test_container.py +++ b/tests/ut/python/pynative_mode/nn/test_container.py @@ -13,9 +13,9 @@ # limitations under the License. # ============================================================================ """ test_container """ -from collections import OrderedDict import numpy as np import pytest +from collections import OrderedDict import mindspore.nn as nn from mindspore import Tensor diff --git a/tests/ut/python/pynative_mode/nn/test_dropout.py b/tests/ut/python/pynative_mode/nn/test_dropout.py index 39ccdc75e26..4c5d3957fa6 100644 --- a/tests/ut/python/pynative_mode/nn/test_dropout.py +++ b/tests/ut/python/pynative_mode/nn/test_dropout.py @@ -14,11 +14,12 @@ # ============================================================================ """ test_dropout """ import numpy as np -from mindspore.common.api import _executor + import mindspore.nn as nn from mindspore import Tensor -from mindspore import dtype as mstype from mindspore import context +from mindspore import dtype as mstype +from mindspore.common.api import _executor context.set_context(device_target="Ascend") diff --git a/tests/ut/python/pynative_mode/ops/test_grad.py b/tests/ut/python/pynative_mode/ops/test_grad.py index b4c87389c49..c2e14129ea6 100644 --- a/tests/ut/python/pynative_mode/ops/test_grad.py +++ b/tests/ut/python/pynative_mode/ops/test_grad.py @@ -14,14 +14,15 @@ # ============================================================================ """ test_grad """ import numpy as np + import mindspore as ms -from mindspore.common.api import ms_function -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.ops.operations as P +from mindspore import Tensor +from mindspore.common.api import ms_function +from mindspore.common.dtype import get_py_obj_dtype +from mindspore.ops import composite as C from mindspore.ops import functional as F +from mindspore.ops.composite import grad_all_with_sens from ...ut_filter import non_graph_engine diff --git a/tests/ut/python/pynative_mode/ops/test_hypermap.py b/tests/ut/python/pynative_mode/ops/test_hypermap.py index 15f11fa7780..dc55ae5cbb3 100644 --- a/tests/ut/python/pynative_mode/ops/test_hypermap.py +++ b/tests/ut/python/pynative_mode/ops/test_hypermap.py @@ -15,12 +15,12 @@ """ test_hypermap """ import numpy as np -from mindspore.common.api import ms_function from mindspore import Tensor +from mindspore.common.api import ms_function from mindspore.ops import Primitive from mindspore.ops import composite as C -from mindspore.ops import operations as P from mindspore.ops import functional as F +from mindspore.ops import operations as P from ...ut_filter import non_graph_engine # pylint: disable=W0613 diff --git a/tests/ut/python/pynative_mode/ops/test_multitype.py b/tests/ut/python/pynative_mode/ops/test_multitype.py index 106d0a6f616..4ceff1d4ac3 100644 --- a/tests/ut/python/pynative_mode/ops/test_multitype.py +++ b/tests/ut/python/pynative_mode/ops/test_multitype.py @@ -15,12 +15,12 @@ """ test_multitype """ import numpy as np +from mindspore import Tensor from mindspore.common.api import ms_function from mindspore.common.parameter import Parameter from mindspore.ops import Primitive from mindspore.ops import composite as C from mindspore.ops import operations as P -from mindspore import Tensor from ...ut_filter import non_graph_engine tensor_add = P.TensorAdd() diff --git a/tests/ut/python/pynative_mode/test_backend.py b/tests/ut/python/pynative_mode/test_backend.py index fae19748543..be9343ed937 100644 --- a/tests/ut/python/pynative_mode/test_backend.py +++ b/tests/ut/python/pynative_mode/test_backend.py @@ -15,12 +15,13 @@ """ test_backend """ import os import pytest -from mindspore.ops import operations as P + import mindspore.nn as nn from mindspore import context, ms_function +from mindspore._checkparam import args_type_check from mindspore.common.initializer import initializer from mindspore.common.parameter import Parameter -from mindspore._checkparam import args_type_check +from mindspore.ops import operations as P def setup_module(module): diff --git a/tests/ut/python/pynative_mode/test_bprop.py b/tests/ut/python/pynative_mode/test_bprop.py index 2cba70334d1..bbf6a270c0d 100644 --- a/tests/ut/python/pynative_mode/test_bprop.py +++ b/tests/ut/python/pynative_mode/test_bprop.py @@ -14,12 +14,13 @@ # ============================================================================ """ test_bprop """ import numpy as np + import mindspore.nn as nn from mindspore import context -from mindspore.ops import operations as P -from mindspore.common.parameter import Parameter from mindspore.common import Tensor from mindspore.common.api import ms_function +from mindspore.common.parameter import Parameter +from mindspore.ops import operations as P from ....mindspore_test_framework.utils.bprop_util import bprop diff --git a/tests/ut/python/pynative_mode/test_cell_bprop.py b/tests/ut/python/pynative_mode/test_cell_bprop.py index 15a1d0b1eb6..041ae9ef047 100644 --- a/tests/ut/python/pynative_mode/test_cell_bprop.py +++ b/tests/ut/python/pynative_mode/test_cell_bprop.py @@ -14,18 +14,18 @@ # ============================================================================ """ test_cell_bprop """ import numpy as np +import pytest + +import mindspore.common.dtype as mstype import mindspore.nn as nn +from mindspore import Parameter +from mindspore import context +from mindspore.common.initializer import initializer +from mindspore.common.tensor import Tensor from mindspore.ops import composite as C from mindspore.ops import operations as P -from mindspore import Parameter -from mindspore.common.tensor import Tensor -import mindspore.common.dtype as mstype -from mindspore.common.initializer import initializer -from mindspore import context from ....mindspore_test_framework.utils.bprop_util import bprop -import pytest - def setup_module(module): context.set_context(mode=context.PYNATIVE_MODE) diff --git a/tests/ut/python/pynative_mode/test_context.py b/tests/ut/python/pynative_mode/test_context.py index f02b017e849..66dc0a4f587 100644 --- a/tests/ut/python/pynative_mode/test_context.py +++ b/tests/ut/python/pynative_mode/test_context.py @@ -15,6 +15,7 @@ """ test_context """ import os import pytest + from mindspore import context diff --git a/tests/ut/python/pynative_mode/test_framstruct.py b/tests/ut/python/pynative_mode/test_framstruct.py index d2b8cc8e223..db7914a2927 100644 --- a/tests/ut/python/pynative_mode/test_framstruct.py +++ b/tests/ut/python/pynative_mode/test_framstruct.py @@ -13,21 +13,22 @@ # limitations under the License. # ============================================================================ """ test_framstruct """ -import pytest import numpy as np +import pytest + import mindspore.nn as nn from mindspore import context +from mindspore.common import dtype as mstype +from mindspore.common.parameter import Parameter, ParameterTuple +from mindspore.common.tensor import Tensor 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 import dtype as mstype +from mindspore.ops._grad.grad_base import bprop_getters +from mindspore.ops.primitive import prim_attr_register, PrimitiveWithInfer 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.ops._grad.grad_base import bprop_getters -from mindspore.ops.primitive import prim_attr_register, PrimitiveWithInfer def setup_module(module): diff --git a/tests/ut/python/pynative_mode/test_graph_return_const_param.py b/tests/ut/python/pynative_mode/test_graph_return_const_param.py index 6f8978dc6e9..67e55fff560 100644 --- a/tests/ut/python/pynative_mode/test_graph_return_const_param.py +++ b/tests/ut/python/pynative_mode/test_graph_return_const_param.py @@ -15,12 +15,13 @@ """ test_return_const_or_parameter """ import numpy as np + +import mindspore.common.dtype as mstype 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 +from mindspore.common.parameter import Parameter +from mindspore.common.tensor import Tensor def setup_module(module): diff --git a/tests/ut/python/pynative_mode/test_high_order_grad.py b/tests/ut/python/pynative_mode/test_high_order_grad.py index 3c26d0fa8b0..97fe7c3b68a 100644 --- a/tests/ut/python/pynative_mode/test_high_order_grad.py +++ b/tests/ut/python/pynative_mode/test_high_order_grad.py @@ -13,9 +13,9 @@ # limitations under the License. # ============================================================================ """ test_high_order_grad """ +from mindspore import context from mindspore.common.api import ms_function from mindspore.ops.composite import grad, grad_all, grad_all_with_sens -from mindspore import context def setup_module(module): diff --git a/tests/ut/python/pynative_mode/test_insert_grad_of.py b/tests/ut/python/pynative_mode/test_insert_grad_of.py index 48033eda0a8..558ede78344 100644 --- a/tests/ut/python/pynative_mode/test_insert_grad_of.py +++ b/tests/ut/python/pynative_mode/test_insert_grad_of.py @@ -14,17 +14,17 @@ # ============================================================================ """ test_insert_grad_of """ import numpy as np + +import mindspore import mindspore.nn as nn -from mindspore.ops import composite as C -from mindspore.ops import operations as P -from mindspore.ops import functional as F +from mindspore import Tensor +from mindspore import context from mindspore.common.api import ms_function +from mindspore.ops import composite as C +from mindspore.ops import functional as F +from mindspore.ops import operations as P from ....mindspore_test_framework.utils.bprop_util import bprop from ....mindspore_test_framework.utils.debug_util import PrintShapeTypeCell, PrintGradShapeTypeCell -from mindspore import Tensor - -from mindspore import context -import mindspore def setup_module(module): diff --git a/tests/ut/python/pynative_mode/test_multigraph_sink.py b/tests/ut/python/pynative_mode/test_multigraph_sink.py index 24530ee226a..e8ebe03797d 100644 --- a/tests/ut/python/pynative_mode/test_multigraph_sink.py +++ b/tests/ut/python/pynative_mode/test_multigraph_sink.py @@ -14,9 +14,9 @@ # ============================================================================ """ test_multigraph_sink """ import mindspore.context as context -from mindspore.common.tensor import Tensor from mindspore.common import dtype as mstype from mindspore.common import ms_function +from mindspore.common.tensor import Tensor def setup_module(module): diff --git a/tests/ut/python/pynative_mode/test_parse_method.py b/tests/ut/python/pynative_mode/test_parse_method.py index a4e6216c429..a4b2907cc96 100644 --- a/tests/ut/python/pynative_mode/test_parse_method.py +++ b/tests/ut/python/pynative_mode/test_parse_method.py @@ -20,16 +20,16 @@ """ import logging import numpy as np -import mindspore.nn as nn +import pytest from dataclasses import dataclass + +import mindspore.nn as nn +from mindspore import context +from mindspore._extends.parse.standard_method import ms_len from mindspore.common.api import ms_function from mindspore.common.tensor import Tensor from mindspore.ops.composite import core -from mindspore._extends.parse.standard_method import ms_len from ..ut_filter import non_graph_engine -import pytest - -from mindspore import context def setup_module(module): diff --git a/tests/ut/python/pynative_mode/test_partial.py b/tests/ut/python/pynative_mode/test_partial.py index d9ba6995f2f..776d9daa370 100644 --- a/tests/ut/python/pynative_mode/test_partial.py +++ b/tests/ut/python/pynative_mode/test_partial.py @@ -13,10 +13,10 @@ # limitations under the License. # ============================================================================ """ test_partial """ -from mindspore.common.api import ms_function -import mindspore.ops.functional as F import mindspore.ops.composite as C +import mindspore.ops.functional as F from mindspore import context +from mindspore.common.api import ms_function def setup_module(module): diff --git a/tests/ut/python/pynative_mode/test_pynative_model.py b/tests/ut/python/pynative_mode/test_pynative_model.py index 9b5cb9babc6..cd6bb43b7a3 100644 --- a/tests/ut/python/pynative_mode/test_pynative_model.py +++ b/tests/ut/python/pynative_mode/test_pynative_model.py @@ -17,11 +17,11 @@ import numpy as np import mindspore.nn as nn from mindspore import Parameter, ParameterTuple, Tensor +from mindspore import context +from mindspore.nn.optim import Momentum from mindspore.ops import composite as C from mindspore.ops import operations as P -from mindspore.nn.optim import Momentum from ..ut_filter import non_graph_engine -from mindspore import context def setup_module(module): diff --git a/tests/ut/python/pynative_mode/test_remove_unnecessary_phi.py b/tests/ut/python/pynative_mode/test_remove_unnecessary_phi.py index cf30a7a61aa..5cc2ce35cc5 100644 --- a/tests/ut/python/pynative_mode/test_remove_unnecessary_phi.py +++ b/tests/ut/python/pynative_mode/test_remove_unnecessary_phi.py @@ -16,10 +16,11 @@ # coding: utf-8 from numpy.random import normal + from mindspore import Tensor -from mindspore.ops.composite import core -from mindspore.common.api import ms_function from mindspore import context +from mindspore.common.api import ms_function +from mindspore.ops.composite import core def setup_module(module): diff --git a/tests/ut/python/pynative_mode/test_staging.py b/tests/ut/python/pynative_mode/test_staging.py index f7a9bb41517..7bf2fd47a42 100644 --- a/tests/ut/python/pynative_mode/test_staging.py +++ b/tests/ut/python/pynative_mode/test_staging.py @@ -15,17 +15,18 @@ """ test_staging """ import numpy as np import pytest + import mindspore as ms import mindspore.nn as nn -from mindspore.common.api import ms_function +from mindspore import Tensor +from mindspore import context from mindspore.common import MetaTensor from mindspore.common import dtype -from mindspore import Tensor -from mindspore.ops import operations as P -from mindspore.ops import functional as F +from mindspore.common.api import ms_function from mindspore.common.dtype import get_py_obj_dtype +from mindspore.ops import functional as F +from mindspore.ops import operations as P from ..ut_filter import non_graph_engine -from mindspore import context def setup_module(module): diff --git a/tests/ut/python/pynative_mode/test_stop_gradient.py b/tests/ut/python/pynative_mode/test_stop_gradient.py index 94a5cdac981..9690138fb95 100644 --- a/tests/ut/python/pynative_mode/test_stop_gradient.py +++ b/tests/ut/python/pynative_mode/test_stop_gradient.py @@ -13,22 +13,22 @@ # limitations under the License. # ============================================================================ """ test_stop_gradient """ -import pytest import numpy as np +import pytest -import mindspore.nn as nn -from mindspore import context import mindspore.common.dtype as mstype +import mindspore.nn as nn from mindspore import Parameter, ParameterTuple, Tensor +from mindspore import Tensor +from mindspore import context +from mindspore import context +from mindspore.common.api import ms_function from mindspore.ops import composite as C from mindspore.ops import operations as P from mindspore.ops.functional import stop_gradient from mindspore.ops.primitive import prim_attr_register, PrimitiveWithInfer from ..ut_filter import non_graph_engine from ....mindspore_test_framework.utils.bprop_util import bprop -from mindspore import Tensor -from mindspore.common.api import ms_function -from mindspore import context def setup_module(module): diff --git a/tests/ut/python/pynative_mode/test_training.py b/tests/ut/python/pynative_mode/test_training.py index 5b0aa936e00..032ae60f60a 100644 --- a/tests/ut/python/pynative_mode/test_training.py +++ b/tests/ut/python/pynative_mode/test_training.py @@ -16,13 +16,13 @@ import numpy as np import mindspore.nn as nn -from mindspore.common.tensor import Tensor -from mindspore.ops import operations as P -from mindspore.nn.optim import Momentum -from mindspore.train.model import Model -from mindspore.nn import WithGradCell, WithLossCell -from ..ut_filter import non_graph_engine from mindspore import context +from mindspore.common.tensor import Tensor +from mindspore.nn import WithGradCell, WithLossCell +from mindspore.nn.optim import Momentum +from mindspore.ops import operations as P +from mindspore.train.model import Model +from ..ut_filter import non_graph_engine def setup_module(module): diff --git a/tests/ut/python/pynative_mode/vm/test_vm.py b/tests/ut/python/pynative_mode/vm/test_vm.py index 10f7435a8cb..53197134ada 100644 --- a/tests/ut/python/pynative_mode/vm/test_vm.py +++ b/tests/ut/python/pynative_mode/vm/test_vm.py @@ -14,6 +14,7 @@ # ============================================================================ """ test_vm """ import numpy as np + from .....vm_impl import vm diff --git a/tests/ut/python/train/quant/mobilenetv2_combined.py b/tests/ut/python/train/quant/mobilenetv2_combined.py index e8161dcd949..86c9847a637 100644 --- a/tests/ut/python/train/quant/mobilenetv2_combined.py +++ b/tests/ut/python/train/quant/mobilenetv2_combined.py @@ -1,7 +1,7 @@ """mobile net v2""" from mindspore import nn -from mindspore.ops import operations as P from mindspore.nn.layer import combined +from mindspore.ops import operations as P def make_divisible(input_x, div_by=8): diff --git a/tests/ut/python/train/quant/test_quant.py b/tests/ut/python/train/quant/test_quant.py index d6409385193..e1acd0ccb82 100644 --- a/tests/ut/python/train/quant/test_quant.py +++ b/tests/ut/python/train/quant/test_quant.py @@ -14,14 +14,15 @@ # ============================================================================ """ tests for quant """ import numpy as np -from mindspore import Tensor -from mindspore.train.quant import quant as qat -from mindspore import nn -import mindspore.ops.operations as P -from mindspore.nn.layer import combined -import mindspore.context as context from mobilenetv2_combined import MobileNetV2 +import mindspore.context as context +import mindspore.ops.operations as P +from mindspore import Tensor +from mindspore import nn +from mindspore.nn.layer import combined +from mindspore.train.quant import quant as qat + context.set_context(mode=context.GRAPH_MODE) diff --git a/tests/ut/python/train/summary/summary_reader.py b/tests/ut/python/train/summary/summary_reader.py index 647c25f25c5..67653ff7a5a 100644 --- a/tests/ut/python/train/summary/summary_reader.py +++ b/tests/ut/python/train/summary/summary_reader.py @@ -13,9 +13,8 @@ # limitations under the License. # ============================================================================ """Summary reader.""" -import struct - import mindspore.train.summary_pb2 as summary_pb2 +import struct _HEADER_SIZE = 8 _HEADER_CRC_SIZE = 4 diff --git a/tests/ut/python/train/summary/test_graph_summary.py b/tests/ut/python/train/summary/test_graph_summary.py index 93da36af3dc..63ce4d3c74e 100644 --- a/tests/ut/python/train/summary/test_graph_summary.py +++ b/tests/ut/python/train/summary/test_graph_summary.py @@ -14,9 +14,8 @@ # ============================================================================ """ test_graph_summary """ import logging -import os - import numpy as np +import os import mindspore.nn as nn from mindspore import Model, context diff --git a/tests/ut/python/train/summary/test_histogram_summary.py b/tests/ut/python/train/summary/test_histogram_summary.py index 94298af5c59..47d463e2b32 100644 --- a/tests/ut/python/train/summary/test_histogram_summary.py +++ b/tests/ut/python/train/summary/test_histogram_summary.py @@ -15,11 +15,10 @@ """Test histogram summary.""" import logging +import numpy as np import os import tempfile -import numpy as np - from mindspore.common.tensor import Tensor from mindspore.train.summary._summary_adapter import _calc_histogram_bins from mindspore.train.summary.summary_record import SummaryRecord, _cache_summary_tensor_data diff --git a/tests/ut/python/train/summary/test_image_summary.py b/tests/ut/python/train/summary/test_image_summary.py index ee598d25a3a..dba4134020c 100644 --- a/tests/ut/python/train/summary/test_image_summary.py +++ b/tests/ut/python/train/summary/test_image_summary.py @@ -19,9 +19,8 @@ @Desc : test summary function """ import logging -import os - import numpy as np +import os import mindspore.nn as nn from mindspore import Model, context diff --git a/tests/ut/python/train/summary/test_summary.py b/tests/ut/python/train/summary/test_summary.py index 1b5e75ee26a..a9cfb3521ac 100644 --- a/tests/ut/python/train/summary/test_summary.py +++ b/tests/ut/python/train/summary/test_summary.py @@ -19,11 +19,10 @@ @Desc : test summary function """ import logging -import os -import random - import numpy as np +import os import pytest +import random import mindspore.nn as nn from mindspore.common.tensor import Tensor diff --git a/tests/ut/python/train/summary/test_summary_abnormal_input.py b/tests/ut/python/train/summary/test_summary_abnormal_input.py index 40c65e5f8ce..ad206c65d30 100644 --- a/tests/ut/python/train/summary/test_summary_abnormal_input.py +++ b/tests/ut/python/train/summary/test_summary_abnormal_input.py @@ -19,9 +19,8 @@ @Desc : test summary function of abnormal input """ import logging -import os - import numpy as np +import os from mindspore.common.tensor import Tensor from mindspore.train.summary.summary_record import SummaryRecord diff --git a/tests/ut/python/train/summary/test_summary_ops_params_valid_check.py b/tests/ut/python/train/summary/test_summary_ops_params_valid_check.py index 1374330c22d..56ea9e8d174 100644 --- a/tests/ut/python/train/summary/test_summary_ops_params_valid_check.py +++ b/tests/ut/python/train/summary/test_summary_ops_params_valid_check.py @@ -19,11 +19,10 @@ @Desc : test summary function of ops params valid check """ import logging -import os -import random - import numpy as np +import os import pytest +import random import mindspore.nn as nn from mindspore.common.tensor import Tensor diff --git a/tests/ut/python/train/summary/test_tensor_summary.py b/tests/ut/python/train/summary/test_tensor_summary.py index 49502410558..bb41951aa28 100644 --- a/tests/ut/python/train/summary/test_tensor_summary.py +++ b/tests/ut/python/train/summary/test_tensor_summary.py @@ -19,9 +19,8 @@ @Desc : test summary function """ import logging -import os - import numpy as np +import os import mindspore.nn as nn from mindspore.common.tensor import Tensor diff --git a/tests/ut/python/train/test_training.py b/tests/ut/python/train/test_training.py index 81bcd1b9d7b..b56a0868cad 100644 --- a/tests/ut/python/train/test_training.py +++ b/tests/ut/python/train/test_training.py @@ -14,7 +14,6 @@ # ============================================================================ """ test_training """ import logging - import numpy as np import pytest diff --git a/tests/ut/python/transform/test_transform.py b/tests/ut/python/transform/test_transform.py index 36f970cd390..e183a50ed0a 100644 --- a/tests/ut/python/transform/test_transform.py +++ b/tests/ut/python/transform/test_transform.py @@ -19,7 +19,6 @@ @Desc : test mindspore compile method """ import logging - import numpy as np import mindspore.nn as nn diff --git a/tests/ut/python/utils/test_callback.py b/tests/ut/python/utils/test_callback.py index f605185d7f6..04db64649a5 100644 --- a/tests/ut/python/utils/test_callback.py +++ b/tests/ut/python/utils/test_callback.py @@ -13,11 +13,10 @@ # limitations under the License. # ============================================================================ """test callback function.""" -import os -import stat - import numpy as np +import os import pytest +import stat import mindspore.common.dtype as mstype import mindspore.nn as nn diff --git a/tests/ut/python/utils/test_initializer.py b/tests/ut/python/utils/test_initializer.py index e44d0f25d6f..15d8838a460 100644 --- a/tests/ut/python/utils/test_initializer.py +++ b/tests/ut/python/utils/test_initializer.py @@ -14,20 +14,19 @@ # ============================================================================ """ test_initializer """ import math -from functools import reduce - import numpy as np import pytest as py +from functools import reduce from scipy import stats import mindspore as ms import mindspore.common.initializer as init import mindspore.nn as nn -from mindspore.common.tensor import Tensor -from mindspore.common.parameter import Parameter -from mindspore.ops import operations as P from mindspore import context +from mindspore.common.parameter import Parameter +from mindspore.common.tensor import Tensor from mindspore.nn import Conv2d +from mindspore.ops import operations as P from ..ut_filter import non_graph_engine diff --git a/tests/ut/python/utils/test_serialize.py b/tests/ut/python/utils/test_serialize.py index 637161582a6..5c0eb6f8dd9 100644 --- a/tests/ut/python/utils/test_serialize.py +++ b/tests/ut/python/utils/test_serialize.py @@ -13,13 +13,12 @@ # limitations under the License. # ============================================================================ """ut for model serialize(save/load)""" +import numpy as np import os +import pytest import stat import time -import numpy as np -import pytest - import mindspore.common.dtype as mstype import mindspore.nn as nn from mindspore import context diff --git a/tests/vm_impl/math_ops_vm_impl.py b/tests/vm_impl/math_ops_vm_impl.py index d674faed74f..166b63a6df7 100644 --- a/tests/vm_impl/math_ops_vm_impl.py +++ b/tests/vm_impl/math_ops_vm_impl.py @@ -14,7 +14,6 @@ # ============================================================================ """Generate vm_impl function for math ops""" import copy - import numpy as np from mindspore.common.dtype import dtype_to_nptype