Update bench-trace: sync definitions, solutions, workloads, traces

#1
This view is limited to 50 files because it contains too many changes. See the raw diff here.
Files changed (50) hide show
  1. solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh1_sw1_cin128_cout256.json +2 -2
  2. solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh1_sw1_cin256_cout512.json +2 -2
  3. solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh1_sw1_cin512_cout1024.json +2 -2
  4. solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh1_sw1_cin64_cout128.json +2 -2
  5. solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh2_sw2_cin128_cout256.json +2 -2
  6. solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh2_sw2_cin256_cout512.json +2 -2
  7. solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh2_sw2_cin512_cout1024.json +2 -2
  8. solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh2_sw2_cin64_cout128.json +2 -2
  9. solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh1_sw1_cin128_cout256.json +2 -2
  10. solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh1_sw1_cin256_cout512.json +2 -2
  11. solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh1_sw1_cin512_cout1024.json +2 -2
  12. solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh1_sw1_cin64_cout128.json +2 -2
  13. solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh2_sw2_cin128_cout256.json +2 -2
  14. solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh2_sw2_cin32_cout64.json +2 -2
  15. solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh2_sw2_cin512_cout512.json +2 -2
  16. solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh2_sw2_cin64_cout128.json +2 -2
  17. solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2_c1024.json +2 -2
  18. solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2_c128.json +2 -2
  19. solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2_c256.json +2 -2
  20. solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2_c32.json +2 -2
  21. solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2_c512.json +2 -2
  22. solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2_c64.json +2 -2
  23. solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh3_kw3_sh1_sw1_c128.json +2 -2
  24. solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh3_kw3_sh1_sw1_c2048.json +2 -2
  25. solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh3_kw3_sh1_sw1_c32.json +2 -2
  26. solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh3_kw3_sh1_sw1_c512.json +2 -2
  27. solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh3_kw3_sh1_sw1_c64.json +2 -2
  28. solutions/ncnn/reference-scalar/conv1d/conv1d_kw1_sw1_dw1_p0_cin1024_cout1024.json +36 -0
  29. solutions/ncnn/reference-scalar/conv1d/conv1d_kw1_sw1_dw1_p0_cin128_cout512.json +36 -0
  30. solutions/ncnn/reference-scalar/conv1d/conv1d_kw1_sw1_dw1_p0_cin256_cout1024.json +36 -0
  31. solutions/ncnn/reference-scalar/conv1d/conv1d_kw1_sw1_dw1_p0_cin512_cout2048.json +36 -0
  32. solutions/ncnn/reference-scalar/conv1d/conv1d_kw1_sw1_dw1_p0_cin64_cout256.json +36 -0
  33. solutions/ncnn/reference-scalar/conv1d/conv1d_kw1_sw1_dw1_p0_cin64_cout64.json +36 -0
  34. solutions/ncnn/reference-scalar/conv1d/conv1d_kw3_sw1_dw1_p1_cin1024_cout1024.json +36 -0
  35. solutions/ncnn/reference-scalar/conv1d/conv1d_kw3_sw1_dw1_p1_cin128_cout256.json +36 -0
  36. solutions/ncnn/reference-scalar/conv1d/conv1d_kw3_sw1_dw1_p1_cin256_cout512.json +36 -0
  37. solutions/ncnn/reference-scalar/conv1d/conv1d_kw3_sw1_dw1_p1_cin3_cout64.json +36 -0
  38. solutions/ncnn/reference-scalar/conv1d/conv1d_kw3_sw1_dw1_p1_cin512_cout1024.json +36 -0
  39. solutions/ncnn/reference-scalar/conv1d/conv1d_kw3_sw1_dw1_p1_cin64_cout128.json +36 -0
  40. solutions/ncnn/reference-scalar/conv2d/conv2d_kh1_kw1_sh1_sw1_dh1_dw1_c1024_c1024.json +10 -2
  41. solutions/ncnn/reference-scalar/conv2d/conv2d_kh1_kw1_sh1_sw1_dh1_dw1_c128_c512.json +10 -2
  42. solutions/ncnn/reference-scalar/conv2d/conv2d_kh1_kw1_sh1_sw1_dh1_dw1_c256_c1024.json +10 -2
  43. solutions/ncnn/reference-scalar/conv2d/conv2d_kh1_kw1_sh1_sw1_dh1_dw1_c512_c2048.json +10 -2
  44. solutions/ncnn/reference-scalar/conv2d/conv2d_kh1_kw1_sh1_sw1_dh1_dw1_c64_c256.json +10 -2
  45. solutions/ncnn/reference-scalar/conv2d/conv2d_kh1_kw1_sh1_sw1_dh1_dw1_c64_c64.json +10 -2
  46. solutions/ncnn/reference-scalar/conv2d/conv2d_kh3_kw3_sh1_sw1_dh1_dw1_c128_c256.json +10 -2
  47. solutions/ncnn/reference-scalar/conv2d/conv2d_kh3_kw3_sh1_sw1_dh1_dw1_c256_c512.json +10 -2
  48. solutions/ncnn/reference-scalar/conv2d/conv2d_kh3_kw3_sh1_sw1_dh1_dw1_c3_c64.json +10 -2
  49. solutions/ncnn/reference-scalar/conv2d/conv2d_kh3_kw3_sh1_sw1_dh1_dw1_c512_c1024.json +10 -2
  50. solutions/ncnn/reference-scalar/conv2d/conv2d_kh3_kw3_sh1_sw1_dh1_dw1_c64_c128.json +10 -2
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh1_sw1_cin128_cout256.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int out_c = 256;\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int out_c = 256;\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh1_sw1_cin256_cout512.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int out_c = 512;\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int out_c = 512;\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh1_sw1_cin512_cout1024.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int out_c = 1024;\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int out_c = 1024;\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh1_sw1_cin64_cout128.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int out_c = 128;\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int out_c = 128;\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh2_sw2_cin128_cout256.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int out_c = 256;\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int out_c = 256;\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh2_sw2_cin256_cout512.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int out_c = 512;\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int out_c = 512;\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh2_sw2_cin512_cout1024.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int out_c = 1024;\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int out_c = 1024;\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh2_sw2_cin64_cout128.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int out_c = 128;\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int out_c = 128;\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh1_sw1_cin128_cout256.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int out_c = 256;\nconstexpr int kernel_w = 4;\nconstexpr int kernel_h = 4;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int out_c = 256;\nconstexpr int kernel_w = 4;\nconstexpr int kernel_h = 4;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh1_sw1_cin256_cout512.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int out_c = 512;\nconstexpr int kernel_w = 4;\nconstexpr int kernel_h = 4;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int out_c = 512;\nconstexpr int kernel_w = 4;\nconstexpr int kernel_h = 4;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh1_sw1_cin512_cout1024.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int out_c = 1024;\nconstexpr int kernel_w = 4;\nconstexpr int kernel_h = 4;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int out_c = 1024;\nconstexpr int kernel_w = 4;\nconstexpr int kernel_h = 4;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh1_sw1_cin64_cout128.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int out_c = 128;\nconstexpr int kernel_w = 4;\nconstexpr int kernel_h = 4;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int out_c = 128;\nconstexpr int kernel_w = 4;\nconstexpr int kernel_h = 4;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh2_sw2_cin128_cout256.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int out_c = 256;\nconstexpr int kernel_w = 4;\nconstexpr int kernel_h = 4;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int out_c = 256;\nconstexpr int kernel_w = 4;\nconstexpr int kernel_h = 4;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh2_sw2_cin32_cout64.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int out_c = 64;\nconstexpr int kernel_w = 4;\nconstexpr int kernel_h = 4;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int out_c = 64;\nconstexpr int kernel_w = 4;\nconstexpr int kernel_h = 4;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh2_sw2_cin512_cout512.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int out_c = 512;\nconstexpr int kernel_w = 4;\nconstexpr int kernel_h = 4;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int out_c = 512;\nconstexpr int kernel_w = 4;\nconstexpr int kernel_h = 4;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh2_sw2_cin64_cout128.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int out_c = 128;\nconstexpr int kernel_w = 4;\nconstexpr int kernel_h = 4;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d Solution;\n// identical across all deconv2d Definitions (const params arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d.h by delegating to\n// ncnn::Deconvolution_arm. The shim armbench_entry_deconv2d (binding.cpp)\n// allocates the full transposed-convolution output\n// (out_w = (in_w-1)*stride_w + dilation_w*(kernel_w-1)+1, likewise out_h) and\n// does NOT crop, so we disable Deconvolution_arm's internal cut_padding\n// (pad_* / output_pad_* / output_w/h all zero). Const params come from the\n// Definition's const axes, so this kernel.cpp is identical across all deconv2d\n// Definitions.\n\n#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolution_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n Deconvolution_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of\n // Deconvolution_arm's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d via ctypes with ONLY the Mat/Option pointers\n// (no scalar args). The body computes transposed-convolution output dims,\n// allocates the output Mat, then dispatches to the Solution's\n// deconvolution_kernel (defined in kernel.cpp).\n//\n// Output formula (from ref_conv.h::ref_deconv2d):\n// ke_h = dilation_h * (kernel_h - 1) + 1\n// ke_w = dilation_w * (kernel_w - 1) + 1\n// out_h = (in_h - 1) * stride_h + ke_h\n// out_w = (in_w - 1) * stride_w + ke_w\n\n#include \"deconv2d.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int out_c = 128;\nconstexpr int kernel_w = 4;\nconstexpr int kernel_h = 4;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (in_c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = out_c*in_c*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_deconv2d in ref_conv.h)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n\n // 2. Allocate top\n top.create(out_w, out_h, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to the Solution-supplied kernel\n return ncnn::deconvolution_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2_c1024.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d_depthwise \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int kernel_w = 2;\nconstexpr int kernel_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c; // depthwise: out_c == in_c\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d_depthwise shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int kernel_w = 2;\nconstexpr int kernel_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c * bottom.elempack; // depthwise: out_c == in_c; elempack>1 when pack4\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2_c128.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d_depthwise \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int kernel_w = 2;\nconstexpr int kernel_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c; // depthwise: out_c == in_c\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d_depthwise shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int kernel_w = 2;\nconstexpr int kernel_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c * bottom.elempack; // depthwise: out_c == in_c; elempack>1 when pack4\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2_c256.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d_depthwise \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int kernel_w = 2;\nconstexpr int kernel_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c; // depthwise: out_c == in_c\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d_depthwise shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int kernel_w = 2;\nconstexpr int kernel_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c * bottom.elempack; // depthwise: out_c == in_c; elempack>1 when pack4\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2_c32.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d_depthwise \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int kernel_w = 2;\nconstexpr int kernel_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c; // depthwise: out_c == in_c\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d_depthwise shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int kernel_w = 2;\nconstexpr int kernel_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c * bottom.elempack; // depthwise: out_c == in_c; elempack>1 when pack4\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2_c512.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d_depthwise \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int kernel_w = 2;\nconstexpr int kernel_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c; // depthwise: out_c == in_c\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d_depthwise shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int kernel_w = 2;\nconstexpr int kernel_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c * bottom.elempack; // depthwise: out_c == in_c; elempack>1 when pack4\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2_c64.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d_depthwise \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int kernel_w = 2;\nconstexpr int kernel_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c; // depthwise: out_c == in_c\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d_depthwise shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int kernel_w = 2;\nconstexpr int kernel_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c * bottom.elempack; // depthwise: out_c == in_c; elempack>1 when pack4\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh3_kw3_sh1_sw1_c128.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d_depthwise \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c; // depthwise: out_c == in_c\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d_depthwise shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c * bottom.elempack; // depthwise: out_c == in_c; elempack>1 when pack4\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh3_kw3_sh1_sw1_c2048.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d_depthwise \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c; // depthwise: out_c == in_c\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d_depthwise shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c * bottom.elempack; // depthwise: out_c == in_c; elempack>1 when pack4\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh3_kw3_sh1_sw1_c32.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d_depthwise \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c; // depthwise: out_c == in_c\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d_depthwise shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c * bottom.elempack; // depthwise: out_c == in_c; elempack>1 when pack4\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh3_kw3_sh1_sw1_c512.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d_depthwise \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c; // depthwise: out_c == in_c\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d_depthwise shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c * bottom.elempack; // depthwise: out_c == in_c; elempack>1 when pack4\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh3_kw3_sh1_sw1_c64.json CHANGED
@@ -29,7 +29,7 @@
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
- "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n int ret = deconv.forward(bottom_blob, local_top, opt);\n if (ret != 0) return ret;\n if (local_top.empty()) return -1;\n\n // Copy into the caller-allocated top_blob.\n if (local_top.c != top_blob.c || local_top.h != top_blob.h || local_top.w != top_blob.w)\n return -1;\n for (int cc = 0; cc < local_top.c; ++cc) {\n std::memcpy(top_blob.channel(cc), local_top.channel(cc),\n local_top.h * local_top.w * sizeof(float));\n }\n return 0;\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
@@ -37,7 +37,7 @@
37
  },
