diff --git a/.clang-tidy b/.clang-tidy index 8e84f7e1b0..b1c12ada82 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -7,6 +7,7 @@ InheritParentConfig: true # @nolint Checks: ' -*, +cppcoreguidelines-init-variables, bugprone-argument-comment, misc-use-internal-linkage, modernize*, diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d175fbe96..2ac120ee8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,8 +208,11 @@ else(MSVC) string(APPEND CMAKE_CXX_FLAGS " -Wunknown-pragmas") string(APPEND CMAKE_CXX_FLAGS " -Wimplicit-fallthrough") string(APPEND CMAKE_CXX_FLAGS " -Wno-strict-aliasing") + string(APPEND CMAKE_CXX_FLAGS " -Wunused-variable") if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 17.0.0) string(APPEND CMAKE_CXX_FLAGS " -Wno-vla-cxx-extension") + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + string(APPEND CMAKE_CXX_FLAGS " -Wmaybe-uninitialized") endif() target_compile_options(fbgemm_avx2 PRIVATE "-m64" "-mavx2" "-mf16c" "-mfma") diff --git a/bench/AlignedVec.h b/bench/AlignedVec.h index f7e739d8f8..115bc850ef 100644 --- a/bench/AlignedVec.h +++ b/bench/AlignedVec.h @@ -107,10 +107,9 @@ class aligned_allocator { // Mallocator wraps malloc(). void* pv = nullptr; - int ret; + int ret = 0; #ifdef _MSC_VER pv = _aligned_malloc(n * sizeof(T), Alignment); - ret = 0; #else ret = posix_memalign(&pv, Alignment, n * sizeof(T)); #endif diff --git a/bench/BenchUtils.cc b/bench/BenchUtils.cc index aa282131c2..f124744234 100644 --- a/bench/BenchUtils.cc +++ b/bench/BenchUtils.cc @@ -150,9 +150,8 @@ aligned_vector getRandomSparseVector( std::sort(sorted_res.begin(), sorted_res.end()); int32_t numZeros = size - static_cast(std::round(size * fractionNonZeros)); - float thr; if (numZeros) { - thr = sorted_res[numZeros - 1]; + float thr = sorted_res[numZeros - 1]; for (auto& f : res) { if (f <= thr) { diff --git a/bench/BenchUtils.h b/bench/BenchUtils.h index 0dc786fc1c..9953f77295 100644 --- a/bench/BenchUtils.h +++ b/bench/BenchUtils.h @@ -28,6 +28,7 @@ #ifdef _OPENMP #include +#include #endif #ifdef USE_MKL @@ -136,8 +137,6 @@ double measureWithWarmup( { #endif for (int i = 0; i < measuredIterations; ++i) { - std::chrono::time_point start, end; - const auto thread_id = useOpenMP ? fbgemm_get_thread_num() : 0; if (thread_id == 0) { @@ -149,7 +148,7 @@ double measureWithWarmup( #pragma omp barrier } #endif - start = std::chrono::high_resolution_clock::now(); + auto start = std::chrono::high_resolution_clock::now(); fn(); @@ -159,7 +158,7 @@ double measureWithWarmup( } #endif - end = std::chrono::high_resolution_clock::now(); + auto end = std::chrono::high_resolution_clock::now(); auto dur = std::chrono::duration_cast(end - start); @@ -256,7 +255,6 @@ void performance_test( #endif std::string type; - double gflops, gbs, ttot; for (auto s : shapes) { int m = s[0]; int n = s[1]; @@ -266,6 +264,7 @@ void performance_test( aligned_vector Aint(m * k); randFill(Aint, 0, 4); std::vector> A; + A.reserve(num_instances); for (int i = 0; i < num_instances; ++i) { A.emplace_back(Aint.begin(), Aint.end()); } @@ -321,6 +320,7 @@ void performance_test( double nflops = 2.0 * m * n * k; double nbytes = 4.0 * m * k + sizeof(btype) * 1.0 * k * n + 4.0 * m * n; + double gflops = 0, gbs = 0, ttot = 0.0; // warm up MKL and fbgemm // check correctness at the same time diff --git a/bench/EmbeddingIndexRemappingBenchmark.cc b/bench/EmbeddingIndexRemappingBenchmark.cc index a28adbd58b..df885b86fb 100644 --- a/bench/EmbeddingIndexRemappingBenchmark.cc +++ b/bench/EmbeddingIndexRemappingBenchmark.cc @@ -135,9 +135,9 @@ static int run_benchmark( } int main() { - int batch_size; - int num_rows; - int average_len; + int batch_size = 0; + int num_rows = 0; + int average_len = 0; vector> inputs(GetInputs_()); diff --git a/bench/EmbeddingSpMDMBenchmark.cc b/bench/EmbeddingSpMDMBenchmark.cc index 1f9d526e07..97dd471e4c 100644 --- a/bench/EmbeddingSpMDMBenchmark.cc +++ b/bench/EmbeddingSpMDMBenchmark.cc @@ -12,7 +12,6 @@ #endif #include #include -#include #include #include #include diff --git a/bench/EmbeddingSpMDMNBit2Benchmark.cc b/bench/EmbeddingSpMDMNBit2Benchmark.cc index 25172a73e3..0d9da565e8 100644 --- a/bench/EmbeddingSpMDMNBit2Benchmark.cc +++ b/bench/EmbeddingSpMDMNBit2Benchmark.cc @@ -12,7 +12,6 @@ #endif #include #include -#include #include #include #include diff --git a/bench/EmbeddingSpMDMNBitBenchmark.cc b/bench/EmbeddingSpMDMNBitBenchmark.cc index d1693c871a..7adbe774fc 100644 --- a/bench/EmbeddingSpMDMNBitBenchmark.cc +++ b/bench/EmbeddingSpMDMNBitBenchmark.cc @@ -492,10 +492,10 @@ static int run_benchmark( } int main() { - int batch_size; - int num_rows; - int embedding_dim; - int average_len; + int batch_size = 0; + int num_rows = 0; + int embedding_dim = 0; + int average_len = 0; vector> inputs(GetInputs_()); diff --git a/bench/EmbeddingSpMDMNBitRowWiseSparseBenchmark.cc b/bench/EmbeddingSpMDMNBitRowWiseSparseBenchmark.cc index 1dd102f636..580f9d4aca 100644 --- a/bench/EmbeddingSpMDMNBitRowWiseSparseBenchmark.cc +++ b/bench/EmbeddingSpMDMNBitRowWiseSparseBenchmark.cc @@ -325,10 +325,10 @@ static int run_benchmark( } int main() { - int batch_size; - int num_rows; - int embedding_dim; - int average_len; + int batch_size = 0; + int num_rows = 0; + int embedding_dim = 0; + int average_len = 0; vector> inputs(GetInputs_()); diff --git a/bench/RowwiseAdagradBenchmark.cc b/bench/RowwiseAdagradBenchmark.cc index ab389354d9..7c143d012c 100644 --- a/bench/RowwiseAdagradBenchmark.cc +++ b/bench/RowwiseAdagradBenchmark.cc @@ -192,9 +192,9 @@ static void run_benchmark( } int main() { - int num_rows; - int block_size; - uint64_t param_size; + int num_rows = 0; + int block_size = 0; + uint64_t param_size = 0; vector> inputs(GetInputs_()); for (auto isIndex64b : vector{true, false}) { diff --git a/bench/SparseAdagradBenchmark.cc b/bench/SparseAdagradBenchmark.cc index cc2d6ab517..39ab6825af 100644 --- a/bench/SparseAdagradBenchmark.cc +++ b/bench/SparseAdagradBenchmark.cc @@ -199,9 +199,9 @@ static void run_benchmark( } int main() { - int num_rows; - int block_size; - uint64_t param_size; + int num_rows = 0; + int block_size = 0; + uint64_t param_size = 0; vector> inputs(GetInputs_()); for (auto isIndex64b : vector{true, false}) { diff --git a/include/fbgemm/ConvUtils.h b/include/fbgemm/ConvUtils.h index 0d0c43cbcf..e14ed8c9ae 100644 --- a/include/fbgemm/ConvUtils.h +++ b/include/fbgemm/ConvUtils.h @@ -16,30 +16,26 @@ namespace fbgemm { template -constexpr - typename std::enable_if>::type - array_of_ones() { +constexpr std::enable_if_t> +array_of_ones() { return std::array{{Vals...}}; } template -constexpr - typename std::enable_if>::type - array_of_ones() { +constexpr std::enable_if_t> +array_of_ones() { return array_of_ones(); } template -constexpr - typename std::enable_if>::type - array_of_zeroes() { +constexpr std::enable_if_t> +array_of_zeroes() { return std::array{{Vals...}}; } template -constexpr - typename std::enable_if>::type - array_of_zeroes() { +constexpr std::enable_if_t> +array_of_zeroes() { return array_of_zeroes(); } diff --git a/include/fbgemm/FloatConversion.h b/include/fbgemm/FloatConversion.h index bae8942451..ba10f45547 100644 --- a/include/fbgemm/FloatConversion.h +++ b/include/fbgemm/FloatConversion.h @@ -8,6 +8,8 @@ #pragma once +#include + #include #include #include @@ -211,7 +213,7 @@ template } // namespace detail inline float16 cpu_float2half_rn(float f) { - uint32_t f_u32; + uint32_t f_u32 = 0; std::memcpy(&f_u32, &f, sizeof(f_u32)); return detail::ieee754_trunc< /*Src=*/detail::IEEE754Single, @@ -220,7 +222,7 @@ inline float16 cpu_float2half_rn(float f) { } inline float16 cpu_float2half_rz(float f) { - uint32_t f_u32; + uint32_t f_u32 = 0; std::memcpy(&f_u32, &f, sizeof(f_u32)); return detail::ieee754_trunc< /*Src=*/detail::IEEE754Single, @@ -263,7 +265,7 @@ inline float cpu_half2float_ref(const float16 h) { exponent = f32_exponent_mask; } else if (!exponent) { // Denorm or Zero if (mantissa) { - uint32_t msb; + uint32_t msb = 0; exponent = f32_exponent_bias - f16_exponent_bias + 1; do { msb = mantissa & f32_most_significant_bit; @@ -279,7 +281,7 @@ inline float cpu_half2float_ref(const float16 h) { const uint32_t i = (sign_bit << f32_num_non_sign_bits) | (exponent << f32_num_mantissa_bits) | mantissa; - float ret; + float ret = NAN; std::memcpy(&ret, &i, sizeof(float)); return ret; } @@ -288,7 +290,7 @@ inline float cpu_half2float_ref(const float16 h) { // conversion provided by the compiler inline float cpu_half2float(const float16 h) { #if defined(HAS_NATIVE_FP16_TYPE) && not defined(MISSING_GNU_F2H_IEEE) - __fp16 h_fp16; + __fp16 h_fp16 = NAN; std::memcpy(&h_fp16, &h, sizeof(__fp16)); return h_fp16; #else @@ -299,7 +301,7 @@ inline float cpu_half2float(const float16 h) { inline float16 cpu_float2half(const float f) { #if defined(HAS_NATIVE_FP16_TYPE) && not defined(MISSING_GNU_F2H_IEEE) __fp16 h = f; - float16 res; + float16 res = 0; std::memcpy(&res, &h, sizeof(__fp16)); return res; #else @@ -308,7 +310,7 @@ inline float16 cpu_float2half(const float f) { } inline float cpu_bf162float(bfloat16 src) { - float ret; + float ret = NAN; uint32_t val_fp32 = static_cast(reinterpret_cast(&src)[0]) << 16; std::memcpy(&ret, &val_fp32, sizeof(float)); @@ -316,7 +318,7 @@ inline float cpu_bf162float(bfloat16 src) { } inline bfloat16 cpu_float2bfloat16(float src) { - uint32_t temp; + uint32_t temp = 0; std::memcpy(&temp, &src, sizeof(uint32_t)); return (temp + (1u << 15)) >> 16; } diff --git a/include/fbgemm/QuantUtils.h b/include/fbgemm/QuantUtils.h index bed5c475d4..034bf053fe 100644 --- a/include/fbgemm/QuantUtils.h +++ b/include/fbgemm/QuantUtils.h @@ -68,7 +68,7 @@ T Quantize( std::int32_t zero_point, float scale, int result_precision, - bool result_is_signed = std::is_signed::value) { + bool result_is_signed = std::is_signed_v) { // Note: We want to multiply with src with inv_scale instead of // dividing src by scale. The same is done in vector code and // at other places. @@ -162,7 +162,7 @@ void Dequantize( const TensorQuantizationParams& qparams, int thread_id = 0, int num_threads = 1) { - int64_t i_begin, i_end; + int64_t i_begin = 0, i_end = 0; fbgemmPartition1D(thread_id, num_threads, len, i_begin, i_end); for (int64_t i = i_begin; i < i_end; i++) { dst[i] = Dequantize(src[i], qparams); diff --git a/include/fbgemm/QuantUtilsAvx2.h b/include/fbgemm/QuantUtilsAvx2.h index d5a479f24d..ef0d4a58a5 100644 --- a/include/fbgemm/QuantUtilsAvx2.h +++ b/include/fbgemm/QuantUtilsAvx2.h @@ -71,7 +71,7 @@ void FusedQuantizeDequantizeAvx2( /// /// Random number generator in [0, 9] based on /// this paper. -uint32_t FBGEMM_API Xor128(void); +uint32_t FBGEMM_API Xor128(); /// @ingroup fbgemm-quant-utils-avx2 /// diff --git a/include/fbgemm/Utils.h b/include/fbgemm/Utils.h index 3d422de7fa..8836792ece 100644 --- a/include/fbgemm/Utils.h +++ b/include/fbgemm/Utils.h @@ -35,7 +35,7 @@ namespace fbgemm { template struct is_8bit { static constexpr bool value = - std::is_same::value || std::is_same::value; + std::is_same_v || std::is_same_v; }; /** @@ -263,8 +263,8 @@ std::string arrayToString(const std::array& inp) { template bool isValidBlockingFactor(const BlockingFactors* const param) { - constexpr bool is_32bit = std::is_same::value; - constexpr bool is_16bit = std::is_same::value; + constexpr bool is_32bit = std::is_same_v; + constexpr bool is_16bit = std::is_same_v; static const auto iset = fbgemmInstructionSet(); if constexpr (is_32bit) { @@ -447,7 +447,7 @@ void nbit_embedding_sanity_check( assert( (input_bit_rate == 2 || input_bit_rate == 4) && "input_bit_rate must be 2 or 4"); - if constexpr (std::is_same::value) { + if constexpr (std::is_same_v) { assert( (no_bag && input_bit_rate == 4 && output_bit_rate == 4) && "we currently only support int4 to int4 for sequential TBE"); diff --git a/src/CodeGenHelpers.h b/src/CodeGenHelpers.h index e461814fd9..b976810b95 100644 --- a/src/CodeGenHelpers.h +++ b/src/CodeGenHelpers.h @@ -91,8 +91,8 @@ template < int> = 0> void emitExtractHalfVector( x86::Emitter* a, - x86::Ymm half, - const x86::Zmm vec, + const x86::Ymm& half, + const x86::Zmm& vec, int idx) { a->vextracti32x8(half, vec, idx); } @@ -107,8 +107,8 @@ template < int> = 0> void emitExtractHalfVector( x86::Emitter* a, - x86::Xmm half, - x86::Ymm vec, + const x86::Xmm& half, + const x86::Ymm& vec, int idx) { a->vextracti32x4(half, vec, idx); } @@ -119,8 +119,8 @@ template < std::enable_if_t = 0> void emitExtractHalfVector( x86::Emitter* a, - x86::Xmm half, - x86::Ymm vec, + const x86::Xmm& half, + const x86::Ymm& vec, int idx) { a->vextracti128(half, vec, idx); } diff --git a/src/EmbeddingSpMDM.cc b/src/EmbeddingSpMDM.cc index 25285e2cf1..732383e4e8 100644 --- a/src/EmbeddingSpMDM.cc +++ b/src/EmbeddingSpMDM.cc @@ -425,7 +425,7 @@ GenEmbeddingSpMDMLookup< x86::Xmm mask_fp16_vreg; // mask for loading fp16 in avx2 vec_reg_t ones_vreg; // 2^15 for bf16_2_fp32_rn - if (is_8bit_in) { + if constexpr (is_8bit_in) { // We need 2 vec registers for 1. scale 2. bias --unroll_factor; scale_vreg = vec_reg_t(unroll_factor); @@ -687,7 +687,7 @@ GenEmbeddingSpMDMLookup< // broadcast the scale x86::Mem scale_src, bias_src; constexpr unsigned int CACHE_LINE_LEN = 64; - if (is_8bit_in) { + if constexpr (is_8bit_in) { if (scale_bias_last) { scale_src = x86::dword_ptr( input, scratchReg1_, 0, block_size * sizeof(uint8_t)); @@ -737,7 +737,7 @@ GenEmbeddingSpMDMLookup< // For 8bit SLS convert usigned 8-bit to 32bit int, then to float // multiply with scale and then add with bias - if (is_8bit_in) { + if constexpr (is_8bit_in) { if (remainder && vec_idx + v == num_vec_regs_per_block - 1 && instSet == inst_set_t::avx512) { a->k(x86::k(1)).z().vpmovzxbd(src_vreg, src_addr); @@ -750,7 +750,7 @@ GenEmbeddingSpMDMLookup< a->vcvtdq2ps(src_vreg, src_vreg); a->vaddps(out_vreg, out_vreg, bias_vreg); a->vfmadd231ps(out_vreg, src_vreg, scale_vreg); - } else if (is_16bit_in) { + } else if constexpr (is_16bit_in) { if (remainder && vec_idx + v == num_vec_regs_per_block - 1) { if constexpr (instSet == inst_set_t::avx2) { if (remainder % 2 == 0) { @@ -990,11 +990,12 @@ GenEmbeddingSpMDMLookup< offsetType, outType, ROWWISE_SPARSE>::jit_embedding_kernel fn; - asmjit::Error err; + asmjit::Error err = 0; { std::unique_lock lock(rtMutex_); err = runtime().add(&fn, &code); } + if (err) { std::cout << "Error: in fn add" << std::endl; return nullptr; diff --git a/src/EmbeddingSpMDMAutovec.cc b/src/EmbeddingSpMDMAutovec.cc index 515702fed7..bd7ecd7c8c 100644 --- a/src/EmbeddingSpMDMAutovec.cc +++ b/src/EmbeddingSpMDMAutovec.cc @@ -15,13 +15,14 @@ #include "fbgemm/FbgemmBuild.h" #include "fbgemm/FloatConversion.h" +#include + #include #include #include #include #include -#include -#include +#include /// @defgroup tbe-cpu-autovec TBE CPU Autovectorization (FP8/16/32) @@ -125,7 +126,7 @@ static bool ALWAYS_INLINE EmbeddingSpMDM8Bit_autovec( std::array local_storage; std::unique_ptr heap_storage; - float* buf; + float* buf = nullptr; if (static_cast(block_size) <= LOCAL_STORAGE_SIZE) { buf = local_storage.data(); } else { @@ -147,19 +148,18 @@ static bool ALWAYS_INLINE EmbeddingSpMDM8Bit_autovec( } else { memset(buf, 0, sizeof(float) * block_size); - float scale; - float bias; + float scale = NAN; + float bias = NAN; const uint8_t* scale_bias_addr = input_row_base + scale_bias_offset; if (scale_bias_last) { - memcpy(&scale, scale_bias_addr, sizeof(float)); - memcpy(&bias, scale_bias_addr + sizeof(float), sizeof(float)); + scale = *(reinterpret_cast(scale_bias_addr)); + bias = *( + reinterpret_cast(scale_bias_addr + sizeof(float))); } else { - float16 scale16; - float16 bias16; - memcpy(&scale16, scale_bias_addr, sizeof(float16)); - memcpy(&bias16, scale_bias_addr + sizeof(float16), sizeof(float16)); - scale = cpu_half2float(scale16); - bias = cpu_half2float(bias16); + scale = cpu_half2float( + *reinterpret_cast(scale_bias_addr)); + bias = cpu_half2float(*reinterpret_cast( + scale_bias_addr + sizeof(float16))); } if (weights) { float weight = weights[m]; @@ -241,18 +241,17 @@ static bool ALWAYS_INLINE EmbeddingSpMDM8Bit_autovec( const uint8_t* input_row_base = input + input_stride * idx; const uint8_t* scale_bias_addr = input_row_base + scale_bias_offset; - float scale; - float bias; + float scale = NAN; + float bias = NAN; if (scale_bias_last) { - memcpy(&scale, scale_bias_addr, sizeof(float)); - memcpy(&bias, scale_bias_addr + sizeof(float), sizeof(float)); + scale = *(reinterpret_cast(scale_bias_addr)); + bias = + *(reinterpret_cast(scale_bias_addr + sizeof(float))); } else { - float16 scale16; - float16 bias16; - memcpy(&scale16, scale_bias_addr, sizeof(float16)); - memcpy(&bias16, scale_bias_addr + sizeof(float16), sizeof(float16)); - scale = cpu_half2float(scale16); - bias = cpu_half2float(bias16); + scale = + cpu_half2float(*reinterpret_cast(scale_bias_addr)); + bias = cpu_half2float(*reinterpret_cast( + scale_bias_addr + sizeof(float16))); } if (weights != nullptr) { @@ -373,7 +372,7 @@ static bool ALWAYS_INLINE EmbeddingSpMDMNBit_autovec( std::array local_storage; std::unique_ptr heap_storage; - float* buf; + float* buf = nullptr; if (static_cast(rounded_block_size) <= LOCAL_STORAGE_SIZE) { buf = local_storage.data(); } else { @@ -415,10 +414,9 @@ static bool ALWAYS_INLINE EmbeddingSpMDMNBit_autovec( const uint8_t* scale_bias_addr = input_row_base + scale_bias_offset; const uint8_t* input_row = input_row_base + input_row_offset; - float16 scale16; - float16 bias16; - memcpy(&scale16, scale_bias_addr, sizeof(float16)); - memcpy(&bias16, scale_bias_addr + sizeof(float16), sizeof(float16)); + float16 scale16 = *reinterpret_cast(scale_bias_addr); + float16 bias16 = + *reinterpret_cast(scale_bias_addr + sizeof(float16)); static_assert(sizeof(scale16) + sizeof(bias16) == scale_bias_size); float scale = cpu_half2float(scale16); @@ -561,7 +559,7 @@ static bool ALWAYS_INLINE EmbeddingSpMDM_autovec( std::array local_storage; std::unique_ptr heap_storage; - float* buf; + float* buf = nullptr; if (static_cast(block_size) <= LOCAL_STORAGE_SIZE) { buf = local_storage.data(); } else { @@ -780,10 +778,9 @@ static bool ALWAYS_INLINE EmbeddingSpMDMRowWiseSparse_autovec( const uint8_t* scale_bias_addr = reinterpret_cast( input + fused_block_size * idx + block_size); - float scale; - float bias; - memcpy(&scale, scale_bias_addr, sizeof(float)); - memcpy(&bias, scale_bias_addr + sizeof(float), sizeof(float)); + float scale = *(reinterpret_cast(scale_bias_addr)); + float bias = + *(reinterpret_cast(scale_bias_addr + sizeof(float))); if (weights != nullptr) { float weight = *weights_addr++; scale *= weight; @@ -892,7 +889,7 @@ void Float8ToFloat_ref_batch( int exponent_bits, int exponent_bias) { for (int i = 0; i < count; ++i) { - uint32_t val_out, sign, multiplier; + uint32_t val_out = 0, sign = 0, multiplier = 0; uint8_t inp = input[i]; sign = (inp & 0x80) << 24; @@ -962,7 +959,7 @@ static bool ALWAYS_INLINE EmbeddingSpMDMFP8_autovec( std::array local_storage; std::unique_ptr heap_storage; - float* buf; + float* buf = nullptr; if (static_cast(block_size) <= LOCAL_STORAGE_SIZE) { buf = local_storage.data(); } else { diff --git a/src/EmbeddingSpMDMNBit.cc b/src/EmbeddingSpMDMNBit.cc index bc7c3a0375..6ff57e0dfc 100644 --- a/src/EmbeddingSpMDMNBit.cc +++ b/src/EmbeddingSpMDMNBit.cc @@ -993,7 +993,7 @@ GenEmbeddingSpMDMNBitLookup< offsetType, outType, ROWWISE_SPARSE>::jit_embedding_kernel fn; - asmjit::Error err; + asmjit::Error err = 0; { unique_lock lock(rtMutex_); err = runtime().add(&fn, &code); diff --git a/src/EmbeddingStatsTrackerConfig.h b/src/EmbeddingStatsTrackerConfig.h index e73a378b39..bd178db672 100644 --- a/src/EmbeddingStatsTrackerConfig.h +++ b/src/EmbeddingStatsTrackerConfig.h @@ -8,6 +8,7 @@ #pragma once +#include #include #include diff --git a/src/ExecuteKernelU8S8.cc b/src/ExecuteKernelU8S8.cc index fd601521be..38be2b0b2b 100644 --- a/src/ExecuteKernelU8S8.cc +++ b/src/ExecuteKernelU8S8.cc @@ -114,8 +114,8 @@ void ExecuteKernel< int32_t bColBlocks = packedB_.blockCols(); - int8_t* bBuf; - int8_t* bBuf_pf; + int8_t* bBuf = nullptr; + int8_t* bBuf_pf = nullptr; uint8_t* aBuf = packedA_.getBuf(0); @@ -127,7 +127,7 @@ void ExecuteKernel< bool lastKBlock = packedB_.isThisLastKBlock(kBlock % packedB_.blockRows()); bool accum = (kBlock % packedB_.blockRows()) > 0; - int64_t jb_begin, jb_end; + int64_t jb_begin = 0, jb_end = 0; fbgemmPartition1D( th_info_.n_thread_id, th_info_.n_num_threads, diff --git a/src/Fbgemm.cc b/src/Fbgemm.cc index 3699d64bb0..47778ce71c 100644 --- a/src/Fbgemm.cc +++ b/src/Fbgemm.cc @@ -58,9 +58,9 @@ void fbgemmPacked( throw std::runtime_error("unknown architecure"); } - int64_t MCB; - int KCB; - int MR; + int64_t MCB = 0; + int KCB = 0; + int MR = 0; if (blocking_params) { MCB = blocking_params->MCB; @@ -129,7 +129,7 @@ void fbgemmPacked( // remainders int _kc = KDimPerGroup % KCB; - int kc, mc; + int kc = 0, mc = 0; block_type_t blockA{0, 0, 0, 0}; @@ -146,7 +146,7 @@ void fbgemmPacked( // if (thread_id == 0) // std::cout << ", " << th_info.toString(); - int64_t g_begin, g_end, i_begin, i_end; + int64_t g_begin = 0, g_end = 0, i_begin = 0, i_end = 0; // Calculate the begin and end index along the group dimension fbgemmPartition1D( diff --git a/src/FbgemmI64.cc b/src/FbgemmI64.cc index e73525229d..c759421508 100644 --- a/src/FbgemmI64.cc +++ b/src/FbgemmI64.cc @@ -120,11 +120,10 @@ CodeGenBase::getOrCreate( int32_t /* unused */) { static constexpr int vectorLen = simd_info::WIDTH_BITS / 64; - tuple kernelSig; - int kBlock; - int nBlock; - int mRegBlockSize; - int nRegBlockSize; + int kBlock = 0; + int nBlock = 0; + int mRegBlockSize = 0; + int nRegBlockSize = 0; if (blocking_params) { kBlock = blocking_params->KCB; @@ -138,7 +137,7 @@ CodeGenBase::getOrCreate( nRegBlockSize = PackingTraits::NR; } - kernelSig = + auto kernelSig = make_tuple(accum, mc, nc, nBlock, kBlock, mRegBlockSize, nRegBlockSize); return codeCache_.getOrCreate(kernelSig, [&]() -> jit_micro_kernel_fp { @@ -376,8 +375,8 @@ CodeGenBase::getOrCreate( a->emitEpilog(frame); - jit_micro_kernel_fp fn; - asmjit::Error err; + jit_micro_kernel_fp fn = nullptr; + asmjit::Error err = 0; { unique_lock lock(rtMutex_); err = runtime().add(&fn, &code); @@ -439,7 +438,7 @@ void cblas_gemm_i64_i64acc( CodeGenType codeObj; CodeGenType::jit_micro_kernel_fp fn = codeObj.getOrCreate(true /* accum */, MCB, NCB, KCB); - CodeGenType::jit_micro_kernel_fp fn_noacc; + CodeGenType::jit_micro_kernel_fp fn_noacc = nullptr; if (!accumulate) { fn_noacc = codeObj.getOrCreate( false /* accum */, MCB, NCB, KCB); diff --git a/src/FbgemmI8Depthwise2DAvx2-inl.h b/src/FbgemmI8Depthwise2DAvx2-inl.h index 8ab427cbec..10a1c83b1e 100644 --- a/src/FbgemmI8Depthwise2DAvx2-inl.h +++ b/src/FbgemmI8Depthwise2DAvx2-inl.h @@ -155,7 +155,8 @@ static ALWAYS_INLINE void depthwise_2d_( int32_t* row_offsets = static_cast( fbgemmAlignedAlloc(64, (IC + 31) / 32 * 32 * sizeof(int32_t))); - int64_t n_begin, n_end, h_begin, h_end, w_begin, w_end; + int64_t n_begin = 0, n_end = 0, h_begin = 0, h_end = 0, w_begin = 0, + w_end = 0; // Reuse the 3-dim partition scheme for parallelization in matrix // multiplication. thread_type_t th_info = @@ -170,7 +171,7 @@ static ALWAYS_INLINE void depthwise_2d_( fbgemmPartition1D( th_info.n_thread_id, th_info.n_num_threads, W_OUT, w_begin, w_end); - GenI8Depthwise::jit_kernel_signature middle_kernel; + GenI8Depthwise::jit_kernel_signature middle_kernel{}; for (int n = n_begin; n < n_end; ++n) { const std::uint8_t* A_base = A + n * H * W * IC; diff --git a/src/FbgemmI8Depthwise3DAvx2.cc b/src/FbgemmI8Depthwise3DAvx2.cc index 20727837a5..4200f3e991 100644 --- a/src/FbgemmI8Depthwise3DAvx2.cc +++ b/src/FbgemmI8Depthwise3DAvx2.cc @@ -170,7 +170,8 @@ static ALWAYS_INLINE void depthwise_3d_same_pad_( int32_t* row_offsets = static_cast( fbgemmAlignedAlloc(64, (IC + 31) / 32 * 32 * sizeof(int32_t))); - int64_t n_begin, n_end, t_begin, t_end, h_begin, h_end; + int64_t n_begin = 0, n_end = 0, t_begin = 0, t_end = 0, h_begin = 0, + h_end = 0; // Reuse the 3-dim partition scheme for parallelization in matrix // multiplication. thread_type_t th_info = @@ -185,15 +186,15 @@ static ALWAYS_INLINE void depthwise_3d_same_pad_( fbgemmPartition1D( th_info.n_thread_id, th_info.n_num_threads, H_OUT, h_begin, h_end); - GenI8Depthwise::jit_kernel_signature middle_kernel; + GenI8Depthwise::jit_kernel_signature middle_kernel = nullptr; for (int n = n_begin; n < n_end; ++n) { const uint8_t* A_base = A + n * T * H * W * IC; uint8_t* C_uint8_base = C_uint8 + n * T_OUT * H_OUT * W_OUT * OC; - int t; + int t = 0; for (t = t_begin; t < PAD_P; ++t) { - int h; + int h = 0; for (h = h_begin; h < PAD_T; ++h) { for (int w = 0; w < W_OUT; ++w) { depthwise_3d_kernel_< @@ -230,7 +231,7 @@ static ALWAYS_INLINE void depthwise_3d_same_pad_( } // h for (; h < std::min(H_OUT - PAD_B - stride_h + 1, h_end); ++h) { - int w; + int w = 0; for (w = 0; w < PAD_L; ++w) { depthwise_3d_kernel_< FUSE_RELU, @@ -264,7 +265,7 @@ static ALWAYS_INLINE void depthwise_3d_same_pad_( act_times_w_scale); } // w - GenI8Depthwise::jit_kernel_signature kernel; + GenI8Depthwise::jit_kernel_signature kernel = nullptr; for (; w < W_OUT - PAD_R - stride_w + 1; ++w) { if (w == PAD_L) { int remainder = OC % 32; @@ -389,7 +390,7 @@ static ALWAYS_INLINE void depthwise_3d_same_pad_( } // t for (; t < std::min(T_OUT - PAD_N - stride_t + 1, t_end); ++t) { - int h; + int h = 0; for (h = h_begin; h < PAD_T; ++h) { for (int w = 0; w < W_OUT; ++w) { depthwise_3d_kernel_< @@ -426,7 +427,7 @@ static ALWAYS_INLINE void depthwise_3d_same_pad_( } // h for (; h < std::min(H_OUT - PAD_B - stride_h + 1, h_end); ++h) { - int w; + int w = 0; for (w = 0; w < PAD_L; ++w) { depthwise_3d_kernel_< FUSE_RELU, @@ -583,7 +584,7 @@ static ALWAYS_INLINE void depthwise_3d_same_pad_( } // t for (; t < t_end; ++t) { - int h; + int h = 0; for (h = h_begin; h < PAD_T; ++h) { for (int w = 0; w < W_OUT; ++w) { depthwise_3d_kernel_< @@ -620,7 +621,7 @@ static ALWAYS_INLINE void depthwise_3d_same_pad_( } // h for (; h < std::min(H_OUT - PAD_B - stride_h + 1, h_end); ++h) { - int w; + int w = 0; for (w = 0; w < PAD_L; ++w) { depthwise_3d_kernel_< FUSE_RELU, @@ -654,7 +655,7 @@ static ALWAYS_INLINE void depthwise_3d_same_pad_( act_times_w_scale); } // w - GenI8Depthwise::jit_kernel_signature kernel; + GenI8Depthwise::jit_kernel_signature kernel = nullptr; for (; w < W_OUT - PAD_R - stride_w + 1; ++w) { if (w == PAD_L) { int remainder = OC % 32; diff --git a/src/FbgemmI8DepthwiseAvx2-inl.h b/src/FbgemmI8DepthwiseAvx2-inl.h index ead56e1c96..6b4f7542a1 100644 --- a/src/FbgemmI8DepthwiseAvx2-inl.h +++ b/src/FbgemmI8DepthwiseAvx2-inl.h @@ -17,6 +17,7 @@ #if defined(__x86_64__) || defined(__i386__) || \ (defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86))) #include +#include #endif namespace fbgemm { @@ -58,7 +59,7 @@ static ALWAYS_INLINE void requantize_( __m256i min_v = _mm256_set1_epi8(static_cast(0)); __m256i max_v = _mm256_set1_epi8(static_cast(255)); - if (A_SYMMETRIC) { + if constexpr (A_SYMMETRIC) { assert(A_zero_point == 0 || col_offsets == nullptr); } __m256i A_zero_point_v = _mm256_set1_epi32(A_zero_point); @@ -81,7 +82,7 @@ static ALWAYS_INLINE void requantize_( reinterpret_cast(C_int32 + j + 3 * VLEN)); __m256i row_offset_v; - if (!B_SYMMETRIC) { + if constexpr (!B_SYMMETRIC) { if (K_PER_G == 1) { row_offset_v = _mm256_loadu_si256( reinterpret_cast(row_offsets + j)); @@ -111,7 +112,7 @@ static ALWAYS_INLINE void requantize_( x_v = _mm256_sub_epi32(x_v, row_offset_v); } __m256i col_off_v; - if (!A_SYMMETRIC) { + if constexpr (!A_SYMMETRIC) { col_off_v = _mm256_mullo_epi32( A_zero_point_v, _mm256_loadu_si256( @@ -119,8 +120,8 @@ static ALWAYS_INLINE void requantize_( x_v = _mm256_sub_epi32(x_v, col_off_v); } - if (!B_SYMMETRIC) { - if (K_PER_G == 1) { + if constexpr (!B_SYMMETRIC) { + if constexpr (K_PER_G == 1) { row_offset_v = _mm256_loadu_si256( reinterpret_cast(row_offsets + j + VLEN)); } else { @@ -147,7 +148,7 @@ static ALWAYS_INLINE void requantize_( row_offset_v = _mm256_mullo_epi32(row_offset_v, B_zero_point_v); y_v = _mm256_sub_epi32(y_v, row_offset_v); } - if (!A_SYMMETRIC) { + if constexpr (!A_SYMMETRIC) { col_off_v = _mm256_mullo_epi32( A_zero_point_v, _mm256_loadu_si256( @@ -155,7 +156,7 @@ static ALWAYS_INLINE void requantize_( y_v = _mm256_sub_epi32(y_v, col_off_v); } - if (!B_SYMMETRIC) { + if constexpr (!B_SYMMETRIC) { if (K_PER_G == 1) { row_offset_v = _mm256_loadu_si256( reinterpret_cast(row_offsets + j + 2 * VLEN)); @@ -183,7 +184,7 @@ static ALWAYS_INLINE void requantize_( row_offset_v = _mm256_mullo_epi32(row_offset_v, B_zero_point_v); z_v = _mm256_sub_epi32(z_v, row_offset_v); } - if (!A_SYMMETRIC) { + if constexpr (!A_SYMMETRIC) { col_off_v = _mm256_mullo_epi32( A_zero_point_v, _mm256_loadu_si256( @@ -191,7 +192,7 @@ static ALWAYS_INLINE void requantize_( z_v = _mm256_sub_epi32(z_v, col_off_v); } - if (!B_SYMMETRIC) { + if constexpr (!B_SYMMETRIC) { if (K_PER_G == 1) { row_offset_v = _mm256_loadu_si256( reinterpret_cast(row_offsets + j + 3 * VLEN)); @@ -219,7 +220,7 @@ static ALWAYS_INLINE void requantize_( row_offset_v = _mm256_mullo_epi32(row_offset_v, B_zero_point_v); w_v = _mm256_sub_epi32(w_v, row_offset_v); } - if (!A_SYMMETRIC) { + if constexpr (!A_SYMMETRIC) { col_off_v = _mm256_mullo_epi32( A_zero_point_v, _mm256_loadu_si256( @@ -400,7 +401,7 @@ static ALWAYS_INLINE void requantize_( __m256i x_v = _mm256_loadu_si256(reinterpret_cast(C_int32 + j)); - if (!B_SYMMETRIC) { + if constexpr (!B_SYMMETRIC) { __m256i row_offset_v; if (K_PER_G == 1) { row_offset_v = _mm256_loadu_si256( @@ -430,7 +431,7 @@ static ALWAYS_INLINE void requantize_( row_offset_v = _mm256_mullo_epi32(row_offset_v, B_zero_point_v); x_v = _mm256_sub_epi32(x_v, row_offset_v); } - if (!A_SYMMETRIC) { + if constexpr (!A_SYMMETRIC) { __m256i col_off_v = _mm256_mullo_epi32( A_zero_point_v, _mm256_loadu_si256( @@ -509,14 +510,14 @@ static ALWAYS_INLINE void requantize_( } else if constexpr (Q_GRAN == QuantizationGranularity::GROUP) { quant_param_idx = j / 2; } - if (!B_SYMMETRIC) { + if constexpr (!B_SYMMETRIC) { raw -= B_zero_point[quant_param_idx] * row_offsets[j / K_PER_G]; } - if (!A_SYMMETRIC) { + if constexpr (!A_SYMMETRIC) { raw -= A_zero_point * col_offsets[j]; } - float raw_f; - if (HAS_BIAS) { // static if + float raw_f = NAN; + if constexpr (HAS_BIAS) { // static if if constexpr (std::is_same_v) { raw_f = raw; raw_f += bias[j] / act_times_w_scale[quant_param_idx]; diff --git a/src/GenerateI8Depthwise.cc b/src/GenerateI8Depthwise.cc index 9051b919df..1a0b738eb2 100644 --- a/src/GenerateI8Depthwise.cc +++ b/src/GenerateI8Depthwise.cc @@ -557,8 +557,8 @@ GenI8Depthwise::jit_kernel_signature GenI8Depthwise::getOrCreate( e->emitEpilog(frame); - jit_kernel_signature fn; - asmjit::Error err; + jit_kernel_signature fn = nullptr; + asmjit::Error err = 0; { std::unique_lock lock(rtMutex_); err = runtime().add(&fn, &code); diff --git a/src/GenerateKernelDirectConvU8S8S32ACC32.cc b/src/GenerateKernelDirectConvU8S8S32ACC32.cc index 093532d4e6..4ae9aee17a 100644 --- a/src/GenerateKernelDirectConvU8S8S32ACC32.cc +++ b/src/GenerateKernelDirectConvU8S8S32ACC32.cc @@ -180,14 +180,13 @@ DirectConvCodeGenBase::getOrCreateDirectConv( constexpr int numRegs = simd_info::NUM_VEC_REGS; static constexpr int vectorLen = simd_info::WIDTH_BYTES; - std::tuple kernelSig; // int ichSize = 32; int mRegBlockSize = 12; int nRegBlockSize = 8; // int nRegBlockSizeMin; int row_interleave = 4; - kernelSig = std::make_tuple( + auto kernelSig = std::make_tuple( accum, O1, i1Xich, strideXich, i1Xich, mRegBlockSize, nRegBlockSize); return codeCache_.getOrCreate(kernelSig, [&]() -> jit_micro_kernel_fp { @@ -402,8 +401,8 @@ DirectConvCodeGenBase::getOrCreateDirectConv( a->emitEpilog(frame); - jit_micro_kernel_fp fn; - asmjit::Error err; + jit_micro_kernel_fp fn = nullptr; + asmjit::Error err = 0; { std::unique_lock lock(rtMutex_); err = runtime().add(&fn, &code); @@ -608,7 +607,6 @@ DirectConvCodeGenBase:: constexpr int numRegs = simd_info::NUM_VEC_REGS; static constexpr int vectorLen = simd_info::WIDTH_BYTES; - std::tuple kernelSig; // int ichSize = 32; int mRowRegBlockSize = 2; int mColRegBlockSize = numColRegs; @@ -617,7 +615,7 @@ DirectConvCodeGenBase:: // int nRegBlockSizeMin; int row_interleave = 4; - kernelSig = std::make_tuple(accum, stride, mRegBlockSize, nRegBlockSize); + auto kernelSig = std::make_tuple(accum, stride, mRegBlockSize, nRegBlockSize); return codeCacheT_.getOrCreate(kernelSig, [&]() -> jit_micro_kernel_fp_convT { asmjit::CodeHolder code; @@ -772,8 +770,8 @@ DirectConvCodeGenBase:: a->emitEpilog(frame); - jit_micro_kernel_fp_convT fn; - asmjit::Error err; + jit_micro_kernel_fp_convT fn = nullptr; + asmjit::Error err = 0; { std::unique_lock lock(rtMutex_); err = runtime().add(&fn, &code); diff --git a/src/GenerateKernelU8S8S32ACC16.cc b/src/GenerateKernelU8S8S32ACC16.cc index a4f3eb93e1..6f46ca6e62 100644 --- a/src/GenerateKernelU8S8S32ACC16.cc +++ b/src/GenerateKernelU8S8S32ACC16.cc @@ -107,13 +107,12 @@ CodeGenBase::getOrCreate( (void)kc; // Suppress unused variable warning constexpr int vectorLen = simd_info::WIDTH_BYTES; - std::tuple kernelSig; - int kBlock; - int nBlock; - int mRegBlockSize; - int nRegBlockSize; - int nRegBlockSizeMin; - int row_interleave; + int kBlock = 0; + int nBlock = 0; + int mRegBlockSize = 0; + int nRegBlockSize = 0; + int nRegBlockSizeMin = 0; + int row_interleave = 0; if (blocking_params) { kBlock = blocking_params->KCB; @@ -134,7 +133,7 @@ CodeGenBase::getOrCreate( } (void)nRegBlockSizeMin; // Suppress unused variable warning - kernelSig = std::make_tuple( + auto kernelSig = std::make_tuple( accum, mc, nc, nBlock, kBlock, mRegBlockSize, nRegBlockSize); return codeCache_.getOrCreate(kernelSig, [&]() -> jit_micro_kernel_fp { @@ -323,8 +322,8 @@ CodeGenBase::getOrCreate( a->emitEpilog(frame); - jit_micro_kernel_fp fn; - asmjit::Error err; + jit_micro_kernel_fp fn = nullptr; + asmjit::Error err = 0; { std::unique_lock lock(rtMutex_); err = runtime().add(&fn, &code); diff --git a/src/GenerateKernelU8S8S32ACC16Avx512.cc b/src/GenerateKernelU8S8S32ACC16Avx512.cc index dab000987b..87f77a447c 100644 --- a/src/GenerateKernelU8S8S32ACC16Avx512.cc +++ b/src/GenerateKernelU8S8S32ACC16Avx512.cc @@ -71,17 +71,15 @@ CodeGenBase::getOrCreate( bool accum, int32_t mc, int32_t nc, - int32_t kc) { - (void)kc; // Suppress unused variable warning + int32_t kc [[maybe_unused]]) { static constexpr int vectorLen = simd_info::WIDTH_BYTES; - std::tuple kernelSig; - int kBlock; - int nBlock; - int mRegBlockSize; - int nRegBlockSize; - int nRegBlockSizeMin; - int row_interleave; + int kBlock = 0; + int nBlock = 0; + int mRegBlockSize = 0; + int nRegBlockSize = 0; + int nRegBlockSizeMin = 0; + int row_interleave = 0; if (blocking_params) { kBlock = blocking_params->KCB; @@ -100,7 +98,7 @@ CodeGenBase::getOrCreate( } (void)nRegBlockSizeMin; // Suppress unused variable warning - kernelSig = std::make_tuple( + auto kernelSig = std::make_tuple( accum, mc, nc, nBlock, kBlock, mRegBlockSize, nRegBlockSize); return codeCache_.getOrCreate(kernelSig, [&]() -> jit_micro_kernel_fp { @@ -347,8 +345,8 @@ CodeGenBase::getOrCreate( a->emitEpilog(frame); - jit_micro_kernel_fp fn; - asmjit::Error err; + jit_micro_kernel_fp fn = nullptr; + asmjit::Error err = 0; { std::unique_lock lock(rtMutex_); err = runtime().add(&fn, &code); diff --git a/src/GenerateKernelU8S8S32ACC32.cc b/src/GenerateKernelU8S8S32ACC32.cc index d55c3cb2e6..a7793a6c71 100644 --- a/src/GenerateKernelU8S8S32ACC32.cc +++ b/src/GenerateKernelU8S8S32ACC32.cc @@ -114,13 +114,12 @@ CodeGenBase::getOrCreate( constexpr int numRegs = simd_info::NUM_VEC_REGS; static constexpr int vectorLen = simd_info::WIDTH_BYTES; - std::tuple kernelSig; - int kBlock; - int nBlock; - int mRegBlockSize; - int nRegBlockSize; - int nRegBlockSizeMin; - int row_interleave; + int kBlock = 0; + int nBlock = 0; + int mRegBlockSize = 0; + int nRegBlockSize = 0; + int nRegBlockSizeMin = 0; + int row_interleave = 0; if (blocking_params) { kBlock = blocking_params->KCB; @@ -139,7 +138,7 @@ CodeGenBase::getOrCreate( } (void)nRegBlockSizeMin; // Suppress unused variable warning - kernelSig = std::make_tuple( + auto kernelSig = std::make_tuple( accum, mc, nc, nBlock, kBlock, mRegBlockSize, nRegBlockSize); return codeCache_.getOrCreate(kernelSig, [&]() -> jit_micro_kernel_fp { @@ -357,8 +356,8 @@ CodeGenBase::getOrCreate( a->emitEpilog(frame); - jit_micro_kernel_fp fn; - asmjit::Error err; + jit_micro_kernel_fp fn = nullptr; + asmjit::Error err = 0; { std::unique_lock lock(rtMutex_); err = runtime().add(&fn, &code); diff --git a/src/GenerateKernelU8S8S32ACC32Avx512VNNI.cc b/src/GenerateKernelU8S8S32ACC32Avx512VNNI.cc index 8bbad0dcbd..17955e6acc 100644 --- a/src/GenerateKernelU8S8S32ACC32Avx512VNNI.cc +++ b/src/GenerateKernelU8S8S32ACC32Avx512VNNI.cc @@ -66,13 +66,12 @@ CodeGenBase::getOrCreate( simd_info::WIDTH_BITS == 512 ? inst_set_t::avx512 : inst_set_t::avx512_ymm; - std::tuple kernelSig; - int kBlock; - int nBlock; - int mRegBlockSize; - int nRegBlockSize; - int nRegBlockSizeMin; - int row_interleave; + int kBlock = 0; + int nBlock = 0; + int mRegBlockSize = 0; + int nRegBlockSize = 0; + int nRegBlockSizeMin = 0; + int row_interleave = 0; if (blocking_params) { kBlock = blocking_params->KCB; @@ -91,7 +90,7 @@ CodeGenBase::getOrCreate( } (void)nRegBlockSizeMin; // Suppress unused variable warning - kernelSig = std::make_tuple( + auto kernelSig = std::make_tuple( accum, mc, nc, nBlock, kBlock, mRegBlockSize, nRegBlockSize); return codeCache_.getOrCreate(kernelSig, [&]() -> jit_micro_kernel_fp { @@ -352,8 +351,8 @@ CodeGenBase::getOrCreate( a->emitEpilog(frame); - jit_micro_kernel_fp fn; - asmjit::Error err; + jit_micro_kernel_fp fn = nullptr; + asmjit::Error err = 0; { std::unique_lock lock(rtMutex_); err = runtime().add(&fn, &code); diff --git a/src/GroupwiseConv.cc b/src/GroupwiseConv.cc index f0337a519b..23f0256774 100644 --- a/src/GroupwiseConv.cc +++ b/src/GroupwiseConv.cc @@ -50,7 +50,7 @@ static void calculateRowOffsets( for (int s = 0; s < conv_param.K[1]; ++s) { int w_in = -W_PAD + w * conv_param.stride[1] + s; for (int c = 0; c < C_per_G; ++c) { - int a_val; + int a_val = 0; if (h_in < 0 || h_in >= IH || w_in < 0 || w_in >= IW) { a_val = a_zero_point; } else { @@ -299,8 +299,8 @@ jit_conv_kernel_fp GenConvKernel::getOrCreate() { a->emitEpilog(frame_); - jit_conv_kernel_fp fn; - asmjit::Error err; + jit_conv_kernel_fp fn = nullptr; + asmjit::Error err = 0; { unique_lock lock(this->rtMutex_); err = this->runtime().add(&fn, &code); @@ -1203,7 +1203,7 @@ void fbgemmGroupwiseConv( isBottomEdgeIncluded, isTopBottomEdgeSame, true); - jit_conv_kernel_fp fpConv; + jit_conv_kernel_fp fpConv = nullptr; #endif int ih_start = 0; diff --git a/src/OptimizedKernelsAvx2.cc b/src/OptimizedKernelsAvx2.cc index 082f652c4a..ae69000b65 100644 --- a/src/OptimizedKernelsAvx2.cc +++ b/src/OptimizedKernelsAvx2.cc @@ -22,7 +22,7 @@ int32_t reduceAvx2(const uint8_t* A, int len) { __m256i one_epi16_v = _mm256_set1_epi16(1); __m256i one_epi8_v = _mm256_set1_epi8(1); - int i; + int i = 0; // vectorized for (i = 0; i < len / 32 * 32; i += 32) { __m256i src_v = _mm256_loadu_si256(reinterpret_cast<__m256i const*>(A + i)); @@ -58,7 +58,7 @@ void transpose_8rows( uint8_t* dst, int ld_dst) { constexpr int M = 8; - int j; + int j = 0; // vectorized loop for (j = 0; j < N / 32 * 32; j += 32) { // a : a0 a1 ... a31 diff --git a/src/PackMatrix.cc b/src/PackMatrix.cc index 8086dddac9..c4b2f92d01 100644 --- a/src/PackMatrix.cc +++ b/src/PackMatrix.cc @@ -44,7 +44,7 @@ int PackMatrix::packedBufferSize( assert(0 && "unknown architecure"); } - int MCB, KCB, NCB; + int MCB = 0, KCB = 0, NCB = 0; if (params) { MCB = params->MCB; NCB = params->NCB; diff --git a/src/PackWeightMatrixForGConv.cc b/src/PackWeightMatrixForGConv.cc index c51f7eac2f..5f0aa09309 100644 --- a/src/PackWeightMatrixForGConv.cc +++ b/src/PackWeightMatrixForGConv.cc @@ -97,7 +97,7 @@ inline int PackWeightMatrixForGConv::unpacked_index_( int IC_per_G = conv_param_.IC / G; int OC_per_G = conv_param_.OC / G; - int idx; + int idx = 0; if (tr) { idx = ((((g * OC_per_G + k) * F + t) * R + r) * S + s) * IC_per_G + c; } else { diff --git a/src/PackWeightsForDirectConv.cc b/src/PackWeightsForDirectConv.cc index 2d097e948d..b40da63c07 100644 --- a/src/PackWeightsForDirectConv.cc +++ b/src/PackWeightsForDirectConv.cc @@ -248,7 +248,7 @@ void fbgemmDirectConv( } else { if (conv_p.transposed) { DirectConvCodeGenBase:: - jit_micro_kernel_fp_convT fn; + jit_micro_kernel_fp_convT fn = nullptr; DirectConvCodeGenBase codeObj; /* fn = codeObj.getOrCreateDirectConvTrans( diff --git a/src/QuantUtils.cc b/src/QuantUtils.cc index 5325e341b0..4b7da50ff3 100644 --- a/src/QuantUtils.cc +++ b/src/QuantUtils.cc @@ -460,7 +460,7 @@ FBGEMM_API void Requantize( const RequantizationParams& params, int thread_id, int num_threads) { - int64_t i_begin, i_end; + int64_t i_begin = 0, i_end = 0; fbgemmPartition1D(thread_id, num_threads, len, i_begin, i_end); if (params.target_qparams.precision == 8 && cpuinfo_initialize() && fbgemmHasAvx2Support()) { @@ -482,7 +482,7 @@ FBGEMM_API void RequantizeFixedPoint( const RequantizationParams& params, int thread_id, int num_threads) { - int64_t i_begin, i_end; + int64_t i_begin = 0, i_end = 0; fbgemmPartition1D(thread_id, num_threads, len, i_begin, i_end); if (std::is_same_v && params.target_qparams.precision == 8 && cpuinfo_initialize() && fbgemmHasAvx2Support()) { @@ -524,7 +524,7 @@ FBGEMM_API void RequantizeFixedPoint( const RequantizationParams& params, int thread_id, int num_threads) { - int64_t i_begin, i_end; + int64_t i_begin = 0, i_end = 0; fbgemmPartition1D(thread_id, num_threads, len, i_begin, i_end); if (params.target_qparams.precision == 8 && cpuinfo_initialize() && diff --git a/src/QuantUtilsAvx2.cc b/src/QuantUtilsAvx2.cc index e49f652131..ebbb080131 100644 --- a/src/QuantUtilsAvx2.cc +++ b/src/QuantUtilsAvx2.cc @@ -138,8 +138,7 @@ uint32_t Xor128() { /* library-local */ static uint32_t y = 362436069; /* library-local */ static uint32_t z = 521288629; /* library-local */ static uint32_t w = 88675123; - uint32_t t; - t = x ^ (x << 11); + uint32_t t = x ^ (x << 11); x = y; y = z; z = w; @@ -166,12 +165,9 @@ void NO_SANITIZE("address") FusedQuantizeDequantizeAvx2( int len, const TensorQuantizationParams& qparams, float noise_ratio) { - float inverse_scale = 1.f / qparams.scale; - constexpr int32_t min_val = std::numeric_limits::min(); - constexpr int32_t max_val = std::numeric_limits::max(); - (void)inverse_scale; // Suppress unused variable warning - (void)min_val; // Suppress unused variable warning - (void)max_val; // Suppress unused variable warning + float inverse_scale [[maybe_unused]] = 1.f / qparams.scale; + constexpr int32_t min_val [[maybe_unused]] = std::numeric_limits::min(); + constexpr int32_t max_val [[maybe_unused]] = std::numeric_limits::max(); #if defined(__AVX2__) && (defined(__FMA__) || defined(_MSC_VER)) constexpr int VLEN = 8; @@ -180,7 +176,6 @@ void NO_SANITIZE("address") FusedQuantizeDequantizeAvx2( constexpr int32_t int32_float_max_val = std::numeric_limits::max() - 127; int64_t i = 0; - uint32_t rand; __m256 inverse_scale_v = _mm256_set1_ps(inverse_scale); __m256 scale_v = _mm256_set1_ps(qparams.scale); __m256 zp_v = _mm256_set1_ps(qparams.zero_point); @@ -193,7 +188,7 @@ void NO_SANITIZE("address") FusedQuantizeDequantizeAvx2( __m256 src_v = _mm256_loadu_ps(src + i); __m256 transformed_v; if (noise_ratio > 0) { - rand = Xor128() % 10; + uint32_t rand = Xor128() % 10; if (rand < noise_ratio * 10) { _mm256_storeu_ps(dst + i, src_v); continue; @@ -235,7 +230,7 @@ void NO_SANITIZE("address") FusedQuantizeDequantizeAvx2( __m256 transformed_v; if (noise_ratio > 0) { - rand = Xor128() % 10; + uint32_t rand = Xor128() % 10; if (rand < noise_ratio * 10) { _mm256_storeu_ps(dst + i, src_v); return; @@ -1582,7 +1577,7 @@ void FloatOrHalfToFusedNBitRowwiseQuantizedSBHalfAvx2( (input_columns + NUM_ELEM_PER_BYTE - 1) / NUM_ELEM_PER_BYTE + 2 * sizeof(std::uint16_t); - float* input_row_float_for_fp16; + float* input_row_float_for_fp16 = nullptr; if constexpr (std::is_same()) { input_row_float_for_fp16 = static_cast( fbgemmAlignedAlloc(64, input_columns * sizeof(float))); @@ -1590,7 +1585,7 @@ void FloatOrHalfToFusedNBitRowwiseQuantizedSBHalfAvx2( for (size_t row = 0; row < input_rows; ++row) { const InputType* input_row = input + row * input_columns; - const float* input_row_float; + const float* input_row_float = nullptr; if constexpr (std::is_same()) { // NOTE: this reinterpret_cast is only to workaround c++ // type requirements -- it is not for fp16 case and `input_row` HAS to be @@ -1610,7 +1605,7 @@ void FloatOrHalfToFusedNBitRowwiseQuantizedSBHalfAvx2( __m256 min_v = _mm256_set1_ps(minimum_element); __m256 max_v = _mm256_set1_ps(maximum_element); - int col; + int col = 0; for (col = 0; col < input_columns / VLEN * VLEN; col += VLEN) { __m256 in_v; if constexpr (std::is_same()) { @@ -1785,14 +1780,14 @@ void FloatOrHalfToFused8BitRowwiseQuantizedSBFloatAvx2( _mm256_set_epi32(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00); const int64_t output_columns = input_columns + 2 * sizeof(float); - float* input_row_float_for_fp16; + float* input_row_float_for_fp16 = nullptr; if constexpr (std::is_same_v) { input_row_float_for_fp16 = static_cast( fbgemmAlignedAlloc(64, input_columns * sizeof(float))); } for (size_t row = 0; row < input_rows; ++row) { const InputType* input_row = input + row * input_columns; - const float* input_row_float; + const float* input_row_float = nullptr; if constexpr (std::is_same_v) { // NOTE: this reinterpret_cast is only to workaround c++ // type requirements -- it is not for fp16 case and `input_row` HAS to be @@ -1809,7 +1804,7 @@ void FloatOrHalfToFused8BitRowwiseQuantizedSBFloatAvx2( float maximum_element = -FLT_MAX; __m256 min_v = _mm256_set1_ps(minimum_element); __m256 max_v = _mm256_set1_ps(maximum_element); - int col; + int col = 0; for (col = 0; col < input_columns / VLEN * VLEN; col += VLEN) { __m256 in_v; if constexpr (std::is_same()) { @@ -1920,7 +1915,7 @@ void FusedNBitRowwiseQuantizedSBHalfToFloatOrHalfAvx2( // multiply by 4 because we're handling 4 vlen per iteration constexpr int NUM_OF_32BIT_PER_VLOAD = VLEN * 4 / NUM_ELEM_PER_32BIT; - int remainder_32bit_granularity, remainder; + int remainder_32bit_granularity = 0, remainder = 0; __m128i vmask_load; __m256i vmask_store0, vmask_store1, vmask_store2, vmask_store3; if constexpr (BIT_RATE == 4 || BIT_RATE == 2) { @@ -1978,14 +1973,8 @@ void FusedNBitRowwiseQuantizedSBHalfToFloatOrHalfAvx2( (output_columns + NUM_ELEM_PER_BYTE - 1) / NUM_ELEM_PER_BYTE); float scale = halfToFloat(input_row_scale_bias[0]); float bias = halfToFloat(input_row_scale_bias[1]); - OutputType* output_row = output + row * output_columns; - float* output_row_float; - if constexpr (std::is_same_v) { - // NOTE: this reinterpret_cast is only to workaround c++ - // type requirements -- it is not for fp16 case and `output_row` HAS to be - // float* type. Remove it and use constexpr when pytorch allows C++17. - output_row_float = reinterpret_cast(output_row); - } + OutputType* const output_row = output + row * output_columns; + auto output_row_float = reinterpret_cast(output_row); int col = 0; if constexpr (BIT_RATE == 4 || BIT_RATE == 2) { @@ -2152,7 +2141,7 @@ void Fused8BitRowwiseQuantizedSBFloatToFloatOrHalfAvx2( __m256 scale_v = _mm256_set1_ps(input_row_scale_bias[0]); __m256 bias_v = _mm256_set1_ps(input_row_scale_bias[1]); - int col; + int col = 0; for (col = 0; col < output_columns / VLEN * VLEN; col += VLEN) { __m256 in_v = _mm256_cvtepi32_ps(_mm256_cvtepu8_epi32( _mm_loadl_epi64(reinterpret_cast(input_row + col)))); diff --git a/src/RefImplementations.cc b/src/RefImplementations.cc index 7ce9b62b06..c31d272ee9 100644 --- a/src/RefImplementations.cc +++ b/src/RefImplementations.cc @@ -13,6 +13,8 @@ #include "fbgemm/FbgemmConvert.h" #include "fbgemm/FloatConversion.h" +#include + #include #include #include @@ -410,7 +412,7 @@ void cblas_gemm_i64_i64acc_ref( int ldc) { for (int i = 0; i < M; ++i) { for (int j = 0; j < N; ++j) { - int64_t acc; + int64_t acc = 0; if (accumulate) { acc = C[i * ldc + j]; } else { @@ -1210,8 +1212,8 @@ bool EmbeddingSpMDM_ref( bool no_bag /*=false*/, bool is_bf16_out /*=false*/, bool is_bf16_in /*=false*/) { - const bool isWeight8bit = is_same_v; - const bool isOutput8bit = is_same_v; + constexpr bool isWeight8bit = is_same_v; + constexpr bool isOutput8bit = is_same_v; if (output_stride == -1) { output_stride = block_size; } @@ -1220,7 +1222,7 @@ bool EmbeddingSpMDM_ref( } vector buf(block_size); - if (isWeight8bit) { + if constexpr (isWeight8bit) { // block_size is the number of elements and fused_block_size is the size of // an entire row, including scale and bias. if (input_stride == -1) { @@ -1252,7 +1254,7 @@ bool EmbeddingSpMDM_ref( weight = weights[m]; } - float scale, bias; + float scale = NAN, bias = NAN; if (scale_bias_last) { scale = weight * scale_bias[0]; bias = weight * scale_bias[1]; @@ -1305,7 +1307,7 @@ bool EmbeddingSpMDM_ref( if (weights) { weight = weights[is_weight_positional ? i : current]; } - float scale, bias; + float scale = NAN, bias = NAN; if (scale_bias_last) { scale = weight * scale_bias[0]; bias = weight * scale_bias[1]; @@ -1579,7 +1581,7 @@ bool EmbeddingSpMDMFP8_ref( for (int j = 0; j < block_size; ++j) { const uint8_t* inptr = input + input_stride * idx + j; - float input_f; + float input_f = NAN; // Dequantize FP8 to FP32 before compute Float8ToFloat_ref(*inptr, &input_f, exponent_bits, exponent_bias); buf[j] = std::fma(w, input_f, buf[j]); @@ -1831,11 +1833,11 @@ int sparse_adagrad_ref( float freq = (counter && counter[idx] > 0) ? counter_halflife / counter[idx] : 1.0; - const float* g_; - const float* h_; - const float* w_; - float* nh_; - float* nw_; + const float* g_ = nullptr; + const float* h_ = nullptr; + const float* w_ = nullptr; + float* nh_ = nullptr; + float* nw_ = nullptr; g_ = g + offsetI; h_ = h + offsetIdx; @@ -1879,9 +1881,9 @@ int rowwise_sparse_adagrad_ref( float freq = (counter && counter[idx] > 0) ? counter_halflife / counter[idx] : 1.0; - const float* g_; - float* h_; - float* w_; + const float* g_ = nullptr; + float* h_ = nullptr; + float* w_ = nullptr; g_ = g + offsetI; h_ = h + idx; // This is different from sparse adagrad diff --git a/src/RefImplementations.h b/src/RefImplementations.h index 47ea86f83b..0e25acad26 100644 --- a/src/RefImplementations.h +++ b/src/RefImplementations.h @@ -417,24 +417,18 @@ FBGEMM_API void compressed_indices_remap_ref( template float convert_to_float_ref(T src, bool is_bf16 = false) { - float f_value; if constexpr (std::is_same_v) { - f_value = is_bf16 ? cpu_bf162float(src) : cpu_half2float(src); - } else { - f_value = src; + return is_bf16 ? cpu_bf162float(src) : cpu_half2float(src); } - return f_value; + return src; } template T convert_from_float_ref(float src, bool is_bf16 = false) { - T o_value; if constexpr (std::is_same_v) { - o_value = is_bf16 ? cpu_float2bfloat16(src) : cpu_float2half_rn(src); - } else { - o_value = src; + return is_bf16 ? cpu_float2bfloat16(src) : cpu_float2half_rn(src); } - return o_value; + return src; } } // namespace fbgemm diff --git a/src/RowWiseSparseAdagradFused.cc b/src/RowWiseSparseAdagradFused.cc index 10996c2f7b..349dbf0b12 100644 --- a/src/RowWiseSparseAdagradFused.cc +++ b/src/RowWiseSparseAdagradFused.cc @@ -754,7 +754,7 @@ typename ReturnFunctionSignature:: // jit_fused8bitembedding_kernel fn; typename ReturnFunctionSignature:: jit_sparse_adagrad_kernel fn; - asmjit::Error err; + asmjit::Error err = 0; { unique_lock lock(rtMutex_); err = runtime().add(&fn, &code); diff --git a/src/SparseAdagrad.cc b/src/SparseAdagrad.cc index e0584a8166..9f5ea25a92 100644 --- a/src/SparseAdagrad.cc +++ b/src/SparseAdagrad.cc @@ -770,7 +770,7 @@ GenSparseAdagrad::getOrCreate( typename ReturnFunctionSignature::jit_sparse_adagrad_kernel fn; - asmjit::Error err; + asmjit::Error err = 0; { std::unique_lock lock(rtMutex_); err = runtime().add(&fn, &code); diff --git a/src/TransposeUtilsAvx2.h b/src/TransposeUtilsAvx2.h index ce14fd2bac..709335c006 100644 --- a/src/TransposeUtilsAvx2.h +++ b/src/TransposeUtilsAvx2.h @@ -75,7 +75,7 @@ static void transpose_kernel_mxn_sse( // load from src to registers __m128i mask_v = _mm_load_si128(reinterpret_cast(masks[N])); __m128 input[4]; - unsigned i; + unsigned i = 0; for (i = 0; i < M; ++i) { input[i] = _mm_maskload_ps(&src[i * ld_src], mask_v); } @@ -210,7 +210,7 @@ static void transpose_kernel_mxn_avx2( __m256i mask_v = _mm256_load_si256( reinterpret_cast(internal::avx2_ps_or_epi32_masks[N])); __m256 input[8]; - unsigned i; + unsigned i = 0; for (i = 0; i < M; ++i) { input[i] = _mm256_maskload_ps(&src[i * ld_src], mask_v); } @@ -728,7 +728,7 @@ static void transpose_kernel_mxn_avx2_uint8( internal::avx2_ps_or_epi32_masks[N / 4])); __m256i input[8]; - unsigned i, j; + unsigned i = 0, j = 0; for (i = 0; i < M; ++i) { uint8_t local_buffer[32] = {0}; @@ -783,7 +783,7 @@ static void transpose_kernel_mxn_avx2_uint8( // 64-127 bit: a1 -- h1, // 128-191 bit: a16 -- h16, // 192-255 bit: a17 -- h17 - uint64_t t; + uint64_t t = 0; mask_v = _mm256_load_si256(reinterpret_cast( internal::avx2_ps_or_epi32_masks[M / 4])); for (i = 0; i < N; ++i) { diff --git a/src/Utils.cc b/src/Utils.cc index 94bee273fd..926b7fc9be 100644 --- a/src/Utils.cc +++ b/src/Utils.cc @@ -426,7 +426,7 @@ void fbgemmPartition1DBlocked( return fbgemmPartition1D(thread_id, num_threads, total_work, start, end); } int64_t total_work_in_blocks = total_work / block_size; - int64_t start_block, end_block; + int64_t start_block = 0, end_block = 0; fbgemmPartition1D( thread_id, num_threads, total_work_in_blocks, start_block, end_block); start = std::min(start_block * block_size, total_work); @@ -440,7 +440,7 @@ void* fbgemmAlignedAlloc( size_t size, bool raiseException /*=false*/) { void* aligned_mem = nullptr; - int ret; + int ret = 0; #ifdef _MSC_VER aligned_mem = _aligned_malloc(size, align); ret = 0; diff --git a/src/UtilsAvx512.cc b/src/UtilsAvx512.cc index a354ad200c..1898129a52 100644 --- a/src/UtilsAvx512.cc +++ b/src/UtilsAvx512.cc @@ -240,7 +240,7 @@ void transpose_kernel_mxn_avx512( // load from src to registers __mmask16 src_mask = (1 << N) - 1; __m512 input[16]; - int i; + int i = 0; for (i = 0; i < M; ++i) { input[i] = _mm512_maskz_loadu_ps(src_mask, &src[i * ld_src]); } diff --git a/src/codegen_fp16fp32.cc b/src/codegen_fp16fp32.cc index a283d93108..a05680035d 100644 --- a/src/codegen_fp16fp32.cc +++ b/src/codegen_fp16fp32.cc @@ -71,7 +71,6 @@ bool parseArgumentBool( const char* argv[], const char* arg, bool def_val) { - int arg_len = strlen(arg); for (auto i = 1; i < argc; ++i) { const char* ptr = strstr(argv[i], arg); if (ptr) { @@ -83,7 +82,6 @@ bool parseArgumentBool( int main(int argc, const char* argv[]) { bool iaca = false; - bool disable = false; unordered_set enabledDataType; // Always generate FP16 @@ -103,8 +101,6 @@ int main(int argc, const char* argv[]) { const int prefetch_c_len = parseArgumentInt(argc, argv, "--prefetch-c", 0, 1024); - bool fixedA = true, fixedB = true, fixedC = true; - int eax, ebx, ecx, edx; __cpuid(1 /* ecx = vendor string */, eax, ebx, ecx, edx); printf("FC16 is %s supported\n", ((ecx & bit_F16C) ? " " : "not")); diff --git a/src/spmmUtils.cc b/src/spmmUtils.cc index a7ef07fd27..1dc57b4519 100644 --- a/src/spmmUtils.cc +++ b/src/spmmUtils.cc @@ -61,10 +61,8 @@ FBGEMM_API void trRequantizeRef( if (r.act_zero_point) { raw -= r.act_zero_point * r.weight_row_offsets[i]; } - int weight_zeropoint_idx; - if constexpr (Q_GRAN == QuantizationGranularity::TENSOR) { - weight_zeropoint_idx = 0; - } else { + int weight_zeropoint_idx = 0; + if constexpr (Q_GRAN != QuantizationGranularity::TENSOR) { // Q_GRAN == QuantizationGranularity::OUT_CHANNEL weight_zeropoint_idx = i; } diff --git a/test/EmbeddingSpMDM8BitTest.cc b/test/EmbeddingSpMDM8BitTest.cc index a0fe570c87..514de02ceb 100644 --- a/test/EmbeddingSpMDM8BitTest.cc +++ b/test/EmbeddingSpMDM8BitTest.cc @@ -87,7 +87,7 @@ TEST_P(Fused8BitRowwiseEmbeddingLookupTest, basicTest) { bool use_offsets = bool_dist(generator); bool scale_bias_last = bool_dist(generator); - int prefetch; + int prefetch = 0; EmbeddingSpMDMWeightChoice weight_choice; EmbeddingSpMDMCornerCase corner_case; EmbeddingSpMDMOutputDtypeChoice out_type; @@ -189,7 +189,7 @@ TEST_P(Fused8BitRowwiseEmbeddingLookupTest, basicTest) { convert_from_float_ref(sentry_value, out_type == BFLOAT16); } - bool success, success_ref; + bool success = false, success_ref = false; #define TEST_BASE( \ indices, \ @@ -334,7 +334,7 @@ TEST_P(Fused8BitRowwiseEmbeddingLookupTest, rowwiseSparseTest) { bool use_offsets = bool_dist(generator); bool scale_bias_last = bool_dist(generator); - int prefetch; + int prefetch = 0; EmbeddingSpMDMWeightChoice weight_choice; EmbeddingSpMDMCornerCase corner_case; EmbeddingSpMDMDtypeChoice out_type; @@ -404,7 +404,7 @@ TEST_P(Fused8BitRowwiseEmbeddingLookupTest, rowwiseSparseTest) { vector& output_ref = use_weight ? output_slws_ref : output_sls_ref; vector& output = use_weight ? output_slws : output_sls; - bool success, success_ref; + bool success = false, success_ref = false; if (isOffset64b) { if (isIndex64b) { diff --git a/test/EmbeddingSpMDMNBitTest.cc b/test/EmbeddingSpMDMNBitTest.cc index 7c38734c0f..5251455f4e 100644 --- a/test/EmbeddingSpMDMNBitTest.cc +++ b/test/EmbeddingSpMDMNBitTest.cc @@ -91,7 +91,7 @@ TEST_P(FusedNBitRowwiseEmbeddingLookupTest, basicTest) { bool use_offsets = bool_dist(generator); bool scale_bias_last = bool_dist(generator); bool test_thread_local = bool_dist(generator); - int bit_rate, prefetch; + int bit_rate = 0, prefetch = 0; EmbeddingSpMDMWeightChoice weight_choice; EmbeddingSpMDMCornerCase corner_case; EmbeddingSpMDMDtypeChoice out_type; @@ -198,7 +198,7 @@ TEST_P(FusedNBitRowwiseEmbeddingLookupTest, basicTest) { FloatToBfloat16_ref(&sentry_value, &output_bf16[i], 1); } - bool success, success_ref; + bool success = false, success_ref = false; #define TEST_BASE( \ indices, \ @@ -394,7 +394,7 @@ TEST_P(FusedNBitRowwiseEmbeddingLookupTest, rowwiseSparseTest) { bool use_offsets = bool_dist(generator); bool scale_bias_last = bool_dist(generator); - int bit_rate, prefetch; + int bit_rate = 0, prefetch = 0; EmbeddingSpMDMWeightChoice weight_choice; EmbeddingSpMDMCornerCase corner_case; EmbeddingSpMDMDtypeChoice out_type; @@ -471,7 +471,7 @@ TEST_P(FusedNBitRowwiseEmbeddingLookupTest, rowwiseSparseTest) { vector& output_ref = use_weight ? output_slws_ref : output_sls_ref; vector& output = use_weight ? output_slws : output_sls; - bool success, success_ref; + bool success = false, success_ref = false; if (isOffset64b) { if (isIndex64b) { diff --git a/test/EmbeddingSpMDMTest.cc b/test/EmbeddingSpMDMTest.cc index 7e9b3b7f85..f1011d9d4e 100644 --- a/test/EmbeddingSpMDMTest.cc +++ b/test/EmbeddingSpMDMTest.cc @@ -13,6 +13,7 @@ #include #include +#include #include "./EmbeddingSpMDMTestUtils.h" #include "fbgemm/Fbgemm.h" @@ -121,7 +122,7 @@ TEST_P(EmbeddingSpMDMTest, basicTest) { bool use_offsets = bool_dist(generator); bool use_output_input_stride = bool_dist(generator); bool test_thread_local = bool_dist(generator); - int prefetch; + int prefetch = 0; EmbeddingSpMDMWeightChoice weight_choice; EmbeddingSpMDMCornerCase corner_case; EmbeddingSpMDMInputDtypeChoice in_type; @@ -228,7 +229,7 @@ TEST_P(EmbeddingSpMDMTest, basicTest) { FloatToBfloat16_ref(&sentry_value, &output_bf16[i], 1); } - bool success, success_ref; + bool success = false, success_ref = false; #define TEST_BASE( \ table, \ @@ -404,7 +405,7 @@ TEST_P(EmbeddingSpMDMTest, basicTest) { if (is_output_float) return output[offset]; else if (is_output_bfloat16) { - float v; + float v = NAN; Bfloat16ToFloat_ref(&output_bf16[offset], &v, 1); return v; } else @@ -415,7 +416,7 @@ TEST_P(EmbeddingSpMDMTest, basicTest) { if (is_output_float) return output_ref[offset]; else if (is_output_bfloat16) { - float v; + float v = NAN; Bfloat16ToFloat_ref(&output_ref_bf16[offset], &v, 1); return v; } else @@ -460,7 +461,7 @@ TEST_P(rowwiseSparseEmbeddingSpMDMTest, rowwiseSparseTest) { bool normalize_by_lengths = bool_dist(generator); bool use_offsets = bool_dist(generator); bool is_output_float = bool_dist(generator); - int prefetch; + int prefetch = 0; EmbeddingSpMDMWeightChoice weight_choice; EmbeddingSpMDMCornerCase corner_case; tie(prefetch, weight_choice, corner_case) = GetParam(); @@ -526,7 +527,7 @@ TEST_P(rowwiseSparseEmbeddingSpMDMTest, rowwiseSparseTest) { vector& output_ref = use_weight ? output_slws_ref : output_sls_ref; vector& output = use_weight ? output_slws : output_sls; - bool success, success_ref; + bool success = false, success_ref = false; if (isOffset64b) { if (isIndex64b) { @@ -828,8 +829,8 @@ TEST_P(rowwiseSparseEmbeddingSpMDMTest, rowwiseSparseTest) { } TEST_P(IndexRemapTest, basicTest) { - int batch_size, num_rows, avg_len; - bool isIndex64b, per_sample_weights; + int batch_size = 0, num_rows = 0, avg_len = 0; + bool isIndex64b = false, per_sample_weights = false; tie(batch_size, num_rows, avg_len, isIndex64b, per_sample_weights) = GetParam(); constexpr float sparsity = 0.5; diff --git a/test/GConvTest.cc b/test/GConvTest.cc index 53be5b9cd8..c1289e62c8 100644 --- a/test/GConvTest.cc +++ b/test/GConvTest.cc @@ -487,11 +487,7 @@ static void runRequantizeTest(matrix_op_t /* unused */, } TEST_P(fbgemmGConvAcc32WithQuantGranularityTest, requantizeTest) { - matrix_op_t atrans, btrans; - QuantizationGranularity q_granularity; - bool a_symmetric, b_symmetric; - - tie(atrans, btrans, q_granularity, a_symmetric, b_symmetric) = GetParam(); + auto [atrans, btrans, q_granularity, a_symmetric, b_symmetric] = GetParam(); runRequantizeTest<2>(atrans, btrans, q_granularity, a_symmetric, b_symmetric); runRequantizeTest<3>(atrans, btrans, q_granularity, a_symmetric, b_symmetric); @@ -504,8 +500,7 @@ TEST_P(fbgemmGConvAcc32WithQuantGranularityTest, requantizeTest) { /* TEST_P(fbgemmGConvAcc32Test, NoRequantizeTest) { vector> shapes(GetShapes_()); - matrix_op_t atrans, btrans; - tie(atrans, btrans) = GetParam(); + auto [atrans, btrans] = GetParam(); for (auto conv_p : shapes) { int R = conv_p.K[0]; diff --git a/test/I8DepthwiseTest.cc b/test/I8DepthwiseTest.cc index 84c0571296..d9a9349c54 100644 --- a/test/I8DepthwiseTest.cc +++ b/test/I8DepthwiseTest.cc @@ -128,8 +128,8 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(1, 2, 3, 4, 5, 9, 10, 11, 27))); TEST_P(FBGemmDepthWiseTest, Test2D) { - bool a_symmetric, b_symmetric; - int oc_per_g; + bool a_symmetric = false, b_symmetric = false; + int oc_per_g = 0; tie(a_symmetric, b_symmetric, oc_per_g) = GetParam(); for (auto shape : shapes) { @@ -265,8 +265,8 @@ TEST_P(FBGemmDepthWiseTest, Test2D) { } // Test3x3 TEST_P(FBGemmDepthWiseTest, Test3D) { - bool a_symmetric, b_symmetric; - int oc_per_g; + bool a_symmetric = false, b_symmetric = false; + int oc_per_g = 0; tie(a_symmetric, b_symmetric, oc_per_g) = GetParam(); // 3D tests take a long time so for a symmetric quantization, we only @@ -690,7 +690,7 @@ TEST_P( } // Test3DPerChannelQuantization TEST_P(FBGemmDepthWisePackUnpackTest, TestPackUnpack) { - int K, kernel_prod; + int K = 0, kernel_prod = 0; tie(K, kernel_prod) = GetParam(); ASSERT_EQ(K % 8, 0) diff --git a/test/I8DirectconvTest.cc b/test/I8DirectconvTest.cc index 0b857b2316..4f01a47ad3 100644 --- a/test/I8DirectconvTest.cc +++ b/test/I8DirectconvTest.cc @@ -257,9 +257,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(1, 2))); // oc_per_g TEST_P(FBGemmDirectConvTest, Test2D) { - bool a_symmetric, b_symmetric; - int oc_per_g; - tie(a_symmetric, b_symmetric, oc_per_g) = GetParam(); + auto [a_symmetric, b_symmetric, oc_per_g] = GetParam(); for (auto conv_p : shapes) { int im_in_dim = accumulate( @@ -429,10 +427,6 @@ INSTANTIATE_TEST_CASE_P( ::testing::Values(1, 2))); // oc_per_g TEST_P(FBGemmDirectConvTransTest, Test2D) { - bool a_symmetric, b_symmetric; - int oc_per_g; - tie(a_symmetric, b_symmetric, oc_per_g) = GetParam(); - for (auto conv_p : shapes_trans) { int im_in_dim = accumulate( conv_p.IN_DIM.begin(), conv_p.IN_DIM.end(), 1, multiplies()); @@ -624,10 +618,6 @@ INSTANTIATE_TEST_CASE_P( TEST_P(FBGemmDirectConvTransFbgemmTest, Test2D) { - bool a_symmetric, b_symmetric; - int oc_per_g; - tie(a_symmetric, b_symmetric, oc_per_g) = GetParam(); - for (auto conv_p : shapes_trans) { int im_in_dim = accumulate( conv_p.IN_DIM.begin(), conv_p.IN_DIM.end(), 1, multiplies()); diff --git a/test/I8SpmdmTest.cc b/test/I8SpmdmTest.cc index 0e650f23ff..682fedfcbe 100644 --- a/test/I8SpmdmTest.cc +++ b/test/I8SpmdmTest.cc @@ -16,6 +16,7 @@ #include #ifdef _OPENMP +#include #include #endif @@ -51,8 +52,8 @@ TEST_P(fbgemmSPMDMTest, TestsSpMDM) { {14 * 14 * 2, 4, 2}, }; - float density; - bool accumulation, test_ld; + float density = NAN; + bool accumulation = false, test_ld = false; tie(density, accumulation, test_ld) = GetParam(); for (const auto& shape : shapes) { diff --git a/test/Im2ColFusedRequantizeTest.cc b/test/Im2ColFusedRequantizeTest.cc index ffd6519a5b..180c967463 100644 --- a/test/Im2ColFusedRequantizeTest.cc +++ b/test/Im2ColFusedRequantizeTest.cc @@ -84,7 +84,7 @@ static void Im2colTest(bool b_symmetric) { } else if constexpr (Q_GRAN == QuantizationGranularity::OUT_CHANNEL) { ncols_per_quant_group = 1; } - int32_t Aint8_zero_point; + int32_t Aint8_zero_point = 0; aligned_vector Bint8_zero_point( conv_p.OC / ncols_per_quant_group); if constexpr (is_same_v) { @@ -237,7 +237,7 @@ static void Im2colTest(bool b_symmetric) { TEST_P(fbgemmIm2colTest, Acc32Test) { QuantizationGranularity q_granularity; - bool b_symmetric; + bool b_symmetric = false; tie(q_granularity, b_symmetric) = GetParam(); if (q_granularity == QuantizationGranularity::TENSOR) { Im2colTest(b_symmetric); @@ -250,7 +250,7 @@ TEST_P(fbgemmIm2colTest, Acc32Test) { TEST_P(fbgemmIm2colTest, Acc16Test) { QuantizationGranularity q_granularity; - bool b_symmetric; + bool b_symmetric = false; tie(q_granularity, b_symmetric) = GetParam(); if (q_granularity == QuantizationGranularity::TENSOR) { Im2colTest(b_symmetric); @@ -285,7 +285,7 @@ static void SConvTest() { } else if constexpr (Q_GRAN == QuantizationGranularity::OUT_CHANNEL) { ncols_per_quant_group = 1; } - int32_t Aint8_zero_point; + int32_t Aint8_zero_point = 0; aligned_vector Bint8_zero_point( conv_p.OC / ncols_per_quant_group); randFill(Aint8, 0, 5); @@ -472,7 +472,7 @@ static void SConvTest() { TEST_P(fbgemmIm2colTest, SConvTest) { QuantizationGranularity q_granularity; - bool b_symmetric; + bool b_symmetric = false; tie(q_granularity, b_symmetric) = GetParam(); // b_symmetric ignored for now if (q_granularity == QuantizationGranularity::TENSOR) { @@ -585,7 +585,7 @@ static void Im2col3DTest(bool b_symmetric) { } else if constexpr (Q_GRAN == QuantizationGranularity::OUT_CHANNEL) { ncols_per_quant_group = 1; } - int32_t Aint8_zero_point; + int32_t Aint8_zero_point = 0; aligned_vector Bint8_zero_point( conv_p.OC / ncols_per_quant_group); if constexpr (is_same_v) { @@ -745,7 +745,7 @@ static void Im2col3DTest(bool b_symmetric) { TEST_P(fbgemmIm2colTest, 3DAcc32Test) { QuantizationGranularity q_granularity; - bool b_symmetric; + bool b_symmetric = false; tie(q_granularity, b_symmetric) = GetParam(); if (q_granularity == QuantizationGranularity::TENSOR) { Im2col3DTest(b_symmetric); @@ -758,7 +758,7 @@ TEST_P(fbgemmIm2colTest, 3DAcc32Test) { TEST_P(fbgemmIm2colTest, 3DAcc16Test) { QuantizationGranularity q_granularity; - bool b_symmetric; + bool b_symmetric = false; tie(q_granularity, b_symmetric) = GetParam(); if (q_granularity == QuantizationGranularity::TENSOR) { Im2col3DTest(b_symmetric); diff --git a/test/PackedRequantizeAcc16Test.cc b/test/PackedRequantizeAcc16Test.cc index 41fab88ddd..cb2eba5c82 100644 --- a/test/PackedRequantizeAcc16Test.cc +++ b/test/PackedRequantizeAcc16Test.cc @@ -119,7 +119,7 @@ TEST_P(fbgemmu8s8acc16WithQuantGranularityTest, Test) { vector> shapes(GetShapes_()); matrix_op_t atrans, btrans; - bool test_ld; + bool test_ld = false; QuantizationGranularity q_granularity; tie(atrans, btrans, test_ld, q_granularity) = GetParam(); @@ -366,7 +366,7 @@ TEST_P(fbgemmu8s8acc16WithQuantGranularityTest, SpMDMTest) { vector> shapes(GetShapes_()); matrix_op_t atrans, btrans; - bool test_ld; + bool test_ld = false; QuantizationGranularity q_granularity; tie(atrans, btrans, test_ld, q_granularity) = GetParam(); @@ -699,7 +699,7 @@ TEST_P(fbgemmu8s8acc16Test, NoRequantizeTest) { vector> shapes(GetShapes_()); matrix_op_t atrans, btrans; - bool test_ld; + bool test_ld = false; tie(atrans, btrans, test_ld) = GetParam(); for (auto shape : shapes) { @@ -850,7 +850,7 @@ TEST_P(fbgemmu8s8acc16Test, NoRequantizeTest) { TEST_P(fbgemmPackUnpackAcc16Test, TestPackUnpack) { vector> shapes(GetShapes_()); matrix_op_t btrans; - bool test_ld; + bool test_ld = false; tie(btrans, test_ld) = GetParam(); BlockingFactors params; diff --git a/test/PackedRequantizeTest.cc b/test/PackedRequantizeTest.cc index 6e80576e68..91912153cb 100644 --- a/test/PackedRequantizeTest.cc +++ b/test/PackedRequantizeTest.cc @@ -112,7 +112,7 @@ static vector> GetShapes_() { TEST_P(fbgemmu8s8acc32WithQuantGranularityTest, Test) { vector> shapes(GetShapes_()); matrix_op_t atrans, btrans; - bool test_ld; + bool test_ld = false; QuantizationGranularity q_granularity; tie(atrans, btrans, test_ld, q_granularity) = GetParam(); @@ -380,7 +380,7 @@ TEST_P(fbgemmu8s8acc32WithQuantGranularityTest, Test) { TEST_P(fbgemmu8s8acc32WithQuantGranularityTest, TestFloatInputOutput) { vector> shapes(GetShapes_()); matrix_op_t atrans, btrans; - bool test_ld; + bool test_ld = false; QuantizationGranularity q_granularity; tie(atrans, btrans, test_ld, q_granularity) = GetParam(); @@ -636,7 +636,7 @@ TEST_P(fbgemmu8s8acc32WithQuantGranularityTest, TestFloatInputOutput) { TEST_P(fbgemmu8s8acc32Test, TestSymmetricQuantizedInputOutput) { vector> shapes(GetShapes_()); matrix_op_t atrans, btrans; - bool test_ld; + bool test_ld = false; tie(atrans, btrans, test_ld) = GetParam(); for (auto shape : shapes) { @@ -780,7 +780,7 @@ TEST_P(fbgemmu8s8acc32Test, TestSymmetricQuantizedInputOutput) { TEST_P(fbgemmPackUnpackAcc32Test, TestPackUnpack) { vector> shapes(GetShapes_()); matrix_op_t btrans; - bool test_ld; + bool test_ld = false; tie(btrans, test_ld) = GetParam(); BlockingFactors params; diff --git a/test/QuantUtilsTest.cc b/test/QuantUtilsTest.cc index 04b8925a6e..f5f305a263 100644 --- a/test/QuantUtilsTest.cc +++ b/test/QuantUtilsTest.cc @@ -6,6 +6,8 @@ * LICENSE file in the root directory of this source tree. */ +#include + #include #include #include @@ -90,7 +92,7 @@ static void ref_impl( for (int g = 0; g < G; ++g) { for (int c = 0; c < C / G; ++c) { for (int x = 0; x < X; ++x) { - float num; + float num = NAN; if (LT == layout_t::KCX) { num = src[(i * C + g * C_per_G + c) * X + x]; } else { @@ -179,7 +181,7 @@ static ::testing::AssertionResult isQEmbeddingClose( } } // compare scale/bias - float scaleTest, scaleRef, biasTest, biasRef; + float scaleTest = NAN, scaleRef = NAN, biasTest = NAN, biasRef = NAN; if constexpr (is_same_v) { // half scale and bias scaleTest = cpu_half2float(reinterpret_cast( @@ -228,7 +230,7 @@ static ::testing::AssertionResult isQEmbeddingClose( * Test for QuantizeGroupwise */ TEST_P(QuantizeGroupwiseTest, quantizeGTest) { - int K, C, X, G; + int K = 0, C = 0, X = 0, G = 0; layout_t layout; tie(K, C, X, G, layout) = GetParam(); @@ -320,7 +322,7 @@ static void runQuantizeTests( * Test for QuantizeGroupwise */ TEST_P(QuantizeTest, quantizeTest) { - int len; + int len = 0; len = GetParam(); random_device rd; @@ -449,7 +451,7 @@ static void runFusedQuantizeDequantizeTests( } TEST_P(FusedQuantizeDequantizeTest, fusedQuantizeDequantizeTest) { - int len; + int len = 0; len = GetParam(); random_device rd; @@ -651,7 +653,7 @@ TEST_P(EmbeddingQuantizeFixedNumberTest, embeddingFloatToQuantizedSBHalfTest) { // Scale and bias are of type float16 TEST_P(EmbeddingQuantizeTest, embeddingHalfTest) { - int bit_rate, rows, cols; + int bit_rate = 0, rows = 0, cols = 0; tie(bit_rate, rows, cols) = GetParam(); random_device rd; @@ -730,7 +732,7 @@ TEST_P(EmbeddingQuantizeTest, embeddingHalfTest) { // Scale and bias are of type float TEST_P(EmbeddingQuantizeSBFloatTest, embeddingFloatTest) { - int rows, cols; + int rows = 0, cols = 0; tie(rows, cols) = GetParam(); random_device rd; diff --git a/test/RequantizeOnlyTest.cc b/test/RequantizeOnlyTest.cc index 99410cee2e..55fd31f98e 100644 --- a/test/RequantizeOnlyTest.cc +++ b/test/RequantizeOnlyTest.cc @@ -50,8 +50,8 @@ INSTANTIATE_TEST_CASE_P( * Test for float bias */ TEST_P(FloatRequantizeTest, floatBiasTest) { - int rows, cols; - bool fuse_relu; + int rows = 0, cols = 0; + bool fuse_relu = false; QuantizationGranularity q_gran; tie(rows, cols, fuse_relu, q_gran) = GetParam(); diff --git a/test/RowWiseSparseAdagradFusedTest.cc b/test/RowWiseSparseAdagradFusedTest.cc index 99508f855f..c59ddc6820 100644 --- a/test/RowWiseSparseAdagradFusedTest.cc +++ b/test/RowWiseSparseAdagradFusedTest.cc @@ -87,9 +87,9 @@ INSTANTIATE_TEST_CASE_P( TEST_P(RowWiseSparseAdagradFusedTest, rowwiseTest) { vector> inputs(GetInputs_()); - bool isWeightFp16, useStochasticRounding, isIndex64b, isOffset64b, - use_offsets, use_grad_stride; - int prefetch; + bool isWeightFp16 = false, useStochasticRounding = false, isIndex64b = false, + isOffset64b = false, use_offsets = false, use_grad_stride = false; + int prefetch = 0; EmbeddingSpMDMCornerCase corner_case; tie(isWeightFp16, useStochasticRounding, @@ -201,7 +201,7 @@ TEST_P(RowWiseSparseAdagradFusedTest, rowwiseTest) { lr); \ } while (0) - bool success, success_ref; + bool success = false, success_ref = false; if (isWeightFp16) { if (isOffset64b) { if (isIndex64b) { diff --git a/test/SparseAdagradTest.cc b/test/SparseAdagradTest.cc index 8b92675a77..a6f42970a3 100644 --- a/test/SparseAdagradTest.cc +++ b/test/SparseAdagradTest.cc @@ -64,8 +64,9 @@ INSTANTIATE_TEST_CASE_P( TEST_P(SparseAdagradTest, basicTest_two_stages) { vector> inputs(GetInputs_()); - bool isIndex64b, out_of_bounds, use_weight_decay, adjust_weight_decay; - int prefetch; + bool isIndex64b = false, out_of_bounds = false, use_weight_decay = false, + adjust_weight_decay = false; + int prefetch = 0; tie(isIndex64b, prefetch, out_of_bounds, @@ -125,7 +126,7 @@ TEST_P(SparseAdagradTest, basicTest_two_stages) { } } - int ret_fbgemm, ret_ref; + int ret_fbgemm = 0, ret_ref = 0; if (isIndex64b) { ret_ref = sparse_adagrad_ref( num_rows, // number of rows reading @@ -198,8 +199,9 @@ TEST_P(SparseAdagradTest, basicTest_two_stages) { TEST_P(SparseAdagradTest, rowwiseTest_two_stages) { vector> inputs(GetInputs_()); - bool isIndex64b, out_of_bounds, use_weight_decay, adjust_weight_decay; - int prefetch; + bool isIndex64b = false, out_of_bounds = false, use_weight_decay = false, + adjust_weight_decay = false; + int prefetch = 0; tie(isIndex64b, prefetch, out_of_bounds, @@ -256,7 +258,7 @@ TEST_P(SparseAdagradTest, rowwiseTest_two_stages) { } } - int ret_fbgemm, ret_ref; + int ret_fbgemm = 0, ret_ref = 0; if (isIndex64b) { ret_ref = rowwise_sparse_adagrad_ref( num_rows, // number of rows reading diff --git a/test/SparseDenseMMInt8Test.cc b/test/SparseDenseMMInt8Test.cc index 4f33a9b613..3053d7799a 100644 --- a/test/SparseDenseMMInt8Test.cc +++ b/test/SparseDenseMMInt8Test.cc @@ -7,6 +7,7 @@ */ #include +#include #include #include "bench/BenchUtils.h" // @manual @@ -43,9 +44,9 @@ INSTANTIATE_TEST_CASE_P( * Test for sparse-dense matrix-matrix multiplication (int8) */ TEST_P(SPMMInt8Test, spInt8) { - int M, N, K; - float fnz; - bool fuse_relu; + int M = 0, N = 0, K = 0; + float fnz = NAN; + bool fuse_relu = false; QuantizationGranularity qGran; tie(M, N, K, fnz, fuse_relu, qGran) = GetParam(); diff --git a/test/SparsePackUnpackTest.cc b/test/SparsePackUnpackTest.cc index 1188baafce..616640b4a9 100644 --- a/test/SparsePackUnpackTest.cc +++ b/test/SparsePackUnpackTest.cc @@ -7,6 +7,7 @@ */ #include +#include #include #include "bench/BenchUtils.h" // @manual @@ -32,8 +33,8 @@ INSTANTIATE_TEST_CASE_P( * Test for packing/unpacking */ TEST_P(packUnpackTest, sparseUnpackTest) { - int N, K; - float fnz; + int N = 0, K = 0; + float fnz = NAN; tie(N, K, fnz) = GetParam(); // wData is dense diff --git a/test/TransposeTest.cc b/test/TransposeTest.cc index 6e87b7418f..4c9067f146 100644 --- a/test/TransposeTest.cc +++ b/test/TransposeTest.cc @@ -94,7 +94,7 @@ TEST(TransposeTest, TransposeTest) { } for (const auto& shape : shapes) { - int m, n, ld_src, ld_dst; + int m = 0, n = 0, ld_src = 0, ld_dst = 0; tie(m, n, ld_src, ld_dst) = shape; // float test diff --git a/test/TransposedRequantizeTest.cc b/test/TransposedRequantizeTest.cc index 24e5fda60d..e0e10ddbb7 100644 --- a/test/TransposedRequantizeTest.cc +++ b/test/TransposedRequantizeTest.cc @@ -48,11 +48,7 @@ INSTANTIATE_TEST_CASE_P( ::testing::ValuesIn(qGranularityVals))); // requantization granularity TEST_P(RequantizeTest, reqTest) { - int rows, cols; - bool fuse_relu; - bool use_bias; - QuantizationGranularity q_gran; - tie(rows, cols, fuse_relu, use_bias, q_gran) = GetParam(); + auto [rows, cols, fuse_relu, use_bias, q_gran] = GetParam(); int numElements = rows * cols; diff --git a/test/UniConvTest.cc b/test/UniConvTest.cc index 94fc35e080..7c3f01df90 100644 --- a/test/UniConvTest.cc +++ b/test/UniConvTest.cc @@ -193,7 +193,8 @@ INSTANTIATE_TEST_CASE_P( * Test for conv packing */ TEST_P(uniConvTest, packingTest) { - int MB, IC, OC, IT, IH, IW, G, kernel, stride, pad; + int MB = 0, IC = 0, OC = 0, IT = 0, IH = 0, IW = 0, G = 0, kernel = 0, + stride = 0, pad = 0; tie(MB, IC, OC, IT, IH, IW, G, kernel, stride, pad) = GetParam(); conv_param_t<1> conv_p_1d( @@ -452,7 +453,8 @@ TEST_P(uniConvTest, packingTest) { * Test for packing/unpacking */ TEST_P(uniConvTest, packUnpackTest) { - int MB, IC, OC, IT, IH, IW, G, kernel, stride, pad; + int MB = 0, IC = 0, OC = 0, IT = 0, IH = 0, IW = 0, G = 0, kernel = 0, + stride = 0, pad = 0; tie(MB, IC, OC, IT, IH, IW, G, kernel, stride, pad) = GetParam(); conv_param_t<1> conv_p_1d( @@ -976,8 +978,8 @@ static void runRequantizeTest( TEST_P(UniConvQGranTest, requantizeTest) { QuantizationGranularity q_granularity; - bool a_symmetric, b_symmetric; - bool test_bias, test_float_bias; + bool a_symmetric = false, b_symmetric = false; + bool test_bias = false, test_float_bias = false; tie(q_granularity, a_symmetric, b_symmetric, test_bias, test_float_bias) = GetParam();