1
1
include (AddMLIRPython)
2
2
3
- # Specifies that all MLIR packages are co-located under the `mlir_standalone`
4
- # top level package (the API has been embedded in a relocatable way).
5
- add_compile_definitions ("MLIR_PYTHON_PACKAGE_PREFIX=${MLIR_PYTHON_PACKAGE_PREFIX} ." )
6
-
7
3
################################################################################
8
4
# Structural groupings.
9
5
################################################################################
@@ -27,6 +23,11 @@ declare_mlir_python_sources(MLIRPythonSources.Core.Python
27
23
passmanager.py
28
24
rewrite.py
29
25
dialects/_ods_common.py
26
+
27
+ # The main _mlir module has submodules: include stubs from each.
28
+ _mlir_libs/_mlir/__init__.pyi
29
+ _mlir_libs/_mlir/ir.pyi
30
+ _mlir_libs/_mlir/passmanager.pyi
30
31
)
31
32
32
33
declare_mlir_python_sources(MLIRPythonSources.Core.Python.Extras
@@ -42,6 +43,7 @@ declare_mlir_python_sources(MLIRPythonSources.ExecutionEngine
42
43
ADD_TO_PARENT MLIRPythonSources
43
44
SOURCES
44
45
execution_engine.py
46
+ _mlir_libs/_mlirExecutionEngine.pyi
45
47
SOURCES_GLOB
46
48
runtime/*.py
47
49
)
@@ -193,6 +195,7 @@ declare_mlir_dialect_python_bindings(
193
195
TD_FILE dialects/TransformOps.td
194
196
SOURCES
195
197
dialects/transform/__init__.py
198
+ _mlir_libs/_mlir/dialects/transform/__init__.pyi
196
199
DIALECT_NAME transform
197
200
GEN_ENUM_BINDINGS_TD_FILE
198
201
"../../include/mlir/Dialect/Transform/IR/TransformAttrs.td"
@@ -364,7 +367,8 @@ declare_mlir_python_sources(
364
367
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR} /mlir"
365
368
GEN_ENUM_BINDINGS
366
369
SOURCES
367
- dialects/quant.py)
370
+ dialects/quant.py
371
+ _mlir_libs/_mlir/dialects/quant.pyi)
368
372
369
373
declare_mlir_dialect_python_bindings(
370
374
ADD_TO_PARENT MLIRPythonSources.Dialects
@@ -380,6 +384,7 @@ declare_mlir_dialect_python_bindings(
380
384
TD_FILE dialects/PDLOps.td
381
385
SOURCES
382
386
dialects/pdl.py
387
+ _mlir_libs/_mlir/dialects/pdl.pyi
383
388
DIALECT_NAME pdl)
384
389
385
390
declare_mlir_dialect_python_bindings(
@@ -505,11 +510,6 @@ declare_mlir_python_extension(MLIRPythonExtension.Core
505
510
506
511
# Dialects
507
512
MLIRCAPIFunc
508
- GENERATE_TYPE_STUBS
509
- "_mlir/__init__.pyi"
510
- "_mlir/ir.pyi"
511
- "_mlir/passmanager.pyi"
512
- "_mlir/rewrite.pyi"
513
513
)
514
514
515
515
# This extension exposes an API to register all dialects, extensions, and passes
@@ -531,8 +531,6 @@ declare_mlir_python_extension(MLIRPythonExtension.RegisterEverything
531
531
MLIRCAPIConversion
532
532
MLIRCAPITransforms
533
533
MLIRCAPIRegisterEverything
534
- GENERATE_TYPE_STUBS
535
- "_mlirRegisterEverything.pyi"
536
534
)
537
535
538
536
declare_mlir_python_extension(MLIRPythonExtension.Dialects.Linalg.Pybind
@@ -547,8 +545,6 @@ declare_mlir_python_extension(MLIRPythonExtension.Dialects.Linalg.Pybind
547
545
EMBED_CAPI_LINK_LIBS
548
546
MLIRCAPIIR
549
547
MLIRCAPILinalg
550
- GENERATE_TYPE_STUBS
551
- "_mlirDialectsLinalg.pyi"
552
548
)
553
549
554
550
declare_mlir_python_extension(MLIRPythonExtension.Dialects.GPU.Pybind
@@ -563,8 +559,6 @@ declare_mlir_python_extension(MLIRPythonExtension.Dialects.GPU.Pybind
563
559
EMBED_CAPI_LINK_LIBS
564
560
MLIRCAPIIR
565
561
MLIRCAPIGPU
566
- GENERATE_TYPE_STUBS
567
- "_mlirDialectsGPU.pyi"
568
562
)
569
563
570
564
declare_mlir_python_extension(MLIRPythonExtension.Dialects.LLVM.Pybind
@@ -579,8 +573,6 @@ declare_mlir_python_extension(MLIRPythonExtension.Dialects.LLVM.Pybind
579
573
EMBED_CAPI_LINK_LIBS
580
574
MLIRCAPIIR
581
575
MLIRCAPILLVM
582
- GENERATE_TYPE_STUBS
583
- "_mlirDialectsLLVM.pyi"
584
576
)
585
577
586
578
declare_mlir_python_extension(MLIRPythonExtension.Dialects.Quant.Pybind
@@ -595,8 +587,6 @@ declare_mlir_python_extension(MLIRPythonExtension.Dialects.Quant.Pybind
595
587
EMBED_CAPI_LINK_LIBS
596
588
MLIRCAPIIR
597
589
MLIRCAPIQuant
598
- GENERATE_TYPE_STUBS
599
- "_mlirDialectsQuant.pyi"
600
590
)
601
591
602
592
declare_mlir_python_extension(MLIRPythonExtension.Dialects.NVGPU.Pybind
@@ -611,8 +601,6 @@ declare_mlir_python_extension(MLIRPythonExtension.Dialects.NVGPU.Pybind
611
601
EMBED_CAPI_LINK_LIBS
612
602
MLIRCAPIIR
613
603
MLIRCAPINVGPU
614
- GENERATE_TYPE_STUBS
615
- "_mlirDialectsNVGPU.pyi"
616
604
)
617
605
618
606
declare_mlir_python_extension(MLIRPythonExtension.Dialects.PDL.Pybind
@@ -627,8 +615,6 @@ declare_mlir_python_extension(MLIRPythonExtension.Dialects.PDL.Pybind
627
615
EMBED_CAPI_LINK_LIBS
628
616
MLIRCAPIIR
629
617
MLIRCAPIPDL
630
- GENERATE_TYPE_STUBS
631
- "_mlirDialectsPDL.pyi"
632
618
)
633
619
634
620
declare_mlir_python_extension(MLIRPythonExtension.Dialects.SparseTensor.Pybind
@@ -643,8 +629,6 @@ declare_mlir_python_extension(MLIRPythonExtension.Dialects.SparseTensor.Pybind
643
629
EMBED_CAPI_LINK_LIBS
644
630
MLIRCAPIIR
645
631
MLIRCAPISparseTensor
646
- GENERATE_TYPE_STUBS
647
- "_mlirDialectsSparseTensor.pyi"
648
632
)
649
633
650
634
declare_mlir_python_extension(MLIRPythonExtension.Dialects.Transform.Pybind
@@ -659,8 +643,6 @@ declare_mlir_python_extension(MLIRPythonExtension.Dialects.Transform.Pybind
659
643
EMBED_CAPI_LINK_LIBS
660
644
MLIRCAPIIR
661
645
MLIRCAPITransformDialect
662
- GENERATE_TYPE_STUBS
663
- "_mlirDialectsTransform.pyi"
664
646
)
665
647
666
648
declare_mlir_python_extension(MLIRPythonExtension.AsyncDialectPasses
@@ -674,8 +656,6 @@ declare_mlir_python_extension(MLIRPythonExtension.AsyncDialectPasses
674
656
LLVMSupport
675
657
EMBED_CAPI_LINK_LIBS
676
658
MLIRCAPIAsync
677
- GENERATE_TYPE_STUBS
678
- "_mlirAsyncPasses.pyi"
679
659
)
680
660
681
661
if (MLIR_ENABLE_EXECUTION_ENGINE)
@@ -690,8 +670,6 @@ if(MLIR_ENABLE_EXECUTION_ENGINE)
690
670
LLVMSupport
691
671
EMBED_CAPI_LINK_LIBS
692
672
MLIRCAPIExecutionEngine
693
- GENERATE_TYPE_STUBS
694
- "_mlirExecutionEngine.pyi"
695
673
)
696
674
endif ()
697
675
@@ -706,8 +684,6 @@ declare_mlir_python_extension(MLIRPythonExtension.GPUDialectPasses
706
684
LLVMSupport
707
685
EMBED_CAPI_LINK_LIBS
708
686
MLIRCAPIGPU
709
- GENERATE_TYPE_STUBS
710
- "_mlirGPUPasses.pyi"
711
687
)
712
688
713
689
declare_mlir_python_extension(MLIRPythonExtension.LinalgPasses
@@ -721,8 +697,6 @@ declare_mlir_python_extension(MLIRPythonExtension.LinalgPasses
721
697
LLVMSupport
722
698
EMBED_CAPI_LINK_LIBS
723
699
MLIRCAPILinalg
724
- GENERATE_TYPE_STUBS
725
- "_mlirLinalgPasses.pyi"
726
700
)
727
701
728
702
declare_mlir_python_extension(MLIRPythonExtension.Dialects.SMT.Pybind
@@ -740,8 +714,6 @@ declare_mlir_python_extension(MLIRPythonExtension.Dialects.SMT.Pybind
740
714
MLIRCAPIIR
741
715
MLIRCAPISMT
742
716
MLIRCAPIExportSMTLIB
743
- GENERATE_TYPE_STUBS
744
- "_mlirDialectsSMT.pyi"
745
717
)
746
718
747
719
declare_mlir_python_extension(MLIRPythonExtension.SparseTensorDialectPasses
@@ -755,8 +727,6 @@ declare_mlir_python_extension(MLIRPythonExtension.SparseTensorDialectPasses
755
727
LLVMSupport
756
728
EMBED_CAPI_LINK_LIBS
757
729
MLIRCAPISparseTensor
758
- GENERATE_TYPE_STUBS
759
- "_mlirSparseTensorPasses.pyi"
760
730
)
761
731
762
732
declare_mlir_python_extension(MLIRPythonExtension.TransformInterpreter
@@ -770,8 +740,6 @@ declare_mlir_python_extension(MLIRPythonExtension.TransformInterpreter
770
740
LLVMSupport
771
741
EMBED_CAPI_LINK_LIBS
772
742
MLIRCAPITransformDialectTransforms
773
- GENERATE_TYPE_STUBS
774
- "_mlirTransformInterpreter.pyi"
775
743
)
776
744
777
745
# TODO: Figure out how to put this in the test tree.
@@ -830,8 +798,6 @@ if(MLIR_INCLUDE_TESTS)
830
798
LLVMSupport
831
799
EMBED_CAPI_LINK_LIBS
832
800
MLIRCAPIPythonTestDialect
833
- GENERATE_TYPE_STUBS
834
- "_mlirPythonTestNanobind.pyi"
835
801
)
836
802
endif ()
837
803
@@ -851,7 +817,7 @@ endif()
851
817
add_mlir_python_common_capi_library(MLIRPythonCAPI
852
818
INSTALL_COMPONENT MLIRPythonModules
853
819
INSTALL_DESTINATION "${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX} /_mlir_libs"
854
- OUTPUT_DIRECTORY "${MLIR_BINARY_DIR} /${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX} /_mlir_libs"
820
+ OUTPUT_DIRECTORY "${MLIR_BINARY_DIR} /python_packages/mlir_core/mlir /_mlir_libs"
855
821
RELATIVE_INSTALL_ROOT "../../../.."
856
822
DECLARED_HEADERS
857
823
MLIRPythonCAPI.HeaderSources
@@ -880,7 +846,7 @@ endif()
880
846
################################################################################
881
847
882
848
add_mlir_python_modules(MLIRPythonModules
883
- ROOT_PREFIX "${MLIR_BINARY_DIR} /${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX} "
849
+ ROOT_PREFIX "${MLIR_BINARY_DIR} /python_packages/mlir_core/mlir "
884
850
INSTALL_PREFIX "${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX} "
885
851
DECLARED_SOURCES
886
852
MLIRPythonSources
0 commit comments