From ae6a82710d01ec8a0606af34215abcfbf3289600 Mon Sep 17 00:00:00 2001 From: ronnywang Date: Mon, 5 Sep 2022 16:16:29 +0800 Subject: [PATCH] [CustomDevice] unittests tracking the fixed version plugin (#45553) * [CustomDevice] unittests tracking the fixed version plugin * update --- .../fluid/tests/custom_runtime/CMakeLists.txt | 16 ++++++++++++---- .../test_collective_process_group_xccl.py | 7 ++++++- .../custom_runtime/test_custom_cpu_plugin.py | 7 ++++++- .../test_custom_cpu_profiler_plugin.py | 7 ++++++- .../test_fleet_launch_custom_device.sh | 6 +++++- 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/python/paddle/fluid/tests/custom_runtime/CMakeLists.txt b/python/paddle/fluid/tests/custom_runtime/CMakeLists.txt index 3161afd1192..099b1ddc1c0 100644 --- a/python/paddle/fluid/tests/custom_runtime/CMakeLists.txt +++ b/python/paddle/fluid/tests/custom_runtime/CMakeLists.txt @@ -1,4 +1,7 @@ if(WITH_CUSTOM_DEVICE AND NOT WITH_GPU) + set(PLUGIN_URL https://github.com/PaddlePaddle/PaddleCustomDevice.git) + set(PLUGIN_TAG d5e5ac1d8e9f7588d4c2998bb3b5ffc66f65af2e) + file( GLOB TEST_OPS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" @@ -7,13 +10,18 @@ if(WITH_CUSTOM_DEVICE AND NOT WITH_GPU) list(REMOVE_ITEM TEST_OPS test_collective_process_group_xccl) foreach(TEST_OP ${TEST_OPS}) - py_test(${TEST_OP} SRCS ${TEST_OP}.py) + py_test(${TEST_OP} SRCS ${TEST_OP}.py ENVS PLUGIN_URL=${PLUGIN_URL} + PLUGIN_TAG=${PLUGIN_TAG}) endforeach() bash_test_modules( - test_fleet_launch_custom_device START_BASH - test_fleet_launch_custom_device.sh ENVS - PADDLE_BINARY_DIR=${PADDLE_BINARY_DIR}) + test_fleet_launch_custom_device + START_BASH + test_fleet_launch_custom_device.sh + ENVS + PADDLE_BINARY_DIR=${PADDLE_BINARY_DIR} + PLUGIN_URL=${PLUGIN_URL} + PLUGIN_TAG=${PLUGIN_TAG}) set_tests_properties(test_custom_cpu_plugin PROPERTIES TIMEOUT 120) set_tests_properties(test_custom_cpu_profiler_plugin PROPERTIES TIMEOUT 120) diff --git a/python/paddle/fluid/tests/custom_runtime/test_collective_process_group_xccl.py b/python/paddle/fluid/tests/custom_runtime/test_collective_process_group_xccl.py index f2e22a292fe..db2510d2beb 100644 --- a/python/paddle/fluid/tests/custom_runtime/test_collective_process_group_xccl.py +++ b/python/paddle/fluid/tests/custom_runtime/test_collective_process_group_xccl.py @@ -136,7 +136,12 @@ class TestProcessGroup(TestMultipleCustomCPU): def setUp(self): # compile so and set to current path cur_dir = os.path.dirname(os.path.abspath(__file__)) - cmd = 'rm -rf PaddleCustomDevice && git clone https://github.com/PaddlePaddle/PaddleCustomDevice.git && cd PaddleCustomDevice/backends/custom_cpu && mkdir build && cd build && cmake .. && make -j8' + cmd = 'rm -rf PaddleCustomDevice \ + && git clone {} \ + && cd PaddleCustomDevice/backends/custom_cpu \ + && git checkout {} -b dev \ + && mkdir build && cd build && cmake .. && make -j8'.format( + os.getenv('PLUGIN_URL'), os.getenv('PLUGIN_TAG')) os.system(cmd) # set environment for loading and registering compiled custom kernels diff --git a/python/paddle/fluid/tests/custom_runtime/test_custom_cpu_plugin.py b/python/paddle/fluid/tests/custom_runtime/test_custom_cpu_plugin.py index 07e22516040..371f0018a0f 100644 --- a/python/paddle/fluid/tests/custom_runtime/test_custom_cpu_plugin.py +++ b/python/paddle/fluid/tests/custom_runtime/test_custom_cpu_plugin.py @@ -24,7 +24,12 @@ class TestCustomCPUPlugin(unittest.TestCase): def setUp(self): # compile so and set to current path cur_dir = os.path.dirname(os.path.abspath(__file__)) - cmd = 'rm -rf PaddleCustomDevice && git clone https://github.com/PaddlePaddle/PaddleCustomDevice.git && cd PaddleCustomDevice/backends/custom_cpu && mkdir build && cd build && cmake .. && make -j8' + cmd = 'rm -rf PaddleCustomDevice \ + && git clone {} \ + && cd PaddleCustomDevice/backends/custom_cpu \ + && git checkout {} -b dev \ + && mkdir build && cd build && cmake .. && make -j8'.format( + os.getenv('PLUGIN_URL'), os.getenv('PLUGIN_TAG')) os.system(cmd) # set environment for loading and registering compiled custom kernels diff --git a/python/paddle/fluid/tests/custom_runtime/test_custom_cpu_profiler_plugin.py b/python/paddle/fluid/tests/custom_runtime/test_custom_cpu_profiler_plugin.py index 7a8356ed932..34bdb067c67 100644 --- a/python/paddle/fluid/tests/custom_runtime/test_custom_cpu_profiler_plugin.py +++ b/python/paddle/fluid/tests/custom_runtime/test_custom_cpu_profiler_plugin.py @@ -24,7 +24,12 @@ class TestCustomCPUProfilerPlugin(unittest.TestCase): def setUp(self): # compile so and set to current path cur_dir = os.path.dirname(os.path.abspath(__file__)) - cmd = 'rm -rf PaddleCustomDevice && git clone https://github.com/PaddlePaddle/PaddleCustomDevice.git && cd PaddleCustomDevice/backends/custom_cpu && mkdir build && cd build && cmake .. && make -j8' + cmd = 'rm -rf PaddleCustomDevice \ + && git clone {} \ + && cd PaddleCustomDevice/backends/custom_cpu \ + && git checkout {} -b dev \ + && mkdir build && cd build && cmake .. && make -j8'.format( + os.getenv('PLUGIN_URL'), os.getenv('PLUGIN_TAG')) os.system(cmd) # set environment for loading and registering compiled custom kernels diff --git a/python/paddle/fluid/tests/custom_runtime/test_fleet_launch_custom_device.sh b/python/paddle/fluid/tests/custom_runtime/test_fleet_launch_custom_device.sh index 68023430172..5570c629dd9 100644 --- a/python/paddle/fluid/tests/custom_runtime/test_fleet_launch_custom_device.sh +++ b/python/paddle/fluid/tests/custom_runtime/test_fleet_launch_custom_device.sh @@ -16,7 +16,11 @@ set -e -rm -rf PaddleCustomDevice && git clone https://github.com/PaddlePaddle/PaddleCustomDevice.git && pushd PaddleCustomDevice/backends/custom_cpu && mkdir build && pushd build && cmake .. && make -j8 && popd && popd +rm -rf PaddleCustomDevice && \ +git clone ${PLUGIN_URL} \ +&& pushd PaddleCustomDevice/backends/custom_cpu \ +&& git checkout ${PLUGIN_TAG} -b dev \ +&& mkdir build && pushd build && cmake .. && make -j8 && popd && popd echo "begin test use custom_cpu" -- GitLab