Initial moves

breakup_python_pytorch_deps
Stella Laurenzo 2023-11-18 16:13:22 -08:00
parent facbe5d96b
commit e7ead186cb
77 changed files with 60 additions and 77 deletions

View File

@ -231,6 +231,4 @@ endif()
# Sub-projects # Sub-projects
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
if(TORCH_MLIR_ENABLE_PROJECT_PT1) add_subdirectory(projects)
add_subdirectory(projects/pt1)
endif()

View File

@ -0,0 +1,43 @@
include(AddMLIRPython)
# Configure PyTorch if we have any features enabled which require it.
if(TORCH_MLIR_ENABLE_JIT_IR_IMPORTER OR TORCH_MLIR_ENABLE_LTC)
message("Enabling PyTorch C++ dep (features depend on it)")
include(TorchMLIRPyTorch)
TorchMLIRProbeForPyTorchInstall()
if(TORCH_MLIR_USE_INSTALLED_PYTORCH)
TorchMLIRConfigurePyTorch()
else()
# 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}")
endif()
find_package(Torch 1.11 REQUIRED)
set(TORCHGEN_DIR ${Torch_ROOT}/../../../torchgen)
include_directories(BEFORE
${TORCH_INCLUDE_DIRS}
${Python3_INCLUDE_DIRS}
)
link_directories("${TORCH_INSTALL_PREFIX}/lib")
message(STATUS "libtorch_python CXXFLAGS is ...${TORCH_CXXFLAGS}")
endif()
# Include jit_ir_common if the jit_ir importer or LTC is enabled,
# since they both require it.
if(TORCH_MLIR_ENABLE_JIT_IR_IMPORTER OR TORCH_MLIR_ENABLE_LTC)
add_subdirectory(jit_ir_common)
endif()
# Include LTC.
if(TORCH_MLIR_ENABLE_LTC)
add_subdirectory(ltc)
endif()
# Include overall PT1 project.
if(TORCH_MLIR_ENABLE_PROJECT_PT1)
add_subdirectory(projects/pt1)
endif()

View File

@ -0,0 +1 @@
add_subdirectory(csrc/base_lazy_backend)

View File

@ -2,30 +2,6 @@
# Setup PyTorch/LTC # Setup PyTorch/LTC
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
include(TorchMLIRPyTorch)
TorchMLIRProbeForPyTorchInstall()
if(TORCH_MLIR_USE_INSTALLED_PYTORCH)
TorchMLIRConfigurePyTorch()
else()
# 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}")
endif()
find_package(Torch 1.11 REQUIRED)
set(TORCHGEN_DIR ${Torch_ROOT}/../../../torchgen)
include_directories(BEFORE
${TORCH_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${Python3_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/projects/pt1/python
)
link_directories("${TORCH_INSTALL_PREFIX}/lib")
set(LTC_GENERATED set(LTC_GENERATED
generated/LazyNativeFunctions.cpp generated/LazyNativeFunctions.cpp
generated/RegisterLazy.cpp generated/RegisterLazy.cpp

View File

@ -1,5 +1,3 @@
include(AddMLIRPython)
# Disables generation of "version soname" (i.e. libFoo.so.<version>), which # Disables generation of "version soname" (i.e. libFoo.so.<version>), which
# causes pure duplication as part of Python wheels. # causes pure duplication as part of Python wheels.
set(CMAKE_PLATFORM_NO_VERSIONED_SONAME ON) set(CMAKE_PLATFORM_NO_VERSIONED_SONAME ON)
@ -90,9 +88,6 @@ declare_mlir_python_extension(TorchMLIRPythonExtensions.Main
# Lazy Tensor Core # Lazy Tensor Core
################################################################################ ################################################################################
if(TORCH_MLIR_ENABLE_LTC)
add_subdirectory(torch_mlir/csrc/base_lazy_backend)
endif()
# Reference backend has a separate check for TORCH_MLIR_ENABLE_LTC, since it # Reference backend has a separate check for TORCH_MLIR_ENABLE_LTC, since it
# generates a dummy Python library when disabled. # generates a dummy Python library when disabled.
if(NOT TORCH_MLIR_ENABLE_ONLY_MLIR_PYTHON_BINDINGS) if(NOT TORCH_MLIR_ENABLE_ONLY_MLIR_PYTHON_BINDINGS)
@ -104,7 +99,7 @@ endif()
################################################################################ ################################################################################
if(TORCH_MLIR_ENABLE_JIT_IR_IMPORTER) if(TORCH_MLIR_ENABLE_JIT_IR_IMPORTER)
add_subdirectory(torch_mlir/dialects/torch/importer/jit_ir) add_subdirectory(torch_mlir/jit_ir_importer)
add_subdirectory(torch_mlir_e2e_test) add_subdirectory(torch_mlir_e2e_test)
endif() endif()

View File

@ -1,32 +0,0 @@
#-------------------------------------------------------------------------------
# Setup PyTorch
#-------------------------------------------------------------------------------
include(TorchMLIRPyTorch)
TorchMLIRProbeForPyTorchInstall()
if(TORCH_MLIR_USE_INSTALLED_PYTORCH)
TorchMLIRConfigurePyTorch()
else()
# 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}")
endif()
find_package(Torch 1.11 REQUIRED)
message(STATUS "libtorch_python CXXFLAGS is ...${TORCH_CXXFLAGS}")
#-------------------------------------------------------------------------------
# Subdirectories
#-------------------------------------------------------------------------------
add_subdirectory(csrc)
## Declare the sources of the Python module.
declare_mlir_python_sources(TorchMLIRPythonSources.JitIRImporter
ROOT_DIR "${TORCH_MLIR_PYTHON_ROOT_DIR}"
ADD_TO_PARENT TorchMLIRPythonSources
SOURCES_GLOB
dialects/torch/importer/jit_ir/*.py
)

View File

@ -0,0 +1,14 @@
#-------------------------------------------------------------------------------
# Subdirectories
#-------------------------------------------------------------------------------
add_subdirectory(csrc)
## Declare the sources of the Python module.
declare_mlir_python_sources(TorchMLIRPythonSources.JitIRImporter
ROOT_DIR "${TORCH_MLIR_PYTHON_ROOT_DIR}"
ADD_TO_PARENT TorchMLIRPythonSources
SOURCES_GLOB
jit_ir_importer/*.py
)

View File

@ -1,15 +1,3 @@
# Sharp edge: Torch extensions need to use the same pybind11 that torch
# was compiled with, or else there will be issues in cross module exception
# handling (which will abort instead of raise). We circumvent the possibility
# by forcing the torch directories first.
include_directories(BEFORE
${TORCH_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${Python3_INCLUDE_DIRS}
)
link_directories("${TORCH_INSTALL_PREFIX}/lib")
# Static library with core functionality. # Static library with core functionality.
# We can't use a shared library here, due to issues with linking on macOS-arm64 (the library itself won't build) # We can't use a shared library here, due to issues with linking on macOS-arm64 (the library itself won't build)
# For details, see: https://github.com/llvm/torch-mlir/runs/7919012376 # For details, see: https://github.com/llvm/torch-mlir/runs/7919012376