Skip to content

Commit 53f3361

Browse files
malfetpytorchmergebot
authored andcommitted
[BE] Use nested namespaces for sparse (pytorch#117415)
C++17 is fu Pull Request resolved: pytorch#117415 Approved by: https://github.com/Skylion007
1 parent d8bdb50 commit 53f3361

23 files changed

+48
-106
lines changed

aten/src/ATen/native/sparse/ParamUtils.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
#include <ATen/TensorUtils.h>
55
#include <tuple>
66

7-
namespace at {
8-
namespace native {
7+
namespace at::native {
98

109
TORCH_API std::tuple<Tensor, Tensor, int64_t> softmax_sparse_input_preprocessing(
1110
const Tensor& input_,
@@ -20,5 +19,4 @@ TORCH_API std::tuple<Tensor, Tensor, Tensor, int64_t> softmax_backward_sparse_in
2019
const Tensor& input_,
2120
CheckedFrom function_name);
2221

23-
} // namespace native
24-
} // namespace at
22+
} // namespace at::native

aten/src/ATen/native/sparse/SparseBinaryOpIntersectionCommon.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
#define NAME "sparse_binary_op_intersection_cpu"
2424
#endif
2525

26-
namespace at {
27-
namespace native {
26+
namespace at::native {
2827

2928
namespace {
3029

@@ -478,4 +477,4 @@ void _sparse_binary_op_intersection_kernel_out(
478477

479478
} // anonymous namespace
480479

481-
}} // at::native
480+
} // at::native

aten/src/ATen/native/sparse/SparseBlas.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
#include <ATen/Tensor.h>
66
#include <ATen/core/Scalar.h>
77

8-
namespace at {
9-
namespace native {
10-
namespace sparse {
8+
namespace at::native::sparse {
119

1210
TORCH_API void sparse_sampled_addmm_check_inputs(
1311
const Tensor& self,
@@ -17,6 +15,4 @@ TORCH_API void sparse_sampled_addmm_check_inputs(
1715
const Scalar& alpha,
1816
const Tensor& result);
1917

20-
} // namespace sparse
21-
} // namespace native
22-
} // namespace at
18+
} // namespace at::native::sparse

aten/src/ATen/native/sparse/SparseBlasImpl.h

+2-8
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
#include <ATen/Tensor.h>
44
#include <ATen/core/Scalar.h>
55

6-
namespace at {
7-
namespace native {
8-
namespace sparse {
9-
namespace impl {
6+
namespace at::native::sparse::impl {
107

118
TORCH_API Tensor& _compressed_row_strided_mm_out(
129
const Tensor& compressed_row_sparse,
@@ -45,7 +42,4 @@ void triangular_solve_out_sparse_csr(
4542
bool unitriangular);
4643

4744
} // namespace cpu
48-
} // namespace impl
49-
} // namespace sparse
50-
} // namespace native
51-
} // namespace at
45+
} // namespace at::native::sparse::impl

aten/src/ATen/native/sparse/SparseCsrTensorMath.h

+2-8
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
#include <ATen/native/ReductionType.h>
77
#include <ATen/native/cpu/SpmmReduceKernel.h>
88

9-
namespace at {
10-
namespace native {
11-
namespace sparse {
12-
namespace impl {
9+
namespace at::native::sparse::impl {
1310

1411
// Returns true if all entries of self are zero
1512
// TODO: This has potential to be a generic helper
@@ -84,7 +81,4 @@ inline void check_sparse_mm_reduce_impl_inputs(
8481
check_dim_size(other, 2, 0, self.size(1));
8582
}
8683

87-
}
88-
}
89-
}
90-
}
84+
} // at::native::sparse::impl

aten/src/ATen/native/sparse/SparseStubs.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,5 @@ DECLARE_DISPATCH(sparse_mask_projection_out_fn, sparse_mask_projection_out_stub)
2222
using flatten_indices_fn = Tensor (*)(const Tensor& indices, IntArrayRef size);
2323
DECLARE_DISPATCH(flatten_indices_fn, flatten_indices_stub);
2424

25-
}
26-
27-
}
25+
} // namespace native
26+
} // namespace at

aten/src/ATen/native/sparse/SparseTensorMath.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
#include <ATen/native/SparseTensorUtils.h>
44

5-
namespace at { namespace native {
5+
namespace at::native {
66

77
TORCH_API sparse::SparseTensor& mul_out_sparse_scalar(sparse::SparseTensor& r, const sparse::SparseTensor& t, const Scalar& value);
88
TORCH_API sparse::SparseTensor& mul_out_sparse_zerodim(sparse::SparseTensor& r, const sparse::SparseTensor& t, const Tensor& value);
99
TORCH_API sparse::SparseTensor& _mul_dense_sparse_out(const Tensor& d, const Tensor& s, Tensor& res);
1010
TORCH_API sparse::SparseTensor& _mul_sparse_sparse_zero_dim_out(const Tensor& zero_dim, const Tensor& other, Tensor& res);
1111
TORCH_API sparse::SparseTensor& _mul_sparse_sparse_out(const Tensor& x, const Tensor& y, Tensor& res);
1212

13-
}}
13+
} // namespace at::native

