Skip to content
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

[Fluid Clean]Migrate utils files and delete dygraph_to_static dir #48566

Merged
merged 6 commits into from
Dec 1, 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
2 changes: 1 addition & 1 deletion python/paddle/fluid/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ def patch_program_cache(ipu_strategy):
ProgramCache,
MAX_TRACED_PROGRAM_COUNT,
)
from ..fluid.dygraph.dygraph_to_static import logging_utils
from paddle.jit.dy2static import logging_utils
from paddle.jit.dy2static.partial_program import (
partial_program_from,
)
Expand Down
2 changes: 0 additions & 2 deletions python/paddle/fluid/dygraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
from . import static_runner
from .static_runner import StaticModelRunner

from . import dygraph_to_static

from . import rnn
from .rnn import *

Expand Down
28 changes: 0 additions & 28 deletions python/paddle/fluid/dygraph/dygraph_to_static/__init__.py

This file was deleted.

This file was deleted.

10 changes: 5 additions & 5 deletions python/paddle/fluid/layers/control_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ def select_input(inputs, mask):


def select_input_with_buildin_type(inputs, mask, name):
from paddle.fluid.dygraph.dygraph_to_static.variable_trans_func import (
from paddle.jit.dy2static.variable_trans_func import (
to_static_variable,
)
from paddle.fluid.dygraph.dygraph_to_static.utils import UndefinedVar
from paddle.jit.dy2static.utils import UndefinedVar

false_var, true_var = inputs

Expand Down Expand Up @@ -1484,7 +1484,7 @@ def _deal_with_undefined_var(output_vars, loop_vars):
3. UndefinedVar = List(int) # create a list of variable
4. UndefinedVar = value # create a variable
"""
from paddle.fluid.dygraph.dygraph_to_static.utils import (
from paddle.jit.dy2static.utils import (
UndefinedVar,
create_undefined_variable,
)
Expand Down Expand Up @@ -2552,7 +2552,7 @@ def merge_every_var_list(false_vars, true_vars, name):


def change_none_to_undefinedvar(nest1, nest2):
from paddle.fluid.dygraph.dygraph_to_static.utils import UndefinedVar
from paddle.jit.dy2static.utils import UndefinedVar

def map_fn(x):
if x is None:
Expand Down Expand Up @@ -2588,7 +2588,7 @@ def expand_undefined_var(nest1, nest2, names):
nest2: Var2, ([1,2,3,4], UndefinedVar)
In this case, we should not expand recursively.
"""
from paddle.fluid.dygraph.dygraph_to_static.utils import UndefinedVar
from paddle.jit.dy2static.utils import UndefinedVar
from paddle.jit.dy2static.return_transformer import (
RETURN_VALUE_PREFIX,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph.dygraph_to_static.utils import ast_to_func
from paddle.jit.dy2static.utils import ast_to_func
from paddle.utils import gast


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import paddle.fluid.dygraph as dygraph
from paddle import to_tensor
from paddle.fluid.dygraph import to_variable
from paddle.fluid.dygraph.dygraph_to_static.utils import is_dygraph_api
from paddle.jit.api import dygraph_to_static_func
from paddle.jit.dy2static.utils import is_dygraph_api
from paddle.utils import gast

SEED = 2020
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph.dygraph_to_static.utils import Dygraph2StaticException
from paddle.jit.api import declarative
from paddle.jit.dy2static.program_translator import ProgramTranslator
from paddle.jit.dy2static.utils import Dygraph2StaticException

SEED = 2020
np.random.seed(SEED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
from numpy import append

import paddle
from paddle.fluid.dygraph.dygraph_to_static.utils import (
FunctionNameLivenessAnalysis,
)
from paddle.jit.dy2static.utils import FunctionNameLivenessAnalysis
from paddle.utils import gast

global_a = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph.dygraph_to_static import error
from paddle.fluid.dygraph.dygraph_to_static.origin_info import unwrap
from paddle.jit.dy2static import error
from paddle.jit.dy2static.origin_info import unwrap


def inner_func():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from test_declarative import foo_func

import paddle
from paddle.fluid.dygraph.dygraph_to_static.function_spec import FunctionSpec
from paddle.jit.dy2static.function_spec import FunctionSpec
from paddle.static import InputSpec

paddle.enable_static()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@

import paddle
import paddle.fluid.core as core
from paddle.fluid.dygraph.dygraph_to_static.utils import Dygraph2StaticException
from paddle.jit.api import declarative
from paddle.jit.dy2static.program_translator import ProgramTranslator
from paddle.jit.dy2static.utils import Dygraph2StaticException

np.random.seed(1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from unittest import mock

import paddle
from paddle.fluid.dygraph.dygraph_to_static import logging_utils
from paddle.jit.dy2static import logging_utils
from paddle.utils import gast


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import sys
import unittest

from paddle.fluid.dygraph.dygraph_to_static.origin_info import (
from paddle.jit.api import declarative
from paddle.jit.dy2static import DygraphToStaticAst
from paddle.jit.dy2static.origin_info import (
ORIGI_INFO,
Location,
OriginInfo,
Expand All @@ -25,9 +27,7 @@
inspect,
unwrap,
)
from paddle.fluid.dygraph.dygraph_to_static.utils import ast_to_func
from paddle.jit.api import declarative
from paddle.jit.dy2static import DygraphToStaticAst
from paddle.jit.dy2static.utils import ast_to_func


def simple_func(x):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import paddle
import paddle.fluid as fluid
import paddle.jit.dy2static as _jst
from paddle.fluid.dygraph.dygraph_to_static.utils import func_to_source_code
from paddle.jit import ProgramTranslator
from paddle.jit.api import declarative
from paddle.jit.dy2static.utils import func_to_source_code
from paddle.utils import gast

np.random.seed(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import paddle
import paddle.fluid as fluid
import paddle.fluid.core as core
from paddle.fluid.dygraph.dygraph_to_static.utils import Dygraph2StaticException
from paddle.jit import ProgramTranslator, to_static
from paddle.jit.dy2static.utils import Dygraph2StaticException

SEED = 2020
np.random.seed(SEED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import numpy as np

import paddle
from paddle.fluid.dygraph.dygraph_to_static.utils import func_to_source_code
from paddle.jit.dy2static.program_translator import StaticFunction
from paddle.jit.dy2static.utils import func_to_source_code


class Net(paddle.nn.Layer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import unittest

from paddle.fluid.dygraph.dygraph_to_static.utils import GetterSetterHelper
from paddle.jit.dy2static.utils import GetterSetterHelper

vars = [1, 2, 3, 4, 5]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@

import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph.dygraph_to_static import (
NodeVarType,
StaticAnalysisVisitor,
)
from paddle.jit.dy2static import NodeVarType, StaticAnalysisVisitor
from paddle.utils import gast


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
import types
import unittest

from paddle.fluid.dygraph.dygraph_to_static.utils import (
index_in_list,
is_paddle_func,
)
from paddle.jit.dy2static.utils import index_in_list, is_paddle_func


class TestIndexInList(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@

import unittest

from paddle.fluid.dygraph.dygraph_to_static.utils import ast_to_source_code
from paddle.fluid.dygraph.dygraph_to_static.variable_trans_func import (
create_fill_constant_node,
)
from paddle.jit.dy2static.utils import ast_to_source_code
from paddle.jit.dy2static.variable_trans_func import create_fill_constant_node


class TestVariableTransFunc(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/fluid/tests/unittests/op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import paddle.fluid.core as core
from paddle.fluid import unique_name
from paddle.fluid.backward import append_backward
from paddle.fluid.dygraph.dygraph_to_static.utils import parse_arg_and_kwargs
from paddle.fluid.executor import Executor
from paddle.fluid.framework import (
OpProtoHolder,
Expand All @@ -43,6 +42,7 @@
_test_eager_guard,
)
from paddle.fluid.op import Operator
from paddle.jit.dy2static.utils import parse_arg_and_kwargs

sys.path.append(os.path.abspath(os.path.dirname(__file__)))
from testsuite import append_input_output, append_loss_ops, create_op, set_input
Expand Down
4 changes: 1 addition & 3 deletions python/paddle/fluid/tests/unittests/test_input_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@

import paddle
import paddle.fluid as fluid
from paddle.fluid.dygraph.dygraph_to_static.utils import (
_compatible_non_tensor_spec,
)
from paddle.fluid.framework import convert_np_dtype_to_dtype_
from paddle.jit.dy2static.utils import _compatible_non_tensor_spec
from paddle.static import InputSpec


Expand Down
2 changes: 1 addition & 1 deletion python/paddle/fluid/variable_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ def _setitem_for_tensor_array(var, item, value):
not _non_static_mode()
), "setitem for tensor_array must be called in static graph mode."
if isinstance(item, (Variable, int)):
from paddle.fluid.dygraph.dygraph_to_static.variable_trans_func import (
from paddle.jit.dy2static.variable_trans_func import (
to_static_variable,
)
from paddle import cast
Expand Down
Loading