diff --git a/python/paddle/fluid/contrib/slim/quantization/imperative/ptq.py b/python/paddle/fluid/contrib/slim/quantization/imperative/ptq.py index 358e08cf588903887086c0506ef6bc6e36c477bc..4b9af49d064225b51a0bf1a6da14ba7dcde5b55e 100644 --- a/python/paddle/fluid/contrib/slim/quantization/imperative/ptq.py +++ b/python/paddle/fluid/contrib/slim/quantization/imperative/ptq.py @@ -20,7 +20,7 @@ import numpy as np import paddle import paddle.nn.quant.quant_layers as quant_layers from paddle.fluid.log_helper import get_logger -from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX +from paddle.jit.translated_layer import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from . import fuse_utils from . import utils diff --git a/python/paddle/fluid/contrib/slim/quantization/imperative/qat.py b/python/paddle/fluid/contrib/slim/quantization/imperative/qat.py index 9e64ecd96b11bd40e96580cd9432e19669b58408..1c34af18c69147aab420687e691509477c663bdd 100644 --- a/python/paddle/fluid/contrib/slim/quantization/imperative/qat.py +++ b/python/paddle/fluid/contrib/slim/quantization/imperative/qat.py @@ -27,7 +27,7 @@ from paddle.fluid.framework import IrGraph from paddle.fluid.executor import Executor, global_scope from paddle.fluid.param_attr import ParamAttr from paddle.fluid.initializer import Constant -from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX +from paddle.jit.translated_layer import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.fluid.io import load_inference_model, save_inference_model from ..quantization_pass import ReplaceFakeQuantDequantPass, QuantWeightPass from paddle.fluid.log_helper import get_logger diff --git a/python/paddle/fluid/contrib/slim/tests/test_imperative_out_scale.py b/python/paddle/fluid/contrib/slim/tests/test_imperative_out_scale.py index e978b636452078915b30a74b1a3383929d94b1ee..ccfd85bf89ed4b7fc8ca7e02f830aca061088adf 100644 --- a/python/paddle/fluid/contrib/slim/tests/test_imperative_out_scale.py +++ b/python/paddle/fluid/contrib/slim/tests/test_imperative_out_scale.py @@ -28,7 +28,7 @@ from paddle.fluid.optimizer import AdamOptimizer from paddle.fluid.framework import IrGraph, _test_eager_guard from paddle.fluid.contrib.slim.quantization import ImperativeQuantAware from paddle.nn import Sequential -from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX +from paddle.jit.translated_layer import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.nn.layer import ReLU, LeakyReLU, Sigmoid, Softmax, PReLU from paddle.nn import Linear, Conv2D, Softmax, BatchNorm2D, MaxPool2D from paddle.fluid.log_helper import get_logger diff --git a/python/paddle/fluid/contrib/slim/tests/test_imperative_qat.py b/python/paddle/fluid/contrib/slim/tests/test_imperative_qat.py index cbf5b30976d8c73a4c298224e11c5a67da48ed64..6169d1db1e8b900ca64760e0c78a6f6cd9a5b30c 100644 --- a/python/paddle/fluid/contrib/slim/tests/test_imperative_qat.py +++ b/python/paddle/fluid/contrib/slim/tests/test_imperative_qat.py @@ -28,7 +28,7 @@ from paddle.fluid.contrib.slim.quantization import ImperativeQuantAware from paddle.nn import Sequential from paddle.nn import Linear, Conv2D, Softmax, Conv2DTranspose from paddle.fluid.log_helper import get_logger -from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX +from paddle.jit.translated_layer import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.nn.quant.quant_layers import ( QuantizedConv2D, QuantizedConv2DTranspose, diff --git a/python/paddle/fluid/contrib/slim/tests/test_imperative_qat_lsq.py b/python/paddle/fluid/contrib/slim/tests/test_imperative_qat_lsq.py index caf9648b3c3369f966e41f7e68f60c5f77618c04..f56c90f5f492d8fc3d70319ca65958807db23182 100644 --- a/python/paddle/fluid/contrib/slim/tests/test_imperative_qat_lsq.py +++ b/python/paddle/fluid/contrib/slim/tests/test_imperative_qat_lsq.py @@ -33,7 +33,7 @@ from paddle.nn import Sequential from paddle.nn import ReLU, ReLU6, LeakyReLU, Sigmoid, Softmax, PReLU from paddle.nn import Linear, Conv2D, Softmax, BatchNorm2D, MaxPool2D from paddle.fluid.log_helper import get_logger -from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX +from paddle.jit.translated_layer import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.nn.quant.quant_layers import ( QuantizedConv2D, QuantizedConv2DTranspose, diff --git a/python/paddle/fluid/contrib/slim/tests/test_imperative_qat_matmul.py b/python/paddle/fluid/contrib/slim/tests/test_imperative_qat_matmul.py index b584204f4f18013bb20e66e8a0cb38dcbd006239..75822fe831d8378a5ae4e46731792c78a738b81e 100644 --- a/python/paddle/fluid/contrib/slim/tests/test_imperative_qat_matmul.py +++ b/python/paddle/fluid/contrib/slim/tests/test_imperative_qat_matmul.py @@ -33,7 +33,7 @@ from paddle.nn import Sequential from paddle.nn import ReLU, ReLU6, LeakyReLU, Sigmoid, Softmax, PReLU from paddle.nn import Linear, Conv2D, Softmax, BatchNorm2D, MaxPool2D from paddle.fluid.log_helper import get_logger -from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX +from paddle.jit.translated_layer import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.nn.quant.quant_layers import ( QuantizedConv2D, QuantizedMatmul, diff --git a/python/paddle/fluid/contrib/slim/tests/test_imperative_skip_op.py b/python/paddle/fluid/contrib/slim/tests/test_imperative_skip_op.py index 9b8ed24af2e551077b0294fed6868b218c9b122c..db014aef2df1b51bd5c0595006ae12266bd0ccad 100644 --- a/python/paddle/fluid/contrib/slim/tests/test_imperative_skip_op.py +++ b/python/paddle/fluid/contrib/slim/tests/test_imperative_skip_op.py @@ -23,7 +23,7 @@ import paddle.fluid.layers as layers from paddle.fluid import core from paddle.fluid.optimizer import AdamOptimizer from paddle.fluid.contrib.slim.quantization import ImperativeQuantAware -from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX +from paddle.jit.translated_layer import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.nn.layer import ReLU, LeakyReLU, Sigmoid, Softmax, ReLU6 from paddle.nn import Linear, Conv2D, Softmax, BatchNorm from paddle.fluid.log_helper import get_logger diff --git a/python/paddle/fluid/dygraph/__init__.py b/python/paddle/fluid/dygraph/__init__.py index 397c305c23e040955a12ddfc9683dc1daad0ab32..0064bd901071134efa149a6494691cc24ef7ba03 100644 --- a/python/paddle/fluid/dygraph/__init__.py +++ b/python/paddle/fluid/dygraph/__init__.py @@ -36,10 +36,6 @@ from .checkpoint import * from . import learning_rate_scheduler from .learning_rate_scheduler import * - -from . import io -from .io import * - from . import static_runner from .static_runner import StaticModelRunner @@ -56,5 +52,4 @@ __all__ += nn.__all__ __all__ += parallel.__all__ __all__ += checkpoint.__all__ __all__ += learning_rate_scheduler.__all__ -__all__ += io.__all__ __all__ += amp.__all__ diff --git a/python/paddle/fluid/dygraph/checkpoint.py b/python/paddle/fluid/dygraph/checkpoint.py index d3e91295d43a29654f2b21bd11382503adf21818..8103f1f82bbe5790a465773e7fc339fe56716cd6 100644 --- a/python/paddle/fluid/dygraph/checkpoint.py +++ b/python/paddle/fluid/dygraph/checkpoint.py @@ -32,7 +32,7 @@ import warnings from .. import core from .base import guard from paddle.jit.api import _SaveLoadConfig -from paddle.fluid.dygraph.io import ( +from paddle.jit.translated_layer import ( _construct_program_holders, _construct_params_and_buffers, ) diff --git a/python/paddle/fluid/dygraph/static_runner.py b/python/paddle/fluid/dygraph/static_runner.py index 27cd5fd6dcc21ddeb7a2774a1542a9e129d1b4ea..8233d6be4455f0f42164c9e751b6a91f9055c957 100644 --- a/python/paddle/fluid/dygraph/static_runner.py +++ b/python/paddle/fluid/dygraph/static_runner.py @@ -13,7 +13,7 @@ # limitations under the License. from paddle.jit.api import _SaveLoadConfig -from paddle.fluid.dygraph.io import TranslatedLayer +from paddle.jit.translated_layer import TranslatedLayer # NOTE: This class will be deprecated later. diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_bert.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_bert.py index cc6b8a7847969b781ceeb2c4bdc9713961580941..1fccfb70a26a901776336dd0c4b442c9d8af8d7c 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_bert.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_bert.py @@ -24,8 +24,8 @@ 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.jit import ProgramTranslator +from paddle.jit.translated_layer import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX program_translator = ProgramTranslator() place = ( diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_bmn.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_bmn.py index aba2f88bc517c72f4b614acdb1edc0b7134dde9d..56f0f6e9c29d42963141bbf0c272f20eb502ac8f 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_bmn.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_bmn.py @@ -24,8 +24,8 @@ import paddle import paddle.fluid as fluid from paddle.fluid import ParamAttr from paddle.fluid.dygraph import to_variable -from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.jit import ProgramTranslator, to_static +from paddle.jit.translated_layer import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX SEED = 2000 DATATYPE = 'float32' diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_lac.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_lac.py index 1ec320317d4c54fbab3a21fa62e53f393a74623c..80e1a12e5c37513a51bcadf45196686031036be4 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_lac.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_lac.py @@ -26,10 +26,10 @@ import paddle import paddle.fluid as fluid from paddle import _legacy_C_ops from paddle.fluid.dygraph import to_variable -from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.fluid.framework import _non_static_mode from paddle.jit import ProgramTranslator from paddle.jit.api import declarative +from paddle.jit.translated_layer import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX SEED = 2020 diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mnist.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mnist.py index b44bd03c1970d27e8390c0127ebfc39cb6e11662..42c541293422184d96667eb5e40b5d185a210136 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mnist.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mnist.py @@ -24,8 +24,8 @@ import paddle import paddle.fluid as fluid from paddle.fluid.dygraph import to_variable 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.optimizer import AdamOptimizer +from paddle.jit.translated_layer import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.nn import Linear SEED = 2020 diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py index 9b803ff1130f205cbc167d9f0ca96a7b4aeb1f53..2995757660e9be0131b0436923cb46e9925c5e0e 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_mobile_net.py @@ -22,11 +22,11 @@ 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.initializer import MSRA from paddle.fluid.param_attr import ParamAttr from paddle.jit import ProgramTranslator from paddle.jit.api import declarative +from paddle.jit.translated_layer import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.nn import BatchNorm, Linear # Note: Set True to eliminate randomness. diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet.py index 8163bfc0cfc68bfe37d703aca7d2f2614f843c67..04cc9ce7ebe5315f0ca442d667d1a74aada6e87d 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet.py @@ -23,8 +23,8 @@ 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.jit import ProgramTranslator +from paddle.jit.translated_layer import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.nn import BatchNorm SEED = 2020 diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet_v2.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet_v2.py index ee01b71e29c7878b4a84b28d43e9dfff99bd7ef2..65fe63e523fb873af2c68f70481e622a2eae3a98 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet_v2.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_resnet_v2.py @@ -231,10 +231,10 @@ class TestResnet(unittest.TestCase): self.temp_dir.name, "./inference/resnet_v2" ) self.model_filename = ( - "resnet_v2" + paddle.fluid.dygraph.io.INFER_MODEL_SUFFIX + "resnet_v2" + paddle.jit.translated_layer.INFER_MODEL_SUFFIX ) self.params_filename = ( - "resnet_v2" + paddle.fluid.dygraph.io.INFER_PARAMS_SUFFIX + "resnet_v2" + paddle.jit.translated_layer.INFER_PARAMS_SUFFIX ) self.dy_state_dict_save_path = os.path.join( self.temp_dir.name, "./resnet_v2.dygraph" diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_save_inference_model.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_save_inference_model.py index 461e9791d23ad3c153af35ff50e8edb4632f48eb..dfea94e6fce2560d040c8e8d29f92e15eff383e4 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_save_inference_model.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_save_inference_model.py @@ -20,10 +20,10 @@ import numpy as np import paddle import paddle.fluid as fluid -from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.jit import ProgramTranslator from paddle.jit.api import declarative from paddle.jit.dy2static.partial_program import partial_program_from +from paddle.jit.translated_layer import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX SEED = 2020 diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_se_resnet.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_se_resnet.py index f46377d6244319e877f25d9d34d152a29d953ea0..6a841b56f1392e56ec98bc958d92ac82596925f3 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_se_resnet.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_se_resnet.py @@ -25,9 +25,9 @@ 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.jit import ProgramTranslator from paddle.jit.api import declarative +from paddle.jit.translated_layer import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.nn import BatchNorm, Linear SEED = 2020 diff --git a/python/paddle/fluid/tests/unittests/test_jit_save_load.py b/python/paddle/fluid/tests/unittests/test_jit_save_load.py index dce6e9f63eaa953f2b4864bd0072b8f344f0234d..2b2bfabd360b1f95b3f0ff062396ca6b7aca0a1d 100644 --- a/python/paddle/fluid/tests/unittests/test_jit_save_load.py +++ b/python/paddle/fluid/tests/unittests/test_jit_save_load.py @@ -24,9 +24,9 @@ import numpy as np import paddle import paddle.fluid as fluid from paddle.fluid import unique_name -from paddle.fluid.dygraph.io import INFER_PARAMS_INFO_SUFFIX from paddle.fluid.layers.utils import flatten from paddle.jit.api import declarative +from paddle.jit.translated_layer import INFER_PARAMS_INFO_SUFFIX from paddle.nn import Linear from paddle.static import InputSpec diff --git a/python/paddle/framework/io.py b/python/paddle/framework/io.py index 7d1803c45ed29b6146730dfad11f7982bc3f9e16..d1ebcc28f465e2a43d91627c3db8f1ee3a4b7e27 100644 --- a/python/paddle/framework/io.py +++ b/python/paddle/framework/io.py @@ -27,12 +27,6 @@ import paddle # deprecated module import from paddle import fluid from paddle.fluid import core -from paddle.fluid.dygraph.io import ( - INFER_MODEL_SUFFIX, - INFER_PARAMS_SUFFIX, - _construct_params_and_buffers, - _construct_program_holders, -) from paddle.fluid.framework import ( EagerParamBase, ParamBase, @@ -52,6 +46,12 @@ from paddle.fluid.io import ( _unpack_saved_dict, ) from paddle.jit.api import _SaveLoadConfig +from paddle.jit.translated_layer import ( + INFER_MODEL_SUFFIX, + INFER_PARAMS_SUFFIX, + _construct_params_and_buffers, + _construct_program_holders, +) __all__ = [] diff --git a/python/paddle/hapi/model.py b/python/paddle/hapi/model.py index 116f433c8f029748975fda050a069b39ea925707..14943cfc019daa9e93775347097a93506511352e 100644 --- a/python/paddle/hapi/model.py +++ b/python/paddle/hapi/model.py @@ -30,7 +30,6 @@ from paddle.autograd import no_grad from paddle.distributed.fleet.base import role_maker from paddle.fluid import core from paddle.fluid.dygraph.base import to_variable -from paddle.fluid.dygraph.io import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.fluid.dygraph.parallel import ParallelEnv from paddle.fluid.executor import global_scope from paddle.fluid.framework import Variable @@ -40,6 +39,7 @@ from paddle.fluid.io import is_belong_to_optimizer from paddle.fluid.layers import collective from paddle.fluid.layers.utils import flatten from paddle.io import DataLoader, Dataset, DistributedBatchSampler +from paddle.jit.translated_layer import INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX from paddle.metric import Metric from paddle.static import InputSpec as Input diff --git a/python/paddle/jit/__init__.py b/python/paddle/jit/__init__.py index 35d1be0aaf7da008affde9b1c0b67e664311253d..c907efc02d12305055ec4685ac364f33fea57203 100644 --- a/python/paddle/jit/__init__.py +++ b/python/paddle/jit/__init__.py @@ -17,11 +17,11 @@ from .api import save from .api import load from .api import declarative as to_static from .api import not_to_static -from .api import TranslatedLayer from .dy2static.logging_utils import set_code_level, set_verbosity from . import dy2static from .dy2static.program_translator import ProgramTranslator +from .translated_layer import TranslatedLayer __all__ = [ # noqa 'save', diff --git a/python/paddle/jit/api.py b/python/paddle/jit/api.py index fff8e37e60d5f6862e3d6c425d28172919c6960d..df555f6a24494ed608151b025d6b829f0cc72034 100644 --- a/python/paddle/jit/api.py +++ b/python/paddle/jit/api.py @@ -47,7 +47,7 @@ from .dy2static.program_translator import ( StaticFunction, unwrap_decorators, ) -from paddle.fluid.dygraph.io import ( +from paddle.jit.translated_layer import ( TranslatedLayer, INFER_MODEL_SUFFIX, INFER_PARAMS_SUFFIX, diff --git a/python/paddle/jit/dy2static/function_spec.py b/python/paddle/jit/dy2static/function_spec.py index bcafd5b751f8e3e330420b3690fe70d64887d6ed..7db8dd2aad0c85753b303d3afb5673b9dedcedc6 100644 --- a/python/paddle/jit/dy2static/function_spec.py +++ b/python/paddle/jit/dy2static/function_spec.py @@ -21,8 +21,8 @@ import paddle from paddle.fluid import core from paddle.fluid.dygraph import layers from paddle.fluid.dygraph.base import switch_to_static_graph -from paddle.fluid.dygraph.io import TranslatedLayer from paddle.fluid.layers.utils import flatten, pack_sequence_as +from paddle.jit.translated_layer import TranslatedLayer from . import logging_utils from .utils import ( diff --git a/python/paddle/fluid/dygraph/io.py b/python/paddle/jit/translated_layer.py similarity index 99% rename from python/paddle/fluid/dygraph/io.py rename to python/paddle/jit/translated_layer.py index 1350493bae332d8c24a23f4a63bd80c501634206..166c43143406c8a2192efed1ddc1efd9ce0ccf23 100644 --- a/python/paddle/fluid/dygraph/io.py +++ b/python/paddle/jit/translated_layer.py @@ -14,27 +14,24 @@ import os import pickle + import numpy as np import paddle -from paddle.fluid import core -from paddle.fluid import framework -from paddle.fluid import backward -from paddle.fluid import unique_name +from paddle import _legacy_C_ops +from paddle.fluid import backward, core, framework, unique_name from paddle.fluid.dygraph import layers -from paddle.fluid.layers import nn -from paddle.fluid.layers.utils import _hash_with_id from paddle.fluid.dygraph.base import switch_to_static_graph -from paddle.fluid.framework import _non_static_mode, OpProtoHolder from paddle.fluid.executor import ( - _is_enable_standalone_executor, _is_dy2st_enable_standalone_executor, + _is_enable_standalone_executor, ) +from paddle.fluid.framework import OpProtoHolder, _non_static_mode +from paddle.fluid.layers.utils import _hash_with_id from paddle.jit.dy2static.partial_program import ( - add_build_strategy_for, LazyInitialized, + add_build_strategy_for, ) -from paddle import _C_ops, _legacy_C_ops __all__ = ['TranslatedLayer'] @@ -58,7 +55,6 @@ def _load_program_desc(model_file_path): raise ValueError( "Unsupported program version: %d\n" % program_desc._version() ) - return program_desc @@ -1193,7 +1189,7 @@ def _append_block( dest_program._sync_with_cpp() offset_block_idx = dest_program.num_blocks - 1 - + parent_idx = 0 if src_program_desc.num_blocks() > 1: for src_block_idx in range(1, src_program_desc.num_blocks()): src_block = src_program_desc.block(src_block_idx)