38
  {
39
  "path": "binding.cpp",
40
- "content": "// ncnn::Mat shim for deconv2d_depthwise \u2014 shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// \u2500\u2500 Per-Definition constants (baked from the Definition's const axes) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nnamespace {\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* \u2014 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* \u2014 empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* \u2014 flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* \u2014 empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c; // depthwise: out_c == in_c\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
 
29
  "sources": [
30
  {
31
  "path": "kernel.cpp",
32
+ "content": "// solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/<def_name>/kernel.cpp\n//\n// Embedded verbatim as kernel.cpp in every baseline-ncnn-arm deconv2d_depthwise\n// Solution; identical across all deconv2d_depthwise Definitions (const params\n// arrive as runtime args).\n//\n// Implements the harness contract declared in deconv2d_depthwise.h by\n// delegating to ncnn::DeconvolutionDepthWise_arm. The shim\n// armbench_entry_deconv2d_depthwise (binding.cpp) allocates the full\n// transposed-convolution output (out_c == in_c) and does NOT crop, so we\n// disable the layer's internal cut_padding. group == channels (depthwise).\n// Const params come from the Definition's const axes, so this kernel.cpp is\n// identical across all deconv2d_depthwise Definitions.\n\n#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n\n#include <cstring>\n\nnamespace ncnn {\n\nint deconvolutiondepthwise_kernel(const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int kernel_h,\n int stride_w, int stride_h,\n int dilation_w, int dilation_h,\n int group,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n DeconvolutionDepthWise_arm deconv;\n deconv.num_output = top_blob.c;\n deconv.kernel_w = kernel_w; deconv.kernel_h = kernel_h;\n deconv.stride_w = stride_w; deconv.stride_h = stride_h;\n deconv.dilation_w = dilation_w; deconv.dilation_h = dilation_h;\n // Harness allocated the full (un-cropped) output, so disable all of the\n // layer's output padding / cropping.\n deconv.pad_left = 0; deconv.pad_right = 0;\n deconv.pad_top = 0; deconv.pad_bottom = 0;\n deconv.output_pad_right = 0; deconv.output_pad_bottom = 0;\n deconv.output_w = 0; deconv.output_h = 0;\n deconv.bias_term = bias_data.empty() ? 0 : 1;\n deconv.weight_data_size = weight_data.w;\n deconv.group = group;\n deconv.activation_type = activation_type;\n deconv.activation_params = const_cast<Mat&>(activation_params);\n deconv.dynamic_weight = 0;\n deconv.weight_data = const_cast<Mat&>(weight_data);\n if (!bias_data.empty()) deconv.bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv.create_pipeline(opt) != 0) return -1;\n\n // forward() may produce pack4 output when use_packing_layout=true;\n // the Python harness unwraps pack4->pack1 in unwrap_output.\n return deconv.forward(bottom_blob, top_blob, opt);\n}\n\n} // namespace ncnn\n"
33
  },
34
  {
35
  "path": "deconv2d_depthwise.h",
 
37
  },
38
  {
39
  "path": "binding.cpp",
40
+ "content": "// ncnn::Mat shim for deconv2d_depthwise shipped in this Solution's own sources.\n//\n// All per-Definition scalar params are baked as constexpr below, so the runner\n// calls armbench_entry_deconv2d_depthwise via ctypes with ONLY the Mat/Option\n// pointers (no scalar args). The body computes transposed-convolution output\n// dims, allocates the output Mat, then dispatches to the Solution's\n// deconvolutiondepthwise_kernel (defined in kernel.cpp).\n//\n// Depthwise: in_c == out_c == channels; group == channels (derived from input).\n\n#include \"deconv2d_depthwise.h\"\n\n// ── Per-Definition constants (baked from the Definition's const axes) ────────\nnamespace {\nconstexpr int kernel_w = 3;\nconstexpr int kernel_h = 3;\nconstexpr int stride_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\n\nint armbench_entry_deconv2d_depthwise(\n // tensors (opaque ncnn::Mat*)\n void* bottom_mat_v, // const ncnn::Mat* 3D input (c, h, w)\n void* top_mat_v, // ncnn::Mat* empty Mat; we create() output here\n void* weight_mat_v, // const ncnn::Mat* flat 1D Mat, size = C*kh*kw\n void* bias_mat_v, // const ncnn::Mat* flat 1D Mat or empty\n void* activation_params_v, // const ncnn::Mat* empty for type=0/1\n void* opt_v) // const ncnn::Option*\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_mat_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_mat_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_mat_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_mat_v);\n const auto& act_par = *reinterpret_cast<const ncnn::Mat*>(activation_params_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n if (bottom.empty()) return -100;\n\n // 1. Compute transposed-convolution output dims (matches ref_depthwise_deconv2d)\n const int ke_h = dilation_h * (kernel_h - 1) + 1;\n const int ke_w = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bottom.w - 1) * stride_w + ke_w;\n const int out_h = (bottom.h - 1) * stride_h + ke_h;\n const int channels = bottom.c * bottom.elempack; // depthwise: out_c == in_c; elempack>1 when pack4\n\n // 2. Allocate top\n top.create(out_w, out_h, channels, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -100;\n\n // 3. Dispatch to Solution kernel with group == channels (depthwise)\n return ncnn::deconvolutiondepthwise_kernel(\n bottom, top, weight, bias,\n kernel_w, kernel_h,\n stride_w, stride_h,\n dilation_w, dilation_h,\n channels,\n activation_type, act_par,\n opt);\n}\n\n} // extern \"C\"\n"
41
  }
42
  ]
43
  }
