Skip to content

Commit 1de2434

Browse files
cyyeverfacebook-github-bot
authored andcommitted
Fix clang-tidy and nvcc warnings (pytorch#4923)
Summary: Pull Request resolved: pytorch#4923 X-link: facebookresearch/FBGEMM#1947 Pull Request resolved: pytorch#4918 Reviewed By: ionuthristodorescu Differential Revision: D83070110 Pulled By: q10 fbshipit-source-id: 1b12db2de80a5bdd50a3a2fdcae332f634a7abbc
1 parent 03f6bde commit 1de2434

File tree

8 files changed

+17
-19
lines changed

8 files changed

+17
-19
lines changed

fbgemm_gpu/codegen/training/backward/embedding_backward_split_indice_weights_template.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ __global__ __launch_bounds__(kForwardMaxThreads) void
9898
{%- endif %}
9999
) {
100100
constexpr int32_t kVecWidth = 4;
101-
int error_code = 0;
102-
int64_t error_value;
101+
[[maybe_unused]] int error_code = 0;
102+
[[maybe_unused]] int64_t error_value = 0;
103103

104104
int32_t T = D_offsets.size(0) - 1;
105105
auto b_t = blockIdx.x * blockDim.y + threadIdx.y;

fbgemm_gpu/codegen/training/forward/embedding_forward_split_kernel_template.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ using namespace fbgemm_gpu;
298298
// Cooperatively load the indices
299299
const overflow_safe_int_t idx = l < L ? indices[indices_start + l] : 0;
300300
// If idx is loaded
301-
const auto offset_idx = idx * D_emb;
301+
[[maybe_unused]] const auto offset_idx = idx * D_emb;
302302
{%- endif %}
303303

304304
{%- if not dense and lxu_miss_rate != "cache_conflict_miss_rate::all" %}

fbgemm_gpu/src/sparse_ops/sparse_ops_cpu.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,9 +1386,9 @@ void _block_bucketize_sparse_features_2d_weights_cpu_kernel(
13861386
const std::optional<Tensor>& total_num_blocks,
13871387
const int64_t my_size,
13881388
const int64_t weights_dim,
1389-
Tensor new_lengths,
1390-
Tensor new_indices,
1391-
Tensor new_weights,
1389+
const Tensor& new_lengths,
1390+
const Tensor& new_indices,
1391+
const Tensor& new_weights,
13921392
std::optional<Tensor> new_pos,
13931393
const std::optional<Tensor>& unbucketize_permute,
13941394
const std::optional<Tensor>& batch_size_per_feature,
@@ -1417,8 +1417,8 @@ void _block_bucketize_sparse_features_2d_weights_cpu_kernel(
14171417
const index_t* const block_sizes_data = block_sizes.data_ptr<index_t>();
14181418
offset_t* batch_sizes_data = nullptr;
14191419
const auto variable_batch_size = batch_size_per_feature.has_value();
1420-
const auto variable_bucket_sizes = block_bucketize_pos.has_value() &&
1421-
block_bucketize_pos.value().size() != 0;
1420+
const auto variable_bucket_sizes =
1421+
block_bucketize_pos.has_value() && !block_bucketize_pos.value().empty();
14221422
using uindex_t = std::make_unsigned_t<index_t>;
14231423
using uoffset_t = std::make_unsigned_t<offset_t>;
14241424
std::vector<int64_t> lower_bounds(indices.numel(), 0);

fbgemm_gpu/src/split_embeddings_utils/generate_vbe_metadata.cu

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ __launch_bounds__(kMaxThreads) void generate_vbe_metadata_foreach_sample_kernel(
7070

7171
} // namespace
7272

73-
std::tuple<int, int, int> get_max_grid_size(int device) {
73+
static std::tuple<int, int, int> get_max_grid_size() {
7474
static auto max_grid = [&]() -> std::tuple<int, int, int> {
7575
cudaDeviceProp prop;
7676
C10_CUDA_CHECK(cudaGetDeviceProperties(&prop, at::cuda::current_device()));
@@ -152,8 +152,7 @@ generate_vbe_metadata(
152152

153153
const auto grid_dim_x = div_round_up(max_B_feature_rank, kMaxThreads);
154154
const dim3 grid_size(grid_dim_x, num_ranks, T);
155-
const auto& [max_grid_x, max_grid_y, max_grid_z] =
156-
get_max_grid_size(at::cuda::current_device());
155+
const auto& [max_grid_x, max_grid_y, max_grid_z] = get_max_grid_size();
157156
TORCH_CHECK(
158157
grid_size.x > 0 && grid_size.x <= max_grid_x,
159158
"generate_vbe_metadata: Invalid grid_size.x ",

fbgemm_gpu/src/split_embeddings_utils/get_infos_metadata.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ using Tensor = at::Tensor;
1414
using namespace fbgemm_gpu;
1515

1616
DLL_PUBLIC std::tuple<int64_t, int64_t>
17-
get_infos_metadata(Tensor unused, int64_t B, int64_t T) {
17+
get_infos_metadata(Tensor /*unused*/, int64_t B, int64_t T) {
1818
return get_info_B_num_bits_from_T(T, B);
1919
}

fbgemm_gpu/src/tbe/eeg/indices_generator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static torch::Tensor convertVectorToTensor(
5353
// Metadata structure for an index
5454
struct IndexMetadata {
5555
std::vector<double> tags;
56-
int64_t freq;
56+
int64_t freq{};
5757
};
5858

5959
torch::Tensor IndicesGenerator::generate() {

fbgemm_gpu/src/topology_utils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ AdjacencyMatrix<Links> get_nvlink_matrix() {
124124
std::unordered_map<Node, uint32_t> cuda_device_to_nvml_device;
125125

126126
for (const auto i : c10::irange(device_count)) {
127-
nvmlDevice_t handle;
127+
nvmlDevice_t handle = nullptr;
128128
NVML_CHECK(nvmlDeviceGetHandleByIndex(i, &handle));
129129
nvmlPciInfo_t pci_info;
130130
NVML_CHECK(nvmlDeviceGetPciInfo(handle, &pci_info));
131-
std::array<char, NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE> pci_bus_id;
131+
std::array<char, NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE> pci_bus_id{};
132132
std::copy(
133133
&pci_info.busId[0],
134134
&pci_info.busId[NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE],
@@ -148,7 +148,7 @@ AdjacencyMatrix<Links> get_nvlink_matrix() {
148148

149149
std::vector<Links> links(world_size * world_size);
150150
for (const auto i : c10::irange(world_size)) {
151-
nvmlDevice_t handle;
151+
nvmlDevice_t handle = nullptr;
152152
NVML_CHECK(
153153
nvmlDeviceGetHandleByIndex(cuda_device_to_nvml_device[i], &handle));
154154
for (const auto link : c10::irange(NVML_NVLINK_MAX_LINKS)) {
@@ -163,7 +163,7 @@ AdjacencyMatrix<Links> get_nvlink_matrix() {
163163
}
164164
nvmlPciInfo_t pci_info;
165165
NVML_CHECK(nvmlDeviceGetNvLinkRemotePciInfo(handle, link, &pci_info));
166-
std::array<char, NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE> pci_bus_id;
166+
std::array<char, NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE> pci_bus_id{};
167167
std::copy(
168168
&pci_info.busId[0],
169169
&pci_info.busId[NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE],

test/PackedRequantizeAcc16Test.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include <cpuinfo.h>
1010
#include <algorithm>
11-
#include <cmath>
1211
#include <numeric>
1312
#include <random>
1413
#include <vector>
@@ -458,7 +457,7 @@ TEST_P(fbgemmu8s8acc16WithQuantGranularityTest, SpMDMTest) {
458457
int b_remainder = 0;
459458
if (kidx % 2 == 1) {
460459
// Make sure abs(b_prev + *bptr - b_remainder) <= 128
461-
int b_prev = B_csc.Values().back();
460+
auto b_prev = B_csc.Values().back();
462461
b_remainder = std::max(b_prev + *bptr - 128, b_remainder);
463462
b_remainder = std::min(b_prev + *bptr + 128, b_remainder);
464463
}

0 commit comments

Comments
 (0)