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 formatgeneric: false
- Uses MLIR's specialized formatbytecode: 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
Beaver.MLIR.***
: APIs related to lifecycle, including creating and destroying MLIR entities.Beaver.MLIR
: APIs likeBeaver.MLIR.dump!/1
orBeaver.MLIR.null?/1
. These are standard features generally expected in any MLIR tools.
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
@type applicable() :: Beaver.MLIR.Operation.t() | Beaver.MLIR.Module.t()
@type apply_opt() :: {:debug, boolean()}
@type dump_opts() :: [{:generic, boolean()}]
@type nullable() :: Beaver.MLIR.Attribute.t() | Beaver.MLIR.Value.t() | Beaver.MLIR.Type.t() | Beaver.MLIR.Operation.t() | Beaver.MLIR.Module.t() | Beaver.MLIR.Block.t() | Beaver.MLIR.Dialect.t() | Beaver.MLIR.ExecutionEngine.t()
@type printable() :: Beaver.MLIR.Attribute.t() | Beaver.MLIR.Value.t() | Beaver.MLIR.Type.t() | Beaver.MLIR.Operation.t() | Beaver.MLIR.AffineMap.t() | Beaver.MLIR.Location.t() | Beaver.MLIR.OpPassManager.t() | Beaver.MLIR.PassManager.t() | Beaver.MLIR.Module.t() | Beaver.MLIR.Identifier.t()
@type verifiable() :: Beaver.MLIR.Operation.t() | Beaver.MLIR.Module.t()
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.
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 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.
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.
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.
@spec verify(verifiable()) :: {:ok, verifiable()} | :null | :fail
@spec verify!(verifiable()) :: :ok