Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Attention Test Suite #37

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions linalg_ops/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,26 @@ iree_cc_binary(
iree::vm::cc
)

iree_cc_binary(
NAME
iree-e2e-attention-test
SRCS
"iree-e2e-attention-test.cc"
DEPS
::test_utils
iree::base
iree::base::internal
iree::base::internal::cpu
iree::base::internal::flags
iree::base::internal::path
iree::hal
iree::modules::hal
iree::tooling::context_util
iree::tooling::device_util
iree::vm
iree::vm::cc
)

#-------------------------------------------------------------------------------
# Tests
#-------------------------------------------------------------------------------
Expand All @@ -144,3 +164,4 @@ include(iree_test_suites_runner_test)

add_subdirectory(matmul)
add_subdirectory(convolution)
add_subdirectory(attention)
113 changes: 113 additions & 0 deletions linalg_ops/attention/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Copyright 2024 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

# TODO(scotttodd): add filtering here, in the helper functions, or in ctest to
# choose which tests to compile and run

set(_SIZES)
list(APPEND _SIZES "large")
list(APPEND _SIZES "medium")
list(APPEND _SIZES "small")


set(_DTYPES_AND_LAYOUTS)
list(APPEND _DTYPES_AND_LAYOUTS "f16_f16_f16_f16")

###############################################################################
#
# CPU - llvm-cpu on local-task, default flags.
#
###############################################################################

foreach(_DTYPE_AND_LAYOUT IN LISTS _DTYPES_AND_LAYOUTS)
foreach(_SIZE IN LISTS _SIZES)
iree_test_suites_runner_test(
NAME
attention_llvm-cpu_local-task_${_DTYPE_AND_LAYOUT}_${_SIZE}
TESTS_SRC
"generated/${_DTYPE_AND_LAYOUT}/attention_${_DTYPE_AND_LAYOUT}_${_SIZE}.mlir"
CALLS_SRC
"generated/${_DTYPE_AND_LAYOUT}/attention_${_DTYPE_AND_LAYOUT}_${_SIZE}_calls.mlir"
TEST_RUNNER
iree-test-suites_iree-e2e-attention-test
TARGET_BACKEND
"llvm-cpu"
DRIVER
"local-task"
COMPILER_FLAGS
"--iree-llvmcpu-target-cpu=host"
RUNNER_FLAGS
LABELS
"hostonly"
"local"
)
endforeach()
endforeach()

###############################################################################
#
# GPU - ROCm/HIP, CDNA(gfx9).
#
###############################################################################

# To distinguish between CDNA(gfx9) and RDNA3(gfx11)
if(IREE_HIP_TEST_TARGET_CHIP MATCHES "^gfx9")

foreach(_DTYPE_AND_LAYOUT IN LISTS _DTYPES_AND_LAYOUTS)
foreach(_SIZE IN LISTS _SIZES)
iree_test_suites_runner_test(
NAME
attention_rocm_hip_${_DTYPE_AND_LAYOUT}_${_SIZE}
TESTS_SRC
"generated/${_DTYPE_AND_LAYOUT}/attention_${_DTYPE_AND_LAYOUT}_${_SIZE}.mlir"
CALLS_SRC
"generated/${_DTYPE_AND_LAYOUT}/attention_${_DTYPE_AND_LAYOUT}_${_SIZE}_calls.mlir"
TEST_RUNNER
iree-test-suites_iree-e2e-attention-test
TARGET_BACKEND
"rocm"
DRIVER
"hip"
COMPILER_FLAGS
"--iree-hip-target=${IREE_HIP_TEST_TARGET_CHIP}"
RUNNER_FLAGS
LABELS
)
endforeach()
endforeach()

###############################################################################
#
# GPU - ROCm/HIP, CDNA(gfx11)
#
###############################################################################

elseif(IREE_HIP_TEST_TARGET_CHIP MATCHES "^gfx11")

foreach(_DTYPE_AND_LAYOUT IN LISTS _DTYPES_AND_LAYOUTS)
foreach(_SIZE IN LISTS _SIZES)
iree_test_suites_runner_test(
NAME
attention_rocm_hip_${_DTYPE_AND_LAYOUT}_${_SIZE}
TESTS_SRC
"generated/${_DTYPE_AND_LAYOUT}/attention_${_DTYPE_AND_LAYOUT}_${_SIZE}.mlir"
CALLS_SRC
"generated/${_DTYPE_AND_LAYOUT}/attention_${_DTYPE_AND_LAYOUT}_${_SIZE}_calls.mlir"
TEST_RUNNER
iree-test-suites_iree-e2e-attention-test
TARGET_BACKEND
"rocm"
DRIVER
"hip"
COMPILER_FLAGS
"--iree-hip-target=${IREE_HIP_TEST_TARGET_CHIP}"
RUNNER_FLAGS
LABELS
)
endforeach()
endforeach()

endif()
Loading