-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix up CMakeLists and reorganize some code locations
Summary: This diff cleans up CMakeFiles and reorganizes some of the code directories. Archetecture-specific kernel code remains in experimental/kernels/cpu/aarch64. This is not changed. Code related to ops (parallel.h, memory.h, "high-level" op interface, examples/torch_custom_op, etc) is moved to experimental/ops. The example code that builds the custom ops for ATen/ExecuTorch (experimental/kernels/cpu/linear/examples/torch_custom_op) is moved out of examples and into a more descriptive directory: experimental/ops/linear/linear_a8wxdq_op. These are the kernels that will be used in torchchat initially. The "high-level" op interface is in ops/linear/channelwise_8bit_activation_groupwise_lowbit_weight.h. A library for it is defined in the CMakeFiles.txt. It uses no templates and is not specific to the universal kernels and can be used with KleidiAI kernels. The ops in experimental/ops/linear/linear_a8wxdq_op use the high-level library and the universal kernels in experimental/kernels/cpu/aarch64 to define custom ops. Finally, there is a CMakeLists at the top-level directory experimental. The script build_torchao_ops.sh builds the torchao_ops for different platforms: ``` sh build_torchao_ops.sh ATEN ``` For ExecuTorch, you must define the environment variables EXECUTORCH_INCLUDE_DIRS and EXECUTORCH_LIBRARIES manually before calling: ``` EXECUTORCH_INCLUDE_DIRS=$HOME EXECUTORCH_LIBRARIES=$HOME/executorch/cmake-out/lib/libexecutorch_no_prim_ops.a sh build_torchao_ops.sh EXECUTORCH ``` Reviewed By: digantdesai Differential Revision: D62711903
- Loading branch information
1 parent
d267622
commit 9a768ab
Showing
44 changed files
with
521 additions
and
431 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
project(torchao) | ||
|
||
cmake_minimum_required(VERSION 3.19) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
if (NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE Release) | ||
endif() | ||
|
||
|
||
# Source root directory for torchao/experimental | ||
if(NOT TORCHAO_ROOT) | ||
set(TORCHAO_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) | ||
endif() | ||
|
||
if(NOT TORCHAO_INCLUDE_DIRS) | ||
set(TORCHAO_INCLUDE_DIRS ${TORCHAO_ROOT}/../..) | ||
endif() | ||
|
||
if (NOT TORCHAO_PARALLEL_BACKEND) | ||
if (TORCHAO_OP_TARGET STREQUAL "ATEN") | ||
set(TORCHAO_PARALLEL_BACKEND "ATEN_OPENMP") | ||
elseif(TORCHAO_OP_TARGET STREQUAL "EXECUTORCH") | ||
set(TORCHAO_PARALLEL_BACKEND "PTHREADPOOL") | ||
else() | ||
message(TORCHAO_PARALLEL_BACKEND "TORCHAO_PARALLEL_BACKEND is not set. Please set it directly or set TORCHAO_OP_TARGET to get a default.") | ||
endif() | ||
endif() | ||
|
||
include(CMakePrintHelpers) | ||
|
||
add_compile_options("-Wall" "-Werror") | ||
|
||
include(CMakePrintHelpers) | ||
message("TORCHAO_INCLUDE_DIRS: ${TORCHAO_INCLUDE_DIRS}") | ||
include_directories(${TORCHAO_INCLUDE_DIRS}) | ||
|
||
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") | ||
# Defines target torchao_kernels_aarch64 | ||
add_subdirectory(${TORCHAO_ROOT}/kernels/cpu/aarch64) | ||
add_subdirectory(${TORCHAO_ROOT}/ops/linear) | ||
add_subdirectory(${TORCHAO_ROOT}/ops/linear/linear_a8wxdq_op) | ||
endif() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 0 additions & 57 deletions
57
torchao/experimental/kernels/cpu/linear/benchmarks/CMakeLists.txt
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
torchao/experimental/kernels/cpu/linear/examples/CMakeLists.txt
This file was deleted.
Oops, something went wrong.
58 changes: 0 additions & 58 deletions
58
torchao/experimental/kernels/cpu/linear/examples/torch_custom_op/CMakeLists.txt
This file was deleted.
Oops, something went wrong.
69 changes: 0 additions & 69 deletions
69
torchao/experimental/kernels/cpu/linear/examples/torch_custom_op/run_custom_op.py
This file was deleted.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
torchao/experimental/kernels/cpu/linear/tests/CMakeLists.txt
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
torchao/experimental/kernels/cpu/linear/tests/build_and_run_tests.sh
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
cmake_minimum_required(VERSION 3.19) | ||
|
||
include(${TORCHAO_ROOT}/Utils.cmake) | ||
|
||
add_library(torchao_ops_linear_${TORCHAO_PARALLEL_BACKEND} STATIC channelwise_8bit_activation_groupwise_lowbit_weight.cpp) | ||
target_link_torchao_parallel_backend(torchao_ops_linear_${TORCHAO_PARALLEL_BACKEND} "${TORCHAO_PARALLEL_BACKEND}") |
Oops, something went wrong.