Beaver.MLIR (beaver v0.4.0)

Core functionality for working with MLIR.

This module serves as the primary interface for MLIR operations and entities in Beaver. It provides:

  • String conversion utilities for debugging and serialization
  • Null checking for safe operation handling
  • Context and location retrieval for MLIR entities

Printing Operations

When converting operations to strings, you can specify the output format:

  • generic: true - Uses MLIR's generic format
  • generic: false - Uses MLIR's specialized format
  • bytecode: true - Uses MLIR's bytecode format

The default format may vary between MLIR versions, so explicitly specify the format when consistent output is required.

Inspecting MLIR Entities

Beaver doesn't implement Inspect protocol for MLIR entities because the output might be too verbose and can crash the BEAM if invalid entities are passed. Use Beaver.MLIR.to_string/2 to convert entities to inspect it.

Null Safety

Many MLIR operations can return null values. Use null?/1 to safely check entities before performing operations that require non-null values.

Name spaces to include different kinds of CAPI delegates

Summary

Functions

Apply patterns on a container (region, operation, module). It returns the container if it succeeds otherwise it raises.

Apply patterns on a container (operation, module). It is named apply_ with a underscore to avoid name collision with Kernel.apply/2

Get the MLIR context of an MLIR entity.

Dump MLIR element to stdio.

Dump MLIR element to stdio and raise an error if it fails.

Compare two MLIR entities.

Get the MLIR location of an MLIR entity.

Check if an MLIR entity is null.

Print MLIR element or StringRef as Elixir binary string.

Types

Functions

apply!(op, patterns, opts \\ [debug: false])

Apply patterns on a container (region, operation, module). It returns the container if it succeeds otherwise it raises.

apply_(op, patterns, opts \\ [debug: false])

Apply patterns on a container (operation, module). It is named apply_ with a underscore to avoid name collision with Kernel.apply/2

context(entity)

Get the MLIR context of an MLIR entity.

dump(mlir, opts \\ [])

@spec dump(printable(), dump_opts()) :: :ok

Dump MLIR element to stdio.

This will call the printer registered in C/C++. Note that the outputs wouldn't go through Erlang's IO system, so it's not possible to capture the output in Elixir. If you need to capture the output, use to_string/1 instead.

dump!(mlir, opts \\ [])

@spec dump!(printable(), dump_opts()) :: any()

Dump MLIR element to stdio and raise an error if it fails.

equal?(a, b)

Compare two MLIR entities.

location(entity)

Get the MLIR location of an MLIR entity.

null?(entity)

@spec null?(nullable()) :: boolean()

Check if an MLIR entity is null.

To prevent crashing the BEAM, it is encouraged to use this function to check if an entity is null before calling functions that require a non-null entity.

to_string(mlir, opts \\ [])

@spec to_string(printable(), dump_opts()) :: :ok

Print MLIR element or StringRef as Elixir binary string.

When printing an operation, it is recommended to use generic: false or generic: true to explicitly specify the format if your usage requires consistent output. If not specified, the default behavior is subject to change according to the MLIR version.

verify(op)

@spec verify(verifiable()) :: {:ok, verifiable()} | :null | :fail

verify!(op)

@spec verify!(verifiable()) :: :ok