diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -146,6 +146,11 @@ # Generally things after this point may depend on MLIR_ALL_LIBS or libMLIR.so. add_subdirectory(tools) +if(MLIR_BINDINGS_PYTHON_ENABLED) + # Python sources: built extensions come in via lib/Bindings/Python + add_subdirectory(python) +endif() + if( LLVM_INCLUDE_EXAMPLES ) add_subdirectory(examples) endif() diff --git a/mlir/cmake/modules/AddMLIRPythonExtension.cmake b/mlir/cmake/modules/AddMLIRPython.cmake rename from mlir/cmake/modules/AddMLIRPythonExtension.cmake rename to mlir/cmake/modules/AddMLIRPython.cmake --- a/mlir/cmake/modules/AddMLIRPythonExtension.cmake +++ b/mlir/cmake/modules/AddMLIRPython.cmake @@ -156,6 +156,7 @@ add_custom_command( TARGET ${tblgen_target} POST_BUILD COMMENT "Copying generated python source \"dialects/${dialect_filename}\"" + BYPRODUCTS "${PROJECT_BINARY_DIR}/python/mlir/dialects/${dialect_filename}" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/${dialect_filename}" "${PROJECT_BINARY_DIR}/python/mlir/dialects/${dialect_filename}") diff --git a/mlir/cmake/modules/CMakeLists.txt b/mlir/cmake/modules/CMakeLists.txt --- a/mlir/cmake/modules/CMakeLists.txt +++ b/mlir/cmake/modules/CMakeLists.txt @@ -81,7 +81,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/MLIRConfig.cmake ${CMAKE_CURRENT_SOURCE_DIR}/AddMLIR.cmake - ${CMAKE_CURRENT_SOURCE_DIR}/AddMLIRPythonExtension.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/AddMLIRPython.cmake ${CMAKE_CURRENT_SOURCE_DIR}/MLIRDetectPythonEnv.cmake DESTINATION ${MLIR_INSTALL_PACKAGE_DIR} COMPONENT mlir-cmake-exports) diff --git a/mlir/lib/Bindings/Python/CMakeLists.txt b/mlir/lib/Bindings/Python/CMakeLists.txt --- a/mlir/lib/Bindings/Python/CMakeLists.txt +++ b/mlir/lib/Bindings/Python/CMakeLists.txt @@ -1,77 +1,6 @@ -include(AddMLIRPythonExtension) +include(AddMLIRPython) add_custom_target(MLIRBindingsPythonExtension) -################################################################################ -# Copy python source tree. -################################################################################ - -file(GLOB_RECURSE PY_SRC_FILES - RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}/mlir/*.py") - -add_custom_target(MLIRBindingsPythonSources ALL - DEPENDS ${PY_SRC_FILES} -) -add_dependencies(MLIRBindingsPythonExtension MLIRBindingsPythonSources) - -foreach(PY_SRC_FILE ${PY_SRC_FILES}) - set(PY_DEST_FILE "${PROJECT_BINARY_DIR}/python/${PY_SRC_FILE}") - get_filename_component(PY_DEST_DIR "${PY_DEST_FILE}" DIRECTORY) - file(MAKE_DIRECTORY "${PY_DEST_DIR}") - add_custom_command( - TARGET MLIRBindingsPythonSources PRE_BUILD - COMMENT "Copying python source ${PY_SRC_FILE} -> ${PY_DEST_FILE}" - DEPENDS "${PY_SRC_FILE}" - COMMAND "${CMAKE_COMMAND}" -E create_symlink - "${CMAKE_CURRENT_SOURCE_DIR}/${PY_SRC_FILE}" "${PY_DEST_FILE}" - ) -endforeach() - -################################################################################ -# Generate dialect-specific bindings. -################################################################################ - -add_mlir_dialect_python_bindings(MLIRBindingsPythonAsyncOps - TD_FILE AsyncOps.td - DIALECT_NAME async_dialect) -add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonAsyncOps) - -add_mlir_dialect_python_bindings(MLIRBindingsPythonBuiltinOps - TD_FILE BuiltinOps.td - DIALECT_NAME builtin) -add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonBuiltinOps) - -add_mlir_dialect_python_bindings(MLIRBindingsPythonGPUOps - TD_FILE GPUOps.td - DIALECT_NAME gpu) -add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonGPUOps) - -add_mlir_dialect_python_bindings(MLIRBindingsPythonLinalgOps - TD_FILE LinalgOps.td - DIALECT_NAME linalg - DEPENDS LinalgOdsGen) -add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonLinalgOps) - -add_mlir_dialect_python_bindings(MLIRBindingsPythonMemRefOps - TD_FILE MemRefOps.td - DIALECT_NAME memref) -add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonMemRefOps) - -add_mlir_dialect_python_bindings(MLIRBindingsPythonShapeOps - TD_FILE ShapeOps.td - DIALECT_NAME shape) -add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonShapeOps) - -add_mlir_dialect_python_bindings(MLIRBindingsPythonStandardOps - TD_FILE StandardOps.td - DIALECT_NAME std) -add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonStandardOps) - -add_mlir_dialect_python_bindings(MLIRBindingsPythonTensorOps - TD_FILE TensorOps.td - DIALECT_NAME tensor) -add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonTensorOps) - ################################################################################ # Build core python extension ################################################################################ @@ -92,42 +21,6 @@ ) add_dependencies(MLIRBindingsPythonExtension MLIRCoreBindingsPythonExtension) -# Note that we copy from the source tree just like for headers because -# it will not be polluted with py_cache runtime artifacts (from testing and -# such). -install( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mlir - DESTINATION python - COMPONENT MLIRBindingsPythonSources - FILES_MATCHING PATTERN "*.py" -) - -if (NOT LLVM_ENABLE_IDE) - add_llvm_install_targets( - install-MLIRBindingsPythonSources - DEPENDS MLIRBindingsPythonSources - COMPONENT MLIRBindingsPythonSources) -endif() - -# Dialect sources are generated. Install separately. -# Note that __pycache__ directories may have been left by tests and other -# executions. And __init__.py is handled as a regular source file. -install( - DIRECTORY ${PROJECT_BINARY_DIR}/python/mlir/dialects - DESTINATION python/mlir - COMPONENT MLIRBindingsPythonDialects - FILES_MATCHING PATTERN "*.py" - PATTERN "__pycache__" EXCLUDE - PATTERN "__init__.py" EXCLUDE -) - -if (NOT LLVM_ENABLE_IDE) - add_llvm_install_targets( - install-MLIRBindingsPythonDialects - DEPENDS MLIRBindingsPythonSources - COMPONENT MLIRBindingsPythonDialects) -endif() - add_subdirectory(Transforms) add_subdirectory(Conversions) diff --git a/mlir/lib/Bindings/Python/.style.yapf b/mlir/python/.style.yapf rename from mlir/lib/Bindings/Python/.style.yapf rename to mlir/python/.style.yapf diff --git a/mlir/python/CMakeLists.txt b/mlir/python/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/mlir/python/CMakeLists.txt @@ -0,0 +1,49 @@ +################################################################################ +# Copy python source tree. +################################################################################ + +file(GLOB_RECURSE PY_SRC_FILES + RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/mlir/*.py") + +add_custom_target(MLIRBindingsPythonSources ALL + DEPENDS + ${PY_SRC_FILES} +) + +foreach(PY_SRC_FILE ${PY_SRC_FILES}) + set(PY_DEST_FILE "${PROJECT_BINARY_DIR}/python/${PY_SRC_FILE}") + get_filename_component(PY_DEST_DIR "${PY_DEST_FILE}" DIRECTORY) + file(MAKE_DIRECTORY "${PY_DEST_DIR}") + add_custom_command( + TARGET MLIRBindingsPythonSources PRE_BUILD + COMMENT "Copying python source ${PY_SRC_FILE} -> ${PY_DEST_FILE}" + DEPENDS "${PY_SRC_FILE}" + BYPRODUCTS "${PY_DEST_FILE}" + COMMAND "${CMAKE_COMMAND}" -E create_symlink + "${CMAKE_CURRENT_SOURCE_DIR}/${PY_SRC_FILE}" "${PY_DEST_FILE}" + ) +endforeach() + +# Note that we copy from the source tree just like for headers because +# it will not be polluted with py_cache runtime artifacts (from testing and +# such). +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mlir + DESTINATION python + COMPONENT MLIRBindingsPythonSources + FILES_MATCHING PATTERN "*.py" +) + +if (NOT LLVM_ENABLE_IDE) + add_llvm_install_targets( + install-MLIRBindingsPythonSources + DEPENDS MLIRBindingsPythonSources + COMPONENT MLIRBindingsPythonSources) +endif() + +################################################################################ +# Generated sources. +################################################################################ + +add_subdirectory(mlir/dialects) diff --git a/mlir/lib/Bindings/Python/mlir/_cext_loader.py b/mlir/python/mlir/_cext_loader.py rename from mlir/lib/Bindings/Python/mlir/_cext_loader.py rename to mlir/python/mlir/_cext_loader.py diff --git a/mlir/lib/Bindings/Python/mlir/_dlloader.py b/mlir/python/mlir/_dlloader.py rename from mlir/lib/Bindings/Python/mlir/_dlloader.py rename to mlir/python/mlir/_dlloader.py diff --git a/mlir/lib/Bindings/Python/mlir/conversions/__init__.py b/mlir/python/mlir/conversions/__init__.py rename from mlir/lib/Bindings/Python/mlir/conversions/__init__.py rename to mlir/python/mlir/conversions/__init__.py diff --git a/mlir/lib/Bindings/Python/AsyncOps.td b/mlir/python/mlir/dialects/AsyncOps.td rename from mlir/lib/Bindings/Python/AsyncOps.td rename to mlir/python/mlir/dialects/AsyncOps.td diff --git a/mlir/lib/Bindings/Python/BuiltinOps.td b/mlir/python/mlir/dialects/BuiltinOps.td rename from mlir/lib/Bindings/Python/BuiltinOps.td rename to mlir/python/mlir/dialects/BuiltinOps.td diff --git a/mlir/python/mlir/dialects/CMakeLists.txt b/mlir/python/mlir/dialects/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/mlir/python/mlir/dialects/CMakeLists.txt @@ -0,0 +1,71 @@ +include(AddMLIRPython) + +################################################################################ +# Generate dialect-specific bindings. +################################################################################ + +add_mlir_dialect_python_bindings(MLIRBindingsPythonAsyncOps + TD_FILE AsyncOps.td + DIALECT_NAME async_dialect) +add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonAsyncOps) + +add_mlir_dialect_python_bindings(MLIRBindingsPythonBuiltinOps + TD_FILE BuiltinOps.td + DIALECT_NAME builtin) +add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonBuiltinOps) + +add_mlir_dialect_python_bindings(MLIRBindingsPythonGPUOps + TD_FILE GPUOps.td + DIALECT_NAME gpu) +add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonGPUOps) + +add_mlir_dialect_python_bindings(MLIRBindingsPythonLinalgOps + TD_FILE LinalgOps.td + DIALECT_NAME linalg + DEPENDS LinalgOdsGen) +add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonLinalgOps) + +add_mlir_dialect_python_bindings(MLIRBindingsPythonMemRefOps + TD_FILE MemRefOps.td + DIALECT_NAME memref) +add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonMemRefOps) + +add_mlir_dialect_python_bindings(MLIRBindingsPythonShapeOps + TD_FILE ShapeOps.td + DIALECT_NAME shape) +add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonShapeOps) + +add_mlir_dialect_python_bindings(MLIRBindingsPythonStandardOps + TD_FILE StandardOps.td + DIALECT_NAME std) +add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonStandardOps) + +add_mlir_dialect_python_bindings(MLIRBindingsPythonTensorOps + TD_FILE TensorOps.td + DIALECT_NAME tensor) +add_dependencies(MLIRBindingsPythonSources MLIRBindingsPythonTensorOps) + +################################################################################ +# Installation. +################################################################################ + +# Dialect sources are generated. Install separately. +# Note that __pycache__ directories may have been left by tests and other +# executions. And __init__.py is handled as a regular source file. +# TODO: Eliminate this glob install, instead adding INSTALL_COMPONENT to +# add_mlir_dialect_python_bindings and installing the precise file there. +install( + DIRECTORY ${PROJECT_BINARY_DIR}/python/mlir/dialects + DESTINATION python/mlir + COMPONENT MLIRBindingsPythonDialects + FILES_MATCHING PATTERN "_*_gen.py" + PATTERN "__pycache__" EXCLUDE + PATTERN "__init__.py" EXCLUDE +) + +if (NOT LLVM_ENABLE_IDE) + add_llvm_install_targets( + install-MLIRBindingsPythonDialects + DEPENDS MLIRBindingsPythonSources + COMPONENT MLIRBindingsPythonDialects) +endif() diff --git a/mlir/lib/Bindings/Python/GPUOps.td b/mlir/python/mlir/dialects/GPUOps.td rename from mlir/lib/Bindings/Python/GPUOps.td rename to mlir/python/mlir/dialects/GPUOps.td diff --git a/mlir/lib/Bindings/Python/LinalgOps.td b/mlir/python/mlir/dialects/LinalgOps.td rename from mlir/lib/Bindings/Python/LinalgOps.td rename to mlir/python/mlir/dialects/LinalgOps.td diff --git a/mlir/lib/Bindings/Python/MemRefOps.td b/mlir/python/mlir/dialects/MemRefOps.td rename from mlir/lib/Bindings/Python/MemRefOps.td rename to mlir/python/mlir/dialects/MemRefOps.td diff --git a/mlir/lib/Bindings/Python/ShapeOps.td b/mlir/python/mlir/dialects/ShapeOps.td rename from mlir/lib/Bindings/Python/ShapeOps.td rename to mlir/python/mlir/dialects/ShapeOps.td diff --git a/mlir/lib/Bindings/Python/StandardOps.td b/mlir/python/mlir/dialects/StandardOps.td rename from mlir/lib/Bindings/Python/StandardOps.td rename to mlir/python/mlir/dialects/StandardOps.td diff --git a/mlir/lib/Bindings/Python/TensorOps.td b/mlir/python/mlir/dialects/TensorOps.td rename from mlir/lib/Bindings/Python/TensorOps.td rename to mlir/python/mlir/dialects/TensorOps.td diff --git a/mlir/lib/Bindings/Python/mlir/dialects/_builtin_ops_ext.py b/mlir/python/mlir/dialects/_builtin_ops_ext.py rename from mlir/lib/Bindings/Python/mlir/dialects/_builtin_ops_ext.py rename to mlir/python/mlir/dialects/_builtin_ops_ext.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/_linalg_ops_ext.py b/mlir/python/mlir/dialects/_linalg_ops_ext.py rename from mlir/lib/Bindings/Python/mlir/dialects/_linalg_ops_ext.py rename to mlir/python/mlir/dialects/_linalg_ops_ext.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/_ods_common.py b/mlir/python/mlir/dialects/_ods_common.py rename from mlir/lib/Bindings/Python/mlir/dialects/_ods_common.py rename to mlir/python/mlir/dialects/_ods_common.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/async_dialect/__init__.py b/mlir/python/mlir/dialects/async_dialect/__init__.py rename from mlir/lib/Bindings/Python/mlir/dialects/async_dialect/__init__.py rename to mlir/python/mlir/dialects/async_dialect/__init__.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/async_dialect/passes/__init__.py b/mlir/python/mlir/dialects/async_dialect/passes/__init__.py rename from mlir/lib/Bindings/Python/mlir/dialects/async_dialect/passes/__init__.py rename to mlir/python/mlir/dialects/async_dialect/passes/__init__.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/builtin.py b/mlir/python/mlir/dialects/builtin.py rename from mlir/lib/Bindings/Python/mlir/dialects/builtin.py rename to mlir/python/mlir/dialects/builtin.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/gpu/__init__.py b/mlir/python/mlir/dialects/gpu/__init__.py rename from mlir/lib/Bindings/Python/mlir/dialects/gpu/__init__.py rename to mlir/python/mlir/dialects/gpu/__init__.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/gpu/passes/__init__.py b/mlir/python/mlir/dialects/gpu/passes/__init__.py rename from mlir/lib/Bindings/Python/mlir/dialects/gpu/passes/__init__.py rename to mlir/python/mlir/dialects/gpu/passes/__init__.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/linalg/__init__.py b/mlir/python/mlir/dialects/linalg/__init__.py rename from mlir/lib/Bindings/Python/mlir/dialects/linalg/__init__.py rename to mlir/python/mlir/dialects/linalg/__init__.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/__init__.py b/mlir/python/mlir/dialects/linalg/opdsl/__init__.py rename from mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/__init__.py rename to mlir/python/mlir/dialects/linalg/opdsl/__init__.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/dump_oplib.py b/mlir/python/mlir/dialects/linalg/opdsl/dump_oplib.py rename from mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/dump_oplib.py rename to mlir/python/mlir/dialects/linalg/opdsl/dump_oplib.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/__init__.py b/mlir/python/mlir/dialects/linalg/opdsl/lang/__init__.py rename from mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/__init__.py rename to mlir/python/mlir/dialects/linalg/opdsl/lang/__init__.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/affine.py b/mlir/python/mlir/dialects/linalg/opdsl/lang/affine.py rename from mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/affine.py rename to mlir/python/mlir/dialects/linalg/opdsl/lang/affine.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/comprehension.py b/mlir/python/mlir/dialects/linalg/opdsl/lang/comprehension.py rename from mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/comprehension.py rename to mlir/python/mlir/dialects/linalg/opdsl/lang/comprehension.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/config.py b/mlir/python/mlir/dialects/linalg/opdsl/lang/config.py rename from mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/config.py rename to mlir/python/mlir/dialects/linalg/opdsl/lang/config.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/dsl.py b/mlir/python/mlir/dialects/linalg/opdsl/lang/dsl.py rename from mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/dsl.py rename to mlir/python/mlir/dialects/linalg/opdsl/lang/dsl.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/emitter.py b/mlir/python/mlir/dialects/linalg/opdsl/lang/emitter.py rename from mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/emitter.py rename to mlir/python/mlir/dialects/linalg/opdsl/lang/emitter.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/scalar_expr.py b/mlir/python/mlir/dialects/linalg/opdsl/lang/scalar_expr.py rename from mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/scalar_expr.py rename to mlir/python/mlir/dialects/linalg/opdsl/lang/scalar_expr.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/types.py b/mlir/python/mlir/dialects/linalg/opdsl/lang/types.py rename from mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/types.py rename to mlir/python/mlir/dialects/linalg/opdsl/lang/types.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/yaml_helper.py b/mlir/python/mlir/dialects/linalg/opdsl/lang/yaml_helper.py rename from mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/lang/yaml_helper.py rename to mlir/python/mlir/dialects/linalg/opdsl/lang/yaml_helper.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/ops/__init__.py b/mlir/python/mlir/dialects/linalg/opdsl/ops/__init__.py rename from mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/ops/__init__.py rename to mlir/python/mlir/dialects/linalg/opdsl/ops/__init__.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/ops/core_named_ops.py b/mlir/python/mlir/dialects/linalg/opdsl/ops/core_named_ops.py rename from mlir/lib/Bindings/Python/mlir/dialects/linalg/opdsl/ops/core_named_ops.py rename to mlir/python/mlir/dialects/linalg/opdsl/ops/core_named_ops.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/linalg/passes/__init__.py b/mlir/python/mlir/dialects/linalg/passes/__init__.py rename from mlir/lib/Bindings/Python/mlir/dialects/linalg/passes/__init__.py rename to mlir/python/mlir/dialects/linalg/passes/__init__.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/memref.py b/mlir/python/mlir/dialects/memref.py rename from mlir/lib/Bindings/Python/mlir/dialects/memref.py rename to mlir/python/mlir/dialects/memref.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/python_test.py b/mlir/python/mlir/dialects/python_test.py rename from mlir/lib/Bindings/Python/mlir/dialects/python_test.py rename to mlir/python/mlir/dialects/python_test.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/shape.py b/mlir/python/mlir/dialects/shape.py rename from mlir/lib/Bindings/Python/mlir/dialects/shape.py rename to mlir/python/mlir/dialects/shape.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/std.py b/mlir/python/mlir/dialects/std.py rename from mlir/lib/Bindings/Python/mlir/dialects/std.py rename to mlir/python/mlir/dialects/std.py diff --git a/mlir/lib/Bindings/Python/mlir/dialects/tensor.py b/mlir/python/mlir/dialects/tensor.py rename from mlir/lib/Bindings/Python/mlir/dialects/tensor.py rename to mlir/python/mlir/dialects/tensor.py diff --git a/mlir/lib/Bindings/Python/mlir/execution_engine.py b/mlir/python/mlir/execution_engine.py rename from mlir/lib/Bindings/Python/mlir/execution_engine.py rename to mlir/python/mlir/execution_engine.py diff --git a/mlir/lib/Bindings/Python/mlir/ir.py b/mlir/python/mlir/ir.py rename from mlir/lib/Bindings/Python/mlir/ir.py rename to mlir/python/mlir/ir.py diff --git a/mlir/lib/Bindings/Python/mlir/passmanager.py b/mlir/python/mlir/passmanager.py rename from mlir/lib/Bindings/Python/mlir/passmanager.py rename to mlir/python/mlir/passmanager.py diff --git a/mlir/lib/Bindings/Python/mlir/runtime/__init__.py b/mlir/python/mlir/runtime/__init__.py rename from mlir/lib/Bindings/Python/mlir/runtime/__init__.py rename to mlir/python/mlir/runtime/__init__.py diff --git a/mlir/lib/Bindings/Python/mlir/runtime/np_to_memref.py b/mlir/python/mlir/runtime/np_to_memref.py rename from mlir/lib/Bindings/Python/mlir/runtime/np_to_memref.py rename to mlir/python/mlir/runtime/np_to_memref.py diff --git a/mlir/lib/Bindings/Python/mlir/transforms/__init__.py b/mlir/python/mlir/transforms/__init__.py rename from mlir/lib/Bindings/Python/mlir/transforms/__init__.py rename to mlir/python/mlir/transforms/__init__.py diff --git a/mlir/lib/Bindings/Python/requirements.txt b/mlir/python/requirements.txt rename from mlir/lib/Bindings/Python/requirements.txt rename to mlir/python/requirements.txt diff --git a/mlir/test/Bindings/CMakeLists.txt b/mlir/test/Bindings/CMakeLists.txt deleted file mode 100644 --- a/mlir/test/Bindings/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -if(MLIR_BINDINGS_PYTHON_ENABLED) - add_subdirectory(Python) -endif() diff --git a/mlir/test/Bindings/Python/.style.yapf b/mlir/test/Bindings/Python/.style.yapf deleted file mode 100644 --- a/mlir/test/Bindings/Python/.style.yapf +++ /dev/null @@ -1,4 +0,0 @@ -[style] - based_on_style = google - column_limit = 80 - indent_width = 2 diff --git a/mlir/test/CMakeLists.txt b/mlir/test/CMakeLists.txt --- a/mlir/test/CMakeLists.txt +++ b/mlir/test/CMakeLists.txt @@ -1,9 +1,12 @@ -add_subdirectory(Bindings) add_subdirectory(CAPI) add_subdirectory(EDSC) add_subdirectory(SDBM) add_subdirectory(lib) +if(MLIR_BINDINGS_PYTHON_ENABLED) + add_subdirectory(python) +endif() + llvm_canonicalize_cmake_booleans( MLIR_BINDINGS_PYTHON_ENABLED LLVM_BUILD_EXAMPLES @@ -111,6 +114,7 @@ if(MLIR_BINDINGS_PYTHON_ENABLED) list(APPEND MLIR_TEST_DEPENDS MLIRBindingsPythonExtension + MLIRBindingsPythonSources MLIRBindingsPythonTestOps MLIRTransformsBindingsPythonExtension MLIRConversionsBindingsPythonExtension diff --git a/mlir/test/Bindings/Python/CMakeLists.txt b/mlir/test/python/CMakeLists.txt rename from mlir/test/Bindings/Python/CMakeLists.txt rename to mlir/test/python/CMakeLists.txt --- a/mlir/test/Bindings/Python/CMakeLists.txt +++ b/mlir/test/python/CMakeLists.txt @@ -1,4 +1,5 @@ -include(AddMLIRPythonExtension) +include(AddMLIRPython) + add_mlir_dialect_python_bindings(MLIRBindingsPythonTestOps TD_FILE python_test_ops.td DIALECT_NAME python_test) diff --git a/mlir/test/Bindings/Python/dialects/async_dialect.py b/mlir/test/python/dialects/async_dialect.py rename from mlir/test/Bindings/Python/dialects/async_dialect.py rename to mlir/test/python/dialects/async_dialect.py diff --git a/mlir/test/Bindings/Python/dialects/builtin.py b/mlir/test/python/dialects/builtin.py rename from mlir/test/Bindings/Python/dialects/builtin.py rename to mlir/test/python/dialects/builtin.py diff --git a/mlir/test/Bindings/Python/dialects/gpu.py b/mlir/test/python/dialects/gpu.py rename from mlir/test/Bindings/Python/dialects/gpu.py rename to mlir/test/python/dialects/gpu.py diff --git a/mlir/test/Bindings/Python/dialects/linalg/opdsl/assignments.py b/mlir/test/python/dialects/linalg/opdsl/assignments.py rename from mlir/test/Bindings/Python/dialects/linalg/opdsl/assignments.py rename to mlir/test/python/dialects/linalg/opdsl/assignments.py diff --git a/mlir/test/Bindings/Python/dialects/linalg/opdsl/doctests.py b/mlir/test/python/dialects/linalg/opdsl/doctests.py rename from mlir/test/Bindings/Python/dialects/linalg/opdsl/doctests.py rename to mlir/test/python/dialects/linalg/opdsl/doctests.py diff --git a/mlir/test/Bindings/Python/dialects/linalg/opdsl/emit_structured_generic.py b/mlir/test/python/dialects/linalg/opdsl/emit_structured_generic.py rename from mlir/test/Bindings/Python/dialects/linalg/opdsl/emit_structured_generic.py rename to mlir/test/python/dialects/linalg/opdsl/emit_structured_generic.py diff --git a/mlir/test/Bindings/Python/dialects/linalg/opdsl/interfaces.py b/mlir/test/python/dialects/linalg/opdsl/interfaces.py rename from mlir/test/Bindings/Python/dialects/linalg/opdsl/interfaces.py rename to mlir/test/python/dialects/linalg/opdsl/interfaces.py diff --git a/mlir/test/Bindings/Python/dialects/linalg/opdsl/lit.local.cfg b/mlir/test/python/dialects/linalg/opdsl/lit.local.cfg rename from mlir/test/Bindings/Python/dialects/linalg/opdsl/lit.local.cfg rename to mlir/test/python/dialects/linalg/opdsl/lit.local.cfg diff --git a/mlir/test/Bindings/Python/dialects/linalg/opdsl/shape_maps_iteration.py b/mlir/test/python/dialects/linalg/opdsl/shape_maps_iteration.py rename from mlir/test/Bindings/Python/dialects/linalg/opdsl/shape_maps_iteration.py rename to mlir/test/python/dialects/linalg/opdsl/shape_maps_iteration.py diff --git a/mlir/test/Bindings/Python/dialects/linalg/opdsl/test_core_named_ops.py b/mlir/test/python/dialects/linalg/opdsl/test_core_named_ops.py rename from mlir/test/Bindings/Python/dialects/linalg/opdsl/test_core_named_ops.py rename to mlir/test/python/dialects/linalg/opdsl/test_core_named_ops.py diff --git a/mlir/test/Bindings/Python/dialects/linalg/ops.py b/mlir/test/python/dialects/linalg/ops.py rename from mlir/test/Bindings/Python/dialects/linalg/ops.py rename to mlir/test/python/dialects/linalg/ops.py diff --git a/mlir/test/Bindings/Python/dialects/linalg/opsrun.py b/mlir/test/python/dialects/linalg/opsrun.py rename from mlir/test/Bindings/Python/dialects/linalg/opsrun.py rename to mlir/test/python/dialects/linalg/opsrun.py diff --git a/mlir/test/Bindings/Python/dialects/memref.py b/mlir/test/python/dialects/memref.py rename from mlir/test/Bindings/Python/dialects/memref.py rename to mlir/test/python/dialects/memref.py diff --git a/mlir/test/Bindings/Python/ods_helpers.py b/mlir/test/python/dialects/ods_helpers.py rename from mlir/test/Bindings/Python/ods_helpers.py rename to mlir/test/python/dialects/ods_helpers.py diff --git a/mlir/test/Bindings/Python/dialects/python_test.py b/mlir/test/python/dialects/python_test.py rename from mlir/test/Bindings/Python/dialects/python_test.py rename to mlir/test/python/dialects/python_test.py diff --git a/mlir/test/Bindings/Python/execution_engine.py b/mlir/test/python/execution_engine.py rename from mlir/test/Bindings/Python/execution_engine.py rename to mlir/test/python/execution_engine.py diff --git a/mlir/test/Bindings/Python/ir_affine_expr.py b/mlir/test/python/ir/affine_expr.py rename from mlir/test/Bindings/Python/ir_affine_expr.py rename to mlir/test/python/ir/affine_expr.py diff --git a/mlir/test/Bindings/Python/ir_affine_map.py b/mlir/test/python/ir/affine_map.py rename from mlir/test/Bindings/Python/ir_affine_map.py rename to mlir/test/python/ir/affine_map.py diff --git a/mlir/test/Bindings/Python/ir_array_attributes.py b/mlir/test/python/ir/array_attributes.py rename from mlir/test/Bindings/Python/ir_array_attributes.py rename to mlir/test/python/ir/array_attributes.py diff --git a/mlir/test/Bindings/Python/ir_attributes.py b/mlir/test/python/ir/attributes.py rename from mlir/test/Bindings/Python/ir_attributes.py rename to mlir/test/python/ir/attributes.py diff --git a/mlir/test/Bindings/Python/context_lifecycle.py b/mlir/test/python/ir/context_lifecycle.py rename from mlir/test/Bindings/Python/context_lifecycle.py rename to mlir/test/python/ir/context_lifecycle.py diff --git a/mlir/test/Bindings/Python/context_managers.py b/mlir/test/python/ir/context_managers.py rename from mlir/test/Bindings/Python/context_managers.py rename to mlir/test/python/ir/context_managers.py diff --git a/mlir/test/Bindings/Python/debug.py b/mlir/test/python/ir/debug.py rename from mlir/test/Bindings/Python/debug.py rename to mlir/test/python/ir/debug.py diff --git a/mlir/test/Bindings/Python/dialects.py b/mlir/test/python/ir/dialects.py rename from mlir/test/Bindings/Python/dialects.py rename to mlir/test/python/ir/dialects.py diff --git a/mlir/test/Bindings/Python/insertion_point.py b/mlir/test/python/ir/insertion_point.py rename from mlir/test/Bindings/Python/insertion_point.py rename to mlir/test/python/ir/insertion_point.py diff --git a/mlir/test/Bindings/Python/ir_integer_set.py b/mlir/test/python/ir/integer_set.py rename from mlir/test/Bindings/Python/ir_integer_set.py rename to mlir/test/python/ir/integer_set.py diff --git a/mlir/test/Bindings/Python/ir_location.py b/mlir/test/python/ir/location.py rename from mlir/test/Bindings/Python/ir_location.py rename to mlir/test/python/ir/location.py diff --git a/mlir/test/Bindings/Python/ir_module.py b/mlir/test/python/ir/module.py rename from mlir/test/Bindings/Python/ir_module.py rename to mlir/test/python/ir/module.py diff --git a/mlir/test/Bindings/Python/ir_operation.py b/mlir/test/python/ir/operation.py rename from mlir/test/Bindings/Python/ir_operation.py rename to mlir/test/python/ir/operation.py diff --git a/mlir/test/Bindings/Python/ir_types.py b/mlir/test/python/ir/types.py rename from mlir/test/Bindings/Python/ir_types.py rename to mlir/test/python/ir/types.py diff --git a/mlir/test/Bindings/Python/ir_value.py b/mlir/test/python/ir/value.py rename from mlir/test/Bindings/Python/ir_value.py rename to mlir/test/python/ir/value.py diff --git a/mlir/test/Bindings/Python/lit.local.cfg b/mlir/test/python/lit.local.cfg rename from mlir/test/Bindings/Python/lit.local.cfg rename to mlir/test/python/lit.local.cfg diff --git a/mlir/test/Bindings/Python/pass_manager.py b/mlir/test/python/pass_manager.py rename from mlir/test/Bindings/Python/pass_manager.py rename to mlir/test/python/pass_manager.py diff --git a/mlir/test/Bindings/Python/python_test_ops.td b/mlir/test/python/python_test_ops.td rename from mlir/test/Bindings/Python/python_test_ops.td rename to mlir/test/python/python_test_ops.td