solutions/ncnn/reference-scalar/conv1d/conv1d_kw1_sw1_dw1_p0_cin1024_cout1024.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "reference-scalar_conv1d_kw1_sw1_dw1_p0_cin1024_cout1024",
3
+ "definition": "conv1d_kw1_sw1_dw1_p0_cin1024_cout1024",
4
+ "dataset": "ncnn",
5
+ "author": "reference-scalar",
6
+ "description": "Scalar raw-float* conv1d for conv1d_kw1_sw1_dw1_p0_cin1024_cout1024. Constexpr-baked dims; armbench_entry_conv1d calls inner_conv1d. Ground-truth correctness baseline.",
7
+ "spec": {
8
+ "language": "cpp",
9
+ "target_hardware": [
10
+ "graviton3",
11
+ "aarch64-sve"
12
+ ],
13
+ "entry_point": "conv1d.cpp::armbench_entry_conv1d",
14
+ "dependencies": [],
15
+ "isa_features": [],
16
+ "compile_flags": [
17
+ "-O2",
18
+ "-std=c++14"
19
+ ],
20
+ "link_flags": []
21
+ },
22
+ "sources": [
23
+ {
24
+ "path": "conv1d.h",
25
+ "content": "#pragma once\n\n// Per-definition constants for this conv1d specialisation.\nnamespace conv1d_def {\nconstexpr int Cin = 1024;\nconstexpr int Cout = 1024;\nconstexpr int Kw = 1;\nconstexpr int Sw = 1;\nconstexpr int Dw = 1;\nconstexpr int pad = 0;\n} // namespace conv1d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// W and W_out are var dims; pre-computed by the binding harness.\n// Input layout: (Cin, W), output layout: (Cout, W_out).\nvoid inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv1d.cpp",
29
+ "content": "// Binding harness: computes W_out from constexpr params, calls inner_conv1d.\n// ABI: armbench_entry_conv1d(input*, output*, weight*, bias*, W)\n// Input layout: (Cin, W); output layout: (Cout, W_out).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" int armbench_entry_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W)\n{\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int W_out = (W + 2 * pad - ext_kw) / Sw + 1;\n inner_conv1d(input, output, weight, bias, W, W_out);\n return 0;\n}\n"
30
+ },
31
+ {
32
+ "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv1d.\n// LLM target: replace this file with an optimised inner_conv1d.\n// All per-definition constants live in conv1d_def:: (conv1d.h).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" void inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out)\n{\n for (int oc = 0; oc < Cout; ++oc) {\n float* out_c = output + (long)oc * W_out;\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias[oc];\n for (int ic = 0; ic < Cin; ++ic) {\n const float* in_c = input + (long)ic * W;\n for (int kw = 0; kw < Kw; ++kw) {\n int iw = ow * Sw - pad + kw * Dw;\n if (iw >= 0 && iw < W)\n sum += in_c[iw] * weight[((long)oc * Cin + ic) * Kw + kw];\n }\n }\n out_c[ow] = sum;\n }\n }\n}\n"
34
+ }
35
+ ]
36
+ }
solutions/ncnn/reference-scalar/conv1d/conv1d_kw1_sw1_dw1_p0_cin128_cout512.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "reference-scalar_conv1d_kw1_sw1_dw1_p0_cin128_cout512",
3
+ "definition": "conv1d_kw1_sw1_dw1_p0_cin128_cout512",
4
+ "dataset": "ncnn",
5
+ "author": "reference-scalar",
6
+ "description": "Scalar raw-float* conv1d for conv1d_kw1_sw1_dw1_p0_cin128_cout512. Constexpr-baked dims; armbench_entry_conv1d calls inner_conv1d. Ground-truth correctness baseline.",
7
+ "spec": {
8
+ "language": "cpp",
9
+ "target_hardware": [
10
+ "graviton3",
11
+ "aarch64-sve"
12
+ ],
13
+ "entry_point": "conv1d.cpp::armbench_entry_conv1d",
14
+ "dependencies": [],
15
+ "isa_features": [],
16
+ "compile_flags": [
17
+ "-O2",
18
+ "-std=c++14"
19
+ ],
20
+ "link_flags": []
21
+ },
22
+ "sources": [
23
+ {
24
+ "path": "conv1d.h",
25
+ "content": "#pragma once\n\n// Per-definition constants for this conv1d specialisation.\nnamespace conv1d_def {\nconstexpr int Cin = 128;\nconstexpr int Cout = 512;\nconstexpr int Kw = 1;\nconstexpr int Sw = 1;\nconstexpr int Dw = 1;\nconstexpr int pad = 0;\n} // namespace conv1d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// W and W_out are var dims; pre-computed by the binding harness.\n// Input layout: (Cin, W), output layout: (Cout, W_out).\nvoid inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv1d.cpp",
29
+ "content": "// Binding harness: computes W_out from constexpr params, calls inner_conv1d.\n// ABI: armbench_entry_conv1d(input*, output*, weight*, bias*, W)\n// Input layout: (Cin, W); output layout: (Cout, W_out).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" int armbench_entry_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W)\n{\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int W_out = (W + 2 * pad - ext_kw) / Sw + 1;\n inner_conv1d(input, output, weight, bias, W, W_out);\n return 0;\n}\n"
30
+ },
31
+ {
32
+ "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv1d.\n// LLM target: replace this file with an optimised inner_conv1d.\n// All per-definition constants live in conv1d_def:: (conv1d.h).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" void inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out)\n{\n for (int oc = 0; oc < Cout; ++oc) {\n float* out_c = output + (long)oc * W_out;\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias[oc];\n for (int ic = 0; ic < Cin; ++ic) {\n const float* in_c = input + (long)ic * W;\n for (int kw = 0; kw < Kw; ++kw) {\n int iw = ow * Sw - pad + kw * Dw;\n if (iw >= 0 && iw < W)\n sum += in_c[iw] * weight[((long)oc * Cin + ic) * Kw + kw];\n }\n }\n out_c[ow] = sum;\n }\n }\n}\n"
34
+ }
35
+ ]
36
+ }
solutions/ncnn/reference-scalar/conv1d/conv1d_kw1_sw1_dw1_p0_cin256_cout1024.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "reference-scalar_conv1d_kw1_sw1_dw1_p0_cin256_cout1024",
3
+ "definition": "conv1d_kw1_sw1_dw1_p0_cin256_cout1024",
4
+ "dataset": "ncnn",
5
+ "author": "reference-scalar",
6
+ "description": "Scalar raw-float* conv1d for conv1d_kw1_sw1_dw1_p0_cin256_cout1024. Constexpr-baked dims; armbench_entry_conv1d calls inner_conv1d. Ground-truth correctness baseline.",
7
+ "spec": {
8
+ "language": "cpp",
9
+ "target_hardware": [
10
+ "graviton3",
11
+ "aarch64-sve"
12
+ ],
13
+ "entry_point": "conv1d.cpp::armbench_entry_conv1d",
14
+ "dependencies": [],
15
+ "isa_features": [],
16
+ "compile_flags": [
17
+ "-O2",
18
+ "-std=c++14"
19
+ ],
20
+ "link_flags": []
21
+ },
22
+ "sources": [
23
+ {
24
+ "path": "conv1d.h",
25
+ "content": "#pragma once\n\n// Per-definition constants for this conv1d specialisation.\nnamespace conv1d_def {\nconstexpr int Cin = 256;\nconstexpr int Cout = 1024;\nconstexpr int Kw = 1;\nconstexpr int Sw = 1;\nconstexpr int Dw = 1;\nconstexpr int pad = 0;\n} // namespace conv1d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// W and W_out are var dims; pre-computed by the binding harness.\n// Input layout: (Cin, W), output layout: (Cout, W_out).\nvoid inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv1d.cpp",
29
+ "content": "// Binding harness: computes W_out from constexpr params, calls inner_conv1d.\n// ABI: armbench_entry_conv1d(input*, output*, weight*, bias*, W)\n// Input layout: (Cin, W); output layout: (Cout, W_out).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" int armbench_entry_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W)\n{\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int W_out = (W + 2 * pad - ext_kw) / Sw + 1;\n inner_conv1d(input, output, weight, bias, W, W_out);\n return 0;\n}\n"
30
+ },
31
+ {
32
+ "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv1d.\n// LLM target: replace this file with an optimised inner_conv1d.\n// All per-definition constants live in conv1d_def:: (conv1d.h).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" void inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out)\n{\n for (int oc = 0; oc < Cout; ++oc) {\n float* out_c = output + (long)oc * W_out;\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias[oc];\n for (int ic = 0; ic < Cin; ++ic) {\n const float* in_c = input + (long)ic * W;\n for (int kw = 0; kw < Kw; ++kw) {\n int iw = ow * Sw - pad + kw * Dw;\n if (iw >= 0 && iw < W)\n sum += in_c[iw] * weight[((long)oc * Cin + ic) * Kw + kw];\n }\n }\n out_c[ow] = sum;\n }\n }\n}\n"
34
+ }
35
+ ]
36
+ }
solutions/ncnn/reference-scalar/conv1d/conv1d_kw1_sw1_dw1_p0_cin512_cout2048.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "reference-scalar_conv1d_kw1_sw1_dw1_p0_cin512_cout2048",
3
+ "definition": "conv1d_kw1_sw1_dw1_p0_cin512_cout2048",
4
+ "dataset": "ncnn",
5
+ "author": "reference-scalar",
6
+ "description": "Scalar raw-float* conv1d for conv1d_kw1_sw1_dw1_p0_cin512_cout2048. Constexpr-baked dims; armbench_entry_conv1d calls inner_conv1d. Ground-truth correctness baseline.",
7
+ "spec": {
8
+ "language": "cpp",
9
+ "target_hardware": [
10
+ "graviton3",
11
+ "aarch64-sve"
12
+ ],
13
+ "entry_point": "conv1d.cpp::armbench_entry_conv1d",
14
+ "dependencies": [],
15
+ "isa_features": [],
16
+ "compile_flags": [
17
+ "-O2",
18
+ "-std=c++14"
19
+ ],
20
+ "link_flags": []
21
+ },
22
+ "sources": [
23
+ {
24
+ "path": "conv1d.h",
25
+ "content": "#pragma once\n\n// Per-definition constants for this conv1d specialisation.\nnamespace conv1d_def {\nconstexpr int Cin = 512;\nconstexpr int Cout = 2048;\nconstexpr int Kw = 1;\nconstexpr int Sw = 1;\nconstexpr int Dw = 1;\nconstexpr int pad = 0;\n} // namespace conv1d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// W and W_out are var dims; pre-computed by the binding harness.\n// Input layout: (Cin, W), output layout: (Cout, W_out).\nvoid inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv1d.cpp",
29
+ "content": "// Binding harness: computes W_out from constexpr params, calls inner_conv1d.\n// ABI: armbench_entry_conv1d(input*, output*, weight*, bias*, W)\n// Input layout: (Cin, W); output layout: (Cout, W_out).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" int armbench_entry_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W)\n{\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int W_out = (W + 2 * pad - ext_kw) / Sw + 1;\n inner_conv1d(input, output, weight, bias, W, W_out);\n return 0;\n}\n"
30
+ },
31
+ {
32
+ "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv1d.\n// LLM target: replace this file with an optimised inner_conv1d.\n// All per-definition constants live in conv1d_def:: (conv1d.h).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" void inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out)\n{\n for (int oc = 0; oc < Cout; ++oc) {\n float* out_c = output + (long)oc * W_out;\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias[oc];\n for (int ic = 0; ic < Cin; ++ic) {\n const float* in_c = input + (long)ic * W;\n for (int kw = 0; kw < Kw; ++kw) {\n int iw = ow * Sw - pad + kw * Dw;\n if (iw >= 0 && iw < W)\n sum += in_c[iw] * weight[((long)oc * Cin + ic) * Kw + kw];\n }\n }\n out_c[ow] = sum;\n }\n }\n}\n"
34
+ }
35
+ ]
36
+ }
solutions/ncnn/reference-scalar/conv1d/conv1d_kw1_sw1_dw1_p0_cin64_cout256.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "reference-scalar_conv1d_kw1_sw1_dw1_p0_cin64_cout256",
3
+ "definition": "conv1d_kw1_sw1_dw1_p0_cin64_cout256",
4
+ "dataset": "ncnn",
5
+ "author": "reference-scalar",
6
+ "description": "Scalar raw-float* conv1d for conv1d_kw1_sw1_dw1_p0_cin64_cout256. Constexpr-baked dims; armbench_entry_conv1d calls inner_conv1d. Ground-truth correctness baseline.",
7
+ "spec": {
8
+ "language": "cpp",
9
+ "target_hardware": [
10
+ "graviton3",
11
+ "aarch64-sve"
12
+ ],
13
+ "entry_point": "conv1d.cpp::armbench_entry_conv1d",
14
+ "dependencies": [],
15
+ "isa_features": [],
16
+ "compile_flags": [
17
+ "-O2",
18
+ "-std=c++14"
19
+ ],
20
+ "link_flags": []
21
+ },
22
+ "sources": [
23
+ {
24
+ "path": "conv1d.h",
25
+ "content": "#pragma once\n\n// Per-definition constants for this conv1d specialisation.\nnamespace conv1d_def {\nconstexpr int Cin = 64;\nconstexpr int Cout = 256;\nconstexpr int Kw = 1;\nconstexpr int Sw = 1;\nconstexpr int Dw = 1;\nconstexpr int pad = 0;\n} // namespace conv1d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// W and W_out are var dims; pre-computed by the binding harness.\n// Input layout: (Cin, W), output layout: (Cout, W_out).\nvoid inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv1d.cpp",
29
+ "content": "// Binding harness: computes W_out from constexpr params, calls inner_conv1d.\n// ABI: armbench_entry_conv1d(input*, output*, weight*, bias*, W)\n// Input layout: (Cin, W); output layout: (Cout, W_out).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" int armbench_entry_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W)\n{\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int W_out = (W + 2 * pad - ext_kw) / Sw + 1;\n inner_conv1d(input, output, weight, bias, W, W_out);\n return 0;\n}\n"
30
+ },
31
+ {
32
+ "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv1d.\n// LLM target: replace this file with an optimised inner_conv1d.\n// All per-definition constants live in conv1d_def:: (conv1d.h).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" void inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out)\n{\n for (int oc = 0; oc < Cout; ++oc) {\n float* out_c = output + (long)oc * W_out;\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias[oc];\n for (int ic = 0; ic < Cin; ++ic) {\n const float* in_c = input + (long)ic * W;\n for (int kw = 0; kw < Kw; ++kw) {\n int iw = ow * Sw - pad + kw * Dw;\n if (iw >= 0 && iw < W)\n sum += in_c[iw] * weight[((long)oc * Cin + ic) * Kw + kw];\n }\n }\n out_c[ow] = sum;\n }\n }\n}\n"
34
+ }
35
+ ]
36
+ }
solutions/ncnn/reference-scalar/conv1d/conv1d_kw1_sw1_dw1_p0_cin64_cout64.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "reference-scalar_conv1d_kw1_sw1_dw1_p0_cin64_cout64",
3
+ "definition": "conv1d_kw1_sw1_dw1_p0_cin64_cout64",
4
+ "dataset": "ncnn",
5
+ "author": "reference-scalar",
6
+ "description": "Scalar raw-float* conv1d for conv1d_kw1_sw1_dw1_p0_cin64_cout64. Constexpr-baked dims; armbench_entry_conv1d calls inner_conv1d. Ground-truth correctness baseline.",
7
+ "spec": {
8
+ "language": "cpp",
9
+ "target_hardware": [
10
+ "graviton3",
11
+ "aarch64-sve"
12
+ ],
13
+ "entry_point": "conv1d.cpp::armbench_entry_conv1d",
14
+ "dependencies": [],
15
+ "isa_features": [],
16
+ "compile_flags": [
17
+ "-O2",
18
+ "-std=c++14"
19
+ ],
20
+ "link_flags": []
21
+ },
22
+ "sources": [
23
+ {
24
+ "path": "conv1d.h",
25
+ "content": "#pragma once\n\n// Per-definition constants for this conv1d specialisation.\nnamespace conv1d_def {\nconstexpr int Cin = 64;\nconstexpr int Cout = 64;\nconstexpr int Kw = 1;\nconstexpr int Sw = 1;\nconstexpr int Dw = 1;\nconstexpr int pad = 0;\n} // namespace conv1d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// W and W_out are var dims; pre-computed by the binding harness.\n// Input layout: (Cin, W), output layout: (Cout, W_out).\nvoid inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv1d.cpp",
29
+ "content": "// Binding harness: computes W_out from constexpr params, calls inner_conv1d.\n// ABI: armbench_entry_conv1d(input*, output*, weight*, bias*, W)\n// Input layout: (Cin, W); output layout: (Cout, W_out).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" int armbench_entry_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W)\n{\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int W_out = (W + 2 * pad - ext_kw) / Sw + 1;\n inner_conv1d(input, output, weight, bias, W, W_out);\n return 0;\n}\n"
30
+ },
31
+ {
32
+ "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv1d.\n// LLM target: replace this file with an optimised inner_conv1d.\n// All per-definition constants live in conv1d_def:: (conv1d.h).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" void inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out)\n{\n for (int oc = 0; oc < Cout; ++oc) {\n float* out_c = output + (long)oc * W_out;\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias[oc];\n for (int ic = 0; ic < Cin; ++ic) {\n const float* in_c = input + (long)ic * W;\n for (int kw = 0; kw < Kw; ++kw) {\n int iw = ow * Sw - pad + kw * Dw;\n if (iw >= 0 && iw < W)\n sum += in_c[iw] * weight[((long)oc * Cin + ic) * Kw + kw];\n }\n }\n out_c[ow] = sum;\n }\n }\n}\n"
34
+ }
35
+ ]
36
+ }
solutions/ncnn/reference-scalar/conv1d/conv1d_kw3_sw1_dw1_p1_cin1024_cout1024.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "reference-scalar_conv1d_kw3_sw1_dw1_p1_cin1024_cout1024",
3
+ "definition": "conv1d_kw3_sw1_dw1_p1_cin1024_cout1024",
4
+ "dataset": "ncnn",
5
+ "author": "reference-scalar",
6
+ "description": "Scalar raw-float* conv1d for conv1d_kw3_sw1_dw1_p1_cin1024_cout1024. Constexpr-baked dims; armbench_entry_conv1d calls inner_conv1d. Ground-truth correctness baseline.",
7
+ "spec": {
8
+ "language": "cpp",
9
+ "target_hardware": [
10
+ "graviton3",
11
+ "aarch64-sve"
12
+ ],
13
+ "entry_point": "conv1d.cpp::armbench_entry_conv1d",
14
+ "dependencies": [],
15
+ "isa_features": [],
16
+ "compile_flags": [
17
+ "-O2",
18
+ "-std=c++14"
19
+ ],
20
+ "link_flags": []
21
+ },
22
+ "sources": [
23
+ {
24
+ "path": "conv1d.h",
25
+ "content": "#pragma once\n\n// Per-definition constants for this conv1d specialisation.\nnamespace conv1d_def {\nconstexpr int Cin = 1024;\nconstexpr int Cout = 1024;\nconstexpr int Kw = 3;\nconstexpr int Sw = 1;\nconstexpr int Dw = 1;\nconstexpr int pad = 1;\n} // namespace conv1d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// W and W_out are var dims; pre-computed by the binding harness.\n// Input layout: (Cin, W), output layout: (Cout, W_out).\nvoid inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv1d.cpp",
29
+ "content": "// Binding harness: computes W_out from constexpr params, calls inner_conv1d.\n// ABI: armbench_entry_conv1d(input*, output*, weight*, bias*, W)\n// Input layout: (Cin, W); output layout: (Cout, W_out).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" int armbench_entry_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W)\n{\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int W_out = (W + 2 * pad - ext_kw) / Sw + 1;\n inner_conv1d(input, output, weight, bias, W, W_out);\n return 0;\n}\n"
30
+ },
31
+ {
32
+ "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv1d.\n// LLM target: replace this file with an optimised inner_conv1d.\n// All per-definition constants live in conv1d_def:: (conv1d.h).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" void inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out)\n{\n for (int oc = 0; oc < Cout; ++oc) {\n float* out_c = output + (long)oc * W_out;\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias[oc];\n for (int ic = 0; ic < Cin; ++ic) {\n const float* in_c = input + (long)ic * W;\n for (int kw = 0; kw < Kw; ++kw) {\n int iw = ow * Sw - pad + kw * Dw;\n if (iw >= 0 && iw < W)\n sum += in_c[iw] * weight[((long)oc * Cin + ic) * Kw + kw];\n }\n }\n out_c[ow] = sum;\n }\n }\n}\n"
34
+ }
35
+ ]
36
+ }
solutions/ncnn/reference-scalar/conv1d/conv1d_kw3_sw1_dw1_p1_cin128_cout256.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "reference-scalar_conv1d_kw3_sw1_dw1_p1_cin128_cout256",
3
+ "definition": "conv1d_kw3_sw1_dw1_p1_cin128_cout256",
4
+ "dataset": "ncnn",
5
+ "author": "reference-scalar",
6
+ "description": "Scalar raw-float* conv1d for conv1d_kw3_sw1_dw1_p1_cin128_cout256. Constexpr-baked dims; armbench_entry_conv1d calls inner_conv1d. Ground-truth correctness baseline.",
7
+ "spec": {
8
+ "language": "cpp",
9
+ "target_hardware": [
10
+ "graviton3",
11
+ "aarch64-sve"
12
+ ],
13
+ "entry_point": "conv1d.cpp::armbench_entry_conv1d",
14
+ "dependencies": [],
15
+ "isa_features": [],
16
+ "compile_flags": [
17
+ "-O2",
18
+ "-std=c++14"
19
+ ],
20
+ "link_flags": []
21
+ },
22
+ "sources": [
23
+ {
24
+ "path": "conv1d.h",
25
+ "content": "#pragma once\n\n// Per-definition constants for this conv1d specialisation.\nnamespace conv1d_def {\nconstexpr int Cin = 128;\nconstexpr int Cout = 256;\nconstexpr int Kw = 3;\nconstexpr int Sw = 1;\nconstexpr int Dw = 1;\nconstexpr int pad = 1;\n} // namespace conv1d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// W and W_out are var dims; pre-computed by the binding harness.\n// Input layout: (Cin, W), output layout: (Cout, W_out).\nvoid inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv1d.cpp",
29
+ "content": "// Binding harness: computes W_out from constexpr params, calls inner_conv1d.\n// ABI: armbench_entry_conv1d(input*, output*, weight*, bias*, W)\n// Input layout: (Cin, W); output layout: (Cout, W_out).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" int armbench_entry_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W)\n{\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int W_out = (W + 2 * pad - ext_kw) / Sw + 1;\n inner_conv1d(input, output, weight, bias, W, W_out);\n return 0;\n}\n"
30
+ },
31
+ {
32
+ "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv1d.\n// LLM target: replace this file with an optimised inner_conv1d.\n// All per-definition constants live in conv1d_def:: (conv1d.h).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" void inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out)\n{\n for (int oc = 0; oc < Cout; ++oc) {\n float* out_c = output + (long)oc * W_out;\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias[oc];\n for (int ic = 0; ic < Cin; ++ic) {\n const float* in_c = input + (long)ic * W;\n for (int kw = 0; kw < Kw; ++kw) {\n int iw = ow * Sw - pad + kw * Dw;\n if (iw >= 0 && iw < W)\n sum += in_c[iw] * weight[((long)oc * Cin + ic) * Kw + kw];\n }\n }\n out_c[ow] = sum;\n }\n }\n}\n"
34
+ }
35
+ ]
36
+ }
solutions/ncnn/reference-scalar/conv1d/conv1d_kw3_sw1_dw1_p1_cin256_cout512.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "reference-scalar_conv1d_kw3_sw1_dw1_p1_cin256_cout512",
3
+ "definition": "conv1d_kw3_sw1_dw1_p1_cin256_cout512",
4
+ "dataset": "ncnn",
5
+ "author": "reference-scalar",
6
+ "description": "Scalar raw-float* conv1d for conv1d_kw3_sw1_dw1_p1_cin256_cout512. Constexpr-baked dims; armbench_entry_conv1d calls inner_conv1d. Ground-truth correctness baseline.",
7
+ "spec": {
8
+ "language": "cpp",
9
+ "target_hardware": [
10
+ "graviton3",
11
+ "aarch64-sve"
12
+ ],
13
+ "entry_point": "conv1d.cpp::armbench_entry_conv1d",
14
+ "dependencies": [],
15
+ "isa_features": [],
16
+ "compile_flags": [
17
+ "-O2",
18
+ "-std=c++14"
19
+ ],
20
+ "link_flags": []
21
+ },
22
+ "sources": [
23
+ {
24
+ "path": "conv1d.h",
25
+ "content": "#pragma once\n\n// Per-definition constants for this conv1d specialisation.\nnamespace conv1d_def {\nconstexpr int Cin = 256;\nconstexpr int Cout = 512;\nconstexpr int Kw = 3;\nconstexpr int Sw = 1;\nconstexpr int Dw = 1;\nconstexpr int pad = 1;\n} // namespace conv1d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// W and W_out are var dims; pre-computed by the binding harness.\n// Input layout: (Cin, W), output layout: (Cout, W_out).\nvoid inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv1d.cpp",
29
+ "content": "// Binding harness: computes W_out from constexpr params, calls inner_conv1d.\n// ABI: armbench_entry_conv1d(input*, output*, weight*, bias*, W)\n// Input layout: (Cin, W); output layout: (Cout, W_out).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" int armbench_entry_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W)\n{\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int W_out = (W + 2 * pad - ext_kw) / Sw + 1;\n inner_conv1d(input, output, weight, bias, W, W_out);\n return 0;\n}\n"
30
+ },
31
+ {
32
+ "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv1d.\n// LLM target: replace this file with an optimised inner_conv1d.\n// All per-definition constants live in conv1d_def:: (conv1d.h).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" void inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out)\n{\n for (int oc = 0; oc < Cout; ++oc) {\n float* out_c = output + (long)oc * W_out;\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias[oc];\n for (int ic = 0; ic < Cin; ++ic) {\n const float* in_c = input + (long)ic * W;\n for (int kw = 0; kw < Kw; ++kw) {\n int iw = ow * Sw - pad + kw * Dw;\n if (iw >= 0 && iw < W)\n sum += in_c[iw] * weight[((long)oc * Cin + ic) * Kw + kw];\n }\n }\n out_c[ow] = sum;\n }\n }\n}\n"
34
+ }
35
+ ]
36
+ }
solutions/ncnn/reference-scalar/conv1d/conv1d_kw3_sw1_dw1_p1_cin3_cout64.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "reference-scalar_conv1d_kw3_sw1_dw1_p1_cin3_cout64",
3
+ "definition": "conv1d_kw3_sw1_dw1_p1_cin3_cout64",
4
+ "dataset": "ncnn",
5
+ "author": "reference-scalar",
6
+ "description": "Scalar raw-float* conv1d for conv1d_kw3_sw1_dw1_p1_cin3_cout64. Constexpr-baked dims; armbench_entry_conv1d calls inner_conv1d. Ground-truth correctness baseline.",
7
+ "spec": {
8
+ "language": "cpp",
9
+ "target_hardware": [
10
+ "graviton3",
11
+ "aarch64-sve"
12
+ ],
13
+ "entry_point": "conv1d.cpp::armbench_entry_conv1d",
14
+ "dependencies": [],
15
+ "isa_features": [],
16
+ "compile_flags": [
17
+ "-O2",
18
+ "-std=c++14"
19
+ ],
20
+ "link_flags": []
21
+ },
22
+ "sources": [
23
+ {
24
+ "path": "conv1d.h",
25
+ "content": "#pragma once\n\n// Per-definition constants for this conv1d specialisation.\nnamespace conv1d_def {\nconstexpr int Cin = 3;\nconstexpr int Cout = 64;\nconstexpr int Kw = 3;\nconstexpr int Sw = 1;\nconstexpr int Dw = 1;\nconstexpr int pad = 1;\n} // namespace conv1d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// W and W_out are var dims; pre-computed by the binding harness.\n// Input layout: (Cin, W), output layout: (Cout, W_out).\nvoid inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv1d.cpp",
29
+ "content": "// Binding harness: computes W_out from constexpr params, calls inner_conv1d.\n// ABI: armbench_entry_conv1d(input*, output*, weight*, bias*, W)\n// Input layout: (Cin, W); output layout: (Cout, W_out).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" int armbench_entry_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W)\n{\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int W_out = (W + 2 * pad - ext_kw) / Sw + 1;\n inner_conv1d(input, output, weight, bias, W, W_out);\n return 0;\n}\n"
30
+ },
31
+ {
32
+ "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv1d.\n// LLM target: replace this file with an optimised inner_conv1d.\n// All per-definition constants live in conv1d_def:: (conv1d.h).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" void inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out)\n{\n for (int oc = 0; oc < Cout; ++oc) {\n float* out_c = output + (long)oc * W_out;\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias[oc];\n for (int ic = 0; ic < Cin; ++ic) {\n const float* in_c = input + (long)ic * W;\n for (int kw = 0; kw < Kw; ++kw) {\n int iw = ow * Sw - pad + kw * Dw;\n if (iw >= 0 && iw < W)\n sum += in_c[iw] * weight[((long)oc * Cin + ic) * Kw + kw];\n }\n }\n out_c[ow] = sum;\n }\n }\n}\n"
34
+ }
35
+ ]
36
+ }
solutions/ncnn/reference-scalar/conv1d/conv1d_kw3_sw1_dw1_p1_cin512_cout1024.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "reference-scalar_conv1d_kw3_sw1_dw1_p1_cin512_cout1024",
3
+ "definition": "conv1d_kw3_sw1_dw1_p1_cin512_cout1024",
4
+ "dataset": "ncnn",
5
+ "author": "reference-scalar",
6
+ "description": "Scalar raw-float* conv1d for conv1d_kw3_sw1_dw1_p1_cin512_cout1024. Constexpr-baked dims; armbench_entry_conv1d calls inner_conv1d. Ground-truth correctness baseline.",
7
+ "spec": {
8
+ "language": "cpp",
9
+ "target_hardware": [
10
+ "graviton3",
11
+ "aarch64-sve"
12
+ ],
13
+ "entry_point": "conv1d.cpp::armbench_entry_conv1d",
14
+ "dependencies": [],
15
+ "isa_features": [],
16
+ "compile_flags": [
17
+ "-O2",
18
+ "-std=c++14"
19
+ ],
20
+ "link_flags": []
21
+ },
22
+ "sources": [
23
+ {
24
+ "path": "conv1d.h",
25
+ "content": "#pragma once\n\n// Per-definition constants for this conv1d specialisation.\nnamespace conv1d_def {\nconstexpr int Cin = 512;\nconstexpr int Cout = 1024;\nconstexpr int Kw = 3;\nconstexpr int Sw = 1;\nconstexpr int Dw = 1;\nconstexpr int pad = 1;\n} // namespace conv1d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// W and W_out are var dims; pre-computed by the binding harness.\n// Input layout: (Cin, W), output layout: (Cout, W_out).\nvoid inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv1d.cpp",
29
+ "content": "// Binding harness: computes W_out from constexpr params, calls inner_conv1d.\n// ABI: armbench_entry_conv1d(input*, output*, weight*, bias*, W)\n// Input layout: (Cin, W); output layout: (Cout, W_out).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" int armbench_entry_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W)\n{\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int W_out = (W + 2 * pad - ext_kw) / Sw + 1;\n inner_conv1d(input, output, weight, bias, W, W_out);\n return 0;\n}\n"
30
+ },
31
+ {
32
+ "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv1d.\n// LLM target: replace this file with an optimised inner_conv1d.\n// All per-definition constants live in conv1d_def:: (conv1d.h).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" void inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out)\n{\n for (int oc = 0; oc < Cout; ++oc) {\n float* out_c = output + (long)oc * W_out;\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias[oc];\n for (int ic = 0; ic < Cin; ++ic) {\n const float* in_c = input + (long)ic * W;\n for (int kw = 0; kw < Kw; ++kw) {\n int iw = ow * Sw - pad + kw * Dw;\n if (iw >= 0 && iw < W)\n sum += in_c[iw] * weight[((long)oc * Cin + ic) * Kw + kw];\n }\n }\n out_c[ow] = sum;\n }\n }\n}\n"
34
+ }
35
+ ]
36
+ }
solutions/ncnn/reference-scalar/conv1d/conv1d_kw3_sw1_dw1_p1_cin64_cout128.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "reference-scalar_conv1d_kw3_sw1_dw1_p1_cin64_cout128",
3
+ "definition": "conv1d_kw3_sw1_dw1_p1_cin64_cout128",
4
+ "dataset": "ncnn",
5
+ "author": "reference-scalar",
6
+ "description": "Scalar raw-float* conv1d for conv1d_kw3_sw1_dw1_p1_cin64_cout128. Constexpr-baked dims; armbench_entry_conv1d calls inner_conv1d. Ground-truth correctness baseline.",
7
+ "spec": {
8
+ "language": "cpp",
9
+ "target_hardware": [
10
+ "graviton3",
11
+ "aarch64-sve"
12
+ ],
13
+ "entry_point": "conv1d.cpp::armbench_entry_conv1d",
14
+ "dependencies": [],
15
+ "isa_features": [],
16
+ "compile_flags": [
17
+ "-O2",
18
+ "-std=c++14"
19
+ ],
20
+ "link_flags": []
21
+ },
22
+ "sources": [
23
+ {
24
+ "path": "conv1d.h",
25
+ "content": "#pragma once\n\n// Per-definition constants for this conv1d specialisation.\nnamespace conv1d_def {\nconstexpr int Cin = 64;\nconstexpr int Cout = 128;\nconstexpr int Kw = 3;\nconstexpr int Sw = 1;\nconstexpr int Dw = 1;\nconstexpr int pad = 1;\n} // namespace conv1d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// W and W_out are var dims; pre-computed by the binding harness.\n// Input layout: (Cin, W), output layout: (Cout, W_out).\nvoid inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv1d.cpp",
29
+ "content": "// Binding harness: computes W_out from constexpr params, calls inner_conv1d.\n// ABI: armbench_entry_conv1d(input*, output*, weight*, bias*, W)\n// Input layout: (Cin, W); output layout: (Cout, W_out).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" int armbench_entry_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W)\n{\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int W_out = (W + 2 * pad - ext_kw) / Sw + 1;\n inner_conv1d(input, output, weight, bias, W, W_out);\n return 0;\n}\n"
30
+ },
31
+ {
32
+ "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv1d.\n// LLM target: replace this file with an optimised inner_conv1d.\n// All per-definition constants live in conv1d_def:: (conv1d.h).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" void inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int W, int W_out)\n{\n for (int oc = 0; oc < Cout; ++oc) {\n float* out_c = output + (long)oc * W_out;\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias[oc];\n for (int ic = 0; ic < Cin; ++ic) {\n const float* in_c = input + (long)ic * W;\n for (int kw = 0; kw < Kw; ++kw) {\n int iw = ow * Sw - pad + kw * Dw;\n if (iw >= 0 && iw < W)\n sum += in_c[iw] * weight[((long)oc * Cin + ic) * Kw + kw];\n }\n }\n out_c[ow] = sum;\n }\n }\n}\n"
34
+ }
35
+ ]
36
+ }
solutions/ncnn/reference-scalar/conv2d/conv2d_kh1_kw1_sh1_sw1_dh1_dw1_c1024_c1024.json CHANGED
@@ -10,7 +10,7 @@
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
- "entry_point": "kernel.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
@@ -20,9 +20,17 @@
20
  "link_flags": []
