Skip to content

Commit

Permalink
[Move Test] xpu (#52661)
Browse files Browse the repository at this point in the history
* move python/paddle/fluid/tests/unittests/xpu to test/xpu

* update CMakeLists.txt

* remove xpu in fluid/tests/unittests/

* add path to op_test_xpu

* fix incorrect path

* update test script

* fix test_adadelta_op_xpu error
  • Loading branch information
RedContritio authored Apr 12, 2023
1 parent 523f8a2 commit 9a7c83b
Show file tree
Hide file tree
Showing 201 changed files with 503 additions and 993 deletions.
2 changes: 1 addition & 1 deletion paddle/scripts/paddle_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2237,7 +2237,7 @@ set +x
set -x
ut_endTime_s=`date +%s`
echo "XPU testCase Time: $[ $ut_endTime_s - $ut_startTime_s ]s"
python ${PADDLE_ROOT}/build/python/paddle/fluid/tests/unittests/xpu/get_test_cover_info.py
python ${PADDLE_ROOT}/build/test/xpu/get_test_cover_info.py
unset XPU_OP_LIST_DIR
if [[ "$EXIT_CODE" != "0" ]]; then
exit 8;
Expand Down
4 changes: 0 additions & 4 deletions python/paddle/fluid/tests/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -772,10 +772,6 @@ add_subdirectory(sequence)
add_subdirectory(rnn)
add_subdirectory(distribution)

if(WITH_XPU)
add_subdirectory(xpu)
endif()

# dist xpu tests:
if(WITH_XPU_BKCL)
py_test(test_collective_allreduce_api_xpu
Expand Down
36 changes: 0 additions & 36 deletions python/paddle/fluid/tests/unittests/xpu/CMakeLists.txt

This file was deleted.

4 changes: 3 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ if(WITH_TESTING)
add_subdirectory(standalone_executor)
add_subdirectory(tokenizer)
# add_subdirectory(white_list)
add_subdirectory(xpu)
if(WITH_XPU)
add_subdirectory(xpu)
endif()
endif()

get_property(test_srcs GLOBAL PROPERTY TEST_SRCS)
Expand Down
37 changes: 37 additions & 0 deletions test/xpu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
if(WITH_XPU)
add_subdirectory(cpp)
endif()

file(
GLOB TEST_OPS
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"test_*.py")
string(REPLACE ".py" "" TEST_OPS "${TEST_OPS}")

if(WITH_XPU_BKCL)
list(REMOVE_ITEM TEST_OPS "test_gen_bkcl_id_op")
endif()

file(
GLOB DIST_TEST_OPS
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"test_dist_*.py")
if(WITH_XPU_BKCL)
list(APPEND DIST_TEST_OPS test_gen_bkcl_id_op)
endif()

foreach(TEST_OP ${TEST_OPS})
py_test_modules(${TEST_OP} MODULES ${TEST_OP})
endforeach()

foreach(TEST_OP ${DIST_TEST_OPS})
py_test_modules(${TEST_OP} MODULES ${TEST_OP})
endforeach()

set_tests_properties(test_conv2d_op_xpu PROPERTIES TIMEOUT 120)
set_tests_properties(test_mul_op_xpu PROPERTIES TIMEOUT 120)
set_tests_properties(test_matmul_v2_op_xpu PROPERTIES TIMEOUT 900)
set_tests_properties(test_matmul_op_xpu PROPERTIES TIMEOUT 300)
set_tests_properties(test_collective_identity_xpu
PROPERTIES LABELS "RUN_TYPE=DIST_KUNLUN")
set_tests_properties(test_collective_allgather_xpu
PROPERTIES LABELS "RUN_TYPE=DIST_KUNLUN")
set_tests_properties(test_collective_allreduce_xpu
PROPERTIES LABELS "RUN_TYPE=DIST_KUNLUN")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys

import numpy as np

sys.path.append('..')
sys.path.append('../../python/paddle/fluid/tests/unittests')

from eager_op_test import OpTest
from testsuite import append_loss_ops, create_op, set_input
from white_list import no_grad_set_white_list, op_threshold_white_list
from xpu.get_test_cover_info import (
from get_test_cover_info import (
get_xpu_op_support_types,
is_empty_grad_op_type,
type_dict_str_to_numpy,
)
from testsuite import append_loss_ops, create_op, set_input
from white_list import no_grad_set_white_list, op_threshold_white_list

import paddle
from paddle import fluid
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import unittest

import numpy as np

sys.path.append("..")
from op_test_xpu import XPUOpTest
from xpu.get_test_cover_info import (
from get_test_cover_info import (
XPUOpTestWrapper,
create_test_class,
get_xpu_op_support_types,
)
from op_test_xpu import XPUOpTest

import paddle

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

import numpy as np

sys.path.append("..")
sys.path.append('../../python/paddle/fluid/tests/unittests')

import numpy as np
from eager_op_test import OpTest
from op_test_xpu import XPUOpTest
from xpu.get_test_cover_info import (
from get_test_cover_info import (
XPUOpTestWrapper,
create_test_class,
get_xpu_op_support_types,
)
from op_test_xpu import XPUOpTest

import paddle
import paddle.nn.functional as F
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import unittest

import numpy as np

sys.path.append("..")

from op_test_xpu import XPUOpTest
from xpu.get_test_cover_info import (
from get_test_cover_info import (
XPUOpTestWrapper,
create_test_class,
get_xpu_op_support_types,
)
from op_test_xpu import XPUOpTest

import paddle
from paddle import fluid
Expand Down Expand Up @@ -52,11 +48,13 @@ def setUp(self):
rho = 0.95
epsilon = 1e-6

learning_rate = 1.0
self.inputs = {
'Param': param,
'Grad': grad,
'AvgSquaredGrad': avg_squared_grad,
'AvgSquaredUpdate': avg_squared_update,
'LearningRate': np.array([learning_rate]).astype("float32"),
}

self.attrs = {'rho': rho, 'epsilon': epsilon}
Expand Down Expand Up @@ -107,11 +105,13 @@ def setUp(self):
rho = 0.95
epsilon = 1e-6

learning_rate = 1.0
self.inputs = {
'Param': param,
'Grad': grad,
'AvgSquaredGrad': avg_squared_grad,
'AvgSquaredUpdate': avg_squared_update,
'LearningRate': np.array([learning_rate]).astype("float32"),
}

avg_squared_grad_out = rho * avg_squared_grad + (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys

import numpy as np

import paddle

sys.path.append("..")
import unittest

from op_test_xpu import XPUOpTest
from xpu.get_test_cover_info import (
import numpy as np
from get_test_cover_info import (
XPUOpTestWrapper,
create_test_class,
get_xpu_op_support_types,
)
from op_test_xpu import XPUOpTest

import paddle

paddle.enable_static()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys

sys.path.append("..")
import unittest

import numpy as np
from op_test_xpu import XPUOpTest
from xpu.get_test_cover_info import (
from get_test_cover_info import (
XPUOpTestWrapper,
create_test_class,
get_xpu_op_support_types,
)
from op_test_xpu import XPUOpTest

import paddle
from paddle.fluid import core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys

sys.path.append("..")

import unittest
from functools import partial

import numpy as np
from op_test_xpu import XPUOpTest
from xpu.get_test_cover_info import (
from get_test_cover_info import (
XPUOpTestWrapper,
create_test_class,
get_xpu_op_support_types,
)
from op_test_xpu import XPUOpTest

import paddle
from paddle import fluid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
Unit testing for affine_channel_op
"""

import sys

sys.path.append("..")

import unittest

import numpy as np
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys

sys.path.append("..")
import unittest

import numpy as np
from op_test_xpu import XPUOpTest
from xpu.get_test_cover_info import (
from get_test_cover_info import (
XPUOpTestWrapper,
create_test_class,
get_xpu_op_support_types,
)
from op_test_xpu import XPUOpTest

import paddle

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import unittest

import numpy as np

sys.path.append("..")

from op_test_xpu import XPUOpTest
from xpu.get_test_cover_info import (
from get_test_cover_info import (
XPUOpTestWrapper,
create_test_class,
get_xpu_op_support_types,
)
from op_test_xpu import XPUOpTest

import paddle

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import unittest

import numpy as np

sys.path.append("..")

from op_test_xpu import XPUOpTest
from xpu.get_test_cover_info import (
from get_test_cover_info import (
XPUOpTestWrapper,
create_test_class,
get_xpu_op_support_types,
)
from op_test_xpu import XPUOpTest

import paddle

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import unittest

import numpy as np

sys.path.append("..")

from op_test_xpu import XPUOpTest
from xpu.get_test_cover_info import (
from get_test_cover_info import (
XPUOpTestWrapper,
create_test_class,
get_xpu_op_support_types,
)
from op_test_xpu import XPUOpTest

import paddle

Expand Down
Loading

0 comments on commit 9a7c83b

Please sign in to comment.