Skip to content

Coding Style

Chao Liu edited this page Mar 30, 2022 · 19 revisions

Naming Style

  • Class: ClassName
  • Class member function: void MemberFunctionName()
  • Class member variable: class_member_
  • Template argument: TemplateArgument
  • Function: void function_name()
  • Function arguement: function_argument_name or functionArgumentName
  • Local variable: local_variable_name or localVariableName
  • Compiler time constant: kConstant ???
  • pointer: p_pointer_name or pPointerName

Integer Type

  • For index, only opaque type index_t and long_index_t should be used, concrete integer type like int, 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, use int32_t instead of int, use uint32_t instead of unsigned

Enum

  • Use enum class instead of enum

Tensor Descriptor

  • 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 as const InGridDescriptor_N_C_Hi_Wi in_grid_desc_n_c_hi_wi

Type conversion

  • Avoid explicit type conversion in GPU code, use ck::type_convert for casting

header file

  • use #pragma once

Misc

  • Must add bracket for all if/else, switch/case
  • xs means "a container of x object", not "number of x objects"

Clone this wiki locally