aten/src/ATen/native/sparse/ValidateCompressedIndicesCommon.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424

2525
#define INVARIANT_CHECK_FUNC_API static INLINE FUNCAPI void
2626

27-
namespace at {
28-
namespace native {
27+
namespace at::native {
2928

3029
namespace {
3130

@@ -412,5 +411,4 @@ void validate_compressed_sparse_indices_kernel(
412411

413412
} // namespace
414413

415-
} // namespace native
416-
} // namespace at
414+
} // namespace at::native

aten/src/ATen/native/sparse/cuda/SoftMax.cu

+2-4
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@
6161

6262
#include <c10/cuda/CUDAMathCompat.h>
6363

64-
namespace at {
65-
namespace native {
64+
namespace at::native {
6665
namespace {
6766

6867
// Number of threads in a block given an input size up to MAX_BLOCK_SIZE
@@ -669,5 +668,4 @@ Tensor log_softmax_backward_sparse_cuda(
669668
return grad_input;
670669
}
671670

672-
} // namespace native
673-
} // namespace at
671+
} // namespace at::native

aten/src/ATen/native/sparse/cuda/SparseBlas.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424

2525
#include <c10/util/MaybeOwned.h>
2626

27-
namespace at {
28-
namespace native {
27+
namespace at::native {
2928

3029
/*
3130
Computes `result` <- α*(A @ B) * spy(C) + β*C, where spy(C) is the sparsity pattern matrix of C.
@@ -285,5 +284,4 @@ std::tuple<Tensor&, Tensor&> triangular_solve_out_sparse_csr_cuda(
285284
return std::tuple<Tensor&, Tensor&>(X, clone_A);
286285
}
287286

288-
} // namespace native
289-
} // namespace at
287+
} // namespace at::native

aten/src/ATen/native/sparse/cuda/SparseBlasImpl.cpp

+2-10
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@
2323
#include <c10/cuda/CUDACachingAllocator.h>
2424
#include <c10/util/MaybeOwned.h>
2525

26-
namespace at {
27-
namespace native {
28-
namespace sparse {
29-
namespace impl {
30-
namespace cuda {
26+
namespace at::native::sparse::impl::cuda {
3127

3228
namespace {
3329

@@ -1515,8 +1511,4 @@ void sampled_addmm_out_sparse_csr(
15151511
#endif
15161512
}
15171513

1518-
} // namespace cuda
1519-
} // namespace impl
1520-
} // namespace sparse
1521-
} // namespace native
1522-
} // namespace at
1514+
} // namespace at::native::sparse::impl::cuda

aten/src/ATen/native/sparse/cuda/SparseBlasImpl.h

+2-10
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
#include <ATen/Tensor.h>
55
#include <ATen/core/Scalar.h>
66

7-
namespace at {
8-
namespace native {
9-
namespace sparse {
10-
namespace impl {
11-
namespace cuda {
7+
namespace at::native::sparse::impl::cuda {
128

139
void addmm_out_sparse_csr(
1410
const Tensor& input,
@@ -47,8 +43,4 @@ void sampled_addmm_out_sparse_csr(
4743
const Scalar& alpha,
4844
const at::sparse_csr::SparseCsrTensor& result);
4945

50-
} // namespace cuda
51-
} // namespace impl
52-
} // namespace sparse
53-
} // namespace native
54-
} // namespace at
46+
} // namespace at::native::sparse::impl::cuda

aten/src/ATen/native/sparse/cuda/SparseBlasLegacy.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ This file will be removed eventually.
99
#include <ATen/native/sparse/cuda/SparseBlasLegacy.h>
1010
#include <ATen/native/sparse/cuda/SparseCUDABlas.h>
1111

12-
namespace at {
13-
namespace native {
12+
namespace at::native {
1413

1514
void s_addmm_out_csr_sparse_dense_cuda_worker(int64_t nnz, int64_t m, int64_t n, int64_t k, const Tensor& r_, const Scalar& beta, const Tensor& t, const Scalar& alpha, const Tensor& crow_indices, const Tensor& col_indices, const Tensor& values, const Tensor& dense) {
1615
TORCH_INTERNAL_ASSERT(nnz > 0);
@@ -71,5 +70,4 @@ void s_addmm_out_csr_sparse_dense_cuda_worker(int64_t nnz, int64_t m, int64_t n,
7170
);
7271
}
7372

74-
} // namespace native
75-
} // namespace at
73+
} // namespace at::native

aten/src/ATen/native/sparse/cuda/SparseBlasLegacy.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ Here only 32-bit indices sparse indices are supported.
99
This file will be removed eventually.
1010
*/
1111

12-
namespace at {
13-
namespace native {
12+
namespace at::native {
1413

1514
void s_addmm_out_csr_sparse_dense_cuda_worker(int64_t nnz, int64_t m, int64_t n, int64_t k, const Tensor& r_, const Scalar& beta, const Tensor& t, const Scalar& alpha, const Tensor& crow_indices, const Tensor& col_indices, const Tensor& values, const Tensor& dense);
1615

17-
} // namespace native
18-
} // namespace at
16+
} // namespace at::native

aten/src/ATen/native/sparse/cuda/SparseCUDAApplyUtils.cuh

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
#include <ATen/native/cuda/thread_constants.h>
66
#include <c10/macros/Macros.h>
77

8-
namespace at { namespace native {
9-
10-
namespace apply {
8+
namespace at::native::apply {
119

1210
using at::cuda::detail::TensorInfo;
1311
using indexT = int64_t;
@@ -290,6 +288,4 @@ __global__ void coalesceValuesKernel(
290288
}
291289
}
292290

293-
} // namespace apply
294-
295-
}} // namespace at::native
291+
} // namespace at::native::apply

aten/src/ATen/native/sparse/cuda/SparseCUDABlas.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const char* cusparseGetErrorString(cusparseStatus_t status) {
6969
}
7070
#endif
7171

72-
namespace at { namespace native { namespace sparse { namespace cuda {
72+
namespace at::native::sparse::cuda {
7373

7474
void Xcoo2csr(const int *coorowind, int64_t nnz, int64_t m, int *csrrowptr) {
7575
TORCH_CHECK((m <= INT_MAX) && (nnz <= INT_MAX),
@@ -524,4 +524,4 @@ void XcoosortByRow(int64_t m, int64_t n, int64_t nnz, int *cooRows, int *cooCols
524524
}
525525

526526

527-
}}}} // namespace at::native::sparse::cuda
527+
} // namespace at::native::sparse::cuda

aten/src/ATen/native/sparse/cuda/SparseCUDABlas.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <ATen/cuda/ATenCUDAGeneral.h>
44

5-
namespace at { namespace native { namespace sparse { namespace cuda {
5+
namespace at::native::sparse::cuda{
66

77
TORCH_CUDA_CU_API void Xcoo2csr(
88
const int* coorowind,
@@ -61,4 +61,4 @@ TORCH_CUDA_CU_API void XcoosortByRow(
6161
int* cooCols,
6262
int* P,
6363
void* pBuffer);
64-
}}}} // namespace at::native::sparse::cuda
64+
} // namespace at::native::sparse::cuda

aten/src/ATen/native/sparse/cuda/SparseCUDATensor.cu

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include <thrust/binary_search.h>
3737
#include <c10/macros/Macros.h>
3838

39-
namespace at { namespace native {
39+
namespace at::native {
4040

4141
using namespace at::sparse;
4242

@@ -166,4 +166,4 @@ SparseTensor _coalesce_sparse_cuda(const SparseTensor& self) {
166166
return dst;
167167
}
168168

169-
}} // namespace at::native
169+
} // namespace at::native

aten/src/ATen/native/sparse/cuda/SparseCUDATensorMath.cu

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#define I_INFO(tensor) cuda::detail::getTensorInfo<int64_t, uint64_t>(tensor)
5252
#define V_INFO(tensor) cuda::detail::getTensorInfo<scalar_t, uint64_t>(tensor)
5353

54-
namespace at { namespace native {
54+
namespace at::native {
5555

5656
using namespace at::sparse;
5757
using at::cuda::detail::TensorInfo;
@@ -961,4 +961,4 @@ Tensor& bmm_out_sparse_cuda(const SparseTensor& self, const Tensor& mat2, Tensor
961961
return result;
962962
}
963963

964-
}} // namespace at::native
964+
} // namespace at::native

aten/src/ATen/native/sparse/cuda/SparseCUDATensorMath.cuh

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ namespace c10 {
1010
class Scalar;
1111
}
1212

13-
namespace at { namespace native {
13+
namespace at::native {
1414

1515
void s_addmm_out_sparse_dense_cuda_worker(int64_t nnz, int64_t m, int64_t n, int64_t k, Tensor& r_, const Scalar& beta, const Tensor& t, const Scalar& alpha, Tensor& indices, Tensor& values, const Tensor& dense);
1616

17-
}} // namespace at::native
17+
} // namespace at::native

aten/src/ATen/native/sparse/cuda/SparseCsrTensorMath.cu

+2-4
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@
4545
#include <thrust/for_each.h>
4646
#include <thrust/sequence.h>
4747

48-
namespace at {
49-
namespace native {
48+
namespace at::native {
5049

5150
namespace {
5251

@@ -737,5 +736,4 @@ Tensor _sparse_csr_prod_cuda(const Tensor& input, IntArrayRef dims_to_reduce, bo
737736
return result;
738737
}
739738

740-
} // namespace native
741-
} // namespace at
739+
} // namespace at::native

aten/src/ATen/native/sparse/cuda/SparseMatMul.cu

+2-4
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050
#include <library_types.h>
5151
#endif
5252

53-
namespace at {
54-
namespace native {
53+
namespace at::native {
5554

5655
namespace {
5756

@@ -811,5 +810,4 @@ Tensor sparse_sparse_matmul_cuda(const Tensor& mat1_, const Tensor& mat2_) {
811810
return output;
812811
}
813812

814-
} // namespace native
815-
} // namespace at
813+
} // namespace at::native

0 commit comments

Comments
 (0)