Skip to content

Commit bad68c7

Browse files
committed
Update on "[Executorch][BE] Rename sdpa_with_kv_cache.py to custom_ops.py"
Because now we have more than sdpa_with_kv_cache in it Differential Revision: [D66269486](https://our.internmc.facebook.com/intern/diff/D66269486/) [ghstack-poisoned]
2 parents 478978c + 83cbdf6 commit bad68c7

File tree

62 files changed

+1501
-453
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1501
-453
lines changed

.github/scripts/extract_benchmark_results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def main() -> None:
451451
continue
452452

453453
output_dir = os.path.join(args.output_dir, schema)
454-
os.mkdir(output_dir)
454+
os.makedirs(output_dir, exist_ok=True)
455455

456456
output_file = os.path.basename(args.artifacts)
457457
with open(f"{output_dir}/{output_file}", "w") as f:

CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,6 @@ option(EXECUTORCH_BUILD_EXTENSION_TENSOR "Build the Tensor extension" OFF)
200200

201201
option(EXECUTORCH_BUILD_EXTENSION_TRAINING "Build the training extension" OFF)
202202

203-
option(EXECUTORCH_BUILD_GTESTS "Build googletest based test binaries" OFF)
204-
205203
option(EXECUTORCH_BUILD_MPS "Build the MPS backend" OFF)
206204

207205
option(EXECUTORCH_BUILD_NEURON "Build the backends/mediatek directory" OFF)
@@ -216,6 +214,8 @@ option(EXECUTORCH_BUILD_KERNELS_QUANTIZED "Build the quantized kernels" OFF)
216214

217215
option(EXECUTORCH_BUILD_DEVTOOLS "Build the ExecuTorch Developer Tools")
218216

217+
option(EXECUTORCH_BUILD_TESTS "Build CMake-based unit tests" OFF)
218+
219219
option(EXECUTORCH_NNLIB_OPT "Build Cadence backend Hifi nnlib kernel" OFF)
220220

221221
option(EXECUTORCH_CADENCE_CPU_RUNNER "Build Cadence backend CPU runner" OFF)
@@ -330,6 +330,10 @@ if(EXECUTORCH_BUILD_PTHREADPOOL)
330330
)
331331
endif()
332332

333+
if(EXECUTORCH_BUILD_TESTS)
334+
include(CTest)
335+
endif()
336+
333337
if(NOT PYTHON_EXECUTABLE)
334338
resolve_python_executable()
335339
endif()
@@ -625,7 +629,7 @@ cmake_dependent_option(
625629
)
626630

627631
# Add googletest if any test targets should be built
628-
if(EXECUTORCH_BUILD_GTESTS)
632+
if(BUILD_TESTING)
629633
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third-party/googletest)
630634
endif()
631635

@@ -829,5 +833,7 @@ if(EXECUTORCH_BUILD_VULKAN)
829833
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/vulkan)
830834
endif()
831835

836+
include(Test.cmake)
837+
832838
# Print all summary
833839
executorch_print_configuration_summary()

Test.cmake

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
#
8+
# A helper CMake file to trigger C++ unit tests.
9+
#
10+
11+
if(BUILD_TESTING)
12+
# This contains the list of tests which are always built
13+
add_subdirectory(extension/evalue_util/test)
14+
add_subdirectory(extension/kernel_util/test)
15+
add_subdirectory(extension/memory_allocator/test)
16+
add_subdirectory(extension/parallel/test)
17+
add_subdirectory(extension/pytree/test)
18+
add_subdirectory(kernels/portable/cpu/util/test)
19+
add_subdirectory(kernels/prim_ops/test)
20+
add_subdirectory(kernels/test)
21+
add_subdirectory(runtime/core/exec_aten/testing_util/test)
22+
add_subdirectory(runtime/core/exec_aten/util/test)
23+
add_subdirectory(runtime/core/portable_type/test)
24+
add_subdirectory(runtime/core/test)
25+
add_subdirectory(runtime/executor/test)
26+
add_subdirectory(runtime/kernel/test)
27+
add_subdirectory(runtime/platform/test)
28+
add_subdirectory(test/utils)
29+
endif()

