or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

api-embedding.mdbuild-system.mdcommand-line-tools.mdcore-compilation.mdfrontend-integration.mdindex.md
tile.json

tessl/pypi-iree-base-compiler

IREE Python Compiler API - MLIR-based end-to-end compiler for Machine Learning models

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/iree-base-compiler@3.6.x

To install, run

npx @tessl/cli install tessl/pypi-iree-base-compiler@3.6.0

index.mddocs/

IREE Base Compiler

IREE Base Compiler provides Python APIs for compiling Machine Learning models using IREE's MLIR-based end-to-end compiler infrastructure. It enables developers to compile ML models from various frameworks (TensorFlow, PyTorch, ONNX) into IREE's optimized intermediate representation for deployment across diverse hardware targets including CPUs, GPUs, and accelerators.

Package Information

  • Package Name: iree-base-compiler
  • Language: Python
  • Installation: pip install iree-base-compiler
  • Repository: https://github.com/iree-org/iree

Core Imports

import iree.compiler

High-level compilation tools:

from iree.compiler.tools import compile_str, compile_file, CompilerOptions

Low-level embedding API:

from iree.compiler.api import Session, Invocation, Source, Output

Build system:

import iree.build

Basic Usage

import iree.compiler.tools

# Simple MLIR compilation
SIMPLE_MUL_ASM = """
func.func @simple_mul(%arg0: tensor<4xf32>, %arg1: tensor<4xf32>) -> tensor<4xf32> {
    %0 = arith.mulf %arg0, %arg1 : tensor<4xf32>
    return %0 : tensor<4xf32>
}
"""

# Compile to FlatBuffer binary for CPU target
binary = iree.compiler.tools.compile_str(
    SIMPLE_MUL_ASM, 
    input_type="auto", 
    target_backends=["llvm-cpu"]
)

# Compile from file with options
options = iree.compiler.tools.CompilerOptions(
    target_backends=["llvm-cpu"],
    optimize=True,
    output_file="output.vmfb"
)
iree.compiler.tools.compile_file("input.mlir", **options.__dict__)

Architecture

IREE Base Compiler provides multiple API layers for different use cases:

  • High-level Tools API (iree.compiler.tools): User-friendly compilation functions with simplified options for common workflows
  • Low-level Embedding API (iree.compiler.api): Direct access to the C embedding API for advanced control over compilation sessions and invocations
  • Build System API (iree.build): Declarative build system for complex compilation workflows with dependencies and actions
  • Frontend Integration: Specialized APIs for TensorFlow and TensorFlow Lite model import
  • Command-line Tools: Console scripts providing command-line access to compilation functionality

This layered design supports everything from simple model compilation to complex multi-step build pipelines in production ML deployment systems.

Capabilities

Core Compilation Functions

High-level compilation functions for compiling MLIR code to IREE VM modules, supporting various input formats and target backends.

def compile_str(input_str: Union[str, bytes], **kwargs) -> Optional[bytes]: ...
def compile_file(input_file: str, **kwargs) -> Optional[bytes]: ...
def query_available_targets() -> List[str]: ...

Core Compilation

Compiler API Embedding

Low-level C API bindings providing direct access to IREE's compiler infrastructure through Session, Invocation, Source, and Output objects.

class Session: ...
class Invocation: ...
class Source: ...
class Output: ...

API Embedding

Build System

Declarative build system for managing complex compilation workflows with dependencies, actions, and entrypoints.

@entrypoint
def build_func(): ...

class CompileSourceAction: ...
class CompileStdModuleAction: ...

Build System

Frontend Integration

Specialized APIs for importing and compiling models from TensorFlow and TensorFlow Lite frameworks.

def compile_from_tf_module(tf_module, **kwargs): ...
def compile_from_tflite_file(tflite_path, **kwargs): ...

Frontend Integration

Command-line Tools

Console scripts providing command-line access to compilation, optimization, and import functionality.

# Console scripts:
# iree-compile, iree-opt, iree-import-onnx, iree-ir-tool, iree-build

Command-line Tools