21
  },
22
  "sources": [
 
 
 
 
 
 
 
 
23
  {
24
  "path": "kernel.cpp",
25
- "content": "// reference-scalar conv2d \u2014 raw float* port of ref_conv.h::ref_conv2d.\n// No ncnn dependency; implements the CandidateBuilder C-ABI directly.\n\n#include \"conv2d.h\"\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int Cin, int H, int W,\n int Cout, int Kh, int Kw, int Sh, int Sw, int Dh, int Dw,\n int pad_top, int pad_left,\n int activation_type, const float* act_params, int n_act)\n{\n (void)act_params; (void)n_act;\n const int ext_kh = Dh * (Kh - 1) + 1;\n const int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias ? bias[oc] : 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n return 0;\n}\n"
26
  }
27
  ]
28
  }
 
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
+ "entry_point": "conv2d.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
 
20
  "link_flags": []
21
  },
22
  "sources": [
23
+ {
24
+ "path": "conv2d.h",
25
+ "content": "// Auto-generated by scripts/gen_candidate_bindings.py \u2014 do not hand-edit.\n#pragma once\n\n// Per-definition constants for this conv2d specialisation.\nnamespace conv2d_def {\nconstexpr int Cin = 1024;\nconstexpr int Cout = 1024;\nconstexpr int Kh = 1;\nconstexpr int Kw = 1;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad_top = 0;\nconstexpr int pad_left = 0;\nconstexpr int activation_type = 0;\n} // namespace conv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\nvoid inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv2d.cpp",
29
+ "content": "// Binding harness: computes output dims from constexpr params, calls inner_conv2d.\n// The ctypes mirror of armbench_entry_conv2d is bench/datasets/raw.py\n// SIGNATURES[\"conv2d\"] \u2014 edit one, edit the other.\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight,\n int N, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n inner_conv2d(input, output, weight, N, H, W, H_out, W_out);\n return 0;\n}"
30
+ },
31
  {
32
  "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv2d \u2014 port of ref_conv.h::ref_conv2d.\n// LLM target: replace this file with an optimised inner_conv2d.\n// All per-definition constants live in conv2d_def:: (conv2d.h).\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" void inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out)\n{\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n}\n"
34
  }
