|
|
@ -25,7 +25,7 @@ import paddle
|
|
|
|
from paddle.fluid import core
|
|
|
|
from paddle.fluid import core
|
|
|
|
from paddle.fluid.compiler import BuildStrategy, CompiledProgram, ExecutionStrategy
|
|
|
|
from paddle.fluid.compiler import BuildStrategy, CompiledProgram, ExecutionStrategy
|
|
|
|
from paddle.fluid.data_feeder import check_type
|
|
|
|
from paddle.fluid.data_feeder import check_type
|
|
|
|
from paddle.fluid.layers.utils import flatten
|
|
|
|
from paddle.fluid.layers.utils import flatten, pack_sequence_as
|
|
|
|
from paddle.fluid.dygraph.base import program_desc_tracing_guard, switch_to_static_graph
|
|
|
|
from paddle.fluid.dygraph.base import program_desc_tracing_guard, switch_to_static_graph
|
|
|
|
from paddle.fluid.dygraph.dygraph_to_static import logging_utils
|
|
|
|
from paddle.fluid.dygraph.dygraph_to_static import logging_utils
|
|
|
|
from paddle.fluid.dygraph.dygraph_to_static.convert_call_func import ConversionOptions, CONVERSION_OPTIONS
|
|
|
|
from paddle.fluid.dygraph.dygraph_to_static.convert_call_func import ConversionOptions, CONVERSION_OPTIONS
|
|
|
@ -681,6 +681,11 @@ def save(layer, path, input_spec=None, **configs):
|
|
|
|
inner_input_spec)
|
|
|
|
inner_input_spec)
|
|
|
|
elif 'forward' == attr_func:
|
|
|
|
elif 'forward' == attr_func:
|
|
|
|
# transform in jit.save, if input_spec is incomplete, declarative will throw error
|
|
|
|
# transform in jit.save, if input_spec is incomplete, declarative will throw error
|
|
|
|
|
|
|
|
# inner_input_spec is list[InputSpec], it should be packed with same sturcture
|
|
|
|
|
|
|
|
# as original input_spec here.
|
|
|
|
|
|
|
|
if inner_input_spec:
|
|
|
|
|
|
|
|
inner_input_spec = pack_sequence_as(input_spec,
|
|
|
|
|
|
|
|
inner_input_spec)
|
|
|
|
static_forward = declarative(
|
|
|
|
static_forward = declarative(
|
|
|
|
inner_layer.forward, input_spec=inner_input_spec)
|
|
|
|
inner_layer.forward, input_spec=inner_input_spec)
|
|
|
|
concrete_program = static_forward.concrete_program
|
|
|
|
concrete_program = static_forward.concrete_program
|
|
|
|