[Mlir-commits] [llvm] [mlir] [MLIR][Python] enable type stub auto-generation (PR #155741)
Maksim Levental
llvmlistbot at llvm.org
Fri Aug 29 15:24:29 PDT 2025
https://github.com/makslevental updated https://github.com/llvm/llvm-project/pull/155741
>From 79943336564dae3cdf721216ff6c0935f9a1b1ba Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Wed, 27 Aug 2025 23:30:01 -0400
Subject: [PATCH 01/11] [MLIR][Python] enable type stub auto-generation
---
mlir/CMakeLists.txt | 4 +
mlir/cmake/modules/AddMLIRPython.cmake | 43 +
.../examples/standalone/python/CMakeLists.txt | 3 +-
mlir/python/CMakeLists.txt | 20 +-
mlir/python/mlir/_mlir_libs/.gitignore | 1 +
.../python/mlir/_mlir_libs/_mlir/__init__.pyi | 12 -
.../mlir/_mlir_libs/_mlir/dialects/pdl.pyi | 63 -
.../mlir/_mlir_libs/_mlir/dialects/quant.pyi | 142 -
.../_mlir/dialects/transform/__init__.pyi | 25 -
mlir/python/mlir/_mlir_libs/_mlir/ir.pyi | 2846 -----------------
.../mlir/_mlir_libs/_mlir/passmanager.pyi | 36 -
.../mlir/_mlir_libs/_mlirExecutionEngine.pyi | 24 -
mlir/python/requirements.txt | 2 +-
13 files changed, 57 insertions(+), 3164 deletions(-)
create mode 100644 mlir/python/mlir/_mlir_libs/.gitignore
delete mode 100644 mlir/python/mlir/_mlir_libs/_mlir/__init__.pyi
delete mode 100644 mlir/python/mlir/_mlir_libs/_mlir/dialects/pdl.pyi
delete mode 100644 mlir/python/mlir/_mlir_libs/_mlir/dialects/quant.pyi
delete mode 100644 mlir/python/mlir/_mlir_libs/_mlir/dialects/transform/__init__.pyi
delete mode 100644 mlir/python/mlir/_mlir_libs/_mlir/ir.pyi
delete mode 100644 mlir/python/mlir/_mlir_libs/_mlir/passmanager.pyi
delete mode 100644 mlir/python/mlir/_mlir_libs/_mlirExecutionEngine.pyi
diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index f58a4c6f506ec..1a211f5495764 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -191,6 +191,10 @@ configure_file(
set(MLIR_BINDINGS_PYTHON_NB_DOMAIN "mlir"
CACHE STRING "nanobind domain for MLIR python bindings.")
+set(MLIR_PYTHON_PACKAGE_PREFIX "mlir"
+ CACHE STRING "Specifies that all MLIR packages are co-located under the
+ `MLIR_PYTHON_PACKAGE_PREFIX` top level package (the API has been
+ embedded in a relocatable way).")
set(MLIR_ENABLE_BINDINGS_PYTHON 0 CACHE BOOL
"Enables building of Python bindings.")
set(MLIR_BINDINGS_PYTHON_INSTALL_PREFIX "python_packages/mlir_core/mlir" CACHE STRING
diff --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake
index 2b883558d33c6..f0e36f85feabf 100644
--- a/mlir/cmake/modules/AddMLIRPython.cmake
+++ b/mlir/cmake/modules/AddMLIRPython.cmake
@@ -99,6 +99,38 @@ function(declare_mlir_python_sources name)
endif()
endfunction()
+function(generate_type_stubs module_name depends_target output_dir)
+ if(EXISTS ${nanobind_DIR}/../src/stubgen.py)
+ set(NB_STUBGEN "${nanobind_DIR}/../src/stubgen.py")
+ elseif(EXISTS ${nanobind_DIR}/../stubgen.py)
+ set(NB_STUBGEN "${nanobind_DIR}/../stubgen.py")
+ else()
+ message(FATAL_ERROR "generate_type_stubs(): could not locate 'stubgen.py'!")
+ endif()
+
+ set(NB_STUBGEN_CMD
+ "${Python_EXECUTABLE}"
+ "${NB_STUBGEN}"
+ --module
+ "${MLIR_PYTHON_PACKAGE_PREFIX}._mlir_libs.${module_name}"
+ -i
+ "${MLIR_BINARY_DIR}/${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX}/.."
+ --recursive
+ --include-private
+ --output-dir
+ "${output_dir}")
+
+ set(NB_STUBGEN_OUTPUT "${output_dir}/${module_name}.pyi")
+ add_custom_command(
+ OUTPUT ${NB_STUBGEN_OUTPUT}
+ COMMAND ${NB_STUBGEN_CMD}
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ DEPENDS ${depends_target})
+ set(_name "MLIRPythonModuleStubs_${module_name}")
+ add_custom_target("${_name}" ALL DEPENDS ${NB_STUBGEN_OUTPUT})
+ set(NB_STUBGEN_CUSTOM_TARGET "${_name}" PARENT_SCOPE)
+endfunction()
+
# Function: declare_mlir_python_extension
# Declares a buildable python extension from C++ source files. The built
# module is considered a python source file and included as everything else.
@@ -243,6 +275,17 @@ function(add_mlir_python_modules name)
)
add_dependencies(${modules_target} ${_extension_target})
mlir_python_setup_extension_rpath(${_extension_target})
+ generate_type_stubs(
+ ${_module_name}
+ ${_extension_target}
+ "${CMAKE_CURRENT_SOURCE_DIR}/mlir/_mlir_libs/_mlir"
+ )
+ declare_mlir_python_sources("_${_module_name}_type_stub_gen"
+ ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"
+ ADD_TO_PARENT "${sources_target}"
+ SOURCES_GLOB "_mlir_libs/${_module_name}/**/*.pyi"
+ )
+ add_dependencies("${modules_target}" "${NB_STUBGEN_CUSTOM_TARGET}")
else()
message(SEND_ERROR "Unrecognized source type '${_source_type}' for python source target ${sources_target}")
return()
diff --git a/mlir/examples/standalone/python/CMakeLists.txt b/mlir/examples/standalone/python/CMakeLists.txt
index 69c82fd913579..c004452457eb9 100644
--- a/mlir/examples/standalone/python/CMakeLists.txt
+++ b/mlir/examples/standalone/python/CMakeLists.txt
@@ -2,8 +2,7 @@ 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.")
+add_compile_definitions("MLIR_PYTHON_PACKAGE_PREFIX=${MLIR_PYTHON_PACKAGE_PREFIX}.")
################################################################################
diff --git a/mlir/python/CMakeLists.txt b/mlir/python/CMakeLists.txt
index 7a0c95ebb8200..961de0a9f45f3 100644
--- a/mlir/python/CMakeLists.txt
+++ b/mlir/python/CMakeLists.txt
@@ -1,5 +1,9 @@
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).
+add_compile_definitions("MLIR_PYTHON_PACKAGE_PREFIX=${MLIR_PYTHON_PACKAGE_PREFIX}.")
+
################################################################################
# Structural groupings.
################################################################################
@@ -23,11 +27,6 @@ declare_mlir_python_sources(MLIRPythonSources.Core.Python
passmanager.py
rewrite.py
dialects/_ods_common.py
-
- # The main _mlir module has submodules: include stubs from each.
- _mlir_libs/_mlir/__init__.pyi
- _mlir_libs/_mlir/ir.pyi
- _mlir_libs/_mlir/passmanager.pyi
)
declare_mlir_python_sources(MLIRPythonSources.Core.Python.Extras
@@ -43,7 +42,6 @@ declare_mlir_python_sources(MLIRPythonSources.ExecutionEngine
ADD_TO_PARENT MLIRPythonSources
SOURCES
execution_engine.py
- _mlir_libs/_mlirExecutionEngine.pyi
SOURCES_GLOB
runtime/*.py
)
@@ -195,7 +193,6 @@ declare_mlir_dialect_python_bindings(
TD_FILE dialects/TransformOps.td
SOURCES
dialects/transform/__init__.py
- _mlir_libs/_mlir/dialects/transform/__init__.pyi
DIALECT_NAME transform
GEN_ENUM_BINDINGS_TD_FILE
"../../include/mlir/Dialect/Transform/IR/TransformAttrs.td"
@@ -367,8 +364,7 @@ declare_mlir_python_sources(
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"
GEN_ENUM_BINDINGS
SOURCES
- dialects/quant.py
- _mlir_libs/_mlir/dialects/quant.pyi)
+ dialects/quant.py)
declare_mlir_dialect_python_bindings(
ADD_TO_PARENT MLIRPythonSources.Dialects
@@ -384,7 +380,6 @@ declare_mlir_dialect_python_bindings(
TD_FILE dialects/PDLOps.td
SOURCES
dialects/pdl.py
- _mlir_libs/_mlir/dialects/pdl.pyi
DIALECT_NAME pdl)
declare_mlir_dialect_python_bindings(
@@ -809,7 +804,7 @@ endif()
add_mlir_python_common_capi_library(MLIRPythonCAPI
INSTALL_COMPONENT MLIRPythonModules
INSTALL_DESTINATION "${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX}/_mlir_libs"
- OUTPUT_DIRECTORY "${MLIR_BINARY_DIR}/python_packages/mlir_core/mlir/_mlir_libs"
+ OUTPUT_DIRECTORY "${MLIR_BINARY_DIR}/${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX}/_mlir_libs"
RELATIVE_INSTALL_ROOT "../../../.."
DECLARED_HEADERS
MLIRPythonCAPI.HeaderSources
@@ -838,7 +833,7 @@ endif()
################################################################################
add_mlir_python_modules(MLIRPythonModules
- ROOT_PREFIX "${MLIR_BINARY_DIR}/python_packages/mlir_core/mlir"
+ ROOT_PREFIX "${MLIR_BINARY_DIR}/${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX}"
INSTALL_PREFIX "${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX}"
DECLARED_SOURCES
MLIRPythonSources
@@ -847,4 +842,3 @@ add_mlir_python_modules(MLIRPythonModules
COMMON_CAPI_LINK_LIBS
MLIRPythonCAPI
)
-
diff --git a/mlir/python/mlir/_mlir_libs/.gitignore b/mlir/python/mlir/_mlir_libs/.gitignore
new file mode 100644
index 0000000000000..10c6f95d3ce42
--- /dev/null
+++ b/mlir/python/mlir/_mlir_libs/.gitignore
@@ -0,0 +1 @@
+_mlir/**/*.pyi
\ No newline at end of file
diff --git a/mlir/python/mlir/_mlir_libs/_mlir/__init__.pyi b/mlir/python/mlir/_mlir_libs/_mlir/__init__.pyi
deleted file mode 100644
index 03449b70b7fa3..0000000000000
--- a/mlir/python/mlir/_mlir_libs/_mlir/__init__.pyi
+++ /dev/null
@@ -1,12 +0,0 @@
-
-globals: "_Globals"
-
-class _Globals:
- dialect_search_modules: list[str]
- def _register_dialect_impl(self, dialect_namespace: str, dialect_class: type) -> None: ...
- def _register_operation_impl(self, operation_name: str, operation_class: type) -> None: ...
- def append_dialect_search_prefix(self, module_name: str) -> None: ...
- def _check_dialect_module_loaded(self, dialect_namespace: str) -> bool: ...
-
-def register_dialect(dialect_class: type) -> type: ...
-def register_operation(dialect_class: type, *, replace: bool = ...) -> type: ...
diff --git a/mlir/python/mlir/_mlir_libs/_mlir/dialects/pdl.pyi b/mlir/python/mlir/_mlir_libs/_mlir/dialects/pdl.pyi
deleted file mode 100644
index d12c6839deaba..0000000000000
--- a/mlir/python/mlir/_mlir_libs/_mlir/dialects/pdl.pyi
+++ /dev/null
@@ -1,63 +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 mlir.ir import Type, Context
-
-__all__ = [
- 'PDLType',
- 'AttributeType',
- 'OperationType',
- 'RangeType',
- 'TypeType',
- 'ValueType',
-]
-
-
-class PDLType(Type):
- @staticmethod
- def isinstance(type: Type) -> bool: ...
-
-
-class AttributeType(Type):
- @staticmethod
- def isinstance(type: Type) -> bool: ...
-
- @staticmethod
- def get(context: Context | None = None) -> AttributeType: ...
-
-
-class OperationType(Type):
- @staticmethod
- def isinstance(type: Type) -> bool: ...
-
- @staticmethod
- def get(context: Context | None = None) -> OperationType: ...
-
-
-class RangeType(Type):
- @staticmethod
- def isinstance(type: Type) -> bool: ...
-
- @staticmethod
- def get(element_type: Type) -> RangeType: ...
-
- @property
- def element_type(self) -> Type: ...
-
-
-class TypeType(Type):
- @staticmethod
- def isinstance(type: Type) -> bool: ...
-
- @staticmethod
- def get(context: Context | None = None) -> TypeType: ...
-
-
-class ValueType(Type):
- @staticmethod
- def isinstance(type: Type) -> bool: ...
-
- @staticmethod
- def get(context: Context | None = None) -> ValueType: ...
diff --git a/mlir/python/mlir/_mlir_libs/_mlir/dialects/quant.pyi b/mlir/python/mlir/_mlir_libs/_mlir/dialects/quant.pyi
deleted file mode 100644
index 3f5304584edef..0000000000000
--- a/mlir/python/mlir/_mlir_libs/_mlir/dialects/quant.pyi
+++ /dev/null
@@ -1,142 +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 mlir.ir import DenseElementsAttr, Type
-
-__all__ = [
- "QuantizedType",
- "AnyQuantizedType",
- "UniformQuantizedType",
- "UniformQuantizedPerAxisType",
- "CalibratedQuantizedType",
-]
-
-class QuantizedType(Type):
- @staticmethod
- def isinstance(type: Type) -> bool: ...
-
- @staticmethod
- def default_minimum_for_integer(is_signed: bool, integral_width: int) -> int:
- ...
-
- @staticmethod
- def default_maximum_for_integer(is_signed: bool, integral_width: int) -> int:
- ...
-
- @property
- def expressed_type(self) -> Type: ...
-
- @property
- def flags(self) -> int: ...
-
- @property
- def is_signed(self) -> bool: ...
-
- @property
- def storage_type(self) -> Type: ...
-
- @property
- def storage_type_min(self) -> int: ...
-
- @property
- def storage_type_max(self) -> int: ...
-
- @property
- def storage_type_integral_width(self) -> int: ...
-
- def is_compatible_expressed_type(self, candidate: Type) -> bool: ...
-
- @property
- def quantized_element_type(self) -> Type: ...
-
- def cast_from_storage_type(self, candidate: Type) -> Type: ...
-
- @staticmethod
- def cast_to_storage_type(type: Type) -> Type: ...
-
- def cast_from_expressed_type(self, candidate: Type) -> Type: ...
-
- @staticmethod
- def cast_to_expressed_type(type: Type) -> Type: ...
-
- def cast_expressed_to_storage_type(self, candidate: Type) -> Type: ...
-
-
-class AnyQuantizedType(QuantizedType):
-
- @classmethod
- def get(cls, flags: int, storage_type: Type, expressed_type: Type,
- storage_type_min: int, storage_type_max: int) -> Type:
- ...
-
-
-class UniformQuantizedType(QuantizedType):
-
- @classmethod
- def get(cls, flags: int, storage_type: Type, expressed_type: Type,
- scale: float, zero_point: int, storage_type_min: int,
- storage_type_max: int) -> Type: ...
-
- @property
- def scale(self) -> float: ...
-
- @property
- def zero_point(self) -> int: ...
-
- @property
- def is_fixed_point(self) -> bool: ...
-
-
-class UniformQuantizedPerAxisType(QuantizedType):
-
- @classmethod
- def get(cls, flags: int, storage_type: Type, expressed_type: Type,
- scales: list[float], zero_points: list[int], quantized_dimension: int,
- storage_type_min: int, storage_type_max: int):
- ...
-
- @property
- def scales(self) -> list[float]: ...
-
- @property
- def zero_points(self) -> list[int]: ...
-
- @property
- def quantized_dimension(self) -> int: ...
-
- @property
- def is_fixed_point(self) -> bool: ...
-
-class UniformQuantizedSubChannelType(QuantizedType):
-
- @classmethod
- def get(cls, flags: int, storage_type: Type, expressed_type: Type,
- scales: DenseElementsAttr, zero_points: DenseElementsAttr,
- quantized_dimensions: list[int], block_sizes: list[int],
- storage_type_min: int, storage_type_max: int):
- ...
-
- @property
- def quantized_dimensions(self) -> list[int]: ...
-
- @property
- def block_sizes(self) -> list[int]: ...
-
- @property
- def scales(self) -> DenseElementsAttr: ...
-
- @property
- def zero_points(self) -> DenseElementsAttr: ...
-
-def CalibratedQuantizedType(QuantizedType):
-
- @classmethod
- def get(cls, expressed_type: Type, min: float, max: float): ...
-
- @property
- def min(self) -> float: ...
-
- @property
- def max(self) -> float: ...
\ No newline at end of file
diff --git a/mlir/python/mlir/_mlir_libs/_mlir/dialects/transform/__init__.pyi b/mlir/python/mlir/_mlir_libs/_mlir/dialects/transform/__init__.pyi
deleted file mode 100644
index a3f1b09102379..0000000000000
--- a/mlir/python/mlir/_mlir_libs/_mlir/dialects/transform/__init__.pyi
+++ /dev/null
@@ -1,25 +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 mlir.ir import Type, Context
-
-
-class AnyOpType(Type):
- @staticmethod
- def isinstance(type: Type) -> bool: ...
-
- @staticmethod
- def get(context: Context | None = None) -> AnyOpType: ...
-
-
-class OperationType(Type):
- @staticmethod
- def isinstance(type: Type) -> bool: ...
-
- @staticmethod
- def get(operation_name: str, context: Context | None = None) -> OperationType: ...
-
- @property
- def operation_name(self) -> str: ...
diff --git a/mlir/python/mlir/_mlir_libs/_mlir/ir.pyi b/mlir/python/mlir/_mlir_libs/_mlir/ir.pyi
deleted file mode 100644
index dcae3dd742940..0000000000000
--- a/mlir/python/mlir/_mlir_libs/_mlir/ir.pyi
+++ /dev/null
@@ -1,2846 +0,0 @@
-# Originally imported via:
-# pybind11-stubgen --print-invalid-expressions-as-is mlir._mlir_libs._mlir.ir
-# but with the following diff (in order to remove pipes from types,
-# which we won't support until bumping minimum python to 3.10)
-#
-# --------------------- diff begins ------------------------------------
-#
-# diff --git a/pybind11_stubgen/printer.py b/pybind11_stubgen/printer.py
-# index 1f755aa..4924927 100644
-# --- a/pybind11_stubgen/printer.py
-# +++ b/pybind11_stubgen/printer.py
-# @@ -283,14 +283,6 @@ class Printer:
-# return split[0] + "..."
-#
-# def print_type(self, type_: ResolvedType) -> str:
-# - if (
-# - str(type_.name) == "typing.Optional"
-# - and type_.parameters is not None
-# - and len(type_.parameters) == 1
-# - ):
-# - return f"{self.print_annotation(type_.parameters[0])} | None"
-# - if str(type_.name) == "typing.Union" and type_.parameters is not None:
-# - return " | ".join(self.print_annotation(p) for p in type_.parameters)
-# if type_.parameters:
-# param_str = (
-# "["
-#
-# --------------------- diff ends ------------------------------------
-#
-# Local modifications:
-# * Rewrite references to 'mlir.ir' to local types.
-# * Drop `typing.` everywhere (top-level import instead).
-# * List -> List, dict -> Dict, Tuple -> Tuple.
-# * copy-paste Buffer type from typing_extensions.
-# * Shuffle _OperationBase, AffineExpr, Attribute, Type, Value to the top.
-# * Patch raw C++ types (like "PyAsmState") with a regex like `Py(.*)`.
-# * _BaseContext -> Context, MlirType -> Type, MlirTypeID -> TypeID, MlirAttribute -> Attribute.
-# * Local edits to signatures and types that pybind11-stubgen did not auto detect (or detected incorrectly).
-# * Add MLIRError, _GlobalDebug, _OperationBase to __all__ by hand.
-# * Fill in `Any`s where possible.
-# * black formatting.
-
-from __future__ import annotations
-
-import abc
-import collections
-from collections.abc import Callable, Sequence
-from pathlib import Path
-from typing import Any, BinaryIO, ClassVar, Literal, TypeVar, overload
-
-__all__ = [
- "AffineAddExpr",
- "AffineBinaryExpr",
- "AffineCeilDivExpr",
- "AffineConstantExpr",
- "AffineDimExpr",
- "AffineExpr",
- "AffineExprList",
- "AffineFloorDivExpr",
- "AffineMap",
- "AffineMapAttr",
- "AffineModExpr",
- "AffineMulExpr",
- "AffineSymbolExpr",
- "ArrayAttr",
- "ArrayAttributeIterator",
- "AsmState",
- "AttrBuilder",
- "Attribute",
- "BF16Type",
- "Block",
- "BlockArgument",
- "BlockArgumentList",
- "BlockIterator",
- "BlockList",
- "BoolAttr",
- "ComplexType",
- "Context",
- "DenseBoolArrayAttr",
- "DenseBoolArrayIterator",
- "DenseElementsAttr",
- "DenseF32ArrayAttr",
- "DenseF32ArrayIterator",
- "DenseF64ArrayAttr",
- "DenseF64ArrayIterator",
- "DenseFPElementsAttr",
- "DenseI16ArrayAttr",
- "DenseI16ArrayIterator",
- "DenseI32ArrayAttr",
- "DenseI32ArrayIterator",
- "DenseI64ArrayAttr",
- "DenseI64ArrayIterator",
- "DenseI8ArrayAttr",
- "DenseI8ArrayIterator",
- "DenseIntElementsAttr",
- "DenseResourceElementsAttr",
- "Diagnostic",
- "DiagnosticHandler",
- "DiagnosticInfo",
- "DiagnosticSeverity",
- "Dialect",
- "DialectDescriptor",
- "DialectRegistry",
- "Dialects",
- "DictAttr",
- "F16Type",
- "F32Type",
- "F64Type",
- "FlatSymbolRefAttr",
- "Float4E2M1FNType",
- "Float6E2M3FNType",
- "Float6E3M2FNType",
- "Float8E3M4Type",
- "Float8E4M3B11FNUZType",
- "Float8E4M3FNType",
- "Float8E4M3FNUZType",
- "Float8E4M3Type",
- "Float8E5M2FNUZType",
- "Float8E5M2Type",
- "Float8E8M0FNUType",
- "FloatAttr",
- "FloatTF32Type",
- "FloatType",
- "FunctionType",
- "IndexType",
- "InferShapedTypeOpInterface",
- "InferTypeOpInterface",
- "InsertionPoint",
- "IntegerAttr",
- "IntegerSet",
- "IntegerSetAttr",
- "IntegerSetConstraint",
- "IntegerSetConstraintList",
- "IntegerType",
- "Location",
- "MemRefType",
- "Module",
- "NamedAttribute",
- "NoneType",
- "OpAttributeMap",
- "OpOperand",
- "OpOperandIterator",
- "OpOperandList",
- "OpResult",
- "OpResultList",
- "OpSuccessors",
- "OpView",
- "OpaqueAttr",
- "OpaqueType",
- "Operation",
- "OperationIterator",
- "OperationList",
- "RankedTensorType",
- "Region",
- "RegionIterator",
- "RegionSequence",
- "ShapedType",
- "ShapedTypeComponents",
- "StridedLayoutAttr",
- "StringAttr",
- "SymbolRefAttr",
- "SymbolTable",
- "TupleType",
- "Type",
- "TypeAttr",
- "TypeID",
- "UnitAttr",
- "UnrankedMemRefType",
- "UnrankedTensorType",
- "Value",
- "VectorType",
- "_GlobalDebug",
- "_OperationBase",
-]
-
-if hasattr(collections.abc, "Buffer"):
- Buffer = collections.abc.Buffer
-else:
- class Buffer(abc.ABC):
- pass
-
-class _OperationBase:
- @overload
- def __eq__(self, arg0: _OperationBase) -> bool: ...
- @overload
- def __eq__(self, arg0: _OperationBase) -> bool: ...
- def __hash__(self) -> int: ...
- def __str__(self) -> str:
- """
- Returns the assembly form of the operation.
- """
- def clone(self, ip: InsertionPoint = None) -> OpView: ...
- def detach_from_parent(self) -> OpView:
- """
- Detaches the operation from its parent block.
- """
-
- @property
- def attached(self) -> bool:
- """
- Reports if the operation is attached to its parent block.
- """
-
- def erase(self) -> None: ...
-
- @overload
- def get_asm(
- binary: Literal[True],
- large_elements_limit: int | None = None,
- large_resource_limit: int | None = None,
- enable_debug_info: bool = False,
- pretty_debug_info: bool = False,
- print_generic_op_form: bool = False,
- use_local_scope: bool = False,
- assume_verified: bool = False,
- skip_regions: bool = False,
- ) -> bytes: ...
- @overload
- def get_asm(
- self,
- binary: bool = False,
- large_elements_limit: int | None = None,
- large_resource_limit: int | None = None,
- enable_debug_info: bool = False,
- pretty_debug_info: bool = False,
- print_generic_op_form: bool = False,
- use_local_scope: bool = False,
- assume_verified: bool = False,
- skip_regions: bool = False,
- ) -> str:
- """
- Returns the assembly form of the operation.
-
- See the print() method for common keyword arguments for configuring
- the output.
- """
-
- def move_after(self, other: _OperationBase) -> None:
- """
- Puts self immediately after the other operation in its parent block.
- """
- def move_before(self, other: _OperationBase) -> None:
- """
- Puts self immediately before the other operation in its parent block.
- """
- @overload
- def print(
- self,
- state: AsmState,
- file: Any | None = None,
- binary: bool = False,
- ) -> None:
- """
- Prints the assembly form of the operation to a file like object.
-
- Args:
- file: The file like object to write to. Defaults to sys.stdout.
- binary: Whether to write bytes (True) or str (False). Defaults to False.
- state: AsmState capturing the operation numbering and flags.
- """
- @overload
- def print(
- self,
- large_elements_limit: int | None = None,
- large_resource_limit: int | None = None,
- enable_debug_info: bool = False,
- pretty_debug_info: bool = False,
- print_generic_op_form: bool = False,
- use_local_scope: bool = False,
- assume_verified: bool = False,
- file: Any | None = None,
- binary: bool = False,
- skip_regions: bool = False,
- ) -> None:
- """
- Prints the assembly form of the operation to a file like object.
-
- Args:
- file: The file like object to write to. Defaults to sys.stdout.
- binary: Whether to write bytes (True) or str (False). Defaults to False.
- large_elements_limit: Whether to elide elements attributes above this
- number of elements. Defaults to None (no limit).
- large_resource_limit: Whether to elide resource strings above this
- number of characters. Defaults to None (no limit). If large_elements_limit
- is set and this is None, the behavior will be to use large_elements_limit
- as large_resource_limit.
- enable_debug_info: Whether to print debug/location information. Defaults
- to False.
- pretty_debug_info: Whether to format debug information for easier reading
- by a human (warning: the result is unparseable).
- print_generic_op_form: Whether to print the generic assembly forms of all
- ops. Defaults to False.
- use_local_Scope: Whether to print in a way that is more optimized for
- multi-threaded access but may not be consistent with how the overall
- module prints.
- assume_verified: By default, if not printing generic form, the verifier
- will be run and if it fails, generic form will be printed with a comment
- about failed verification. While a reasonable default for interactive use,
- for systematic use, it is often better for the caller to verify explicitly
- and report failures in a more robust fashion. Set this to True if doing this
- in order to avoid running a redundant verification. If the IR is actually
- invalid, behavior is undefined.
- skip_regions: Whether to skip printing regions. Defaults to False.
- """
- def verify(self) -> bool:
- """
- Verify the operation. Raises MLIRError if verification fails, and returns true otherwise.
- """
- def write_bytecode(self, file: BinaryIO | str, desired_version: int | None = None) -> None:
- """
- Write the bytecode form of the operation to a file like object.
-
- Args:
- file: The file like object or path to write to.
- desired_version: The version of bytecode to emit.
- Returns:
- The bytecode writer status.
- """
- @property
- def _CAPIPtr(self) -> object: ...
- @property
- def attributes(self) -> OpAttributeMap: ...
- @property
- def context(self) -> Context:
- """
- Context that owns the Operation
- """
- @property
- def location(self) -> Location:
- """
- Returns the source location the operation was defined or derived from.
- """
- @property
- def name(self) -> str: ...
- @property
- def operands(self) -> OpOperandList: ...
- @property
- def parent(self) -> _OperationBase | None: ...
- @property
- def regions(self) -> RegionSequence: ...
- @property
- def result(self) -> OpResult:
- """
- Shortcut to get an op result if it has only one (throws an error otherwise).
- """
- @property
- def results(self) -> OpResultList:
- """
- Returns the List of Operation results.
- """
-
-_TOperation = TypeVar("_TOperation", bound=_OperationBase)
-
-class AffineExpr:
- @staticmethod
- @overload
- def get_add(arg0: AffineExpr, arg1: AffineExpr) -> AffineAddExpr:
- """
- Gets an affine expression containing a sum of two expressions.
- """
- @staticmethod
- @overload
- def get_add(arg0: int, arg1: AffineExpr) -> AffineAddExpr:
- """
- Gets an affine expression containing a sum of a constant and another expression.
- """
- @staticmethod
- @overload
- def get_add(arg0: AffineExpr, arg1: int) -> AffineAddExpr:
- """
- Gets an affine expression containing a sum of an expression and a constant.
- """
- @staticmethod
- @overload
- def get_ceil_div(arg0: AffineExpr, arg1: AffineExpr) -> AffineCeilDivExpr:
- """
- Gets an affine expression containing the rounded-up result of dividing one expression by another.
- """
- @staticmethod
- @overload
- def get_ceil_div(arg0: int, arg1: AffineExpr) -> AffineCeilDivExpr:
- """
- Gets a semi-affine expression containing the rounded-up result of dividing a constant by an expression.
- """
- @staticmethod
- @overload
- def get_ceil_div(arg0: AffineExpr, arg1: int) -> AffineCeilDivExpr:
- """
- Gets an affine expression containing the rounded-up result of dividing an expression by a constant.
- """
- @staticmethod
- def get_constant(
- value: int, context: Context | None = None
- ) -> AffineConstantExpr:
- """
- Gets a constant affine expression with the given value.
- """
- @staticmethod
- def get_dim(position: int, context: Context | None = None) -> AffineDimExpr:
- """
- Gets an affine expression of a dimension at the given position.
- """
- @staticmethod
- @overload
- def get_floor_div(arg0: AffineExpr, arg1: AffineExpr) -> AffineFloorDivExpr:
- """
- Gets an affine expression containing the rounded-down result of dividing one expression by another.
- """
- @staticmethod
- @overload
- def get_floor_div(arg0: int, arg1: AffineExpr) -> AffineFloorDivExpr:
- """
- Gets a semi-affine expression containing the rounded-down result of dividing a constant by an expression.
- """
- @staticmethod
- @overload
- def get_floor_div(arg0: AffineExpr, arg1: int) -> AffineFloorDivExpr:
- """
- Gets an affine expression containing the rounded-down result of dividing an expression by a constant.
- """
- @staticmethod
- @overload
- def get_mod(arg0: AffineExpr, arg1: AffineExpr) -> AffineModExpr:
- """
- Gets an affine expression containing the modulo of dividing one expression by another.
- """
- @staticmethod
- @overload
- def get_mod(arg0: int, arg1: AffineExpr) -> AffineModExpr:
- """
- Gets a semi-affine expression containing the modulo of dividing a constant by an expression.
- """
- @staticmethod
- @overload
- def get_mod(arg0: AffineExpr, arg1: int) -> AffineModExpr:
- """
- Gets an affine expression containing the module of dividingan expression by a constant.
- """
- @staticmethod
- @overload
- def get_mul(arg0: AffineExpr, arg1: AffineExpr) -> AffineMulExpr:
- """
- Gets an affine expression containing a product of two expressions.
- """
- @staticmethod
- @overload
- def get_mul(arg0: int, arg1: AffineExpr) -> AffineMulExpr:
- """
- Gets an affine expression containing a product of a constant and another expression.
- """
- @staticmethod
- @overload
- def get_mul(arg0: AffineExpr, arg1: int) -> AffineMulExpr:
- """
- Gets an affine expression containing a product of an expression and a constant.
- """
- @staticmethod
- def get_symbol(
- position: int, context: Context | None = None
- ) -> AffineSymbolExpr:
- """
- Gets an affine expression of a symbol at the given position.
- """
- def _CAPICreate(self) -> AffineExpr: ...
- @overload
- def __add__(self, arg0: AffineExpr) -> AffineAddExpr: ...
- @overload
- def __add__(self, arg0: int) -> AffineAddExpr: ...
- @overload
- def __eq__(self, arg0: AffineExpr) -> bool: ...
- @overload
- def __eq__(self, arg0: Any) -> bool: ...
- def __hash__(self) -> int: ...
- @overload
- def __mod__(self, arg0: AffineExpr) -> AffineModExpr: ...
- @overload
- def __mod__(self, arg0: int) -> AffineModExpr: ...
- @overload
- def __mul__(self, arg0: AffineExpr) -> AffineMulExpr: ...
- @overload
- def __mul__(self, arg0: int) -> AffineMulExpr: ...
- def __radd__(self, arg0: int) -> AffineAddExpr: ...
- def __rmod__(self, arg0: int) -> AffineModExpr: ...
- def __rmul__(self, arg0: int) -> AffineMulExpr: ...
- def __rsub__(self, arg0: int) -> AffineAddExpr: ...
- @overload
- def __sub__(self, arg0: AffineExpr) -> AffineAddExpr: ...
- @overload
- def __sub__(self, arg0: int) -> AffineAddExpr: ...
- def compose(self, arg0: AffineMap) -> AffineExpr: ...
- def dump(self) -> None:
- """
- Dumps a debug representation of the object to stderr.
- """
- @property
- def _CAPIPtr(self) -> object: ...
- @property
- def context(self) -> Context: ...
-
-class Attribute:
- @staticmethod
- def parse(asm: str | bytes, context: Context | None = None) -> Attribute:
- """
- Parses an attribute from an assembly form. Raises an MLIRError on failure.
- """
- def _CAPICreate(self) -> Attribute: ...
- @overload
- def __eq__(self, arg0: Attribute) -> bool: ...
- @overload
- def __eq__(self, arg0: object) -> bool: ...
- def __hash__(self) -> int: ...
- def __init__(self, cast_from_type: Attribute) -> None:
- """
- Casts the passed attribute to the generic Attribute
- """
- def __str__(self) -> str:
- """
- Returns the assembly form of the Attribute.
- """
- def dump(self) -> None:
- """
- Dumps a debug representation of the object to stderr.
- """
- def get_named(self, arg0: str) -> NamedAttribute:
- """
- Binds a name to the attribute
- """
- def maybe_downcast(self) -> Any: ...
- @property
- def _CAPIPtr(self) -> object: ...
- @property
- def context(self) -> Context:
- """
- Context that owns the Attribute
- """
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class Type:
- @staticmethod
- def parse(asm: str | bytes, context: Context | None = None) -> Type:
- """
- Parses the assembly form of a type.
-
- Returns a Type object or raises an MLIRError if the type cannot be parsed.
-
- See also: https://mlir.llvm.org/docs/LangRef/#type-system
- """
- def _CAPICreate(self) -> Type: ...
- @overload
- def __eq__(self, arg0: Type) -> bool: ...
- @overload
- def __eq__(self, arg0: object) -> bool: ...
- def __hash__(self) -> int: ...
- def __init__(self, cast_from_type: Type) -> None:
- """
- Casts the passed type to the generic Type
- """
- def __str__(self) -> str:
- """
- Returns the assembly form of the type.
- """
- def dump(self) -> None:
- """
- Dumps a debug representation of the object to stderr.
- """
- def maybe_downcast(self) -> Any: ...
- @property
- def _CAPIPtr(self) -> object: ...
- @property
- def context(self) -> Context:
- """
- Context that owns the Type
- """
- @property
- def typeid(self) -> TypeID: ...
-
-class Value:
- def _CAPICreate(self) -> Value: ...
- @overload
- def __eq__(self, arg0: Value) -> bool: ...
- @overload
- def __eq__(self, arg0: object) -> bool: ...
- def __hash__(self) -> int: ...
- def __init__(self, value: Value) -> None: ...
- def __str__(self) -> str:
- """
- Returns the string form of the value.
-
- If the value is a block argument, this is the assembly form of its type and the
- position in the argument List. If the value is an operation result, this is
- equivalent to printing the operation that produced it.
- """
- def dump(self) -> None:
- """
- Dumps a debug representation of the object to stderr.
- """
- @overload
- def get_name(self, use_local_scope: bool = False, use_name_loc_as_prefix: bool = True) -> str: ...
- @overload
- def get_name(self, state: AsmState) -> str:
- """
- Returns the string form of value as an operand (i.e., the ValueID).
- """
- def maybe_downcast(self) -> Any: ...
- def replace_all_uses_with(self, arg0: Value) -> None:
- """
- Replace all uses of value with the new value, updating anything in
- the IR that uses 'self' to use the other value instead.
- """
- def set_type(self, type: Type) -> None: ...
- @property
- def _CAPIPtr(self) -> object: ...
- @property
- def context(self) -> Context:
- """
- Context in which the value lives.
- """
- @property
- def owner(self) -> _OperationBase: ...
- @property
- def type(self) -> Type: ...
- @property
- def uses(self) -> OpOperandIterator: ...
-
-class AffineAddExpr(AffineBinaryExpr):
- @staticmethod
- def get(arg0: AffineExpr, arg1: AffineExpr) -> AffineAddExpr: ...
- @staticmethod
- def isinstance(other: AffineExpr) -> bool: ...
- def __init__(self, expr: AffineExpr) -> None: ...
-
-class AffineBinaryExpr(AffineExpr):
- @staticmethod
- def isinstance(other: AffineExpr) -> bool: ...
- def __init__(self, expr: AffineExpr) -> None: ...
- @property
- def lhs(self) -> AffineExpr: ...
- @property
- def rhs(self) -> AffineExpr: ...
-
-class AffineCeilDivExpr(AffineBinaryExpr):
- @staticmethod
- def get(arg0: AffineExpr, arg1: AffineExpr) -> AffineCeilDivExpr: ...
- @staticmethod
- def isinstance(other: AffineExpr) -> bool: ...
- def __init__(self, expr: AffineExpr) -> None: ...
-
-class AffineConstantExpr(AffineExpr):
- @staticmethod
- def get(value: int, context: Context | None = None) -> AffineConstantExpr: ...
- @staticmethod
- def isinstance(other: AffineExpr) -> bool: ...
- def __init__(self, expr: AffineExpr) -> None: ...
- @property
- def value(self) -> int: ...
-
-class AffineDimExpr(AffineExpr):
- @staticmethod
- def get(position: int, context: Context | None = None) -> AffineDimExpr: ...
- @staticmethod
- def isinstance(other: AffineExpr) -> bool: ...
- def __init__(self, expr: AffineExpr) -> None: ...
- @property
- def position(self) -> int: ...
-
-class AffineExprList:
- def __add__(self, arg0: AffineExprList) -> list[AffineExpr]: ...
-
-class AffineFloorDivExpr(AffineBinaryExpr):
- @staticmethod
- def get(arg0: AffineExpr, arg1: AffineExpr) -> AffineFloorDivExpr: ...
- @staticmethod
- def isinstance(other: AffineExpr) -> bool: ...
- def __init__(self, expr: AffineExpr) -> None: ...
-
-class AffineMap:
- @staticmethod
- def compress_unused_symbols(
- arg0: list, arg1: Context | None
- ) -> list[AffineMap]: ...
- @staticmethod
- def get(
- dim_count: int,
- symbol_count: int,
- exprs: list,
- context: Context | None = None,
- ) -> AffineMap:
- """
- Gets a map with the given expressions as results.
- """
- @staticmethod
- def get_constant(value: int, context: Context | None = None) -> AffineMap:
- """
- Gets an affine map with a single constant result
- """
- @staticmethod
- def get_empty(context: Context | None = None) -> AffineMap:
- """
- Gets an empty affine map.
- """
- @staticmethod
- def get_identity(n_dims: int, context: Context | None = None) -> AffineMap:
- """
- Gets an identity map with the given number of dimensions.
- """
- @staticmethod
- def get_minor_identity(
- n_dims: int, n_results: int, context: Context | None = None
- ) -> AffineMap:
- """
- Gets a minor identity map with the given number of dimensions and results.
- """
- @staticmethod
- def get_permutation(
- permutation: list[int], context: Context | None = None
- ) -> AffineMap:
- """
- Gets an affine map that permutes its inputs.
- """
- def _CAPICreate(self) -> AffineMap: ...
- @overload
- def __eq__(self, arg0: AffineMap) -> bool: ...
- @overload
- def __eq__(self, arg0: object) -> bool: ...
- def __hash__(self) -> int: ...
- def dump(self) -> None:
- """
- Dumps a debug representation of the object to stderr.
- """
- def get_major_submap(self, n_results: int) -> AffineMap: ...
- def get_minor_submap(self, n_results: int) -> AffineMap: ...
- def get_submap(self, result_positions: list[int]) -> AffineMap: ...
- def replace(
- self,
- expr: AffineExpr,
- replacement: AffineExpr,
- n_result_dims: int,
- n_result_syms: int,
- ) -> AffineMap: ...
- @property
- def _CAPIPtr(self) -> object: ...
- @property
- def context(self) -> Context:
- """
- Context that owns the Affine Map
- """
- @property
- def is_permutation(self) -> bool: ...
- @property
- def is_projected_permutation(self) -> bool: ...
- @property
- def n_dims(self) -> int: ...
- @property
- def n_inputs(self) -> int: ...
- @property
- def n_symbols(self) -> int: ...
- @property
- def results(self) -> AffineMapExprList: ...
-
-class AffineMapAttr(Attribute):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(affine_map: AffineMap) -> AffineMapAttr:
- """
- Gets an attribute wrapping an AffineMap.
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class AffineModExpr(AffineBinaryExpr):
- @staticmethod
- def get(arg0: AffineExpr, arg1: AffineExpr) -> AffineModExpr: ...
- @staticmethod
- def isinstance(other: AffineExpr) -> bool: ...
- def __init__(self, expr: AffineExpr) -> None: ...
-
-class AffineMulExpr(AffineBinaryExpr):
- @staticmethod
- def get(arg0: AffineExpr, arg1: AffineExpr) -> AffineMulExpr: ...
- @staticmethod
- def isinstance(other: AffineExpr) -> bool: ...
- def __init__(self, expr: AffineExpr) -> None: ...
-
-class AffineSymbolExpr(AffineExpr):
- @staticmethod
- def get(position: int, context: Context | None = None) -> AffineSymbolExpr: ...
- @staticmethod
- def isinstance(other: AffineExpr) -> bool: ...
- def __init__(self, expr: AffineExpr) -> None: ...
- @property
- def position(self) -> int: ...
-
-class ArrayAttr(Attribute):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(attributes: list, context: Context | None = None) -> ArrayAttr:
- """
- Gets a uniqued Array attribute
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __add__(self, arg0: list) -> ArrayAttr: ...
- def __getitem__(self, arg0: int) -> Attribute: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- def __iter__(
- self,
- ) -> ArrayAttributeIterator: ...
- def __len__(self) -> int: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class ArrayAttributeIterator:
- def __iter__(self) -> ArrayAttributeIterator: ...
- def __next__(self) -> Attribute: ...
-
-class AsmState:
- @overload
- def __init__(self, value: Value, use_local_scope: bool = False) -> None: ...
- @overload
- def __init__(self, op: _OperationBase, use_local_scope: bool = False) -> None: ...
-
-class AttrBuilder:
- @staticmethod
- def contains(arg0: str) -> bool: ...
- @staticmethod
- def get(arg0: str) -> Callable: ...
- @staticmethod
- def insert(
- attribute_kind: str, attr_builder: Callable, replace: bool = False
- ) -> None:
- """
- Register an attribute builder for building MLIR attributes from python values.
- """
-
-class BF16Type(Type):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> BF16Type:
- """
- Create a bf16 type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class Block:
- @staticmethod
- def create_at_start(
- parent: Region,
- arg_types: list[Type],
- arg_locs: Sequence | None = None,
- ) -> Block:
- """
- Creates and returns a new Block at the beginning of the given region (with given argument types and locations).
- """
- @overload
- def __eq__(self, arg0: Block) -> bool: ...
- @overload
- def __eq__(self, arg0: Any) -> bool: ...
- def __hash__(self) -> int: ...
- def __iter__(self) -> OperationIterator:
- """
- Iterates over operations in the block.
- """
- def __str__(self) -> str:
- """
- Returns the assembly form of the block.
- """
- def append(self, operation: _OperationBase) -> None:
- """
- Appends an operation to this block. If the operation is currently in another block, it will be moved.
- """
- def append_to(self, arg0: Region) -> None:
- """
- Append this block to a region, transferring ownership if necessary
- """
- def create_after(self, *args, arg_locs: Sequence | None = None) -> Block:
- """
- Creates and returns a new Block after this block (with given argument types and locations).
- """
- def create_before(self, *args, arg_locs: Sequence | None = None) -> Block:
- """
- Creates and returns a new Block before this block (with given argument types and locations).
- """
- @property
- def _CAPIPtr(self) -> object: ...
- @property
- def arguments(self) -> BlockArgumentList:
- """
- Returns a List of block arguments.
- """
- @property
- def operations(self) -> OperationList:
- """
- Returns a forward-optimized sequence of operations.
- """
- @property
- def owner(self) -> OpView:
- """
- Returns the owning operation of this block.
- """
- @property
- def region(self) -> Region:
- """
- Returns the owning region of this block.
- """
-
-class BlockArgument(Value):
- @staticmethod
- def isinstance(other_value: Value) -> bool: ...
- def __init__(self, value: Value) -> None: ...
- def maybe_downcast(self) -> Any: ...
- def set_type(self, type: Type) -> None: ...
- @property
- def arg_number(self) -> int: ...
- @property
- def owner(self) -> Block: ...
-
-class BlockArgumentList:
- @overload
- def __getitem__(self, arg0: int) -> BlockArgument: ...
- @overload
- def __getitem__(self, arg0: slice) -> BlockArgumentList: ...
- def __len__(self) -> int: ...
- def __add__(self, arg0: BlockArgumentList) -> list[BlockArgument]: ...
- @property
- def types(self) -> list[Type]: ...
-
-class BlockIterator:
- def __iter__(self) -> BlockIterator: ...
- def __next__(self) -> Block: ...
-
-class BlockList:
- def __getitem__(self, arg0: int) -> Block: ...
- def __iter__(self) -> BlockIterator: ...
- def __len__(self) -> int: ...
- def append(self, *args, arg_locs: Sequence | None = None) -> Block:
- """
- Appends a new block, with argument types as positional args.
-
- Returns:
- The created block.
- """
-
-class BoolAttr(Attribute):
- @staticmethod
- def get(value: bool, context: Context | None = None) -> BoolAttr:
- """
- Gets an uniqued bool attribute
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __bool__(self: Attribute) -> bool:
- """
- Converts the value of the bool attribute to a Python bool
- """
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- @property
- def static_typeid(self) -> TypeID: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
- @property
- def value(self) -> bool:
- """
- Returns the value of the bool attribute
- """
-
-class ComplexType(Type):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(arg0: Type) -> ComplexType:
- """
- Create a complex type
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def element_type(self) -> Type:
- """
- Returns element type.
- """
- @property
- def typeid(self) -> TypeID: ...
-
-class Context:
- current: ClassVar[Context] = ... # read-only
- allow_unregistered_dialects: bool
- @staticmethod
- def _get_live_count() -> int: ...
- def _CAPICreate(self) -> object: ...
- def __enter__(self) -> Context: ...
- def __exit__(self, arg0: Any, arg1: Any, arg2: Any) -> None: ...
- def __init__(self) -> None: ...
- def _clear_live_operations(self) -> int: ...
- def _get_context_again(self) -> Context: ...
- def _get_live_module_count(self) -> int: ...
- def _get_live_operation_count(self) -> int: ...
- def _get_live_operation_objects(self) -> list[Operation]: ...
- def append_dialect_registry(self, registry: DialectRegistry) -> None: ...
- def attach_diagnostic_handler(
- self, callback: Callable[[Diagnostic], bool]
- ) -> DiagnosticHandler:
- """
- Attaches a diagnostic handler that will receive callbacks
- """
- def enable_multithreading(self, enable: bool) -> None: ...
- def get_dialect_descriptor(self, dialect_name: str) -> DialectDescriptor:
- """
- Gets or loads a dialect by name, returning its descriptor object
- """
- def is_registered_operation(self, operation_name: str) -> bool: ...
- def load_all_available_dialects(self) -> None: ...
- @property
- def _CAPIPtr(self) -> object: ...
- @property
- def d(self) -> Dialects:
- """
- Alias for 'dialect'
- """
- @property
- def dialects(self) -> Dialects:
- """
- Gets a container for accessing dialects by name
- """
-
-class DenseBoolArrayAttr(Attribute):
- @staticmethod
- def get(
- values: Sequence[bool], context: Context | None = None
- ) -> DenseBoolArrayAttr:
- """
- Gets a uniqued dense array attribute
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __add__(self, arg0: list) -> DenseBoolArrayAttr: ...
- def __getitem__(self, arg0: int) -> bool: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- def __iter__(
- self,
- ) -> DenseBoolArrayIterator: ...
- def __len__(self) -> int: ...
- @property
- def static_typeid(self) -> TypeID: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class DenseBoolArrayIterator:
- def __iter__(self) -> DenseBoolArrayIterator: ...
- def __next__(self) -> bool: ...
-
-class DenseElementsAttr(Attribute):
- @staticmethod
- def get(
- array: Buffer,
- signless: bool = True,
- type: Type | None = None,
- shape: list[int] | None = None,
- context: Context | None = None,
- ) -> DenseElementsAttr:
- """
- Gets a DenseElementsAttr from a Python buffer or array.
-
- When `type` is not provided, then some limited type inferencing is done based
- on the buffer format. Support presently exists for 8/16/32/64 signed and
- unsigned integers and float16/float32/float64. DenseElementsAttrs of these
- types can also be converted back to a corresponding buffer.
-
- For conversions outside of these types, a `type=` must be explicitly provided
- and the buffer contents must be bit-castable to the MLIR internal
- representation:
-
- * Integer types (except for i1): the buffer must be byte aligned to the
- next byte boundary.
- * Floating point types: Must be bit-castable to the given floating point
- size.
- * i1 (bool): Bit packed into 8bit words where the bit pattern matches a
- row major ordering. An arbitrary Numpy `bool_` array can be bit packed to
- this specification with: `np.packbits(ary, axis=None, bitorder='little')`.
-
- If a single element buffer is passed (or for i1, a single byte with value 0
- or 255), then a splat will be created.
-
- Args:
- array: The array or buffer to convert.
- signless: If inferring an appropriate MLIR type, use signless types for
- integers (defaults True).
- type: Skips inference of the MLIR element type and uses this instead. The
- storage size must be consistent with the actual contents of the buffer.
- shape: Overrides the shape of the buffer when constructing the MLIR
- shaped type. This is needed when the physical and logical shape differ (as
- for i1).
- context: Explicit context, if not from context manager.
-
- Returns:
- DenseElementsAttr on success.
-
- Raises:
- ValueError: If the type of the buffer or array cannot be matched to an MLIR
- type or if the buffer does not meet expectations.
- """
- @staticmethod
- def get_splat(shaped_type: Type, element_attr: Attribute) -> DenseElementsAttr:
- """
- Gets a DenseElementsAttr where all values are the same
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- def __len__(self) -> int: ...
- def get_splat_value(self) -> Attribute: ...
- @property
- def is_splat(self) -> bool: ...
- @property
- def static_typeid(self) -> TypeID: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class DenseF32ArrayAttr(Attribute):
- @staticmethod
- def get(
- values: Sequence[float], context: Context | None = None
- ) -> DenseF32ArrayAttr:
- """
- Gets a uniqued dense array attribute
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __add__(self, arg0: list) -> DenseF32ArrayAttr: ...
- def __getitem__(self, arg0: int) -> float: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- def __iter__(
- self,
- ) -> DenseF32ArrayIterator: ...
- def __len__(self) -> int: ...
- @property
- def static_typeid(self) -> TypeID: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class DenseF32ArrayIterator:
- def __iter__(self) -> DenseF32ArrayIterator: ...
- def __next__(self) -> float: ...
-
-class DenseF64ArrayAttr(Attribute):
- @staticmethod
- def get(
- values: Sequence[float], context: Context | None = None
- ) -> DenseF64ArrayAttr:
- """
- Gets a uniqued dense array attribute
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __add__(self, arg0: list) -> DenseF64ArrayAttr: ...
- def __getitem__(self, arg0: int) -> float: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- def __iter__(
- self,
- ) -> DenseF64ArrayIterator: ...
- def __len__(self) -> int: ...
- @property
- def static_typeid(self) -> TypeID: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class DenseF64ArrayIterator:
- def __iter__(self) -> DenseF64ArrayIterator: ...
- def __next__(self) -> float: ...
-
-class DenseFPElementsAttr(DenseElementsAttr):
- @staticmethod
- def get(
- array: Buffer,
- signless: bool = True,
- type: Type | None = None,
- shape: list[int] | None = None,
- context: Context | None = None,
- ) -> DenseFPElementsAttr: ...
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __getitem__(self, arg0: int) -> float: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- @property
- def static_typeid(self) -> TypeID: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class DenseI16ArrayAttr(Attribute):
- @staticmethod
- def get(values: Sequence[int], context: Context | None = None) -> DenseI16ArrayAttr:
- """
- Gets a uniqued dense array attribute
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __add__(self, arg0: list) -> DenseI16ArrayAttr: ...
- def __getitem__(self, arg0: int) -> int: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- def __iter__(
- self,
- ) -> DenseI16ArrayIterator: ...
- def __len__(self) -> int: ...
- @property
- def static_typeid(self) -> TypeID: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class DenseI16ArrayIterator:
- def __iter__(self) -> DenseI16ArrayIterator: ...
- def __next__(self) -> int: ...
-
-class DenseI32ArrayAttr(Attribute):
- @staticmethod
- def get(values: Sequence[int], context: Context | None = None) -> DenseI32ArrayAttr:
- """
- Gets a uniqued dense array attribute
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __add__(self, arg0: list) -> DenseI32ArrayAttr: ...
- def __getitem__(self, arg0: int) -> int: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- def __iter__(
- self,
- ) -> DenseI32ArrayIterator: ...
- def __len__(self) -> int: ...
- @property
- def static_typeid(self) -> TypeID: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class DenseI32ArrayIterator:
- def __iter__(self) -> DenseI32ArrayIterator: ...
- def __next__(self) -> int: ...
-
-class DenseI64ArrayAttr(Attribute):
- @staticmethod
- def get(values: Sequence[int], context: Context | None = None) -> DenseI64ArrayAttr:
- """
- Gets a uniqued dense array attribute
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __add__(self, arg0: list) -> DenseI64ArrayAttr: ...
- def __getitem__(self, arg0: int) -> int: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- def __iter__(
- self,
- ) -> DenseI16ArrayIterator: ...
- def __len__(self) -> int: ...
- @property
- def static_typeid(self) -> TypeID: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class DenseI64ArrayIterator:
- def __iter__(self) -> DenseI64ArrayIterator: ...
- def __next__(self) -> int: ...
-
-class DenseI8ArrayAttr(Attribute):
- @staticmethod
- def get(values: Sequence[int], context: Context | None = None) -> DenseI8ArrayAttr:
- """
- Gets a uniqued dense array attribute
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __add__(self, arg0: list) -> DenseI8ArrayAttr: ...
- def __getitem__(self, arg0: int) -> int: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- def __iter__(
- self,
- ) -> DenseI8ArrayIterator: ...
- def __len__(self) -> int: ...
- @property
- def static_typeid(self) -> TypeID: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class DenseI8ArrayIterator:
- def __iter__(self) -> DenseI8ArrayIterator: ...
- def __next__(self) -> int: ...
-
-class DenseIntElementsAttr(DenseElementsAttr):
- @staticmethod
- def get(
- array: Buffer,
- signless: bool = True,
- type: Type | None = None,
- shape: list[int] | None = None,
- context: Context | None = None,
- ) -> DenseIntElementsAttr: ...
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __getitem__(self, arg0: int) -> int: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- @property
- def static_typeid(self) -> TypeID: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class DenseResourceElementsAttr(Attribute):
- @staticmethod
- def get_from_buffer(
- array: Buffer,
- name: str,
- type: Type,
- alignment: int | None = None,
- is_mutable: bool = False,
- context: Context | None = None,
- ) -> DenseResourceElementsAttr:
- """
- Gets a DenseResourceElementsAttr from a Python buffer or array.
-
- This function does minimal validation or massaging of the data, and it is
- up to the caller to ensure that the buffer meets the characteristics
- implied by the shape.
-
- The backing buffer and any user objects will be retained for the lifetime
- of the resource blob. This is typically bounded to the context but the
- resource can have a shorter lifespan depending on how it is used in
- subsequent processing.
-
- Args:
- buffer: The array or buffer to convert.
- name: Name to provide to the resource (may be changed upon collision).
- type: The explicit ShapedType to construct the attribute with.
- context: Explicit context, if not from context manager.
-
- Returns:
- DenseResourceElementsAttr on success.
-
- Raises:
- ValueError: If the type of the buffer or array cannot be matched to an MLIR
- type or if the buffer does not meet expectations.
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- @property
- def static_typeid(self) -> TypeID: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class Diagnostic:
- @property
- def location(self) -> Location: ...
- @property
- def message(self) -> str: ...
- @property
- def notes(self) -> tuple[Diagnostic]: ...
- @property
- def severity(self) -> DiagnosticSeverity: ...
-
-class DiagnosticHandler:
- def __enter__(self) -> DiagnosticHandler: ...
- def __exit__(self, arg0: object, arg1: object, arg2: object) -> None: ...
- def detach(self) -> None: ...
- @property
- def attached(self) -> bool: ...
- @property
- def had_error(self) -> bool: ...
-
-class DiagnosticInfo:
- def __init__(self, arg0: Diagnostic) -> None: ...
- @property
- def location(self) -> Location: ...
- @property
- def message(self) -> str: ...
- @property
- def notes(self) -> list[DiagnosticInfo]: ...
- @property
- def severity(self) -> DiagnosticSeverity: ...
-
-class DiagnosticSeverity:
- """
- Members:
-
- ERROR
-
- WARNING
-
- NOTE
-
- REMARK
- """
-
- ERROR: ClassVar[DiagnosticSeverity] # value = <DiagnosticSeverity.ERROR: 0>
- NOTE: ClassVar[DiagnosticSeverity] # value = <DiagnosticSeverity.NOTE: 2>
- REMARK: ClassVar[DiagnosticSeverity] # value = <DiagnosticSeverity.REMARK: 3>
- WARNING: ClassVar[DiagnosticSeverity] # value = <DiagnosticSeverity.WARNING: 1>
- __members__: ClassVar[
- dict[str, DiagnosticSeverity]
- ] # value = {'ERROR': <DiagnosticSeverity.ERROR: 0>, 'WARNING': <DiagnosticSeverity.WARNING: 1>, 'NOTE': <DiagnosticSeverity.NOTE: 2>, 'REMARK': <DiagnosticSeverity.REMARK: 3>}
- def __eq__(self, other: Any) -> bool: ...
- def __getstate__(self) -> int: ...
- def __hash__(self) -> int: ...
- def __index__(self) -> int: ...
- def __init__(self, value: int) -> None: ...
- def __int__(self) -> int: ...
- def __ne__(self, other: Any) -> bool: ...
- def __setstate__(self, state: int) -> None: ...
- @property
- def name(self) -> str: ...
- @property
- def value(self) -> int: ...
-
-class Dialect:
- def __init__(self, descriptor: DialectDescriptor) -> None: ...
- @property
- def descriptor(self) -> DialectDescriptor: ...
-
-class DialectDescriptor:
- @property
- def namespace(self) -> str: ...
-
-class DialectRegistry:
- def _CAPICreate(self) -> DialectRegistry: ...
- def __init__(self) -> None: ...
- @property
- def _CAPIPtr(self) -> object: ...
-
-class Dialects:
- def __getattr__(self, arg0: str) -> Dialect: ...
- def __getitem__(self, arg0: str) -> Dialect: ...
-
-class DictAttr(Attribute):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(value: dict = {}, context: Context | None = None) -> DictAttr:
- """
- Gets an uniqued Dict attribute
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __contains__(self, arg0: str) -> bool: ...
- @overload
- def __getitem__(self, arg0: str) -> Attribute: ...
- @overload
- def __getitem__(self, arg0: int) -> NamedAttribute: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- def __len__(self) -> int: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class FloatType(Type):
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def width(self) -> int:
- """
- Returns the width of the floating-point type.
- """
-
-class F16Type(FloatType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> F16Type:
- """
- Create a f16 type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class F32Type(FloatType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> F32Type:
- """
- Create a f32 type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class F64Type(FloatType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> F64Type:
- """
- Create a f64 type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class FlatSymbolRefAttr(Attribute):
- @staticmethod
- def get(value: str, context: Context | None = None) -> FlatSymbolRefAttr:
- """
- Gets a uniqued FlatSymbolRef attribute
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- @property
- def static_typeid(self) -> TypeID: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
- @property
- def value(self) -> str:
- """
- Returns the value of the FlatSymbolRef attribute as a string
- """
-
-class Float4E2M1FNType(FloatType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> Float4E2M1FNType:
- """
- Create a float4_e2m1fn type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class Float6E2M3FNType(FloatType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> Float6E2M3FNType:
- """
- Create a float6_e2m3fn type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class Float6E3M2FNType(FloatType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> Float6E3M2FNType:
- """
- Create a float6_e3m2fn type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class Float8E3M4Type(FloatType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> Float8E3M4Type:
- """
- Create a float8_e3m4 type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class Float8E4M3B11FNUZType(FloatType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> Float8E4M3B11FNUZType:
- """
- Create a float8_e4m3b11fnuz type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class Float8E4M3FNType(FloatType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> Float8E4M3FNType:
- """
- Create a float8_e4m3fn type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class Float8E4M3FNUZType(FloatType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> Float8E4M3FNUZType:
- """
- Create a float8_e4m3fnuz type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class Float8E4M3Type(FloatType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> Float8E4M3Type:
- """
- Create a float8_e4m3 type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class Float8E5M2FNUZType(FloatType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> Float8E5M2FNUZType:
- """
- Create a float8_e5m2fnuz type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class Float8E5M2Type(FloatType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> Float8E5M2Type:
- """
- Create a float8_e5m2 type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class Float8E8M0FNUType(FloatType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> Float8E8M0FNUType:
- """
- Create a float8_e8m0fnu type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class FloatAttr(Attribute):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(type: Type, value: float, loc: Location | None = None) -> FloatAttr:
- """
- Gets an uniqued float point attribute associated to a type
- """
- @staticmethod
- def get_f32(value: float, context: Context | None = None) -> FloatAttr:
- """
- Gets an uniqued float point attribute associated to a f32 type
- """
- @staticmethod
- def get_f64(value: float, context: Context | None = None) -> FloatAttr:
- """
- Gets an uniqued float point attribute associated to a f64 type
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __float__(self: Attribute) -> float:
- """
- Converts the value of the float attribute to a Python float
- """
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
- @property
- def value(self) -> float:
- """
- Returns the value of the float attribute
- """
-
-class FloatTF32Type(FloatType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> FloatTF32Type:
- """
- Create a tf32 type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class FunctionType(Type):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(
- inputs: list[Type], results: list[Type], context: Context | None = None
- ) -> FunctionType:
- """
- Gets a FunctionType from a List of input and result types
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def inputs(self) -> list:
- """
- Returns the List of input types in the FunctionType.
- """
- @property
- def results(self) -> list:
- """
- Returns the List of result types in the FunctionType.
- """
- @property
- def typeid(self) -> TypeID: ...
-
-class IndexType(Type):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> IndexType:
- """
- Create a index type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class InferShapedTypeOpInterface:
- def __init__(self, object: object, context: Context | None = None) -> None:
- """
- Creates an interface from a given operation/opview object or from a
- subclass of OpView. Raises ValueError if the operation does not implement the
- interface.
- """
- def inferReturnTypeComponents(
- self,
- operands: list | None = None,
- attributes: Attribute | None = None,
- properties=None,
- regions: list[Region] | None = None,
- context: Context | None = None,
- loc: Location | None = None,
- ) -> list[ShapedTypeComponents]:
- """
- Given the arguments required to build an operation, attempts to infer
- its return shaped type components. Raises ValueError on failure.
- """
- @property
- def operation(self) -> Operation:
- """
- Returns an Operation for which the interface was constructed.
- """
- @property
- def opview(self) -> OpView:
- """
- Returns an OpView subclass _instance_ for which the interface was
- constructed
- """
-
-class InferTypeOpInterface:
- def __init__(self, object: object, context: Context | None = None) -> None:
- """
- Creates an interface from a given operation/opview object or from a
- subclass of OpView. Raises ValueError if the operation does not implement the
- interface.
- """
- def inferReturnTypes(
- self,
- operands: list | None = None,
- attributes: Attribute | None = None,
- properties=None,
- regions: list[Region] | None = None,
- context: Context | None = None,
- loc: Location | None = None,
- ) -> list[Type]:
- """
- Given the arguments required to build an operation, attempts to infer
- its return types. Raises ValueError on failure.
- """
- @property
- def operation(self) -> Operation:
- """
- Returns an Operation for which the interface was constructed.
- """
- @property
- def opview(self) -> OpView:
- """
- Returns an OpView subclass _instance_ for which the interface was
- constructed
- """
-
-class InsertionPoint:
- current: ClassVar[InsertionPoint] = ... # read-only
- @staticmethod
- def at_block_begin(block: Block) -> InsertionPoint:
- """
- Inserts at the beginning of the block.
- """
- @staticmethod
- def at_block_terminator(block: Block) -> InsertionPoint:
- """
- Inserts before the block terminator.
- """
- def __enter__(self) -> InsertionPoint: ...
- def __exit__(self, arg0: Any, arg1: Any, arg2: Any) -> None: ...
- @overload
- def __init__(self, block: Block) -> None:
- """
- Inserts after the last operation but still inside the block.
- """
- @overload
- def __init__(self, beforeOperation: _OperationBase) -> None:
- """
- Inserts before a referenced operation.
- """
- def insert(self, operation: _OperationBase) -> None:
- """
- Inserts an operation.
- """
- @property
- def block(self) -> Block:
- """
- Returns the block that this InsertionPoint points to.
- """
- @property
- def ref_operation(self) -> _OperationBase | None:
- """
- The reference operation before which new operations are inserted, or None if the insertion point is at the end of the block
- """
-
-class IntegerAttr(Attribute):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(type: Type, value: int) -> IntegerAttr:
- """
- Gets an uniqued integer attribute associated to a type
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- def __int__(self) -> int:
- """
- Converts the value of the integer attribute to a Python int
- """
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
- @property
- def value(self) -> int:
- """
- Returns the value of the integer attribute
- """
-
-class IntegerSet:
- @staticmethod
- def get(
- num_dims: int,
- num_symbols: int,
- exprs: list,
- eq_flags: list[bool],
- context: Context | None = None,
- ) -> IntegerSet: ...
- @staticmethod
- def get_empty(
- num_dims: int, num_symbols: int, context: Context | None = None
- ) -> IntegerSet: ...
- def _CAPICreate(self) -> IntegerSet: ...
- @overload
- def __eq__(self, arg0: IntegerSet) -> bool: ...
- @overload
- def __eq__(self, arg0: object) -> bool: ...
- def __hash__(self) -> int: ...
- def dump(self) -> None:
- """
- Dumps a debug representation of the object to stderr.
- """
- def get_replaced(
- self,
- dim_exprs: list,
- symbol_exprs: list,
- num_result_dims: int,
- num_result_symbols: int,
- ) -> IntegerSet: ...
- @property
- def _CAPIPtr(self) -> object: ...
- @property
- def constraints(self) -> IntegerSetConstraintList: ...
- @property
- def context(self) -> Context: ...
- @property
- def is_canonical_empty(self) -> bool: ...
- @property
- def n_dims(self) -> int: ...
- @property
- def n_equalities(self) -> int: ...
- @property
- def n_inequalities(self) -> int: ...
- @property
- def n_inputs(self) -> int: ...
- @property
- def n_symbols(self) -> int: ...
-
-class IntegerSetAttr(Attribute):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(integer_set) -> IntegerSetAttr:
- """
- Gets an attribute wrapping an IntegerSet.
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class IntegerSetConstraint:
- def __init__(self, *args, **kwargs) -> None: ...
- @property
- def expr(self) -> AffineExpr: ...
- @property
- def is_eq(self) -> bool: ...
-
-class IntegerSetConstraintList:
- def __init__(self, *args, **kwargs) -> None: ...
- def __add__(self, arg0: IntegerSetConstraintList) -> list[IntegerSetConstraint]: ...
- @overload
- def __getitem__(self, arg0: int) -> IntegerSetConstraint: ...
- @overload
- def __getitem__(self, arg0: slice) -> IntegerSetConstraintList: ...
- def __len__(self) -> int: ...
-
-class IntegerType(Type):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get_signed(width: int, context: Context | None = None) -> IntegerType:
- """
- Create a signed integer type
- """
- @staticmethod
- def get_signless(width: int, context: Context | None = None) -> IntegerType:
- """
- Create a signless integer type
- """
- @staticmethod
- def get_unsigned(width: int, context: Context | None = None) -> IntegerType:
- """
- Create an unsigned integer type
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def is_signed(self) -> bool:
- """
- Returns whether this is a signed integer
- """
- @property
- def is_signless(self) -> bool:
- """
- Returns whether this is a signless integer
- """
- @property
- def is_unsigned(self) -> bool:
- """
- Returns whether this is an unsigned integer
- """
- @property
- def typeid(self) -> TypeID: ...
- @property
- def width(self) -> int:
- """
- Returns the width of the integer type
- """
-
-class Location:
- current: ClassVar[Location] = ... # read-only
- __hash__: ClassVar[None] = None
- @staticmethod
- def callsite(
- callee: Location, frames: Sequence[Location], context: Context | None = None
- ) -> Location:
- """
- Gets a Location representing a caller and callsite
- """
- @staticmethod
- def file(
- filename: str, line: int, col: int, context: Context | None = None
- ) -> Location:
- """
- Gets a Location representing a file, line and column
- """
- @staticmethod
- def from_attr(attribute: Attribute, context: Context | None = None) -> Location:
- """
- Gets a Location from a LocationAttr
- """
- @staticmethod
- def fused(
- locations: Sequence[Location],
- metadata: Attribute | None = None,
- context: Context | None = None,
- ) -> Location:
- """
- Gets a Location representing a fused location with optional metadata
- """
- @staticmethod
- def name(
- name: str,
- childLoc: Location | None = None,
- context: Context | None = None,
- ) -> Location:
- """
- Gets a Location representing a named location with optional child location
- """
- @staticmethod
- def unknown(context: Context | None = None) -> Location:
- """
- Gets a Location representing an unknown location
- """
- def _CAPICreate(self) -> Location: ...
- def __enter__(self) -> Location: ...
- @overload
- def __eq__(self, arg0: Location) -> bool: ...
- @overload
- def __eq__(self, arg0: Location) -> bool: ...
- def __exit__(self, arg0: object, arg1: object, arg2: object) -> None: ...
- def emit_error(self, message: str) -> None:
- """
- Emits an error at this location
- """
- @property
- def _CAPIPtr(self) -> object: ...
- @property
- def attr(self) -> Attribute:
- """
- Get the underlying LocationAttr
- """
- @property
- def context(self) -> Context:
- """
- Context that owns the Location
- """
-
-class MemRefType(ShapedType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(
- shape: list[int],
- element_type: Type,
- layout: Attribute = None,
- memory_space: Attribute = None,
- loc: Location | None = None,
- ) -> MemRefType:
- """
- Create a memref type
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def affine_map(self) -> AffineMap:
- """
- The layout of the MemRef type as an affine map.
- """
- @property
- def layout(self) -> Attribute:
- """
- The layout of the MemRef type.
- """
- @property
- def memory_space(self) -> Attribute | None:
- """
- Returns the memory space of the given MemRef type.
- """
- @property
- def typeid(self) -> TypeID: ...
- def get_strides_and_offset(self) -> tuple[list[int], int]:
- """
- The strides and offset of the MemRef type.
- """
-
-class Module:
- @staticmethod
- def create(loc: Location | None = None) -> Module:
- """
- Creates an empty module
- """
- @staticmethod
- def parse(asm: str | bytes, context: Context | None = None) -> Module:
- """
- Parses a module's assembly format from a string.
-
- Returns a new MlirModule or raises an MLIRError if the parsing fails.
-
- See also: https://mlir.llvm.org/docs/LangRef/
- """
- @staticmethod
- def parseFile(path: str, context: Context | None = None) -> Module:
- """
- Parses a module's assembly format from file.
-
- Returns a new MlirModule or raises an MLIRError if the parsing fails.
-
- See also: https://mlir.llvm.org/docs/LangRef/
- """
- def _CAPICreate(self) -> Any: ...
- def __str__(self) -> str:
- """
- Gets the assembly form of the operation with default options.
-
- If more advanced control over the assembly formatting or I/O options is needed,
- use the dedicated print or get_asm method, which supports keyword arguments to
- customize behavior.
- """
- def dump(self) -> None:
- """
- Dumps a debug representation of the object to stderr.
- """
- @property
- def _CAPIPtr(self) -> object: ...
- @property
- def body(self) -> Block:
- """
- Return the block for this module
- """
- @property
- def context(self) -> Context:
- """
- Context that created the Module
- """
- @property
- def operation(self) -> Operation:
- """
- Accesses the module as an operation
- """
-
-class MLIRError(Exception):
- def __init__(
- self, message: str, error_diagnostics: list[DiagnosticInfo]
- ) -> None: ...
-
-class NamedAttribute:
- @property
- def attr(self) -> Attribute:
- """
- The underlying generic attribute of the NamedAttribute binding
- """
- @property
- def name(self) -> str:
- """
- The name of the NamedAttribute binding
- """
-
-class NoneType(Type):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> NoneType:
- """
- Create a none type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class OpAttributeMap:
- def __contains__(self, arg0: str) -> bool: ...
- def __delitem__(self, arg0: str) -> None: ...
- @overload
- def __getitem__(self, arg0: str) -> Attribute: ...
- @overload
- def __getitem__(self, arg0: int) -> NamedAttribute: ...
- def __len__(self) -> int: ...
- def __setitem__(self, arg0: str, arg1: Attribute) -> None: ...
-
-class OpOperand:
- @property
- def operand_number(self) -> int: ...
- @property
- def owner(self) -> _OperationBase: ...
-
-class OpOperandIterator:
- def __iter__(self) -> OpOperandIterator: ...
- def __next__(self) -> OpOperand: ...
-
-class OpOperandList:
- def __add__(self, arg0: OpOperandList) -> list[Value]: ...
- @overload
- def __getitem__(self, arg0: int) -> Value: ...
- @overload
- def __getitem__(self, arg0: slice) -> OpOperandList: ...
- def __len__(self) -> int: ...
- def __setitem__(self, arg0: int, arg1: Value) -> None: ...
-
-class OpResult(Value):
- @staticmethod
- def isinstance(other_value: Value) -> bool: ...
- def __init__(self, value: Value) -> None: ...
- @staticmethod
- def isinstance(arg: Any) -> bool: ...
- @property
- def owner(self) -> _OperationBase: ...
- @property
- def result_number(self) -> int: ...
-
-class OpResultList:
- def __add__(self, arg0: OpResultList) -> list[OpResult]: ...
- @overload
- def __getitem__(self, arg0: int) -> OpResult: ...
- @overload
- def __getitem__(self, arg0: slice) -> OpResultList: ...
- def __len__(self) -> int: ...
- @property
- def owner(self) -> _OperationBase: ...
- @property
- def types(self) -> list[Type]: ...
-
-class OpSuccessors:
- def __add__(self, arg0: OpSuccessors) -> list[Block]: ...
- @overload
- def __getitem__(self, arg0: int) -> Block: ...
- @overload
- def __getitem__(self, arg0: slice) -> OpSuccessors: ...
- def __setitem__(self, arg0: int, arg1: Block) -> None: ...
- def __len__(self) -> int: ...
-
-class OpView(_OperationBase):
- _ODS_OPERAND_SEGMENTS: ClassVar[None] = ...
- _ODS_REGIONS: ClassVar[tuple] = ...
- _ODS_RESULT_SEGMENTS: ClassVar[None] = ...
- def __init__(self, operation: _OperationBase) -> None: ...
- @classmethod
- def build_generic(
- cls: type[_TOperation],
- results: Sequence[Type] | None = None,
- operands: Sequence[Value] | None = None,
- attributes: dict[str, Attribute] | None = None,
- successors: Sequence[Block] | None = None,
- regions: int | None = None,
- loc: Location | None = None,
- ip: InsertionPoint | None = None,
- ) -> _TOperation:
- """
- Builds a specific, generated OpView based on class level attributes.
- """
- @classmethod
- def parse(
- cls: type[_TOperation],
- source: str | bytes,
- *,
- source_name: str = "",
- context: Context | None = None,
- ) -> _TOperation:
- """
- Parses a specific, generated OpView based on class level attributes
- """
- def __init__(self, operation: _OperationBase) -> None: ...
- @property
- def operation(self) -> _OperationBase: ...
- @property
- def opview(self) -> OpView: ...
- @property
- def successors(self) -> OpSuccessors:
- """
- Returns the List of Operation successors.
- """
-
-class OpaqueAttr(Attribute):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(
- dialect_namespace: str,
- buffer: Buffer,
- type: Type,
- context: Context | None = None,
- ) -> OpaqueAttr:
- """
- Gets an Opaque attribute.
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- @property
- def data(self) -> bytes:
- """
- Returns the data for the Opaqued attributes as `bytes`
- """
- @property
- def dialect_namespace(self) -> str:
- """
- Returns the dialect namespace for the Opaque attribute as a string
- """
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class OpaqueType(Type):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(
- dialect_namespace: str, buffer: str, context: Context | None = None
- ) -> OpaqueType:
- """
- Create an unregistered (opaque) dialect type.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def data(self) -> str:
- """
- Returns the data for the Opaque type as a string.
- """
- @property
- def dialect_namespace(self) -> str:
- """
- Returns the dialect namespace for the Opaque type as a string.
- """
- @property
- def typeid(self) -> TypeID: ...
-
-class Operation(_OperationBase):
- def _CAPICreate(self) -> object: ...
- @staticmethod
- def create(
- name: str,
- results: Sequence[Type] | None = None,
- operands: Sequence[Value] | None = None,
- attributes: dict[str, Attribute] | None = None,
- successors: Sequence[Block] | None = None,
- regions: int = 0,
- loc: Location | None = None,
- ip: InsertionPoint | None = None,
- infer_type: bool = False,
- ) -> Operation:
- """
- Creates a new operation.
-
- Args:
- name: Operation name (e.g. "dialect.operation").
- results: Sequence of Type representing op result types.
- attributes: Dict of str:Attribute.
- successors: List of Block for the operation's successors.
- regions: Number of regions to create.
- loc: A Location object (defaults to resolve from context manager).
- ip: An InsertionPoint (defaults to resolve from context manager or set to
- False to disable insertion, even with an insertion point set in the
- context manager).
- infer_type: Whether to infer result types.
- Returns:
- A new "detached" Operation object. Detached operations can be added
- to blocks, which causes them to become "attached."
- """
- @staticmethod
- def parse(
- source: str | bytes, *, source_name: str = "", context: Context | None = None
- ) -> Operation:
- """
- Parses an operation. Supports both text assembly format and binary bytecode format.
- """
- def _CAPICreate(self) -> object: ...
- @property
- def _CAPIPtr(self) -> object: ...
- @property
- def operation(self) -> Operation: ...
- @property
- def opview(self) -> OpView: ...
- @property
- def successors(self) -> OpSuccessors:
- """
- Returns the List of Operation successors.
- """
-
-class OperationIterator:
- def __iter__(self) -> OperationIterator: ...
- def __next__(self) -> OpView: ...
-
-class OperationList:
- def __getitem__(self, arg0: int) -> OpView: ...
- def __iter__(self) -> OperationIterator: ...
- def __len__(self) -> int: ...
-
-class RankedTensorType(ShapedType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(
- shape: list[int],
- element_type: Type,
- encoding: Attribute | None = None,
- loc: Location | None = None,
- ) -> RankedTensorType:
- """
- Create a ranked tensor type
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def encoding(self) -> Attribute | None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class Region:
- __hash__: ClassVar[None] = None
- @overload
- def __eq__(self, arg0: Region) -> bool: ...
- @overload
- def __eq__(self, arg0: object) -> bool: ...
- def __iter__(self) -> BlockIterator:
- """
- Iterates over blocks in the region.
- """
- @property
- def blocks(self) -> BlockList:
- """
- Returns a forward-optimized sequence of blocks.
- """
- @property
- def owner(self) -> OpView:
- """
- Returns the operation owning this region.
- """
-
-class RegionIterator:
- def __iter__(self) -> RegionIterator: ...
- def __next__(self) -> Region: ...
-
-class RegionSequence:
- @overload
- def __getitem__(self, arg0: int) -> Region: ...
- @overload
- def __getitem__(self, arg0: slice) -> Sequence[Region]: ...
- def __iter__(self) -> RegionIterator: ...
- def __len__(self) -> int: ...
-
-class ShapedType(Type):
- @staticmethod
- def get_dynamic_size() -> int:
- """
- Returns the value used to indicate dynamic dimensions in shaped types.
- """
- @staticmethod
- def get_dynamic_stride_or_offset() -> int:
- """
- Returns the value used to indicate dynamic strides or offsets in shaped types.
- """
- @staticmethod
- def is_dynamic_size(dim_size: int) -> bool:
- """
- Returns whether the given dimension size indicates a dynamic dimension.
- """
- @staticmethod
- def is_static_size(dim_size: int) -> bool:
- """
- Returns whether the given dimension size indicates a static dimension.
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- def get_dim_size(self, dim: int) -> int:
- """
- Returns the dim-th dimension of the given ranked shaped type.
- """
- def is_dynamic_dim(self, dim: int) -> bool:
- """
- Returns whether the dim-th dimension of the given shaped type is dynamic.
- """
- def is_static_dim(self, dim: int) -> bool:
- """
- Returns whether the dim-th dimension of the given shaped type is static.
- """
- def is_dynamic_stride_or_offset(self, dim_size: int) -> bool:
- """
- Returns whether the given value is used as a placeholder for dynamic strides and offsets in shaped types.
- """
- def is_static_stride_or_offset(self, dim_size: int) -> bool:
- """
- Returns whether the given shaped type stride or offset value is statically-sized.
- """
- @property
- def element_type(self) -> Type:
- """
- Returns the element type of the shaped type.
- """
- @property
- def has_rank(self) -> bool:
- """
- Returns whether the given shaped type is ranked.
- """
- @property
- def has_static_shape(self) -> bool:
- """
- Returns whether the given shaped type has a static shape.
- """
- @property
- def rank(self) -> int:
- """
- Returns the rank of the given ranked shaped type.
- """
- @property
- def shape(self) -> list[int]:
- """
- Returns the shape of the ranked shaped type as a List of integers.
- """
- @property
- def static_typeid(self) -> TypeID: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class ShapedTypeComponents:
- @staticmethod
- @overload
- def get(element_type: Type) -> ShapedTypeComponents:
- """
- Create an shaped type components object with only the element type.
- """
- @staticmethod
- @overload
- def get(shape: list, element_type: Type) -> ShapedTypeComponents:
- """
- Create a ranked shaped type components object.
- """
- @staticmethod
- @overload
- def get(
- shape: list, element_type: Type, attribute: Attribute
- ) -> ShapedTypeComponents:
- """
- Create a ranked shaped type components object with attribute.
- """
- @property
- def element_type(self) -> Type:
- """
- Returns the element type of the shaped type components.
- """
- @property
- def has_rank(self) -> bool:
- """
- Returns whether the given shaped type component is ranked.
- """
- @property
- def rank(self) -> int:
- """
- Returns the rank of the given ranked shaped type components. If the shaped type components does not have a rank, None is returned.
- """
- @property
- def shape(self) -> list[int]:
- """
- Returns the shape of the ranked shaped type components as a List of integers. Returns none if the shaped type component does not have a rank.
- """
-
-class StridedLayoutAttr(Attribute):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(
- offset: int, strides: list[int], context: Context | None = None
- ) -> StridedLayoutAttr:
- """
- Gets a strided layout attribute.
- """
- @staticmethod
- def get_fully_dynamic(
- rank: int, context: Context | None = None
- ) -> StridedLayoutAttr:
- """
- Gets a strided layout attribute with dynamic offset and strides of a given rank.
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- @property
- def offset(self) -> int:
- """
- Returns the value of the float point attribute
- """
- @property
- def strides(self) -> list[int]:
- """
- Returns the value of the float point attribute
- """
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class StringAttr(Attribute):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(value: str | bytes, context: Context | None = None) -> StringAttr:
- """
- Gets a uniqued string attribute
- """
- @staticmethod
- def get_typed(type: Type, value: str) -> StringAttr:
- """
- Gets a uniqued string attribute associated to a type
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
- @property
- def value(self) -> str:
- """
- Returns the value of the string attribute
- """
- @property
- def value_bytes(self) -> bytes:
- """
- Returns the value of the string attribute as `bytes`
- """
-
-class SymbolRefAttr(Attribute):
- @staticmethod
- def get(symbols: list[str], context: Context | None = None) -> Attribute:
- """
- Gets a uniqued SymbolRef attribute from a List of symbol names
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- @property
- def static_typeid(self) -> TypeID: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
- @property
- def value(self) -> list[str]:
- """
- Returns the value of the SymbolRef attribute as a List[str]
- """
-
-class SymbolTable:
- @staticmethod
- def get_symbol_name(symbol: _OperationBase) -> Attribute: ...
- @staticmethod
- def get_visibility(symbol: _OperationBase) -> Attribute: ...
- @staticmethod
- def replace_all_symbol_uses(
- old_symbol: str, new_symbol: str, from_op: _OperationBase
- ) -> None: ...
- @staticmethod
- def set_symbol_name(symbol: _OperationBase, name: str) -> None: ...
- @staticmethod
- def set_visibility(symbol: _OperationBase, visibility: str) -> None: ...
- @staticmethod
- def walk_symbol_tables(
- from_op: _OperationBase,
- all_sym_uses_visible: bool,
- callback: Callable[[_OperationBase, bool], None],
- ) -> None: ...
- def __contains__(self, arg0: str) -> bool: ...
- def __delitem__(self, arg0: str) -> None: ...
- def __getitem__(self, arg0: str) -> OpView: ...
- def __init__(self, arg0: _OperationBase) -> None: ...
- def erase(self, operation: _OperationBase) -> None: ...
- def insert(self, operation: _OperationBase) -> Attribute: ...
-
-class TupleType(Type):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get_tuple(elements: list[Type], context: Context | None = None) -> TupleType:
- """
- Create a Tuple type
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- def get_type(self, pos: int) -> Type:
- """
- Returns the pos-th type in the Tuple type.
- """
- @property
- def num_types(self) -> int:
- """
- Returns the number of types contained in a Tuple.
- """
- @property
- def typeid(self) -> TypeID: ...
-
-class TypeAttr(Attribute):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(value: Type, context: Context | None = None) -> TypeAttr:
- """
- Gets a uniqued Type attribute
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
- @property
- def value(self) -> Type: ...
-
-class TypeID:
- def _CAPICreate(self) -> TypeID: ...
- @overload
- def __eq__(self, arg0: TypeID) -> bool: ...
- @overload
- def __eq__(self, arg0: Any) -> bool: ...
- def __hash__(self) -> int: ...
- @property
- def _CAPIPtr(self) -> object: ...
-
-class UnitAttr(Attribute):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(context: Context | None = None) -> UnitAttr:
- """
- Create a Unit attribute.
- """
- @staticmethod
- def isinstance(other: Attribute) -> bool: ...
- def __init__(self, cast_from_attr: Attribute) -> None: ...
- @property
- def type(self) -> Type: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class UnrankedMemRefType(ShapedType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(
- element_type: Type, memory_space: Attribute, loc: Location | None = None
- ) -> UnrankedMemRefType:
- """
- Create a unranked memref type
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def memory_space(self) -> Attribute | None:
- """
- Returns the memory space of the given Unranked MemRef type.
- """
- @property
- def typeid(self) -> TypeID: ...
-
-class UnrankedTensorType(ShapedType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(element_type: Type, loc: Location | None = None) -> UnrankedTensorType:
- """
- Create a unranked tensor type
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class VectorType(ShapedType):
- static_typeid: ClassVar[TypeID]
- @staticmethod
- def get(
- shape: list[int],
- element_type: Type,
- *,
- scalable: list | None = None,
- scalable_dims: list[int] | None = None,
- loc: Location | None = None,
- ) -> VectorType:
- """
- Create a vector type
- """
- @staticmethod
- def isinstance(other: Type) -> bool: ...
- def __init__(self, cast_from_type: Type) -> None: ...
- @property
- def scalable(self) -> bool: ...
- @property
- def scalable_dims(self) -> list[bool]: ...
- @property
- def typeid(self) -> TypeID: ...
-
-class _GlobalDebug:
- flag: ClassVar[bool] = False
diff --git a/mlir/python/mlir/_mlir_libs/_mlir/passmanager.pyi b/mlir/python/mlir/_mlir_libs/_mlir/passmanager.pyi
deleted file mode 100644
index 1010daddae2aa..0000000000000
--- a/mlir/python/mlir/_mlir_libs/_mlir/passmanager.pyi
+++ /dev/null
@@ -1,36 +0,0 @@
-# Originally imported via:
-# stubgen {...} -m mlir._mlir_libs._mlir.passmanager
-# Local modifications:
-# * Relative imports for cross-module references.
-# * Add __all__
-
-
-from . import ir as _ir
-
-__all__ = [
- "PassManager",
-]
-
-class PassManager:
- def __init__(self, context: _ir.Context | None = None) -> None: ...
- def _CAPICreate(self) -> object: ...
- def _testing_release(self) -> None: ...
- def enable_ir_printing(
- self,
- print_before_all: bool = False,
- print_after_all: bool = True,
- print_module_scope: bool = False,
- print_after_change: bool = False,
- print_after_failure: bool = False,
- large_elements_limit: int | None = None,
- large_resource_limit: int | None = None,
- enable_debug_info: bool = False,
- print_generic_op_form: bool = False,
- tree_printing_dir_path: str | None = None,
- ) -> None: ...
- def enable_verifier(self, enable: bool) -> None: ...
- @staticmethod
- def parse(pipeline: str, context: _ir.Context | None = None) -> PassManager: ...
- def run(self, module: _ir._OperationBase) -> None: ...
- @property
- def _CAPIPtr(self) -> object: ...
diff --git a/mlir/python/mlir/_mlir_libs/_mlirExecutionEngine.pyi b/mlir/python/mlir/_mlir_libs/_mlirExecutionEngine.pyi
deleted file mode 100644
index 4b82c78489295..0000000000000
--- a/mlir/python/mlir/_mlir_libs/_mlirExecutionEngine.pyi
+++ /dev/null
@@ -1,24 +0,0 @@
-# Originally imported via:
-# stubgen {...} -m mlir._mlir_libs._mlirExecutionEngine
-# Local modifications:
-# * Relative imports for cross-module references.
-# * Add __all__
-
-from collections.abc import Sequence
-
-from ._mlir import ir as _ir
-
-__all__ = [
- "ExecutionEngine",
-]
-
-class ExecutionEngine:
- def __init__(self, module: _ir.Module, opt_level: int = 2, shared_libs: Sequence[str] = ...) -> None: ...
- def _CAPICreate(self) -> object: ...
- def _testing_release(self) -> None: ...
- def dump_to_object_file(self, file_name: str) -> None: ...
- def raw_lookup(self, func_name: str) -> int: ...
- def raw_register_runtime(self, name: str, callback: object) -> None: ...
- def init() -> None: ...
- @property
- def _CAPIPtr(self) -> object: ...
diff --git a/mlir/python/requirements.txt b/mlir/python/requirements.txt
index 1a0075e829aef..8fe75a117a973 100644
--- a/mlir/python/requirements.txt
+++ b/mlir/python/requirements.txt
@@ -1,4 +1,4 @@
-nanobind>=2.4, <3.0
+nanobind @ git+https://github.com/wjakob/nanobind@53dce4e
numpy>=1.19.5, <=2.1.2
pybind11>=2.10.0, <=2.13.6
PyYAML>=5.4.0, <=6.0.1
>From a288be5dca65100999d9022d8285070914dd557a Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Thu, 28 Aug 2025 02:41:44 -0400
Subject: [PATCH 02/11] Update requirements.txt
---
mlir/python/requirements.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mlir/python/requirements.txt b/mlir/python/requirements.txt
index 8fe75a117a973..a0b2c3736b214 100644
--- a/mlir/python/requirements.txt
+++ b/mlir/python/requirements.txt
@@ -1,6 +1,6 @@
-nanobind @ git+https://github.com/wjakob/nanobind@53dce4e
+nanobind @ git+https://github.com/wjakob/nanobind
numpy>=1.19.5, <=2.1.2
pybind11>=2.10.0, <=2.13.6
PyYAML>=5.4.0, <=6.0.1
ml_dtypes>=0.1.0, <=0.6.0; python_version<"3.13" # provides several NumPy dtype extensions, including the bf16
-ml_dtypes>=0.5.0, <=0.6.0; python_version>="3.13"
\ No newline at end of file
+ml_dtypes>=0.5.0, <=0.6.0; python_version>="3.13"
>From c23ac1b2f286273eea444a4fa53f38779031d5ba Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Thu, 28 Aug 2025 03:01:15 -0400
Subject: [PATCH 03/11] Update all_requirements.txt
---
.ci/all_requirements.txt | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/.ci/all_requirements.txt b/.ci/all_requirements.txt
index f73500efdc7e0..4a203444c404c 100644
--- a/.ci/all_requirements.txt
+++ b/.ci/all_requirements.txt
@@ -34,9 +34,7 @@ ml-dtypes==0.5.1 ; python_version < "3.13" \
--hash=sha256:d13755f8e8445b3870114e5b6240facaa7cb0c3361e54beba3e07fa912a6e12b \
--hash=sha256:fd918d4e6a4e0c110e2e05be7a7814d10dc1b95872accbf6512b80a109b71ae1
# via -r ./mlir/python/requirements.txt
-nanobind==2.7.0 \
- --hash=sha256:73b12d0e751d140d6c1bf4b215e18818a8debfdb374f08dc3776ad208d808e74 \
- --hash=sha256:f9f1b160580c50dcf37b6495a0fd5ec61dc0d95dae5f8004f87dd9ad7eb46b34
+nanobind @ git+https://github.com/wjakob/nanobind
# via -r ./mlir/python/requirements.txt
numpy==2.0.2 \
--hash=sha256:0123ffdaa88fa4ab64835dcbde75dcdf89c453c922f18dced6e27c90d1d0ec5a \
>From e1f1f5f43b225599c0d218bd750fe1f114949e80 Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Thu, 28 Aug 2025 03:11:17 -0400
Subject: [PATCH 04/11] Update monolithic-linux.sh
---
.ci/monolithic-linux.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/.ci/monolithic-linux.sh b/.ci/monolithic-linux.sh
index 3ca4d05f4c891..4063819397db3 100755
--- a/.ci/monolithic-linux.sh
+++ b/.ci/monolithic-linux.sh
@@ -34,6 +34,7 @@ lit_args="-v --xunit-xml-output ${BUILD_DIR}/test-results.xml --use-unique-outpu
start-group "CMake"
export PIP_BREAK_SYSTEM_PACKAGES=1
pip install -q -r "${MONOREPO_ROOT}"/.ci/all_requirements.txt
+pip install "nanobind @ git+https://github.com/wjakob/nanobind"
# Set the system llvm-symbolizer as preferred.
export LLVM_SYMBOLIZER_PATH=`which llvm-symbolizer`
>From debc3aa8e9bda13b65ce840c3d658056b7c4838f Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Thu, 28 Aug 2025 03:12:00 -0400
Subject: [PATCH 05/11] Update monolithic-windows.sh
---
.ci/monolithic-windows.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/.ci/monolithic-windows.sh b/.ci/monolithic-windows.sh
index 0f3a1994a0497..097cd770055cf 100755
--- a/.ci/monolithic-windows.sh
+++ b/.ci/monolithic-windows.sh
@@ -20,6 +20,7 @@ targets="${2}"
start-group "CMake"
pip install -q -r "${MONOREPO_ROOT}"/.ci/all_requirements.txt
+pip install "nanobind @ git+https://github.com/wjakob/nanobind"
export CC=cl
export CXX=cl
>From 497989fc3faaebe43c064b09d92eb74bc7617c4f Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Thu, 28 Aug 2025 08:09:43 -0400
Subject: [PATCH 06/11] Update AddMLIRPython.cmake
---
mlir/cmake/modules/AddMLIRPython.cmake | 13 ++++++++-----
mlir/examples/standalone/CMakeLists.txt | 2 ++
mlir/examples/standalone/python/CMakeLists.txt | 10 +++++-----
3 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake
index f0e36f85feabf..71ff59e9a264c 100644
--- a/mlir/cmake/modules/AddMLIRPython.cmake
+++ b/mlir/cmake/modules/AddMLIRPython.cmake
@@ -99,7 +99,7 @@ function(declare_mlir_python_sources name)
endif()
endfunction()
-function(generate_type_stubs module_name depends_target output_dir)
+function(generate_type_stubs module_name depends_target mlir_depends_target output_dir)
if(EXISTS ${nanobind_DIR}/../src/stubgen.py)
set(NB_STUBGEN "${nanobind_DIR}/../src/stubgen.py")
elseif(EXISTS ${nanobind_DIR}/../stubgen.py)
@@ -108,11 +108,12 @@ function(generate_type_stubs module_name depends_target output_dir)
message(FATAL_ERROR "generate_type_stubs(): could not locate 'stubgen.py'!")
endif()
+ set(_module "${MLIR_PYTHON_PACKAGE_PREFIX}._mlir_libs.${module_name}")
set(NB_STUBGEN_CMD
"${Python_EXECUTABLE}"
"${NB_STUBGEN}"
--module
- "${MLIR_PYTHON_PACKAGE_PREFIX}._mlir_libs.${module_name}"
+ "${_module}"
-i
"${MLIR_BINARY_DIR}/${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX}/.."
--recursive
@@ -125,8 +126,8 @@ function(generate_type_stubs module_name depends_target output_dir)
OUTPUT ${NB_STUBGEN_OUTPUT}
COMMAND ${NB_STUBGEN_CMD}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- DEPENDS ${depends_target})
- set(_name "MLIRPythonModuleStubs_${module_name}")
+ DEPENDS "${mlir_depends_target}" "${depends_target}")
+ set(_name "MLIRPythonModuleStubs_${_module}")
add_custom_target("${_name}" ALL DEPENDS ${NB_STUBGEN_OUTPUT})
set(NB_STUBGEN_CUSTOM_TARGET "${_name}" PARENT_SCOPE)
endfunction()
@@ -278,9 +279,11 @@ function(add_mlir_python_modules name)
generate_type_stubs(
${_module_name}
${_extension_target}
+ "${modules_target}.extension._mlir.dso"
"${CMAKE_CURRENT_SOURCE_DIR}/mlir/_mlir_libs/_mlir"
)
- declare_mlir_python_sources("_${_module_name}_type_stub_gen"
+ declare_mlir_python_sources(
+ "${MLIR_PYTHON_PACKAGE_PREFIX}.${_module_name}_type_stub_gen"
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"
ADD_TO_PARENT "${sources_target}"
SOURCES_GLOB "_mlir_libs/${_module_name}/**/*.pyi"
diff --git a/mlir/examples/standalone/CMakeLists.txt b/mlir/examples/standalone/CMakeLists.txt
index 42b487fe2d40f..e882eb431fe64 100644
--- a/mlir/examples/standalone/CMakeLists.txt
+++ b/mlir/examples/standalone/CMakeLists.txt
@@ -52,6 +52,8 @@ add_subdirectory(include)
add_subdirectory(lib)
if(MLIR_ENABLE_BINDINGS_PYTHON)
message(STATUS "Enabling Python API")
+ set(MLIR_PYTHON_PACKAGE_PREFIX "mlir_standalone" CACHE STRING "" FORCE)
+ set(MLIR_BINDINGS_PYTHON_INSTALL_PREFIX "python_packages/standalone/mlir_standalone" CACHE STRING "" FORCE)
add_subdirectory(python)
endif()
add_subdirectory(test)
diff --git a/mlir/examples/standalone/python/CMakeLists.txt b/mlir/examples/standalone/python/CMakeLists.txt
index c004452457eb9..89e03bc793c66 100644
--- a/mlir/examples/standalone/python/CMakeLists.txt
+++ b/mlir/examples/standalone/python/CMakeLists.txt
@@ -48,8 +48,8 @@ declare_mlir_python_extension(StandalonePythonSources.NanobindExtension
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"
+ INSTALL_DESTINATION "${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX}/_mlir_libs"
+ OUTPUT_DIRECTORY "${MLIR_BINARY_DIR}/${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX}/_mlir_libs"
RELATIVE_INSTALL_ROOT "../../../.."
DECLARED_SOURCES
StandalonePythonSources
@@ -64,14 +64,14 @@ add_mlir_python_common_capi_library(StandalonePythonCAPI
################################################################################
add_mlir_python_modules(StandalonePythonModules
- ROOT_PREFIX "${MLIR_BINARY_DIR}/python_packages/standalone/mlir_standalone"
- INSTALL_PREFIX "python_packages/standalone/mlir_standalone"
+ ROOT_PREFIX "${MLIR_BINARY_DIR}/${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX}"
+ INSTALL_PREFIX "${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX}"
DECLARED_SOURCES
StandalonePythonSources
# TODO: Remove this in favor of showing fine grained registration once
# available.
MLIRPythonExtension.RegisterEverything
- MLIRPythonSources
+ MLIRPythonSources.Core
COMMON_CAPI_LINK_LIBS
StandalonePythonCAPI
)
>From 7f1e69f5ddcc609d80cb2aaf183e336541a9c7e9 Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Thu, 28 Aug 2025 20:13:42 -0400
Subject: [PATCH 07/11] fix standalone
---
mlir/examples/standalone/CMakeLists.txt | 2 ++
mlir/test/Examples/standalone/test.toy | 3 ++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/mlir/examples/standalone/CMakeLists.txt b/mlir/examples/standalone/CMakeLists.txt
index e882eb431fe64..88dfa3e5d57a3 100644
--- a/mlir/examples/standalone/CMakeLists.txt
+++ b/mlir/examples/standalone/CMakeLists.txt
@@ -52,6 +52,8 @@ add_subdirectory(include)
add_subdirectory(lib)
if(MLIR_ENABLE_BINDINGS_PYTHON)
message(STATUS "Enabling Python API")
+ include(MLIRDetectPythonEnv)
+ mlir_configure_python_dev_packages()
set(MLIR_PYTHON_PACKAGE_PREFIX "mlir_standalone" CACHE STRING "" FORCE)
set(MLIR_BINDINGS_PYTHON_INSTALL_PREFIX "python_packages/standalone/mlir_standalone" CACHE STRING "" FORCE)
add_subdirectory(python)
diff --git a/mlir/test/Examples/standalone/test.toy b/mlir/test/Examples/standalone/test.toy
index c91b3cf8a50f2..5a0cdf81bfe0b 100644
--- a/mlir/test/Examples/standalone/test.toy
+++ b/mlir/test/Examples/standalone/test.toy
@@ -2,7 +2,8 @@
# RUN: -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc \
# RUN: -DLLVM_ENABLE_LIBCXX=%enable_libcxx -DMLIR_DIR=%mlir_cmake_dir \
# RUN: -DLLVM_USE_LINKER=%llvm_use_linker \
-# RUN: -DPython3_EXECUTABLE=%python
+# RUN: -DPython3_EXECUTABLE=%python \
+# RUN: -DPython_EXECUTABLE=%python
# RUN: "%cmake_exe" --build . --target check-standalone | tee %t | FileCheck %s
# Note: The number of checked tests is not important. The command will fail
>From da6d3b3a90298f64ae126ba38721b7ced69e41eb Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Thu, 28 Aug 2025 20:43:48 -0400
Subject: [PATCH 08/11] cat temp file
---
mlir/test/Examples/standalone/test.toy | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mlir/test/Examples/standalone/test.toy b/mlir/test/Examples/standalone/test.toy
index 5a0cdf81bfe0b..5d568941c7e6c 100644
--- a/mlir/test/Examples/standalone/test.toy
+++ b/mlir/test/Examples/standalone/test.toy
@@ -4,7 +4,7 @@
# RUN: -DLLVM_USE_LINKER=%llvm_use_linker \
# RUN: -DPython3_EXECUTABLE=%python \
# RUN: -DPython_EXECUTABLE=%python
-# RUN: "%cmake_exe" --build . --target check-standalone | tee %t | FileCheck %s
+# RUN: "%cmake_exe" --build . --target check-standalone | tee %t | FileCheck %s || cat %t && false
# Note: The number of checked tests is not important. The command will fail
# if any fail.
>From 8cff8f8f3ff1d517faec29909ccf8e26c4390553 Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Thu, 28 Aug 2025 21:26:41 -0400
Subject: [PATCH 09/11] add builtin
---
mlir/examples/standalone/python/CMakeLists.txt | 2 ++
mlir/test/Examples/standalone/test.toy | 4 +++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/mlir/examples/standalone/python/CMakeLists.txt b/mlir/examples/standalone/python/CMakeLists.txt
index 89e03bc793c66..a0eca9c095775 100644
--- a/mlir/examples/standalone/python/CMakeLists.txt
+++ b/mlir/examples/standalone/python/CMakeLists.txt
@@ -57,6 +57,7 @@ add_mlir_python_common_capi_library(StandalonePythonCAPI
# available.
MLIRPythonExtension.RegisterEverything
MLIRPythonSources.Core
+ MLIRPythonSources.Dialects.builtin
)
################################################################################
@@ -72,6 +73,7 @@ add_mlir_python_modules(StandalonePythonModules
# available.
MLIRPythonExtension.RegisterEverything
MLIRPythonSources.Core
+ MLIRPythonSources.Dialects.builtin
COMMON_CAPI_LINK_LIBS
StandalonePythonCAPI
)
diff --git a/mlir/test/Examples/standalone/test.toy b/mlir/test/Examples/standalone/test.toy
index 5d568941c7e6c..e99bab5f0affc 100644
--- a/mlir/test/Examples/standalone/test.toy
+++ b/mlir/test/Examples/standalone/test.toy
@@ -4,9 +4,11 @@
# RUN: -DLLVM_USE_LINKER=%llvm_use_linker \
# RUN: -DPython3_EXECUTABLE=%python \
# RUN: -DPython_EXECUTABLE=%python
-# RUN: "%cmake_exe" --build . --target check-standalone | tee %t | FileCheck %s || cat %t && false
+# RUN: "%cmake_exe" --build . --target check-standalone | tee %t
+# RUN: FileCheck --input-file=%t %s
# Note: The number of checked tests is not important. The command will fail
# if any fail.
# CHECK: Passed
+# CHECK-NOT: Failed
# UNSUPPORTED: target={{.*(windows|android).*}}
>From a95c56861b144052a10bc7b066eb4a5435ac0649 Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Thu, 28 Aug 2025 23:38:57 -0400
Subject: [PATCH 10/11] add typing_extensions to windows
---
.ci/monolithic-windows.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/.ci/monolithic-windows.sh b/.ci/monolithic-windows.sh
index 097cd770055cf..f7076fa84770d 100755
--- a/.ci/monolithic-windows.sh
+++ b/.ci/monolithic-windows.sh
@@ -21,6 +21,7 @@ targets="${2}"
start-group "CMake"
pip install -q -r "${MONOREPO_ROOT}"/.ci/all_requirements.txt
pip install "nanobind @ git+https://github.com/wjakob/nanobind"
+pip install typing_extensions
export CC=cl
export CXX=cl
>From 25fe915cfeff0a1457b7a969b6f6c83fb67edf8e Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Fri, 29 Aug 2025 18:13:33 -0400
Subject: [PATCH 11/11] fix stubgen failure pybind11
---
.ci/all_requirements.txt | 226 ++-----------------------
.ci/monolithic-linux.sh | 1 -
.ci/monolithic-windows.sh | 1 -
mlir/cmake/modules/AddMLIRPython.cmake | 38 +++--
mlir/python/requirements.txt | 2 +-
5 files changed, 37 insertions(+), 231 deletions(-)
diff --git a/.ci/all_requirements.txt b/.ci/all_requirements.txt
index 40290a69bd8e5..f73500efdc7e0 100644
--- a/.ci/all_requirements.txt
+++ b/.ci/all_requirements.txt
@@ -1,173 +1,13 @@
#
-# This file is autogenerated by pip-compile with Python 3.12
+# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --generate-hashes --output-file=./.ci/all_requirements.txt ./.ci/requirements.txt ./lldb/test/requirements.txt ./mlir/python/requirements.txt
#
-cachetools==5.5.2 \
- --hash=sha256:1a661caa9175d26759571b2e19580f9d6393969e5dfca11fdb1f947a23e640d4 \
- --hash=sha256:d26a22bcc62eb95c3beabd9f1ee5e820d3d2704fe2967cbe350e20c8ffcd3f0a
- # via google-auth
-certifi==2025.8.3 \
- --hash=sha256:e564105f78ded564e3ae7c923924435e1daa7463faeab5bb932bc53ffae63407 \
- --hash=sha256:f6c12493cfb1b06ba2ff328595af9350c65d6644968e5d3a2ffd78699af217a5
- # via requests
-charset-normalizer==3.4.3 \
- --hash=sha256:00237675befef519d9af72169d8604a067d92755e84fe76492fef5441db05b91 \
- --hash=sha256:02425242e96bcf29a49711b0ca9f37e451da7c70562bc10e8ed992a5a7a25cc0 \
- --hash=sha256:027b776c26d38b7f15b26a5da1044f376455fb3766df8fc38563b4efbc515154 \
- --hash=sha256:07a0eae9e2787b586e129fdcbe1af6997f8d0e5abaa0bc98c0e20e124d67e601 \
- --hash=sha256:0cacf8f7297b0c4fcb74227692ca46b4a5852f8f4f24b3c766dd94a1075c4884 \
- --hash=sha256:0e78314bdc32fa80696f72fa16dc61168fda4d6a0c014e0380f9d02f0e5d8a07 \
- --hash=sha256:0f2be7e0cf7754b9a30eb01f4295cc3d4358a479843b31f328afd210e2c7598c \
- --hash=sha256:13faeacfe61784e2559e690fc53fa4c5ae97c6fcedb8eb6fb8d0a15b475d2c64 \
- --hash=sha256:14c2a87c65b351109f6abfc424cab3927b3bdece6f706e4d12faaf3d52ee5efe \
- --hash=sha256:1606f4a55c0fd363d754049cdf400175ee96c992b1f8018b993941f221221c5f \
- --hash=sha256:16a8770207946ac75703458e2c743631c79c59c5890c80011d536248f8eaa432 \
- --hash=sha256:18343b2d246dc6761a249ba1fb13f9ee9a2bcd95decc767319506056ea4ad4dc \
- --hash=sha256:18b97b8404387b96cdbd30ad660f6407799126d26a39ca65729162fd810a99aa \
- --hash=sha256:1bb60174149316da1c35fa5233681f7c0f9f514509b8e399ab70fea5f17e45c9 \
- --hash=sha256:1e8ac75d72fa3775e0b7cb7e4629cec13b7514d928d15ef8ea06bca03ef01cae \
- --hash=sha256:1ef99f0456d3d46a50945c98de1774da86f8e992ab5c77865ea8b8195341fc19 \
- --hash=sha256:2001a39612b241dae17b4687898843f254f8748b796a2e16f1051a17078d991d \
- --hash=sha256:23b6b24d74478dc833444cbd927c338349d6ae852ba53a0d02a2de1fce45b96e \
- --hash=sha256:252098c8c7a873e17dd696ed98bbe91dbacd571da4b87df3736768efa7a792e4 \
- --hash=sha256:257f26fed7d7ff59921b78244f3cd93ed2af1800ff048c33f624c87475819dd7 \
- --hash=sha256:2c322db9c8c89009a990ef07c3bcc9f011a3269bc06782f916cd3d9eed7c9312 \
- --hash=sha256:30a96e1e1f865f78b030d65241c1ee850cdf422d869e9028e2fc1d5e4db73b92 \
- --hash=sha256:30d006f98569de3459c2fc1f2acde170b7b2bd265dc1943e87e1a4efe1b67c31 \
- --hash=sha256:31a9a6f775f9bcd865d88ee350f0ffb0e25936a7f930ca98995c05abf1faf21c \
- --hash=sha256:320e8e66157cc4e247d9ddca8e21f427efc7a04bbd0ac8a9faf56583fa543f9f \
- --hash=sha256:34a7f768e3f985abdb42841e20e17b330ad3aaf4bb7e7aeeb73db2e70f077b99 \
- --hash=sha256:3653fad4fe3ed447a596ae8638b437f827234f01a8cd801842e43f3d0a6b281b \
- --hash=sha256:3cd35b7e8aedeb9e34c41385fda4f73ba609e561faedfae0a9e75e44ac558a15 \
- --hash=sha256:3cfb2aad70f2c6debfbcb717f23b7eb55febc0bb23dcffc0f076009da10c6392 \
- --hash=sha256:416175faf02e4b0810f1f38bcb54682878a4af94059a1cd63b8747244420801f \
- --hash=sha256:41d1fc408ff5fdfb910200ec0e74abc40387bccb3252f3f27c0676731df2b2c8 \
- --hash=sha256:42e5088973e56e31e4fa58eb6bd709e42fc03799c11c42929592889a2e54c491 \
- --hash=sha256:4ca4c094de7771a98d7fbd67d9e5dbf1eb73efa4f744a730437d8a3a5cf994f0 \
- --hash=sha256:511729f456829ef86ac41ca78c63a5cb55240ed23b4b737faca0eb1abb1c41bc \
- --hash=sha256:53cd68b185d98dde4ad8990e56a58dea83a4162161b1ea9272e5c9182ce415e0 \
- --hash=sha256:585f3b2a80fbd26b048a0be90c5aae8f06605d3c92615911c3a2b03a8a3b796f \
- --hash=sha256:5b413b0b1bfd94dbf4023ad6945889f374cd24e3f62de58d6bb102c4d9ae534a \
- --hash=sha256:5d8d01eac18c423815ed4f4a2ec3b439d654e55ee4ad610e153cf02faf67ea40 \
- --hash=sha256:6aab0f181c486f973bc7262a97f5aca3ee7e1437011ef0c2ec04b5a11d16c927 \
- --hash=sha256:6cf8fd4c04756b6b60146d98cd8a77d0cdae0e1ca20329da2ac85eed779b6849 \
- --hash=sha256:6fb70de56f1859a3f71261cbe41005f56a7842cc348d3aeb26237560bfa5e0ce \
- --hash=sha256:6fce4b8500244f6fcb71465d4a4930d132ba9ab8e71a7859e6a5d59851068d14 \
- --hash=sha256:70bfc5f2c318afece2f5838ea5e4c3febada0be750fcf4775641052bbba14d05 \
- --hash=sha256:73dc19b562516fc9bcf6e5d6e596df0b4eb98d87e4f79f3ae71840e6ed21361c \
- --hash=sha256:74d77e25adda8581ffc1c720f1c81ca082921329452eba58b16233ab1842141c \
- --hash=sha256:78deba4d8f9590fe4dae384aeff04082510a709957e968753ff3c48399f6f92a \
- --hash=sha256:86df271bf921c2ee3818f0522e9a5b8092ca2ad8b065ece5d7d9d0e9f4849bcc \
- --hash=sha256:88ab34806dea0671532d3f82d82b85e8fc23d7b2dd12fa837978dad9bb392a34 \
- --hash=sha256:8999f965f922ae054125286faf9f11bc6932184b93011d138925a1773830bbe9 \
- --hash=sha256:8dcfc373f888e4fb39a7bc57e93e3b845e7f462dacc008d9749568b1c4ece096 \
- --hash=sha256:939578d9d8fd4299220161fdd76e86c6a251987476f5243e8864a7844476ba14 \
- --hash=sha256:96b2b3d1a83ad55310de8c7b4a2d04d9277d5591f40761274856635acc5fcb30 \
- --hash=sha256:a2d08ac246bb48479170408d6c19f6385fa743e7157d716e144cad849b2dd94b \
- --hash=sha256:b256ee2e749283ef3ddcff51a675ff43798d92d746d1a6e4631bf8c707d22d0b \
- --hash=sha256:b5e3b2d152e74e100a9e9573837aba24aab611d39428ded46f4e4022ea7d1942 \
- --hash=sha256:b89bc04de1d83006373429975f8ef9e7932534b8cc9ca582e4db7d20d91816db \
- --hash=sha256:bd28b817ea8c70215401f657edef3a8aa83c29d447fb0b622c35403780ba11d5 \
- --hash=sha256:c60e092517a73c632ec38e290eba714e9627abe9d301c8c8a12ec32c314a2a4b \
- --hash=sha256:c6dbd0ccdda3a2ba7c2ecd9d77b37f3b5831687d8dc1b6ca5f56a4880cc7b7ce \
- --hash=sha256:c6e490913a46fa054e03699c70019ab869e990270597018cef1d8562132c2669 \
- --hash=sha256:c6f162aabe9a91a309510d74eeb6507fab5fff92337a15acbe77753d88d9dcf0 \
- --hash=sha256:c6fd51128a41297f5409deab284fecbe5305ebd7e5a1f959bee1c054622b7018 \
- --hash=sha256:cc34f233c9e71701040d772aa7490318673aa7164a0efe3172b2981218c26d93 \
- --hash=sha256:cc9370a2da1ac13f0153780040f465839e6cccb4a1e44810124b4e22483c93fe \
- --hash=sha256:ccf600859c183d70eb47e05a44cd80a4ce77394d1ac0f79dbd2dd90a69a3a049 \
- --hash=sha256:ce571ab16d890d23b5c278547ba694193a45011ff86a9162a71307ed9f86759a \
- --hash=sha256:cf1ebb7d78e1ad8ec2a8c4732c7be2e736f6e5123a4146c5b89c9d1f585f8cef \
- --hash=sha256:d0e909868420b7049dafd3a31d45125b31143eec59235311fc4c57ea26a4acd2 \
- --hash=sha256:d22dbedd33326a4a5190dd4fe9e9e693ef12160c77382d9e87919bce54f3d4ca \
- --hash=sha256:d716a916938e03231e86e43782ca7878fb602a125a91e7acb8b5112e2e96ac16 \
- --hash=sha256:d79c198e27580c8e958906f803e63cddb77653731be08851c7df0b1a14a8fc0f \
- --hash=sha256:d95bfb53c211b57198bb91c46dd5a2d8018b3af446583aab40074bf7988401cb \
- --hash=sha256:e28e334d3ff134e88989d90ba04b47d84382a828c061d0d1027b1b12a62b39b1 \
- --hash=sha256:ec557499516fc90fd374bf2e32349a2887a876fbf162c160e3c01b6849eaf557 \
- --hash=sha256:fb6fecfd65564f208cbf0fba07f107fb661bcd1a7c389edbced3f7a493f70e37 \
- --hash=sha256:fb731e5deb0c7ef82d698b0f4c5bb724633ee2a489401594c5c88b02e6cb15f7 \
- --hash=sha256:fb7f67a1bfa6e40b438170ebdc8158b78dc465a5a67b6dde178a46987b244a72 \
- --hash=sha256:fd10de089bcdcd1be95a2f73dbe6254798ec1bda9f450d5828c96f93e2536b9c \
- --hash=sha256:fdabf8315679312cfa71302f9bd509ded4f2f263fb5b765cf1433b39106c3cc9
- # via requests
-google-api-core==2.25.1 \
- --hash=sha256:8a2a56c1fef82987a524371f99f3bd0143702fecc670c72e600c1cda6bf8dbb7 \
- --hash=sha256:d2aaa0b13c78c61cb3f4282c464c046e45fbd75755683c9c525e6e8f7ed0a5e8
- # via
- # google-cloud-core
- # google-cloud-storage
-google-auth==2.40.3 \
- --hash=sha256:1370d4593e86213563547f97a92752fc658456fe4514c809544f330fed45a7ca \
- --hash=sha256:500c3a29adedeb36ea9cf24b8d10858e152f2412e3ca37829b3fa18e33d63b77
- # via
- # google-api-core
- # google-cloud-core
- # google-cloud-storage
-google-cloud-core==2.4.3 \
- --hash=sha256:1fab62d7102844b278fe6dead3af32408b1df3eb06f5c7e8634cbd40edc4da53 \
- --hash=sha256:5130f9f4c14b4fafdff75c79448f9495cfade0d8775facf1b09c3bf67e027f6e
- # via google-cloud-storage
-google-cloud-storage==3.3.0 \
- --hash=sha256:0338ecd6621b3ecacb108f1cf7513ff0d1bca7f1ff4d58e0220b59f3a725ff23 \
- --hash=sha256:ae9d891d53e17d9681d7c4ef1ffeea0cde9bdc53d5b64fa6ff6bf30d1911cf61
- # via -r .ci/requirements.txt
-google-crc32c==1.7.1 \
- --hash=sha256:0f99eaa09a9a7e642a61e06742856eec8b19fc0037832e03f941fe7cf0c8e4db \
- --hash=sha256:19eafa0e4af11b0a4eb3974483d55d2d77ad1911e6cf6f832e1574f6781fd337 \
- --hash=sha256:1c67ca0a1f5b56162951a9dae987988679a7db682d6f97ce0f6381ebf0fbea4c \
- --hash=sha256:1f2b3522222746fff0e04a9bd0a23ea003ba3cccc8cf21385c564deb1f223242 \
- --hash=sha256:22beacf83baaf59f9d3ab2bbb4db0fb018da8e5aebdce07ef9f09fce8220285e \
- --hash=sha256:2bff2305f98846f3e825dbeec9ee406f89da7962accdb29356e4eadc251bd472 \
- --hash=sha256:2d73a68a653c57281401871dd4aeebbb6af3191dcac751a76ce430df4d403194 \
- --hash=sha256:32d1da0d74ec5634a05f53ef7df18fc646666a25efaaca9fc7dcfd4caf1d98c3 \
- --hash=sha256:3bda0fcb632d390e3ea8b6b07bf6b4f4a66c9d02dcd6fbf7ba00a197c143f582 \
- --hash=sha256:6335de12921f06e1f774d0dd1fbea6bf610abe0887a1638f64d694013138be5d \
- --hash=sha256:6b211ddaf20f7ebeec5c333448582c224a7c90a9d98826fbab82c0ddc11348e6 \
- --hash=sha256:6efb97eb4369d52593ad6f75e7e10d053cf00c48983f7a973105bc70b0ac4d82 \
- --hash=sha256:6fbab4b935989e2c3610371963ba1b86afb09537fd0c633049be82afe153ac06 \
- --hash=sha256:713121af19f1a617054c41f952294764e0c5443d5a5d9034b2cd60f5dd7e0349 \
- --hash=sha256:754561c6c66e89d55754106739e22fdaa93fafa8da7221b29c8b8e8270c6ec8a \
- --hash=sha256:7cc81b3a2fbd932a4313eb53cc7d9dde424088ca3a0337160f35d91826880c1d \
- --hash=sha256:85fef7fae11494e747c9fd1359a527e5970fc9603c90764843caabd3a16a0a48 \
- --hash=sha256:905a385140bf492ac300026717af339790921f411c0dfd9aa5a9e69a08ed32eb \
- --hash=sha256:9fc196f0b8d8bd2789352c6a522db03f89e83a0ed6b64315923c396d7a932315 \
- --hash=sha256:a8e9afc74168b0b2232fb32dd202c93e46b7d5e4bf03e66ba5dc273bb3559589 \
- --hash=sha256:b07d48faf8292b4db7c3d64ab86f950c2e94e93a11fd47271c28ba458e4a0d76 \
- --hash=sha256:b6d86616faaea68101195c6bdc40c494e4d76f41e07a37ffdef270879c15fb65 \
- --hash=sha256:b7491bdc0c7564fcf48c0179d2048ab2f7c7ba36b84ccd3a3e1c3f7a72d3bba6 \
- --hash=sha256:bb5e35dcd8552f76eed9461a23de1030920a3c953c1982f324be8f97946e7127 \
- --hash=sha256:d68e17bad8f7dd9a49181a1f5a8f4b251c6dbc8cc96fb79f1d321dfd57d66f53 \
- --hash=sha256:dcdf5a64adb747610140572ed18d011896e3b9ae5195f2514b7ff678c80f1603 \
- --hash=sha256:df8b38bdaf1629d62d51be8bdd04888f37c451564c2042d36e5812da9eff3c35 \
- --hash=sha256:e10554d4abc5238823112c2ad7e4560f96c7bf3820b202660373d769d9e6e4c9 \
- --hash=sha256:e42e20a83a29aa2709a0cf271c7f8aefaa23b7ab52e53b322585297bb94d4638 \
- --hash=sha256:ed66cbe1ed9cbaaad9392b5259b3eba4a9e565420d734e6238813c428c3336c9 \
- --hash=sha256:ee6547b657621b6cbed3562ea7826c3e11cab01cd33b74e1f677690652883e77 \
- --hash=sha256:f2226b6a8da04f1d9e61d3e357f2460b9551c5e6950071437e122c958a18ae14 \
- --hash=sha256:fa8136cc14dd27f34a3221c0f16fd42d8a40e4778273e61a3c19aedaa44daf6b \
- --hash=sha256:fc5319db92daa516b653600794d5b9f9439a9a121f3e162f94b0e1891c7933cb
- # via
- # google-cloud-storage
- # google-resumable-media
-google-resumable-media==2.7.2 \
- --hash=sha256:3ce7551e9fe6d99e9a126101d2536612bb73486721951e9562fee0f90c6ababa \
- --hash=sha256:5280aed4629f2b60b847b0d42f9857fd4935c11af266744df33d8074cae92fe0
- # via google-cloud-storage
-googleapis-common-protos==1.70.0 \
- --hash=sha256:0e1b44e0ea153e6594f9f394fef15193a68aaaea2d843f83e2742717ca753257 \
- --hash=sha256:b8bfcca8c25a2bb253e0e0b0adaf8c00773e5e6af6fd92397576680b807e0fd8
- # via google-api-core
-idna==3.10 \
- --hash=sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9 \
- --hash=sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3
- # via requests
junitparser==3.2.0 \
--hash=sha256:b05e89c27e7b74b3c563a078d6e055d95cf397444f8f689b0ca616ebda0b3c65 \
--hash=sha256:e14fdc0a999edfc15889b637390e8ef6ca09a49532416d3bd562857d42d4b96d
- # via -r .ci/requirements.txt
+ # via -r ./.ci/requirements.txt
ml-dtypes==0.5.1 ; python_version < "3.13" \
--hash=sha256:023ce2f502efd4d6c1e0472cc58ce3640d051d40e71e27386bed33901e201327 \
--hash=sha256:05f23447a1c20ddf4dc7c2c661aa9ed93fcb2658f1017c204d1e758714dc28a8 \
@@ -194,8 +34,10 @@ ml-dtypes==0.5.1 ; python_version < "3.13" \
--hash=sha256:d13755f8e8445b3870114e5b6240facaa7cb0c3361e54beba3e07fa912a6e12b \
--hash=sha256:fd918d4e6a4e0c110e2e05be7a7814d10dc1b95872accbf6512b80a109b71ae1
# via -r ./mlir/python/requirements.txt
-nanobind @ git+https://github.com/wjakob/nanobind
- # via -r mlir/python/requirements.txt
+nanobind==2.7.0 \
+ --hash=sha256:73b12d0e751d140d6c1bf4b215e18818a8debfdb374f08dc3776ad208d808e74 \
+ --hash=sha256:f9f1b160580c50dcf37b6495a0fd5ec61dc0d95dae5f8004f87dd9ad7eb46b34
+ # via -r ./mlir/python/requirements.txt
numpy==2.0.2 \
--hash=sha256:0123ffdaa88fa4ab64835dcbde75dcdf89c453c922f18dced6e27c90d1d0ec5a \
--hash=sha256:11a76c372d1d37437857280aa142086476136a8c0f373b2e648ab2c8f18fb195 \
@@ -243,34 +85,16 @@ numpy==2.0.2 \
--hash=sha256:f15975dfec0cf2239224d80e32c3170b1d168335eaedee69da84fbe9f1f9cd04 \
--hash=sha256:f26b258c385842546006213344c50655ff1555a9338e2e5e02a0756dc3e803dd
# via
- # -r mlir/python/requirements.txt
+ # -r ./mlir/python/requirements.txt
# ml-dtypes
packaging==25.0 \
--hash=sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484 \
--hash=sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f
- # via -r lldb/test/requirements.txt
+ # via -r ./lldb/test/requirements.txt
pexpect==4.9.0 ; sys_platform != "win32" \
--hash=sha256:7236d1e080e4936be2dc3e326cec0af72acf9212a7e1d060210e70a47e253523 \
--hash=sha256:ee7d41123f3c9911050ea2c2dac107568dc43b2d3b0c7557a33212c398ead30f
- # via -r lldb/test/requirements.txt
-proto-plus==1.26.1 \
- --hash=sha256:13285478c2dcf2abb829db158e1047e2f1e8d63a077d94263c2b88b043c75a66 \
- --hash=sha256:21a515a4c4c0088a773899e23c7bbade3d18f9c66c73edd4c7ee3816bc96a012
- # via google-api-core
-protobuf==6.32.0 \
- --hash=sha256:15eba1b86f193a407607112ceb9ea0ba9569aed24f93333fe9a497cf2fda37d3 \
- --hash=sha256:501fe6372fd1c8ea2a30b4d9be8f87955a64d6be9c88a973996cef5ef6f0abf1 \
- --hash=sha256:75a2aab2bd1aeb1f5dc7c5f33bcb11d82ea8c055c9becbb41c26a8c43fd7092c \
- --hash=sha256:7db8ed09024f115ac877a1427557b838705359f047b2ff2f2b2364892d19dacb \
- --hash=sha256:84f9e3c1ff6fb0308dbacb0950d8aa90694b0d0ee68e75719cb044b7078fe741 \
- --hash=sha256:a81439049127067fc49ec1d36e25c6ee1d1a2b7be930675f919258d03c04e7d2 \
- --hash=sha256:a8bdbb2f009cfc22a36d031f22a625a38b615b5e19e558a7b756b3279723e68e \
- --hash=sha256:ba377e5b67b908c8f3072a57b63e2c6a4cbd18aea4ed98d2584350dbf46f2783 \
- --hash=sha256:d52691e5bee6c860fff9a1c86ad26a13afbeb4b168cd4445c922b7e2cf85aaf0
- # via
- # google-api-core
- # googleapis-common-protos
- # proto-plus
+ # via -r ./lldb/test/requirements.txt
psutil==7.0.0 \
--hash=sha256:101d71dc322e3cffd7cea0650b09b3d08b8e7c4109dd6809fe452dfd00e58b25 \
--hash=sha256:1e744154a6580bc968a0195fd25e80432d3afec619daf145b9e5ba16cc1d688e \
@@ -282,25 +106,15 @@ psutil==7.0.0 \
--hash=sha256:84df4eb63e16849689f76b1ffcb36db7b8de703d1bc1fe41773db487621b6c17 \
--hash=sha256:a5f098451abc2828f7dc6b58d44b532b22f2088f4999a937557b603ce72b1993 \
--hash=sha256:ba3fcef7523064a6c9da440fc4d6bd07da93ac726b5733c29027d7dc95b39d99
- # via -r lldb/test/requirements.txt
+ # via -r ./lldb/test/requirements.txt
ptyprocess==0.7.0 \
--hash=sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35 \
--hash=sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220
# via pexpect
-pyasn1==0.6.1 \
- --hash=sha256:0d632f46f2ba09143da3a8afe9e33fb6f92fa2320ab7e886e2d0f7672af84629 \
- --hash=sha256:6f580d2bdd84365380830acf45550f2511469f673cb4a5ae3857a3170128b034
- # via
- # pyasn1-modules
- # rsa
-pyasn1-modules==0.4.2 \
- --hash=sha256:29253a9207ce32b64c3ac6600edc75368f98473906e8fd1043bd6b5b1de2c14a \
- --hash=sha256:677091de870a80aae844b1ca6134f54652fa2c8c5a52aa396440ac3106e941e6
- # via google-auth
pybind11==2.13.6 \
--hash=sha256:237c41e29157b962835d356b370ededd57594a26d5894a795960f0047cb5caf5 \
--hash=sha256:ba6af10348c12b24e92fa086b39cfba0eff619b61ac77c406167d813b096d39a
- # via -r mlir/python/requirements.txt
+ # via -r ./mlir/python/requirements.txt
pyyaml==6.0.1 \
--hash=sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5 \
--hash=sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc \
@@ -353,17 +167,7 @@ pyyaml==6.0.1 \
--hash=sha256:fca0e3a251908a499833aa292323f32437106001d436eca0e6e7833256674585 \
--hash=sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d \
--hash=sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f
- # via -r mlir/python/requirements.txt
-requests==2.32.5 \
- --hash=sha256:2462f94637a34fd532264295e186976db0f5d453d1cdd31473c85a6a161affb6 \
- --hash=sha256:dbba0bac56e100853db0ea71b82b4dfd5fe2bf6d3754a8893c3af500cec7d7cf
- # via
- # google-api-core
- # google-cloud-storage
-rsa==4.9.1 \
- --hash=sha256:68635866661c6836b8d39430f97a996acbd61bfa49406748ea243539fe239762 \
- --hash=sha256:e7bdbfdb5497da4c07dfd35530e1a902659db6ff241e39d9953cad06ebd0ae75
- # via google-auth
+ # via -r ./mlir/python/requirements.txt
swig==4.3.1 \
--hash=sha256:07082c2f8693f83ba136136e54e92a5af014488ca4f2a3de4b471337c00d92aa \
--hash=sha256:0743063399e373b17d658481f4cd327245ef58a1d17a3e2071de88dec60082fc \
@@ -380,8 +184,4 @@ swig==4.3.1 \
--hash=sha256:d84b3e31d943d81b28bd4144dcf5271909ad2313f0f2afbd7f2fb37ef2a6d8bb \
--hash=sha256:efec16327029f682f649a26da726bb0305be8800bd0f1fa3e81bf0769cf5b476 \
--hash=sha256:fc496c0d600cf1bb2d91e28d3d6eae9c4301e5ea7a0dec5a4281b5efed4245a8
- # via -r lldb/test/requirements.txt
-urllib3==2.5.0 \
- --hash=sha256:3fc47733c7e419d4bc3f6b3dc2b4f890bb743906a30d56ba4a5bfa4bbff92760 \
- --hash=sha256:e6b01673c0fa6a13e374b50871808eb3bf7046c4b125b216f6bf1cc604cff0dc
- # via requests
+ # via -r ./lldb/test/requirements.txt
diff --git a/.ci/monolithic-linux.sh b/.ci/monolithic-linux.sh
index 4063819397db3..3ca4d05f4c891 100755
--- a/.ci/monolithic-linux.sh
+++ b/.ci/monolithic-linux.sh
@@ -34,7 +34,6 @@ lit_args="-v --xunit-xml-output ${BUILD_DIR}/test-results.xml --use-unique-outpu
start-group "CMake"
export PIP_BREAK_SYSTEM_PACKAGES=1
pip install -q -r "${MONOREPO_ROOT}"/.ci/all_requirements.txt
-pip install "nanobind @ git+https://github.com/wjakob/nanobind"
# Set the system llvm-symbolizer as preferred.
export LLVM_SYMBOLIZER_PATH=`which llvm-symbolizer`
diff --git a/.ci/monolithic-windows.sh b/.ci/monolithic-windows.sh
index f7076fa84770d..d10118616a044 100755
--- a/.ci/monolithic-windows.sh
+++ b/.ci/monolithic-windows.sh
@@ -20,7 +20,6 @@ targets="${2}"
start-group "CMake"
pip install -q -r "${MONOREPO_ROOT}"/.ci/all_requirements.txt
-pip install "nanobind @ git+https://github.com/wjakob/nanobind"
pip install typing_extensions
export CC=cl
diff --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake
index 71ff59e9a264c..9c8d1ee8e6f38 100644
--- a/mlir/cmake/modules/AddMLIRPython.cmake
+++ b/mlir/cmake/modules/AddMLIRPython.cmake
@@ -151,7 +151,7 @@ endfunction()
function(declare_mlir_python_extension name)
cmake_parse_arguments(ARG
""
- "ROOT_DIR;MODULE_NAME;ADD_TO_PARENT;PYTHON_BINDINGS_LIBRARY"
+ "ROOT_DIR;MODULE_NAME;ADD_TO_PARENT;PYTHON_BINDINGS_LIBRARY;GENERATE_TYPE_STUBS"
"SOURCES;PRIVATE_LINK_LIBS;EMBED_CAPI_LINK_LIBS"
${ARGN})
@@ -162,18 +162,23 @@ function(declare_mlir_python_extension name)
if(NOT ARG_PYTHON_BINDINGS_LIBRARY)
set(ARG_PYTHON_BINDINGS_LIBRARY "pybind11")
+ set(ARG_GENERATE_TYPE_STUBS OFF)
+ endif()
+ if(NOT DEFINED ARG_GENERATE_TYPE_STUBS)
+ set(ARG_GENERATE_TYPE_STUBS ON)
endif()
add_library(${name} INTERFACE)
set_target_properties(${name} PROPERTIES
# Yes: Leading-lowercase property names are load bearing and the recommended
# way to do this: https://gitlab.kitware.com/cmake/cmake/-/issues/19261
- EXPORT_PROPERTIES "mlir_python_SOURCES_TYPE;mlir_python_EXTENSION_MODULE_NAME;mlir_python_EMBED_CAPI_LINK_LIBS;mlir_python_DEPENDS;mlir_python_BINDINGS_LIBRARY"
+ EXPORT_PROPERTIES "mlir_python_SOURCES_TYPE;mlir_python_EXTENSION_MODULE_NAME;mlir_python_EMBED_CAPI_LINK_LIBS;mlir_python_DEPENDS;mlir_python_BINDINGS_LIBRARY;mlir_python_GENERATE_TYPE_STUBS"
mlir_python_SOURCES_TYPE extension
mlir_python_EXTENSION_MODULE_NAME "${ARG_MODULE_NAME}"
mlir_python_EMBED_CAPI_LINK_LIBS "${ARG_EMBED_CAPI_LINK_LIBS}"
mlir_python_DEPENDS ""
mlir_python_BINDINGS_LIBRARY "${ARG_PYTHON_BINDINGS_LIBRARY}"
+ mlir_python_GENERATE_TYPE_STUBS "${ARG_GENERATE_TYPE_STUBS}"
)
# Set the interface source and link_libs properties of the target
@@ -276,19 +281,22 @@ function(add_mlir_python_modules name)
)
add_dependencies(${modules_target} ${_extension_target})
mlir_python_setup_extension_rpath(${_extension_target})
- generate_type_stubs(
- ${_module_name}
- ${_extension_target}
- "${modules_target}.extension._mlir.dso"
- "${CMAKE_CURRENT_SOURCE_DIR}/mlir/_mlir_libs/_mlir"
- )
- declare_mlir_python_sources(
- "${MLIR_PYTHON_PACKAGE_PREFIX}.${_module_name}_type_stub_gen"
- ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"
- ADD_TO_PARENT "${sources_target}"
- SOURCES_GLOB "_mlir_libs/${_module_name}/**/*.pyi"
- )
- add_dependencies("${modules_target}" "${NB_STUBGEN_CUSTOM_TARGET}")
+ get_target_property(_generate_type_stubs ${sources_target} mlir_python_GENERATE_TYPE_STUBS)
+ if(_generate_type_stubs)
+ generate_type_stubs(
+ ${_module_name}
+ ${_extension_target}
+ "${modules_target}.extension._mlir.dso"
+ "${CMAKE_CURRENT_SOURCE_DIR}/mlir/_mlir_libs/_mlir"
+ )
+ declare_mlir_python_sources(
+ "${MLIR_PYTHON_PACKAGE_PREFIX}.${_module_name}_type_stub_gen"
+ ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"
+ ADD_TO_PARENT "${sources_target}"
+ SOURCES_GLOB "_mlir_libs/${_module_name}/**/*.pyi"
+ )
+ add_dependencies("${modules_target}" "${NB_STUBGEN_CUSTOM_TARGET}")
+ endif()
else()
message(SEND_ERROR "Unrecognized source type '${_source_type}' for python source target ${sources_target}")
return()
diff --git a/mlir/python/requirements.txt b/mlir/python/requirements.txt
index a0b2c3736b214..86bd22a2e1d8b 100644
--- a/mlir/python/requirements.txt
+++ b/mlir/python/requirements.txt
@@ -1,4 +1,4 @@
-nanobind @ git+https://github.com/wjakob/nanobind
+nanobind>=2.4, <3.0
numpy>=1.19.5, <=2.1.2
pybind11>=2.10.0, <=2.13.6
PyYAML>=5.4.0, <=6.0.1
More information about the Mlir-commits
mailing list