Skip to content

Commit c814ad0

Browse files
authored
Add coding practices for onnx-mlir (#2935)
Signed-off-by: Mike Essenmacher <[email protected]>
1 parent 8dc51ac commit c814ad0

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

CODING_PRACTICE.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!--- SPDX-License-Identifier: Apache-2.0 -->
2+
3+
# Coding Practices
4+
5+
This document contains coding practices to use when adding or updating code to the onnx-mlir project.
6+
7+
## Practices
8+
9+
* Use C++ style casting instead of C style when casting in cpp.
10+
11+
For example, use C++ style casting:
12+
```
13+
Value one = create.llvm.constant(llvmI64Ty, static_cast<int64_t>(1));
14+
```
15+
16+
Not, C style casting:
17+
```
18+
Value one = create.llvm.constant(llvmI64Ty, (int64_t)1);
19+
```
20+
21+
* Perform bitwise operations on unsigned types and not signed.
22+
* Check the result of malloc() invocations.
23+
* Check the result of input/output operations, such as fopen() and fprintf().
24+
* Use parentheses around parameter names in macro definitions.
25+
26+
## Contributing
27+
28+
We are welcoming contributions from the community.
29+
Please consult the [CONTRIBUTING](CONTRIBUTING.md) page for help on how to proceed.

CONTRIBUTING.md

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ A comprehensive list of documents is found [here](docs/DocumentList.md).
3030
* The Krnl Dialect is used to lower ONNX operators to MLIR affine. The Krnl Dialect is defined [here](docs/Dialects/krnl.md).
3131
* To update the internal documentation on our dialects when there are changes, please look for guidance [here](docs/ImportONNXDefs.md#update-your-operations-status).
3232

33+
## Coding practices for ONNX-MLIR
34+
35+
* When adding or updating code, see [here](CODING_PRACTICE.md) for coding practices.
36+
3337
## Testing and debugging ONNX-MLIR
3438

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

0 commit comments

Comments
 (0)