未验证 提交 a559a664 编写于 作者: N Nyakku Shigure 提交者: GitHub

[CodeStyle][isort] introduce isort (part3) (#48401)

上级 d86aa4ca
......@@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from transformer_dygraph_model import MultiHeadAttention, PrePostProcessLayer
import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph import Embedding, Layer, Linear
from paddle.jit.api import declarative
from transformer_dygraph_model import MultiHeadAttention, PrePostProcessLayer
class PositionwiseFeedForwardLayer(Layer):
def __init__(
......
......@@ -14,11 +14,10 @@
import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph.nn import BatchNorm
from paddle.fluid.param_attr import ParamAttr
from paddle.fluid.regularizer import L2Decay
from paddle.fluid.dygraph.nn import BatchNorm
class ConvBNLayer(fluid.dygraph.Layer):
def __init__(
......
......@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import paddle
from functools import wraps
import paddle
def deco1(fun):
@wraps(fun)
......
......@@ -15,10 +15,9 @@
import os
import numpy as np
import paddle.fluid as fluid
from paddle.fluid.core import AnalysisConfig
from paddle.fluid.core import create_paddle_predictor
import paddle.fluid as fluid
from paddle.fluid.core import AnalysisConfig, create_paddle_predictor
class PredictorTools:
......
......@@ -14,15 +14,15 @@
# limitations under the License.
import numpy as np
from seq2seq_utils import Seq2SeqModelHyperParams as args
import paddle
import paddle.fluid as fluid
from paddle.fluid import ParamAttr
from paddle.fluid import layers
from paddle.fluid import ParamAttr, layers
from paddle.fluid.dygraph import Layer
from paddle.fluid.dygraph.base import to_variable
from paddle.jit.api import declarative
from paddle.fluid.dygraph.nn import Embedding
from seq2seq_utils import Seq2SeqModelHyperParams as args
from paddle.jit.api import declarative
INF = 1.0 * 1e5
alpha = 0.6
......
......@@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from functools import reduce
import paddle
import paddle.fluid as fluid
import paddle.fluid.param_attr as attr
from functools import reduce
from paddle.jit.api import declarative
from paddle.fluid.dygraph import Embedding, Layer, Linear
from paddle.jit.api import declarative
from paddle.static import Variable
......
......@@ -13,6 +13,7 @@
# limitations under the License.
from functools import reduce
import paddle
from paddle.static import Variable
......
......@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy
import unittest
import numpy
import paddle
import paddle.fluid as fluid
from paddle.jit import ProgramTranslator
......
......@@ -12,21 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import textwrap
from paddle.utils import gast
import inspect
import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph.dygraph_to_static.utils import ast_to_func
import textwrap
import unittest
import numpy as np
from ifelse_simple_func import (
dyfunc_with_if_else,
dyfunc_with_if_else2,
nested_if_else,
)
import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph.dygraph_to_static.utils import ast_to_func
from paddle.utils import gast
class TestAST2Func(unittest.TestCase):
"""
......
......@@ -12,19 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import unittest
import inspect
from paddle.utils import gast
import unittest
import numpy as np
import paddle
import paddle.fluid as fluid
import paddle.fluid.dygraph as dygraph
from paddle import to_tensor
from paddle.fluid.dygraph import to_variable
from paddle.jit.api import dygraph_to_static_func
from paddle.fluid.dygraph.dygraph_to_static.utils import is_dygraph_api
from paddle.jit.api import dygraph_to_static_func
from paddle.utils import gast
SEED = 2020
np.random.seed(SEED)
......
......@@ -13,20 +13,19 @@
# limitations under the License.
import os
import time
import tempfile
import time
import unittest
import numpy as np
from bert_dygraph_model import PretrainModelLayer
from bert_utils import get_bert_config, get_feed_data_reader
from predictor_utils import PredictorTools
import paddle
import paddle.fluid as fluid
from paddle.jit import ProgramTranslator
from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX
from bert_dygraph_model import PretrainModelLayer
from bert_utils import get_bert_config, get_feed_data_reader
from predictor_utils import PredictorTools
from paddle.jit import ProgramTranslator
program_translator = ProgramTranslator()
place = (
......
......@@ -12,20 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import math
import numpy as np
import os
import tempfile
import unittest
import numpy as np
from predictor_utils import PredictorTools
import paddle
import tempfile
from paddle.jit import to_static
import paddle.fluid as fluid
from paddle.fluid import ParamAttr
from paddle.fluid.dygraph import to_variable
from paddle.jit import ProgramTranslator
from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX
from predictor_utils import PredictorTools
from paddle.jit import ProgramTranslator, to_static
SEED = 2000
DATATYPE = 'float32'
......
......@@ -13,14 +13,14 @@
# limitations under the License.
import unittest
import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.jit.api import declarative
from paddle.jit.dy2static.program_translator import (
ProgramTranslator,
)
from paddle.fluid.dygraph.dygraph_to_static.utils import Dygraph2StaticException
from paddle.jit.api import declarative
from paddle.jit.dy2static.program_translator import ProgramTranslator
SEED = 2020
np.random.seed(SEED)
......
......@@ -12,13 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import paddle
import unittest
import numpy as np
from paddle.jit import ProgramTranslator
import numpy as np
from test_resnet import ResNetHelper
import paddle
from paddle.jit import ProgramTranslator
program_translator = ProgramTranslator()
......
......@@ -13,17 +13,17 @@
# limitations under the License.
import unittest
import numpy as np
from collections import Counter
import numpy as np
from test_fetch_feed import Linear, Pool2D
import paddle
import paddle.fluid as fluid
from paddle.jit.api import declarative
from paddle.jit import ProgramTranslator
from paddle.jit.api import declarative
from paddle.jit.dy2static import convert_to_static
from test_fetch_feed import Pool2D, Linear
class TestCacheProgram(unittest.TestCase):
def setUp(self):
......
......@@ -13,7 +13,9 @@
# limitations under the License.
import unittest
import numpy as np
import paddle.fluid as fluid
from paddle.jit.api import declarative
......
......@@ -12,15 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import inspect
import unittest
from numpy import append
import paddle
from paddle.fluid.dygraph.dygraph_to_static.utils import (
FunctionNameLivenessAnalysis,
)
from paddle.utils import gast
import inspect
from numpy import append
global_a = []
......
......@@ -13,10 +13,12 @@
# limitations under the License.
import os
import paddle
import tempfile
import unittest
import numpy as np
import tempfile
import paddle
class BufferLayers(paddle.nn.Layer):
......
......@@ -12,9 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import numpy as np
import paddle
import unittest
class CallNotExist(paddle.nn.Layer):
......
......@@ -13,9 +13,11 @@
# limitations under the License.
import unittest
import paddle
import numpy as np
import paddle
class TestCpuCuda(unittest.TestCase):
def test_cpu_cuda(self):
......
......@@ -23,23 +23,23 @@
# See the License for the specific language governing permissions and
# limitations under the License
import time
import os
import random
import time
import unittest
import numpy as np
from PIL import Image, ImageOps
import os
# Use GPU:0 to elimate the influence of other tasks.
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph import to_variable
from paddle.jit.api import declarative
from paddle.fluid.dygraph.nn import BatchNorm, Conv2DTranspose
from paddle.jit import ProgramTranslator
from paddle.fluid.dygraph.nn import Conv2DTranspose, BatchNorm
from paddle.jit.api import declarative
# Note: Set True to eliminate randomness.
# 1. For one operation, cuDNN has several algorithms,
......
......@@ -12,25 +12,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import unittest
import os
import tempfile
import unittest
import numpy as np
from test_basic_api_transformation import dyfunc_to_variable
import paddle
import paddle.fluid as fluid
from paddle.static import InputSpec
from paddle.fluid.dygraph import (
to_variable,
Layer,
)
from paddle.jit.api import declarative
from paddle.fluid.dygraph import Layer, to_variable
from paddle.jit import ProgramTranslator
from paddle.jit.api import declarative
from paddle.jit.dy2static.program_translator import (
ConcreteProgram,
StaticFunction,
)
from test_basic_api_transformation import dyfunc_to_variable
from paddle.static import InputSpec
program_trans = ProgramTranslator()
......
......@@ -12,13 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import paddle
import unittest
import numpy as np
import decos
import warnings
from functools import wraps
from contextlib import contextmanager
from functools import wraps
import decos
import numpy as np
import paddle
def deco1(func):
......
......@@ -13,14 +13,13 @@
# limitations under the License.
import unittest
import paddle
import numpy as np
from paddle.jit.dy2static.program_translator import (
StaticFunction,
)
from copy import deepcopy
import numpy as np
from test_rollback import Net, foo
from copy import deepcopy
import paddle
from paddle.jit.dy2static.program_translator import StaticFunction
class TestDeepCopy(unittest.TestCase):
......
......@@ -12,15 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import unittest
import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.jit import to_static
from paddle.jit.dy2static.program_translator import (
ProgramTranslator,
)
from paddle.jit.dy2static.program_translator import ProgramTranslator
PLACE = (
fluid.CUDAPlace(0) if fluid.is_compiled_with_cuda() else fluid.CPUPlace()
......
......@@ -13,6 +13,7 @@
# limitations under the License.
import unittest
import numpy as np
import paddle
......
......@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import unittest
import numpy as np
import paddle
np.random.seed(1)
......
......@@ -12,12 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import unittest
import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.jit.api import declarative
from paddle.jit import ProgramTranslator
from paddle.jit.api import declarative
SEED = 2020
......
......@@ -12,10 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import unittest
import os
import tempfile
import unittest
import numpy as np
import paddle
import paddle.fluid as fluid
......
......@@ -12,10 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import numpy as np
import paddle
import paddle.fluid as fluid
import unittest
from paddle.jit import to_static
......
......@@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import paddle
from paddle.static import InputSpec
from paddle.fluid.dygraph.dygraph_to_static.function_spec import FunctionSpec
import unittest
from test_declarative import foo_func
import unittest
import paddle
from paddle.fluid.dygraph.dygraph_to_static.function_spec import FunctionSpec
from paddle.static import InputSpec
paddle.enable_static()
......
......@@ -12,11 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import paddle
import unittest
import os
import tempfile
import unittest
import numpy as np
import paddle
class GradLayer(paddle.nn.Layer):
......
......@@ -14,9 +14,10 @@
import unittest
import paddle
import numpy as np
import paddle
SEED = 2020
np.random.seed(SEED)
......
......@@ -12,11 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import paddle
from paddle import nn, ParamAttr
import unittest
import numpy as np
import unittest
import paddle
from paddle import ParamAttr, nn
np.random.seed(2020)
paddle.seed(2020)
......
......@@ -12,17 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import unittest
import paddle
from paddle.jit.api import declarative
from paddle.jit.dy2static.program_translator import (
ProgramTranslator,
)
from paddle.fluid.dygraph.dygraph_to_static.utils import Dygraph2StaticException
import paddle.fluid.core as core
import numpy as np
from ifelse_simple_func import (
NetWithControlFlowIf,
add_fn,
......@@ -49,6 +41,12 @@ from ifelse_simple_func import (
nested_if_else_3,
)
import paddle
import paddle.fluid.core as core
from paddle.fluid.dygraph.dygraph_to_static.utils import Dygraph2StaticException
from paddle.jit.api import declarative
from paddle.jit.dy2static.program_translator import ProgramTranslator
np.random.seed(1)
if fluid.is_compiled_with_cuda():
......
......@@ -23,9 +23,10 @@
# See the License for the specific language governing permissions and
# limitations under the License
import numpy as np
import unittest
import numpy as np
import paddle
import paddle.nn as nn
......
......@@ -13,6 +13,7 @@
# limitations under the License.
import unittest
import paddle
......
......@@ -13,24 +13,23 @@
# limitations under the License.
import math
import os
import tempfile
import time
import numpy as np
import unittest
import os
import tempfile
import numpy as np
os.environ["CUDA_VISIBLE_DEVICES"] = "2"
import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph import to_variable
from paddle.fluid.dygraph import Embedding, Linear, GRUUnit
from paddle.jit.api import declarative
from paddle.jit import ProgramTranslator
from paddle import _legacy_C_ops
from paddle.fluid.dygraph import Embedding, GRUUnit, Linear, to_variable
from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX
from paddle.fluid.framework import _non_static_mode
from paddle import _legacy_C_ops
from paddle.jit import ProgramTranslator
from paddle.jit.api import declarative
SEED = 2020
......
......@@ -12,11 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import unittest
import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.jit.api import declarative
......
......@@ -12,11 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import paddle
import os
import numpy as np
import tempfile
import unittest
import numpy as np
import paddle
def forward_post_hook1(layer, input, output):
......
......@@ -15,11 +15,12 @@
import unittest
import paddle
import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.jit.api import declarative
from paddle.fluid.layers.utils import map_structure
from paddle.jit.api import declarative
SEED = 2020
np.random.seed(SEED)
......
......@@ -17,12 +17,11 @@ import logging
import os
import sys
import unittest
from paddle.utils import gast
from unittest import mock
import paddle
from paddle.fluid.dygraph.dygraph_to_static import logging_utils
from unittest import mock
from paddle.utils import gast
class TestLoggingUtils(unittest.TestCase):
......
......@@ -17,15 +17,15 @@ or nested loop have been covered in file test_ifelse.py and test_loop.py"""
import unittest
from paddle.utils import gast
import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.jit import ProgramTranslator
from paddle.fluid.dygraph.dygraph_to_static.logical_transformer import (
cmpop_node_to_str,
)
from paddle.jit import ProgramTranslator
from paddle.utils import gast
program_translator = ProgramTranslator()
......
......@@ -12,12 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import tempfile
import unittest
import numpy as np
import paddle
import unittest
from paddle import nn
import os
import tempfile
class LSTMLayer(nn.Layer):
......
......@@ -12,23 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import os
import tempfile
import unittest
from time import time
import numpy as np
from predictor_utils import PredictorTools
import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph.base import switch_to_static_graph
from paddle.fluid.dygraph import to_variable
from paddle.fluid.dygraph.nn import Linear, Pool2D
from paddle.fluid.optimizer import AdamOptimizer
from paddle.fluid.dygraph.base import switch_to_static_graph
from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX
from paddle.fluid.dygraph.nn import Linear, Pool2D
from paddle.fluid.framework import _test_eager_guard
from predictor_utils import PredictorTools
from paddle.fluid.optimizer import AdamOptimizer
SEED = 2020
......
......@@ -12,11 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import paddle
import unittest
import numpy as np
from time import time
from test_mnist import MNIST, TestMNIST, SEED
import numpy as np
from test_mnist import MNIST, SEED, TestMNIST
import paddle
from paddle.fluid.optimizer import AdamOptimizer
if paddle.fluid.is_compiled_with_cuda():
......
......@@ -12,12 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import paddle
import unittest
import numpy as np
from time import time
import numpy as np
from test_mnist import MNIST, SEED, TestMNIST
import paddle
if paddle.fluid.is_compiled_with_cuda():
paddle.fluid.set_flags({'FLAGS_cudnn_deterministic': True})
......
......@@ -15,19 +15,19 @@
import os
import tempfile
import time
import unittest
import numpy as np
from predictor_utils import PredictorTools
import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX
from paddle.fluid.dygraph.nn import BatchNorm, Linear, Pool2D
from paddle.fluid.initializer import MSRA
from paddle.fluid.param_attr import ParamAttr
from paddle.fluid.dygraph.nn import Pool2D, BatchNorm, Linear
from paddle.jit.api import declarative
from paddle.jit import ProgramTranslator
from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX
import unittest
from predictor_utils import PredictorTools
from paddle.jit.api import declarative
# Note: Set True to eliminate randomness.
# 1. For one operation, cuDNN has several algorithms,
......
......@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import paddle
import paddle.fluid as fluid
import unittest
class MyLayer(paddle.nn.Layer):
......
......@@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import paddle
import unittest
import paddle
from paddle.static import InputSpec
......
......@@ -15,12 +15,9 @@
import sys
import unittest
from paddle.jit.dy2static import (
DygraphToStaticAst,
)
from paddle.fluid.dygraph.dygraph_to_static.origin_info import (
Location,
ORIGI_INFO,
Location,
OriginInfo,
attach_origin_info,
create_and_update_origin_info_map,
......@@ -30,6 +27,7 @@ from paddle.fluid.dygraph.dygraph_to_static.origin_info import (
)
from paddle.fluid.dygraph.dygraph_to_static.utils import ast_to_func
from paddle.jit.api import declarative
from paddle.jit.dy2static import DygraphToStaticAst
def simple_func(x):
......
......@@ -12,11 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import paddle
import numpy as np
import unittest
from paddle.jit import to_static, ProgramTranslator
import numpy as np
import paddle
from paddle.jit import ProgramTranslator, to_static
class NetWithParameterList(paddle.nn.Layer):
......
......@@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import paddle
import paddle.nn as nn
import paddle.distributed as dist
import unittest
import paddle.nn as nn
class Net(nn.Layer):
......
......@@ -12,16 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import numpy as np
from test_fetch_feed import Linear
import paddle
import paddle.fluid as fluid
from paddle.fluid.layers.utils import flatten
from paddle.jit.api import declarative
from paddle.jit import ProgramTranslator
from test_fetch_feed import Linear
import unittest
from paddle.jit.api import declarative
SEED = 2020
......
......@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import paddle
import unittest
import paddle
class TestPlace(unittest.TestCase):
def test_place(self):
......
......@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy
import unittest
import numpy
import paddle.fluid as fluid
from paddle.jit import ProgramTranslator
from paddle.jit.api import declarative
......
......@@ -12,26 +12,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import astor
from paddle.utils import gast
import inspect
import numpy as np
import textwrap
import unittest
import paddle
import paddle.fluid as fluid
from paddle.jit import ProgramTranslator
from paddle.jit.api import declarative
from paddle.fluid.dygraph.dygraph_to_static.utils import func_to_source_code
import paddle.jit.dy2static as _jst
import astor
import numpy as np
from ifelse_simple_func import (
dyfunc_with_if_else,
dyfunc_with_if_else_early_return1,
dyfunc_with_if_else_early_return2,
)
import paddle
import paddle.fluid as fluid
import paddle.jit.dy2static as _jst
from paddle.fluid.dygraph.dygraph_to_static.utils import func_to_source_code
from paddle.jit import ProgramTranslator
from paddle.jit.api import declarative
from paddle.utils import gast
np.random.seed(0)
......
......@@ -17,13 +17,14 @@ import time
import unittest
import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.jit import ProgramTranslator
from paddle.fluid.dygraph.base import to_variable
from paddle.jit.api import declarative
from paddle.fluid.dygraph.nn import Embedding
from paddle.fluid.optimizer import SGDOptimizer
from paddle.jit import ProgramTranslator
from paddle.jit.api import declarative
PRINT_STEP = 20
SEED = 2020
......
......@@ -17,6 +17,7 @@ import time
import unittest
import numpy as np
import paddle
PRINT_STEP = 20
......
......@@ -12,18 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import gym
import math
import itertools
import math
import unittest
import gym
import numpy as np
import paddle
import paddle.fluid as fluid
import paddle.fluid.dygraph.nn as nn
from paddle.fluid.dygraph import to_variable, Layer
from paddle.jit.api import declarative
from paddle.fluid.dygraph import Layer, to_variable
from paddle.jit import ProgramTranslator
import unittest
from paddle.jit.api import declarative
SEED = 2020
program_translator = ProgramTranslator()
......
......@@ -12,21 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import math
import time
import os
import tempfile
import time
import unittest
import numpy as np
from predictor_utils import PredictorTools
import paddle
import paddle.fluid as fluid
from paddle.jit import ProgramTranslator
from paddle.fluid.dygraph.nn import BatchNorm, Linear, Pool2D
from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX
from predictor_utils import PredictorTools
from paddle.fluid.dygraph.nn import BatchNorm, Linear, Pool2D
from paddle.jit import ProgramTranslator
SEED = 2020
IMAGENET1000 = 1281167
......
......@@ -16,11 +16,11 @@ import time
import unittest
import numpy as np
from test_resnet import SEED, ResNet, optimizer_setting
import paddle
import paddle.fluid as fluid
from paddle.jit import ProgramTranslator
from test_resnet import ResNet, optimizer_setting, SEED
# NOTE: Reduce batch_size from 8 to 2 to avoid unittest timeout.
batch_size = 2
......
......@@ -16,11 +16,11 @@ import time
import unittest
import numpy as np
from test_resnet import SEED, ResNet, optimizer_setting
import paddle
import paddle.fluid as fluid
from paddle.jit import ProgramTranslator
from test_resnet import ResNet, optimizer_setting, SEED
# NOTE: Reduce batch_size from 8 to 2 to avoid unittest timeout.
batch_size = 2
......
......@@ -16,16 +16,15 @@ import os
os.environ["FLAGS_enable_eager_mode"] = "0"
import math
import tempfile
import time
import unittest
import tempfile
import numpy as np
from predictor_utils import PredictorTools
import paddle
from predictor_utils import PredictorTools
SEED = 2020
IMAGENET1000 = 1281167
base_lr = 0.001
......
......@@ -12,17 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import numpy as np
from ifelse_simple_func import dyfunc_with_if_else
import paddle
import paddle.fluid as fluid
import paddle.fluid.core as core
from paddle.jit import to_static
from paddle.jit import ProgramTranslator
from paddle.fluid.dygraph.dygraph_to_static.utils import Dygraph2StaticException
import unittest
import numpy as np
from ifelse_simple_func import dyfunc_with_if_else
from paddle.jit import ProgramTranslator, to_static
SEED = 2020
np.random.seed(SEED)
......
......@@ -13,12 +13,12 @@
# limitations under the License.
import unittest
import paddle
import numpy as np
import paddle
from paddle.fluid.dygraph.dygraph_to_static.utils import func_to_source_code
from paddle.jit.dy2static.program_translator import (
StaticFunction,
)
from paddle.jit.dy2static.program_translator import StaticFunction
class Net(paddle.nn.Layer):
......
......@@ -14,21 +14,21 @@
import logging
import math
import time
import unittest
import os
import tempfile
import time
import unittest
import numpy as np
from predictor_utils import PredictorTools
import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph.base import to_variable
from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX
from paddle.fluid.dygraph.nn import BatchNorm, Linear, Pool2D
from paddle.jit.api import declarative
from paddle.jit import ProgramTranslator
from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX
from predictor_utils import PredictorTools
from paddle.jit.api import declarative
SEED = 2020
np.random.seed(SEED)
......
......@@ -13,17 +13,17 @@
# limitations under the License.
import time
import unittest
import numpy as np
from test_lac import DynamicGRU
import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph.nn import Linear, Embedding
from paddle.fluid.dygraph import to_variable
from paddle.fluid.dygraph.nn import Embedding, Linear
from paddle.jit import ProgramTranslator
from paddle.jit.api import declarative
from test_lac import DynamicGRU
SEED = 2020
program_translator = ProgramTranslator()
......
......@@ -13,6 +13,7 @@
# limitations under the License.
import unittest
from paddle.fluid.dygraph.dygraph_to_static.utils import GetterSetterHelper
vars = [1, 2, 3, 4, 5]
......
......@@ -13,15 +13,16 @@
# limitations under the License.
import argparse
import numpy as np
import paddle
import paddle.fluid as fluid
import random
import unittest
from paddle.jit import ProgramTranslator
import numpy as np
from simnet_dygraph_model import BOW, HingeLoss
import paddle
import paddle.fluid as fluid
from paddle.jit import ProgramTranslator
SEED = 102
random.seed(SEED)
......
......@@ -13,13 +13,14 @@
# limitations under the License.
import argparse
import numpy as np
import paddle
import random
import unittest
import numpy as np
from simnet_dygraph_model_v2 import BOW, HingeLoss
import paddle
SEED = 102
random.seed(SEED)
......
......@@ -15,6 +15,7 @@
import os
import tempfile
import unittest
import numpy as np
import paddle
......
......@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import paddle
from paddle.nn import Layer
import unittest
class Net(Layer):
......
......@@ -12,17 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from paddle.utils import gast
import inspect
import unittest
import numpy as np
import paddle
import paddle.fluid as fluid
import unittest
from paddle.fluid.dygraph.dygraph_to_static import (
NodeVarType,
StaticAnalysisVisitor,
)
from paddle.utils import gast
def func_to_test1(a, b):
......
......@@ -12,9 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import numpy as np
import paddle
import unittest
@paddle.jit.to_static
......
......@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import numpy as np
import unittest
import paddle
import paddle.fluid as fluid
from paddle.jit.api import declarative
......
......@@ -12,11 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
import numpy
import paddle
import unittest
from paddle.fluid.framework import program_guard, Program
from paddle.fluid import core
from paddle.fluid.framework import Program, program_guard
def case0(x):
......
......@@ -14,14 +14,11 @@
import logging
import os
import time
import tempfile
import time
import unittest
import numpy as np
import paddle
import paddle.fluid as fluid
import transformer_util as util
from transformer_dygraph_model import (
CrossEntropyCriterion,
......@@ -29,6 +26,9 @@ from transformer_dygraph_model import (
position_encoding_init,
)
import paddle
import paddle.fluid as fluid
trainer_count = 1
place = (
fluid.CUDAPlace(0) if fluid.is_compiled_with_cuda() else fluid.CPUPlace()
......
......@@ -13,18 +13,20 @@
# limitations under the License.
import argparse
import numpy as np
import os
import random
import sys
import unittest
import numpy as np
from tsm_config_utils import merge_configs, parse_config, print_configs
import paddle
import paddle.fluid as fluid
from paddle.jit.api import declarative
from paddle.jit import ProgramTranslator
from paddle.fluid.dygraph import to_variable
from paddle.fluid.dygraph.nn import BatchNorm, Linear, Pool2D
from tsm_config_utils import merge_configs, parse_config, print_configs
from paddle.jit import ProgramTranslator
from paddle.jit.api import declarative
random.seed(0)
np.random.seed(0)
......
......@@ -12,10 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import paddle.fluid as fluid
import unittest
import numpy as np
import paddle.fluid as fluid
from paddle.jit.api import declarative
SEED = 2020
......
......@@ -13,11 +13,13 @@
# limitations under the License.
import os
import tempfile
import paddle
import unittest
import numpy as np
from typing import Dict, List, Tuple
import numpy as np
import paddle
class BaseLayer(paddle.nn.Layer):
def __init__(self, in_size, out_size):
......
......@@ -15,8 +15,10 @@
import types
import unittest
from paddle.fluid.dygraph.dygraph_to_static.utils import index_in_list
from paddle.fluid.dygraph.dygraph_to_static.utils import is_paddle_func
from paddle.fluid.dygraph.dygraph_to_static.utils import (
index_in_list,
is_paddle_func,
)
class TestIndexInList(unittest.TestCase):
......
......@@ -13,8 +13,9 @@
# limitations under the License.
import unittest
import paddle
import warnings
import paddle
from paddle.fluid.layers.control_flow import cond
......
......@@ -12,17 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import numpy as np
import random
import time
import unittest
import numpy as np
from yolov3 import YOLOv3, cfg
import paddle
import paddle.fluid as fluid
from paddle.jit import ProgramTranslator
from paddle.fluid.dygraph import to_variable
from yolov3 import cfg, YOLOv3
from paddle.jit import ProgramTranslator
paddle.enable_static()
random.seed(0)
......
......@@ -14,8 +14,10 @@
import numpy as np
import paddle
import paddle.fluid as fluid
import paddle.fluid.layers as layers
import paddle.nn.functional as F
from paddle.fluid.dygraph import (
Embedding,
Layer,
......@@ -23,10 +25,8 @@ from paddle.fluid.dygraph import (
Linear,
to_variable,
)
from paddle.jit.api import dygraph_to_static_func
from paddle.fluid.layers.utils import map_structure
import paddle
import paddle.nn.functional as F
from paddle.jit.api import dygraph_to_static_func
def position_encoding_init(n_position, d_pos_vec):
......
......@@ -15,11 +15,12 @@
import pickle
import warnings
from functools import partial
import numpy as np
import paddle
import paddle.fluid as fluid
import paddle.dataset.wmt16 as wmt16
import paddle.fluid as fluid
def get_input_descs(args, mode="train"):
......
......@@ -15,15 +15,13 @@
import os
import sys
import paddle
from darknet import ConvBNLayer, DarkNet53_conv_body
import paddle
import paddle.fluid as fluid
from paddle.jit.api import declarative
from paddle.fluid.param_attr import ParamAttr
from paddle.fluid.regularizer import L2Decay
from darknet import DarkNet53_conv_body
from darknet import ConvBNLayer
from paddle.jit.api import declarative
class AttrDict(dict):
......
......@@ -14,16 +14,15 @@
import tempfile
import unittest
from functools import partial
import numpy as np
import paddle
from paddle.jit.dy2static.program_translator import (
ProgramCache,
)
from paddle.fluid.tests.unittests.ipu.op_test_ipu import IPUD2STest
from paddle.jit import to_static
from paddle.jit.dy2static.program_translator import ProgramCache
from paddle.optimizer.lr import LRScheduler
from functools import partial
class SimpleLayer(paddle.nn.Layer):
......
......@@ -13,7 +13,9 @@
# limitations under the License.
import unittest
import numpy as np
import paddle
import paddle.fluid.core as core
from paddle.fluid.framework import _test_eager_guard
......
......@@ -14,9 +14,10 @@
import unittest
import numpy as np
import paddle
import paddle.fluid as fluid
import numpy as np
class TestManualSeed(unittest.TestCase):
......
......@@ -13,11 +13,12 @@
# limitations under the License.
import unittest
import numpy as np
from op_test import OpTest
import paddle
from paddle.fluid import core
from paddle.fluid import Program, program_guard
from paddle.fluid import Program, core, program_guard
def stable_softmax_comm(x):
......
......@@ -13,10 +13,12 @@
# limitations under the License.
import unittest
import numpy as np
from op_test import OpTest
from paddle import fluid
import paddle
from paddle import fluid
class TestMarginRankLossOp(OpTest):
......
......@@ -12,7 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
from op_test import OpTest
from paddle.distributed.fleet.meta_optimizers.common import OpRole
......
......@@ -13,8 +13,10 @@
# limitations under the License.
import unittest
import numpy as np
from op_test import OpTest
import paddle
......
......@@ -13,8 +13,10 @@
# limitations under the License.
import unittest
import numpy as np
from op_test import OpTest
import paddle.fluid as fluid
......
......@@ -13,11 +13,13 @@
# limitations under the License.
import unittest
import numpy
import numpy as np
from decorator_helper import prog_scope
import paddle
import paddle.fluid as fluid
import numpy
import numpy as np
class TestMathOpPatches(unittest.TestCase):
......
......@@ -12,11 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import inspect
import unittest
import numpy as np
import paddle
import paddle.fluid as fluid
import numpy as np
import inspect
from paddle.fluid.framework import _test_eager_guard
......
......@@ -13,8 +13,10 @@
# limitations under the License.
import unittest
import numpy as np
from op_test import OpTest
import paddle
import paddle.fluid as fluid
from paddle.fluid import Program, program_guard
......
......@@ -13,6 +13,7 @@
# limitations under the License.
import unittest
import numpy as np
from op_test import OpTest
......
......@@ -13,14 +13,15 @@
# limitations under the License.
import unittest
import numpy as np
from op_test import OpTest, convert_float_to_uint16, get_numeric_gradient
from paddle.fluid.tests.unittests.testsuite import create_op
import paddle.fluid.core as core
import paddle
import paddle.fluid as fluid
import paddle.fluid.core as core
from paddle.fluid.framework import _test_eager_guard
from paddle.fluid.tests.unittests.testsuite import create_op
def reference_matmul(X, Y, transpose_X=False, transpose_Y=False):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册