mirror of https://github.com/llvm/torch-mlir
Move TORCH_MLIR_USE_INSTALLED_PYTORCH to top-level.
This was unfortunately being initialized in a directory below its first use. This was causing the first configure to mis-detect the ABI flags, which was causing type conversion failures at runtime. Fixes #2298 and hardens some additional messages and checks to better make it clear when something goes awry.pull/2595/head
parent
1b7d6f2af9
commit
66b73edb28
|
@ -29,6 +29,8 @@ set(CMAKE_CXX_STANDARD 17)
|
|||
# Project options
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
option(TORCH_MLIR_USE_INSTALLED_PYTORCH "If depending on PyTorch use it as installed in the current Python environment" ON)
|
||||
|
||||
option(TORCH_MLIR_ENABLE_REFBACKEND "Enable reference backend" ON)
|
||||
if(TORCH_MLIR_ENABLE_REFBACKEND)
|
||||
add_definitions(-DTORCH_MLIR_ENABLE_REFBACKEND)
|
||||
|
|
|
@ -12,6 +12,9 @@ if(TORCH_MLIR_ENABLE_JIT_IR_IMPORTER OR TORCH_MLIR_ENABLE_LTC)
|
|||
# Assume it is a sibling to the overall project.
|
||||
set(Torch_DIR "${PROJECT_SOURCE_DIR}/../libtorch/share/cmake/Torch")
|
||||
message(STATUS "Attempting to locate libtorch as a sibling to the project: ${Torch_DIR}")
|
||||
if(NOT EXISTS "${Torch_DIR}")
|
||||
message(FATAL_ERROR "Without TORCH_MLIR_USE_INSTALLED_PYTORCH, expected to find Torch configuration at ${Torch_DIR}, which does not exist")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_package(Torch 1.11 REQUIRED)
|
||||
|
@ -23,7 +26,13 @@ if(TORCH_MLIR_ENABLE_JIT_IR_IMPORTER OR TORCH_MLIR_ENABLE_LTC)
|
|||
${Python3_INCLUDE_DIRS}
|
||||
)
|
||||
link_directories("${TORCH_INSTALL_PREFIX}/lib")
|
||||
message(STATUS "libtorch_python CXXFLAGS is ...${TORCH_CXXFLAGS}")
|
||||
message(STATUS "TORCH_CXXFLAGS is = ${TORCH_CXXFLAGS}")
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT TORCH_CXXFLAGS)
|
||||
message(WARNING
|
||||
"When building on Linux TORCH_CXXFLAGS are almost always required but were not detected. "
|
||||
"It is very likely this this will produce a non-functional installation. "
|
||||
"See notes in build_tools/cmake/TorchMLIRPyTorch.cmake.")
|
||||
endif()
|
||||
message(STATUS "TORCH_LIBRARIES = ${TORCH_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@ add_compile_definitions("MLIR_PYTHON_PACKAGE_PREFIX=torch_mlir.")
|
|||
# PyTorch
|
||||
################################################################################
|
||||
|
||||
option(TORCH_MLIR_USE_INSTALLED_PYTORCH "Build from local PyTorch in environment" ON)
|
||||
|
||||
if (NOT TORCH_MLIR_USE_INSTALLED_PYTORCH)
|
||||
# Source builds
|
||||
set(ENV{TORCH_MLIR_SRC_PYTORCH_REPO} ${TORCH_MLIR_SRC_PYTORCH_REPO})
|
||||
|
|
Loading…
Reference in New Issue