Skip to content

Commit

Permalink
Add expander_name to stablehlo printer (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
pearu authored Dec 21, 2024
1 parent 2615811 commit 7a84fef
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion functional_algorithms/targets/stablehlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ def tostring(self, expr, tab=""):
sargs = ", ".join(sargs)

lines = []
expander_name = expr.props.get("expander_name", "")
chlo_name = expr.props.get("name", f"CHLO_{name.ref.title()}")
lines.append(f"{tab}def : Pat<({chlo_name} {sargs}),")
lines.append(f"{tab}def {expander_name}: Pat<({chlo_name} {sargs}),")

for line in self.tostring(body, tab=tab + " ").splitlines():
sline = line.lstrip()
Expand Down
2 changes: 1 addition & 1 deletion results/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Finally,
| square | complex128 | 995705 | 6296 | - | - | - | - |
| sqrt | float32 | 1000001 | - | - | - | - | using native sqrt |
| sqrt | complex64 | 639573 | 362328 | 100 | - | - | using native sqrt |
| sqrt<sub>2</sub> | complex64 | 639573 | 362328 | 100 | - | - | using native sqrt |
| sqrt<sub>2</sub> | complex64 | 644997 | 356784 | 212 | 8 | - | - |
| sqrt | complex128 | 637905 | 364008 | 88 | - | - | - |
| angle | complex64 | 940289 | 61332 | 376 | 4 | - | - |
| angle | complex128 | 989787 | 12214 | - | - | - | - |
Expand Down
2 changes: 1 addition & 1 deletion results/estimate_accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def get_inputs():
# ("sqrt", np.float32, {}), # real_sqrt is not implemented
("sqrt", np.float32, dict(use_native_sqrt=True)),
# ("sqrt", np.float64, {}), # real_sqrt is not implemented
("sqrt", np.complex64, {}),
("sqrt", np.complex64, dict(use_native_sqrt=True)),
("sqrt", np.complex64, {}),
("sqrt", np.complex128, {}),
("angle", np.complex64, {}),
("angle", np.complex128, {}),
Expand Down

0 comments on commit 7a84fef

Please sign in to comment.