35
  ]
36
  }
solutions/ncnn/reference-scalar/conv2d/conv2d_kh1_kw1_sh1_sw1_dh1_dw1_c128_c512.json CHANGED
@@ -10,7 +10,7 @@
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
- "entry_point": "kernel.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
@@ -20,9 +20,17 @@
20
  "link_flags": []
21
  },
22
  "sources": [
 
 
 
 
 
 
 
 
23
  {
24
  "path": "kernel.cpp",
25
- "content": "// reference-scalar conv2d \u2014 raw float* port of ref_conv.h::ref_conv2d.\n// No ncnn dependency; implements the CandidateBuilder C-ABI directly.\n\n#include \"conv2d.h\"\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int Cin, int H, int W,\n int Cout, int Kh, int Kw, int Sh, int Sw, int Dh, int Dw,\n int pad_top, int pad_left,\n int activation_type, const float* act_params, int n_act)\n{\n (void)act_params; (void)n_act;\n const int ext_kh = Dh * (Kh - 1) + 1;\n const int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias ? bias[oc] : 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n return 0;\n}\n"
26
  }
27
  ]
28
  }
 
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
+ "entry_point": "conv2d.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
 
20
  "link_flags": []
21
  },
22
  "sources": [
23
+ {
24
+ "path": "conv2d.h",
25
+ "content": "// Auto-generated by scripts/gen_candidate_bindings.py \u2014 do not hand-edit.\n#pragma once\n\n// Per-definition constants for this conv2d specialisation.\nnamespace conv2d_def {\nconstexpr int Cin = 128;\nconstexpr int Cout = 512;\nconstexpr int Kh = 1;\nconstexpr int Kw = 1;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad_top = 0;\nconstexpr int pad_left = 0;\nconstexpr int activation_type = 0;\n} // namespace conv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\nvoid inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv2d.cpp",
29
+ "content": "// Binding harness: computes output dims from constexpr params, calls inner_conv2d.\n// The ctypes mirror of armbench_entry_conv2d is bench/datasets/raw.py\n// SIGNATURES[\"conv2d\"] \u2014 edit one, edit the other.\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight,\n int N, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n inner_conv2d(input, output, weight, N, H, W, H_out, W_out);\n return 0;\n}"
30
+ },
31
  {
32
  "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv2d \u2014 port of ref_conv.h::ref_conv2d.\n// LLM target: replace this file with an optimised inner_conv2d.\n// All per-definition constants live in conv2d_def:: (conv2d.h).\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" void inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out)\n{\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n}\n"
34
  }
