@@ -95,7 +95,7 @@ c10::MaybeOwned<Tensor> inline prepare_matrix_for_cublas(const Tensor& tensor, b
95
95
96
96
struct cublasCommonArgs {
97
97
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 ;
99
99
result = prepare_matrix_for_cublas (c, transpose_result);
100
100
mata = prepare_matrix_for_cublas (transpose_result ? mat2 : mat1, transpose_mat1, transpose_result);
101
101
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
263
263
" expected mat1 and mat2 to have the same dtype, but got: " , mat1.dtype (), " != " , mat2.dtype ()
264
264
)
265
265
266
+ // NOLINTNEXTLINE(*c-array*)
266
267
TensorArg targs[]{{result, " out" , 0 }, {self, " self" , 1 }, {mat1, " mat1" , 2 }, {mat2, " mat2" , 3 }};
267
268
checkAllSameGPU (__func__, targs);
268
269
@@ -483,9 +484,11 @@ Tensor& addmm_out_cuda_impl(Tensor& result, const Tensor& self, const Tensor& ma
483
484
});
484
485
switch (activation) {
485
486
case Activation::RELU:
487
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
486
488
at::relu_ (const_cast <Tensor&>(*args.result ));
487
489
break ;
488
490
case Activation::GELU:
491
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
489
492
at::gelu_ (const_cast <Tensor&>(*args.result ), " tanh" );
490
493
break ;
491
494
default : break ;
@@ -542,8 +545,8 @@ const Tensor& baddbmm_out_cuda_impl(const Tensor& result, const Tensor& self, co
542
545
int64_t n = result_sizes[leading_dim];
543
546
int64_t k = (transpose_result ? batch2 : batch1).sizes ()[leading_dim];
544
547
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 ;
547
550
auto batch1_ = prepare_batch_matrix_for_cublas (transpose_result ? batch2 : batch1, transpose_batch1, lda, transpose_result, m, k);
548
551
auto batch2_ = prepare_batch_matrix_for_cublas (transpose_result ? batch1 : batch2, transpose_batch2, ldb, transpose_result, k, n);
549
552
@@ -593,14 +596,17 @@ const Tensor& baddbmm_out_cuda_impl(const Tensor& result, const Tensor& self, co
593
596
} // anonymous namespace
594
597
595
598
TORCH_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)
596
600
addmm_out_cuda_impl (const_cast <Tensor&>(result), self, mat1, mat2, beta, alpha);
597
601
}
598
602
599
603
TORCH_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)
600
605
addmm_out_cuda_impl (const_cast <Tensor&>(result), self, mat1, mat2, beta, alpha, use_gelu ? Activation::GELU : Activation::RELU);
601
606
}
602
607
603
608
TORCH_IMPL_FUNC (mm_out_cuda)(const Tensor& self, const Tensor& mat2, const Tensor& result) {
609
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
604
610
addmm_out_cuda_impl (const_cast <Tensor&>(result), result, self, mat2, 0 , 1 );
605
611
}
606
612
@@ -765,13 +771,15 @@ TORCH_IMPL_FUNC(addmv_out_cuda)(const Tensor &self, const Tensor &mat, const Ten
765
771
result.zero_ ();
766
772
} else {
767
773
at::mul_out (
774
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
768
775
const_cast <Tensor&>(result),
769
776
self,
770
777
at::native::scalar_tensor (
771
778
beta_, self.scalar_type (), std::nullopt /* layout */ , at::kCPU , std::nullopt /* pin_memory */ ));
772
779
}
773
780
} else {
774
781
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)
775
783
at::native::copy_ (const_cast <Tensor&>(result), *self_);
776
784
}
777
785
if (result.numel () != 0 ) {
@@ -1040,6 +1048,7 @@ _scaled_mm_out_cuda(const Tensor& mat1, const Tensor& mat2,
1040
1048
auto bias_ = bias.value_or (Tensor ());
1041
1049
auto scale_result_ = scale_result.value_or (Tensor ());
1042
1050
1051
+ // NOLINTNEXTLINE(*c-array*)
1043
1052
TensorArg targs[]{{out, " out" , 0 }, {mat1, " mat1" , 1 }, {mat2, " mat2" , 2 },
1044
1053
{bias_, " bias" , 3 }, {scale_a, " scale_a" , 4 }, {scale_b, " scale_b" , 5 },
1045
1054
{scale_result_, " scale_result" , 6 }};
0 commit comments