File tree Expand file tree Collapse file tree 3 files changed +64
-2
lines changed Expand file tree Collapse file tree 3 files changed +64
-2
lines changed Original file line number Diff line number Diff line change @@ -48,9 +48,16 @@ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
4848 )
4949 if (TORCHAO_BUILD_EXECUTORCH_OPS)
5050 add_library (torchao_ops_executorch STATIC )
51- target_link_libraries (torchao_ops_executorch PRIVATE torchao_ops_linear_8bit_act_xbit_weight_executorch)
51+ target_link_libraries (torchao_ops_executorch PRIVATE
52+ torchao_ops_linear_8bit_act_xbit_weight_executorch
53+ torchao_ops_embedding_xbit_executorch
54+ )
5255 install (
53- TARGETS torchao_ops_executorch torchao_ops_linear_8bit_act_xbit_weight_executorch torchao_kernels_aarch64
56+ TARGETS
57+ torchao_ops_executorch
58+ torchao_kernels_aarch64
59+ torchao_ops_linear_8bit_act_xbit_weight_executorch
60+ torchao_ops_embedding_xbit_executorch
5461 EXPORT _targets
5562 DESTINATION lib
5663 )
Original file line number Diff line number Diff line change @@ -17,3 +17,20 @@ target_link_libraries(torchao_ops_embedding_xbit_aten PRIVATE torchao_kernels_aa
1717target_include_directories (torchao_ops_embedding_xbit_aten PRIVATE "${TORCH_INCLUDE_DIRS} " )
1818target_link_libraries (torchao_ops_embedding_xbit_aten PRIVATE "${TORCH_LIBRARIES} " )
1919target_compile_definitions (torchao_ops_embedding_xbit_aten PRIVATE USE_ATEN=1)
20+
21+ if (TORCHAO_BUILD_EXECUTORCH_OPS)
22+ # ExecuTorch package is not required, but EXECUTORCH_INCLUDE_DIRS and EXECUTORCH_LIBRARIES must
23+ # be defined and EXECUTORCH_LIBRARIES must include the following libraries installed by ExecuTorch:
24+ # libexecutorch.a
25+ # libextension_threadpool.a
26+ # libcpuinfo.a
27+ # libpthreadpool.a
28+ add_library (torchao_ops_embedding_xbit_executorch OBJECT
29+ op_embedding_xbit_executorch.cpp
30+ )
31+ target_link_torchao_parallel_backend(torchao_ops_embedding_xbit_executorch executorch)
32+ target_include_directories (torchao_ops_embedding_xbit_executorch PRIVATE "${EXECUTORCH_INCLUDE_DIRS} " )
33+ target_compile_definitions (torchao_ops_embedding_xbit_executorch PRIVATE USE_EXECUTORCH=1)
34+ target_link_libraries (torchao_ops_embedding_xbit_executorch PRIVATE "${EXECUTORCH_LIBRARIES} " )
35+ target_link_libraries (torchao_ops_embedding_xbit_executorch PRIVATE torchao_kernels_aarch64)
36+ endif ()
Original file line number Diff line number Diff line change 1+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2+ // All rights reserved.
3+ //
4+ // This source code is licensed under the license found in the
5+ // LICENSE file in the root directory of this source tree.
6+
7+ #include < torchao/experimental/ops/embedding_xbit/op_embedding_xbit-impl.h>
8+
9+ #define DEFINE_OP (weight_nbit ) \
10+ Tensor _op_out_##weight_nbit( \
11+ RuntimeContext& ctx, \
12+ const Tensor& packed_weight_qvals, \
13+ const Tensor& num_embeddings_tensor, \
14+ const Tensor& embedding_dim_tensor, \
15+ const Tensor& weight_scales, \
16+ const Tensor& weight_zeros, \
17+ const Tensor& indices, \
18+ Tensor& out) { \
19+ (void )ctx; \
20+ embedding_out_cpu<weight_nbit>( \
21+ packed_weight_qvals, \
22+ num_embeddings_tensor, \
23+ embedding_dim_tensor, \
24+ weight_scales, \
25+ weight_zeros, \
26+ indices, \
27+ out); \
28+ return out; \
29+ } \
30+ EXECUTORCH_LIBRARY ( \
31+ torchao, " _embedding_" #weight_nbit " bit.out" , _op_out_##weight_nbit)
32+
33+ DEFINE_OP(1 );
34+ DEFINE_OP (2 );
35+ DEFINE_OP (3 );
36+ DEFINE_OP (4 );
37+ DEFINE_OP (5 );
38+ DEFINE_OP (6 );
You can’t perform that action at this time.
0 commit comments