-
Notifications
You must be signed in to change notification settings - Fork 140
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_name
orfunctionArgumentName
- Local variable:
local_variable_name
orlocalVariableName
- Compiler time constant:
kConstant
??? - pointer:
p_pointer_name
orpPointerName
- For index, only opaque type
index_t
andlong_index_t
should be used, concrete integer type likeint
,int32_t
,long
is not allowed - If tensor data that is integer type, only concrete type like
int32_t
,uint32_t
,int64_t
are allow. Also, useint32_t
instead ofint
, useuint32_t
instead 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
CamelCase
for variables that describe the shape of tensor:NumOfDimension
,Length
,Stride
,GemmM
- use
xx_yy_zz
orxxYyZz
for index:i
,i_pad
,iPad
- Avoid explicit type conversion in GPU code, use
ck::type_convert
for casting
- use
#pragma once
in header files
- use
git mv
instead ofmv
to 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
-
xs
means "a container of x object", not "number of x objects"