Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CodeStyle][isort] introduce isort (part4) #48402

Merged
merged 4 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions cmake/copyfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import glob
import os
import sys
import shutil
import glob
import sys


def main():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import os
import sys


def GenerateFileStructureForFinalDygraph(eager_dir):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import yaml
import re

import yaml

####################
# Global Variables #
####################
Expand Down
42 changes: 24 additions & 18 deletions paddle/fluid/eager/auto_code_generator/generator/eager_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,36 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import re
import argparse
import os
import re

from codegen_utils import (
core_ops_returns_info,
core_ops_args_info,
core_ops_args_type_info,
)
from codegen_utils import ReadBwdFile
from codegen_utils import FindForwardName, GetGradNodeName, GetSavedName
from codegen_utils import IsPlainTensorType, IsVectorTensorType
from codegen_utils import GetConstReference, RemoveConstAndReference
from codegen_utils import (
AssertMessage,
FindForwardName,
FunctionGeneratorBase,
GeneratorBase,
GetAutoGradMetaName,
GetAutoGradMetaVectorName,
GetConstReference,
GetDygraphForwardFunctionName,
GetGradNodeName,
GetIndent,
GetInplacedFunctionName,
GetIntermediateAPIFunctionName,
GetSavedName,
IsPlainTensorType,
IsVectorTensorType,
ParseYamlBackward,
ParseYamlForwardFromBackward,
ParseYamlInplaceInfo,
ReadBwdFile,
RemoveConstAndReference,
core_ops_args_info,
core_ops_args_type_info,
core_ops_returns_info,
ops_to_fill_zero_for_empty_grads,
)
from codegen_utils import GetAutoGradMetaName, GetAutoGradMetaVectorName
from codegen_utils import GetInplacedFunctionName
from codegen_utils import ParseYamlForwardFromBackward
from codegen_utils import ParseYamlBackward
from codegen_utils import ParseYamlInplaceInfo
from codegen_utils import FunctionGeneratorBase, GeneratorBase
from codegen_utils import ops_to_fill_zero_for_empty_grads
from codegen_utils import AssertMessage, GetIndent

# Note: assign is a inplace api when parameter(output) isn't none,
# so we should check parameter(output) with rule of inplace.
Expand Down
13 changes: 9 additions & 4 deletions paddle/fluid/eager/auto_code_generator/generator/python_c_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import argparse
from codegen_utils import FunctionGeneratorBase, GeneratorBase
from codegen_utils import GetForwardFunctionName, IsVectorTensorType
from codegen_utils import GetInplacedFunctionName
import os

from codegen_utils import (
FunctionGeneratorBase,
GeneratorBase,
GetForwardFunctionName,
GetInplacedFunctionName,
IsVectorTensorType,
)

#########################
# Global Configurations #
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/inference/api/demo_ci/untar_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import tarfile
import sys
import tarfile


