1
1
load ("@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
- )
39
2
40
3
def define_common_targets ():
41
4
"""Defines targets that should be shared between fbcode and xplat.
42
5
43
6
The directory containing this targets.bzl file should also contain both
44
7
TARGETS and BUCK files that call this function.
45
8
"""
46
-
47
9
runtime .python_library (
48
10
name = "llama_custom_ops_aot_lib" ,
49
11
srcs = [
@@ -58,71 +20,54 @@ def define_common_targets():
58
20
],
59
21
)
60
22
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
-
94
23
runtime .cxx_library (
95
- name = "sdpa " ,
24
+ name = "custom_ops " ,
96
25
srcs = ["op_sdpa.cpp" ],
97
- deps = [
26
+ exported_headers = ["op_sdpa.h" ],
27
+ exported_deps = [
98
28
"//executorch/runtime/kernel:kernel_includes" ,
99
29
"//executorch/kernels/portable/cpu:scalar_utils" ,
100
30
"//executorch/kernels/optimized:libblas" ,
101
31
"//executorch/kernels/optimized:libvec" ,
32
+ "//executorch/extension/kernel_util:kernel_util" ,
102
33
"//executorch/extension/parallel:thread_parallel" ,
103
34
"//executorch/backends/xnnpack/threadpool:threadpool" ,
104
35
],
105
- compiler_flags = ["-Wno-missing-prototypes" ],
36
+ compiler_flags = ["-Wno-missing-prototypes" , "-Wno-global-constructors" ],
106
37
visibility = [
107
38
"//executorch/..." ,
108
39
"//executorch/examples/models/llama2/custom_ops/..." ,
109
40
"@EXECUTORCH_CLIENTS" ,
110
41
],
42
+ # @lint-ignore BUCKLINT link_whole
43
+ link_whole = True ,
111
44
force_static = True ,
112
45
)
113
46
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/..." ],
116
53
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" ,
120
58
],
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" ,
125
72
],
126
- define_static_targets = True ,
127
73
)
128
- define_tests ()
0 commit comments