forked from OSchip/llvm-project
Revert "[mlir] Allow out-of-tree python building from installed MLIR."
This reverts commit c7be8b7539
.
Build is broken (multiple buildbots)
This commit is contained in:
parent
72e947765a
commit
1a6c26d1f5
|
@ -35,7 +35,6 @@ function(declare_mlir_python_sources name)
|
||||||
if(NOT ARG_ROOT_DIR)
|
if(NOT ARG_ROOT_DIR)
|
||||||
set(ARG_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
set(ARG_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
endif()
|
endif()
|
||||||
set(_install_destination "src/python/${name}")
|
|
||||||
|
|
||||||
# Process the glob.
|
# Process the glob.
|
||||||
set(_glob_sources)
|
set(_glob_sources)
|
||||||
|
@ -51,44 +50,21 @@ function(declare_mlir_python_sources name)
|
||||||
|
|
||||||
# We create a custom target to carry properties and dependencies for
|
# We create a custom target to carry properties and dependencies for
|
||||||
# generated sources.
|
# generated sources.
|
||||||
add_library(${name} INTERFACE)
|
add_custom_target(${name})
|
||||||
set(_file_depends "${ARG_SOURCES}")
|
set(_file_depends "${ARG_SOURCES}")
|
||||||
list(TRANSFORM _file_depends PREPEND "${ARG_ROOT_DIR}/")
|
list(TRANSFORM _file_depends PREPEND "${ARG_ROOT_DIR}/")
|
||||||
set_target_properties(${name} PROPERTIES
|
set_target_properties(${name} PROPERTIES
|
||||||
# Yes: Leading-lowercase property names are load bearing and the recommended
|
PYTHON_SOURCES_TYPE pure
|
||||||
# way to do this: https://gitlab.kitware.com/cmake/cmake/-/issues/19261
|
PYTHON_ROOT_DIR "${ARG_ROOT_DIR}"
|
||||||
# Note that ROOT_DIR and FILE_DEPENDS are not exported because they are
|
PYTHON_DEST_PREFIX "${ARG_DEST_PREFIX}"
|
||||||
# only relevant to in-tree uses.
|
PYTHON_SOURCES "${ARG_SOURCES}"
|
||||||
EXPORT_PROPERTIES "mlir_python_SOURCES_TYPE;mlir_python_DEST_PREFIX;mlir_python_DEST_PREFIX;mlir_python_SOURCES;mlir_python_DEPENDS"
|
PYTHON_FILE_DEPENDS "${_file_depends}"
|
||||||
mlir_python_SOURCES_TYPE pure
|
PYTHON_DEPENDS ""
|
||||||
mlir_python_ROOT_DIR "${ARG_ROOT_DIR}"
|
|
||||||
mlir_python_DEST_PREFIX "${ARG_DEST_PREFIX}"
|
|
||||||
mlir_python_SOURCES "${ARG_SOURCES}"
|
|
||||||
mlir_python_FILE_DEPENDS "${_file_depends}"
|
|
||||||
mlir_python_DEPENDS ""
|
|
||||||
)
|
|
||||||
# Note that an "include" directory has no meaning to such faux targets,
|
|
||||||
# but it is a CMake supported way to specify a directory search list in a
|
|
||||||
# way that works both in-tree and out. It has some super powers which are
|
|
||||||
# not possible to emulate with custom properties (because of the prohibition
|
|
||||||
# on using generator expressions in exported custom properties and the
|
|
||||||
# special dispensation for $<INSTALL_PREFIX>).
|
|
||||||
target_include_directories(${name} INTERFACE
|
|
||||||
"$<BUILD_INTERFACE:${ARG_ROOT_DIR}>"
|
|
||||||
"$<INSTALL_INTERFACE:${_install_destination}>"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add to parent.
|
# Add to parent.
|
||||||
if(ARG_ADD_TO_PARENT)
|
if(ARG_ADD_TO_PARENT)
|
||||||
set_property(TARGET ${ARG_ADD_TO_PARENT} APPEND PROPERTY mlir_python_DEPENDS ${name})
|
set_property(TARGET ${ARG_ADD_TO_PARENT} APPEND PROPERTY PYTHON_DEPENDS ${name})
|
||||||
endif()
|
|
||||||
|
|
||||||
# Install.
|
|
||||||
if(NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
|
||||||
_mlir_python_install_sources(
|
|
||||||
${name} "${ARG_ROOT_DIR}" "${_install_destination}"
|
|
||||||
${ARG_SOURCES}
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
@ -96,8 +72,6 @@ endfunction()
|
||||||
# Declares a buildable python extension from C++ source files. The built
|
# Declares a buildable python extension from C++ source files. The built
|
||||||
# module is considered a python source file and included as everything else.
|
# module is considered a python source file and included as everything else.
|
||||||
# Arguments:
|
# Arguments:
|
||||||
# ROOT_DIR: Root directory where sources are interpreted relative to.
|
|
||||||
# Defaults to CMAKE_CURRENT_SOURCE_DIR.
|
|
||||||
# MODULE_NAME: Local import name of the module (i.e. "_mlir").
|
# MODULE_NAME: Local import name of the module (i.e. "_mlir").
|
||||||
# ADD_TO_PARENT: Same as for declare_mlir_python_sources.
|
# ADD_TO_PARENT: Same as for declare_mlir_python_sources.
|
||||||
# SOURCES: C++ sources making up the module.
|
# SOURCES: C++ sources making up the module.
|
||||||
|
@ -110,75 +84,25 @@ endfunction()
|
||||||
function(declare_mlir_python_extension name)
|
function(declare_mlir_python_extension name)
|
||||||
cmake_parse_arguments(ARG
|
cmake_parse_arguments(ARG
|
||||||
""
|
""
|
||||||
"ROOT_DIR;MODULE_NAME;ADD_TO_PARENT"
|
"MODULE_NAME;ADD_TO_PARENT"
|
||||||
"SOURCES;PRIVATE_LINK_LIBS;EMBED_CAPI_LINK_LIBS"
|
"SOURCES;PRIVATE_LINK_LIBS;EMBED_CAPI_LINK_LIBS"
|
||||||
${ARGN})
|
${ARGN})
|
||||||
|
|
||||||
if(NOT ARG_ROOT_DIR)
|
add_custom_target(${name})
|
||||||
set(ARG_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
||||||
endif()
|
|
||||||
set(_install_destination "src/python/${name}")
|
|
||||||
|
|
||||||
add_library(${name} INTERFACE)
|
|
||||||
set_target_properties(${name} PROPERTIES
|
set_target_properties(${name} PROPERTIES
|
||||||
# Yes: Leading-lowercase property names are load bearing and the recommended
|
PYTHON_SOURCES_TYPE extension
|
||||||
# way to do this: https://gitlab.kitware.com/cmake/cmake/-/issues/19261
|
PYTHON_EXTENSION_MODULE_NAME "${ARG_MODULE_NAME}"
|
||||||
# Note that ROOT_DIR and FILE_DEPENDS are not exported because they are
|
PYTHON_CPP_SOURCES "${ARG_SOURCES}"
|
||||||
# only relevant to in-tree uses.
|
PYTHON_PRIVATE_LINK_LIBS "${ARG_PRIVATE_LINK_LIBS}"
|
||||||
EXPORT_PROPERTIES "mlir_python_SOURCES_TYPE;mlir_python_EXTENSION_MODULE_NAME;mlir_python_CPP_SOURCES;mlir_python_PRIVATE_LINK_LIBS;mlir_python_EMBED_CAPI_LINK_LIBS;mlir_python_DEPENDS"
|
PYTHON_EMBED_CAPI_LINK_LIBS "${ARG_EMBED_CAPI_LINK_LIBS}"
|
||||||
mlir_python_SOURCES_TYPE extension
|
PYTHON_FILE_DEPENDS ""
|
||||||
mlir_python_ROOT_DIR "${ARG_ROOT_DIR}"
|
PYTHON_DEPENDS ""
|
||||||
mlir_python_EXTENSION_MODULE_NAME "${ARG_MODULE_NAME}"
|
|
||||||
mlir_python_CPP_SOURCES "${ARG_SOURCES}"
|
|
||||||
mlir_python_PRIVATE_LINK_LIBS "${ARG_PRIVATE_LINK_LIBS}"
|
|
||||||
mlir_python_EMBED_CAPI_LINK_LIBS "${ARG_EMBED_CAPI_LINK_LIBS}"
|
|
||||||
mlir_python_FILE_DEPENDS ""
|
|
||||||
mlir_python_DEPENDS ""
|
|
||||||
)
|
|
||||||
# Note that an "include" directory has no meaning to such faux targets,
|
|
||||||
# but it is a CMake supported way to specify an install-prefix relative
|
|
||||||
# directory. It has some super powers which are not possible to emulate
|
|
||||||
# with custom properties (because of the prohibition on using generator
|
|
||||||
# expressions in exported custom properties and the special dispensation
|
|
||||||
# for $<INSTALL_PREFIX> and $<INSTALL_INTERFACE>). On imported targets,
|
|
||||||
# this is used as a single value, not as a list, so it must only have one
|
|
||||||
# item in it.
|
|
||||||
target_include_directories(${name} INTERFACE
|
|
||||||
"$<INSTALL_INTERFACE:${_install_destination}>"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add to parent.
|
# Add to parent.
|
||||||
if(ARG_ADD_TO_PARENT)
|
if(ARG_ADD_TO_PARENT)
|
||||||
set_property(TARGET ${ARG_ADD_TO_PARENT} APPEND PROPERTY mlir_python_DEPENDS ${name})
|
set_property(TARGET ${ARG_ADD_TO_PARENT} APPEND PROPERTY PYTHON_DEPENDS ${name})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Install.
|
|
||||||
if(NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
|
||||||
_mlir_python_install_sources(
|
|
||||||
${name} "${ARG_ROOT_DIR}" "src/python/${name}"
|
|
||||||
${ARG_SOURCES}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
function(_mlir_python_install_sources name source_root_dir destination)
|
|
||||||
foreach(source_relative_path ${ARGN})
|
|
||||||
# Transform "a/b/c.py" -> "${install_prefix}/a/b" for installation.
|
|
||||||
get_filename_component(
|
|
||||||
dest_relative_path "${source_relative_path}" DIRECTORY
|
|
||||||
BASE_DIR "${source_root_dir}"
|
|
||||||
)
|
|
||||||
install(
|
|
||||||
FILES "${source_root_dir}/${source_relative_path}"
|
|
||||||
DESTINATION "${destination}/${dest_relative_path}"
|
|
||||||
COMPONENT "${name}"
|
|
||||||
)
|
|
||||||
endforeach()
|
|
||||||
get_target_export_arg(${name} MLIR export_to_mlirtargets UMBRELLA mlir-libraries)
|
|
||||||
install(TARGETS ${name}
|
|
||||||
COMPONENT ${name}
|
|
||||||
${export_to_mlirtargets}
|
|
||||||
)
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Function: add_mlir_python_modules
|
# Function: add_mlir_python_modules
|
||||||
|
@ -204,26 +128,12 @@ function(add_mlir_python_modules name)
|
||||||
${ARGN})
|
${ARGN})
|
||||||
# Helper to process an individual target.
|
# Helper to process an individual target.
|
||||||
function(_process_target modules_target sources_target)
|
function(_process_target modules_target sources_target)
|
||||||
get_target_property(_source_type ${sources_target} mlir_python_SOURCES_TYPE)
|
get_target_property(_source_type ${sources_target} PYTHON_SOURCES_TYPE)
|
||||||
|
|
||||||
# The root directory differs based on whether it is IMPORTED (installed
|
|
||||||
# dep).
|
|
||||||
get_target_property(_is_imported ${sources_target} IMPORTED)
|
|
||||||
if(NOT _is_imported)
|
|
||||||
# In-tree.
|
|
||||||
get_target_property(_python_root_dir ${sources_target} mlir_python_ROOT_DIR)
|
|
||||||
else()
|
|
||||||
# Imported.
|
|
||||||
# Note: We only populate a single directory in
|
|
||||||
# INTERFACE_INCLUDE_DIRECTORIES, so we can get away with just using it
|
|
||||||
# as a single value.
|
|
||||||
get_target_property(_python_root_dir ${sources_target} INTERFACE_INCLUDE_DIRECTORIES)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(_source_type STREQUAL "pure")
|
if(_source_type STREQUAL "pure")
|
||||||
# Pure python sources to link into the tree.
|
# Pure python sources to link into the tree.
|
||||||
get_target_property(_python_sources ${sources_target} mlir_python_SOURCES)
|
get_target_property(_python_root_dir ${sources_target} PYTHON_ROOT_DIR)
|
||||||
get_target_property(_specified_dest_prefix ${sources_target} mlir_python_DEST_PREFIX)
|
get_target_property(_python_sources ${sources_target} PYTHON_SOURCES)
|
||||||
|
get_target_property(_specified_dest_prefix ${sources_target} PYTHON_DEST_PREFIX)
|
||||||
foreach(_source_relative_path ${_python_sources})
|
foreach(_source_relative_path ${_python_sources})
|
||||||
set(_dest_relative_path "${_source_relative_path}")
|
set(_dest_relative_path "${_source_relative_path}")
|
||||||
if(_specified_dest_prefix)
|
if(_specified_dest_prefix)
|
||||||
|
@ -252,11 +162,9 @@ function(add_mlir_python_modules name)
|
||||||
endforeach()
|
endforeach()
|
||||||
elseif(_source_type STREQUAL "extension")
|
elseif(_source_type STREQUAL "extension")
|
||||||
# Native CPP extension.
|
# Native CPP extension.
|
||||||
get_target_property(_module_name ${sources_target} mlir_python_EXTENSION_MODULE_NAME)
|
get_target_property(_module_name ${sources_target} PYTHON_EXTENSION_MODULE_NAME)
|
||||||
get_target_property(_cpp_sources ${sources_target} mlir_python_CPP_SOURCES)
|
get_target_property(_cpp_sources ${sources_target} PYTHON_CPP_SOURCES)
|
||||||
get_target_property(_private_link_libs ${sources_target} mlir_python_PRIVATE_LINK_LIBS)
|
get_target_property(_private_link_libs ${sources_target} PYTHON_PRIVATE_LINK_LIBS)
|
||||||
# Transform relative source to based on root dir.
|
|
||||||
list(TRANSFORM _cpp_sources PREPEND "${_python_root_dir}/")
|
|
||||||
set(_extension_target "${name}.extension.${_module_name}.dso")
|
set(_extension_target "${name}.extension.${_module_name}.dso")
|
||||||
add_mlir_python_extension(${_extension_target} "${_module_name}"
|
add_mlir_python_extension(${_extension_target} "${_module_name}"
|
||||||
INSTALL_COMPONENT ${modules_target}
|
INSTALL_COMPONENT ${modules_target}
|
||||||
|
@ -279,10 +187,8 @@ function(add_mlir_python_modules name)
|
||||||
# Collect dependencies.
|
# Collect dependencies.
|
||||||
set(_depends)
|
set(_depends)
|
||||||
foreach(sources_target ${_flat_targets})
|
foreach(sources_target ${_flat_targets})
|
||||||
get_target_property(_local_depends ${sources_target} mlir_python_FILE_DEPENDS)
|
get_target_property(_local_depends ${sources_target} PYTHON_FILE_DEPENDS)
|
||||||
if(_local_depends)
|
list(APPEND _depends ${_local_depends})
|
||||||
list(APPEND _depends ${_local_depends})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Build the modules target.
|
# Build the modules target.
|
||||||
|
@ -428,7 +334,7 @@ function(add_mlir_python_common_capi_library name)
|
||||||
set(_embed_libs ${ARG_EMBED_LIBS})
|
set(_embed_libs ${ARG_EMBED_LIBS})
|
||||||
_flatten_mlir_python_targets(_all_source_targets ${ARG_DECLARED_SOURCES})
|
_flatten_mlir_python_targets(_all_source_targets ${ARG_DECLARED_SOURCES})
|
||||||
foreach(t ${_all_source_targets})
|
foreach(t ${_all_source_targets})
|
||||||
get_target_property(_local_embed_libs ${t} mlir_python_EMBED_CAPI_LINK_LIBS)
|
get_target_property(_local_embed_libs ${t} PYTHON_EMBED_CAPI_LINK_LIBS)
|
||||||
if(_local_embed_libs)
|
if(_local_embed_libs)
|
||||||
list(APPEND _embed_libs ${_local_embed_libs})
|
list(APPEND _embed_libs ${_local_embed_libs})
|
||||||
endif()
|
endif()
|
||||||
|
@ -466,8 +372,8 @@ endfunction()
|
||||||
function(_flatten_mlir_python_targets output_var)
|
function(_flatten_mlir_python_targets output_var)
|
||||||
set(_flattened)
|
set(_flattened)
|
||||||
foreach(t ${ARGN})
|
foreach(t ${ARGN})
|
||||||
get_target_property(_source_type ${t} mlir_python_SOURCES_TYPE)
|
get_target_property(_source_type ${t} PYTHON_SOURCES_TYPE)
|
||||||
get_target_property(_depends ${t} mlir_python_DEPENDS)
|
get_target_property(_depends ${t} PYTHON_DEPENDS)
|
||||||
if(_source_type)
|
if(_source_type)
|
||||||
list(APPEND _flattened "${t}")
|
list(APPEND _flattened "${t}")
|
||||||
if(_depends)
|
if(_depends)
|
||||||
|
|
|
@ -10,7 +10,6 @@ set(MLIR_CMAKE_DIR "@MLIR_CONFIG_CMAKE_DIR@")
|
||||||
set(MLIR_INCLUDE_DIRS "@MLIR_CONFIG_INCLUDE_DIRS@")
|
set(MLIR_INCLUDE_DIRS "@MLIR_CONFIG_INCLUDE_DIRS@")
|
||||||
set(MLIR_TABLEGEN_EXE "@MLIR_TABLEGEN_EXE@")
|
set(MLIR_TABLEGEN_EXE "@MLIR_TABLEGEN_EXE@")
|
||||||
set(MLIR_INSTALL_AGGREGATE_OBJECTS "@MLIR_INSTALL_AGGREGATE_OBJECTS@")
|
set(MLIR_INSTALL_AGGREGATE_OBJECTS "@MLIR_INSTALL_AGGREGATE_OBJECTS@")
|
||||||
set(MLIR_ENABLE_BINDINGS_PYTHON "@MLIR_ENABLE_BINDINGS_PYTHON@")
|
|
||||||
|
|
||||||
# For mlir_tablegen()
|
# For mlir_tablegen()
|
||||||
set(MLIR_INCLUDE_DIR "@MLIR_INCLUDE_DIR@")
|
set(MLIR_INCLUDE_DIR "@MLIR_INCLUDE_DIR@")
|
||||||
|
|
|
@ -20,12 +20,6 @@ include(TableGen)
|
||||||
include(AddLLVM)
|
include(AddLLVM)
|
||||||
include(AddMLIR)
|
include(AddMLIR)
|
||||||
include(HandleLLVMOptions)
|
include(HandleLLVMOptions)
|
||||||
include(MLIRDetectPythonEnv)
|
|
||||||
|
|
||||||
if(MLIR_ENABLE_BINDINGS_PYTHON)
|
|
||||||
include(MLIRDetectPythonEnv)
|
|
||||||
mlir_configure_python_dev_packages()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include_directories(${LLVM_INCLUDE_DIRS})
|
include_directories(${LLVM_INCLUDE_DIRS})
|
||||||
include_directories(${MLIR_INCLUDE_DIRS})
|
include_directories(${MLIR_INCLUDE_DIRS})
|
||||||
|
@ -36,10 +30,6 @@ add_definitions(${LLVM_DEFINITIONS})
|
||||||
|
|
||||||
add_subdirectory(include)
|
add_subdirectory(include)
|
||||||
add_subdirectory(lib)
|
add_subdirectory(lib)
|
||||||
if(MLIR_ENABLE_BINDINGS_PYTHON)
|
|
||||||
message(STATUS "Enabling Python API")
|
|
||||||
add_subdirectory(python)
|
|
||||||
endif()
|
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
add_subdirectory(standalone-opt)
|
add_subdirectory(standalone-opt)
|
||||||
add_subdirectory(standalone-translate)
|
add_subdirectory(standalone-translate)
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#ifndef STANDALONE_OPS
|
#ifndef STANDALONE_OPS
|
||||||
#define STANDALONE_OPS
|
#define STANDALONE_OPS
|
||||||
|
|
||||||
include "Standalone/StandaloneDialect.td"
|
include "StandaloneDialect.td"
|
||||||
include "mlir/Interfaces/SideEffectInterfaces.td"
|
include "mlir/Interfaces/SideEffectInterfaces.td"
|
||||||
|
|
||||||
def Standalone_FooOp : Standalone_Op<"foo", [NoSideEffect,
|
def Standalone_FooOp : Standalone_Op<"foo", [NoSideEffect,
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
include(AddMLIRPython)
|
|
||||||
|
|
||||||
# Specifies that all MLIR packages are co-located under the `mlir_standalone`
|
|
||||||
# top level package (the API has been embedded in a relocatable way).
|
|
||||||
# TODO: Add an upstream cmake param for this vs having a global here.
|
|
||||||
add_compile_definitions("MLIR_PYTHON_PACKAGE_PREFIX=mlir_standalone.")
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# Sources
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
declare_mlir_python_sources(StandalonePythonSources)
|
|
||||||
|
|
||||||
declare_mlir_dialect_python_bindings(
|
|
||||||
ADD_TO_PARENT StandalonePythonSources
|
|
||||||
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir_standalone"
|
|
||||||
TD_FILE dialects/StandaloneOps.td
|
|
||||||
SOURCES
|
|
||||||
dialects/standalone.py
|
|
||||||
DIALECT_NAME standalone)
|
|
||||||
|
|
||||||
declare_mlir_python_extension(StandalonePythonSources.Extension
|
|
||||||
MODULE_NAME _standaloneDialects
|
|
||||||
ADD_TO_PARENT StandalonePythonSources
|
|
||||||
SOURCES
|
|
||||||
StandaloneExtension.cpp
|
|
||||||
EMBED_CAPI_LINK_LIBS
|
|
||||||
StandaloneCAPI
|
|
||||||
)
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# Common CAPI
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
add_mlir_python_common_capi_library(StandalonePythonCAPI
|
|
||||||
INSTALL_COMPONENT StandalonePythonModules
|
|
||||||
INSTALL_DESTINATION python_packages/standalone/mlir_standalone/_mlir_libs
|
|
||||||
OUTPUT_DIRECTORY "${MLIR_BINARY_DIR}/python_packages/standalone/mlir_standalone/_mlir_libs"
|
|
||||||
RELATIVE_INSTALL_ROOT "../../../.."
|
|
||||||
DECLARED_SOURCES
|
|
||||||
StandalonePythonSources
|
|
||||||
MLIRPythonSources.Core
|
|
||||||
)
|
|
||||||
|
|
||||||
################################################################################
|
|
||||||
# Instantiation of all Python modules
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
add_mlir_python_modules(StandalonePythonModules
|
|
||||||
ROOT_PREFIX "${MLIR_BINARY_DIR}/python_packages/standalone/mlir_standalone"
|
|
||||||
INSTALL_PREFIX "python_packages/standalone/mlir_standalone"
|
|
||||||
DECLARED_SOURCES
|
|
||||||
StandalonePythonSources
|
|
||||||
MLIRPythonSources
|
|
||||||
COMMON_CAPI_LINK_LIBS
|
|
||||||
StandalonePythonCAPI
|
|
||||||
)
|
|
|
@ -1,31 +0,0 @@
|
||||||
//===- StandaloneExtension.cpp - Extension module -------------------------===//
|
|
||||||
//
|
|
||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
|
||||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#include "Standalone-c/Dialects.h"
|
|
||||||
#include "mlir/Bindings/Python/PybindAdaptors.h"
|
|
||||||
|
|
||||||
namespace py = pybind11;
|
|
||||||
using namespace mlir::python::adaptors;
|
|
||||||
|
|
||||||
PYBIND11_MODULE(_standaloneDialects, m) {
|
|
||||||
//===--------------------------------------------------------------------===//
|
|
||||||
// standalone dialect
|
|
||||||
//===--------------------------------------------------------------------===//
|
|
||||||
auto standalone_m = m.def_submodule("standalone");
|
|
||||||
|
|
||||||
standalone_m.def(
|
|
||||||
"register_dialect",
|
|
||||||
[](MlirContext context, bool load) {
|
|
||||||
MlirDialectHandle handle = mlirGetDialectHandle__standalone__();
|
|
||||||
mlirDialectHandleRegisterDialect(handle, context);
|
|
||||||
if (load) {
|
|
||||||
mlirDialectHandleLoadDialect(handle, context);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
py::arg("context") = py::none(), py::arg("load") = true);
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
//===-- StandaloneOps.td - Python bindings for standalone --*- tablegen -*-===//
|
|
||||||
//
|
|
||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
|
||||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
||||||
//
|
|
||||||
//===---------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#ifndef PYTHON_BINDINGS_STANDALONE_OPS
|
|
||||||
#define PYTHON_BINDINGS_STANDALONE_OPS
|
|
||||||
|
|
||||||
include "mlir/Bindings/Python/Attributes.td"
|
|
||||||
include "Standalone/StandaloneOps.td"
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,6 +0,0 @@
|
||||||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
||||||
# See https://llvm.org/LICENSE.txt for license information.
|
|
||||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
||||||
|
|
||||||
from ._standalone_ops_gen import *
|
|
||||||
from .._mlir_libs._standaloneDialects.standalone import *
|
|
|
@ -1,7 +1,3 @@
|
||||||
llvm_canonicalize_cmake_booleans(
|
|
||||||
MLIR_ENABLE_BINDINGS_PYTHON
|
|
||||||
)
|
|
||||||
|
|
||||||
configure_lit_site_cfg(
|
configure_lit_site_cfg(
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
|
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
|
||||||
|
|
|
@ -56,12 +56,7 @@ tool_dirs = [config.standalone_tools_dir, config.llvm_tools_dir]
|
||||||
tools = [
|
tools = [
|
||||||
'standalone-capi-test',
|
'standalone-capi-test',
|
||||||
'standalone-opt',
|
'standalone-opt',
|
||||||
'standalone-translate',
|
'standalone-translate'
|
||||||
ToolSubst('%PYTHON', config.python_executable, unresolved='ignore'),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
llvm_config.add_tool_substitutions(tools, tool_dirs)
|
llvm_config.add_tool_substitutions(tools, tool_dirs)
|
||||||
|
|
||||||
llvm_config.with_environment('PYTHONPATH', [
|
|
||||||
os.path.join(config.mlir_binary_dir, 'python_packages', 'standalone'),
|
|
||||||
], append_path=True)
|
|
||||||
|
|
|
@ -12,9 +12,7 @@ config.llvm_shlib_dir = "@SHLIBDIR@"
|
||||||
config.llvm_shlib_ext = "@SHLIBEXT@"
|
config.llvm_shlib_ext = "@SHLIBEXT@"
|
||||||
config.llvm_exe_ext = "@EXEEXT@"
|
config.llvm_exe_ext = "@EXEEXT@"
|
||||||
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
|
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
|
||||||
config.mlir_binary_dir = "@MLIR_BINARY_DIR@"
|
config.python_executable = "@PYTHON_EXECUTABLE@"
|
||||||
config.python_executable = "@Python3_EXECUTABLE@"
|
|
||||||
config.enable_bindings_python = @MLIR_ENABLE_BINDINGS_PYTHON@
|
|
||||||
config.gold_executable = "@GOLD_EXECUTABLE@"
|
config.gold_executable = "@GOLD_EXECUTABLE@"
|
||||||
config.ld64_executable = "@LD64_EXECUTABLE@"
|
config.ld64_executable = "@LD64_EXECUTABLE@"
|
||||||
config.enable_shared = @ENABLE_SHARED@
|
config.enable_shared = @ENABLE_SHARED@
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
config.suffixes.add('.py')
|
|
||||||
|
|
||||||
if not config.enable_bindings_python:
|
|
||||||
config.unsupported = True
|
|
|
@ -1,17 +0,0 @@
|
||||||
# RUN: %PYTHON %s | FileCheck %s
|
|
||||||
|
|
||||||
from mlir_standalone.ir import *
|
|
||||||
from mlir_standalone.dialects import (
|
|
||||||
builtin as builtin_d,
|
|
||||||
standalone as standalone_d
|
|
||||||
)
|
|
||||||
|
|
||||||
with Context():
|
|
||||||
standalone_d.register_dialect()
|
|
||||||
module = Module.parse("""
|
|
||||||
%0 = constant 2 : i32
|
|
||||||
%1 = standalone.foo %0 : i32
|
|
||||||
""")
|
|
||||||
# CHECK: %[[C:.*]] = constant 2 : i32
|
|
||||||
# CHECK: standalone.foo %[[C]] : i32
|
|
||||||
print(str(module))
|
|
|
@ -174,26 +174,18 @@ set(PYTHON_SOURCE_DIR "${MLIR_SOURCE_DIR}/lib/Bindings/Python")
|
||||||
declare_mlir_python_extension(MLIRPythonExtension.Core
|
declare_mlir_python_extension(MLIRPythonExtension.Core
|
||||||
MODULE_NAME _mlir
|
MODULE_NAME _mlir
|
||||||
ADD_TO_PARENT MLIRPythonSources.Core
|
ADD_TO_PARENT MLIRPythonSources.Core
|
||||||
ROOT_DIR "${PYTHON_SOURCE_DIR}"
|
|
||||||
SOURCES
|
SOURCES
|
||||||
DialectLinalg.cpp # TODO: Break this out.
|
${PYTHON_SOURCE_DIR}/DialectLinalg.cpp # TODO: Break this out.
|
||||||
DialectSparseTensor.cpp # TODO: Break this out.
|
${PYTHON_SOURCE_DIR}/DialectSparseTensor.cpp # TODO: Break this out.
|
||||||
MainModule.cpp
|
${PYTHON_SOURCE_DIR}/MainModule.cpp
|
||||||
IRAffine.cpp
|
${PYTHON_SOURCE_DIR}/IRAffine.cpp
|
||||||
IRAttributes.cpp
|
${PYTHON_SOURCE_DIR}/IRAttributes.cpp
|
||||||
IRCore.cpp
|
${PYTHON_SOURCE_DIR}/IRCore.cpp
|
||||||
IRInterfaces.cpp
|
${PYTHON_SOURCE_DIR}/IRInterfaces.cpp
|
||||||
IRModule.cpp
|
${PYTHON_SOURCE_DIR}/IRModule.cpp
|
||||||
IRTypes.cpp
|
${PYTHON_SOURCE_DIR}/IRTypes.cpp
|
||||||
PybindUtils.cpp
|
${PYTHON_SOURCE_DIR}/PybindUtils.cpp
|
||||||
Pass.cpp
|
${PYTHON_SOURCE_DIR}/Pass.cpp
|
||||||
|
|
||||||
# Headers must be included explicitly so they are installed.
|
|
||||||
Dialects.h
|
|
||||||
Globals.h
|
|
||||||
IRModule.h
|
|
||||||
Pass.h
|
|
||||||
PybindUtils.h
|
|
||||||
PRIVATE_LINK_LIBS
|
PRIVATE_LINK_LIBS
|
||||||
LLVMSupport
|
LLVMSupport
|
||||||
EMBED_CAPI_LINK_LIBS
|
EMBED_CAPI_LINK_LIBS
|
||||||
|
@ -210,9 +202,8 @@ declare_mlir_python_extension(MLIRPythonExtension.Core
|
||||||
|
|
||||||
declare_mlir_python_extension(MLIRPythonExtension.AllPassesRegistration
|
declare_mlir_python_extension(MLIRPythonExtension.AllPassesRegistration
|
||||||
MODULE_NAME _mlirAllPassesRegistration
|
MODULE_NAME _mlirAllPassesRegistration
|
||||||
ROOT_DIR "${PYTHON_SOURCE_DIR}"
|
|
||||||
SOURCES
|
SOURCES
|
||||||
AllPassesRegistration.cpp
|
${PYTHON_SOURCE_DIR}/AllPassesRegistration.cpp
|
||||||
PRIVATE_LINK_LIBS
|
PRIVATE_LINK_LIBS
|
||||||
LLVMSupport
|
LLVMSupport
|
||||||
EMBED_CAPI_LINK_LIBS
|
EMBED_CAPI_LINK_LIBS
|
||||||
|
@ -223,9 +214,8 @@ declare_mlir_python_extension(MLIRPythonExtension.AllPassesRegistration
|
||||||
declare_mlir_python_extension(MLIRPythonExtension.AsyncDialectPasses
|
declare_mlir_python_extension(MLIRPythonExtension.AsyncDialectPasses
|
||||||
MODULE_NAME _mlirAsyncPasses
|
MODULE_NAME _mlirAsyncPasses
|
||||||
ADD_TO_PARENT MLIRPythonSources.Dialects.async_dialect
|
ADD_TO_PARENT MLIRPythonSources.Dialects.async_dialect
|
||||||
ROOT_DIR "${PYTHON_SOURCE_DIR}"
|
|
||||||
SOURCES
|
SOURCES
|
||||||
AsyncPasses.cpp
|
${PYTHON_SOURCE_DIR}/AsyncPasses.cpp
|
||||||
PRIVATE_LINK_LIBS
|
PRIVATE_LINK_LIBS
|
||||||
LLVMSupport
|
LLVMSupport
|
||||||
EMBED_CAPI_LINK_LIBS
|
EMBED_CAPI_LINK_LIBS
|
||||||
|
@ -235,9 +225,8 @@ declare_mlir_python_extension(MLIRPythonExtension.AsyncDialectPasses
|
||||||
declare_mlir_python_extension(MLIRPythonExtension.Conversions
|
declare_mlir_python_extension(MLIRPythonExtension.Conversions
|
||||||
MODULE_NAME _mlirConversions
|
MODULE_NAME _mlirConversions
|
||||||
ADD_TO_PARENT MLIRPythonSources.Passes
|
ADD_TO_PARENT MLIRPythonSources.Passes
|
||||||
ROOT_DIR "${PYTHON_SOURCE_DIR}"
|
|
||||||
SOURCES
|
SOURCES
|
||||||
Conversions/Conversions.cpp
|
${PYTHON_SOURCE_DIR}/Conversions/Conversions.cpp
|
||||||
PRIVATE_LINK_LIBS
|
PRIVATE_LINK_LIBS
|
||||||
LLVMSupport
|
LLVMSupport
|
||||||
EMBED_CAPI_LINK_LIBS
|
EMBED_CAPI_LINK_LIBS
|
||||||
|
@ -247,9 +236,8 @@ declare_mlir_python_extension(MLIRPythonExtension.Conversions
|
||||||
declare_mlir_python_extension(MLIRPythonExtension.ExecutionEngine
|
declare_mlir_python_extension(MLIRPythonExtension.ExecutionEngine
|
||||||
MODULE_NAME _mlirExecutionEngine
|
MODULE_NAME _mlirExecutionEngine
|
||||||
ADD_TO_PARENT MLIRPythonSources.ExecutionEngine
|
ADD_TO_PARENT MLIRPythonSources.ExecutionEngine
|
||||||
ROOT_DIR "${PYTHON_SOURCE_DIR}"
|
|
||||||
SOURCES
|
SOURCES
|
||||||
ExecutionEngineModule.cpp
|
${PYTHON_SOURCE_DIR}/ExecutionEngineModule.cpp
|
||||||
PRIVATE_LINK_LIBS
|
PRIVATE_LINK_LIBS
|
||||||
LLVMSupport
|
LLVMSupport
|
||||||
EMBED_CAPI_LINK_LIBS
|
EMBED_CAPI_LINK_LIBS
|
||||||
|
@ -259,9 +247,8 @@ declare_mlir_python_extension(MLIRPythonExtension.ExecutionEngine
|
||||||
declare_mlir_python_extension(MLIRPythonExtension.GPUDialectPasses
|
declare_mlir_python_extension(MLIRPythonExtension.GPUDialectPasses
|
||||||
MODULE_NAME _mlirGPUPasses
|
MODULE_NAME _mlirGPUPasses
|
||||||
ADD_TO_PARENT MLIRPythonSources.Dialects.gpu
|
ADD_TO_PARENT MLIRPythonSources.Dialects.gpu
|
||||||
ROOT_DIR "${PYTHON_SOURCE_DIR}"
|
|
||||||
SOURCES
|
SOURCES
|
||||||
GPUPasses.cpp
|
${PYTHON_SOURCE_DIR}/GPUPasses.cpp
|
||||||
PRIVATE_LINK_LIBS
|
PRIVATE_LINK_LIBS
|
||||||
LLVMSupport
|
LLVMSupport
|
||||||
EMBED_CAPI_LINK_LIBS
|
EMBED_CAPI_LINK_LIBS
|
||||||
|
@ -271,9 +258,8 @@ declare_mlir_python_extension(MLIRPythonExtension.GPUDialectPasses
|
||||||
declare_mlir_python_extension(MLIRPythonExtension.LinalgPasses
|
declare_mlir_python_extension(MLIRPythonExtension.LinalgPasses
|
||||||
MODULE_NAME _mlirLinalgPasses
|
MODULE_NAME _mlirLinalgPasses
|
||||||
ADD_TO_PARENT MLIRPythonSources.Dialects.linalg
|
ADD_TO_PARENT MLIRPythonSources.Dialects.linalg
|
||||||
ROOT_DIR "${PYTHON_SOURCE_DIR}"
|
|
||||||
SOURCES
|
SOURCES
|
||||||
LinalgPasses.cpp
|
${PYTHON_SOURCE_DIR}/LinalgPasses.cpp
|
||||||
PRIVATE_LINK_LIBS
|
PRIVATE_LINK_LIBS
|
||||||
LLVMSupport
|
LLVMSupport
|
||||||
EMBED_CAPI_LINK_LIBS
|
EMBED_CAPI_LINK_LIBS
|
||||||
|
@ -283,9 +269,8 @@ declare_mlir_python_extension(MLIRPythonExtension.LinalgPasses
|
||||||
declare_mlir_python_extension(MLIRPythonExtension.SparseTensorDialectPasses
|
declare_mlir_python_extension(MLIRPythonExtension.SparseTensorDialectPasses
|
||||||
MODULE_NAME _mlirSparseTensorPasses
|
MODULE_NAME _mlirSparseTensorPasses
|
||||||
ADD_TO_PARENT MLIRPythonSources.Dialects.sparse_tensor
|
ADD_TO_PARENT MLIRPythonSources.Dialects.sparse_tensor
|
||||||
ROOT_DIR "${PYTHON_SOURCE_DIR}"
|
|
||||||
SOURCES
|
SOURCES
|
||||||
SparseTensorPasses.cpp
|
${PYTHON_SOURCE_DIR}/SparseTensorPasses.cpp
|
||||||
PRIVATE_LINK_LIBS
|
PRIVATE_LINK_LIBS
|
||||||
LLVMSupport
|
LLVMSupport
|
||||||
EMBED_CAPI_LINK_LIBS
|
EMBED_CAPI_LINK_LIBS
|
||||||
|
@ -295,9 +280,8 @@ declare_mlir_python_extension(MLIRPythonExtension.SparseTensorDialectPasses
|
||||||
declare_mlir_python_extension(MLIRPythonExtension.Transforms
|
declare_mlir_python_extension(MLIRPythonExtension.Transforms
|
||||||
MODULE_NAME _mlirTransforms
|
MODULE_NAME _mlirTransforms
|
||||||
ADD_TO_PARENT MLIRPythonSources.Passes
|
ADD_TO_PARENT MLIRPythonSources.Passes
|
||||||
ROOT_DIR "${PYTHON_SOURCE_DIR}"
|
|
||||||
SOURCES
|
SOURCES
|
||||||
Transforms/Transforms.cpp
|
${PYTHON_SOURCE_DIR}/Transforms/Transforms.cpp
|
||||||
PRIVATE_LINK_LIBS
|
PRIVATE_LINK_LIBS
|
||||||
LLVMSupport
|
LLVMSupport
|
||||||
EMBED_CAPI_LINK_LIBS
|
EMBED_CAPI_LINK_LIBS
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
# RUN: %cmake %mlir_src_root/examples/standalone -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc -DLLVM_ENABLE_LIBCXX=%enable_libcxx -DMLIR_DIR=%mlir_cmake_dir ; %cmake --build . --target check-standalone | tee %t | FileCheck %s
|
# RUN: %cmake %mlir_src_root/examples/standalone -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc -DLLVM_ENABLE_LIBCXX=%enable_libcxx -DMLIR_DIR=%mlir_cmake_dir ; %cmake --build . --target check-standalone | tee %t | FileCheck %s
|
||||||
|
|
||||||
# Note: The number of checked tests is not important. The command will fail
|
# CHECK: Passed: 4
|
||||||
# if any fail.
|
|
||||||
# CHECK: Passed
|
|
||||||
# UNSUPPORTED: windows, android
|
# UNSUPPORTED: windows, android
|
||||||
|
|
Loading…
Reference in New Issue