Skip to content

determine fht_avx.c/fht_neon.c based on CMake target processor #8346

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

Merged
merged 35 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 1 addition & 4 deletions build/cmake_deps.toml
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,7 @@ buck_targets = [
"//extension/llm/custom_ops:custom_ops",
]
filters = [
# Second clause is to pick up fht_neon.c/fht_avx.c from FFHT. TODO:
# remove filters and patch extract_sources.py's Buck query to fetch
# srcs; presumably filters is here to remove .h files.
"(.cpp$)|(fht.*\\.c$)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comment is irrelevant since you are removing it, but this second regex seemed wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks right to me. Dot is a regex metacharacter so we need to escape it with a backslash. Backslash is a string metacharacter so we need to escape it with a second backslash. Or is there a different problem I missed entirely?

".cpp$",
]
excludes = [
"^codegen",
Expand Down
16 changes: 16 additions & 0 deletions extension/llm/custom_ops/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ list(APPEND custom_ops_libs cpuinfo)
list(APPEND custom_ops_libs cpublas)
list(APPEND custom_ops_libs eigen_blas)

if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64|armv7)$")
list(APPEND _custom_ops__srcs
"extension/llm/custom_ops/spinquant/third-party/FFHT/fht_neon.c"
)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
list(APPEND _custom_ops__srcs
"extension/llm/custom_ops/spinquant/third-party/FFHT/fht_avx.c"
)
else()
message(
FATAL_ERROR
"Unsupported CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}. (If \
32-bit x86, try using fht_avx.c and send a PR if it works!)"
)
endif()

list(TRANSFORM _custom_ops__srcs PREPEND "${EXECUTORCH_ROOT}/")

if(NOT EXECUTORCH_BUILD_XNNPACK)
Expand Down
30 changes: 30 additions & 0 deletions extension/llm/custom_ops/spinquant/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# @generated by test/utils/generate_gtest_cmakelists.py
#
# This file should be formatted with
# ~~~
# cmake-format -i CMakeLists.txt
# ~~~
# It should also be cmake-lint clean.
#

cmake_minimum_required(VERSION 3.19)

set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../../..)

include(${EXECUTORCH_ROOT}/build/Test.cmake)

set(_test_srcs
fast_hadamard_transform_test.cpp fast_hadamard_transform_test_impl.cpp
op_fast_hadamard_transform_test.cpp
)

et_cxx_test(
extension_llm_custom_ops_spinquant_test SOURCES ${_test_srcs} EXTRA_LIBS
custom_ops
)
11 changes: 11 additions & 0 deletions test/utils/OSSTestConfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
{ "tests": [
{
"directory": "extension/llm/custom_ops/spinquant/test",
"sources": [
"fast_hadamard_transform_test.cpp",
"fast_hadamard_transform_test_impl.cpp",
"op_fast_hadamard_transform_test.cpp"
],
"additional_libs": [
"custom_ops"
]
},
{
"directory": "extension/data_loader/test",
"sources": [
Expand Down
Loading