Skip to content

Remove PATTERNLINT suppressions #6821

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

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading