Skip to content

Commit ecd4991

Browse files
authored
Clean up dpctl.tensor code (#2797)
This PR adds a small clean up to already porting dpctl.tensor code: * remove unused includes * add missing includes * remove redundant namespace qualifications when calling function from the same namespace
1 parent 192bd93 commit ecd4991

18 files changed

+59
-81
lines changed

dpctl_ext/tensor/libtensor/include/kernels/constructors.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
//===----------------------------------------------------------------------===//
3434

3535
#pragma once
36+
3637
#include <array>
37-
#include <complex>
3838
#include <cstddef>
3939
#include <vector>
4040

dpctl_ext/tensor/libtensor/include/kernels/elementwise_functions/common.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,8 @@
3333
#pragma once
3434

3535
#include <algorithm>
36-
#include <cmath>
37-
#include <complex>
3836
#include <cstddef>
3937
#include <cstdint>
40-
#include <limits>
4138
#include <type_traits>
4239
#include <vector>
4340

dpctl_ext/tensor/libtensor/include/kernels/elementwise_functions/logaddexp.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
#include "vec_size_util.hpp"
4747

4848
#include "utils/math_utils.hpp"
49-
#include "utils/offset_utils.hpp"
5049
#include "utils/type_dispatch_building.hpp"
5150
#include "utils/type_utils.hpp"
5251

dpctl_ext/tensor/libtensor/include/kernels/elementwise_functions/maximum.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
#include "vec_size_util.hpp"
4646

4747
#include "utils/math_utils.hpp"
48-
#include "utils/offset_utils.hpp"
4948
#include "utils/type_dispatch_building.hpp"
5049
#include "utils/type_utils.hpp"
5150

dpctl_ext/tensor/libtensor/include/kernels/elementwise_functions/minimum.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include "vec_size_util.hpp"
4545

4646
#include "utils/math_utils.hpp"
47-
#include "utils/offset_utils.hpp"
4847
#include "utils/type_dispatch_building.hpp"
4948
#include "utils/type_utils.hpp"
5049

dpctl_ext/tensor/libtensor/include/kernels/integer_advanced_indexing.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
//===----------------------------------------------------------------------===//
3434

3535
#pragma once
36-
#include <complex>
36+
3737
#include <cstddef>
3838
#include <type_traits>
3939
#include <vector>

dpctl_ext/tensor/libtensor/source/accumulators.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,18 @@
3232
/// This file defines functions of dpctl.tensor._tensor_impl extensions
3333
//===----------------------------------------------------------------------===//
3434

35-
#include <algorithm>
3635
#include <cstddef>
3736
#include <cstdint>
3837
#include <stdexcept>
38+
#include <string>
39+
#include <tuple>
40+
#include <utility>
3941
#include <vector>
4042

4143
#include <sycl/sycl.hpp>
4244

4345
#include "dpnp4pybind11.hpp"
4446
#include <pybind11/pybind11.h>
45-
#include <pybind11/stl.h>
4647

4748
#include "kernels/accumulators.hpp"
4849
#include "simplify_iteration_space.hpp"
@@ -196,8 +197,8 @@ std::size_t py_mask_positions(const dpctl::tensor::usm_ndarray &mask,
196197
int mask_nd = mask.get_ndim();
197198
int nd = mask_nd;
198199

199-
dpctl::tensor::py_internal::compact_iteration_space(
200-
nd, shape, strides_vector, compact_shape, compact_strides);
200+
compact_iteration_space(nd, shape, strides_vector, compact_shape,
201+
compact_strides);
201202

202203
// Strided implementation
203204
auto strided_fn =
@@ -351,8 +352,8 @@ std::size_t py_cumsum_1d(const dpctl::tensor::usm_ndarray &src,
351352
int src_nd = src.get_ndim();
352353
int nd = src_nd;
353354

354-
dpctl::tensor::py_internal::compact_iteration_space(
355-
nd, shape, strides_vector, compact_shape, compact_strides);
355+
compact_iteration_space(nd, shape, strides_vector, compact_shape,
356+
compact_strides);
356357

357358
// Strided implementation
358359
auto strided_fn = cumsum_1d_strided_dispatch_vector[src_typeid];

dpctl_ext/tensor/libtensor/source/accumulators.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include <sycl/sycl.hpp>
4040

4141
#include "dpnp4pybind11.hpp"
42-
#include <pybind11/pybind11.h>
4342

4443
namespace dpctl::tensor::py_internal
4544
{

dpctl_ext/tensor/libtensor/source/boolean_advanced_indexing.cpp

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -336,21 +336,19 @@ std::pair<sycl::event, sycl::event>
336336
shT masked_src_shape;
337337
shT ortho_src_strides;
338338
shT masked_src_strides;
339-
dpctl::tensor::py_internal::split_iteration_space(
340-
src_shape_vec, src_strides_vec, axis_start, axis_end,
341-
ortho_src_shape,
342-
masked_src_shape, // 4 vectors modified
343-
ortho_src_strides, masked_src_strides);
339+
split_iteration_space(src_shape_vec, src_strides_vec, axis_start,
340+
axis_end, ortho_src_shape,
341+
masked_src_shape, // 4 vectors modified
342+
ortho_src_strides, masked_src_strides);
344343

345344
shT ortho_dst_shape;
346345
shT masked_dst_shape;
347346
shT ortho_dst_strides;
348347
shT masked_dst_strides;
349-
dpctl::tensor::py_internal::split_iteration_space(
350-
dst_shape_vec, dst_strides_vec, axis_start, axis_start + 1,
351-
ortho_dst_shape,
352-
masked_dst_shape, // 4 vectors modified
353-
ortho_dst_strides, masked_dst_strides);
348+
split_iteration_space(dst_shape_vec, dst_strides_vec, axis_start,
349+
axis_start + 1, ortho_dst_shape,
350+
masked_dst_shape, // 4 vectors modified
351+
ortho_dst_strides, masked_dst_strides);
354352

355353
assert(ortho_src_shape.size() == static_cast<std::size_t>(ortho_nd));
356354
assert(ortho_dst_shape.size() == static_cast<std::size_t>(ortho_nd));
@@ -366,7 +364,7 @@ std::pair<sycl::event, sycl::event>
366364
py::ssize_t ortho_src_offset(0);
367365
py::ssize_t ortho_dst_offset(0);
368366

369-
dpctl::tensor::py_internal::simplify_iteration_space(
367+
simplify_iteration_space(
370368
ortho_nd, _shape, ortho_src_strides, ortho_dst_strides,
371369
// output
372370
simplified_ortho_shape, simplified_ortho_src_strides,
@@ -646,21 +644,19 @@ std::pair<sycl::event, sycl::event>
646644
shT masked_dst_shape;
647645
shT ortho_dst_strides;
648646
shT masked_dst_strides;
649-
dpctl::tensor::py_internal::split_iteration_space(
650-
dst_shape_vec, dst_strides_vec, axis_start, axis_end,
651-
ortho_dst_shape,
652-
masked_dst_shape, // 4 vectors modified
653-
ortho_dst_strides, masked_dst_strides);
647+
split_iteration_space(dst_shape_vec, dst_strides_vec, axis_start,
648+
axis_end, ortho_dst_shape,
649+
masked_dst_shape, // 4 vectors modified
650+
ortho_dst_strides, masked_dst_strides);
654651

655652
shT ortho_rhs_shape;
656653
shT masked_rhs_shape;
657654
shT ortho_rhs_strides;
658655
shT masked_rhs_strides;
659-
dpctl::tensor::py_internal::split_iteration_space(
660-
rhs_shape_vec, rhs_strides_vec, axis_start, axis_start + 1,
661-
ortho_rhs_shape,
662-
masked_rhs_shape, // 4 vectors modified
663-
ortho_rhs_strides, masked_rhs_strides);
656+
split_iteration_space(rhs_shape_vec, rhs_strides_vec, axis_start,
657+
axis_start + 1, ortho_rhs_shape,
658+
masked_rhs_shape, // 4 vectors modified
659+
ortho_rhs_strides, masked_rhs_strides);
664660

665661
assert(ortho_dst_shape.size() == static_cast<std::size_t>(ortho_nd));
666662
assert(ortho_rhs_shape.size() == static_cast<std::size_t>(ortho_nd));
@@ -676,7 +672,7 @@ std::pair<sycl::event, sycl::event>
676672
py::ssize_t ortho_dst_offset(0);
677673
py::ssize_t ortho_rhs_offset(0);
678674

679-
dpctl::tensor::py_internal::simplify_iteration_space(
675+
simplify_iteration_space(
680676
ortho_nd, _shape, ortho_dst_strides, ortho_rhs_strides,
681677
simplified_ortho_shape, simplified_ortho_dst_strides,
682678
simplified_ortho_rhs_strides, ortho_dst_offset, ortho_rhs_offset);

dpctl_ext/tensor/libtensor/source/copy_and_cast_usm_to_usm.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,10 @@ std::pair<sycl::event, sycl::event> copy_usm_ndarray_into_usm_ndarray(
188188
const py::ssize_t *shape = src_shape;
189189

190190
// nd, simplified_* and *_offset are modified by reference
191-
dpctl::tensor::py_internal::simplify_iteration_space(
192-
nd, shape, src_strides, dst_strides,
193-
// output
194-
simplified_shape, simplified_src_strides, simplified_dst_strides,
195-
src_offset, dst_offset);
191+
simplify_iteration_space(nd, shape, src_strides, dst_strides,
192+
// output
193+
simplified_shape, simplified_src_strides,
194+
simplified_dst_strides, src_offset, dst_offset);
196195

197196
if (nd < 2) {
198197
if (nd == 1) {

0 commit comments

Comments
 (0)