Skip to content

Commit

Permalink
Merge pull request google#286 from asraa:add-template-docs
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 586068759
  • Loading branch information
copybara-github committed Nov 28, 2023
2 parents 576bcf0 + 0eeeb66 commit 799b02f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
42 changes: 42 additions & 0 deletions docs/content/en/docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,45 @@ To run them manually, run
```bash
pre-commit run --all-files
```

## Creating a New Pass

The `templates` folder contains Python scripts to create boilerplate for new conversion or (dialect-specific) transform passes.

### Conversion Pass

To create a new conversion pass, run a command similar to the following:

```
python templates/templates.py new_conversion_pass \
--source_dialect_name=CGGI \
--source_dialect_namespace=cggi \
--source_dialect_mnemonic=cggi \
--target_dialect_name=TfheRust \
--target_dialect_namespace=tfhe_rust \
--target_dialect_mnemonic=tfhe_rust
```

In order to build the resulting code, you must fix the labeled `FIXME`s in the type converter and the op conversion patterns.

### Transform Passes

To create a transform or rewrite pass that operates on a dialect, run a command similar to the following:

```
python templates/templates.py new_dialect_transform \
--pass_name=ForgetSecrets \
--pass_flag=forget-secrets \
--dialect_name=Secret \
--dialect_namespace=secret \
--force=false
```

If the transform does not operate from and to a specific dialect, use

```
python templates/templates.py new_transform \
--pass_name=ForgetSecrets \
--pass_flag=forget-secrets \
--force=false
```
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
fire==0.5.0
jinja2==3.1.2
pre-commit==v3.3.3

0 comments on commit 799b02f

Please sign in to comment.