35
  ]
36
  }
solutions/ncnn/reference-scalar/conv2d/conv2d_kh1_kw1_sh1_sw1_dh1_dw1_c256_c1024.json CHANGED
@@ -10,7 +10,7 @@
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
- "entry_point": "kernel.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
@@ -20,9 +20,17 @@
20
  "link_flags": []
21
  },
22
  "sources": [
 
 
 
 
 
 
 
 
23
  {
24
  "path": "kernel.cpp",
25
- "content": "// reference-scalar conv2d \u2014 raw float* port of ref_conv.h::ref_conv2d.\n// No ncnn dependency; implements the CandidateBuilder C-ABI directly.\n\n#include \"conv2d.h\"\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int Cin, int H, int W,\n int Cout, int Kh, int Kw, int Sh, int Sw, int Dh, int Dw,\n int pad_top, int pad_left,\n int activation_type, const float* act_params, int n_act)\n{\n (void)act_params; (void)n_act;\n const int ext_kh = Dh * (Kh - 1) + 1;\n const int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias ? bias[oc] : 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n return 0;\n}\n"
26
  }
27
  ]
28
  }
 
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
+ "entry_point": "conv2d.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
 
20
  "link_flags": []
21
  },
22
  "sources": [
23
+ {
24
+ "path": "conv2d.h",
25
+ "content": "// Auto-generated by scripts/gen_candidate_bindings.py \u2014 do not hand-edit.\n#pragma once\n\n// Per-definition constants for this conv2d specialisation.\nnamespace conv2d_def {\nconstexpr int Cin = 256;\nconstexpr int Cout = 1024;\nconstexpr int Kh = 1;\nconstexpr int Kw = 1;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad_top = 0;\nconstexpr int pad_left = 0;\nconstexpr int activation_type = 0;\n} // namespace conv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\nvoid inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv2d.cpp",
29
+ "content": "// Binding harness: computes output dims from constexpr params, calls inner_conv2d.\n// The ctypes mirror of armbench_entry_conv2d is bench/datasets/raw.py\n// SIGNATURES[\"conv2d\"] \u2014 edit one, edit the other.\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight,\n int N, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n inner_conv2d(input, output, weight, N, H, W, H_out, W_out);\n return 0;\n}"
30
+ },
31
  {
32
  "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv2d \u2014 port of ref_conv.h::ref_conv2d.\n// LLM target: replace this file with an optimised inner_conv2d.\n// All per-definition constants live in conv2d_def:: (conv2d.h).\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" void inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out)\n{\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n}\n"
34
  }
35
  ]
36
  }
solutions/ncnn/reference-scalar/conv2d/conv2d_kh1_kw1_sh1_sw1_dh1_dw1_c512_c2048.json CHANGED
@@ -10,7 +10,7 @@
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
- "entry_point": "kernel.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
@@ -20,9 +20,17 @@
20
  "link_flags": []
