-
Notifications
You must be signed in to change notification settings - Fork 249
Coding Style
Chao Liu edited this page May 25, 2022
·
19 revisions
- Class:
ClassName - Class member function:
void MemberFunctionName() - Class member variable:
class_member_ - Template argument:
TemplateArgument - Function:
void function_name() - Function arguement:
function_argument_nameorfunctionArgumentName - Local variable:
local_variable_nameorlocalVariableName - Compiler time constant:
kConstant??? - pointer:
p_pointer_nameorpPointerName
- For index, only opaque type
index_tandlong_index_tshould be used, concrete integer type likeint,int32_t,longis not allowed - If tensor data that is integer type, only concrete type like
int32_t,uint32_t,int64_tare allow. Also, useint32_tinstead ofint, useuint32_tinstead ofunsigned
- Use enum class instead of enum
- A tensor descriptor must clearly indicate:
- Each dimension of tensor in the correct order
- The scope of the tensor: grid/block/wave/thread level
- For example, for grid level input image tensor
In[N, C, Hi, Wi]should be declared asconst InGridDescriptor_N_C_Hi_Wi in_grid_desc_n_c_hi_wi
- Use
CamelCasefor variables that describe the shape of tensor:NumOfDimension,Length,Stride,GemmM - use
xx_yy_zzorxxYyZzfor index:i,i_pad,iPad
- Avoid explicit type conversion in GPU code, use
ck::type_convertfor casting
- use
#pragma oncein header files
- use
git mvinstead ofmvto move files, to keep file history
- It's ok for CPU code to have external dependency.
- For GPU code (used by function with
__device__or__global__keyword), don't use external dependency likestd.
- Must add bracket for all
if/else,switch/case -
xsmeans "a container of x object", not "number of x objects"