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
Code cleanup, styling, and formatting #753
Conversation
Looks great @hsbadr ! Just 2 comments:
|
Sure, I'll automate it in GHA. Also, it seems that Window doesn't like that |
- gen-*.* - lantern.* - RcppExports.*
@dfalbel GHA needs more work than this PR. So, I'd go with the documentation and update the workflow later. Here's the customized Rscript -e 'styler::style_pkg(exclude_files = list.files("./R", pattern = "^gen-*.*|^RcppExports.*"))'
find . -type f \( -name 'DESCRIPTION' -o -name "*.R" \) ! -path "*/gen-*.*" ! -path "*/RcppExports.*" -exec sed -i -e 's/[ \t]*$//' {} \;
find . -type f \( -name '*.h' -o -name '*.hpp' -o -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.cxx' \) ! -path "*/gen-*.*" ! -path "*/lantern.*" ! -path "*/RcppExports.*" -exec sed -i -e 's/[ \t]*$//' {} \;
find . -type f \( -name '*.h' -o -name '*.hpp' -o -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.cxx' \) ! -path "*/gen-*.*" ! -path "*/lantern.*" ! -path "*/RcppExports.*" -exec clang-format -style=Google --verbose -i {} \; The above lines will reproduce this PR. Would you prefer to run them on pull request or if |
Oh wow, we had one, but it seems that we have unintentionally removed at some point. Can't find when though :( I think running in PR's is great! What do you think? Maybe we can also add this custom script to |
Should I recover the latest version in this PR?
Yes, I usually run it on PR... but that commits format/style changes if needed. We can also run it on demand by adding
Yeah, that makes sense and could be better that listing specific commands in |
@dfalbel This is ready. I'll take a cut at GHA workflow later. |
@hsbadr Thanks for getting the CONTRIBUTING guide back! I'm trying to run the Maybe I'm missing something? |
It seems that you use Posix Sed (BSD/macOS) not GNU Sed (Linux). I run the script on Linux (same in GHA). |
Co-authored-by: Daniel Falbel <dfalbel@gmail.com>
@dfalbel Can you try now? I've replaced GNU |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @hsbadr
Now I think formatting worked, but I don't completely reproduce the same changes in this PR. I get a large diff eg:
(Of course we can ignore the workflows change, but I would expect .R files and .cpp files to be identical)
❯ git diff --stat style
.github/CONTRIBUTING.md | 109 -------------------------------------------------------------------------------------------------------------
.github/workflows/lantern.yaml | 2 +-
.github/workflows/main.yaml | 38 ++++++++++++++++++--------------------
.github/workflows/website.yaml | 2 +-
NEWS.md | 2 --
R/autograd.R | 6 ------
R/device.R | 1 -
R/distributions-categorical.R | 1 -
R/distributions-chi2.R | 1 -
R/distributions-mixture_same_family.R | 1 -
R/distributions-multivariate_normal.R | 1 -
R/distributions-normal.R | 1 -
R/gen-method.R | 2 +-
R/gen-namespace.R | 4 ++--
R/generator.R | 10 ++++++----
R/indexing.R | 1 -
R/jit-compile.R | 1 -
R/linalg.R | 26 --------------------------
R/nn-activation.R | 25 -------------------------
R/nn-batchnorm.R | 3 ---
R/nn-conv.R | 5 -----
R/nn-distance.R | 1 -
R/nn-dropout.R | 3 ---
R/nn-init.R | 12 ------------
R/nn-linear.R | 3 ---
R/nn-loss.R | 12 ------------
R/nn-normalization.R | 2 --
R/nn-pooling.R | 19 -------------------
R/nn-rnn.R | 3 ---
R/nn-sparse.R | 1 -
R/nn-upsampling.R | 1 -
R/nn-utils-rnn.R | 3 ---
R/nn.R | 3 ---
R/nnf-activation.R | 2 --
R/optim.R | 1 -
R/quantization.R | 1 +
R/stack.R | 1 -
R/tensor.R | 10 ----------
R/trace.R | 4 ----
R/with-indices.R | 10 ----------
R/wrapers.R | 1 -
README.md | 94 +++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------
inst/include/lantern/types.h | 10 +++++-----
inst/include/torch.h | 2 --
inst/include/torch_types.h | 2 --
lantern/include/lantern/types.h | 10 +++++-----
lantern/src/Allocator.cpp | 2 --
lantern/src/AllocatorCuda.cpp | 5 ++---
lantern/src/Autograd.cpp | 4 ++--
lantern/src/Backends.cpp | 4 ++--
lantern/src/Compile.cpp | 1 -
lantern/src/Contrib/SortVertices/cuda_utils.h | 1 -
lantern/src/Contrib/SortVertices/sort_vert.cpp | 2 --
lantern/src/Contrib/SortVertices/sort_vert_cpu.cpp | 1 -
lantern/src/Contrib/Sparsemax.cpp | 2 --
lantern/src/Delete.cpp | 3 ++-
lantern/src/Device.cpp | 3 ++-
lantern/src/Dimname.cpp | 3 ++-
lantern/src/Dtype.cpp | 3 ++-
lantern/src/Function.cpp | 1 -
lantern/src/Function.h | 3 ++-
lantern/src/Generator.cpp | 3 ++-
lantern/src/IValue.cpp | 1 -
lantern/src/Indexing.cpp | 3 ++-
lantern/src/JITTypes.cpp | 2 --
lantern/src/Layout.cpp | 3 ++-
lantern/src/MemoryFormat.cpp | 3 ++-
lantern/src/NNUtilsRnn.cpp | 3 ++-
lantern/src/QScheme.cpp | 3 ++-
lantern/src/Quantization.cpp | 3 ++-
lantern/src/Reduction.cpp | 3 ++-
lantern/src/Save.cpp | 2 +-
lantern/src/Scalar.cpp | 3 ++-
lantern/src/ScriptModule.cpp | 1 -
lantern/src/Stack.cpp | 1 -
lantern/src/Storage.cpp | 3 ++-
lantern/src/Tensor.cpp | 3 ++-
lantern/src/TensorList.cpp | 3 ++-
lantern/src/TensorOptions.cpp | 3 ++-
lantern/src/Threads.cpp | 1 -
lantern/src/Trace.cpp | 1 -
lantern/src/utils.cpp | 4 ++--
lantern/tests/init.cpp | 4 ++--
lantern/tests/main.cpp | 3 ++-
Maybe this was caused by a different version of styler or clang-format?
I have styler v1.6.2
clang-format version 8.0.0 (tags/google/stable/2019-01-18)
@dfalbel Note that this also fixes some GHA issues such as failed |
@dfalbel Any idea?
|
Oh I see, we can't run win-gpu tests on forked repos. |
Fixes: ``` Warning: google-github-actions/setup-gcloud is pinned at HEAD. We strongly advise against pinning to "@master" as it may be unstable. Please update your GitHub Action YAML from: uses: 'google-github-actions/setup-gcloud@master' to: uses: 'google-github-actions/setup-gcloud@v0' ```
This reverts commit 226c176.
@dfalbel It seems that the GPU runs are stuck, after the
I think it's ready to go anyway. |
Close #752.