dnn:rvv: rename pooling HAL hooks to *pool3d and correct the NCDHWc layout comment

This commit is contained in:
velonica0
2026-07-28 19:00:22 -07:00
parent 55fdef8581
commit b907960e0b
5 changed files with 21 additions and 21 deletions

View File

@@ -9,7 +9,7 @@ namespace cv { namespace rvv_hal { namespace dnn {
#if CV_HAL_RVV_1P0_ENABLED
// Blocked NCHWc pooling, CV_32F. The geometry crosses the boundary as a flat, stable
// Blocked NCDHWc pooling, CV_32F. The geometry crosses the boundary as a flat, stable
// C argument list (no dnn types): C0 channel block; insize/outsize = the [3] input/output
// spatial dims in a fixed Z,Y,X frame (unused leading dims = 1); strides[3]; pads[6]
// (begin[0..2]+end[3..5]); inner[6] = the padding-free interior bounds; coordtab[ksize*3]
@@ -17,26 +17,26 @@ namespace cv { namespace rvv_hal { namespace dnn {
// Each hook computes only the block-plane range [task_start, task_end) (N*C1 planes);
// OpenCV owns the parallel_for_ and never expects the HAL to spawn threads.
/* ############ maxpool32f ############ */
/* ############ maxpool3d32f ############ */
int maxpool32f(const float* inp_data, float* out_data, int C0,
int maxpool3d32f(const float* inp_data, float* out_data, int C0,
const int* insize, const int* outsize, const int* strides,
const int* pads, const int* inner, const int* coordtab,
const int* ofstab, int ksize, int task_start, int task_end);
#undef cv_hal_dnn_maxpool32f
#define cv_hal_dnn_maxpool32f cv::rvv_hal::dnn::maxpool32f
#undef cv_hal_dnn_maxpool3d32f
#define cv_hal_dnn_maxpool3d32f cv::rvv_hal::dnn::maxpool3d32f
/* ############ avgpool32f ############ */
/* ############ avgpool3d32f ############ */
int avgpool32f(const float* inp_data, float* out_data, int C0,
int avgpool3d32f(const float* inp_data, float* out_data, int C0,
const int* insize, const int* outsize, const int* strides,
const int* pads, const int* inner, const int* coordtab,
const int* ofstab, int ksize, int count_include_pad,
int task_start, int task_end);
#undef cv_hal_dnn_avgpool32f
#define cv_hal_dnn_avgpool32f cv::rvv_hal::dnn::avgpool32f
#undef cv_hal_dnn_avgpool3d32f
#define cv_hal_dnn_avgpool3d32f cv::rvv_hal::dnn::avgpool3d32f
#endif // CV_HAL_RVV_1P0_ENABLED

View File

@@ -12,7 +12,7 @@ namespace cv { namespace rvv_hal { namespace dnn {
#if CV_HAL_RVV_1P0_ENABLED
// Blocked NCHWc pooling, RVV, CV_32F. Mirrors the built-in maxPool32f/avgPool32f
// Blocked NCDHWc pooling, RVV, CV_32F. Mirrors the built-in maxPool32f/avgPool32f
// semantics (modules/dnn/src/layers/{max,avg}pool_layer.cpp) but computes only the
// block-plane range [task_start, task_end).
//
@@ -29,7 +29,7 @@ namespace cv { namespace rvv_hal { namespace dnn {
// * stride-x > 1: pixels' tap data are strided; we fall back to processing C0
// channels per vector, register-blocked 4 output columns at a time for ILP.
int maxpool32f(const float* inp_data, float* out_data, int C0,
int maxpool3d32f(const float* inp_data, float* out_data, int C0,
const int* insize, const int* outsize, const int* strides,
const int* pads, const int* inner, const int* coordtab,
const int* ofstab, int ksize, int task_start, int task_end)
@@ -148,7 +148,7 @@ int maxpool32f(const float* inp_data, float* out_data, int C0,
return CV_HAL_ERROR_OK;
}
int avgpool32f(const float* inp_data, float* out_data, int C0,
int avgpool3d32f(const float* inp_data, float* out_data, int C0,
const int* insize, const int* outsize, const int* strides,
const int* pads, const int* inner, const int* coordtab,
const int* ofstab, int ksize, int count_include_pad,

View File

@@ -28,7 +28,7 @@
//! the default @c hal_ni_* below returns @c CV_HAL_ERROR_NOT_IMPLEMENTED, so the
//! built-in implementation runs unchanged when no backend is present.
//!
//! Tensors use the engine's blocked NCHWc layout described by @ref cv::dnn::ConvState:
//! Tensors use the engine's blocked NCDHWc layout described by @ref cv::dnn::ConvState:
//! @c N * C1 channel-blocks of @c C0 channels each, laid out as [N, C1, ...spatial..., C0].
//!
//! **Parallelism is owned by OpenCV, not by the HAL.** Each hook receives a task
@@ -42,16 +42,16 @@
// (begin[0..2] + end[3..5]); @c inner [6] = the padding-free interior bounds; @c coordtab
// [ksize*3] = per-tap (dz,dy,dx); @c ofstab [ksize] = per-tap flat input offset (interior).
/** @brief Max pooling over a slice [task_start, task_end) of the output (blocked NCHWc, CV_32F). */
inline int hal_ni_dnn_maxpool32f(const float* inp_data, float* out_data, int C0,
/** @brief Max pooling over a slice [task_start, task_end) of the output (blocked NCDHWc, CV_32F). */
inline int hal_ni_dnn_maxpool3d32f(const float* inp_data, float* out_data, int C0,
const int* insize, const int* outsize, const int* strides,
const int* pads, const int* inner, const int* coordtab,
const int* ofstab, int ksize, int task_start, int task_end)
{ return CV_HAL_ERROR_NOT_IMPLEMENTED; }
/** @brief Average pooling over a slice [task_start, task_end) of the output (blocked NCHWc, CV_32F).
/** @brief Average pooling over a slice [task_start, task_end) of the output (blocked NCDHWc, CV_32F).
@param count_include_pad nonzero to divide by the full kernel size (count padded cells) */
inline int hal_ni_dnn_avgpool32f(const float* inp_data, float* out_data, int C0,
inline int hal_ni_dnn_avgpool3d32f(const float* inp_data, float* out_data, int C0,
const int* insize, const int* outsize, const int* strides,
const int* pads, const int* inner, const int* coordtab,
const int* ofstab, int ksize, int count_include_pad,
@@ -59,8 +59,8 @@ inline int hal_ni_dnn_avgpool32f(const float* inp_data, float* out_data, int C0,
{ return CV_HAL_ERROR_NOT_IMPLEMENTED; }
//! @cond IGNORED
#define cv_hal_dnn_maxpool32f hal_ni_dnn_maxpool32f
#define cv_hal_dnn_avgpool32f hal_ni_dnn_avgpool32f
#define cv_hal_dnn_maxpool3d32f hal_ni_dnn_maxpool3d32f
#define cv_hal_dnn_avgpool3d32f hal_ni_dnn_avgpool3d32f
//! @endcond
//! @}

View File

@@ -31,7 +31,7 @@ static void avgPool32f(const void* inp_, void* out_,
int sd = cs.nspatialdims;
int insize[3] = { sd > 2 ? cs.inpshape[sd-1] : 1, sd > 1 ? cs.inpshape[sd] : 1, cs.inpshape[sd+1] };
int outsize[3] = { sd > 2 ? cs.outshape[sd-1] : 1, sd > 1 ? cs.outshape[sd] : 1, cs.outshape[sd+1] };
CALL_HAL(dnn_avgpool32f, cv_hal_dnn_avgpool32f,
CALL_HAL(dnn_avgpool3d32f, cv_hal_dnn_avgpool3d32f,
(const float*)inp_, (float*)out_, cs.inpshape.back(),
insize, outsize, cs.strides, cs.pads, cs.inner,
cs.coordtab.data(), cs.ofstab.data(), (int)cs.ofstab.size(),

View File

@@ -34,7 +34,7 @@ static void maxPool32f(const void* inp_, void* out_, const ConvState& cs)
int sd = cs.nspatialdims;
int insize[3] = { sd > 2 ? cs.inpshape[sd-1] : 1, sd > 1 ? cs.inpshape[sd] : 1, cs.inpshape[sd+1] };
int outsize[3] = { sd > 2 ? cs.outshape[sd-1] : 1, sd > 1 ? cs.outshape[sd] : 1, cs.outshape[sd+1] };
CALL_HAL(dnn_maxpool32f, cv_hal_dnn_maxpool32f,
CALL_HAL(dnn_maxpool3d32f, cv_hal_dnn_maxpool3d32f,
(const float*)inp_, (float*)out_, cs.inpshape.back(),
insize, outsize, cs.strides, cs.pads, cs.inner,
cs.coordtab.data(), cs.ofstab.data(), (int)cs.ofstab.size(),