|
15 | 15 |
|
16 | 16 | # Temporary disable isort to avoid circular import |
17 | 17 | # This can be removed after the circular import is resolved |
18 | | -# isort: skip_file |
19 | 18 | from __future__ import annotations |
20 | 19 |
|
| 20 | +import inspect |
21 | 21 | import os |
22 | 22 | import pickle |
23 | | -import warnings |
24 | 23 | import sys |
25 | | -from collections import OrderedDict |
26 | | -import inspect |
27 | 24 | import threading |
28 | | -from typing import Any |
29 | 25 | import types |
| 26 | +import warnings |
| 27 | +from collections import OrderedDict |
| 28 | +from typing import Any |
30 | 29 |
|
31 | 30 | import paddle |
32 | 31 | from paddle.base import core, dygraph |
|
40 | 39 | program_desc_tracing_guard, |
41 | 40 | switch_to_static_graph, |
42 | 41 | ) |
43 | | -from .dy2static import logging_utils |
44 | | -from .dy2static.convert_call_func import ( |
45 | | - ConversionOptions, |
46 | | - add_ignore_module, |
47 | | -) |
48 | | -from .dy2static.program_translator import ( |
49 | | - ProgramTranslator, |
50 | | - StaticFunction, |
51 | | - ASTStaticFunction, |
52 | | - SymbolicStaticFunction, |
53 | | - unwrap_decorators, |
54 | | -) |
55 | | -from paddle.jit.translated_layer import ( |
56 | | - TranslatedLayer, |
57 | | - INFER_MODEL_SUFFIX, |
58 | | - INFER_PARAMS_SUFFIX, |
59 | | - INFER_PARAMS_INFO_SUFFIX, |
60 | | - INFER_PROPERTY_SUFFIX, |
61 | | -) |
62 | | -from paddle.nn import Layer |
63 | 42 | from paddle.base.executor import Executor, scope_guard |
64 | 43 | from paddle.base.framework import ( |
65 | 44 | Block, |
| 45 | + EagerParamBase, |
| 46 | + Parameter, |
66 | 47 | Program, |
67 | 48 | Variable, |
68 | | - Parameter, |
69 | | - EagerParamBase, |
70 | | -) |
71 | | -from paddle.base.framework import ( |
72 | 49 | _current_expected_place, |
73 | 50 | _dygraph_guard, |
74 | 51 | _dygraph_tracer, |
| 52 | + dygraph_only, |
75 | 53 | ) |
76 | | -from paddle.base.framework import dygraph_only |
77 | 54 | from paddle.base.wrapped_decorator import wrap_decorator |
78 | | -from paddle.static.io import save_inference_model |
79 | 55 | from paddle.framework import in_dynamic_mode |
| 56 | +from paddle.nn import Layer |
| 57 | +from paddle.static.io import save_inference_model |
| 58 | + |
| 59 | +from .dy2static import logging_utils |
| 60 | +from .dy2static.convert_call_func import ConversionOptions, add_ignore_module |
| 61 | +from .dy2static.program_translator import ( |
| 62 | + ASTStaticFunction, |
| 63 | + ProgramTranslator, |
| 64 | + StaticFunction, |
| 65 | + SymbolicStaticFunction, |
| 66 | + convert_to_static, |
| 67 | + unwrap_decorators, |
| 68 | +) |
| 69 | +from .translated_layer import ( |
| 70 | + INFER_MODEL_SUFFIX, |
| 71 | + INFER_PARAMS_INFO_SUFFIX, |
| 72 | + INFER_PARAMS_SUFFIX, |
| 73 | + INFER_PROPERTY_SUFFIX, |
| 74 | + TranslatedLayer, |
| 75 | +) |
80 | 76 |
|
81 | 77 |
|
82 | 78 | def create_program_from_desc(program_desc): |
@@ -166,7 +162,7 @@ def __impl__(*args, **kwargs): |
166 | 162 | "We will just return dygraph output." |
167 | 163 | ) |
168 | 164 | return dygraph_func(*args, **kwargs) |
169 | | - static_func = program_translator.get_func(dygraph_func) |
| 165 | + static_func = convert_to_static(dygraph_func) |
170 | 166 | return static_func(*args, **kwargs) |
171 | 167 |
|
172 | 168 | return __impl__ |
|
0 commit comments