From 421b6778597d24268daebd994722209d0f014ff7 Mon Sep 17 00:00:00 2001 From: Wei Xu Date: Mon, 12 Dec 2022 16:12:41 +0000 Subject: [PATCH 1/4] odla_popart: add support for graphcore poplar sdk 3.1.0 This patch adds support for the newest poplar sdk on the following test setup. Docker image: registry-intl.us-west-1.aliyuncs.com/computation/halo:0.8.1-devel-cuda11.4.2-cudnn8-centos7 SDK: poplar_sdk-centos_7_6-3.1.0-EA.1+1168-a2e17bf73e Test command line: cmake -G Ninja .. -DHALO_USE_TIDY_CHECK=OFF -DHALO_GEN_DOCS=OFF -DPOPLAR_ROOT=$POPLAR_ROOT \ -DPOPLAR_VERSION=$POPLAR_VERSION -DPOPART_ROOT=$POPART_ROOT -DODLA_BUILD_POPART_USE_CXX11ABI=ON \ -DODLA_BUILD_POPART_CUSTOM_OPS=ON -DHALO_BUILD_RTLIB=OFF -DODLA_BUILD_TRT=OFF \ -DODLA_BUILD_XNNPACK=OFF -DODLA_BUILD_EIGEN=OFF -DODLA_BUILD_DNNL=OFF \ -DCMAKE_BUILD_TYPE=Debug -DODLA_BUILD_VODLA=off time ninja Signed-off-by: Wei Xu --- .github/actions/build/build_in_docker.sh | 2 +- .github/workflows/main.yaml | 2 +- ODLA/platforms/odla_popart/CMakeLists.txt | 6 ++---- ODLA/platforms/odla_popart/common.cc | 4 ++-- ODLA/platforms/odla_popart/custom_ops/CMakeLists.txt | 2 +- ODLA/platforms/odla_popart/custom_ops/rsqrt.cc | 2 ++ ODLA/platforms/odla_popart/odla_popart.cc | 4 +++- ODLA/platforms/odla_popart/odla_popart.h | 2 ++ ODLA/platforms/odla_popart/test/CMakeLists.txt | 2 +- 9 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/actions/build/build_in_docker.sh b/.github/actions/build/build_in_docker.sh index 8249b60ce..2d3e04a30 100755 --- a/.github/actions/build/build_in_docker.sh +++ b/.github/actions/build/build_in_docker.sh @@ -34,7 +34,7 @@ cmake_flags="$cmake_flags -DHALO_USE_STATIC_PROTOBUF=ON -DCPACK_SYSTEM_NAME=ubun gid=$(id -g ${USER}) group=$(id -g -n ${USER}) uid=$(id -u ${USER}) -extra_mnt="-v /opt/poplar_sdk-ubuntu_18_04-2.3.1_793:/opt/poplar_sdk:ro" +extra_mnt="-v /opt/poplar_sdk-ubuntu_18_04-3.1.0-EA.1+1167-ed39666085:/opt/poplar_sdk:ro" mkdir -p /tmp/ubuntu.cache extra_mnt="$extra_mnt -v /tmp/ubuntu.cache:/cache" diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 5e33faf66..c3a3650a2 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -88,7 +88,7 @@ jobs: $image_registry/computation/halo:$image_tag \ /bin/bash -c 'source scl_source enable devtoolset-7 && cd /build && cmake -G Ninja /host/halo -DHALO_USE_TIDY_CHECK=OFF -DHALO_GEN_DOCS=OFF -DODLA_BUILD_POPART_USE_CXX11ABI=OFF -DODLA_BUILD_POPART_CUSTOM_OPS=ON -DODLA_BUILD_TRT=ON -DODLA_BUILD_XNNPACK=OFF -DODLA_BUILD_EIGEN=ON -DODLA_BUILD_DNNL=ON -DODLA_BUILD_ASCEND=ON -DHALO_BUILD_RTLIB=OFF -DHALO_USE_STATIC_PROTOBUF=ON -DCPACK_SYSTEM_NAME=centos-i686 && ninja && source /opt/poplar_sdk/poplar/enable.sh && ninja check-halo && ninja package && cp /build/*.bz2 /build/*.rpm /host/output_centos' env: - poplar_sdk: /opt/poplar_sdk-centos_7_6-2.3.1_793 + poplar_sdk: /opt/poplar_sdk-centos_7_6-3.1.0-EA.1+1168-a2e17bf73e repo_name : heterogeneity-aware-lowering-and-optimization image_registry : registry-intl.us-west-1.aliyuncs.com image_tag : 0.8.1-devel-cuda11.4.2-cudnn8-centos7 diff --git a/ODLA/platforms/odla_popart/CMakeLists.txt b/ODLA/platforms/odla_popart/CMakeLists.txt index 7be1d40f9..d0a7b00a7 100644 --- a/ODLA/platforms/odla_popart/CMakeLists.txt +++ b/ODLA/platforms/odla_popart/CMakeLists.txt @@ -23,6 +23,7 @@ if(ENABLE_COVERAGE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage --coverage") endif() +set(CMAKE_CXX_FLAGS "-DONNX_NAMESPACE=onnx ${CMAKE_CXX_FLAGS}") add_odla_library(odla_popart SHARED common.cc odla_compute.cc odla_ops_math.cc odla_ops_nn.cc odla_ops_process.cc odla_ops.cc @@ -41,9 +42,6 @@ set(POPART_ROOT ${POPART_ROOT} PARENT_SCOPE) list(APPEND CMAKE_PREFIX_PATH ${POPLAR_ROOT}) list(APPEND CMAKE_PREFIX_PATH ${POPART_ROOT}) -find_package(popart 2.3.0... REQUIRED CONFIG COMPONENTS popart-only REQUIRED) - -message(STATUS "Found popart, version: ${popart_VERSION}") if (ODLA_BUILD_POPART_CUSTOM_OPS) message(STATUS "Build popart custom op") @@ -58,7 +56,7 @@ if (NOT ODLA_BUILD_POPART_USE_CXX11ABI) endif() -target_link_libraries(odla_popart PUBLIC ODLA custom_ops popart-only) +target_link_libraries(odla_popart PUBLIC ODLA custom_ops popart) if(ENABLE_COVERAGE) target_link_libraries(odla_popart PUBLIC gcov) diff --git a/ODLA/platforms/odla_popart/common.cc b/ODLA/platforms/odla_popart/common.cc index 244b1716b..c3a943ed8 100644 --- a/ODLA/platforms/odla_popart/common.cc +++ b/ODLA/platforms/odla_popart/common.cc @@ -140,8 +140,8 @@ std::unique_ptr MakeNDArrayWrapper(const odla_void* data_ptr, break; } case popart::DataType::FLOAT16: { - pArray = std::make_unique>( - reinterpret_cast(ptr), shape); + pArray = std::make_unique>( + reinterpret_cast(ptr), shape); break; } case popart::DataType::UINT32: { diff --git a/ODLA/platforms/odla_popart/custom_ops/CMakeLists.txt b/ODLA/platforms/odla_popart/custom_ops/CMakeLists.txt index 4c5ff119b..c35c96030 100644 --- a/ODLA/platforms/odla_popart/custom_ops/CMakeLists.txt +++ b/ODLA/platforms/odla_popart/custom_ops/CMakeLists.txt @@ -28,7 +28,7 @@ if (NOT ODLA_BUILD_POPART_USE_CXX11ABI) target_compile_definitions(custom_ops PRIVATE _GLIBCXX_USE_CXX11_ABI=0) endif() -target_link_libraries(custom_ops PRIVATE popart-only) +target_link_libraries(custom_ops PRIVATE popart) target_include_directories(custom_ops PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/onnx/ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/include/ diff --git a/ODLA/platforms/odla_popart/custom_ops/rsqrt.cc b/ODLA/platforms/odla_popart/custom_ops/rsqrt.cc index 01c38201f..294777dd2 100644 --- a/ODLA/platforms/odla_popart/custom_ops/rsqrt.cc +++ b/ODLA/platforms/odla_popart/custom_ops/rsqrt.cc @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include namespace CustomOperators { diff --git a/ODLA/platforms/odla_popart/odla_popart.cc b/ODLA/platforms/odla_popart/odla_popart.cc index 3c2ce3e74..ff5a6750a 100644 --- a/ODLA/platforms/odla_popart/odla_popart.cc +++ b/ODLA/platforms/odla_popart/odla_popart.cc @@ -28,6 +28,7 @@ #include #include #include +#include #include "odla_pipeline.h" #include "onnx/onnx.pb.h" @@ -278,7 +279,8 @@ odla_status _odla_computation::init(bool is_compile) { int config_len = 0; cache_fs->read((char*)&config_len, sizeof(config_len)); cache_fs->seekg(config_len + sizeof(config_len), std::ios::beg); - new_session->loadExecutableFromStream(*(cache_fs.get())); + std::shared_ptr in{cache_fs.get()}; + new_session->loadExecutableFromStream(in); } catch (std::exception& e) { popart::logging::err("bad cache file: {}", e.what()); return ODLA_FAILURE; diff --git a/ODLA/platforms/odla_popart/odla_popart.h b/ODLA/platforms/odla_popart/odla_popart.h index 331a82dfa..b17580c16 100644 --- a/ODLA/platforms/odla_popart/odla_popart.h +++ b/ODLA/platforms/odla_popart/odla_popart.h @@ -23,8 +23,10 @@ #include #include +#include #include #include +#include #include #include #include diff --git a/ODLA/platforms/odla_popart/test/CMakeLists.txt b/ODLA/platforms/odla_popart/test/CMakeLists.txt index 4da531187..0c9373b73 100644 --- a/ODLA/platforms/odla_popart/test/CMakeLists.txt +++ b/ODLA/platforms/odla_popart/test/CMakeLists.txt @@ -28,7 +28,7 @@ function(add_odla_cpp_unit_test name) set(target_name ${ARGV0}) add_executable(${target_name} ${FILES} utils.cc) - target_link_libraries(${target_name} PUBLIC ODLA pthread gcov custom_ops odla_popart popart-only) + target_link_libraries(${target_name} PUBLIC ODLA pthread gcov custom_ops odla_popart popart) target_include_directories(${target_name} PRIVATE From 22f58dbe9691d21ef1f39375ec9200cb3175de4b Mon Sep 17 00:00:00 2001 From: wangcl15 <1373555614@qq.com> Date: Wed, 14 Dec 2022 17:09:13 +0800 Subject: [PATCH 2/4] [CI] update poplar_sdk-3.1.0 for workflow scripts. --- .github/actions/build/build_in_docker.sh | 6 +++--- .github/workflows/main.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/actions/build/build_in_docker.sh b/.github/actions/build/build_in_docker.sh index 2d3e04a30..c0a0c3e45 100755 --- a/.github/actions/build/build_in_docker.sh +++ b/.github/actions/build/build_in_docker.sh @@ -39,9 +39,9 @@ mkdir -p /tmp/ubuntu.cache extra_mnt="$extra_mnt -v /tmp/ubuntu.cache:/cache" rm -fr $MOUNT_DIR/output_ubuntu && mkdir -p $MOUNT_DIR/output_ubuntu -extra_cmd="source /opt/poplar_sdk/poplar/enable.sh" # dummy command -cmd="cd /build && cmake -G Ninja $cmake_flags /host/halo " -cmd="$cmd && ninja && $extra_cmd && $check_cmds && ninja package " +extra_cmd="source /opt/poplar_sdk/poplar/enable.sh && source /opt/poplar_sdk/popart/enable.sh" +cmd="cd /build && $extra_cmd && cmake -G Ninja $cmake_flags /host/halo " +cmd="$cmd && ninja && $check_cmds && ninja package " cmd="$cmd && cp /build/*.bz2 /host/output_ubuntu" docker run -e CCACHE_DIR=/cache $docker_run_flag -v $MOUNT_DIR:/host \ --tmpfs /build:exec --tmpfs /tmp:exec --entrypoint="" \ diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index c3a3650a2..f76a1a9b4 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -86,7 +86,7 @@ jobs: -v $poplar_sdk:/opt/poplar_sdk:ro \ -v ${{runner.workspace}}/$repo_name:/host \ $image_registry/computation/halo:$image_tag \ - /bin/bash -c 'source scl_source enable devtoolset-7 && cd /build && cmake -G Ninja /host/halo -DHALO_USE_TIDY_CHECK=OFF -DHALO_GEN_DOCS=OFF -DODLA_BUILD_POPART_USE_CXX11ABI=OFF -DODLA_BUILD_POPART_CUSTOM_OPS=ON -DODLA_BUILD_TRT=ON -DODLA_BUILD_XNNPACK=OFF -DODLA_BUILD_EIGEN=ON -DODLA_BUILD_DNNL=ON -DODLA_BUILD_ASCEND=ON -DHALO_BUILD_RTLIB=OFF -DHALO_USE_STATIC_PROTOBUF=ON -DCPACK_SYSTEM_NAME=centos-i686 && ninja && source /opt/poplar_sdk/poplar/enable.sh && ninja check-halo && ninja package && cp /build/*.bz2 /build/*.rpm /host/output_centos' + /bin/bash -c 'source scl_source enable devtoolset-7 && cd /build && source /opt/poplar_sdk/poplar/enable.sh && source /opt/poplar_sdk/popart/enable.sh && cmake -G Ninja /host/halo -DHALO_USE_TIDY_CHECK=OFF -DHALO_GEN_DOCS=OFF -DODLA_BUILD_POPART_USE_CXX11ABI=OFF -DODLA_BUILD_POPART_CUSTOM_OPS=ON -DODLA_BUILD_TRT=ON -DODLA_BUILD_XNNPACK=OFF -DODLA_BUILD_EIGEN=ON -DODLA_BUILD_DNNL=ON -DODLA_BUILD_ASCEND=ON -DHALO_BUILD_RTLIB=OFF -DHALO_USE_STATIC_PROTOBUF=ON -DCPACK_SYSTEM_NAME=centos-i686 && ninja && source /opt/poplar_sdk/poplar/enable.sh && ninja check-halo && ninja package && cp /build/*.bz2 /build/*.rpm /host/output_centos' env: poplar_sdk: /opt/poplar_sdk-centos_7_6-3.1.0-EA.1+1168-a2e17bf73e repo_name : heterogeneity-aware-lowering-and-optimization From 81cc0db954cb6f568b149b36fe055ae6dbe33595 Mon Sep 17 00:00:00 2001 From: wangcl15 <1373555614@qq.com> Date: Thu, 15 Dec 2022 17:19:58 +0800 Subject: [PATCH 3/4] [Tests] update poplar_sdk name for run_test.py --- tests/unittests/run_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unittests/run_test.py b/tests/unittests/run_test.py index a285061e8..bb9dc0528 100644 --- a/tests/unittests/run_test.py +++ b/tests/unittests/run_test.py @@ -118,9 +118,9 @@ def link(case_path, obj_file, device, flags): lib_path = [] lib_path.append('-L' + odla_lib) if device =='popart': - poplar_prefix = '/opt/poplar_sdk-ubuntu_18_04-1.4.0+365-665f971c8f' - poplar_path = poplar_prefix + '/poplar-ubuntu_18_04-1.4.0+71819-c5c0c8ebab/lib' - popart_path = poplar_prefix + '/popart-ubuntu_18_04-1.4.0+5352-e86081acc9/lib' + poplar_prefix = '/opt/poplar_sdk' + poplar_path = poplar_prefix + '/poplar/lib' + popart_path = poplar_prefix + '/popart/lib' lib_path = ['-L'+poplar_path] lib_path.append('-L'+popart_path) From ba8355b4ebd3249a099fd97cb4631d1b65324572 Mon Sep 17 00:00:00 2001 From: wangcl15 <1373555614@qq.com> Date: Fri, 16 Dec 2022 15:32:40 +0800 Subject: [PATCH 4/4] [Tests] remove XFAIL for test_pow_types_int32_int32_popart.cc. --- .../lit_cases/test_popart/test_pow_types_int32_int32_popart.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unittests/lit_cases/test_popart/test_pow_types_int32_int32_popart.cc b/tests/unittests/lit_cases/test_popart/test_pow_types_int32_int32_popart.cc index 337ed219b..2d9c4b874 100644 --- a/tests/unittests/lit_cases/test_popart/test_pow_types_int32_int32_popart.cc +++ b/tests/unittests/lit_cases/test_popart/test_pow_types_int32_int32_popart.cc @@ -26,5 +26,4 @@ // RUN: %t_popart.exe 0.0001 0 popart %data_path/test_pow_types_int32_int32 | FileCheck %s // CHECK: Result Pass // clang-format on -// XFAIL: * #include "test_pow_types_int32_int32_popart.cc.tmp.main.cc.in"