backends/arm/_passes/arm_pass_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def get_node_arg(args: list | dict, key: int | str | type, default_value=None):
156156
f"Out of bounds index {key} for getting value in args (of size {len(args)})"
157157
)
158158
elif isinstance(key, str):
159-
return args.get(key, default_value)
159+
return args.get(key, default_value) # pyre-ignore[16]
160160
elif isclass(key):
161161
for arg in args:
162162
if isinstance(arg, key):

backends/arm/_passes/keep_dims_false_to_squeeze_pass.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,17 @@ def call(self, graph_module: torch.fx.GraphModule):
6464
continue
6565

6666
sum_node = cast(torch.fx.Node, node)
67-
keep_dim = get_node_arg(sum_node.args, keep_dim_index, False)
67+
keep_dim = get_node_arg(
68+
# pyre-ignore[6]
69+
sum_node.args,
70+
keep_dim_index,
71+
False,
72+
)
6873

6974
if keep_dim:
7075
continue
7176

72-
dim_list = get_node_arg(sum_node.args, 1, [0])
77+
dim_list = get_node_arg(sum_node.args, 1, [0]) # pyre-ignore[6]
7378

7479
# Add keep_dim = True arg to sum node.
7580
set_node_arg(sum_node, 2, True)

backends/arm/operator_support/to_copy_support.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ class ToCopySupported(SupportedTOSAOperatorCheck):
3333

3434
@staticmethod
3535
def _merge_supported_types(
36-
dtypes1: SupportedTypeDict, dtypes2: SupportedTypeDict
36+
# pyre-ignore[11]
37+
dtypes1: SupportedTypeDict,
38+
dtypes2: SupportedTypeDict,
3739
) -> SupportedTypeDict:
3840
merged_dtypes = dtypes1
3941
for k, v in dtypes2.items():
@@ -92,7 +94,7 @@ def is_node_supported(self, node: fx.Node, tosa_spec: TosaSpecification) -> bool
9294
if input_dtype not in supported_dtypes:
9395
logger.info(
9496
f"Input dtype {input_val.dtype} is not supported in "
95-
f"{node.target.name()}."
97+
f"{node.target.name()}." # pyre-ignore[16]
9698
)
9799
return False
98100

@@ -102,7 +104,7 @@ def is_node_supported(self, node: fx.Node, tosa_spec: TosaSpecification) -> bool
102104
if output_val.dtype not in supported_dtypes[input_dtype]:
103105
logger.info(
104106
f"Output dtype {output_val.dtype} is not supported in "
105-
f"{node.target.name()} for input dtype {input_dtype}. "
107+
f"{node.target.name()} for input dtype {input_dtype}. " # pyre-ignore[16]
106108
f"Supported output types: "
107109
f"{''.join(str(t) for t in supported_dtypes[input_dtype])}"
108110
)
@@ -113,7 +115,7 @@ def is_node_supported(self, node: fx.Node, tosa_spec: TosaSpecification) -> bool
113115
if node.kwargs["memory_format"] in (torch.preserve_format,):
114116
logger.info(
115117
f"Argument 'memory_format' is not supported for "
116-
f"{node.target.name()} right now."
118+
f"{node.target.name()} right now." # pyre-ignore[16]
117119
)
118120
return False
119121

backends/cadence/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ include(${EXECUTORCH_ROOT}/build/Utils.cmake)
2323

2424
# Let files say "include <executorch/path/to/header.h>".
2525
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
26-
set(TARGET_DIR reference)
2726

2827
if(EXECUTORCH_CADENCE_CPU_RUNNER)
2928
include(${EXECUTORCH_ROOT}/build/Codegen.cmake)
@@ -61,6 +60,9 @@ if(EXECUTORCH_CADENCE_CPU_RUNNER)
6160
${_common_include_directories}
6261
)
6362

