Skip to content

Commit

Permalink
Remove PATTERNLINT suppressions (#6821)
Browse files Browse the repository at this point in the history
* [ExecuTorch] Remove PATTERNLINT suppressions

Pull Request resolved: #6692

The linter these are suppressing was removed in D63859186.
ghstack-source-id: 253169885

Differential Revision: [D65507718](https://our.internmc.facebook.com/intern/diff/D65507718/)

* Add NOSTDINC and NOTORCHINC lintrunner (#6822)

[ExecuTorch] Add NOSTDINC and NOTORCHINC lintrunner

Pull Request resolved: #6693

Prohibit standard C++ container, aten, and torch includes in core, at least pending further review. Note that non-core directories, such as extension/, test/, and any testing_util/ subdirectories, are exempted.
ghstack-source-id: 253193810

Differential Revision: [D65541332](https://our.internmc.facebook.com/intern/diff/D65541332/)

Co-authored-by: Scott Wolchok <[email protected]>

---------

Co-authored-by: Scott Wolchok <[email protected]>
  • Loading branch information
pytorchbot and swolchok authored Nov 13, 2024
1 parent 93b202c commit dd8f182
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 17 deletions.
88 changes: 88 additions & 0 deletions .lintrunner.toml
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,91 @@ command = [
'@{{PATHSFILE}}',
]
is_formatter = true

[[linter]]
code = 'NOSTDINC'
include_patterns = [
"**/*.c",
"**/*.cpp",
"**/*.h",
"**/*.hpp",
]
exclude_patterns = [
'**/devtools/**',
'**/test/**',
'**/testing_util/**',
'**/third-party/**',
'backends/**',
'devtools/**',
'examples/**',
'extension/**',
'kernels/optimized/**',
'scripts/**',
'third-party/**',
'util/**',
]
command = [
'python',
'-m',
'lintrunner_adapters',
'run',
'grep_linter',
'--pattern=([^\\S\r\n]*#include\s*<(deque|exception|forward_list|functional|list|map|multimap|multiset|priority_queue|queue|set|stack|string|unordered_map|unordered_multimap|unordered_multiset|unordered_set|vector)>)',
'--linter-name=NOSTDINC',
'--error-name=Standard C++ container include in core',
"""--error-description=\
Standard library containers should not be included in ExecuTorch core \
because they may call malloc, which is not allowed in core. \
""",
'--',
'@{{PATHSFILE}}',
]

[[linter]]
code = 'NOTORCHINC'
include_patterns = [
"**/*.c",
"**/*.cpp",
"**/*.h",
"**/*.hpp",
]
exclude_patterns = [
'**/devtools/**',
'**/fb/**',
'**/test/**',
'**/tests/**',
'**/testing_util/**',
'**/third-party/**',
'backends/**',
'codegen/templates/RegisterDispatchKeyCustomOps.cpp',
'codegen/templates/RegisterSchema.cpp',
'devtools/**',
'examples/**',
'exir/verification/bindings.cpp',
'extension/**',
'kernels/optimized/**',
'runtime/core/exec_aten/**',
'runtime/executor/tensor_parser_aten.cpp',
'scripts/**',
'test/**',
'third-party/**',
'util/**',
]
command = [
'python',
'-m',
'lintrunner_adapters',
'run',
'grep_linter',
'--pattern=#include\s+[<"](aten/|ATen/|torch/)',
'--linter-name=NOTORCHINC',
'--error-name=ATen or torch include',
"""--error-description=\
PyTorch includes in ExecuTorch core are prohibited to prevent \
accidentally breaking core's requirements; please make sure this \
header complies (e.g., no streams/malloc/syscalls) and then include \
a patch to update this linter.\
""",
'--',
'@{{PATHSFILE}}',
]
1 change: 0 additions & 1 deletion extension/llm/custom_ops/op_sdpa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <executorch/runtime/core/exec_aten/util/scalar_type_util.h>

#include <array>
// patternlint-disable-next-line executorch-cpp-nostdinc
#include <vector>

#ifdef ET_USE_THREADPOOL
Expand Down
3 changes: 1 addition & 2 deletions extension/llm/runner/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
// A simple image struct.

#pragma once
#include <cstdint>
// patternlint-disable-next-line executorch-cpp-nostdinc
#include <executorch/runtime/platform/compiler.h>
#include <cstdint>
#include <vector>

namespace executorch {
Expand Down
3 changes: 0 additions & 3 deletions extension/llm/runner/multimodal_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@
#pragma once

#include <cstdint>
// patternlint-disable-next-line executorch-cpp-nostdinc
#include <functional>
#include <memory>
// patternlint-disable-next-line executorch-cpp-nostdinc
#include <string>
#include <type_traits>
// patternlint-disable-next-line executorch-cpp-nostdinc
#include <unordered_map>

#include <executorch/extension/llm/runner/image.h>
Expand Down
1 change: 0 additions & 1 deletion extension/llm/runner/stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <executorch/runtime/platform/log.h>
#include <cinttypes>
#include <sstream>
// patternlint-disable-next-line executorch-cpp-nostdinc
#include <string>

namespace executorch {
Expand Down
1 change: 0 additions & 1 deletion extension/llm/runner/text_decoder_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <executorch/extension/module/module.h>
#include <executorch/extension/tensor/tensor.h>
#include <executorch/runtime/platform/compiler.h>
// patternlint-disable-next-line executorch-cpp-nostdinc
#include <functional>

namespace executorch {
Expand Down
1 change: 0 additions & 1 deletion extension/llm/runner/text_prefiller.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#include <executorch/extension/llm/runner/text_decoder_runner.h>
#include <executorch/extension/llm/tokenizer/tokenizer.h>
// patternlint-disable-next-line executorch-cpp-nostdinc
#include <functional>

namespace executorch {
Expand Down
2 changes: 0 additions & 2 deletions extension/llm/tokenizer/tokenizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
#pragma once

#include <cinttypes>
// patternlint-disable-next-line executorch-cpp-nostdinc
#include <string>
// patternlint-disable-next-line executorch-cpp-nostdinc
#include <vector>

#include <executorch/runtime/core/error.h>
Expand Down
1 change: 0 additions & 1 deletion extension/parallel/thread_parallel.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#pragma once

#include <cstdint>
// @nolint PATTERNLINT Ok to use stdlib for this optional library
#include <functional>

namespace executorch {
Expand Down
2 changes: 0 additions & 2 deletions kernels/optimized/vec/vec_base.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

// @nolint PATTERNLINT <functional> is required for std::equal_to, etc.

#include <cassert>
#include <cstdint>
#include <cstring>
Expand Down
4 changes: 1 addition & 3 deletions runtime/core/exec_aten/testing_util/tensor_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
#ifdef USE_ATEN_LIB
#include <ATen/ATen.h>
#else // !USE_ATEN_LIB
#include <numeric>
// @nolint PATTERNLINT Ok to use stdlib for this test framework
#include <memory>
// @nolint PATTERNLINT Ok to use stdlib for this test framework
#include <numeric>
#include <vector>
#endif // !USE_ATEN_LIB

Expand Down

0 comments on commit dd8f182

Please sign in to comment.