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

Pr54202 #7

Merged
merged 3 commits into from
Jun 16, 2023
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
5 changes: 3 additions & 2 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ else()
${PADDLE_BINARY_DIR}/python
COMMAND cp -r ${PADDLE_SOURCE_DIR}/test ${PADDLE_BINARY_DIR}/
COMMAND env ${py_env} ${PYTHON_EXECUTABLE} setup.py bdist_wheel
COMMAND ln -sf ${PADDLE_SOURCE_DIR}/python/paddle/jit/PaddleSOT/sot ${PADDLE_BINARY_DIR}/python/paddle/jit/sot
COMMAND ln -sf ${PADDLE_SOURCE_DIR}/python/paddle/jit/PaddleSOT/sot
${PADDLE_BINARY_DIR}/python/paddle/jit/sot
COMMENT "Packing whl packages------>>>"
DEPENDS copy_libpaddle ${FLUID_CORE} framework_py_proto profiler_py_proto
pass_desc_py_proto ${PY_FILES})
Expand Down Expand Up @@ -169,4 +170,4 @@ if(LINUX
FATAL_ERROR "patchelf not found, please install it.\n"
"For Ubuntu, the command is: apt-get install -y patchelf.")
endif()
endif()
endif()
2 changes: 2 additions & 0 deletions test/dygraph_to_static/test_mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from time import time

import numpy as np
from dygraph_to_static_util import ast_only_test
from predictor_utils import PredictorTools

import paddle
Expand Down Expand Up @@ -158,6 +159,7 @@ def train_static(self):
def train_dygraph(self):
return self.train(to_static=False)

@ast_only_test
def test_mnist_to_static(self):
dygraph_loss = self.train_dygraph()
static_loss = self.train_static()
Expand Down
2 changes: 2 additions & 0 deletions test/dygraph_to_static/test_mobile_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import unittest

import numpy as np
from dygraph_to_static_util import ast_only_test
from predictor_utils import PredictorTools

import paddle
Expand Down Expand Up @@ -713,6 +714,7 @@ def assert_same_predict(self, model_name):
),
)

@ast_only_test
def test_mobile_net(self):
# MobileNet-V1
self.assert_same_loss("MobileNetV1")
Expand Down
4 changes: 4 additions & 0 deletions test/dygraph_to_static/test_op_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import unittest

from dygraph_to_static_util import ast_only_test

import paddle
from paddle.static import InputSpec

Expand Down Expand Up @@ -75,6 +77,7 @@ def expected_results(self):
'elementwise_sub': self.sub_attrs,
}

@ast_only_test
def test_set_op_attrs(self):
net = NetWithOpAttr(self.in_num, self.out_num)
# set attrs
Expand Down Expand Up @@ -116,6 +119,7 @@ def check_op_attrs(self, main_program):
else:
self.assertEqual(op_val, expect_val)

@ast_only_test
def test_set_op_attrs_with_sub_block(self):
net = NetWithOpAttr(self.in_num, self.out_num)
# set attrs
Expand Down
5 changes: 5 additions & 0 deletions test/dygraph_to_static/test_resnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import unittest

import numpy as np
from dygraph_to_static_util import ast_only_test
from predictor_utils import PredictorTools

import paddle
Expand Down Expand Up @@ -413,6 +414,7 @@ def verify_predict(self):
),
)

@ast_only_test
def test_resnet(self):
static_loss = self.train(to_static=True)
dygraph_loss = self.train(to_static=False)
Expand All @@ -426,6 +428,7 @@ def test_resnet(self):
)
self.verify_predict()

@ast_only_test
def test_resnet_composite_backward(self):
core._set_prim_backward_enabled(True)
static_loss = self.train(to_static=True)
Expand All @@ -440,6 +443,7 @@ def test_resnet_composite_backward(self):
),
)

@ast_only_test
def test_resnet_composite_forward_backward(self):
core._set_prim_all_enabled(True)
static_loss = self.train(to_static=True)
Expand All @@ -454,6 +458,7 @@ def test_resnet_composite_forward_backward(self):
),
)

@ast_only_test
def test_in_static_mode_mkldnn(self):
fluid.set_flags({'FLAGS_use_mkldnn': True})
try:
Expand Down
4 changes: 4 additions & 0 deletions test/dygraph_to_static/test_resnet_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import unittest

import numpy as np
from dygraph_to_static_util import ast_only_test
from predictor_utils import PredictorTools

import paddle
Expand Down Expand Up @@ -412,6 +413,7 @@ def verify_predict(self):
),
)

@ast_only_test
def test_resnet(self):
static_loss = self.train(to_static=True)
dygraph_loss = self.train(to_static=False)
Expand All @@ -425,6 +427,7 @@ def test_resnet(self):
)
self.verify_predict()

@ast_only_test
def test_resnet_composite(self):
core._set_prim_backward_enabled(True)
core._add_skip_comp_ops("batch_norm")
Expand All @@ -440,6 +443,7 @@ def test_resnet_composite(self):
),
)

@ast_only_test
def test_in_static_mode_mkldnn(self):
paddle.fluid.set_flags({'FLAGS_use_mkldnn': True})
try:
Expand Down
2 changes: 2 additions & 0 deletions test/dygraph_to_static/test_rollback.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import unittest

import numpy as np
from dygraph_to_static_util import ast_only_test

import paddle
from paddle.jit.dy2static.program_translator import StaticFunction
Expand Down Expand Up @@ -88,6 +89,7 @@ class TestRollBackNet(unittest.TestCase):
def setUp(self):
paddle.set_device("cpu")

@ast_only_test
def test_net(self):
net = paddle.jit.to_static(Net())
x = paddle.randn([3, 4])
Expand Down
3 changes: 3 additions & 0 deletions test/dygraph_to_static/test_save_inference_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import unittest

import numpy as np
from dygraph_to_static_util import ast_only_test

import paddle
from paddle import fluid
Expand Down Expand Up @@ -53,6 +54,7 @@ def setUp(self):
def tearDown(self):
self.temp_dir.cleanup()

@ast_only_test
def test_save_inference_model(self):
fc_size = 20
x_data = np.random.random((fc_size, fc_size)).astype('float32')
Expand Down Expand Up @@ -145,6 +147,7 @@ def load_and_run_inference(


class TestPartialProgramRaiseError(unittest.TestCase):
@ast_only_test
def test_param_type(self):
paddle.jit.enable_to_static(True)
x_data = np.random.random((20, 20)).astype('float32')
Expand Down
3 changes: 3 additions & 0 deletions test/dygraph_to_static/test_save_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import unittest

import numpy as np
from dygraph_to_static_util import ast_only_test
from test_fetch_feed import Linear

import paddle
Expand Down Expand Up @@ -115,6 +116,7 @@ def test_save_load_same_result(self):
dygraph_loss.numpy(), static_loss.numpy(), rtol=1e-05
)

@ast_only_test
def test_save_load_prim(self):
with fluid.dygraph.guard(place):
self.x = paddle.randn([4, 2, 6, 6], dtype="float32")
Expand Down Expand Up @@ -155,6 +157,7 @@ def test_save_load_prim(self):
self.assertIn("pool2d", load_op_type_list)
np.testing.assert_allclose(res.numpy(), new_res.numpy(), rtol=1e-05)

@ast_only_test
def test_save_load_prim_with_hook(self):
with fluid.dygraph.guard(place):
self.x = paddle.randn([4, 2, 6, 6], dtype="float32")
Expand Down