You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: CODING-GUIDELINES.md
+10-10
Original file line number
Diff line number
Diff line change
@@ -76,7 +76,7 @@ if (nbInputs == kNbInputsWBias) {/*...*/}
76
76
* Public member variables do not require the 'm' prefix but it is highly encouraged to use the prefix when needed to improve code clarity, especially in cases where the class is a base class in an inheritance chain.
77
77
78
78
8. Constants
79
-
* Enumerations, global constants, static constants at class-scope and function-scope magic-number/literal constants are uppercase snakecase with prefix 'k':
79
+
* Enumerations, global constants, static constants at class-scope and function-scope magic-number/literal constants are uppercase snakecase with prefix 'k':
80
80
```cpp
81
81
constintkDIGIT_NUM = 10;
82
82
```
@@ -103,7 +103,7 @@ Notes:
103
103
104
104
#### Formatting
105
105
1. Use the [LLVM clang-format](https://clang.llvm.org/docs/ClangFormat.html) tool for formatting your changes prior to submitting the PR.
106
-
2. Use a maximum of 120 characters per line. The auto formatting tool will wrap longer lines.
106
+
2. Use a maximum of 120 characters per line. The auto formatting tool will wrap longer lines.
107
107
3. Exceptions to formatting violations must be justified on a per-case basis. Bypassing the formatting rules is discouraged, but can be achieved for exceptions as follows:
// Alternative: use a macro which evaluates to a noop in release code.
154
154
#if DEBUG_CONVOLUTION_INSTRUMENTATION
155
155
# define DEBUG_CONV_CODE(x) x
@@ -235,7 +235,7 @@ switch (x) case 4: if (y) case 5: return 0; else default: return 1;
235
235
switch (x)
236
236
{
237
237
case 0: // Fall-through allowed from case 0: to case 1: since case 0 is empty.
238
-
case 1:
238
+
case 1:
239
239
a();
240
240
b();
241
241
break;
@@ -250,7 +250,7 @@ case 5:
250
250
c();
251
251
throw 42; // Terminating with throw is okay
252
252
default:
253
-
throw 42;
253
+
throw 42;
254
254
}
255
255
```
256
256
@@ -297,7 +297,7 @@ case 1:
297
297
#### Preprocessor Directives
298
298
1.*MISRA C++: 2008 Rule 16-0-2*
299
299
`#define` and `#undef` of macros should be done only at global namespace.
300
-
2. Avoid the use of `#ifdef` and `#ifndef` directives (except in the case of header include guards). Prefer to use `#if defined(...)` or `#if !defined(...)` instead. The latter syntax is more consistent with C syntax, and allows you to use more complicated preprocessor conditionals, e.g.:
300
+
2. Avoid the use of `#ifdef` and `#ifndef` directives (except in the case of header include guards). Prefer to use `#if defined(...)` or `#if !defined(...)` instead. The latter syntax is more consistent with C syntax, and allows you to use more complicated preprocessor conditionals, e.g.:
301
301
```cpp
302
302
#if defined(FOO) || defined(BAR)
303
303
void foo();
@@ -343,14 +343,14 @@ for (size_t i = 0; i < mTensors.size(); ++i) // preferred style
343
343
```
344
344
* Using only signed integers for the above would lead to prolixity and perhaps unsafe narrowing:
345
345
```cpp
346
-
for (int i = 0; i < static_cast<int>(mTensors.size()); ++i)
346
+
for (int i = 0; i < static_cast<int>(mTensors.size()); ++i)
347
347
```
348
348
349
349
350
350
#### Special Considerations for API
351
351
1. The API consists, with very few exceptions, of methodless structs and pure virtual interface classes.
352
352
2. API class methods should be either virtual or inline.
353
-
3. The API does not use integral types with platform-dependent sizes, other than `int`, `unsigned`, and `bool`. `size_t` should be used only for sizes of memory buffers.
353
+
3. The API does not use integral types with platform-dependent sizes, other than `int`, `unsigned`, and `bool`. `size_t` should be used only for sizes of memory buffers.
354
354
4. The API does not use any aggregate types (e.g. `std::string`) which may be compiled differently with different compilers and libraries.
355
355
5. The API minimizes dependencies on system headers - currently only `<cstddef>` and `<cstdint>`.
356
356
6. Memory ownership may not be transferred across API boundaries - any memory allocated inside a library must be freed inside the library.
1. All TensorRT Open Source Software code should contain an NVIDIA copyright header that includes the current year. The following block of text should be prepended to the top of all OSS files. This includes .cpp, .h, .cu, .py, and any other source files which are compiled or interpreted.
420
420
```cpp
421
421
/*
422
-
* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
422
+
* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
423
423
*
424
424
* Licensed under the Apache License, Version 2.0 (the "License");
425
425
* you may not use this file except in compliance with the License.
0 commit comments