| # Copyright 2025 The IREE Authors |
| # |
| # Licensed under the Apache License v2.0 with LLVM Exceptions. |
| # See https://llvm.org/LICENSE.txt for license information. |
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| |
| load("//build_tools/bazel:build_defs.oss.bzl", "iree_cmake_extra_content") |
| load("//build_tools/bazel:iree_lit_test.bzl", "iree_lit_test_suite") |
| load("//build_tools/embed_data:build_defs.bzl", "iree_c_embed_data") |
| |
| package( |
| default_visibility = ["//visibility:public"], |
| features = ["layering_check"], |
| licenses = ["notice"], # Apache 2.0 |
| ) |
| |
| iree_cmake_extra_content( |
| content = """ |
| if(NOT IREE_TARGET_BACKEND_ROCM) |
| return() |
| endif() |
| """, |
| inline = True, |
| ) |
| |
| # Target archs for specialization patternsets. https://llvm.org/docs/AMDGPUUsage.html#processors |
| gpu_archs = [ |
| "gfx942", |
| ] |
| |
| ukernel_patterns_mlir_files = [ |
| "ukernel_patterns_%s.mlir" % gpu_arch |
| for gpu_arch in gpu_archs |
| ] |
| |
| iree_c_embed_data( |
| name = "iree_mlir_ukernel_patterns_amdgpu", |
| srcs = ukernel_patterns_mlir_files, |
| c_file_output = "iree_mlir_ukernel_patterns_amdgpu.c", |
| flatten = True, |
| h_file_output = "iree_mlir_ukernel_patterns_amdgpu.h", |
| ) |
| |
| # Verify that the tuning specs are valid. We need this here because we do not |
| # assemble the tuning spec mlir and invalid specs do not lead to build errors. |
| iree_lit_test_suite( |
| name = "verify_mlir_ukernel_patterns_amdgpu", |
| srcs = ukernel_patterns_mlir_files, |
| cfg = "//compiler:lit.cfg.py", |
| tools = [ |
| "//tools:iree-opt", |
| ], |
| ) |
| |
| iree_c_embed_data( |
| name = "iree_mlir_ukernels_amdgpu", |
| srcs = [ |
| "iree_uk_amdgpu_matmul_bf16.mlir", |
| "iree_uk_amdgpu_matmul_f16.mlir", |
| "iree_uk_amdgpu_matmul_f8.mlir", |
| ], |
| c_file_output = "iree_mlir_ukernels_amdgpu.c", |
| flatten = True, |
| h_file_output = "iree_mlir_ukernels_amdgpu.h", |
| ) |
| |
| # Verify that the ukernels are valid. We need this here because we do not |
| # assemble the ukernel mlir and invalid specs do not lead to build errors. |
| iree_lit_test_suite( |
| name = "verify_mlir_ukernels_amdgpu", |
| srcs = [ |
| "iree_uk_amdgpu_matmul_bf16.mlir", |
| "iree_uk_amdgpu_matmul_f16.mlir", |
| "iree_uk_amdgpu_matmul_f8.mlir", |
| ], |
| cfg = "//compiler:lit.cfg.py", |
| tools = [ |
| "//tools:iree-opt", |
| ], |
| ) |