Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR types
Others
PR changes
Others
Describe
Background
Paddle 2.0 uses dygraph mode by default. PR #27443 has changed the default mode from static mode to dygraph mode.
However, there are some problems because of unittests are implemented based on static mode. It will cause conflicts when dygraph mode is opened by default.
In order to pass CI, before the unittest runs, PR #27443 switches the mode to static mode. The specific method is to modify
test_runner.py
, and the execution environment is static mode ifctest
is used to run.Problem
the behavior of using
ctest
andpython
to run unittests is inconsistent.ctest
is static modepython
is dygraph modedevelopers need to develop unittest in static mode
Because the execution environment of
ctest
is static mode. In order to pass CI, developers need to develop unittest in static mode, it's inconsistent with the default mode of Paddle.Solution
Add a
static_mode_white_list
. The white list saves the tesing modules whose execution environment is static mode.ctest
will change dygraph mode to static mode only if the test module is instatic_mode_white_list
.static_mode_white_list
, use static mode to runctest
static_mode_white_list
, use dygraph mode to runctest
Thus, subsequent developers can use the dygraph mode to develop unittest.
Next task
static_mode_white_list
can't solve the problem of inconsistent environment when usingctest
andpython
to execute.Unittest modules in
static_mode_white_list
need to be modified so that they can be executed in dygraph mode by default.For example, we can add
paddle.enable_static
in every unittest modules. This work will be discussed later.