Skip to content

Commit

Permalink
Add coding practices for onnx-mlir (#2935)
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Essenmacher <[email protected]>
  • Loading branch information
mikeessen authored Sep 10, 2024
1 parent 8dc51ac commit c814ad0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions CODING_PRACTICE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!--- SPDX-License-Identifier: Apache-2.0 -->

# Coding Practices

This document contains coding practices to use when adding or updating code to the onnx-mlir project.

## Practices

* Use C++ style casting instead of C style when casting in cpp.

For example, use C++ style casting:
```
Value one = create.llvm.constant(llvmI64Ty, static_cast<int64_t>(1));
```

Not, C style casting:
```
Value one = create.llvm.constant(llvmI64Ty, (int64_t)1);
```

* Perform bitwise operations on unsigned types and not signed.
* Check the result of malloc() invocations.
* Check the result of input/output operations, such as fopen() and fprintf().
* Use parentheses around parameter names in macro definitions.

## Contributing

We are welcoming contributions from the community.
Please consult the [CONTRIBUTING](CONTRIBUTING.md) page for help on how to proceed.
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ A comprehensive list of documents is found [here](docs/DocumentList.md).
* The Krnl Dialect is used to lower ONNX operators to MLIR affine. The Krnl Dialect is defined [here](docs/Dialects/krnl.md).
* To update the internal documentation on our dialects when there are changes, please look for guidance [here](docs/ImportONNXDefs.md#update-your-operations-status).

## Coding practices for ONNX-MLIR

* When adding or updating code, see [here](CODING_PRACTICE.md) for coding practices.

## Testing and debugging ONNX-MLIR

* To test new code, see [here](docs/Testing.md) for instructions.
Expand Down

0 comments on commit c814ad0

Please sign in to comment.