Skip to content

[CodeStyle][py2] remove paddle.compat #47269

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

Merged
merged 5 commits into from
Oct 25, 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion python/paddle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
from .framework import VarBase as Tensor # noqa: F401

Tensor.__qualname__ = 'Tensor' # noqa: F401
import paddle.compat # noqa: F401
import paddle.distributed # noqa: F401
import paddle.sysconfig # noqa: F401
import paddle.distribution # noqa: F401
Expand Down
198 changes: 0 additions & 198 deletions python/paddle/compat.py

This file was deleted.

1 change: 0 additions & 1 deletion python/paddle/fluid/backward.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import collections
import copy
import logging
from .. import compat as cpt
from . import unique_name
from . import log_helper
import paddle.fluid
Expand Down
4 changes: 0 additions & 4 deletions python/paddle/fluid/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
os.add_dll_directory(third_lib_path)

except ImportError as e:
from .. import compat as cpt

if os.name == 'nt':
executable_path = os.path.abspath(os.path.dirname(sys.executable))
raise ImportError(
Expand All @@ -71,8 +69,6 @@ def avx_supported():
"""
Whether current system(Linux, MacOS, Windows) is supported with AVX.
"""
from .. import compat as cpt

sysstr = platform.system().lower()
has_avx = False
if sysstr == 'linux':
Expand Down
1 change: 0 additions & 1 deletion python/paddle/fluid/dygraph/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import numpy as np

import paddle
from paddle import compat as cpt
from paddle.fluid import core
from paddle.fluid import framework
from paddle.fluid import backward
Expand Down
1 change: 0 additions & 1 deletion python/paddle/fluid/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import multiprocessing
import sys
import logging
from .. import compat as cpt
from .proto import framework_pb2

from . import core
Expand Down
1 change: 0 additions & 1 deletion python/paddle/fluid/layers/control_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
check_type,
check_dtype,
)
from ... import compat as cpt
from ..backward import _infer_var_data_type_shape_
from paddle import _C_ops, _legacy_C_ops

Expand Down
1 change: 0 additions & 1 deletion python/paddle/fluid/layers/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from . import tensor
from . import nn
from . import ops
from ... import compat as cpt
from ..data_feeder import check_variable_and_dtype, check_type, check_dtype
import math
import numpy as np
Expand Down
6 changes: 3 additions & 3 deletions python/paddle/fluid/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
from functools import reduce
from functools import cmp_to_key
from .wrapped_decorator import signature_safe_contextmanager
from .. import compat as cpt
import warnings
from paddle import _C_ops, _legacy_C_ops
from ..fluid.framework import (
Expand Down Expand Up @@ -6933,9 +6932,10 @@ def load(self, state_dict):
Examples:
.. code-block:: python

import paddle
import paddle.fluid as fluid
import paddle.compat as cpt

paddle.enable_static()
def mlp(input_x, input_y, hid_dim=128, label_dim=2):
fc_1 = fluid.layers.fc(input=input_x, size=hid_dim)
prediction = fluid.layers.fc(input=[fc_1], size=label_dim, act='softmax')
Expand All @@ -6955,7 +6955,7 @@ def mlp(input_x, input_y, hid_dim=128, label_dim=2):
state_dict = {}
sgd.load(state_dict)
except NotImplementedError as e:
print(cpt.get_exception_message(e))
print(e)
Copy link
Member Author

@SigureMo SigureMo Oct 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一处 API 文档变动:移除了一个示例代码的 compat 模块的使用,为通过示例代码运行添加了 enable_static

"""
raise NotImplementedError(
"load function is not supported by Recompute Optimizer for now"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def runtime_main(test_class, col_type):
model.run_trainer(args)


import paddle.compat as cpt
import socket
from contextlib import closing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ def runtime_main(test_class):
model.run_trainer(args)


import paddle.compat as cpt
import socket
from contextlib import closing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import paddle
import paddle.fluid.core as core
from paddle.static import program_guard, Program
import paddle.compat as cpt
import unittest
import numpy as np
from op_test import OpTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ def runtime_main(test_class, col_type, sub_type):
model.run_trainer(args)


import paddle.compat as cpt
import socket
from contextlib import closing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ def runtime_main(test_class, col_type, sub_type):
model.run_trainer(args)


import paddle.compat as cpt
import socket
from contextlib import closing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ def runtime_main(test_class, col_type, sub_type):
model.run_trainer(args)


import paddle.compat as cpt
import socket
from contextlib import closing

Expand Down
Loading