-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy path.clinerules
More file actions
129 lines (98 loc) · 3.72 KB
/
Copy path.clinerules
File metadata and controls
129 lines (98 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Cline Rules for hipDNN Project
## C++ Code Style
### Naming Conventions
- Use CamelCase for class and struct names (e.g., `BatchNormTestCase`, `SimpleTensorBundle`)
- Use camelBack for functions, variables, and private members (e.g., `setupEnvironment()`, `tensorData`)
- Prefix private members with underscore (e.g., `_handle`, `_testData`)
### File Headers
- Always add copyright header to all source files:
```cpp
// Copyright © Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
```
- For header files (.h, .hpp), add `#pragma once` immediately after copyright
### Code Practices
- Use `auto` when initializing with a cast to avoid duplicating the type name
```cpp
// Good
auto tensor = static_cast<float*>(data);
// Avoid
float* tensor = static_cast<float*>(data);
```
- Use auto when initializing variables, unless the type is not obvious.
### Build System
- Always use CMake for managing C/C++ dependencies
- When discussing dependencies or build configuration, provide CMake-based solutions
### Serialization
- Use Flatbuffers for serialization needs
- Provide Flatbuffer schema definitions when creating serializable data structures
### Testing
- Use Google Test (gtest) framework for all C/C++ tests
- Never generate a main() function in test files - gtest provides its own
- Use TEST(), TEST_F(), or TEST_P() macros as appropriate
#### Test Naming Guidelines
Rules below apply ONLY to the TestSuite name (first parameter of `TEST` / `TEST_F` / `TEST_P`). The TestCase (second parameter) can be descriptive but should still avoid the reserved keywords where noted.
TestCase should be PascalCase.
**Ordering & Composition (left → right):**
1. Optional `Integration` prefix for integration tests.
2. Optional `Gpu` (immediately after `Integration` if both apply) for GPU-required tests.
3. Core Feature / Subject under test (PascalCase, no underscores).
4. Optional Datatype token (`Bfp16`, `Fp16`, `Fp32`) at the end.
Omit any category that does not apply.
### 10.1 Keywords (reserved positions)
- **Integration** (only for integration tests, always first if present).
- **Gpu** (always first unless preceded by Integration).
- **Datatypes**: Bfp16, Fp16, Fp32.
### 10.2 Unit Tests
In most cases unit style tests should be named so the directly mirror the class under test. If the class is named `MyClass`, then the test suite should be named `TestMyClass`. In general these kinds of tests should try to avoid using anything that requires Gpu support. This is not always possible, in the cases where Gpu support is required, the test suite should be named `GpuTestMyClass`.
### 10.3 Valid Examples
```cpp
IntegrationGpuConvolutionPlannerNchwFp32
GpuTestActivationKernelNchwFp32
GpuTestExecutionPlanBuilderFp32
GpuTestExecutionPlanBuilderNchw
IntegrationGraphFusion
TestConvolutionHeuristicsFp32
TestConvolutionHeuristics
```
## Example Code Structure
```cpp
// Copyright © Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#pragma once // For header files only
#include <memory>
#include <vector>
// Class names in PascalCase
class MyTestClass
{
public:
// Public methods in camelCase
void setupTest();
int getValue() const;
private:
// Private members prefixed with _
int _testValue;
std::vector<float> _data;
};
// Functions in camelCase
void processData(const MyTestClass& obj);
```
## Test File Example
```cpp
// Copyright © Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#include <gtest/gtest.h>
class MyTestFixture : public ::testing::Test
{
protected:
void SetUp() override
{
// Setup code
}
private:
int _testData;
};
TEST_F(MyTestFixture, testSomething)
{
// Test implementation
}