From b55f7326a5d6b45efe9092bde7607e45c9dc3ad8 Mon Sep 17 00:00:00 2001 From: YuanRisheng Date: Fri, 16 Dec 2022 17:57:51 +0800 Subject: [PATCH] [Remove Fluid]move TranslatedLayer from fluid dir to jit dir (#49065) * move translated layer * fix build bugs * fix unittest bug * trigger ci --- .../slim/quantization/imperative/ptq.py | 2 +- .../slim/quantization/imperative/qat.py | 2 +- .../slim/tests/test_imperative_out_scale.py | 2 +- .../contrib/slim/tests/test_imperative_qat.py | 2 +- .../slim/tests/test_imperative_qat_lsq.py | 2 +- .../slim/tests/test_imperative_qat_matmul.py | 2 +- .../slim/tests/test_imperative_skip_op.py | 2 +- python/paddle/fluid/dygraph/__init__.py | 5 ----- python/paddle/fluid/dygraph/checkpoint.py | 2 +- python/paddle/fluid/dygraph/static_runner.py | 2 +- .../unittests/dygraph_to_static/test_bert.py | 2 +- .../unittests/dygraph_to_static/test_bmn.py | 2 +- .../unittests/dygraph_to_static/test_lac.py | 2 +- .../unittests/dygraph_to_static/test_mnist.py | 2 +- .../dygraph_to_static/test_mobile_net.py | 2 +- .../dygraph_to_static/test_resnet.py | 2 +- .../dygraph_to_static/test_resnet_v2.py | 4 ++-- .../test_save_inference_model.py | 2 +- .../dygraph_to_static/test_se_resnet.py | 2 +- .../tests/unittests/test_jit_save_load.py | 2 +- python/paddle/framework/io.py | 12 +++++------ python/paddle/hapi/model.py | 2 +- python/paddle/jit/__init__.py | 2 +- python/paddle/jit/api.py | 2 +- python/paddle/jit/dy2static/function_spec.py | 2 +- .../dygraph/io.py => jit/translated_layer.py} | 20 ++++++++----------- 26 files changed, 38 insertions(+), 47 deletions(-) rename python/paddle/{fluid/dygraph/io.py => jit/translated_layer.py} (99%) diff --git a/python/paddle/fluid/contrib/slim/quantization/imperative/ptq.py b/python/paddle/fluid/contrib/slim/quantization/imperative/ptq.py index 358e08cf58..4b9af49d06 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 9e64ecd96b..1c34af18c6 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 e978b63645..ccfd85bf89 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 cbf5b30976..6169d1db1e 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 caf9648b3c..f56c90f5f4 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 b584204f4f..75822fe831 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 9b8ed24af2..db014aef2d 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 397c305c23..0064bd9010 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 d3e91295d4..8103f1f82b 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 27cd5fd6dc..8233d6be44 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 cc6b8a7847..1fccfb70a2 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 aba2f88bc5..56f0f6e9c2 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 1ec320317d..80e1a12e5c 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 b44bd03c19..42c5412934 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 9b803ff113..2995757660 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 8163bfc0cf..04cc9ce7eb 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 ee01b71e29..65fe63e523 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 461e9791d2..dfea94e6fc 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 f46377d624..6a841b56f1 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 dce6e9f63e..2b2bfabd36 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 7d1803c45e..d1ebcc28f4 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 116f433c8f..14943cfc01 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 35d1be0aaf..c907efc02d 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 fff8e37e60..df555f6a24 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 bcafd5b751..7db8dd2aad 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 1350493bae..166c431434 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) -- GitLab