| 1 |
#!/usr/bin/env bash |
| 2 |
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 3 |
# See https://llvm.org/LICENSE.txt for license information. |
| 4 |
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 5 |
|
| 6 |
# Updates the LinalgStructuredOps.yaml file based on the |
| 7 |
# core_named_ops.py source of truth. |
| 8 |
|
| 9 |
set -eu -o errtrace |
| 10 |
shopt -s inherit_errexit |
| 11 |
|
| 12 |
mlir_source_dir="@MLIR_SOURCE_DIR@" |
| 13 |
python_exe="@Python3_EXECUTABLE@" |
| 14 |
mlir_binary_dir="@MLIR_BINARY_DIR@" |
| 15 |
python_package_dir="$mlir_binary_dir/python_packages/mlir_core" |
| 16 |
|
| 17 |
if ! [[ -d "$python_package_dir" ]]; then |
| 18 |
echo "ERROR: Python bindings not found. Build with -DMLIR_ENABLE_BINDINGS_PYTHON=ON" |
| 19 |
exit 1 |
| 20 |
fi |
| 21 |
|
| 22 |
dest_file="$mlir_source_dir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml" |
| 23 |
echo "Updating ops in $dest_file" |
| 24 |
|
| 25 |
export PYTHONPATH="$python_package_dir" |
| 26 |
OUTPUT="$( |
| 27 |
echo "### AUTOGENERATED from core_named_ops.py" && \ |
| 28 |
echo "### To regenerate, run: bin/update_core_linalg_named_ops.sh" && \ |
| 29 |
"$python_exe" -m mlir.dialects.linalg.opdsl.dump_oplib .ops.core_named_ops \ |
| 30 |
)" |
| 31 |
echo "$OUTPUT" > "$dest_file" |
| 32 |
echo "Success." |