Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add support for using python builder invoke with integer literals #1849

Merged
merged 4 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion calyx-py/calyx/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,16 @@ def invoke(cell: CellBuilder, **kwargs) -> ast.Invoke:
return ast.Invoke(
cell._cell.id,
[
(k[3:], ExprBuilder.unwrap(v))
(
k[3:],
(
(
const(cell.infer_width(k[3:]), v).expr
if isinstance(v, int)
else ExprBuilder.unwrap(v)
)
),
)
for (k, v) in kwargs.items()
if k.startswith("in_")
],
Expand Down
3 changes: 2 additions & 1 deletion docs/builder/ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ See the language reference for [`invoke`][invoke].

```python
# invoke(cell, **kwargs)
my_invoke = invoke(my_cell, in_arg1=my_cell_arg1_reg.out, in_arg2=my_cell_arg2_reg.out)
my_invoke = invoke(my_cell, in_arg1=my_cell_arg1_reg.out, in_arg2=1)

```

## Miscellaneous Tips + Tricks
Expand Down
Loading