21
  },
22
  "sources": [
 
 
 
 
 
 
 
 
23
  {
24
  "path": "kernel.cpp",
25
- "content": "// reference-scalar conv2d \u2014 raw float* port of ref_conv.h::ref_conv2d.\n// No ncnn dependency; implements the CandidateBuilder C-ABI directly.\n\n#include \"conv2d.h\"\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int Cin, int H, int W,\n int Cout, int Kh, int Kw, int Sh, int Sw, int Dh, int Dw,\n int pad_top, int pad_left,\n int activation_type, const float* act_params, int n_act)\n{\n (void)act_params; (void)n_act;\n const int ext_kh = Dh * (Kh - 1) + 1;\n const int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias ? bias[oc] : 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n return 0;\n}\n"
26
  }
27
  ]
28
  }
 
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
+ "entry_point": "conv2d.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
 
20
  "link_flags": []
21
  },
22
  "sources": [
23
+ {
24
+ "path": "conv2d.h",
25
+ "content": "// Auto-generated by scripts/gen_candidate_bindings.py \u2014 do not hand-edit.\n#pragma once\n\n// Per-definition constants for this conv2d specialisation.\nnamespace conv2d_def {\nconstexpr int Cin = 512;\nconstexpr int Cout = 2048;\nconstexpr int Kh = 1;\nconstexpr int Kw = 1;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad_top = 0;\nconstexpr int pad_left = 0;\nconstexpr int activation_type = 0;\n} // namespace conv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\nvoid inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv2d.cpp",
29
+ "content": "// Binding harness: computes output dims from constexpr params, calls inner_conv2d.\n// The ctypes mirror of armbench_entry_conv2d is bench/datasets/raw.py\n// SIGNATURES[\"conv2d\"] \u2014 edit one, edit the other.\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight,\n int N, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n inner_conv2d(input, output, weight, N, H, W, H_out, W_out);\n return 0;\n}"
30
+ },
31
  {
32
  "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv2d \u2014 port of ref_conv.h::ref_conv2d.\n// LLM target: replace this file with an optimised inner_conv2d.\n// All per-definition constants live in conv2d_def:: (conv2d.h).\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" void inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out)\n{\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n}\n"
34
  }
35
  ]
36
  }
solutions/ncnn/reference-scalar/conv2d/conv2d_kh1_kw1_sh1_sw1_dh1_dw1_c64_c256.json CHANGED
@@ -10,7 +10,7 @@
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
- "entry_point": "kernel.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
@@ -20,9 +20,17 @@
20
  "link_flags": []
21
  },
22
  "sources": [
 
 
 
 
 
 
 
 
23
  {
24
  "path": "kernel.cpp",
25
- "content": "// reference-scalar conv2d \u2014 raw float* port of ref_conv.h::ref_conv2d.\n// No ncnn dependency; implements the CandidateBuilder C-ABI directly.\n\n#include \"conv2d.h\"\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int Cin, int H, int W,\n int Cout, int Kh, int Kw, int Sh, int Sw, int Dh, int Dw,\n int pad_top, int pad_left,\n int activation_type, const float* act_params, int n_act)\n{\n (void)act_params; (void)n_act;\n const int ext_kh = Dh * (Kh - 1) + 1;\n const int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias ? bias[oc] : 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n return 0;\n}\n"
26
  }
27
  ]
28
  }
 
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
+ "entry_point": "conv2d.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
 
20
  "link_flags": []
21
  },
22
  "sources": [
23
+ {
24
+ "path": "conv2d.h",
25
+ "content": "// Auto-generated by scripts/gen_candidate_bindings.py \u2014 do not hand-edit.\n#pragma once\n\n// Per-definition constants for this conv2d specialisation.\nnamespace conv2d_def {\nconstexpr int Cin = 64;\nconstexpr int Cout = 256;\nconstexpr int Kh = 1;\nconstexpr int Kw = 1;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad_top = 0;\nconstexpr int pad_left = 0;\nconstexpr int activation_type = 0;\n} // namespace conv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\nvoid inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv2d.cpp",
29
+ "content": "// Binding harness: computes output dims from constexpr params, calls inner_conv2d.\n// The ctypes mirror of armbench_entry_conv2d is bench/datasets/raw.py\n// SIGNATURES[\"conv2d\"] \u2014 edit one, edit the other.\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight,\n int N, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n inner_conv2d(input, output, weight, N, H, W, H_out, W_out);\n return 0;\n}"
30
+ },
31
  {
32
  "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv2d \u2014 port of ref_conv.h::ref_conv2d.\n// LLM target: replace this file with an optimised inner_conv2d.\n// All per-definition constants live in conv2d_def:: (conv2d.h).\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" void inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out)\n{\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n}\n"
34
  }
35
  ]
36
  }
solutions/ncnn/reference-scalar/conv2d/conv2d_kh1_kw1_sh1_sw1_dh1_dw1_c64_c64.json CHANGED
@@ -10,7 +10,7 @@
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
- "entry_point": "kernel.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
@@ -20,9 +20,17 @@
20
  "link_flags": []
21
  },
22
  "sources": [
 
 
 
 
 
 
 
 
23
  {
24
  "path": "kernel.cpp",
25
- "content": "// reference-scalar conv2d \u2014 raw float* port of ref_conv.h::ref_conv2d.\n// No ncnn dependency; implements the CandidateBuilder C-ABI directly.\n\n#include \"conv2d.h\"\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int Cin, int H, int W,\n int Cout, int Kh, int Kw, int Sh, int Sw, int Dh, int Dw,\n int pad_top, int pad_left,\n int activation_type, const float* act_params, int n_act)\n{\n (void)act_params; (void)n_act;\n const int ext_kh = Dh * (Kh - 1) + 1;\n const int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias ? bias[oc] : 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n return 0;\n}\n"
26
  }
27
  ]
28
  }
 
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
+ "entry_point": "conv2d.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
 
20
  "link_flags": []
21
  },
22
  "sources": [
23
+ {
24
+ "path": "conv2d.h",
25
+ "content": "// Auto-generated by scripts/gen_candidate_bindings.py \u2014 do not hand-edit.\n#pragma once\n\n// Per-definition constants for this conv2d specialisation.\nnamespace conv2d_def {\nconstexpr int Cin = 64;\nconstexpr int Cout = 64;\nconstexpr int Kh = 1;\nconstexpr int Kw = 1;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad_top = 0;\nconstexpr int pad_left = 0;\nconstexpr int activation_type = 0;\n} // namespace conv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\nvoid inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv2d.cpp",
29
+ "content": "// Binding harness: computes output dims from constexpr params, calls inner_conv2d.\n// The ctypes mirror of armbench_entry_conv2d is bench/datasets/raw.py\n// SIGNATURES[\"conv2d\"] \u2014 edit one, edit the other.\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight,\n int N, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n inner_conv2d(input, output, weight, N, H, W, H_out, W_out);\n return 0;\n}"
30
+ },
31
  {
32
  "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv2d \u2014 port of ref_conv.h::ref_conv2d.\n// LLM target: replace this file with an optimised inner_conv2d.\n// All per-definition constants live in conv2d_def:: (conv2d.h).\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" void inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out)\n{\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n}\n"
34
  }
35
  ]
36
  }
solutions/ncnn/reference-scalar/conv2d/conv2d_kh3_kw3_sh1_sw1_dh1_dw1_c128_c256.json CHANGED
@@ -10,7 +10,7 @@
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
- "entry_point": "kernel.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
@@ -20,9 +20,17 @@
20
  "link_flags": []
21
  },
22
  "sources": [
 
 
 
 
 
 
 
 
23
  {
24
  "path": "kernel.cpp",
25
- "content": "// reference-scalar conv2d \u2014 raw float* port of ref_conv.h::ref_conv2d.\n// No ncnn dependency; implements the CandidateBuilder C-ABI directly.\n\n#include \"conv2d.h\"\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int Cin, int H, int W,\n int Cout, int Kh, int Kw, int Sh, int Sw, int Dh, int Dw,\n int pad_top, int pad_left,\n int activation_type, const float* act_params, int n_act)\n{\n (void)act_params; (void)n_act;\n const int ext_kh = Dh * (Kh - 1) + 1;\n const int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias ? bias[oc] : 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n return 0;\n}\n"
26
  }
27
  ]
28
  }
 
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
+ "entry_point": "conv2d.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
 
20
  "link_flags": []
21
  },
22
  "sources": [
23
+ {
24
+ "path": "conv2d.h",
25
+ "content": "// Auto-generated by scripts/gen_candidate_bindings.py \u2014 do not hand-edit.\n#pragma once\n\n// Per-definition constants for this conv2d specialisation.\nnamespace conv2d_def {\nconstexpr int Cin = 128;\nconstexpr int Cout = 256;\nconstexpr int Kh = 3;\nconstexpr int Kw = 3;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad_top = 1;\nconstexpr int pad_left = 1;\nconstexpr int activation_type = 0;\n} // namespace conv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\nvoid inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv2d.cpp",
29
+ "content": "// Binding harness: computes output dims from constexpr params, calls inner_conv2d.\n// The ctypes mirror of armbench_entry_conv2d is bench/datasets/raw.py\n// SIGNATURES[\"conv2d\"] \u2014 edit one, edit the other.\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight,\n int N, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n inner_conv2d(input, output, weight, N, H, W, H_out, W_out);\n return 0;\n}"
30
+ },
31
  {
32
  "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv2d \u2014 port of ref_conv.h::ref_conv2d.\n// LLM target: replace this file with an optimised inner_conv2d.\n// All per-definition constants live in conv2d_def:: (conv2d.h).\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" void inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out)\n{\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n}\n"
34
  }
35
  ]
36
  }
solutions/ncnn/reference-scalar/conv2d/conv2d_kh3_kw3_sh1_sw1_dh1_dw1_c256_c512.json CHANGED
@@ -10,7 +10,7 @@
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
- "entry_point": "kernel.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
@@ -20,9 +20,17 @@
20
  "link_flags": []
21
  },
22
  "sources": [
 
 
 
 
 
 
 
 
23
  {
24
  "path": "kernel.cpp",
25
- "content": "// reference-scalar conv2d \u2014 raw float* port of ref_conv.h::ref_conv2d.\n// No ncnn dependency; implements the CandidateBuilder C-ABI directly.\n\n#include \"conv2d.h\"\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int Cin, int H, int W,\n int Cout, int Kh, int Kw, int Sh, int Sw, int Dh, int Dw,\n int pad_top, int pad_left,\n int activation_type, const float* act_params, int n_act)\n{\n (void)act_params; (void)n_act;\n const int ext_kh = Dh * (Kh - 1) + 1;\n const int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias ? bias[oc] : 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n return 0;\n}\n"
26
  }
27
  ]
