From b3d7001561e7cf846a131df63463074c0a900bee Mon Sep 17 00:00:00 2001 From: David Mak Date: Fri, 20 Dec 2024 13:19:40 +0800 Subject: [PATCH] [core] irrt: Minor cleanup --- nac3core/irrt/irrt/ndarray.hpp | 2 +- nac3core/irrt/irrt/ndarray/basic.hpp | 6 ++---- nac3core/irrt/irrt/ndarray/indexing.hpp | 9 ++++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/nac3core/irrt/irrt/ndarray.hpp b/nac3core/irrt/irrt/ndarray.hpp index 9d305aa4..72ca0b9e 100644 --- a/nac3core/irrt/irrt/ndarray.hpp +++ b/nac3core/irrt/irrt/ndarray.hpp @@ -148,4 +148,4 @@ void __nac3_ndarray_calc_broadcast_idx64(const uint64_t* src_dims, NDIndexInt* out_idx) { __nac3_ndarray_calc_broadcast_idx_impl(src_dims, src_ndims, in_idx, out_idx); } -} // namespace \ No newline at end of file +} \ No newline at end of file diff --git a/nac3core/irrt/irrt/ndarray/basic.hpp b/nac3core/irrt/irrt/ndarray/basic.hpp index 05ee30fc..62c92ae2 100644 --- a/nac3core/irrt/irrt/ndarray/basic.hpp +++ b/nac3core/irrt/irrt/ndarray/basic.hpp @@ -6,8 +6,7 @@ #include "irrt/ndarray/def.hpp" namespace { -namespace ndarray { -namespace basic { +namespace ndarray::basic { /** * @brief Assert that `shape` does not contain negative dimensions. * @@ -247,8 +246,7 @@ void copy_data(const NDArray* src_ndarray, NDArray* dst_ndarray) { ndarray::basic::set_pelement_value(dst_ndarray, dst_element, src_element); } } -} // namespace basic -} // namespace ndarray +} // namespace ndarray::basic } // namespace extern "C" { diff --git a/nac3core/irrt/irrt/ndarray/indexing.hpp b/nac3core/irrt/irrt/ndarray/indexing.hpp index 9e9e7b6e..76e78473 100644 --- a/nac3core/irrt/irrt/ndarray/indexing.hpp +++ b/nac3core/irrt/irrt/ndarray/indexing.hpp @@ -65,8 +65,7 @@ struct NDIndex { } // namespace namespace { -namespace ndarray { -namespace indexing { +namespace ndarray::indexing { /** * @brief Perform ndarray "basic indexing" (https://numpy.org/doc/stable/user/basics.indexing.html#basic-indexing) * @@ -162,7 +161,8 @@ void index(SizeT num_indices, const NDIndex* indices, const NDArray* src_ Range range = slice->indices_checked(src_ndarray->shape[src_axis]); - dst_ndarray->data = static_cast(dst_ndarray->data) + (SizeT)range.start * src_ndarray->strides[src_axis]; + dst_ndarray->data = + static_cast(dst_ndarray->data) + (SizeT)range.start * src_ndarray->strides[src_axis]; dst_ndarray->strides[dst_axis] = ((SizeT)range.step) * src_ndarray->strides[src_axis]; dst_ndarray->shape[dst_axis] = (SizeT)range.len(); @@ -197,8 +197,7 @@ void index(SizeT num_indices, const NDIndex* indices, const NDArray* src_ debug_assert_eq(SizeT, src_ndarray->ndims, src_axis); debug_assert_eq(SizeT, dst_ndarray->ndims, dst_axis); } -} // namespace indexing -} // namespace ndarray +} // namespace ndarray::indexing } // namespace extern "C" {