1# This file is licensed under the Apache License v2.0 with LLVM Exceptions. 2# See https://llvm.org/LICENSE.txt for license information. 3# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 5# Description: 6# Python bindings for MLIR. 7# 8# We define separate filegroups for files in different directories so 9# that downstream users can mirror the tree in their own py_library() rules. 10 11load("//mlir:tblgen.bzl", "gentbl_filegroup", "td_library") 12 13package( 14 default_visibility = [ 15 "//visibility:public", 16 ], 17 licenses = ["notice"], 18) 19 20##---------------------------------------------------------------------------## 21# Core IR modules. 22##---------------------------------------------------------------------------## 23 24filegroup( 25 name = "ConversionsPyFiles", 26 srcs = glob([ 27 "mlir/conversions/*.py", 28 ]), 29) 30 31filegroup( 32 name = "DialectCorePyFiles", 33 srcs = [ 34 "mlir/dialects/_ods_common.py", 35 ], 36) 37 38filegroup( 39 name = "ExecutionEnginePyFiles", 40 srcs = [ 41 "mlir/execution_engine.py", 42 ], 43) 44 45filegroup( 46 name = "IRPyFiles", 47 srcs = [ 48 "mlir/ir.py", 49 ], 50) 51 52filegroup( 53 name = "PassManagerPyFiles", 54 srcs = [ 55 "mlir/passmanager.py", 56 ], 57) 58 59filegroup( 60 name = "RuntimePyFiles", 61 srcs = glob([ 62 "mlir/runtime/*.py", 63 ]), 64) 65 66filegroup( 67 name = "TransformsPyFiles", 68 srcs = glob([ 69 "mlir/transforms/*.py", 70 ]), 71) 72 73filegroup( 74 name = "AllPassesRegistrationPyFiles", 75 srcs = glob([ 76 "mlir/all_passes_registration/*.py", 77 ]), 78) 79 80##---------------------------------------------------------------------------## 81# Builtin dialect. 82##---------------------------------------------------------------------------## 83 84td_library( 85 name = "BuiltinOpsPyTdFiles", 86 srcs = [ 87 "mlir/dialects/BuiltinOps.td", 88 "//mlir:include/mlir/Bindings/Python/Attributes.td", 89 ], 90 deps = [ 91 "//mlir:BuiltinDialectTdFiles", 92 "//mlir:FunctionInterfacesTdFiles", 93 "//mlir:OpBaseTdFiles", 94 ], 95) 96 97gentbl_filegroup( 98 name = "BuiltinOpsPyGen", 99 tbl_outs = [ 100 ( 101 [ 102 "-gen-python-op-bindings", 103 "-bind-dialect=builtin", 104 ], 105 "mlir/dialects/_builtin_ops_gen.py", 106 ), 107 ], 108 tblgen = "//mlir:mlir-tblgen", 109 td_file = "mlir/dialects/BuiltinOps.td", 110 deps = [ 111 ":BuiltinOpsPyTdFiles", 112 ], 113) 114 115filegroup( 116 name = "BuiltinOpsPyFiles", 117 srcs = [ 118 "mlir/dialects/_builtin_ops_ext.py", 119 "mlir/dialects/builtin.py", 120 ":BuiltinOpsPyGen", 121 ], 122) 123 124##---------------------------------------------------------------------------## 125# Linalg dialect. 126##---------------------------------------------------------------------------## 127 128td_library( 129 name = "LinalgOpsPyTdFiles", 130 srcs = [ 131 "mlir/dialects/LinalgOps.td", 132 "//mlir:include/mlir/Bindings/Python/Attributes.td", 133 ], 134 deps = [ 135 "//mlir:LinalgOpsTdFiles", 136 "//mlir:LinalgStructuredOpsTdFiles", 137 "//mlir:OpBaseTdFiles", 138 ], 139) 140 141gentbl_filegroup( 142 name = "LinalgOpsPyGen", 143 tbl_outs = [ 144 ( 145 [ 146 "-gen-python-op-bindings", 147 "-bind-dialect=linalg", 148 ], 149 "mlir/dialects/_linalg_ops_gen.py", 150 ), 151 ], 152 tblgen = "//mlir:mlir-tblgen", 153 td_file = "mlir/dialects/LinalgOps.td", 154 deps = [ 155 ":LinalgOpsPyTdFiles", 156 ], 157) 158 159filegroup( 160 name = "LinalgOpsPyFiles", 161 srcs = [ 162 "mlir/dialects/_linalg_ops_ext.py", 163 ":LinalgOpsPyGen", 164 ], 165) 166 167filegroup( 168 name = "LinalgOpsPackagePyFiles", 169 srcs = glob(["mlir/dialects/linalg/*.py"]), 170) 171 172filegroup( 173 name = "LinalgOpsPackageOpDSLPyFiles", 174 srcs = glob(["mlir/dialects/linalg/opdsl/*.py"]), 175) 176 177filegroup( 178 name = "LinalgOpsPackageOpDSLLangPyFiles", 179 srcs = glob(["mlir/dialects/linalg/opdsl/lang/*.py"]), 180) 181 182filegroup( 183 name = "LinalgOpsPackageOpDSLOpsPyFiles", 184 srcs = glob(["mlir/dialects/linalg/opdsl/ops/*.py"]), 185) 186 187filegroup( 188 name = "LinalgOpsPackagePassesPyFiles", 189 srcs = glob(["mlir/dialects/linalg/passes/*.py"]), 190) 191 192##---------------------------------------------------------------------------## 193# Arithmetic dialect. 194##---------------------------------------------------------------------------## 195 196td_library( 197 name = "ArithmeticOpsPyTdFiles", 198 srcs = [ 199 "//mlir:include/mlir/Bindings/Python/Attributes.td", 200 ], 201 includes = ["../include"], 202 deps = [ 203 "//mlir:ArithmeticOpsTdFiles", 204 "//mlir:OpBaseTdFiles", 205 ], 206) 207 208gentbl_filegroup( 209 name = "ArithmeticOpsPyGen", 210 tbl_outs = [ 211 ( 212 [ 213 "-gen-python-op-bindings", 214 "-bind-dialect=arith", 215 ], 216 "mlir/dialects/_arith_ops_gen.py", 217 ), 218 ], 219 tblgen = "//mlir:mlir-tblgen", 220 td_file = "mlir/dialects/ArithmeticOps.td", 221 deps = [ 222 ":ArithmeticOpsPyTdFiles", 223 ], 224) 225 226filegroup( 227 name = "ArithmeticOpsPyFiles", 228 srcs = [ 229 "mlir/dialects/_arith_ops_ext.py", 230 "mlir/dialects/arith.py", 231 ":ArithmeticOpsPyGen", 232 ], 233) 234 235##---------------------------------------------------------------------------## 236# Math dialect. 237##---------------------------------------------------------------------------## 238 239td_library( 240 name = "MathOpsPyTdFiles", 241 srcs = [ 242 "//mlir:include/mlir/Bindings/Python/Attributes.td", 243 ], 244 includes = ["../include"], 245 deps = [ 246 "//mlir:MathOpsTdFiles", 247 "//mlir:OpBaseTdFiles", 248 ], 249) 250 251gentbl_filegroup( 252 name = "MathOpsPyGen", 253 tbl_outs = [ 254 ( 255 [ 256 "-gen-python-op-bindings", 257 "-bind-dialect=math", 258 ], 259 "mlir/dialects/_math_ops_gen.py", 260 ), 261 ], 262 tblgen = "//mlir:mlir-tblgen", 263 td_file = "mlir/dialects/MathOps.td", 264 deps = [ 265 ":MathOpsPyTdFiles", 266 ], 267) 268 269filegroup( 270 name = "MathOpsPyFiles", 271 srcs = [ 272 "mlir/dialects/math.py", 273 ":MathOpsPyGen", 274 ], 275) 276 277##---------------------------------------------------------------------------## 278# MemRef dialect. 279##---------------------------------------------------------------------------## 280 281td_library( 282 name = "MemRefOpsPyTdFiles", 283 srcs = [ 284 "//mlir:include/mlir/Bindings/Python/Attributes.td", 285 ], 286 includes = ["../include"], 287 deps = [ 288 "//mlir:MemRefOpsTdFiles", 289 "//mlir:OpBaseTdFiles", 290 ], 291) 292 293gentbl_filegroup( 294 name = "MemRefOpsPyGen", 295 tbl_outs = [ 296 ( 297 [ 298 "-gen-python-op-bindings", 299 "-bind-dialect=memref", 300 ], 301 "mlir/dialects/_memref_ops_gen.py", 302 ), 303 ], 304 tblgen = "//mlir:mlir-tblgen", 305 td_file = "mlir/dialects/MemRefOps.td", 306 deps = [ 307 ":MemRefOpsPyTdFiles", 308 ], 309) 310 311filegroup( 312 name = "MemRefOpsPyFiles", 313 srcs = [ 314 "mlir/dialects/_memref_ops_ext.py", 315 "mlir/dialects/memref.py", 316 ":MemRefOpsPyGen", 317 ], 318) 319 320##---------------------------------------------------------------------------## 321# Quant dialect. 322##---------------------------------------------------------------------------## 323 324filegroup( 325 name = "QuantPyFiles", 326 srcs = [ 327 "mlir/dialects/quant.py", 328 ], 329) 330 331##---------------------------------------------------------------------------## 332# PythonTest dialect. 333##---------------------------------------------------------------------------## 334 335td_library( 336 name = "PythonTestPyTdFiles", 337 srcs = [ 338 "//mlir:include/mlir/Bindings/Python/Attributes.td", 339 ], 340 deps = [ 341 "//mlir:InferTypeOpInterfaceTdFiles", 342 "//mlir:OpBaseTdFiles", 343 ], 344) 345 346gentbl_filegroup( 347 name = "PythonTestPyGen", 348 tbl_outs = [ 349 ( 350 [ 351 "-gen-python-op-bindings", 352 "-bind-dialect=python_test", 353 ], 354 "mlir/dialects/_python_test_ops_gen.py", 355 ), 356 ], 357 tblgen = "//mlir:mlir-tblgen", 358 td_file = "//mlir/test/python:python_test_ops.td", 359 deps = [ 360 ":PythonTestPyTdFiles", 361 ], 362) 363 364filegroup( 365 name = "PythonTestPyFiles", 366 srcs = [ 367 "mlir/dialects/python_test.py", 368 ":PythonTestPyGen", 369 ], 370) 371 372##---------------------------------------------------------------------------## 373# SCF dialect. 374##---------------------------------------------------------------------------## 375 376td_library( 377 name = "SCFPyTdFiles", 378 srcs = [ 379 "//mlir:include/mlir/Bindings/Python/Attributes.td", 380 ], 381 includes = ["../include"], 382 deps = [ 383 "//mlir:OpBaseTdFiles", 384 "//mlir:SCFTdFiles", 385 ], 386) 387 388gentbl_filegroup( 389 name = "SCFPyGen", 390 tbl_outs = [ 391 ( 392 [ 393 "-gen-python-op-bindings", 394 "-bind-dialect=scf", 395 ], 396 "mlir/dialects/_scf_ops_gen.py", 397 ), 398 ], 399 tblgen = "//mlir:mlir-tblgen", 400 td_file = "mlir/dialects/SCFOps.td", 401 deps = [ 402 ":SCFPyTdFiles", 403 ], 404) 405 406filegroup( 407 name = "SCFPyFiles", 408 srcs = [ 409 "mlir/dialects/_scf_ops_ext.py", 410 "mlir/dialects/scf.py", 411 ":SCFPyGen", 412 ], 413) 414 415##---------------------------------------------------------------------------## 416# Shape dialect. 417##---------------------------------------------------------------------------## 418 419td_library( 420 name = "ShapeOpsPyTdFiles", 421 srcs = [ 422 "//mlir:include/mlir/Bindings/Python/Attributes.td", 423 ], 424 includes = ["../include"], 425 deps = [ 426 "//mlir:OpBaseTdFiles", 427 "//mlir:ShapeOpsTdFiles", 428 ], 429) 430 431gentbl_filegroup( 432 name = "ShapeOpsPyGen", 433 tbl_outs = [ 434 ( 435 [ 436 "-gen-python-op-bindings", 437 "-bind-dialect=shape", 438 ], 439 "mlir/dialects/_shape_ops_gen.py", 440 ), 441 ], 442 tblgen = "//mlir:mlir-tblgen", 443 td_file = "mlir/dialects/ShapeOps.td", 444 deps = [ 445 ":ShapeOpsPyTdFiles", 446 ], 447) 448 449filegroup( 450 name = "ShapeOpsPyFiles", 451 srcs = [ 452 "mlir/dialects/shape.py", 453 ":ShapeOpsPyGen", 454 ], 455) 456 457##---------------------------------------------------------------------------## 458# Standard dialect. 459##---------------------------------------------------------------------------## 460 461td_library( 462 name = "StandardOpsPyTdFiles", 463 srcs = [ 464 "//mlir:include/mlir/Bindings/Python/Attributes.td", 465 ], 466 deps = [ 467 "//mlir:OpBaseTdFiles", 468 "//mlir:StdOpsTdFiles", 469 ], 470) 471 472gentbl_filegroup( 473 name = "StandardOpsPyGen", 474 tbl_outs = [ 475 ( 476 [ 477 "-gen-python-op-bindings", 478 "-bind-dialect=std", 479 ], 480 "mlir/dialects/_std_ops_gen.py", 481 ), 482 ], 483 tblgen = "//mlir:mlir-tblgen", 484 td_file = "mlir/dialects/StandardOps.td", 485 deps = [ 486 ":StandardOpsPyTdFiles", 487 ], 488) 489 490filegroup( 491 name = "StandardOpsPyFiles", 492 srcs = [ 493 "mlir/dialects/_std_ops_ext.py", 494 "mlir/dialects/std.py", 495 ":StandardOpsPyGen", 496 ], 497) 498 499##---------------------------------------------------------------------------## 500# SparseTensor dialect. 501##---------------------------------------------------------------------------## 502 503td_library( 504 name = "SparseTensorOpsPyTdFiles", 505 srcs = [ 506 "//mlir:include/mlir/Bindings/Python/Attributes.td", 507 ], 508 deps = [ 509 "//mlir:OpBaseTdFiles", 510 "//mlir:SparseTensorTdFiles", 511 ], 512) 513 514gentbl_filegroup( 515 name = "SparseTensorOpsPyGen", 516 tbl_outs = [ 517 ( 518 [ 519 "-gen-python-op-bindings", 520 "-bind-dialect=sparse_tensor", 521 ], 522 "mlir/dialects/_sparse_tensor_ops_gen.py", 523 ), 524 ], 525 tblgen = "//mlir:mlir-tblgen", 526 td_file = "mlir/dialects/SparseTensorOps.td", 527 deps = [ 528 ":SparseTensorOpsPyTdFiles", 529 ], 530) 531 532filegroup( 533 name = "SparseTensorOpsPyFiles", 534 srcs = [ 535 "mlir/dialects/sparse_tensor.py", 536 ":SparseTensorOpsPyGen", 537 ], 538) 539 540##---------------------------------------------------------------------------## 541# Tosa dialect. 542##---------------------------------------------------------------------------## 543 544td_library( 545 name = "TosaOpsPyTdFiles", 546 srcs = [ 547 "//mlir:include/mlir/Bindings/Python/Attributes.td", 548 ], 549 deps = [ 550 "//mlir:OpBaseTdFiles", 551 "//mlir:TosaDialectTdFiles", 552 ], 553) 554 555gentbl_filegroup( 556 name = "TosaOpsPyGen", 557 tbl_outs = [ 558 ( 559 [ 560 "-gen-python-op-bindings", 561 "-bind-dialect=tosa", 562 ], 563 "mlir/dialects/_tosa_ops_gen.py", 564 ), 565 ], 566 tblgen = "//mlir:mlir-tblgen", 567 td_file = "mlir/dialects/TosaOps.td", 568 deps = [ 569 ":TosaOpsPyTdFiles", 570 ], 571) 572 573filegroup( 574 name = "TosaOpsPyFiles", 575 srcs = [ 576 "mlir/dialects/tosa.py", 577 ":TosaOpsPyGen", 578 ], 579) 580 581##---------------------------------------------------------------------------## 582# Vector dialect. 583##---------------------------------------------------------------------------## 584 585td_library( 586 name = "VectorOpsPyTdFiles", 587 srcs = [ 588 "//mlir:include/mlir/Bindings/Python/Attributes.td", 589 ], 590 includes = ["../include"], 591 deps = [ 592 "//mlir:OpBaseTdFiles", 593 "//mlir:VectorOpsTdFiles", 594 ], 595) 596 597gentbl_filegroup( 598 name = "VectorOpsPyGen", 599 tbl_outs = [ 600 ( 601 [ 602 "-gen-python-op-bindings", 603 "-bind-dialect=vector", 604 ], 605 "mlir/dialects/_vector_ops_gen.py", 606 ), 607 ], 608 tblgen = "//mlir:mlir-tblgen", 609 td_file = "mlir/dialects/VectorOps.td", 610 deps = [ 611 ":VectorOpsPyTdFiles", 612 ], 613) 614 615filegroup( 616 name = "VectorOpsPyFiles", 617 srcs = [ 618 "mlir/dialects/vector.py", 619 ":VectorOpsPyGen", 620 ], 621) 622