Open
Conversation
…en if it's set, make an extra call here to heir_translate and cc_library for the debug code, and then include that new cc_library as a dependency of the cc_library target.
f3c6e53 to
29533bc
Compare
asraa
approved these changes
Mar 2, 2026
Collaborator
asraa
left a comment
There was a problem hiding this comment.
overall looks great! thank you! i just have some very minor suggestions
| @@ -40,8 +42,8 @@ def openfhe_lib( | |||
| generated_cc_filename = "%s_lib.inc.cc" % name | |||
| heir_opt_name = "%s_heir_opt" % name | |||
| generated_heir_opt_name = "%s_heir_opt.mlir" % name | |||
| heir_translate_cc_flags = heir_translate_flags + ["--emit-openfhe-pke", "--openfhe-include-type=source-relative"] | |||
| heir_translate_h_flags = heir_translate_flags + ["--emit-openfhe-pke-header", "--openfhe-include-type=source-relative"] | |||
| generated_debug_h_filename = "%s_debug_helper.h" % name | |||
Collaborator
There was a problem hiding this comment.
small nit: the generated_debug_(h/cc)_filename can be moved within the if block
| @@ -62,6 +64,61 @@ def openfhe_lib( | |||
| else: | |||
| generated_heir_opt_name = mlir_src | |||
|
|
|||
| if generate_debug_helper: | |||
Collaborator
There was a problem hiding this comment.
optional: but there's a bunch of repetition of adding the source-relative flag, and so you could do that at once at the start, and avoid doing that for each flag
heir_translate_source_relative_flags = heir_translate_flags + ["--openfhe-include-type=source-relative"]
cc_lib_target = cc_lib_target_name
if not cc_lib_target:
cc_lib_target = "_heir_%s" % name
pybind_target = pybind_target_name
if not pybind_target:
pybind_target = "_heir_%s" % name
if heir_opt_flags:
heir_opt(
name = heir_opt_name,
src = mlir_src,
pass_flags = heir_opt_flags,
generated_filename = generated_heir_opt_name,
data = data,
)
else:
generated_heir_opt_name = mlir_src
if generate_debug_helper:
generated_debug_h_filename = "%s_debug_helper.h" % name
generated_debug_cc_filename = "%s_debug_helper.cc" % name
heir_translate_debug_header_flags = heir_translate_source_relative_flags + [
"--emit-openfhe-pke-debug-header",
]
debug_header_codegen_target = name + ".heir_debug_h"
heir_translate(
name = debug_header_codegen_target,
src = generated_heir_opt_name,
pass_flags = heir_translate_debug_header_flags,
generated_filename = generated_debug_h_filename,
)
heir_translate_source_relative_flags = heir_translate_source_relative_flags + [
"--openfhe-debug-helper-include-path=%s" % generated_debug_h_filename,
]
heir_translate_debug_flags = heir_translate_source_relative_flags + [
"--emit-openfhe-pke-debug",
]
cc_debug_codegen_target = name + ".heir_debug_cc"
heir_translate(
name = cc_debug_codegen_target,
src = generated_heir_opt_name,
pass_flags = heir_translate_debug_flags,
generated_filename = generated_debug_cc_filename,
)
debug_lib_target = "%s_debug_helper_lib" % name
cc_library(
name = debug_lib_target,
srcs = [generated_debug_cc_filename],
hdrs = [generated_debug_h_filename],
deps = deps + ["@openfhe//:pke"],
tags = tags,
data = data,
copts = OPENMP_COPTS,
linkopts = OPENMP_LINKOPTS,
**kwargs
)
deps = deps + [debug_lib_target]
heir_translate_cc_flags = heir_translate_source_relative_flags + ["--emit-openfhe-pke"]
heir_translate_h_flags = heir_translate_source_relative_flags + ["--emit-openfhe-pke-header"]
| @@ -0,0 +1,16 @@ | |||
| load("@heir//tests/Examples/openfhe:test.bzl", "openfhe_end_to_end_test") | |||
Collaborator
There was a problem hiding this comment.
I think it would be fine to place these inside dot_product_8_debug as well
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a new boolean generate_debug_helper option to openfhe_lib. if it's true, it makes an extra call to heir_translate and cc_library for the debug code, and includes that new cc_library as a dependency of the cc_library target. This new option is passed through openfhe_end_to_end_test and a new test added that sets it.
followup to openfhe default debug helper emitter in #2679, related to #1485