63+
set(TARGET_DIR reference)
64+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/kernels)
65+
6466
target_link_libraries(
6567
cadence_runner
6668
executorch

backends/cadence/aot/functions.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,41 @@
142142
- arg_meta: null
143143
kernel_name: torch::executor::where_out
144144

145+
- op: transpose_copy.int_out
146+
kernels:
147+
- arg_meta: null
148+
kernel_name: torch::executor::transpose_copy_int_out
149+
150+
- op: eq.Scalar_out
151+
kernels:
152+
- arg_meta: null
153+
kernel_name: torch::executor::eq_scalar_out
154+
155+
- op: logical_not.out
156+
kernels:
157+
- arg_meta: null
158+
kernel_name: torch::executor::logical_not_out
159+
160+
- op: any.out
161+
kernels:
162+
- arg_meta: null
163+
kernel_name: torch::executor::any_out
164+
165+
- op: native_group_norm.out
166+
kernels:
167+
- arg_meta: null
168+
kernel_name: torch::executor::native_group_norm_out
169+
170+
- op: sum.IntList_out
171+
kernels:
172+
- arg_meta: null
173+
kernel_name: torch::executor::sum_dim_out
174+
175+
- op: select_copy.int_out
176+
kernels:
177+
- arg_meta: null
178+
kernel_name: torch::executor::select_copy_int_out
179+
145180
# custom ops
146181
- func: cadence::quantize_per_tensor.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)
147182
variants: function
@@ -183,3 +218,18 @@
183218
kernels:
184219
- arg_meta: null
185220
kernel_name: impl::reference::quantized_matmul_out
221+
222+
- func: cadence::quantized_linear.per_tensor_out(Tensor src, Tensor weight, Tensor bias, SymInt src_zero_point, SymInt weight_zero_point, SymInt out_multiplier, SymInt out_shift, SymInt out_zero_point, Tensor? offset, *, Tensor(a!) out) -> Tensor(a!)
223+
kernels:
224+
- arg_meta: null
225+
kernel_name: impl::reference::quantized_linear_per_tensor_out
226+
227+
- func: cadence::im2row.out(Tensor input, int[2] kernel_size, int[2] dilation, int[2] padding, int[2] stride, Tensor in_zero_point, bool channel_last=False, *, Tensor(a!) out) -> Tensor(a!)
228+
kernels:
229+
- arg_meta: null
230+
kernel_name: impl::reference::im2row_out
231+
232+
- func: cadence::quantized_conv.per_tensor_out(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, int weight_zero_point, float bias_scale, float out_scale, int out_zero_point, int out_multiplier, int out_shift, bool channel_last=False, *, Tensor(a!) out) -> Tensor(a!)
233+
kernels:
234+
- arg_meta: null
235+
kernel_name: impl::reference::quantized_conv_per_tensor_out

backends/cadence/reference/operators/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ set(_aten_ops__srcs
5555
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_expand_copy.cpp"
5656
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_gelu.cpp"
5757
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_empty.cpp"
58+
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_transpose_copy.cpp"
59+
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_eq.cpp"
60+
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_logical_not.cpp"
61+
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_any.cpp"
62+
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_native_group_norm.cpp"
63+
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_sum.cpp"
64+
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_select_copy.cpp"
65+
"${EXECUTORCH_ROOT}/kernels/portable/cpu/util/dtype_util.cpp"
66+
"${EXECUTORCH_ROOT}/kernels/portable/cpu/util/normalization_ops_util.cpp"
67+
"${EXECUTORCH_ROOT}/kernels/portable/cpu/util/select_copy_util.cpp"
5868
)
5969
add_library(aten_ops_cadence ${_aten_ops__srcs})
6070
target_link_libraries(aten_ops_cadence PUBLIC executorch)
@@ -78,6 +88,7 @@ add_library(
7888
"quantize_per_tensor.cpp"
7989
"dequantize_per_tensor.cpp"
8090
"quantized_matmul_out.cpp"
91+
"im2row_out.cpp"
8192
)
8293
target_include_directories(
8394
custom_ops PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}

0 commit comments

Comments
 (0)