-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add coding practices for onnx-mlir (#2935)
Signed-off-by: Mike Essenmacher <[email protected]>
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters