// File: binding.cpp
#include "pooling_contract.h"
#include "mat.h"
#include "option.h"

namespace {
constexpr int kernel_h = 3;
constexpr int kernel_w = 3;
constexpr int stride_h = 1;
constexpr int stride_w = 1;
constexpr int pad_top  = 1;
constexpr int pad_left = 1;
} // namespace

extern "C" {
int armbench_entry_pooling(
    void* bottom_v, void* top_v,
    void* opt_v)
{
    const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);
    auto&       top    = *reinterpret_cast<ncnn::Mat*>(top_v);
    const auto& opt    = *reinterpret_cast<const ncnn::Option*>(opt_v);

    const int C     = bottom.c;
    const int H_out = (bottom.h + 2 * pad_top  - kernel_h) / stride_h + 1;
    const int W_out = (bottom.w + 2 * pad_left - kernel_w) / stride_w + 1;

    top.create(W_out, H_out, C, (size_t)4u, opt.blob_allocator);
    if (top.empty()) return -1;

    return ncnn::pooling_kernel(
        bottom, top,
        kernel_h, kernel_w,
        stride_h, stride_w,
        pad_top, pad_left,
        opt);
}
} // extern "C"