From f03225b1f15e32293a07d140d970ad7f75633f1f Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Sun, 22 Nov 2020 13:01:15 -0800 Subject: [PATCH] Bump llvm-project to f4f8a67aaf13bc66a2b7d55561b14a3724a5e0de. * Incorporates source fixes. * Uses upstream pybind11 detection logic. * Patches CI. * This may break the CI, which will need to be fixed manually in a followup. --- .github/workflows/buildAndTest.yml | 14 +++------ CMakeLists.txt | 9 +++--- cmake/modules/NpcompDetectPythonEnv.cmake | 30 +++++++++++++++++++ external/llvm-project | 2 +- .../ATen/Transforms/ATenLoweringPass.cpp | 1 + python/npcomp/dialect/Basicpy.py | 4 +-- 6 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 cmake/modules/NpcompDetectPythonEnv.cmake diff --git a/.github/workflows/buildAndTest.yml b/.github/workflows/buildAndTest.yml index 3695b27c8..25632afde 100644 --- a/.github/workflows/buildAndTest.yml +++ b/.github/workflows/buildAndTest.yml @@ -15,12 +15,9 @@ jobs: uses: actions/checkout@v2 with: submodules: 'true' - - name: Install pytest + - name: Install python depends run: | - pip3 install pytest - - name: Install pybind11 - run: | - sudo apt-get install python3-pybind11 + pip3 install pytest pybind11 - name: Get LLVM Hash id: get-llvm-hash run: echo "::set-output name=hash::$(git submodule status)" @@ -50,12 +47,9 @@ jobs: uses: actions/checkout@v2 with: submodules: 'true' - - name: Install pytest + - name: Install python depends run: | - pip3 install pytest - - name: Install pybind11 - run: | - sudo apt-get install python3-pybind11 + pip3 install pytest pybind11 - name: Get LLVM Hash id: get-llvm-hash run: echo "::set-output name=hash::$(git submodule status)" diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ed63ed2c..7505fc22e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,6 +81,7 @@ include(AddLLVM) include(AddMLIR) include(AddNPCOMP) include(HandleLLVMOptions) +include(NpcompDetectPythonEnv) include(ConfigurePyTorch) include_directories(${LLVM_INCLUDE_DIRS}) include_directories(${MLIR_INCLUDE_DIRS}) @@ -162,11 +163,9 @@ endif() # Pybind11 Configuration #------------------------------------------------------------------------------- -find_package(pybind11 CONFIG REQUIRED) -# TODO: pybind11 v2.6 switched from pybind11_INCLUDE_DIRS (plural) to -# pybind11_INCLUDE_DIR (singular). A lot has changed in this area since this -# was written and overall python config and pybind11 should be modernized. -set(pybind11_INCLUDE_DIR ${pybind11_INCLUDE_DIR} ${pybind11_INCLUDE_DIRS}) +npcomp_detect_pybind11_install() +find_package(pybind11 2.6 CONFIG REQUIRED) +set(pybind11_INCLUDE_DIR ${pybind11_INCLUDE_DIR}) message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIR}") message(STATUS "Python prefix = '${PYTHON_MODULE_PREFIX}', " "suffix = '${PYTHON_MODULE_SUFFIX}', " diff --git a/cmake/modules/NpcompDetectPythonEnv.cmake b/cmake/modules/NpcompDetectPythonEnv.cmake new file mode 100644 index 000000000..3bdc975a8 --- /dev/null +++ b/cmake/modules/NpcompDetectPythonEnv.cmake @@ -0,0 +1,30 @@ +# Forked and adapted from MLIRDetectPythonEnv.cmake upstream. The eventual +# goal is to use the upstream configuration but until that is ready, just +# move/adapt these facilities. Please try to not diverge. + +# Macros and functions related to detecting details of the Python environment. + +# Detects a pybind11 package installed in the current python environment +# and sets variables to allow it to be found. This allows pybind11 to be +# installed via pip, which typically yields a much more recent version than +# the OS install, which will be available otherwise. +function(npcomp_detect_pybind11_install) + if(pybind11_DIR) + message(STATUS "Using explicit pybind11 cmake directory: ${pybind11_DIR} (-Dpybind11_DIR to change)") + else() + message(CHECK_START "Checking for pybind11 in python path...") + execute_process( + COMMAND "${PYTHON_EXECUTABLE}" + -c "import pybind11;print(pybind11.get_cmake_dir(), end='')" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE STATUS + OUTPUT_VARIABLE PACKAGE_DIR + ERROR_QUIET) + if(NOT STATUS EQUAL "0") + message(CHECK_FAIL "not found (install via 'pip install pybind11' or set pybind11_DIR)") + return() + endif() + message(CHECK_PASS "found (${PACKAGE_DIR})") + set(pybind11_DIR "${PACKAGE_DIR}" PARENT_SCOPE) + endif() +endfunction() diff --git a/external/llvm-project b/external/llvm-project index 703ef17e7..f4f8a67aa 160000 --- a/external/llvm-project +++ b/external/llvm-project @@ -1 +1 @@ -Subproject commit 703ef17e7a0a0f51e1d000bb1f71ad437a9933e4 +Subproject commit f4f8a67aaf13bc66a2b7d55561b14a3724a5e0de diff --git a/lib/Dialect/ATen/Transforms/ATenLoweringPass.cpp b/lib/Dialect/ATen/Transforms/ATenLoweringPass.cpp index 29f6ed71b..d176c968d 100644 --- a/lib/Dialect/ATen/Transforms/ATenLoweringPass.cpp +++ b/lib/Dialect/ATen/Transforms/ATenLoweringPass.cpp @@ -200,6 +200,7 @@ static FuncOp getATenFn(ModuleOp module, std::string mangledFunctionName, if (!fn) { fn = FuncOp::create(builder.getUnknownLoc(), mangledFunctionName, fnTy); + fn.setVisibility(SymbolTable::Visibility::Private); module.push_back(fn); } diff --git a/python/npcomp/dialect/Basicpy.py b/python/npcomp/dialect/Basicpy.py index b5c46db81..738191f19 100644 --- a/python/npcomp/dialect/Basicpy.py +++ b/python/npcomp/dialect/Basicpy.py @@ -30,7 +30,7 @@ class DialectHelper(_BaseDialectHelper): >>> h.builder.insert_block_start(m.first_block) >>> _ = h.basicpy_singleton_op(h.basicpy_NoneType) >>> m.to_asm().strip() - 'module {\n %0 = basicpy.singleton : !basicpy.NoneType\n}' + 'module {\n %0 = basicpy.singleton : !basicpy.NoneType\n}' slot_object ops: >>> m = c.new_module() @@ -39,7 +39,7 @@ class DialectHelper(_BaseDialectHelper): >>> slot_object = h.basicpy_slot_object_make_op("foobar", v0, v0).result >>> _ = h.basicpy_slot_object_get_op(slot_object, 0) >>> print(m.to_asm().strip()) - module { + module { %0 = basicpy.singleton : !basicpy.NoneType %1 = basicpy.slot_object_make(%0, %0) -> !basicpy.SlotObject %2 = basicpy.slot_object_get %1[0] : !basicpy.SlotObject