Skip to content

Commit

Permalink
[CodeStyle] clean isort ignore (#59335)
Browse files Browse the repository at this point in the history
  • Loading branch information
gouzil authored Nov 25, 2023
1 parent 907e425 commit e19a92d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
21 changes: 8 additions & 13 deletions python/paddle/incubate/asp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# isort: off
# NOTE(gouzil): MaskAlgo can cause circular references, so sorting is disabled
from .asp import (
ASPHelper, # noqa: F401
decorate,
prune_model,
reset_excluded_layers,
set_excluded_layers,
)
from .supported_layer_list import add_supported_layer
from .utils import ( # noqa: F401
CheckMethod,
MaskAlgo,
Expand All @@ -28,17 +34,6 @@
get_mask_2d_greedy,
)

# isort: on

from .asp import ASPHelper # noqa: F401
from .asp import (
decorate,
prune_model,
reset_excluded_layers,
set_excluded_layers,
)
from .supported_layer_list import add_supported_layer

__all__ = [
'calculate_density',
'decorate',
Expand Down
12 changes: 6 additions & 6 deletions python/paddle/incubate/asp/asp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
import paddle
from paddle.base import core, global_scope, program_guard
from paddle.base.framework import dygraph_only
from paddle.incubate import asp

from .supported_layer_list import (
_default_pruning,
supported_layers_and_prune_func_map,
)
from .utils import MaskAlgo

OpRole = core.op_proto_and_checker_maker.OpRole
OP_ROLE_KEY = core.op_proto_and_checker_maker.kOpRoleAttrName()
Expand Down Expand Up @@ -437,9 +437,9 @@ def prune_model(model, n=2, m=4, mask_algo='mask_1d', with_mask=True):
place = paddle.set_device(device)

MaskAlgo_mapping = {
'mask_1d': asp.MaskAlgo.MASK_1D,
'mask_2d_greedy': asp.MaskAlgo.MASK_2D_GREEDY,
'mask_2d_best': asp.MaskAlgo.MASK_2D_BEST,
'mask_1d': MaskAlgo.MASK_1D,
'mask_2d_greedy': MaskAlgo.MASK_2D_GREEDY,
'mask_2d_best': MaskAlgo.MASK_2D_BEST,
}
assert (
mask_algo in MaskAlgo_mapping
Expand Down Expand Up @@ -568,7 +568,7 @@ def prune_model_by_program(
main_program=None,
n=2,
m=4,
mask_algo=asp.MaskAlgo.MASK_1D,
mask_algo=MaskAlgo.MASK_1D,
with_mask=True,
):
r"""
Expand Down Expand Up @@ -620,7 +620,7 @@ def prune_model_by_layer(
layer,
n=2,
m=4,
mask_algo=asp.MaskAlgo.MASK_1D,
mask_algo=MaskAlgo.MASK_1D,
with_mask=True,
):
r"""
Expand Down
2 changes: 0 additions & 2 deletions python/paddle/jit/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Temporary disable isort to avoid circular import
# This can be removed after the circular import is resolved
from __future__ import annotations

import inspect
Expand Down
8 changes: 1 addition & 7 deletions python/paddle/jit/dy2static/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
from .assert_transformer import AssertTransformer # noqa: F401
from .ast_transformer import DygraphToStaticAst # noqa: F401
from .convert_call_func import convert_call as Call # noqa: F401

# isort: off
# NOTE(gouzil): isort will delete the import
# TODO(gouzil): Remove `isort: off` after adding the `combine-as-imports` configuration
from .convert_operators import ( # noqa: F401
convert_assert as Assert,
convert_attr as Attr,
Expand All @@ -29,15 +25,13 @@
convert_logical_not as Not,
convert_logical_or as Or,
convert_pop as Pop,
convert_shape_compare,
convert_shape as Shape,
convert_shape_compare,
convert_var_dtype as AsDtype,
convert_while_loop as While,
indexable as Indexable,
unpack_by_structure as Unpack,
)

# isort: on
from .program_translator import convert_to_static # noqa: F401
from .static_analysis import NodeVarType, StaticAnalysisVisitor # noqa: F401
from .utils import UndefinedVar, ast_to_source_code, saw # noqa: F401
Expand Down

0 comments on commit e19a92d

Please sign in to comment.