Skip to content

Commit dd8f182

Browse files
pytorchbotswolchok
andauthored
Remove PATTERNLINT suppressions (#6821)
* [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]>
1 parent 93b202c commit dd8f182

File tree

11 files changed

+90
-17
lines changed

11 files changed

+90
-17
lines changed

.lintrunner.toml

+88
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,91 @@ command = [
196196
'@{{PATHSFILE}}',
197197
]
198198
is_formatter = true
199+
200+
[[linter]]
201+
code = 'NOSTDINC'
202+
include_patterns = [
203+
"**/*.c",
204+
"**/*.cpp",
205+
"**/*.h",
206+
"**/*.hpp",
207+
]
208+
exclude_patterns = [
209+
'**/devtools/**',
210+
'**/test/**',
211+
'**/testing_util/**',
212+
'**/third-party/**',
213+
'backends/**',
214+
'devtools/**',
215+
'examples/**',
216+
'extension/**',
217+
'kernels/optimized/**',
218+
'scripts/**',
219+
'third-party/**',
220+
'util/**',
221+
]
222+
command = [
223+
'python',
224+
'-m',
225+
'lintrunner_adapters',
226+
'run',
227+
'grep_linter',
228+
'--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)>)',
229+
'--linter-name=NOSTDINC',
230+
'--error-name=Standard C++ container include in core',
231+
"""--error-description=\
232+
Standard library containers should not be included in ExecuTorch core \
233+
because they may call malloc, which is not allowed in core. \
234+
""",
235+
'--',
236+
'@{{PATHSFILE}}',
237+
]
238+
239+
[[linter]]
240+
code = 'NOTORCHINC'
241+
include_patterns = [
242+
"**/*.c",
243+
"**/*.cpp",
244+
"**/*.h",
245+
"**/*.hpp",
246+
]
247+
exclude_patterns = [
248+
'**/devtools/**',
249+
'**/fb/**',
250+
'**/test/**',
251+
'**/tests/**',
252+
'**/testing_util/**',
253+
'**/third-party/**',
254+
'backends/**',
255+
'codegen/templates/RegisterDispatchKeyCustomOps.cpp',
256+
'codegen/templates/RegisterSchema.cpp',
257+
'devtools/**',
258+
'examples/**',
259+
'exir/verification/bindings.cpp',
260+
'extension/**',
261+
'kernels/optimized/**',
262+
'runtime/core/exec_aten/**',
263+
'runtime/executor/tensor_parser_aten.cpp',
264+
'scripts/**',
265+
'test/**',
266+
'third-party/**',
267+
'util/**',
268+
]
269+
command = [
270+
'python',
271+
'-m',
272+
'lintrunner_adapters',
273+
'run',
274+
'grep_linter',
275+
'--pattern=#include\s+[<"](aten/|ATen/|torch/)',
276+
'--linter-name=NOTORCHINC',
277+
'--error-name=ATen or torch include',
278+
"""--error-description=\
279+
PyTorch includes in ExecuTorch core are prohibited to prevent \
280+
accidentally breaking core's requirements; please make sure this \
281+
header complies (e.g., no streams/malloc/syscalls) and then include \
282+
a patch to update this linter.\
283+
""",
284+
'--',
285+
'@{{PATHSFILE}}',
286+
]

extension/llm/custom_ops/op_sdpa.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <executorch/runtime/core/exec_aten/util/scalar_type_util.h>
1717

1818
#include <array>
19-
// patternlint-disable-next-line executorch-cpp-nostdinc
2019
#include <vector>
2120

2221
#ifdef ET_USE_THREADPOOL

extension/llm/runner/image.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
// A simple image struct.
1010

1111
#pragma once
12-
#include <cstdint>
13-
// patternlint-disable-next-line executorch-cpp-nostdinc
1412
#include <executorch/runtime/platform/compiler.h>
13+
#include <cstdint>
1514
#include <vector>
1615

1716
namespace executorch {

extension/llm/runner/multimodal_runner.h

-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@
1313
#pragma once
1414

1515
#include <cstdint>
16-
// patternlint-disable-next-line executorch-cpp-nostdinc
1716
#include <functional>
1817
#include <memory>
19-
// patternlint-disable-next-line executorch-cpp-nostdinc
2018
#include <string>
2119
#include <type_traits>
22-
// patternlint-disable-next-line executorch-cpp-nostdinc
2320
#include <unordered_map>
2421

2522
#include <executorch/extension/llm/runner/image.h>

extension/llm/runner/stats.h

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <executorch/runtime/platform/log.h>
1313
#include <cinttypes>
1414
#include <sstream>
15-
// patternlint-disable-next-line executorch-cpp-nostdinc
1615
#include <string>
1716

1817
namespace executorch {

extension/llm/runner/text_decoder_runner.h

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <executorch/extension/module/module.h>
1515
#include <executorch/extension/tensor/tensor.h>
1616
#include <executorch/runtime/platform/compiler.h>
17-
// patternlint-disable-next-line executorch-cpp-nostdinc
1817
#include <functional>
1918

2019
namespace executorch {

extension/llm/runner/text_prefiller.h

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

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

1918
namespace executorch {

extension/llm/tokenizer/tokenizer.h

-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
#pragma once
1010

1111
#include <cinttypes>
12-
// patternlint-disable-next-line executorch-cpp-nostdinc
1312
#include <string>
14-
// patternlint-disable-next-line executorch-cpp-nostdinc
1513
#include <vector>
1614

1715
#include <executorch/runtime/core/error.h>

extension/parallel/thread_parallel.h

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#pragma once
1010

1111
#include <cstdint>
12-
// @nolint PATTERNLINT Ok to use stdlib for this optional library
1312
#include <functional>
1413

1514
namespace executorch {

kernels/optimized/vec/vec_base.h

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#pragma once
22

3-
// @nolint PATTERNLINT <functional> is required for std::equal_to, etc.
4-
53
#include <cassert>
64
#include <cstdint>
75
#include <cstring>

runtime/core/exec_aten/testing_util/tensor_factory.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
#ifdef USE_ATEN_LIB
1515
#include <ATen/ATen.h>
1616
#else // !USE_ATEN_LIB
17-
#include <numeric>
18-
// @nolint PATTERNLINT Ok to use stdlib for this test framework
1917
#include <memory>
20-
// @nolint PATTERNLINT Ok to use stdlib for this test framework
18+
#include <numeric>
2119
#include <vector>
2220
#endif // !USE_ATEN_LIB
2321

0 commit comments

Comments
 (0)