Skip to content

Commit

Permalink
Fix unused-variable issues in caffe2 (pytorch#143639)
Browse files Browse the repository at this point in the history
Summary:
LLVM-15 has a warning `-Wunused-variable` which we treat as an error because it's so often diagnostic of a code issue. Unused variables can compromise readability or, worse, performance.

This diff either (a) removes an unused variable and, possibly, it's associated code or (b) qualifies the variable with `[[maybe_unused]]`.

 - If you approve of this diff, please use the "Accept & Ship" button :-)

Test Plan: Sandcastle

Pull Request resolved: pytorch#143639
Approved by: https://github.com/kit1980, https://github.com/malfet, https://github.com/cyyever
  • Loading branch information
r-barnes authored and pytorchmergebot committed Dec 21, 2024
1 parent f443100 commit 518b505
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions aten/src/ATen/cuda/CUDABlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,6 @@ void scaled_gemm(
#if CUDA_VERSION >= 11080 || defined(USE_ROCM)
const auto computeType = CUBLAS_COMPUTE_32F;
const auto scaleType = CUDA_R_32F;
const int8_t fastAccuMode = use_fast_accum ? 1 : 0;
const float alpha_val = 1.0;
const float beta_val = 0.0;
CuBlasLtMatmulDescriptor computeDesc(computeType, scaleType);
Expand All @@ -1454,7 +1453,7 @@ void scaled_gemm(
computeDesc.setAttribute(CUBLASLT_MATMUL_DESC_D_SCALE_POINTER, result_scale_ptr);
}
#ifndef USE_ROCM
computeDesc.setAttribute(CUBLASLT_MATMUL_DESC_FAST_ACCUM, fastAccuMode);
computeDesc.setAttribute(CUBLASLT_MATMUL_DESC_FAST_ACCUM, use_fast_accum ? 1 : 0);
#endif
CuBlasLtMatrixLayout Adesc(ScalarTypeToCudaDataType(mat1_dtype), m, k, mat1_ld, transa == 't');
CuBlasLtMatrixLayout Bdesc(ScalarTypeToCudaDataType(mat2_dtype), k, n, mat2_ld, transb == 't');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace ao::sparse {
int register_linear_params() {
static auto register_linear_params =
[[maybe_unused]] static auto register_linear_params =
torch::selective_class_<LinearPackedParamsBase>(
"sparse", TORCH_SELECTIVE_CLASS("LinearPackedParamsBase"))
.def_pickle(
Expand Down
2 changes: 1 addition & 1 deletion aten/src/ATen/native/sparse/cuda/SparseCUDABlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ void _csrmm2(


auto handle = at::cuda::getCurrentCUDASparseHandle();
cudaDeviceProp* prop = at::cuda::getCurrentDeviceProperties();
// ALG1 is broken on SM89 as of CUDA 11.8+
#if !defined(USE_ROCM)
cudaDeviceProp* prop = at::cuda::getCurrentDeviceProperties();
auto default_alg = prop->major == 8 && prop->minor == 9 ? CUSPARSE_SPMM_CSR_ALG2 : CUSPARSE_SPMM_CSR_ALG1;
#else
auto default_alg = CUSPARSE_SPMM_CSR_ALG1;
Expand Down
5 changes: 3 additions & 2 deletions aten/src/ATen/native/transformers/cuda/sdp_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,13 +650,14 @@ bool can_use_mem_efficient_attention(sdp_params const& params, bool debug) {
return false;
#endif
// Constraints specific to mem efficient attention
constexpr auto greater_than_or_equal_sm80_mem_efficient_dtypes =
array_of<at::ScalarType>(at::kHalf, at::kFloat, at::kBFloat16);
constexpr auto less_than_sm80_mem_efficient_dtypes =
array_of<at::ScalarType>(at::kHalf, at::kFloat);
#ifdef USE_ROCM
constexpr auto aotriton_mem_efficient_dtypes =
array_of<at::ScalarType>(at::kHalf, at::kFloat, at::kBFloat16);
#else
constexpr auto greater_than_or_equal_sm80_mem_efficient_dtypes =
array_of<at::ScalarType>(at::kHalf, at::kFloat, at::kBFloat16);
#endif

// Define gate functions that determine if a mem efficient kernel can be ran
Expand Down

0 comments on commit 518b505

Please sign in to comment.