forked from google/heir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a bazel file for HEIR-Jaxite path
PiperOrigin-RevId: 683692013
- Loading branch information
1 parent
7f407b9
commit 0f48904
Showing
4 changed files
with
63 additions
and
46 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,7 @@ filegroup( | |
"*.v", | ||
]), | ||
) | ||
|
||
exports_files([ | ||
"*.v", | ||
]) |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"""A macro providing an end-to-end library for jaxite codegen.""" | ||
|
||
load("@heir//tools:heir-opt.bzl", "heir_opt") | ||
load("@heir//tools:heir-translate.bzl", "heir_translate") | ||
load("@rules_python//python:py_library.bzl", "py_library") | ||
|
||
def fhe_jaxite_lib(name, mlir_src, entry_function_flag = "", py_lib_target_name = "", tags = [], deps = [], **kwargs): | ||
"""A rule for generating Jaxite code. | ||
Args: | ||
name: The name of the py_test target and the generated .cc file basename. | ||
mlir_src: The source mlir file to run through heir-translate. | ||
entry_function_flag: Flags for entry function. | ||
py_lib_target_name: target_name for the py_library. | ||
tags: Tags to pass to py_test. | ||
deps: Deps to pass to py_test and py_library. | ||
**kwargs: Keyword arguments to pass to py_library and py_test. | ||
""" | ||
heir_opt_name = name + ".heir_opt" | ||
generated_heir_opt_name = "%s.heir_opt.mlir" % name | ||
py_codegen_target = name + ".heir_translate_py" | ||
generated_py_filename = "%s_lib.py" % name | ||
if not py_lib_target_name: | ||
py_lib_target_name = "%s_py_lib" % name | ||
|
||
if entry_function_flag: | ||
heir_opt_pass_flag = "--tosa-to-boolean-jaxite=%s" % entry_function_flag | ||
heir_opt( | ||
name = heir_opt_name, | ||
src = mlir_src, | ||
pass_flag = heir_opt_pass_flag, | ||
generated_filename = generated_heir_opt_name, | ||
HEIR_YOSYS = True, | ||
data = ["@heir//lib/Transforms/YosysOptimizer/yosys:share_files"], | ||
) | ||
else: | ||
generated_heir_opt_name = mlir_src | ||
|
||
heir_translate( | ||
name = py_codegen_target, | ||
src = generated_heir_opt_name, | ||
pass_flags = ["--emit-jaxite"], | ||
generated_filename = generated_py_filename, | ||
) | ||
py_library( | ||
name = py_lib_target_name, | ||
srcs = [":" + generated_py_filename], | ||
deps = deps + ["@heir_pip_deps_jaxite//:pkg"], | ||
tags = tags, | ||
**kwargs | ||
) |