Skip to content

Commit

Permalink
Refactor convolution test suite (#24)
Browse files Browse the repository at this point in the history
Progress on #2.
This PR refactors, adds, and migrates conv2d e2e tests from the PRs
here: iree-org/iree#16849 and
iree-org/iree#18125

---------

Signed-off-by: erman-gurses <[email protected]>
  • Loading branch information
erman-gurses authored Oct 30, 2024
1 parent 26ee0c2 commit 15315f5
Show file tree
Hide file tree
Showing 54 changed files with 5,542 additions and 1 deletion.
21 changes: 21 additions & 0 deletions linalg_ops/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,26 @@ iree_cc_binary(
iree::vm::cc
)

iree_cc_binary(
NAME
iree-e2e-conv2d-test
SRCS
"iree-e2e-conv2d-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 @@ -123,3 +143,4 @@ include(iree_test_suites_native_test)
include(iree_test_suites_runner_test)

add_subdirectory(matmul)
add_subdirectory(convolution)
309 changes: 309 additions & 0 deletions linalg_ops/convolution/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,309 @@
# 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_nhwc_f16_hwcf_f16")
list(APPEND _DTYPES_AND_LAYOUTS "f16_nchw_f16_fchw_f16")
list(APPEND _DTYPES_AND_LAYOUTS "f16_nhwc_f16_hwcf_f32")
list(APPEND _DTYPES_AND_LAYOUTS "f16_nchw_f16_fchw_f32")
list(APPEND _DTYPES_AND_LAYOUTS "f32_nhwc_f32_hwcf_f32")
list(APPEND _DTYPES_AND_LAYOUTS "f32_nchw_f32_fchw_f32")

###############################################################################
#
# 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
conv2d_llvm-cpu_local-task_${_DTYPE_AND_LAYOUT}_${_SIZE}
TESTS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}.mlir"
CALLS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}_calls.mlir"
TEST_RUNNER
iree-test-suites_iree-e2e-conv2d-test
TARGET_BACKEND
"llvm-cpu"
DRIVER
"local-task"
COMPILER_FLAGS
RUNNER_FLAGS
LABELS
"hostonly"
"local"
)
endforeach()
endforeach()

###############################################################################
#
# CPU - Winograd 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
conv2d_winograd_llvm-cpu_local-task_${_DTYPE_AND_LAYOUT}_${_SIZE}
TESTS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}.mlir"
CALLS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}_calls.mlir"
TEST_RUNNER
iree-test-suites_iree-e2e-conv2d-test
TARGET_BACKEND
"llvm-cpu"
DRIVER
"local-task"
COMPILER_FLAGS
"--iree-preprocessing-pass-pipeline=builtin.module\(func.func\(iree-linalg-ext-convert-conv2d-to-winograd{replace-all-convs=true}\)\)"
RUNNER_FLAGS
LABELS
"hostonly"
"local"
TARGET_CPU_FEATURES_VARIANTS
"default"
)
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
conv2d_rocm_hip_${_DTYPE_AND_LAYOUT}_${_SIZE}
TESTS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}.mlir"
CALLS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}_calls.mlir"
TEST_RUNNER
iree-test-suites_iree-e2e-conv2d-test
TARGET_BACKEND
"rocm"
DRIVER
"hip"
COMPILER_FLAGS
"--iree-hip-target=${IREE_HIP_TEST_TARGET_CHIP}"
RUNNER_FLAGS
LABELS
)
endforeach()
endforeach()

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

foreach(_DTYPE_AND_LAYOUT IN LISTS _DTYPES_AND_LAYOUTS)
foreach(_SIZE IN LISTS _SIZES)
iree_test_suites_runner_test(
NAME
conv2d_winograd_rocm_hip_${_DTYPE_AND_LAYOUT}_${_SIZE}
TESTS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}.mlir"
CALLS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}_calls.mlir"
TEST_RUNNER
iree-test-suites_iree-e2e-conv2d-test
TARGET_BACKEND
"rocm"
DRIVER
"hip"
COMPILER_FLAGS
"--iree-preprocessing-pass-pipeline=builtin.module\(func.func\(iree-linalg-ext-convert-conv2d-to-winograd{replace-all-convs=true}\)\)"
"--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
conv2d_rocm_hip_${_DTYPE_AND_LAYOUT}_${_SIZE}
TESTS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}.mlir"
CALLS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}_calls.mlir"
TEST_RUNNER
iree-test-suites_iree-e2e-conv2d-test
TARGET_BACKEND
"rocm"
DRIVER
"hip"
COMPILER_FLAGS
"--iree-hip-target=${IREE_HIP_TEST_TARGET_CHIP}"
RUNNER_FLAGS
LABELS
)
endforeach()
endforeach()

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

foreach(_DTYPE_AND_LAYOUT IN LISTS _DTYPES_AND_LAYOUTS)
foreach(_SIZE IN LISTS _SIZES)
iree_test_suites_runner_test(
NAME
conv2d_winograd_rocm_hip_${_DTYPE_AND_LAYOUT}_${_SIZE}
TESTS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}.mlir"
CALLS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}_calls.mlir"
TEST_RUNNER
iree-test-suites_iree-e2e-conv2d-test
TARGET_BACKEND
"rocm"
DRIVER
"hip"
COMPILER_FLAGS
"--iree-preprocessing-pass-pipeline=builtin.module\(func.func\(iree-linalg-ext-convert-conv2d-to-winograd{replace-all-convs=true}\)\)"
"--iree-hip-target=${IREE_HIP_TEST_TARGET_CHIP}"
RUNNER_FLAGS
LABELS
)
endforeach()
endforeach()

endif()

# CPU and GPU tests for without Winograd
set(_DTYPES_AND_LAYOUTS)
list(APPEND _DTYPES_AND_LAYOUTS "i8_nhwc_i8_hwcf_i32")
list(APPEND _DTYPES_AND_LAYOUTS "i8_nchw_i8_fchw_i32")

###############################################################################
#
# 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
conv2d_llvm-cpu_local-task_${_DTYPE_AND_LAYOUT}_${_SIZE}
TESTS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}.mlir"
CALLS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}_calls.mlir"
TEST_RUNNER
iree-test-suites_iree-e2e-conv2d-test
TARGET_BACKEND
"llvm-cpu"
DRIVER
"local-task"
COMPILER_FLAGS
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
conv2d_rocm_hip_${_DTYPE_AND_LAYOUT}_${_SIZE}
TESTS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}.mlir"
CALLS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}_calls.mlir"
TEST_RUNNER
iree-test-suites_iree-e2e-conv2d-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
conv2d_rocm_hip_${_DTYPE_AND_LAYOUT}_${_SIZE}
TESTS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}.mlir"
CALLS_SRC
"generated/${_DTYPE_AND_LAYOUT}/conv2d_${_DTYPE_AND_LAYOUT}_${_SIZE}_calls.mlir"
TEST_RUNNER
iree-test-suites_iree-e2e-conv2d-test
TARGET_BACKEND
"rocm"
DRIVER
"hip"
COMPILER_FLAGS
"--iree-hip-target=${IREE_HIP_TEST_TARGET_CHIP}"
RUNNER_FLAGS
LABELS
)
endforeach()
endforeach()

endif()
Loading

0 comments on commit 15315f5

Please sign in to comment.