Skip to content

Commit f6e22fb

Browse files
committed
[experimental][kleidi] compile-time preprocessor switch for kleidi tests
1 parent d4bb3ed commit f6e22fb

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

torchao/experimental/kernels/cpu/aarch64/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ FetchContent_MakeAvailable(kleidiai)
2020
CMAKE_DEPENDENT_OPTION(BUILD_KLEIDI "Download, build, and link against Arm KleidiAI library"
2121
OFF "CMAKE_SYSTEM_PROCESSOR STREQUAL \"arm64\"" ON)
2222

23-
add_compile_definitions("TORCHAO_ENABLE_KLEIDI=$<BOOL:${BUILD_KLEIDI}>")
24-
2523
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
2624
add_library(
2725
torchao_kernels_aarch64
@@ -31,6 +29,9 @@ if (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
3129
${TORCHAO_INCLUDE_DIRS}/torchao/experimental/kernels/cpu/aarch64/valpacking/interleave.cpp
3230
)
3331
if (BUILD_KLEIDI)
32+
# Temporarily exposing this to the parent scope until we wire
33+
# this up properly from the top level
34+
set(TORCHAO_ENABLE_KLEIDI ON PARENT_SCOPE)
3435
message(STATUS "Building with Kleidi")
3536
target_link_libraries(torchao_kernels_aarch64 PUBLIC kleidiai)
3637
endif()

torchao/experimental/kernels/cpu/aarch64/tests/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,15 @@ add_library(
3232
if(NOT TORCHAO_INCLUDE_DIRS)
3333
set(TORCHAO_INCLUDE_DIRS ${TORCHAO_LIBRARIES})
3434
endif()
35+
3536
add_subdirectory(${TORCHAO_LIBRARIES}/torchao/experimental/kernels/cpu/aarch64 ${CMAKE_CURRENT_BINARY_DIR}/torchao_kernels_aarch64)
3637

38+
# The TORCHAO_ENABLE_KLEIDI cmake variable should be set by `torchao_kernels_aarch64"
39+
# This is a temporary work around.
40+
if(TORCHAO_ENABLE_KLEIDI)
41+
add_compile_definitions(TORCHAO_ENABLE_KLEIDI)
42+
endif()
43+
3744
enable_testing()
3845

3946
add_executable(test_quantization test_quantization.cpp)

torchao/experimental/kernels/cpu/aarch64/tests/test_linear.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
#include <torchao/experimental/kernels/cpu/aarch64/linear/linear.h>
1515
#include <torchao/experimental/kernels/cpu/aarch64/tests/test_utils.h>
1616

17+
#ifdef TORCHAO_ENABLE_KLEIDI
1718
#include <torchao/experimental/kernels/cpu/aarch64/kleidi/kai_matmul_clamp_f32_qai8dxp1x8_qsi4c32p4x8_1x4x32_neon_dotprod.h>
1819
#include <torchao/experimental/kernels/cpu/aarch64/kleidi/kai_matmul_clamp_f32_qai8dxp1x8_qsi4c32p8x8_1x8x32_neon_dotprod.h>
20+
#endif
1921

2022
float kTol = 0.0001;
2123

@@ -354,9 +356,7 @@ TEST(
354356
}
355357
}
356358

357-
// #ifdef TORCHAO_ENABLE_KLEIDI
358-
// TODO: Wire up the the compile defination for TORCHAO_ENABLE_KLEIDI
359-
359+
#ifdef TORCHAO_ENABLE_KLEIDI
360360
template <bool has_bias, bool has_clamp>
361361
void test_kai_matmul_clamp_f32_qai8dxp1x8_qsi4c32p4x8_1x4x32_neon_dotprod(
362362
int m,
@@ -585,5 +585,5 @@ TEST(
585585
true /*has_clamp*/>(
586586
/*m=*/11, /*k=*/128, /*n=*/182, /*group_size=*/128);
587587
}
588-
// #endif // defined(TORCHAO_ENABLE_KLEIDI)
588+
#endif // TORCHAO_ENABLE_KLEIDI
589589
#endif // defined(__aarch64__) || defined(__ARM_NEON)

0 commit comments

Comments
 (0)