Skip to content

Add coding practices for onnx-mlir #2935

New issue

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

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

Already on GitHub? Sign in to your account

Merged
3 commits merged into from Sep 10, 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
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
Loading