28
  }
 
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
+ "entry_point": "conv2d.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
 
20
  "link_flags": []
21
  },
22
  "sources": [
23
+ {
24
+ "path": "conv2d.h",
25
+ "content": "// Auto-generated by scripts/gen_candidate_bindings.py \u2014 do not hand-edit.\n#pragma once\n\n// Per-definition constants for this conv2d specialisation.\nnamespace conv2d_def {\nconstexpr int Cin = 256;\nconstexpr int Cout = 512;\nconstexpr int Kh = 3;\nconstexpr int Kw = 3;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad_top = 1;\nconstexpr int pad_left = 1;\nconstexpr int activation_type = 0;\n} // namespace conv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\nvoid inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv2d.cpp",
29
+ "content": "// Binding harness: computes output dims from constexpr params, calls inner_conv2d.\n// The ctypes mirror of armbench_entry_conv2d is bench/datasets/raw.py\n// SIGNATURES[\"conv2d\"] \u2014 edit one, edit the other.\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight,\n int N, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n inner_conv2d(input, output, weight, N, H, W, H_out, W_out);\n return 0;\n}"
30
+ },
31
  {
32
  "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv2d \u2014 port of ref_conv.h::ref_conv2d.\n// LLM target: replace this file with an optimised inner_conv2d.\n// All per-definition constants live in conv2d_def:: (conv2d.h).\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" void inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out)\n{\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n}\n"
34
  }
35
  ]
36
  }
solutions/ncnn/reference-scalar/conv2d/conv2d_kh3_kw3_sh1_sw1_dh1_dw1_c3_c64.json CHANGED
@@ -10,7 +10,7 @@
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
- "entry_point": "kernel.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
@@ -20,9 +20,17 @@
20
  "link_flags": []
21
  },
22
  "sources": [
 
 
 
 
 
 
 
 
23
  {
24
  "path": "kernel.cpp",
25
- "content": "// reference-scalar conv2d \u2014 raw float* port of ref_conv.h::ref_conv2d.\n// No ncnn dependency; implements the CandidateBuilder C-ABI directly.\n\n#include \"conv2d.h\"\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int Cin, int H, int W,\n int Cout, int Kh, int Kw, int Sh, int Sw, int Dh, int Dw,\n int pad_top, int pad_left,\n int activation_type, const float* act_params, int n_act)\n{\n (void)act_params; (void)n_act;\n const int ext_kh = Dh * (Kh - 1) + 1;\n const int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias ? bias[oc] : 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n return 0;\n}\n"
26
  }
27
  ]
28
  }
 
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
+ "entry_point": "conv2d.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
 
20
  "link_flags": []
21
  },
22
  "sources": [
23
+ {
24
+ "path": "conv2d.h",
25
+ "content": "// Auto-generated by scripts/gen_candidate_bindings.py \u2014 do not hand-edit.\n#pragma once\n\n// Per-definition constants for this conv2d specialisation.\nnamespace conv2d_def {\nconstexpr int Cin = 3;\nconstexpr int Cout = 64;\nconstexpr int Kh = 3;\nconstexpr int Kw = 3;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad_top = 1;\nconstexpr int pad_left = 1;\nconstexpr int activation_type = 0;\n} // namespace conv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\nvoid inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv2d.cpp",
29
+ "content": "// Binding harness: computes output dims from constexpr params, calls inner_conv2d.\n// The ctypes mirror of armbench_entry_conv2d is bench/datasets/raw.py\n// SIGNATURES[\"conv2d\"] \u2014 edit one, edit the other.\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight,\n int N, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n inner_conv2d(input, output, weight, N, H, W, H_out, W_out);\n return 0;\n}"
30
+ },
31
  {
32
  "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv2d \u2014 port of ref_conv.h::ref_conv2d.\n// LLM target: replace this file with an optimised inner_conv2d.\n// All per-definition constants live in conv2d_def:: (conv2d.h).\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" void inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out)\n{\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n}\n"
34
  }
35
  ]
36
  }
solutions/ncnn/reference-scalar/conv2d/conv2d_kh3_kw3_sh1_sw1_dh1_dw1_c512_c1024.json CHANGED
@@ -10,7 +10,7 @@
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
- "entry_point": "kernel.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
@@ -20,9 +20,17 @@
20
  "link_flags": []
21
  },
22
  "sources": [
 
 
 
 
 
 
 
 
23
  {
24
  "path": "kernel.cpp",
25
- "content": "// reference-scalar conv2d \u2014 raw float* port of ref_conv.h::ref_conv2d.\n// No ncnn dependency; implements the CandidateBuilder C-ABI directly.\n\n#include \"conv2d.h\"\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int Cin, int H, int W,\n int Cout, int Kh, int Kw, int Sh, int Sw, int Dh, int Dw,\n int pad_top, int pad_left,\n int activation_type, const float* act_params, int n_act)\n{\n (void)act_params; (void)n_act;\n const int ext_kh = Dh * (Kh - 1) + 1;\n const int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias ? bias[oc] : 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n return 0;\n}\n"
26
  }
27
  ]
28
  }
 
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
+ "entry_point": "conv2d.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
 
20
  "link_flags": []
21
  },
22
  "sources": [
23
+ {
24
+ "path": "conv2d.h",
25
+ "content": "// Auto-generated by scripts/gen_candidate_bindings.py \u2014 do not hand-edit.\n#pragma once\n\n// Per-definition constants for this conv2d specialisation.\nnamespace conv2d_def {\nconstexpr int Cin = 512;\nconstexpr int Cout = 1024;\nconstexpr int Kh = 3;\nconstexpr int Kw = 3;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad_top = 1;\nconstexpr int pad_left = 1;\nconstexpr int activation_type = 0;\n} // namespace conv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\nvoid inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv2d.cpp",
29
+ "content": "// Binding harness: computes output dims from constexpr params, calls inner_conv2d.\n// The ctypes mirror of armbench_entry_conv2d is bench/datasets/raw.py\n// SIGNATURES[\"conv2d\"] \u2014 edit one, edit the other.\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight,\n int N, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n inner_conv2d(input, output, weight, N, H, W, H_out, W_out);\n return 0;\n}"
30
+ },
31
  {
32
  "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv2d \u2014 port of ref_conv.h::ref_conv2d.\n// LLM target: replace this file with an optimised inner_conv2d.\n// All per-definition constants live in conv2d_def:: (conv2d.h).\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" void inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out)\n{\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n}\n"
34
  }
35
  ]
36
  }
solutions/ncnn/reference-scalar/conv2d/conv2d_kh3_kw3_sh1_sw1_dh1_dw1_c64_c128.json CHANGED
@@ -10,7 +10,7 @@
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
- "entry_point": "kernel.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
@@ -20,9 +20,17 @@
20
  "link_flags": []
21
  },
22
  "sources": [
 
 
 
 
 
 
 
 
23
  {
24
  "path": "kernel.cpp",
25
- "content": "// reference-scalar conv2d \u2014 raw float* port of ref_conv.h::ref_conv2d.\n// No ncnn dependency; implements the CandidateBuilder C-ABI directly.\n\n#include \"conv2d.h\"\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int Cin, int H, int W,\n int Cout, int Kh, int Kw, int Sh, int Sw, int Dh, int Dw,\n int pad_top, int pad_left,\n int activation_type, const float* act_params, int n_act)\n{\n (void)act_params; (void)n_act;\n const int ext_kh = Dh * (Kh - 1) + 1;\n const int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias ? bias[oc] : 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n return 0;\n}\n"
26
  }
27
  ]
28
  }
 
10
  "graviton3",
11
  "aarch64-sve"
12
  ],
13
+ "entry_point": "conv2d.cpp::armbench_entry_conv2d",
14
  "dependencies": [],
15
  "isa_features": [],
16
  "compile_flags": [
 
20
  "link_flags": []
21
  },
22
  "sources": [
23
+ {
24
+ "path": "conv2d.h",
25
+ "content": "// Auto-generated by scripts/gen_candidate_bindings.py \u2014 do not hand-edit.\n#pragma once\n\n// Per-definition constants for this conv2d specialisation.\nnamespace conv2d_def {\nconstexpr int Cin = 64;\nconstexpr int Cout = 128;\nconstexpr int Kh = 3;\nconstexpr int Kw = 3;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad_top = 1;\nconstexpr int pad_left = 1;\nconstexpr int activation_type = 0;\n} // namespace conv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\nvoid inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
26
+ },
27
+ {
28
+ "path": "conv2d.cpp",
29
+ "content": "// Binding harness: computes output dims from constexpr params, calls inner_conv2d.\n// The ctypes mirror of armbench_entry_conv2d is bench/datasets/raw.py\n// SIGNATURES[\"conv2d\"] \u2014 edit one, edit the other.\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight,\n int N, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n inner_conv2d(input, output, weight, N, H, W, H_out, W_out);\n return 0;\n}"
30
+ },
31
  {
32
  "path": "kernel.cpp",
33
+ "content": "// Reference-scalar conv2d \u2014 port of ref_conv.h::ref_conv2d.\n// LLM target: replace this file with an optimised inner_conv2d.\n// All per-definition constants live in conv2d_def:: (conv2d.h).\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" void inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int H, int W, int H_out, int W_out)\n{\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * Cin * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int oc = 0; oc < Cout; ++oc) {\n float* outc = out_n + (long)oc * H_out * W_out;\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = 0.0f;\n for (int ic = 0; ic < Cin; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int ih = oh * Sh - pad_top + kh * Dh;\n int iw = ow * Sw - pad_left + kw * Dw;\n float px = (ih >= 0 && ih < H && iw >= 0 && iw < W)\n ? inc[ih * W + iw] : 0.0f;\n int widx = ((oc * Cin + ic) * Kh + kh) * Kw + kw;\n sum += px * weight[widx];\n }\n }\n }\n if (activation_type == 1 && sum < 0.0f) sum = 0.0f;\n outc[oh * W_out + ow] = sum;\n }\n }\n }\n }\n}\n"
34
  }
35
  ]
36
  }