@@ -95,7 +95,7 @@ c10::MaybeOwned<Tensor> inline prepare_matrix_for_cublas(const Tensor& tensor, b
9595
9696struct cublasCommonArgs {
9797 cublasCommonArgs (const Tensor& mat1, const Tensor& mat2, Tensor& c) {
98- bool transpose_result, transpose_mat1, transpose_mat2;
98+ bool transpose_result = false , transpose_mat1 = false , transpose_mat2 = false ;
9999 result = prepare_matrix_for_cublas (c, transpose_result);
100100 mata = prepare_matrix_for_cublas (transpose_result ? mat2 : mat1, transpose_mat1, transpose_result);
101101 matb = prepare_matrix_for_cublas (transpose_result ? mat1 : mat2, transpose_mat2, transpose_result);
@@ -263,6 +263,7 @@ Tensor& addmm_out_cuda_impl(Tensor& result, const Tensor& self, const Tensor& ma
263263 " expected mat1 and mat2 to have the same dtype, but got: " , mat1.dtype (), " != " , mat2.dtype ()
264264 )
265265
266+ // NOLINTNEXTLINE(*c-array*)
266267 TensorArg targs[]{{result, " out" , 0 }, {self, " self" , 1 }, {mat1, " mat1" , 2 }, {mat2, " mat2" , 3 }};
267268 checkAllSameGPU (__func__, targs);
268269
@@ -483,9 +484,11 @@ Tensor& addmm_out_cuda_impl(Tensor& result, const Tensor& self, const Tensor& ma
483484 });
484485 switch (activation) {
485486 case Activation::RELU:
487+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
486488 at::relu_ (const_cast <Tensor&>(*args.result ));
487489 break ;
488490 case Activation::GELU:
491+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
489492 at::gelu_ (const_cast <Tensor&>(*args.result ), " tanh" );
490493 break ;
491494 default : break ;
@@ -542,8 +545,8 @@ const Tensor& baddbmm_out_cuda_impl(const Tensor& result, const Tensor& self, co
542545 int64_t n = result_sizes[leading_dim];
543546 int64_t k = (transpose_result ? batch2 : batch1).sizes ()[leading_dim];
544547
545- int64_t lda, ldb, ldc;
546- bool transpose_batch1, transpose_batch2;
548+ int64_t lda = 0 , ldb = 0 , ldc = 0 ;
549+ bool transpose_batch1 = false , transpose_batch2 = false ;
547550 auto batch1_ = prepare_batch_matrix_for_cublas (transpose_result ? batch2 : batch1, transpose_batch1, lda, transpose_result, m, k);
548551 auto batch2_ = prepare_batch_matrix_for_cublas (transpose_result ? batch1 : batch2, transpose_batch2, ldb, transpose_result, k, n);
549552
@@ -593,14 +596,17 @@ const Tensor& baddbmm_out_cuda_impl(const Tensor& result, const Tensor& self, co
593596} // anonymous namespace
594597
595598TORCH_IMPL_FUNC (addmm_out_cuda)(const Tensor& self, const Tensor& mat1, const Tensor& mat2, const Scalar& beta, const Scalar& alpha, const Tensor& result) {
599+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
596600 addmm_out_cuda_impl (const_cast <Tensor&>(result), self, mat1, mat2, beta, alpha);
597601}
598602
599603TORCH_IMPL_FUNC (addmm_activation_out_cuda)(const Tensor& self, const Tensor& mat1, const Tensor& mat2, const Scalar& beta, const Scalar& alpha, bool use_gelu, const Tensor& result) {
604+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
600605 addmm_out_cuda_impl (const_cast <Tensor&>(result), self, mat1, mat2, beta, alpha, use_gelu ? Activation::GELU : Activation::RELU);
601606}
602607
603608TORCH_IMPL_FUNC (mm_out_cuda)(const Tensor& self, const Tensor& mat2, const Tensor& result) {
609+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
604610 addmm_out_cuda_impl (const_cast <Tensor&>(result), result, self, mat2, 0 , 1 );
605611}
606612
@@ -765,13 +771,15 @@ TORCH_IMPL_FUNC(addmv_out_cuda)(const Tensor &self, const Tensor &mat, const Ten
765771 result.zero_ ();
766772 } else {
767773 at::mul_out (
774+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
768775 const_cast <Tensor&>(result),
769776 self,
770777 at::native::scalar_tensor (
771778 beta_, self.scalar_type (), std::nullopt /* layout */ , at::kCPU , std::nullopt /* pin_memory */ ));
772779 }
773780 } else {
774781 if (!result.is_same (*self_) && betaval != 0.0 ) { // if beta is 0, result contents will be zeroed later
782+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
775783 at::native::copy_ (const_cast <Tensor&>(result), *self_);
776784 }
777785 if (result.numel () != 0 ) {
@@ -1040,6 +1048,7 @@ _scaled_mm_out_cuda(const Tensor& mat1, const Tensor& mat2,
10401048 auto bias_ = bias.value_or (Tensor ());
10411049 auto scale_result_ = scale_result.value_or (Tensor ());
10421050
1051+ // NOLINTNEXTLINE(*c-array*)
10431052 TensorArg targs[]{{out, " out" , 0 }, {mat1, " mat1" , 1 }, {mat2, " mat2" , 2 },
10441053 {bias_, " bias" , 3 }, {scale_a, " scale_a" , 4 }, {scale_b, " scale_b" , 5 },
10451054 {scale_result_, " scale_result" , 6 }};
0 commit comments