Transforms
MLIR transformation passes for loop optimization.
This module provides functions for applying various loop transformation passes to MLIR code, including tiling, interchange, parallelization, vectorization, and fusion. It interfaces with the MLIR transform dialect for specifying and applying transformations.
transform_TP(module, operation_tag, tiling_sizes)
Apply tiling and parallelization transformation to an operation.
Tiles loops using forall constructs for parallelization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
The MLIR module to transform. |
required |
operation_tag
|
str
|
The tag of the operation to transform. |
required |
tiling_sizes
|
list[int]
|
List of tiling factors for each loop. |
required |
Source code in mlir_rl_artifact/transforms.py
transform_tile(module, operation_tag, tiling_sizes)
Apply tiling transformation to an operation using for loops.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
The MLIR module to transform. |
required |
operation_tag
|
str
|
The tag of the operation to transform. |
required |
tiling_sizes
|
list[int]
|
List of tiling factors for each loop. |
required |
Source code in mlir_rl_artifact/transforms.py
transform_interchange(module, operation_tag, interchange_list)
Apply loop interchange transformation to an operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
The MLIR module to transform. |
required |
operation_tag
|
str
|
The tag of the operation to transform. |
required |
interchange_list
|
list[int]
|
Permutation of loop indices defining the new loop order. |
required |
Source code in mlir_rl_artifact/transforms.py
transform_vectorize(module, operation_tag)
Apply vectorization transformation to an operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
The MLIR module to transform. |
required |
operation_tag
|
str
|
The tag of the operation to transform. |
required |
Source code in mlir_rl_artifact/transforms.py
transform_img2col(module, operation_tag)
Apply img2col transformation to convert convolution to matrix multiplication.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
The MLIR module to transform. |
required |
operation_tag
|
str
|
The tag of the convolution operation to transform. |
required |
Source code in mlir_rl_artifact/transforms.py
transform_TF(module, consumer_tag, producer_tag, new_producer_tag, tiling_sizes)
Apply tiling and fusion transformation to consumer and producer operations.
Tiles the consumer with parallelization and fuses the producer into the tiled loops.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
The MLIR module to transform. |
required |
consumer_tag
|
str
|
The tag of the consumer operation. |
required |
producer_tag
|
str
|
The tag of the producer operation to fuse. |
required |
new_producer_tag
|
str
|
The tag to assign to the fused producer. |
required |
tiling_sizes
|
list[int]
|
List of tiling factors for consumer loops. |
required |
Source code in mlir_rl_artifact/transforms.py
transform_decompose(module, operation_tag)
Apply decomposition transformation to an operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
The MLIR module to transform. |
required |
operation_tag
|
str
|
The tag of the operation to decompose. |
required |
Source code in mlir_rl_artifact/transforms.py
transform_transpose_conv_2d(module, operation_tag)
Apply transposed convolution transformation to an operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
The MLIR module to transform. |
required |
operation_tag
|
str
|
The tag of the convolution operation to transform. |
required |
Source code in mlir_rl_artifact/transforms.py
transform_bufferize_and_lower_v(module)
Apply bufferization and lowering transformations for vectorized execution.
Applies a comprehensive series of transformations including bufferization, vectorization, and lowering to prepare code for execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
The MLIR module to transform. |
required |
Source code in mlir_rl_artifact/transforms.py
transform_pre_vec(module, operation_tag)
Apply pre-vectorization transformation to eliminate unit-stride accesses.
Eliminates accesses with constant 1 stride by adding subviews, which enables better vectorization opportunities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
The MLIR module to transform. |
required |
operation_tag
|
str
|
The tag of the operation to transform. |
required |
Source code in mlir_rl_artifact/transforms.py
move_module(source, destination)
Copy all operations from source module to destination module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Module
|
The source MLIR module. |
required |
destination
|
Module
|
The destination MLIR module where operations will be copied. |
required |
Source code in mlir_rl_artifact/transforms.py
__run_transform_code_wrapper(module, transform_code)
Wrapper for running transform code with timeout support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
The MLIR module to transform. |
required |
transform_code
|
str
|
The MLIR transform dialect code. |
required |
Source code in mlir_rl_artifact/transforms.py
__run_transform_code(module, transform_code)
Parse and apply MLIR transform dialect code to a module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
The MLIR module to transform. |
required |
transform_code
|
str
|
The MLIR transform dialect code. |
required |