Skip to content

Commit 8efb1ae

Browse files
Daksh-Shamifacebook-github-bot
authored andcommitted
Add exception free quantized kernels (pytorch#14962)
Summary: Explicitly declaring generated libs with exception code off for quantized kernels as executorch does not use exceptions in general, and it can cause downstream errors. Detailed error is P1986979595 but the relevant part is: ``` buck-out/ABC/gen/fbsource/6e53edb0a9a0d828/xplat/executorch/kernels/quantized/__generated_lib_combined__/out/RegisterCodegenUnboxedKernelsEverything.cpp:77:44: error: exception handling disabled, use '-fexceptions' to enable 77 | } catch (const std::exception& ex) { | ``` This means the existing generated code uses exceptions in its code, so when we use these kernels with -fno-exceptions downstream, the build fails. After this diff, we can use the exception free kernels with 'no_exceptions' suffix -- `//xplat/executorch/kernels/quantized:generated_lib_no_exceptions` or `//xplat/executorch/kernels/quantized:generated_lib_aten_no_exceptions` as appropriate. We still have `//xplat/executorch/kernels/quantized:generated_lib` and `//xplat/executorch/kernels/quantized:generated_lib_aten` available, same as before, so no downstream side effects are expected. Reviewed By: swolchok Differential Revision: D84284541
1 parent 4ba2a66 commit 8efb1ae

File tree

1 file changed

+39
-34
lines changed

1 file changed

+39
-34
lines changed

kernels/quantized/targets.bzl

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -96,41 +96,46 @@ def define_common_targets():
9696
],
9797
)
9898

99-
executorch_generated_lib(
100-
name = "generated_lib" + aten_suffix,
101-
deps = [
102-
":quantized_operators" + aten_suffix,
103-
":all_quantized_ops",
104-
],
105-
custom_ops_yaml_target = ":quantized.yaml",
106-
custom_ops_aten_kernel_deps = [":quantized_operators_aten"] if aten_mode else [],
107-
custom_ops_requires_aot_registration = False,
108-
aten_mode = aten_mode,
109-
visibility = [
110-
"//executorch/...",
111-
"@EXECUTORCH_CLIENTS",
112-
],
113-
define_static_targets = True,
114-
)
99+
for support_exceptions in [True, False]:
100+
exception_suffix = "_no_exceptions" if not support_exceptions else ""
115101

116-
# On Windows we can only compile these two ops currently, so adding a
117-
# separate target for this.
118-
executorch_generated_lib(
119-
name = "q_dq_ops_generated_lib" + aten_suffix,
120-
custom_ops_yaml_target = ":quantized.yaml",
121-
kernel_deps = [
122-
"//executorch/kernels/quantized/cpu:op_quantize" + aten_suffix,
123-
"//executorch/kernels/quantized/cpu:op_dequantize" + aten_suffix,
124-
],
125-
aten_mode = aten_mode,
126-
deps = [
127-
":q_dq_ops",
128-
],
129-
visibility = [
130-
"//executorch/...",
131-
"@EXECUTORCH_CLIENTS",
132-
],
133-
)
102+
executorch_generated_lib(
103+
name = "generated_lib" + aten_suffix + exception_suffix,
104+
deps = [
105+
":quantized_operators" + aten_suffix,
106+
":all_quantized_ops",
107+
],
108+
custom_ops_yaml_target = ":quantized.yaml",
109+
custom_ops_aten_kernel_deps = [":quantized_operators_aten"] if aten_mode else [],
110+
custom_ops_requires_aot_registration = False,
111+
aten_mode = aten_mode,
112+
support_exceptions = support_exceptions,
113+
visibility = [
114+
"//executorch/...",
115+
"@EXECUTORCH_CLIENTS",
116+
],
117+
define_static_targets = True,
118+
)
119+
120+
# On Windows we can only compile these two ops currently, so adding a
121+
# separate target for this.
122+
executorch_generated_lib(
123+
name = "q_dq_ops_generated_lib" + aten_suffix + exception_suffix,
124+
custom_ops_yaml_target = ":quantized.yaml",
125+
kernel_deps = [
126+
"//executorch/kernels/quantized/cpu:op_quantize" + aten_suffix,
127+
"//executorch/kernels/quantized/cpu:op_dequantize" + aten_suffix,
128+
],
129+
aten_mode = aten_mode,
130+
deps = [
131+
":q_dq_ops",
132+
],
133+
support_exceptions = support_exceptions,
134+
visibility = [
135+
"//executorch/...",
136+
"@EXECUTORCH_CLIENTS",
137+
],
138+
)
134139

135140
runtime.python_library(
136141
name = "quantized_ops_lib",

0 commit comments

Comments
 (0)