-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support clang format and format almost all C++ code (#423)
* refactor: format almost all code * fix: update IncludeCategories * fix: make sure structmember.h is before Python.h
- Loading branch information
Showing
119 changed files
with
6,606 additions
and
6,240 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,3 @@ | ||
--- | ||
Language: Cpp | ||
BasedOnStyle: Google |
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,22 @@ | ||
name: code format | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
cpp-linter: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: cpp-linter/cpp-linter-action@v2 | ||
id: linter | ||
with: | ||
style: file | ||
tidy-checks: '-*' # disable clang tidy at this stage | ||
- name: Fail test | ||
if: steps.linter.outputs.checks-failed > 0 | ||
run: echo "Some files failed the linting checks!" && exit 1 |
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,3 @@ | ||
--- | ||
DisableFormat: true | ||
SortIncludes: Never |
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,36 @@ | ||
--- | ||
BasedOnStyle: InheritParentConfig | ||
IncludeCategories: | ||
- Regex: '^("|<)csrc_dipu/' | ||
Priority: 90 | ||
CaseSensitive: false | ||
- Regex: '^("|<)diopi/' | ||
Priority: 80 | ||
CaseSensitive: false | ||
- Regex: '^("|<)(c10|aten|torch)/' | ||
Priority: 40 | ||
CaseSensitive: false | ||
- Regex: '^("|<)Python\.h' | ||
Priority: 50 | ||
CaseSensitive: false | ||
- Regex: '^("|<)(frameobject|structmember)\.h' | ||
Priority: 50 | ||
SortPriority: 51 | ||
CaseSensitive: false | ||
- Regex: '^("|<)(pybind11)' | ||
Priority: 50 | ||
SortPriority: 52 | ||
CaseSensitive: false | ||
- Regex: '^<((ext/.*)|pthread)\.h' | ||
Priority: 20 | ||
SortPriority: 21 | ||
CaseSensitive: false | ||
- Regex: '^("|<)(cuda|su|cn|(..?ccl)|(.*_runtime)).*\.h' | ||
Priority: 30 | ||
CaseSensitive: false | ||
- Regex: '^<.*' | ||
Priority: 20 | ||
CaseSensitive: false | ||
- Regex: '.*' | ||
Priority: 100 | ||
CaseSensitive: false |
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 |
---|---|---|
@@ -1,21 +1,22 @@ | ||
// Copyright (c) 2023, DeepLink. | ||
#include <torch/torch.h> | ||
#include <iostream> | ||
|
||
void testTensorRelu(at::Tensor& self) { | ||
std::cout << self << std::endl; | ||
std::cout << torch::relu(self) << std::endl; | ||
std::cout << self << std::endl; | ||
#include <torch/torch.h> | ||
|
||
void testTensorRelu(at::Tensor &self) { | ||
std::cout << self << std::endl; | ||
std::cout << torch::relu(self) << std::endl; | ||
std::cout << self << std::endl; | ||
|
||
std::cout << torch::relu_(self) << std::endl; | ||
std::cout << self << std::endl; | ||
std::cout << torch::relu_(self) << std::endl; | ||
std::cout << self << std::endl; | ||
} | ||
|
||
int main() { | ||
torch::Tensor tensor = torch::randn(10).cuda(); | ||
testTensorRelu(tensor); | ||
torch::Tensor tensor = torch::randn(10).cuda(); | ||
testTensorRelu(tensor); | ||
|
||
torch::Tensor tensor_cpu = torch::randn(10); | ||
testTensorRelu(tensor_cpu); | ||
return 0; | ||
torch::Tensor tensor_cpu = torch::randn(10); | ||
testTensorRelu(tensor_cpu); | ||
return 0; | ||
} |
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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
// Copyright (c) 2023, DeepLink. | ||
#include <iostream> | ||
|
||
#include <ATen/Tensor.h> | ||
#include <ATen/ATen.h> | ||
#include <ATen/Tensor.h> | ||
|
||
void testTensorAdd(const at::Tensor& lhs, const at::Tensor& rhs) { | ||
at::Tensor result = lhs + rhs; | ||
std::cout << lhs << std::endl; | ||
std::cout << rhs << std::endl; | ||
std::cout << result << std::endl; | ||
void testTensorAdd(const at::Tensor &lhs, const at::Tensor &rhs) { | ||
at::Tensor result = lhs + rhs; | ||
std::cout << lhs << std::endl; | ||
std::cout << rhs << std::endl; | ||
std::cout << result << std::endl; | ||
} | ||
|
||
int main() { | ||
at::Tensor t0 = at::randn({2, 2}).cuda(); | ||
at::Tensor t1 = at::randn({2}).cuda(); | ||
testTensorAdd(t0, t1); | ||
testTensorAdd(t0.cpu(), t1.cpu()); | ||
return 0; | ||
at::Tensor t0 = at::randn({2, 2}).cuda(); | ||
at::Tensor t1 = at::randn({2}).cuda(); | ||
testTensorAdd(t0, t1); | ||
testTensorAdd(t0.cpu(), t1.cpu()); | ||
return 0; | ||
} |
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
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,3 @@ | ||
--- | ||
DisableFormat: true | ||
SortIncludes: Never |
Oops, something went wrong.