11load ("@fbsource//xplat/executorch/build:runtime_wrapper.bzl" , "runtime" )
2- load ("@fbsource//xplat/executorch/codegen:codegen.bzl" , "et_operator_library" , "executorch_generated_lib" )
3- load ("@fbsource//xplat/executorch/kernels/test:util.bzl" , "codegen_function_header_wrapper" )
4-
5- def define_tests ():
6- codegen_function_header_wrapper ("executorch/examples/models/llama2/custom_ops" , "custom_ops" )
7-
8- # In the long run we should really have aten variant available as well
9- deps = [":function_header_wrapper_custom_ops" ]
10- generated_lib_and_op_deps = [
11- ":custom_ops" ,
12- ":sdpa" ,
13- ":custom_ops_headers" ,
14- ]
15- runtime .cxx_test (
16- name = "op_sdpa_test" ,
17- srcs = [
18- "op_sdpa_test.cpp" ,
19- ],
20- visibility = ["//executorch/..." ],
21- deps = [
22- "//executorch/runtime/core/exec_aten:lib" ,
23- "//executorch/runtime/core/exec_aten/testing_util:tensor_util" ,
24- "//executorch/kernels/test:test_util" ,
25- ] + generated_lib_and_op_deps + deps ,
26- )
27- runtime .cxx_test (
28- name = "op_sdpa_with_kv_cache_test" ,
29- srcs = [
30- "op_sdpa_with_kv_cache_test.cpp" ,
31- ],
32- visibility = ["//executorch/..." ],
33- deps = [
34- "//executorch/runtime/core/exec_aten:lib" ,
35- "//executorch/runtime/core/exec_aten/testing_util:tensor_util" ,
36- "//executorch/kernels/test:test_util" ,
37- ] + generated_lib_and_op_deps + deps ,
38- )
392
403def define_common_targets ():
414 """Defines targets that should be shared between fbcode and xplat.
425
436 The directory containing this targets.bzl file should also contain both
447 TARGETS and BUCK files that call this function.
458 """
46-
479 runtime .python_library (
4810 name = "llama_custom_ops_aot_lib" ,
4911 srcs = [
@@ -58,71 +20,54 @@ def define_common_targets():
5820 ],
5921 )
6022
61- runtime .export_file (
62- name = "custom_ops.yaml" ,
63- visibility = [
64- "//executorch/..." ,
65- "@EXECUTORCH_CLIENTS" ,
66- ],
67- )
68-
69- # ~~~ START of custom ops 1 `my_ops::mul3` library definitions ~~~
70- et_operator_library (
71- name = "sdpa_op" ,
72- ops = [
73- "llama::sdpa.out" ,
74- ],
75- define_static_targets = True ,
76- visibility = [
77- "//executorch/codegen/..." ,
78- "@EXECUTORCH_CLIENTS" ,
79- ],
80- )
81-
82- et_operator_library (
83- name = "sdpa_with_kv_cache" ,
84- ops = [
85- "llama::sdpa_with_kv_cache.out" ,
86- ],
87- define_static_targets = True ,
88- visibility = [
89- "//executorch/codegen/..." ,
90- "@EXECUTORCH_CLIENTS" ,
91- ],
92- )
93-
9423 runtime .cxx_library (
95- name = "sdpa " ,
24+ name = "custom_ops " ,
9625 srcs = ["op_sdpa.cpp" ],
97- deps = [
26+ exported_headers = ["op_sdpa.h" ],
27+ exported_deps = [
9828 "//executorch/runtime/kernel:kernel_includes" ,
9929 "//executorch/kernels/portable/cpu:scalar_utils" ,
10030 "//executorch/kernels/optimized:libblas" ,
10131 "//executorch/kernels/optimized:libvec" ,
32+ "//executorch/extension/kernel_util:kernel_util" ,
10233 "//executorch/extension/parallel:thread_parallel" ,
10334 "//executorch/backends/xnnpack/threadpool:threadpool" ,
10435 ],
105- compiler_flags = ["-Wno-missing-prototypes" ],
36+ compiler_flags = ["-Wno-missing-prototypes" , "-Wno-global-constructors" ],
10637 visibility = [
10738 "//executorch/..." ,
10839 "//executorch/examples/models/llama2/custom_ops/..." ,
10940 "@EXECUTORCH_CLIENTS" ,
11041 ],
42+ # @lint-ignore BUCKLINT link_whole
43+ link_whole = True ,
11144 force_static = True ,
11245 )
11346
114- executorch_generated_lib (
115- name = "custom_ops" ,
47+ runtime .cxx_test (
48+ name = "op_sdpa_test" ,
49+ srcs = [
50+ "op_sdpa_test.cpp" ,
51+ ],
52+ visibility = ["//executorch/..." ],
11653 deps = [
117- ":sdpa_op" ,
118- ":sdpa_with_kv_cache" ,
119- ":sdpa" ,
54+ "//executorch/runtime/core/exec_aten:lib" ,
55+ "//executorch/runtime/core/exec_aten/testing_util:tensor_util" ,
56+ "//executorch/kernels/test:test_util" ,
57+ ":custom_ops" ,
12058 ],
121- custom_ops_yaml_target = ":custom_ops.yaml" ,
122- visibility = [
123- "//executorch/..." ,
124- "@EXECUTORCH_CLIENTS" ,
59+ )
60+
61+ runtime .cxx_test (
62+ name = "op_sdpa_with_kv_cache_test" ,
63+ srcs = [
64+ "op_sdpa_with_kv_cache_test.cpp" ,
65+ ],
66+ visibility = ["//executorch/..." ],
67+ deps = [
68+ "//executorch/runtime/core/exec_aten:lib" ,
69+ "//executorch/runtime/core/exec_aten/testing_util:tensor_util" ,
70+ "//executorch/kernels/test:test_util" ,
71+ ":custom_ops" ,
12572 ],
126- define_static_targets = True ,
12773 )
128- define_tests ()
0 commit comments