def untar(fname, dirs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@
# without warranties or conditions of any kind, either express or implied.
# see the license for the specific language governing permissions and
# limitations under the license.
import os
import argparse
import io
import numpy as np
import os
import shutil
import sys
import tarfile

import numpy as np
from PIL import Image

from paddle.dataset.common import download
import tarfile
import argparse
import shutil

np.random.seed(0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import xml.etree.ElementTree
from PIL import Image
import numpy as np
import argparse
import hashlib
import os
import sys
from paddle.dataset.common import download
import tarfile
import xml.etree.ElementTree
from io import StringIO
import hashlib
import tarfile
import argparse

import numpy as np
from PIL import Image

from paddle.dataset.common import download

DATA_URL = (
"http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtest_06-Nov-2007.tar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest
import os
import unittest


class Test_Preprocess(unittest.TestCase):
Expand Down
12 changes: 5 additions & 7 deletions paddle/fluid/operators/generator/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,16 @@
import re

from type_mapping import (
input_types_map,
optional_input_types_map,
attr_types_map,
opmaker_attr_types_map,
output_type_map,
)
from type_mapping import (
dense_input_types_map,
dense_optional_input_types_map,
dense_output_types_map,
sr_output_types_map,
input_types_map,
opmaker_attr_types_map,
optional_input_types_map,
output_type_map,
phi_attr_types_map,
sr_output_types_map,
)


Expand Down
12 changes: 6 additions & 6 deletions paddle/fluid/operators/generator/generate_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@
from pathlib import Path

import yaml
from jinja2 import Environment, FileSystemLoader, StrictUndefined

from filters import (
cartesian_prod_mapping,
to_input_name,
to_op_attr_type,
to_opmaker_name,
to_opmaker_name_cstr,
to_pascal_case,
)
from jinja2 import Environment, FileSystemLoader, StrictUndefined
from parse_utils import to_named_dict
from tests import (
is_base_op,
is_vec,
is_scalar,
is_initializer_list,
is_scalar,
is_vec,
supports_inplace,
supports_no_need_buffer,
)
from filters import to_input_name, cartesian_prod_mapping
from parse_utils import to_named_dict

file_loader = FileSystemLoader(Path(__file__).parent / "templates")
env = Environment(
Expand Down
14 changes: 7 additions & 7 deletions paddle/fluid/operators/generator/generate_sparse_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@
from pathlib import Path

import yaml
from jinja2 import Environment, FileSystemLoader, StrictUndefined

from filters import (
cartesian_prod_mapping,
to_input_name,
to_op_attr_type,
to_opmaker_name,
to_opmaker_name_cstr,
to_pascal_case,
)
from generate_op import process_invoke_op
from jinja2 import Environment, FileSystemLoader, StrictUndefined
from parse_utils import to_named_dict
from tests import (
is_base_op,
is_vec,
is_scalar,
is_initializer_list,
is_scalar,
is_vec,
supports_inplace,
supports_no_need_buffer,
)
from filters import to_input_name, cartesian_prod_mapping
from parse_utils import to_named_dict
from generate_op import process_invoke_op

file_loader = FileSystemLoader(Path(__file__).parent / "templates")
env = Environment(
Expand Down
1 change: 0 additions & 1 deletion paddle/fluid/operators/generator/parse_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import argparse

import yaml

from parse_utils import parse_op_entry


Expand Down
3 changes: 2 additions & 1 deletion paddle/fluid/operators/generator/parse_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

import re
from copy import copy
from typing import Dict, Any, List, Tuple
from typing import Any, Dict, List, Tuple

from tests import is_attr, is_input, is_output, is_vec


Expand Down
3 changes: 2 additions & 1 deletion paddle/fluid/operators/generator/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# limitations under the License.

import re
from type_mapping import input_types_map, attr_types_map, output_type_map

from type_mapping import attr_types_map, input_types_map, output_type_map


# tests for typename
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/pybind/generate_file_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import os
import sys

if __name__ == "__main__":
assert len(sys.argv) == 3
Expand Down
5 changes: 3 additions & 2 deletions paddle/infrt/tests/models/abs_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys

import paddle
from paddle.static import InputSpec
from paddle.jit import to_static
import sys
from paddle.static import InputSpec


class AbsNet(paddle.nn.Layer):
Expand Down
6 changes: 4 additions & 2 deletions paddle/infrt/tests/models/efficientnet-b4/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys

# url: https://aistudio.baidu.com/aistudio/projectdetail/3756986?forkThirdPart=1
from net import EfficientNet

import paddle
from paddle.jit import to_static
from paddle.static import InputSpec
import paddle
import sys

model = EfficientNet.from_name('efficientnet-b4')
net = to_static(
Expand Down
8 changes: 4 additions & 4 deletions paddle/infrt/tests/models/efficientnet-b4/net/efficientnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
import paddle.nn.functional as F

from .utils import (
round_filters,
round_repeats,
drop_connect,
get_same_padding_conv2d,
get_model_params,
efficientnet_params,
get_model_params,
get_same_padding_conv2d,
load_pretrained_weights,
round_filters,
round_repeats,
)


Expand Down
4 changes: 2 additions & 2 deletions paddle/infrt/tests/models/efficientnet-b4/net/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import re
import collections
import math
import re
from functools import partial
import collections

import paddle
import paddle.nn as nn
Expand Down
1 change: 1 addition & 0 deletions paddle/infrt/tests/models/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

# example 1: save layer
import numpy as np

import paddle
import paddle.nn as nn
import paddle.optimizer as opt
Expand Down
5 changes: 3 additions & 2 deletions paddle/infrt/tests/models/resnet50_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys

import paddle
from paddle.vision.models import resnet50
from paddle.jit import to_static
from paddle.static import InputSpec
import sys
from paddle.vision.models import resnet50

model = resnet50(True)
net = to_static(
Expand Down
Loading