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

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

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