Skip to content

Commit

Permalink
Apply clang-format 18
Browse files Browse the repository at this point in the history
Summary: Previously this code conformed from clang-format 12.

Reviewed By: igorsugak

Differential Revision: D56065247

fbshipit-source-id: f5a985dd8f8b84f2f9e1818b3719b43c5a1b05b3
  • Loading branch information
zertosh authored and facebook-github-bot committed Apr 14, 2024
1 parent d2dc957 commit d6142ef
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 97 deletions.
113 changes: 57 additions & 56 deletions python/aitemplate/backend/cuda/groupnorm/layer_norm.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ DispatchLayerNormWarpImplCols(
return cudaErrorInvalidValue;
}
#define DEFINE_ONE_ELIF(thread_group_width) \
else if (cols <= (thread_group_width)*pack_size) { \
else if (cols <= (thread_group_width) * pack_size) { \
if (rows % 2 == 0) { \
return DispatchLayerNormWarpImplPadding< \
LOAD, \
Expand Down Expand Up @@ -622,7 +622,7 @@ DispatchLayerNormWarpImplCols(
DEFINE_ONE_ELIF(32)
#undef DEFINE_ONE_ELIF
#define DEFINE_ONE_ELIF(max_col, min_col) \
else if (cols <= (max_col)*kWarpSize) { \
else if (cols <= (max_col) * kWarpSize) { \
return DispatchLayerNormWarpImplPadding< \
LOAD, \
STORE, \
Expand Down Expand Up @@ -663,7 +663,7 @@ DispatchLayerNormWarpImplCols(
return cudaErrorInvalidValue;
}
#define DEFINE_ONE_ELIF(thread_group_width) \
else if (cols <= (thread_group_width)*pack_size) { \
else if (cols <= (thread_group_width) * pack_size) { \
if (rows % 2 == 0) { \
return DispatchLayerNormWarpImplPadding< \
LOAD, \
Expand Down Expand Up @@ -691,17 +691,18 @@ DispatchLayerNormWarpImplCols(
DEFINE_ONE_ELIF(16)
DEFINE_ONE_ELIF(32)
#undef DEFINE_ONE_ELIF
#define DEFINE_ONE_ELIF(max_col, min_col) \
else if ((cols <= (max_col)*kWarpSize) && (cols > (min_col)*kWarpSize)) { \
return DispatchLayerNormWarpImplPadding< \
LOAD, \
STORE, \
ComputeType, \
pack_size, \
max_col, \
min_col, \
kWarpSize, \
1>(stream, load, store, rows, cols, epsilon, mean, inv_variance); \
#define DEFINE_ONE_ELIF(max_col, min_col) \
else if ( \
(cols <= (max_col) * kWarpSize) && (cols > (min_col) * kWarpSize)) { \
return DispatchLayerNormWarpImplPadding< \
LOAD, \
STORE, \
ComputeType, \
pack_size, \
max_col, \
min_col, \
kWarpSize, \
1>(stream, load, store, rows, cols, epsilon, mean, inv_variance); \
}
DEFINE_ONE_ELIF(4, 2)
DEFINE_ONE_ELIF(8, 4)
Expand Down Expand Up @@ -1518,55 +1519,55 @@ DispatchLayerNormGradWarpImplCols(
if (cols <= 0) {
return cudaErrorInvalidValue;
}
#define DEFINE_ONE_ELIF(thread_group_width) \
else if (cols <= (thread_group_width)*pack_size) { \
if (rows % 2 == 0) { \
return DispatchLayerNormGradWarpImplPadding< \
LOAD_X, \
LOAD_SCALED_DY, \
STORE, \
ComputeType, \
pack_size, \
pack_size, \
0, \
thread_group_width, \
2>( \
stream, \
load_x, \
load_scaled_dy, \
store, \
mean, \
inv_variance, \
rows, \
cols); \
} else { \
return DispatchLayerNormGradWarpImplPadding< \
LOAD_X, \
LOAD_SCALED_DY, \
STORE, \
ComputeType, \
pack_size, \
pack_size, \
0, \
thread_group_width, \
1>( \
stream, \
load_x, \
load_scaled_dy, \
store, \
mean, \
inv_variance, \
rows, \
cols); \
} \
#define DEFINE_ONE_ELIF(thread_group_width) \
else if (cols <= (thread_group_width) * pack_size) { \
if (rows % 2 == 0) { \
return DispatchLayerNormGradWarpImplPadding< \
LOAD_X, \
LOAD_SCALED_DY, \
STORE, \
ComputeType, \
pack_size, \
pack_size, \
0, \
thread_group_width, \
2>( \
stream, \
load_x, \
load_scaled_dy, \
store, \
mean, \
inv_variance, \
rows, \
cols); \
} else { \
return DispatchLayerNormGradWarpImplPadding< \
LOAD_X, \
LOAD_SCALED_DY, \
STORE, \
ComputeType, \
pack_size, \
pack_size, \
0, \
thread_group_width, \
1>( \
stream, \
load_x, \
load_scaled_dy, \
store, \
mean, \
inv_variance, \
rows, \
cols); \
} \
}
DEFINE_ONE_ELIF(4)
DEFINE_ONE_ELIF(8)
DEFINE_ONE_ELIF(16)
DEFINE_ONE_ELIF(32)
#undef DEFINE_ONE_ELIF
#define DEFINE_ONE_ELIF(max_col, min_col) \
else if (cols <= (max_col)*kWarpSize) { \
else if (cols <= (max_col) * kWarpSize) { \
return DispatchLayerNormGradWarpImplPadding< \
LOAD_X, \
LOAD_SCALED_DY, \
Expand Down
29 changes: 15 additions & 14 deletions python/aitemplate/backend/cuda/layernorm_sigmoid_mul/layer_norm.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ DispatchLayerNormWarpImplCols(
return cudaErrorInvalidValue;
}
#define DEFINE_ONE_ELIF(thread_group_width) \
else if (cols <= (thread_group_width)*pack_size) { \
else if (cols <= (thread_group_width) * pack_size) { \
if (rows % 2 == 0) { \
return DispatchLayerNormWarpImplPadding< \
LOAD, \
Expand Down Expand Up @@ -622,7 +622,7 @@ DispatchLayerNormWarpImplCols(
DEFINE_ONE_ELIF(32)
#undef DEFINE_ONE_ELIF
#define DEFINE_ONE_ELIF(max_col, min_col) \
else if (cols <= (max_col)*kWarpSize) { \
else if (cols <= (max_col) * kWarpSize) { \
return DispatchLayerNormWarpImplPadding< \
LOAD, \
STORE, \
Expand Down Expand Up @@ -663,7 +663,7 @@ DispatchLayerNormWarpImplCols(
return cudaErrorInvalidValue;
}
#define DEFINE_ONE_ELIF(thread_group_width) \
else if (cols <= (thread_group_width)*pack_size) { \
else if (cols <= (thread_group_width) * pack_size) { \
if (rows % 2 == 0) { \
return DispatchLayerNormWarpImplPadding< \
LOAD, \
Expand Down Expand Up @@ -691,17 +691,18 @@ DispatchLayerNormWarpImplCols(
DEFINE_ONE_ELIF(16)
DEFINE_ONE_ELIF(32)
#undef DEFINE_ONE_ELIF
#define DEFINE_ONE_ELIF(max_col, min_col) \
else if ((cols <= (max_col)*kWarpSize) && (cols > (min_col)*kWarpSize)) { \
return DispatchLayerNormWarpImplPadding< \
LOAD, \
STORE, \
ComputeType, \
pack_size, \
max_col, \
min_col, \
kWarpSize, \
1>(stream, load, store, rows, cols, epsilon, mean, inv_variance); \
#define DEFINE_ONE_ELIF(max_col, min_col) \
else if ( \
(cols <= (max_col) * kWarpSize) && (cols > (min_col) * kWarpSize)) { \
return DispatchLayerNormWarpImplPadding< \
LOAD, \
STORE, \
ComputeType, \
pack_size, \
max_col, \
min_col, \
kWarpSize, \
1>(stream, load, store, rows, cols, epsilon, mean, inv_variance); \
}
DEFINE_ONE_ELIF(4, 2)
DEFINE_ONE_ELIF(8, 4)
Expand Down
6 changes: 2 additions & 4 deletions static/csrc/standalone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,9 @@ struct AITStandaloneTestcase {

inputs.push_back(AITData(gpu_data_owner.back().get(), shape, dtype));
}
std::cout << "Finished loading testcase inputs."
<< "\n";
std::cout << "Finished loading testcase inputs." << "\n";
if (fh.peek() == std::ifstream::traits_type::eof()) {
std::cout << "No expected outputs in testcase."
<< "\n";
std::cout << "No expected outputs in testcase." << "\n";
return;
}
if (inputs.size() != num_inputs) {
Expand Down
19 changes: 7 additions & 12 deletions static/include/cuda_device_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ inline std::string GetUUIDToString(const char bytes[16]) {

inline std::string PrintDebugDeviceProperties(const DevicePropertyType& prop) {
std::ostringstream oss;
oss << "Hardware accelerator device properties: "
<< "\n Device: "
oss << "Hardware accelerator device properties: " << "\n Device: "
<< "\n ASCII string identifying device: " << prop.name
<< "\n Major compute capability: " << prop.major
<< "\n Minor compute capability: " << prop.minor
Expand Down Expand Up @@ -121,9 +120,8 @@ inline std::string PrintDebugDeviceProperties(const DevicePropertyType& prop) {
<< "\n Peak global memory bandwidth (GByte/s): "
<< (prop.memoryClockRate / 1e6) * (prop.memoryBusWidth / 8) * 2

<< "\n Thread limits: "
<< "\n Warp size in threads: " << prop.warpSize
<< "\n Maximum size of each dimension of a grid: "
<< "\n Thread limits: " << "\n Warp size in threads: "
<< prop.warpSize << "\n Maximum size of each dimension of a grid: "
<< prop.maxGridSize[0] << " " << prop.maxGridSize[1] << " "
<< prop.maxGridSize[2]
<< "\n Maximum size of each dimension of a block: "
Expand All @@ -145,8 +143,7 @@ inline std::string PrintDebugDeviceProperties(const DevicePropertyType& prop) {
<< "\n Max clock frequency of the multiProcessors in khz: "
<< prop.clockRate

<< "\n Device features: "
<< "\n Device has ECC support enabled: "
<< "\n Device features: " << "\n Device has ECC support enabled: "
<< (prop.ECCEnabled ? "yes" : "no")
<< "\n Device can map host memory with cudaHostAlloc/cudaHostGetDevicePointer: "
<< (prop.canMapHostMemory ? "yes" : "no")
Expand Down Expand Up @@ -185,9 +182,8 @@ inline std::string PrintDebugDeviceProperties(const DevicePropertyType& prop) {
<< "\n Device shares a unified address space with the host: "
<< (prop.unifiedAddressing ? "yes" : "no")

<< "\n Texture limits: "
<< "\n Maximum 1D surface size: " << prop.maxSurface1D
<< "\n Maximum 1D layered surface dimensions: "
<< "\n Texture limits: " << "\n Maximum 1D surface size: "
<< prop.maxSurface1D << "\n Maximum 1D layered surface dimensions: "
<< prop.maxSurface1DLayered[0] << " " << prop.maxSurface1DLayered[1]
<< "\n Maximum 2D surface dimensions: " << prop.maxSurface2D[0] << " "
<< prop.maxSurface2D[1]
Expand Down Expand Up @@ -234,8 +230,7 @@ inline std::string PrintDebugDeviceProperties(const DevicePropertyType& prop) {

inline std::string PrintInfoDeviceProperties(const DevicePropertyType& prop) {
std::ostringstream oss;
oss << "Hardware accelerator device properties: "
<< "\n Device: "
oss << "Hardware accelerator device properties: " << "\n Device: "
<< "\n ASCII string identifying device: " << prop.name
<< "\n Major compute capability: " << prop.major
<< "\n Minor compute capability: " << prop.minor
Expand Down
9 changes: 5 additions & 4 deletions static/include/kernels/kat_printf.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ struct components {
};
} // namespace double_
__attribute__((device)) static inline constexpr int get_sign_bit(double x) {
return (
int)(double_::with_bit_access::wrap(x).U >> (double_::size_in_bits - 1));
return (int)(double_::with_bit_access::wrap(x).U >>
(double_::size_in_bits - 1));
}
__attribute__((device)) static inline int get_exp2(double x) {
return double_::with_bit_access::wrap(x).exp2();
Expand Down Expand Up @@ -472,8 +472,9 @@ __attribute__((device)) static void print_integer(
} else {
do {
const char digit = (char)(value % base);
buf[len++] =
(char)(digit < 10 ? '0' + digit : (flags & flags::uppercase ? 'A' : 'a') + digit - 10);
buf[len++] = (char)(digit < 10 ? '0' + digit
: (flags & flags::uppercase ? 'A' : 'a') +
digit - 10);
value /= base;
} while (value && (len < detail_::printf::integer_buffer_size));
}
Expand Down
11 changes: 4 additions & 7 deletions static/include/rocm_device_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ inline std::string PrintArchFeatureFlags(const hipDeviceArch_t& arch) {

inline std::string PrintInfoDeviceProperties(const DevicePropertyType& prop) {
std::ostringstream oss;
oss << "Hardware accelerator device properties: "
<< "\n Device: "
oss << "Hardware accelerator device properties: " << "\n Device: "
<< "\n ASCII string identifying device: " << prop.name
<< "\n Major compute capability: " << prop.major
<< "\n Minor compute capability: " << prop.minor
Expand All @@ -113,8 +112,7 @@ inline std::string PrintInfoDeviceProperties(const DevicePropertyType& prop) {

inline std::string PrintDebugDeviceProperties(const DevicePropertyType& prop) {
std::ostringstream oss;
oss << "Hardware accelerator device properties: "
<< "\n Device: "
oss << "Hardware accelerator device properties: " << "\n Device: "
<< "\n ASCII string identifying device: " << prop.name
<< "\n Major compute capability: " << prop.major
<< "\n Minor compute capability: " << prop.minor
Expand All @@ -138,9 +136,8 @@ inline std::string PrintDebugDeviceProperties(const DevicePropertyType& prop) {
<< "\n Peak global memory bandwidth (GByte/s): "
<< (prop.memoryClockRate / 1e6) * (prop.memoryBusWidth / 8) * 2

<< "\n Thread limits: "
<< "\n Warp size in threads: " << prop.warpSize
<< "\n Maximum size of each dimension of a grid: "
<< "\n Thread limits: " << "\n Warp size in threads: "
<< prop.warpSize << "\n Maximum size of each dimension of a grid: "
<< prop.maxGridSize[0] << " " << prop.maxGridSize[1] << " "
<< prop.maxGridSize[2]
<< "\n Maximum size of each dimension of a block: "
Expand Down

0 comments on commit d6142ef

Please sign in to comment.