[core] irrt: Minor cleanup

This commit is contained in:
David Mak 2024-12-20 13:19:40 +08:00
parent f62babbace
commit b3d7001561
3 changed files with 7 additions and 10 deletions

View File

@ -148,4 +148,4 @@ void __nac3_ndarray_calc_broadcast_idx64(const uint64_t* src_dims,
NDIndexInt* out_idx) { NDIndexInt* out_idx) {
__nac3_ndarray_calc_broadcast_idx_impl(src_dims, src_ndims, in_idx, out_idx); __nac3_ndarray_calc_broadcast_idx_impl(src_dims, src_ndims, in_idx, out_idx);
} }
} // namespace }

View File

@ -6,8 +6,7 @@
#include "irrt/ndarray/def.hpp" #include "irrt/ndarray/def.hpp"
namespace { namespace {
namespace ndarray { namespace ndarray::basic {
namespace basic {
/** /**
* @brief Assert that `shape` does not contain negative dimensions. * @brief Assert that `shape` does not contain negative dimensions.
* *
@ -247,8 +246,7 @@ void copy_data(const NDArray<SizeT>* src_ndarray, NDArray<SizeT>* dst_ndarray) {
ndarray::basic::set_pelement_value(dst_ndarray, dst_element, src_element); ndarray::basic::set_pelement_value(dst_ndarray, dst_element, src_element);
} }
} }
} // namespace basic } // namespace ndarray::basic
} // namespace ndarray
} // namespace } // namespace
extern "C" { extern "C" {

View File

@ -65,8 +65,7 @@ struct NDIndex {
} // namespace } // namespace
namespace { namespace {
namespace ndarray { namespace ndarray::indexing {
namespace indexing {
/** /**
* @brief Perform ndarray "basic indexing" (https://numpy.org/doc/stable/user/basics.indexing.html#basic-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<SizeT>* src_
Range<int32_t> range = slice->indices_checked<SizeT>(src_ndarray->shape[src_axis]); Range<int32_t> range = slice->indices_checked<SizeT>(src_ndarray->shape[src_axis]);
dst_ndarray->data = static_cast<uint8_t*>(dst_ndarray->data) + (SizeT)range.start * src_ndarray->strides[src_axis]; dst_ndarray->data =
static_cast<uint8_t*>(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->strides[dst_axis] = ((SizeT)range.step) * src_ndarray->strides[src_axis];
dst_ndarray->shape[dst_axis] = (SizeT)range.len<SizeT>(); dst_ndarray->shape[dst_axis] = (SizeT)range.len<SizeT>();
@ -197,8 +197,7 @@ void index(SizeT num_indices, const NDIndex* indices, const NDArray<SizeT>* src_
debug_assert_eq(SizeT, src_ndarray->ndims, src_axis); debug_assert_eq(SizeT, src_ndarray->ndims, src_axis);
debug_assert_eq(SizeT, dst_ndarray->ndims, dst_axis); debug_assert_eq(SizeT, dst_ndarray->ndims, dst_axis);
} }
} // namespace indexing } // namespace ndarray::indexing
} // namespace ndarray
} // namespace } // namespace
extern "C" { extern "C" {