ArtificialRay commited on
Commit ·
07f5581
1
Parent(s): c2269ab
Definitions, solutions, and evaluation trace updates for ncnn kernels
Browse files- update ncnn-arm baseline and reference-scalar solution and claude-sonnet-4-6 agent eval solution trace
- update evaluation traces for conv2d, conv2d depthwise, gemm, pooling
- update low-bit kernel definition for conv2d, conv2d_depthwise, gemm
This view is limited to 50 files because it contains too many changes. See raw diff
- definitions/conv2d/conv2d_w8a8ch_kh1_kw1_sh1_sw1_dh1_dw1_p0.json +2 -2
- definitions/conv2d/conv2d_w8a8ch_kh1_kw1_sh2_sw2_dh1_dw1_p0.json +2 -2
- definitions/conv2d/conv2d_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1.json +2 -2
- definitions/conv2d/conv2d_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1.json +2 -2
- definitions/conv2d/conv2d_w8a8ch_kh7_kw7_sh2_sw2_dh1_dw1_p3.json +2 -2
- definitions/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1.json +2 -2
- definitions/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1.json +2 -2
- definitions/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh5_kw5_sh1_sw1_dh1_dw1_p2.json +2 -2
- definitions/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh5_kw5_sh2_sw2_dh1_dw1_p2.json +2 -2
- definitions/gemm/gemm_w8a8ch_n1000_k1280.json +2 -2
- definitions/gemm/gemm_w8a8ch_n1000_k2048.json +2 -2
- definitions/gemm/gemm_w8a8ch_n1280_k960.json +2 -2
- solutions/ncnn/baseline-ncnn-arm/conv1d/conv1d_kw1_sw1_dw1_cout512_p0.json +0 -40
- solutions/ncnn/baseline-ncnn-arm/conv1d/conv1d_kw3_sw1_dw1_cout512_p1.json +0 -40
- solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_fp32_kh1_kw1_sh1_sw1_dh1_dw1_p0.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_fp32_kh1_kw1_sh2_sw2_dh1_dw1_p0.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_fp32_kh7_kw7_sh2_sw2_dh1_dw1_p3.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_w8a8ch_kh1_kw1_sh1_sw1_dh1_dw1_p0.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_w8a8ch_kh1_kw1_sh2_sw2_dh1_dw1_p0.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_w8a8ch_kh7_kw7_sh2_sw2_dh1_dw1_p3.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_fp32_kh5_kw5_sh1_sw1_dh1_dw1_p2.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_fp32_kh5_kw5_sh2_sw2_dh1_dw1_p2.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh5_kw5_sh1_sw1_dh1_dw1_p2.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh5_kw5_sh2_sw2_dh1_dw1_p2.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh1_sw1_cout256.json +0 -40
- solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh2_sw2_cout256.json +0 -40
- solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh1_sw1_cout128.json +0 -40
- solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh2_sw2_cout128.json +0 -40
- solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2.json +0 -40
- solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh3_kw3_sh1_sw1.json +0 -40
- solutions/ncnn/baseline-ncnn-arm/gemm/gemm_fp32_n1000_k1280.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/gemm/gemm_fp32_n1000_k2048.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/gemm/gemm_fp32_n1280_k960.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/gemm/gemm_fp32_n29_k800.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/gemm/gemm_w8a8ch_n1000_k1280.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/gemm/gemm_w8a8ch_n1000_k2048.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/gemm/gemm_w8a8ch_n1280_k960.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/lstm/lstm_fp32_i322_h800.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/pooling/pooling_fp32_global_avg.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/pooling/pooling_fp32_max_kh2_kw2_sh2_sw2_p0.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/pooling/pooling_fp32_max_kh3_kw3_sh1_sw1_p1.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/pooling/pooling_fp32_max_kh3_kw3_sh2_sw2_p0.json +40 -0
definitions/conv2d/conv2d_w8a8ch_kh1_kw1_sh1_sw1_dh1_dw1_p0.json
CHANGED
|
@@ -110,12 +110,12 @@
|
|
| 110 |
"H_out",
|
| 111 |
"W_out"
|
| 112 |
],
|
| 113 |
-
"dtype": "
|
| 114 |
}
|
| 115 |
},
|
| 116 |
"constraints": [
|
| 117 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 118 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 119 |
],
|
| 120 |
-
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scale, weight_scales):\n N, Cin, H, W = input.shape\n Cout = weight.shape[0]\n Kh, Kw = 1, 1\n Sh, Sw = 1, 1\n Dh, Dw = 1, 1\n Ph, Pw = 0, 0\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)\n acc = np.zeros((N, Cout, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += np.einsum('ncHW,oc->noHW', patch, w64[:, :, kh, kw])\n scale = input_scale * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return
|
| 121 |
}
|
|
|
|
| 110 |
"H_out",
|
| 111 |
"W_out"
|
| 112 |
],
|
| 113 |
+
"dtype": "float32"
|
| 114 |
}
|
| 115 |
},
|
| 116 |
"constraints": [
|
| 117 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 118 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 119 |
],
|
| 120 |
+
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scale, weight_scales):\n N, Cin, H, W = input.shape\n Cout = weight.shape[0]\n Kh, Kw = 1, 1\n Sh, Sw = 1, 1\n Dh, Dw = 1, 1\n Ph, Pw = 0, 0\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)\n acc = np.zeros((N, Cout, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += np.einsum('ncHW,oc->noHW', patch, w64[:, :, kh, kw])\n scale = input_scale * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return sumfp.astype(np.float32)\n"
|
| 121 |
}
|
definitions/conv2d/conv2d_w8a8ch_kh1_kw1_sh2_sw2_dh1_dw1_p0.json
CHANGED
|
@@ -110,12 +110,12 @@
|
|
| 110 |
"H_out",
|
| 111 |
"W_out"
|
| 112 |
],
|
| 113 |
-
"dtype": "
|
| 114 |
}
|
| 115 |
},
|
| 116 |
"constraints": [
|
| 117 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 118 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 119 |
],
|
| 120 |
-
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scale, weight_scales):\n N, Cin, H, W = input.shape\n Cout = weight.shape[0]\n Kh, Kw = 1, 1\n Sh, Sw = 2, 2\n Dh, Dw = 1, 1\n Ph, Pw = 0, 0\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)\n acc = np.zeros((N, Cout, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += np.einsum('ncHW,oc->noHW', patch, w64[:, :, kh, kw])\n scale = input_scale * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return
|
| 121 |
}
|
|
|
|
| 110 |
"H_out",
|
| 111 |
"W_out"
|
| 112 |
],
|
| 113 |
+
"dtype": "float32"
|
| 114 |
}
|
| 115 |
},
|
| 116 |
"constraints": [
|
| 117 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 118 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 119 |
],
|
| 120 |
+
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scale, weight_scales):\n N, Cin, H, W = input.shape\n Cout = weight.shape[0]\n Kh, Kw = 1, 1\n Sh, Sw = 2, 2\n Dh, Dw = 1, 1\n Ph, Pw = 0, 0\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)\n acc = np.zeros((N, Cout, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += np.einsum('ncHW,oc->noHW', patch, w64[:, :, kh, kw])\n scale = input_scale * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return sumfp.astype(np.float32)\n"
|
| 121 |
}
|
definitions/conv2d/conv2d_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1.json
CHANGED
|
@@ -110,12 +110,12 @@
|
|
| 110 |
"H_out",
|
| 111 |
"W_out"
|
| 112 |
],
|
| 113 |
-
"dtype": "
|
| 114 |
}
|
| 115 |
},
|
| 116 |
"constraints": [
|
| 117 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 118 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 119 |
],
|
| 120 |
-
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scale, weight_scales):\n N, Cin, H, W = input.shape\n Cout = weight.shape[0]\n Kh, Kw = 3, 3\n Sh, Sw = 1, 1\n Dh, Dw = 1, 1\n Ph, Pw = 1, 1\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)\n acc = np.zeros((N, Cout, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += np.einsum('ncHW,oc->noHW', patch, w64[:, :, kh, kw])\n scale = input_scale * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return
|
| 121 |
}
|
|
|
|
| 110 |
"H_out",
|
| 111 |
"W_out"
|
| 112 |
],
|
| 113 |
+
"dtype": "float32"
|
| 114 |
}
|
| 115 |
},
|
| 116 |
"constraints": [
|
| 117 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 118 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 119 |
],
|
| 120 |
+
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scale, weight_scales):\n N, Cin, H, W = input.shape\n Cout = weight.shape[0]\n Kh, Kw = 3, 3\n Sh, Sw = 1, 1\n Dh, Dw = 1, 1\n Ph, Pw = 1, 1\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)\n acc = np.zeros((N, Cout, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += np.einsum('ncHW,oc->noHW', patch, w64[:, :, kh, kw])\n scale = input_scale * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return sumfp.astype(np.float32)\n"
|
| 121 |
}
|
definitions/conv2d/conv2d_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1.json
CHANGED
|
@@ -110,12 +110,12 @@
|
|
| 110 |
"H_out",
|
| 111 |
"W_out"
|
| 112 |
],
|
| 113 |
-
"dtype": "
|
| 114 |
}
|
| 115 |
},
|
| 116 |
"constraints": [
|
| 117 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 118 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 119 |
],
|
| 120 |
-
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scale, weight_scales):\n N, Cin, H, W = input.shape\n Cout = weight.shape[0]\n Kh, Kw = 3, 3\n Sh, Sw = 2, 2\n Dh, Dw = 1, 1\n Ph, Pw = 1, 1\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)\n acc = np.zeros((N, Cout, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += np.einsum('ncHW,oc->noHW', patch, w64[:, :, kh, kw])\n scale = input_scale * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return
|
| 121 |
}
|
|
|
|
| 110 |
"H_out",
|
| 111 |
"W_out"
|
| 112 |
],
|
| 113 |
+
"dtype": "float32"
|
| 114 |
}
|
| 115 |
},
|
| 116 |
"constraints": [
|
| 117 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 118 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 119 |
],
|
| 120 |
+
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scale, weight_scales):\n N, Cin, H, W = input.shape\n Cout = weight.shape[0]\n Kh, Kw = 3, 3\n Sh, Sw = 2, 2\n Dh, Dw = 1, 1\n Ph, Pw = 1, 1\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)\n acc = np.zeros((N, Cout, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += np.einsum('ncHW,oc->noHW', patch, w64[:, :, kh, kw])\n scale = input_scale * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return sumfp.astype(np.float32)\n"
|
| 121 |
}
|
definitions/conv2d/conv2d_w8a8ch_kh7_kw7_sh2_sw2_dh1_dw1_p3.json
CHANGED
|
@@ -110,12 +110,12 @@
|
|
| 110 |
"H_out",
|
| 111 |
"W_out"
|
| 112 |
],
|
| 113 |
-
"dtype": "
|
| 114 |
}
|
| 115 |
},
|
| 116 |
"constraints": [
|
| 117 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 118 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 119 |
],
|
| 120 |
-
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scale, weight_scales):\n N, Cin, H, W = input.shape\n Cout = weight.shape[0]\n Kh, Kw = 7, 7\n Sh, Sw = 2, 2\n Dh, Dw = 1, 1\n Ph, Pw = 3, 3\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)\n acc = np.zeros((N, Cout, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += np.einsum('ncHW,oc->noHW', patch, w64[:, :, kh, kw])\n scale = input_scale * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return
|
| 121 |
}
|
|
|
|
| 110 |
"H_out",
|
| 111 |
"W_out"
|
| 112 |
],
|
| 113 |
+
"dtype": "float32"
|
| 114 |
}
|
| 115 |
},
|
| 116 |
"constraints": [
|
| 117 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 118 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 119 |
],
|
| 120 |
+
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scale, weight_scales):\n N, Cin, H, W = input.shape\n Cout = weight.shape[0]\n Kh, Kw = 7, 7\n Sh, Sw = 2, 2\n Dh, Dw = 1, 1\n Ph, Pw = 3, 3\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)\n acc = np.zeros((N, Cout, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += np.einsum('ncHW,oc->noHW', patch, w64[:, :, kh, kw])\n scale = input_scale * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return sumfp.astype(np.float32)\n"
|
| 121 |
}
|
definitions/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1.json
CHANGED
|
@@ -113,12 +113,12 @@
|
|
| 113 |
"H_out",
|
| 114 |
"W_out"
|
| 115 |
],
|
| 116 |
-
"dtype": "
|
| 117 |
}
|
| 118 |
},
|
| 119 |
"constraints": [
|
| 120 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 121 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 122 |
],
|
| 123 |
-
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scales, weight_scales):\n N, C, H, W = input.shape\n Kh, Kw = 3, 3\n Sh, Sw = 1, 1\n Dh, Dw = 1, 1\n Ph, Pw = 1, 1\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)[:, 0, :, :]\n acc = np.zeros((N, C, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += patch * w64[:, kh, kw][np.newaxis, :, np.newaxis, np.newaxis]\n scale = input_scales.astype(np.float64) * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return
|
| 124 |
}
|
|
|
|
| 113 |
"H_out",
|
| 114 |
"W_out"
|
| 115 |
],
|
| 116 |
+
"dtype": "float32"
|
| 117 |
}
|
| 118 |
},
|
| 119 |
"constraints": [
|
| 120 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 121 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 122 |
],
|
| 123 |
+
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scales, weight_scales):\n N, C, H, W = input.shape\n Kh, Kw = 3, 3\n Sh, Sw = 1, 1\n Dh, Dw = 1, 1\n Ph, Pw = 1, 1\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)[:, 0, :, :]\n acc = np.zeros((N, C, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += patch * w64[:, kh, kw][np.newaxis, :, np.newaxis, np.newaxis]\n scale = input_scales.astype(np.float64) * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return sumfp.astype(np.float32)\n"
|
| 124 |
}
|
definitions/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1.json
CHANGED
|
@@ -113,12 +113,12 @@
|
|
| 113 |
"H_out",
|
| 114 |
"W_out"
|
| 115 |
],
|
| 116 |
-
"dtype": "
|
| 117 |
}
|
| 118 |
},
|
| 119 |
"constraints": [
|
| 120 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 121 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 122 |
],
|
| 123 |
-
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scales, weight_scales):\n N, C, H, W = input.shape\n Kh, Kw = 3, 3\n Sh, Sw = 2, 2\n Dh, Dw = 1, 1\n Ph, Pw = 1, 1\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)[:, 0, :, :]\n acc = np.zeros((N, C, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += patch * w64[:, kh, kw][np.newaxis, :, np.newaxis, np.newaxis]\n scale = input_scales.astype(np.float64) * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return
|
| 124 |
}
|
|
|
|
| 113 |
"H_out",
|
| 114 |
"W_out"
|
| 115 |
],
|
| 116 |
+
"dtype": "float32"
|
| 117 |
}
|
| 118 |
},
|
| 119 |
"constraints": [
|
| 120 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 121 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 122 |
],
|
| 123 |
+
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scales, weight_scales):\n N, C, H, W = input.shape\n Kh, Kw = 3, 3\n Sh, Sw = 2, 2\n Dh, Dw = 1, 1\n Ph, Pw = 1, 1\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)[:, 0, :, :]\n acc = np.zeros((N, C, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += patch * w64[:, kh, kw][np.newaxis, :, np.newaxis, np.newaxis]\n scale = input_scales.astype(np.float64) * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return sumfp.astype(np.float32)\n"
|
| 124 |
}
|
definitions/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh5_kw5_sh1_sw1_dh1_dw1_p2.json
CHANGED
|
@@ -113,12 +113,12 @@
|
|
| 113 |
"H_out",
|
| 114 |
"W_out"
|
| 115 |
],
|
| 116 |
-
"dtype": "
|
| 117 |
}
|
| 118 |
},
|
| 119 |
"constraints": [
|
| 120 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 121 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 122 |
],
|
| 123 |
-
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scales, weight_scales):\n N, C, H, W = input.shape\n Kh, Kw = 5, 5\n Sh, Sw = 1, 1\n Dh, Dw = 1, 1\n Ph, Pw = 2, 2\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)[:, 0, :, :]\n acc = np.zeros((N, C, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += patch * w64[:, kh, kw][np.newaxis, :, np.newaxis, np.newaxis]\n scale = input_scales.astype(np.float64) * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return
|
| 124 |
}
|
|
|
|
| 113 |
"H_out",
|
| 114 |
"W_out"
|
| 115 |
],
|
| 116 |
+
"dtype": "float32"
|
| 117 |
}
|
| 118 |
},
|
| 119 |
"constraints": [
|
| 120 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 121 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 122 |
],
|
| 123 |
+
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scales, weight_scales):\n N, C, H, W = input.shape\n Kh, Kw = 5, 5\n Sh, Sw = 1, 1\n Dh, Dw = 1, 1\n Ph, Pw = 2, 2\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)[:, 0, :, :]\n acc = np.zeros((N, C, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += patch * w64[:, kh, kw][np.newaxis, :, np.newaxis, np.newaxis]\n scale = input_scales.astype(np.float64) * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return sumfp.astype(np.float32)\n"
|
| 124 |
}
|
definitions/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh5_kw5_sh2_sw2_dh1_dw1_p2.json
CHANGED
|
@@ -113,12 +113,12 @@
|
|
| 113 |
"H_out",
|
| 114 |
"W_out"
|
| 115 |
],
|
| 116 |
-
"dtype": "
|
| 117 |
}
|
| 118 |
},
|
| 119 |
"constraints": [
|
| 120 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 121 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 122 |
],
|
| 123 |
-
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scales, weight_scales):\n N, C, H, W = input.shape\n Kh, Kw = 5, 5\n Sh, Sw = 2, 2\n Dh, Dw = 1, 1\n Ph, Pw = 2, 2\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)[:, 0, :, :]\n acc = np.zeros((N, C, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += patch * w64[:, kh, kw][np.newaxis, :, np.newaxis, np.newaxis]\n scale = input_scales.astype(np.float64) * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return
|
| 124 |
}
|
|
|
|
| 113 |
"H_out",
|
| 114 |
"W_out"
|
| 115 |
],
|
| 116 |
+
"dtype": "float32"
|
| 117 |
}
|
| 118 |
},
|
| 119 |
"constraints": [
|
| 120 |
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 121 |
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 122 |
],
|
| 123 |
+
"reference": "import numpy as np\n\ndef run(input, weight, bias, input_scales, weight_scales):\n N, C, H, W = input.shape\n Kh, Kw = 5, 5\n Sh, Sw = 2, 2\n Dh, Dw = 1, 1\n Ph, Pw = 2, 2\n Hout = (H + 2 * Ph - Dh * (Kh - 1) - 1) // Sh + 1\n Wout = (W + 2 * Pw - Dw * (Kw - 1) - 1) // Sw + 1\n xp = np.pad(input.astype(np.int64), ((0, 0), (0, 0), (Ph, Ph), (Pw, Pw)))\n w64 = weight.astype(np.int64)[:, 0, :, :]\n acc = np.zeros((N, C, Hout, Wout), dtype=np.int64)\n for kh in range(Kh):\n for kw in range(Kw):\n patch = xp[:, :, kh * Dh: kh * Dh + Sh * Hout: Sh,\n kw * Dw: kw * Dw + Sw * Wout: Sw]\n acc += patch * w64[:, kh, kw][np.newaxis, :, np.newaxis, np.newaxis]\n scale = input_scales.astype(np.float64) * weight_scales.astype(np.float64)\n sumfp = acc.astype(np.float64) * scale[np.newaxis, :, np.newaxis, np.newaxis]\n sumfp += bias.astype(np.float64)[np.newaxis, :, np.newaxis, np.newaxis]\n return sumfp.astype(np.float32)\n"
|
| 124 |
}
|
definitions/gemm/gemm_w8a8ch_n1000_k1280.json
CHANGED
|
@@ -52,9 +52,9 @@
|
|
| 52 |
"M",
|
| 53 |
"N"
|
| 54 |
],
|
| 55 |
-
"dtype": "
|
| 56 |
}
|
| 57 |
},
|
| 58 |
"constraints": [],
|
| 59 |
-
"reference": "import numpy as np\ndef run(A, B, input_scale, weight_scales):\n acc = A.astype(np.int32) @ B.T.astype(np.int32)\n dequant = acc * (input_scale * weight_scales)[np.newaxis, :]\n return
|
| 60 |
}
|
|
|
|
| 52 |
"M",
|
| 53 |
"N"
|
| 54 |
],
|
| 55 |
+
"dtype": "float32"
|
| 56 |
}
|
| 57 |
},
|
| 58 |
"constraints": [],
|
| 59 |
+
"reference": "import numpy as np\ndef run(A, B, input_scale, weight_scales):\n acc = A.astype(np.int32) @ B.T.astype(np.int32)\n dequant = acc * (input_scale * weight_scales)[np.newaxis, :]\n return dequant.astype(np.float32)\n"
|
| 60 |
}
|
definitions/gemm/gemm_w8a8ch_n1000_k2048.json
CHANGED
|
@@ -52,9 +52,9 @@
|
|
| 52 |
"M",
|
| 53 |
"N"
|
| 54 |
],
|
| 55 |
-
"dtype": "
|
| 56 |
}
|
| 57 |
},
|
| 58 |
"constraints": [],
|
| 59 |
-
"reference": "import numpy as np\ndef run(A, B, input_scale, weight_scales):\n acc = A.astype(np.int32) @ B.T.astype(np.int32)\n dequant = acc * (input_scale * weight_scales)[np.newaxis, :]\n return
|
| 60 |
}
|
|
|
|
| 52 |
"M",
|
| 53 |
"N"
|
| 54 |
],
|
| 55 |
+
"dtype": "float32"
|
| 56 |
}
|
| 57 |
},
|
| 58 |
"constraints": [],
|
| 59 |
+
"reference": "import numpy as np\ndef run(A, B, input_scale, weight_scales):\n acc = A.astype(np.int32) @ B.T.astype(np.int32)\n dequant = acc * (input_scale * weight_scales)[np.newaxis, :]\n return dequant.astype(np.float32)\n"
|
| 60 |
}
|
definitions/gemm/gemm_w8a8ch_n1280_k960.json
CHANGED
|
@@ -52,9 +52,9 @@
|
|
| 52 |
"M",
|
| 53 |
"N"
|
| 54 |
],
|
| 55 |
-
"dtype": "
|
| 56 |
}
|
| 57 |
},
|
| 58 |
"constraints": [],
|
| 59 |
-
"reference": "import numpy as np\ndef run(A, B, input_scale, weight_scales):\n acc = A.astype(np.int32) @ B.T.astype(np.int32)\n dequant = acc * (input_scale * weight_scales)[np.newaxis, :]\n return
|
| 60 |
}
|
|
|
|
| 52 |
"M",
|
| 53 |
"N"
|
| 54 |
],
|
| 55 |
+
"dtype": "float32"
|
| 56 |
}
|
| 57 |
},
|
| 58 |
"constraints": [],
|
| 59 |
+
"reference": "import numpy as np\ndef run(A, B, input_scale, weight_scales):\n acc = A.astype(np.int32) @ B.T.astype(np.int32)\n dequant = acc * (input_scale * weight_scales)[np.newaxis, :]\n return dequant.astype(np.float32)\n"
|
| 60 |
}
|
solutions/ncnn/baseline-ncnn-arm/conv1d/conv1d_kw1_sw1_dw1_cout512_p0.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "baseline-ncnn-arm_conv1d_kw1_sw1_dw1_cout512_p0",
|
| 3 |
-
"definition": "conv1d_kw1_sw1_dw1_cout512_p0",
|
| 4 |
-
"dataset": "ncnn",
|
| 5 |
-
"author": "baseline-ncnn-arm",
|
| 6 |
-
"description": "ncnn::*_arm baseline for conv1d_kw1_sw1_dw1_cout512_p0. binding.cpp bakes constexpr params and implements armbench_entry_conv1d with void* ncnn::Mat ABI; kernel.cpp delegates to libncnn.a. Timing baseline for speedup computation.",
|
| 7 |
-
"spec": {
|
| 8 |
-
"language": "cpp",
|
| 9 |
-
"target_hardware": [
|
| 10 |
-
"graviton3",
|
| 11 |
-
"aarch64-sve",
|
| 12 |
-
"graviton4",
|
| 13 |
-
"aarch64-sve2"
|
| 14 |
-
],
|
| 15 |
-
"entry_point": "binding.cpp::armbench_entry_conv1d",
|
| 16 |
-
"dependencies": [],
|
| 17 |
-
"isa_features": [],
|
| 18 |
-
"compile_flags": [
|
| 19 |
-
"-O3",
|
| 20 |
-
"-std=c++17"
|
| 21 |
-
],
|
| 22 |
-
"link_flags": [
|
| 23 |
-
"-fopenmp"
|
| 24 |
-
]
|
| 25 |
-
},
|
| 26 |
-
"sources": [
|
| 27 |
-
{
|
| 28 |
-
"path": "conv1d.h",
|
| 29 |
-
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv1d baseline.\n// Called by armbench_entry_conv1d (binding.cpp); implemented by kernel.cpp.\n// Input/output are 2D ncnn::Mats (w=seq_len, h=channels).\n// num_output is encoded in top_blob.h (pre-allocated by binding.cpp).\nnamespace ncnn {\nint convolution1d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int stride_w, int dilation_w,\n int activation_type, const Mat& activation_params,\n const Option& opt);\n}\n"
|
| 30 |
-
},
|
| 31 |
-
{
|
| 32 |
-
"path": "binding.cpp",
|
| 33 |
-
"content": "#include \"conv1d.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int out_c = 512;\nconstexpr int kernel_w = 1;\nconstexpr int stride_w = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad_left = 0;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv1d(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* act_v, void* opt_v)\n{\n // bottom is 2D ncnn::Mat (w=seq_len, h=C_in) \u2014 created by NcnnDataset.\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& act = *reinterpret_cast<const ncnn::Mat*>(act_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // Pad the sequence (w) dimension symmetrically.\n ncnn::Mat bordered;\n ncnn::copy_make_border(bottom, bordered, 0, 0, pad_left, pad_left,\n ncnn::BORDER_CONSTANT, 0.f, opt);\n\n // Compute output sequence length.\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bordered.w - ext_kw) / stride_w + 1;\n\n // Pre-allocate top as 2D (w=out_w, h=out_c) so kernel reads out_c from top.h.\n top.create(out_w, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::convolution1d_kernel(\n bordered, top, weight, bias,\n kernel_w, stride_w, dilation_w,\n activation_type, act, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
-
},
|
| 35 |
-
{
|
| 36 |
-
"path": "kernel.cpp",
|
| 37 |
-
"content": "#include \"conv1d.h\"\n#include \"convolution1d_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::convolution1d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int stride_w, int dilation_w,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n // top_blob is pre-allocated 2D (w=out_w, h=out_c); read out_c from top_blob.h.\n const int num_output = top_blob.h;\n\n // Use heap allocation: stack-allocated ncnn ARM layers fail to populate\n // weight_data_tm in create_pipeline on AArch64 with -O3.\n Convolution1D_arm* conv = new Convolution1D_arm();\n conv->num_output = num_output;\n conv->kernel_w = kernel_w;\n conv->stride_w = stride_w;\n conv->dilation_w = dilation_w;\n conv->pad_left = 0;\n conv->pad_right = 0;\n conv->pad_value = 0.f;\n conv->bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n conv->weight_data_size = static_cast<int>(weight_data.total());\n conv->activation_type = activation_type;\n conv->activation_params = activation_params;\n conv->dynamic_weight = 0;\n conv->weight_data = const_cast<Mat&>(weight_data);\n if (conv->bias_term) conv->bias_data = const_cast<Mat&>(bias_data);\n\n if (conv->create_pipeline(opt) != 0) { delete conv; return -1; }\n\n Mat local_top;\n int ret = conv->forward(bottom_blob, local_top, opt);\n delete conv;\n if (ret != 0) return -1;\n\n // Copy from local_top to pre-allocated top_blob (both 2D, same shape).\n for (int c = 0; c < num_output; ++c)\n std::memcpy(top_blob.row(c), local_top.row(c), top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
-
}
|
| 39 |
-
]
|
| 40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
solutions/ncnn/baseline-ncnn-arm/conv1d/conv1d_kw3_sw1_dw1_cout512_p1.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "baseline-ncnn-arm_conv1d_kw3_sw1_dw1_cout512_p1",
|
| 3 |
-
"definition": "conv1d_kw3_sw1_dw1_cout512_p1",
|
| 4 |
-
"dataset": "ncnn",
|
| 5 |
-
"author": "baseline-ncnn-arm",
|
| 6 |
-
"description": "ncnn::*_arm baseline for conv1d_kw3_sw1_dw1_cout512_p1. binding.cpp bakes constexpr params and implements armbench_entry_conv1d with void* ncnn::Mat ABI; kernel.cpp delegates to libncnn.a. Timing baseline for speedup computation.",
|
| 7 |
-
"spec": {
|
| 8 |
-
"language": "cpp",
|
| 9 |
-
"target_hardware": [
|
| 10 |
-
"graviton3",
|
| 11 |
-
"aarch64-sve",
|
| 12 |
-
"graviton4",
|
| 13 |
-
"aarch64-sve2"
|
| 14 |
-
],
|
| 15 |
-
"entry_point": "binding.cpp::armbench_entry_conv1d",
|
| 16 |
-
"dependencies": [],
|
| 17 |
-
"isa_features": [],
|
| 18 |
-
"compile_flags": [
|
| 19 |
-
"-O3",
|
| 20 |
-
"-std=c++17"
|
| 21 |
-
],
|
| 22 |
-
"link_flags": [
|
| 23 |
-
"-fopenmp"
|
| 24 |
-
]
|
| 25 |
-
},
|
| 26 |
-
"sources": [
|
| 27 |
-
{
|
| 28 |
-
"path": "conv1d.h",
|
| 29 |
-
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv1d baseline.\n// Called by armbench_entry_conv1d (binding.cpp); implemented by kernel.cpp.\n// Input/output are 2D ncnn::Mats (w=seq_len, h=channels).\n// num_output is encoded in top_blob.h (pre-allocated by binding.cpp).\nnamespace ncnn {\nint convolution1d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int stride_w, int dilation_w,\n int activation_type, const Mat& activation_params,\n const Option& opt);\n}\n"
|
| 30 |
-
},
|
| 31 |
-
{
|
| 32 |
-
"path": "binding.cpp",
|
| 33 |
-
"content": "#include \"conv1d.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int out_c = 512;\nconstexpr int kernel_w = 3;\nconstexpr int stride_w = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad_left = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv1d(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* act_v, void* opt_v)\n{\n // bottom is 2D ncnn::Mat (w=seq_len, h=C_in) \u2014 created by NcnnDataset.\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& act = *reinterpret_cast<const ncnn::Mat*>(act_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // Pad the sequence (w) dimension symmetrically.\n ncnn::Mat bordered;\n ncnn::copy_make_border(bottom, bordered, 0, 0, pad_left, pad_left,\n ncnn::BORDER_CONSTANT, 0.f, opt);\n\n // Compute output sequence length.\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int out_w = (bordered.w - ext_kw) / stride_w + 1;\n\n // Pre-allocate top as 2D (w=out_w, h=out_c) so kernel reads out_c from top.h.\n top.create(out_w, out_c, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::convolution1d_kernel(\n bordered, top, weight, bias,\n kernel_w, stride_w, dilation_w,\n activation_type, act, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
-
},
|
| 35 |
-
{
|
| 36 |
-
"path": "kernel.cpp",
|
| 37 |
-
"content": "#include \"conv1d.h\"\n#include \"convolution1d_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::convolution1d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_w, int stride_w, int dilation_w,\n int activation_type, const Mat& activation_params,\n const Option& opt)\n{\n // top_blob is pre-allocated 2D (w=out_w, h=out_c); read out_c from top_blob.h.\n const int num_output = top_blob.h;\n\n // Use heap allocation: stack-allocated ncnn ARM layers fail to populate\n // weight_data_tm in create_pipeline on AArch64 with -O3.\n Convolution1D_arm* conv = new Convolution1D_arm();\n conv->num_output = num_output;\n conv->kernel_w = kernel_w;\n conv->stride_w = stride_w;\n conv->dilation_w = dilation_w;\n conv->pad_left = 0;\n conv->pad_right = 0;\n conv->pad_value = 0.f;\n conv->bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n conv->weight_data_size = static_cast<int>(weight_data.total());\n conv->activation_type = activation_type;\n conv->activation_params = activation_params;\n conv->dynamic_weight = 0;\n conv->weight_data = const_cast<Mat&>(weight_data);\n if (conv->bias_term) conv->bias_data = const_cast<Mat&>(bias_data);\n\n if (conv->create_pipeline(opt) != 0) { delete conv; return -1; }\n\n Mat local_top;\n int ret = conv->forward(bottom_blob, local_top, opt);\n delete conv;\n if (ret != 0) return -1;\n\n // Copy from local_top to pre-allocated top_blob (both 2D, same shape).\n for (int c = 0; c < num_output; ++c)\n std::memcpy(top_blob.row(c), local_top.row(c), top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
-
}
|
| 39 |
-
]
|
| 40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_fp32_kh1_kw1_sh1_sw1_dh1_dw1_p0.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_fp32_kh1_kw1_sh1_sw1_dh1_dw1_p0",
|
| 3 |
+
"definition": "conv2d_fp32_kh1_kw1_sh1_sw1_dh1_dw1_p0",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_fp32_kh1_kw1_sh1_sw1_dh1_dw1_p0. binding.cpp bakes constexpr params and implements armbench_entry_conv2d with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d baseline.\n// Called by armbench_entry_conv2d (binding.cpp); implemented by kernel.cpp.\n// num_output is encoded in top_blob.c (pre-allocated by binding.cpp).\nnamespace ncnn {\nint convolution2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n int activation_type,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 1;\nconstexpr int kernel_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int stride_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad_top = 0;\nconstexpr int pad_left = 0;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // C_out varies per workload (unlike Kh/Kw/.../pad, which are per-definition\n // consts) \u2014 derive it from the weight tensor instead of baking it.\n const int C_in = bottom.c;\n const int C_out = static_cast<int>(weight.total()) / (C_in * kernel_h * kernel_w);\n\n // Compute output spatial dims.\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad_top - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad_left - ext_kw) / stride_w + 1;\n\n // Pre-allocate top so kernel reads num_output from top.c.\n top.create(W_out, H_out, C_out, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::convolution2d_kernel(\n bottom, top, weight, bias,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad_top, pad_left,\n activation_type, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_contract.h\"\n#include \"convolution_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::convolution2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n int activation_type,\n const Option& opt)\n{\n const int num_output = top_blob.c; // pre-set by binding.cpp\n\n Convolution_arm conv;\n conv.num_output = num_output;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad_top; conv.pad_bottom = pad_top;\n conv.pad_left = pad_left; conv.pad_right = pad_left;\n conv.pad_value = 0.f;\n conv.bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n conv.int8_scale_term = 0;\n conv.activation_type = activation_type;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n if (conv.bias_term) conv.bias_data = const_cast<Mat&>(bias_data);\n\n if (conv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n // Copy from local_top to pre-allocated top_blob, channel by channel.\n for (int c = 0; c < num_output; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_fp32_kh1_kw1_sh2_sw2_dh1_dw1_p0.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_fp32_kh1_kw1_sh2_sw2_dh1_dw1_p0",
|
| 3 |
+
"definition": "conv2d_fp32_kh1_kw1_sh2_sw2_dh1_dw1_p0",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_fp32_kh1_kw1_sh2_sw2_dh1_dw1_p0. binding.cpp bakes constexpr params and implements armbench_entry_conv2d with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d baseline.\n// Called by armbench_entry_conv2d (binding.cpp); implemented by kernel.cpp.\n// num_output is encoded in top_blob.c (pre-allocated by binding.cpp).\nnamespace ncnn {\nint convolution2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n int activation_type,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 1;\nconstexpr int kernel_w = 1;\nconstexpr int stride_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad_top = 0;\nconstexpr int pad_left = 0;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // C_out varies per workload (unlike Kh/Kw/.../pad, which are per-definition\n // consts) \u2014 derive it from the weight tensor instead of baking it.\n const int C_in = bottom.c;\n const int C_out = static_cast<int>(weight.total()) / (C_in * kernel_h * kernel_w);\n\n // Compute output spatial dims.\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad_top - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad_left - ext_kw) / stride_w + 1;\n\n // Pre-allocate top so kernel reads num_output from top.c.\n top.create(W_out, H_out, C_out, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::convolution2d_kernel(\n bottom, top, weight, bias,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad_top, pad_left,\n activation_type, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_contract.h\"\n#include \"convolution_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::convolution2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n int activation_type,\n const Option& opt)\n{\n const int num_output = top_blob.c; // pre-set by binding.cpp\n\n Convolution_arm conv;\n conv.num_output = num_output;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad_top; conv.pad_bottom = pad_top;\n conv.pad_left = pad_left; conv.pad_right = pad_left;\n conv.pad_value = 0.f;\n conv.bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n conv.int8_scale_term = 0;\n conv.activation_type = activation_type;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n if (conv.bias_term) conv.bias_data = const_cast<Mat&>(bias_data);\n\n if (conv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n // Copy from local_top to pre-allocated top_blob, channel by channel.\n for (int c = 0; c < num_output; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1",
|
| 3 |
+
"definition": "conv2d_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1. binding.cpp bakes constexpr params and implements armbench_entry_conv2d with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d baseline.\n// Called by armbench_entry_conv2d (binding.cpp); implemented by kernel.cpp.\n// num_output is encoded in top_blob.c (pre-allocated by binding.cpp).\nnamespace ncnn {\nint convolution2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n int activation_type,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 3;\nconstexpr int kernel_w = 3;\nconstexpr int stride_h = 1;\nconstexpr int stride_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad_top = 1;\nconstexpr int pad_left = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // C_out varies per workload (unlike Kh/Kw/.../pad, which are per-definition\n // consts) \u2014 derive it from the weight tensor instead of baking it.\n const int C_in = bottom.c;\n const int C_out = static_cast<int>(weight.total()) / (C_in * kernel_h * kernel_w);\n\n // Compute output spatial dims.\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad_top - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad_left - ext_kw) / stride_w + 1;\n\n // Pre-allocate top so kernel reads num_output from top.c.\n top.create(W_out, H_out, C_out, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::convolution2d_kernel(\n bottom, top, weight, bias,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad_top, pad_left,\n activation_type, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_contract.h\"\n#include \"convolution_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::convolution2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n int activation_type,\n const Option& opt)\n{\n const int num_output = top_blob.c; // pre-set by binding.cpp\n\n Convolution_arm conv;\n conv.num_output = num_output;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad_top; conv.pad_bottom = pad_top;\n conv.pad_left = pad_left; conv.pad_right = pad_left;\n conv.pad_value = 0.f;\n conv.bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n conv.int8_scale_term = 0;\n conv.activation_type = activation_type;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n if (conv.bias_term) conv.bias_data = const_cast<Mat&>(bias_data);\n\n if (conv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n // Copy from local_top to pre-allocated top_blob, channel by channel.\n for (int c = 0; c < num_output; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1",
|
| 3 |
+
"definition": "conv2d_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1. binding.cpp bakes constexpr params and implements armbench_entry_conv2d with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d baseline.\n// Called by armbench_entry_conv2d (binding.cpp); implemented by kernel.cpp.\n// num_output is encoded in top_blob.c (pre-allocated by binding.cpp).\nnamespace ncnn {\nint convolution2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n int activation_type,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 3;\nconstexpr int kernel_w = 3;\nconstexpr int stride_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad_top = 1;\nconstexpr int pad_left = 1;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // C_out varies per workload (unlike Kh/Kw/.../pad, which are per-definition\n // consts) \u2014 derive it from the weight tensor instead of baking it.\n const int C_in = bottom.c;\n const int C_out = static_cast<int>(weight.total()) / (C_in * kernel_h * kernel_w);\n\n // Compute output spatial dims.\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad_top - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad_left - ext_kw) / stride_w + 1;\n\n // Pre-allocate top so kernel reads num_output from top.c.\n top.create(W_out, H_out, C_out, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::convolution2d_kernel(\n bottom, top, weight, bias,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad_top, pad_left,\n activation_type, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_contract.h\"\n#include \"convolution_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::convolution2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n int activation_type,\n const Option& opt)\n{\n const int num_output = top_blob.c; // pre-set by binding.cpp\n\n Convolution_arm conv;\n conv.num_output = num_output;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad_top; conv.pad_bottom = pad_top;\n conv.pad_left = pad_left; conv.pad_right = pad_left;\n conv.pad_value = 0.f;\n conv.bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n conv.int8_scale_term = 0;\n conv.activation_type = activation_type;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n if (conv.bias_term) conv.bias_data = const_cast<Mat&>(bias_data);\n\n if (conv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n // Copy from local_top to pre-allocated top_blob, channel by channel.\n for (int c = 0; c < num_output; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_fp32_kh7_kw7_sh2_sw2_dh1_dw1_p3.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_fp32_kh7_kw7_sh2_sw2_dh1_dw1_p3",
|
| 3 |
+
"definition": "conv2d_fp32_kh7_kw7_sh2_sw2_dh1_dw1_p3",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_fp32_kh7_kw7_sh2_sw2_dh1_dw1_p3. binding.cpp bakes constexpr params and implements armbench_entry_conv2d with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d baseline.\n// Called by armbench_entry_conv2d (binding.cpp); implemented by kernel.cpp.\n// num_output is encoded in top_blob.c (pre-allocated by binding.cpp).\nnamespace ncnn {\nint convolution2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n int activation_type,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 7;\nconstexpr int kernel_w = 7;\nconstexpr int stride_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad_top = 3;\nconstexpr int pad_left = 3;\nconstexpr int activation_type = 0;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // C_out varies per workload (unlike Kh/Kw/.../pad, which are per-definition\n // consts) \u2014 derive it from the weight tensor instead of baking it.\n const int C_in = bottom.c;\n const int C_out = static_cast<int>(weight.total()) / (C_in * kernel_h * kernel_w);\n\n // Compute output spatial dims.\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad_top - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad_left - ext_kw) / stride_w + 1;\n\n // Pre-allocate top so kernel reads num_output from top.c.\n top.create(W_out, H_out, C_out, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::convolution2d_kernel(\n bottom, top, weight, bias,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad_top, pad_left,\n activation_type, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_contract.h\"\n#include \"convolution_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::convolution2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n int activation_type,\n const Option& opt)\n{\n const int num_output = top_blob.c; // pre-set by binding.cpp\n\n Convolution_arm conv;\n conv.num_output = num_output;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad_top; conv.pad_bottom = pad_top;\n conv.pad_left = pad_left; conv.pad_right = pad_left;\n conv.pad_value = 0.f;\n conv.bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n conv.int8_scale_term = 0;\n conv.activation_type = activation_type;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n if (conv.bias_term) conv.bias_data = const_cast<Mat&>(bias_data);\n\n if (conv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n // Copy from local_top to pre-allocated top_blob, channel by channel.\n for (int c = 0; c < num_output; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_w8a8ch_kh1_kw1_sh1_sw1_dh1_dw1_p0.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_w8a8ch_kh1_kw1_sh1_sw1_dh1_dw1_p0",
|
| 3 |
+
"definition": "conv2d_w8a8ch_kh1_kw1_sh1_sw1_dh1_dw1_p0",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_w8a8ch_kh1_kw1_sh1_sw1_dh1_dw1_p0. binding.cpp bakes constexpr params and implements armbench_entry_conv2d with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_w8a8ch_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d w8a8ch (int8) baseline.\n// Called by armbench_entry_conv2d (binding.cpp); implemented by kernel.cpp.\n// num_output is encoded in top_blob.c (pre-allocated by binding.cpp, elemsize=1u \u2014\n// int8 output). input_scale is a per-definition-constant dequant scalar (see\n// binding.cpp.tmpl); weight_scales is a genuine runtime Mat (per-output-channel).\nnamespace ncnn {\nint convolution2d_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_w8a8ch_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 1;\nconstexpr int kernel_w = 1;\nconstexpr int stride_h = 1;\nconstexpr int stride_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad_top = 0;\nconstexpr int pad_left = 0;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* weight_scales_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& weight_scales = *reinterpret_cast<const ncnn::Mat*>(weight_scales_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // C_out varies per workload \u2014 derive from the weight tensor instead of baking it.\n const int C_in = bottom.c;\n const int C_out = static_cast<int>(weight.total()) / (C_in * kernel_h * kernel_w);\n\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad_top - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad_left - ext_kw) / stride_w + 1;\n\n // Dequantized float32 output \u2014 same elemsize as the fp32 baseline. w8a8ch\n // only quantizes inputs; the task doesn't require requantizing the result.\n top.create(W_out, H_out, C_out, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::convolution2d_w8a8ch_kernel(\n bottom, top, weight, bias, weight_scales,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad_top, pad_left,\n opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_w8a8ch_contract.h\"\n#include \"convolution_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nnamespace {\n// input_scale is constant across every workload for this definition (checked\n// at generation time), so it's baked here rather than plumbed through the ABI.\nconstexpr float input_scale = 0.02506;\n} // namespace\n\nint ncnn::convolution2d_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n const Option& opt)\n{\n const int num_output = top_blob.c; // pre-set by binding.cpp\n\n // ncnn's int8 scale fields are *quantization* multipliers (int8 =\n // round(float * scale)); this baseline's weight_scales/input_scale are\n // *dequantization* multipliers (real = int8 * scale) per the reference \u2014\n // invert them, or the output is silently wrong (not a crash).\n Mat weight_int8_scales;\n weight_int8_scales.create(num_output, (size_t)4u);\n if (weight_int8_scales.empty()) return -1;\n const float* ws = (const float*)weight_scales.data;\n for (int p = 0; p < num_output; ++p)\n weight_int8_scales[p] = 1.0f / ws[p];\n\n Mat bottom_int8_scales;\n bottom_int8_scales.create(1, (size_t)4u);\n if (bottom_int8_scales.empty()) return -1;\n bottom_int8_scales[0] = 1.0f / input_scale;\n\n Convolution_arm conv;\n conv.num_output = num_output;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad_top; conv.pad_bottom = pad_top;\n conv.pad_left = pad_left; conv.pad_right = pad_left;\n conv.pad_value = 0.f;\n conv.bias_term = 1;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n // Must stay truthy to enter the int8 input path, but <=100 so ncnn takes\n // the plain-dequantize branch (dequantize_from_int32: out = acc*scale+bias,\n // no rounding/clip) instead of requantizing to int8 \u2014 w8a8ch only quantizes\n // inputs, the task doesn't require a quantized output.\n conv.int8_scale_term = 2;\n conv.activation_type = 0;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n conv.bias_data = const_cast<Mat&>(bias_data);\n conv.weight_data_int8_scales = weight_int8_scales;\n conv.bottom_blob_int8_scales = bottom_int8_scales;\n\n if (conv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n // Copy from local_top to pre-allocated top_blob, channel by channel (never\n // bulk-memcpy \u2014 channels can have cstep alignment padding).\n for (int c = 0; c < num_output; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_w8a8ch_kh1_kw1_sh2_sw2_dh1_dw1_p0.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_w8a8ch_kh1_kw1_sh2_sw2_dh1_dw1_p0",
|
| 3 |
+
"definition": "conv2d_w8a8ch_kh1_kw1_sh2_sw2_dh1_dw1_p0",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_w8a8ch_kh1_kw1_sh2_sw2_dh1_dw1_p0. binding.cpp bakes constexpr params and implements armbench_entry_conv2d with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_w8a8ch_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d w8a8ch (int8) baseline.\n// Called by armbench_entry_conv2d (binding.cpp); implemented by kernel.cpp.\n// num_output is encoded in top_blob.c (pre-allocated by binding.cpp, elemsize=1u \u2014\n// int8 output). input_scale is a per-definition-constant dequant scalar (see\n// binding.cpp.tmpl); weight_scales is a genuine runtime Mat (per-output-channel).\nnamespace ncnn {\nint convolution2d_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_w8a8ch_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 1;\nconstexpr int kernel_w = 1;\nconstexpr int stride_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad_top = 0;\nconstexpr int pad_left = 0;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* weight_scales_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& weight_scales = *reinterpret_cast<const ncnn::Mat*>(weight_scales_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // C_out varies per workload \u2014 derive from the weight tensor instead of baking it.\n const int C_in = bottom.c;\n const int C_out = static_cast<int>(weight.total()) / (C_in * kernel_h * kernel_w);\n\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad_top - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad_left - ext_kw) / stride_w + 1;\n\n // Dequantized float32 output \u2014 same elemsize as the fp32 baseline. w8a8ch\n // only quantizes inputs; the task doesn't require requantizing the result.\n top.create(W_out, H_out, C_out, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::convolution2d_w8a8ch_kernel(\n bottom, top, weight, bias, weight_scales,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad_top, pad_left,\n opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_w8a8ch_contract.h\"\n#include \"convolution_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nnamespace {\n// input_scale is constant across every workload for this definition (checked\n// at generation time), so it's baked here rather than plumbed through the ABI.\nconstexpr float input_scale = 0.03331;\n} // namespace\n\nint ncnn::convolution2d_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n const Option& opt)\n{\n const int num_output = top_blob.c; // pre-set by binding.cpp\n\n // ncnn's int8 scale fields are *quantization* multipliers (int8 =\n // round(float * scale)); this baseline's weight_scales/input_scale are\n // *dequantization* multipliers (real = int8 * scale) per the reference \u2014\n // invert them, or the output is silently wrong (not a crash).\n Mat weight_int8_scales;\n weight_int8_scales.create(num_output, (size_t)4u);\n if (weight_int8_scales.empty()) return -1;\n const float* ws = (const float*)weight_scales.data;\n for (int p = 0; p < num_output; ++p)\n weight_int8_scales[p] = 1.0f / ws[p];\n\n Mat bottom_int8_scales;\n bottom_int8_scales.create(1, (size_t)4u);\n if (bottom_int8_scales.empty()) return -1;\n bottom_int8_scales[0] = 1.0f / input_scale;\n\n Convolution_arm conv;\n conv.num_output = num_output;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad_top; conv.pad_bottom = pad_top;\n conv.pad_left = pad_left; conv.pad_right = pad_left;\n conv.pad_value = 0.f;\n conv.bias_term = 1;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n // Must stay truthy to enter the int8 input path, but <=100 so ncnn takes\n // the plain-dequantize branch (dequantize_from_int32: out = acc*scale+bias,\n // no rounding/clip) instead of requantizing to int8 \u2014 w8a8ch only quantizes\n // inputs, the task doesn't require a quantized output.\n conv.int8_scale_term = 2;\n conv.activation_type = 0;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n conv.bias_data = const_cast<Mat&>(bias_data);\n conv.weight_data_int8_scales = weight_int8_scales;\n conv.bottom_blob_int8_scales = bottom_int8_scales;\n\n if (conv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n // Copy from local_top to pre-allocated top_blob, channel by channel (never\n // bulk-memcpy \u2014 channels can have cstep alignment padding).\n for (int c = 0; c < num_output; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1",
|
| 3 |
+
"definition": "conv2d_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1. binding.cpp bakes constexpr params and implements armbench_entry_conv2d with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_w8a8ch_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d w8a8ch (int8) baseline.\n// Called by armbench_entry_conv2d (binding.cpp); implemented by kernel.cpp.\n// num_output is encoded in top_blob.c (pre-allocated by binding.cpp, elemsize=1u \u2014\n// int8 output). input_scale is a per-definition-constant dequant scalar (see\n// binding.cpp.tmpl); weight_scales is a genuine runtime Mat (per-output-channel).\nnamespace ncnn {\nint convolution2d_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_w8a8ch_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 3;\nconstexpr int kernel_w = 3;\nconstexpr int stride_h = 1;\nconstexpr int stride_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad_top = 1;\nconstexpr int pad_left = 1;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* weight_scales_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& weight_scales = *reinterpret_cast<const ncnn::Mat*>(weight_scales_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // C_out varies per workload \u2014 derive from the weight tensor instead of baking it.\n const int C_in = bottom.c;\n const int C_out = static_cast<int>(weight.total()) / (C_in * kernel_h * kernel_w);\n\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad_top - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad_left - ext_kw) / stride_w + 1;\n\n // Dequantized float32 output \u2014 same elemsize as the fp32 baseline. w8a8ch\n // only quantizes inputs; the task doesn't require requantizing the result.\n top.create(W_out, H_out, C_out, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::convolution2d_w8a8ch_kernel(\n bottom, top, weight, bias, weight_scales,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad_top, pad_left,\n opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_w8a8ch_contract.h\"\n#include \"convolution_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nnamespace {\n// input_scale is constant across every workload for this definition (checked\n// at generation time), so it's baked here rather than plumbed through the ABI.\nconstexpr float input_scale = 0.02677;\n} // namespace\n\nint ncnn::convolution2d_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n const Option& opt)\n{\n const int num_output = top_blob.c; // pre-set by binding.cpp\n\n // ncnn's int8 scale fields are *quantization* multipliers (int8 =\n // round(float * scale)); this baseline's weight_scales/input_scale are\n // *dequantization* multipliers (real = int8 * scale) per the reference \u2014\n // invert them, or the output is silently wrong (not a crash).\n Mat weight_int8_scales;\n weight_int8_scales.create(num_output, (size_t)4u);\n if (weight_int8_scales.empty()) return -1;\n const float* ws = (const float*)weight_scales.data;\n for (int p = 0; p < num_output; ++p)\n weight_int8_scales[p] = 1.0f / ws[p];\n\n Mat bottom_int8_scales;\n bottom_int8_scales.create(1, (size_t)4u);\n if (bottom_int8_scales.empty()) return -1;\n bottom_int8_scales[0] = 1.0f / input_scale;\n\n Convolution_arm conv;\n conv.num_output = num_output;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad_top; conv.pad_bottom = pad_top;\n conv.pad_left = pad_left; conv.pad_right = pad_left;\n conv.pad_value = 0.f;\n conv.bias_term = 1;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n // Must stay truthy to enter the int8 input path, but <=100 so ncnn takes\n // the plain-dequantize branch (dequantize_from_int32: out = acc*scale+bias,\n // no rounding/clip) instead of requantizing to int8 \u2014 w8a8ch only quantizes\n // inputs, the task doesn't require a quantized output.\n conv.int8_scale_term = 2;\n conv.activation_type = 0;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n conv.bias_data = const_cast<Mat&>(bias_data);\n conv.weight_data_int8_scales = weight_int8_scales;\n conv.bottom_blob_int8_scales = bottom_int8_scales;\n\n if (conv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n // Copy from local_top to pre-allocated top_blob, channel by channel (never\n // bulk-memcpy \u2014 channels can have cstep alignment padding).\n for (int c = 0; c < num_output; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1",
|
| 3 |
+
"definition": "conv2d_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1. binding.cpp bakes constexpr params and implements armbench_entry_conv2d with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_w8a8ch_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d w8a8ch (int8) baseline.\n// Called by armbench_entry_conv2d (binding.cpp); implemented by kernel.cpp.\n// num_output is encoded in top_blob.c (pre-allocated by binding.cpp, elemsize=1u \u2014\n// int8 output). input_scale is a per-definition-constant dequant scalar (see\n// binding.cpp.tmpl); weight_scales is a genuine runtime Mat (per-output-channel).\nnamespace ncnn {\nint convolution2d_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_w8a8ch_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 3;\nconstexpr int kernel_w = 3;\nconstexpr int stride_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad_top = 1;\nconstexpr int pad_left = 1;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* weight_scales_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& weight_scales = *reinterpret_cast<const ncnn::Mat*>(weight_scales_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // C_out varies per workload \u2014 derive from the weight tensor instead of baking it.\n const int C_in = bottom.c;\n const int C_out = static_cast<int>(weight.total()) / (C_in * kernel_h * kernel_w);\n\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad_top - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad_left - ext_kw) / stride_w + 1;\n\n // Dequantized float32 output \u2014 same elemsize as the fp32 baseline. w8a8ch\n // only quantizes inputs; the task doesn't require requantizing the result.\n top.create(W_out, H_out, C_out, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::convolution2d_w8a8ch_kernel(\n bottom, top, weight, bias, weight_scales,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad_top, pad_left,\n opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_w8a8ch_contract.h\"\n#include \"convolution_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nnamespace {\n// input_scale is constant across every workload for this definition (checked\n// at generation time), so it's baked here rather than plumbed through the ABI.\nconstexpr float input_scale = 0.01686;\n} // namespace\n\nint ncnn::convolution2d_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n const Option& opt)\n{\n const int num_output = top_blob.c; // pre-set by binding.cpp\n\n // ncnn's int8 scale fields are *quantization* multipliers (int8 =\n // round(float * scale)); this baseline's weight_scales/input_scale are\n // *dequantization* multipliers (real = int8 * scale) per the reference \u2014\n // invert them, or the output is silently wrong (not a crash).\n Mat weight_int8_scales;\n weight_int8_scales.create(num_output, (size_t)4u);\n if (weight_int8_scales.empty()) return -1;\n const float* ws = (const float*)weight_scales.data;\n for (int p = 0; p < num_output; ++p)\n weight_int8_scales[p] = 1.0f / ws[p];\n\n Mat bottom_int8_scales;\n bottom_int8_scales.create(1, (size_t)4u);\n if (bottom_int8_scales.empty()) return -1;\n bottom_int8_scales[0] = 1.0f / input_scale;\n\n Convolution_arm conv;\n conv.num_output = num_output;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad_top; conv.pad_bottom = pad_top;\n conv.pad_left = pad_left; conv.pad_right = pad_left;\n conv.pad_value = 0.f;\n conv.bias_term = 1;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n // Must stay truthy to enter the int8 input path, but <=100 so ncnn takes\n // the plain-dequantize branch (dequantize_from_int32: out = acc*scale+bias,\n // no rounding/clip) instead of requantizing to int8 \u2014 w8a8ch only quantizes\n // inputs, the task doesn't require a quantized output.\n conv.int8_scale_term = 2;\n conv.activation_type = 0;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n conv.bias_data = const_cast<Mat&>(bias_data);\n conv.weight_data_int8_scales = weight_int8_scales;\n conv.bottom_blob_int8_scales = bottom_int8_scales;\n\n if (conv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n // Copy from local_top to pre-allocated top_blob, channel by channel (never\n // bulk-memcpy \u2014 channels can have cstep alignment padding).\n for (int c = 0; c < num_output; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_w8a8ch_kh7_kw7_sh2_sw2_dh1_dw1_p3.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_w8a8ch_kh7_kw7_sh2_sw2_dh1_dw1_p3",
|
| 3 |
+
"definition": "conv2d_w8a8ch_kh7_kw7_sh2_sw2_dh1_dw1_p3",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_w8a8ch_kh7_kw7_sh2_sw2_dh1_dw1_p3. binding.cpp bakes constexpr params and implements armbench_entry_conv2d with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_w8a8ch_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d w8a8ch (int8) baseline.\n// Called by armbench_entry_conv2d (binding.cpp); implemented by kernel.cpp.\n// num_output is encoded in top_blob.c (pre-allocated by binding.cpp, elemsize=1u \u2014\n// int8 output). input_scale is a per-definition-constant dequant scalar (see\n// binding.cpp.tmpl); weight_scales is a genuine runtime Mat (per-output-channel).\nnamespace ncnn {\nint convolution2d_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_w8a8ch_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 7;\nconstexpr int kernel_w = 7;\nconstexpr int stride_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad_top = 3;\nconstexpr int pad_left = 3;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* weight_scales_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& weight_scales = *reinterpret_cast<const ncnn::Mat*>(weight_scales_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // C_out varies per workload \u2014 derive from the weight tensor instead of baking it.\n const int C_in = bottom.c;\n const int C_out = static_cast<int>(weight.total()) / (C_in * kernel_h * kernel_w);\n\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad_top - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad_left - ext_kw) / stride_w + 1;\n\n // Dequantized float32 output \u2014 same elemsize as the fp32 baseline. w8a8ch\n // only quantizes inputs; the task doesn't require requantizing the result.\n top.create(W_out, H_out, C_out, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::convolution2d_w8a8ch_kernel(\n bottom, top, weight, bias, weight_scales,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad_top, pad_left,\n opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_w8a8ch_contract.h\"\n#include \"convolution_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nnamespace {\n// input_scale is constant across every workload for this definition (checked\n// at generation time), so it's baked here rather than plumbed through the ABI.\nconstexpr float input_scale = 0.01503;\n} // namespace\n\nint ncnn::convolution2d_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad_top, int pad_left,\n const Option& opt)\n{\n const int num_output = top_blob.c; // pre-set by binding.cpp\n\n // ncnn's int8 scale fields are *quantization* multipliers (int8 =\n // round(float * scale)); this baseline's weight_scales/input_scale are\n // *dequantization* multipliers (real = int8 * scale) per the reference \u2014\n // invert them, or the output is silently wrong (not a crash).\n Mat weight_int8_scales;\n weight_int8_scales.create(num_output, (size_t)4u);\n if (weight_int8_scales.empty()) return -1;\n const float* ws = (const float*)weight_scales.data;\n for (int p = 0; p < num_output; ++p)\n weight_int8_scales[p] = 1.0f / ws[p];\n\n Mat bottom_int8_scales;\n bottom_int8_scales.create(1, (size_t)4u);\n if (bottom_int8_scales.empty()) return -1;\n bottom_int8_scales[0] = 1.0f / input_scale;\n\n Convolution_arm conv;\n conv.num_output = num_output;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad_top; conv.pad_bottom = pad_top;\n conv.pad_left = pad_left; conv.pad_right = pad_left;\n conv.pad_value = 0.f;\n conv.bias_term = 1;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n // Must stay truthy to enter the int8 input path, but <=100 so ncnn takes\n // the plain-dequantize branch (dequantize_from_int32: out = acc*scale+bias,\n // no rounding/clip) instead of requantizing to int8 \u2014 w8a8ch only quantizes\n // inputs, the task doesn't require a quantized output.\n conv.int8_scale_term = 2;\n conv.activation_type = 0;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n conv.bias_data = const_cast<Mat&>(bias_data);\n conv.weight_data_int8_scales = weight_int8_scales;\n conv.bottom_blob_int8_scales = bottom_int8_scales;\n\n if (conv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n // Copy from local_top to pre-allocated top_blob, channel by channel (never\n // bulk-memcpy \u2014 channels can have cstep alignment padding).\n for (int c = 0; c < num_output; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_depthwise_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1",
|
| 3 |
+
"definition": "conv2d_depthwise_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_depthwise_fp32_kh3_kw3_sh1_sw1_dh1_dw1_p1. binding.cpp bakes constexpr params and implements armbench_entry_conv2d_depthwise with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d_depthwise",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_depthwise_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d_depthwise baseline.\n// Called by armbench_entry_conv2d_depthwise (binding.cpp); implemented by kernel.cpp.\n// num_output (== C, group == C) is encoded in top_blob.c (pre-allocated by binding.cpp).\nnamespace ncnn {\nint conv2d_depthwise_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_depthwise_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 3;\nconstexpr int kernel_w = 3;\nconstexpr int stride_h = 1;\nconstexpr int stride_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad = 1;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d_depthwise(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // Depthwise: num_output == input channels.\n const int C = bottom.c;\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad - ext_kw) / stride_w + 1;\n\n top.create(W_out, H_out, C, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::conv2d_depthwise_kernel(\n bottom, top, weight, bias,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_depthwise_contract.h\"\n#include \"convolutiondepthwise_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::conv2d_depthwise_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad,\n const Option& opt)\n{\n const int C = top_blob.c; // pre-set by binding.cpp (== input channels)\n\n // ncnn's pack1 convdw3x3s1_neon reads 12 floats per iteration (for 8 outputs),\n // potentially overreading past the last channel's allocation when the bordered blob\n // lands near a page boundary. Use pack4 (4-channel interleaved) when possible to\n // take the safe convdw3x3s1_pack4_neon path instead.\n if (C % 4 == 0) {\n Option opt4 = opt;\n opt4.use_packing_layout = true;\n\n Mat bottom_pack4;\n convert_packing(bottom_blob, bottom_pack4, 4, opt4);\n\n ConvolutionDepthWise_arm conv;\n conv.num_output = C;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad; conv.pad_bottom = pad;\n conv.pad_left = pad; conv.pad_right = pad;\n conv.pad_value = 0.f;\n conv.bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n conv.group = C;\n conv.int8_scale_term = 0;\n conv.activation_type = 0;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n if (conv.bias_term) conv.bias_data = const_cast<Mat&>(bias_data);\n\n if (conv.create_pipeline(opt4) != 0) return -1;\n Mat top_pack4;\n if (conv.forward(bottom_pack4, top_pack4, opt4) != 0) return -1;\n\n Mat local_top;\n convert_packing(top_pack4, local_top, 1, opt);\n\n for (int c = 0; c < C; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n }\n\n // Fallback pack1 path for C not divisible by 4.\n ConvolutionDepthWise_arm conv;\n conv.num_output = C;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad; conv.pad_bottom = pad;\n conv.pad_left = pad; conv.pad_right = pad;\n conv.pad_value = 0.f;\n conv.bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n conv.group = C;\n conv.int8_scale_term = 0;\n conv.activation_type = 0;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n if (conv.bias_term) conv.bias_data = const_cast<Mat&>(bias_data);\n\n if (conv.create_pipeline(opt) != 0) return -1;\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n for (int c = 0; c < C; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_depthwise_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1",
|
| 3 |
+
"definition": "conv2d_depthwise_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_depthwise_fp32_kh3_kw3_sh2_sw2_dh1_dw1_p1. binding.cpp bakes constexpr params and implements armbench_entry_conv2d_depthwise with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d_depthwise",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_depthwise_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d_depthwise baseline.\n// Called by armbench_entry_conv2d_depthwise (binding.cpp); implemented by kernel.cpp.\n// num_output (== C, group == C) is encoded in top_blob.c (pre-allocated by binding.cpp).\nnamespace ncnn {\nint conv2d_depthwise_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_depthwise_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 3;\nconstexpr int kernel_w = 3;\nconstexpr int stride_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad = 1;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d_depthwise(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // Depthwise: num_output == input channels.\n const int C = bottom.c;\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad - ext_kw) / stride_w + 1;\n\n top.create(W_out, H_out, C, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::conv2d_depthwise_kernel(\n bottom, top, weight, bias,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_depthwise_contract.h\"\n#include \"convolutiondepthwise_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::conv2d_depthwise_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad,\n const Option& opt)\n{\n const int C = top_blob.c; // pre-set by binding.cpp (== input channels)\n\n // ncnn's pack1 convdw3x3s1_neon reads 12 floats per iteration (for 8 outputs),\n // potentially overreading past the last channel's allocation when the bordered blob\n // lands near a page boundary. Use pack4 (4-channel interleaved) when possible to\n // take the safe convdw3x3s1_pack4_neon path instead.\n if (C % 4 == 0) {\n Option opt4 = opt;\n opt4.use_packing_layout = true;\n\n Mat bottom_pack4;\n convert_packing(bottom_blob, bottom_pack4, 4, opt4);\n\n ConvolutionDepthWise_arm conv;\n conv.num_output = C;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad; conv.pad_bottom = pad;\n conv.pad_left = pad; conv.pad_right = pad;\n conv.pad_value = 0.f;\n conv.bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n conv.group = C;\n conv.int8_scale_term = 0;\n conv.activation_type = 0;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n if (conv.bias_term) conv.bias_data = const_cast<Mat&>(bias_data);\n\n if (conv.create_pipeline(opt4) != 0) return -1;\n Mat top_pack4;\n if (conv.forward(bottom_pack4, top_pack4, opt4) != 0) return -1;\n\n Mat local_top;\n convert_packing(top_pack4, local_top, 1, opt);\n\n for (int c = 0; c < C; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n }\n\n // Fallback pack1 path for C not divisible by 4.\n ConvolutionDepthWise_arm conv;\n conv.num_output = C;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad; conv.pad_bottom = pad;\n conv.pad_left = pad; conv.pad_right = pad;\n conv.pad_value = 0.f;\n conv.bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n conv.group = C;\n conv.int8_scale_term = 0;\n conv.activation_type = 0;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n if (conv.bias_term) conv.bias_data = const_cast<Mat&>(bias_data);\n\n if (conv.create_pipeline(opt) != 0) return -1;\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n for (int c = 0; c < C; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_fp32_kh5_kw5_sh1_sw1_dh1_dw1_p2.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_depthwise_fp32_kh5_kw5_sh1_sw1_dh1_dw1_p2",
|
| 3 |
+
"definition": "conv2d_depthwise_fp32_kh5_kw5_sh1_sw1_dh1_dw1_p2",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_depthwise_fp32_kh5_kw5_sh1_sw1_dh1_dw1_p2. binding.cpp bakes constexpr params and implements armbench_entry_conv2d_depthwise with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d_depthwise",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_depthwise_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d_depthwise baseline.\n// Called by armbench_entry_conv2d_depthwise (binding.cpp); implemented by kernel.cpp.\n// num_output (== C, group == C) is encoded in top_blob.c (pre-allocated by binding.cpp).\nnamespace ncnn {\nint conv2d_depthwise_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_depthwise_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 5;\nconstexpr int kernel_w = 5;\nconstexpr int stride_h = 1;\nconstexpr int stride_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad = 2;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d_depthwise(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // Depthwise: num_output == input channels.\n const int C = bottom.c;\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad - ext_kw) / stride_w + 1;\n\n top.create(W_out, H_out, C, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::conv2d_depthwise_kernel(\n bottom, top, weight, bias,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_depthwise_contract.h\"\n#include \"convolutiondepthwise_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::conv2d_depthwise_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad,\n const Option& opt)\n{\n const int C = top_blob.c; // pre-set by binding.cpp (== input channels)\n\n // ncnn's pack1 convdw3x3s1_neon reads 12 floats per iteration (for 8 outputs),\n // potentially overreading past the last channel's allocation when the bordered blob\n // lands near a page boundary. Use pack4 (4-channel interleaved) when possible to\n // take the safe convdw3x3s1_pack4_neon path instead.\n if (C % 4 == 0) {\n Option opt4 = opt;\n opt4.use_packing_layout = true;\n\n Mat bottom_pack4;\n convert_packing(bottom_blob, bottom_pack4, 4, opt4);\n\n ConvolutionDepthWise_arm conv;\n conv.num_output = C;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad; conv.pad_bottom = pad;\n conv.pad_left = pad; conv.pad_right = pad;\n conv.pad_value = 0.f;\n conv.bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n conv.group = C;\n conv.int8_scale_term = 0;\n conv.activation_type = 0;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n if (conv.bias_term) conv.bias_data = const_cast<Mat&>(bias_data);\n\n if (conv.create_pipeline(opt4) != 0) return -1;\n Mat top_pack4;\n if (conv.forward(bottom_pack4, top_pack4, opt4) != 0) return -1;\n\n Mat local_top;\n convert_packing(top_pack4, local_top, 1, opt);\n\n for (int c = 0; c < C; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n }\n\n // Fallback pack1 path for C not divisible by 4.\n ConvolutionDepthWise_arm conv;\n conv.num_output = C;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad; conv.pad_bottom = pad;\n conv.pad_left = pad; conv.pad_right = pad;\n conv.pad_value = 0.f;\n conv.bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n conv.group = C;\n conv.int8_scale_term = 0;\n conv.activation_type = 0;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n if (conv.bias_term) conv.bias_data = const_cast<Mat&>(bias_data);\n\n if (conv.create_pipeline(opt) != 0) return -1;\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n for (int c = 0; c < C; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_fp32_kh5_kw5_sh2_sw2_dh1_dw1_p2.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_depthwise_fp32_kh5_kw5_sh2_sw2_dh1_dw1_p2",
|
| 3 |
+
"definition": "conv2d_depthwise_fp32_kh5_kw5_sh2_sw2_dh1_dw1_p2",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_depthwise_fp32_kh5_kw5_sh2_sw2_dh1_dw1_p2. binding.cpp bakes constexpr params and implements armbench_entry_conv2d_depthwise with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d_depthwise",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_depthwise_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d_depthwise baseline.\n// Called by armbench_entry_conv2d_depthwise (binding.cpp); implemented by kernel.cpp.\n// num_output (== C, group == C) is encoded in top_blob.c (pre-allocated by binding.cpp).\nnamespace ncnn {\nint conv2d_depthwise_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_depthwise_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 5;\nconstexpr int kernel_w = 5;\nconstexpr int stride_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad = 2;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d_depthwise(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // Depthwise: num_output == input channels.\n const int C = bottom.c;\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad - ext_kw) / stride_w + 1;\n\n top.create(W_out, H_out, C, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::conv2d_depthwise_kernel(\n bottom, top, weight, bias,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_depthwise_contract.h\"\n#include \"convolutiondepthwise_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::conv2d_depthwise_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad,\n const Option& opt)\n{\n const int C = top_blob.c; // pre-set by binding.cpp (== input channels)\n\n // ncnn's pack1 convdw3x3s1_neon reads 12 floats per iteration (for 8 outputs),\n // potentially overreading past the last channel's allocation when the bordered blob\n // lands near a page boundary. Use pack4 (4-channel interleaved) when possible to\n // take the safe convdw3x3s1_pack4_neon path instead.\n if (C % 4 == 0) {\n Option opt4 = opt;\n opt4.use_packing_layout = true;\n\n Mat bottom_pack4;\n convert_packing(bottom_blob, bottom_pack4, 4, opt4);\n\n ConvolutionDepthWise_arm conv;\n conv.num_output = C;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad; conv.pad_bottom = pad;\n conv.pad_left = pad; conv.pad_right = pad;\n conv.pad_value = 0.f;\n conv.bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n conv.group = C;\n conv.int8_scale_term = 0;\n conv.activation_type = 0;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n if (conv.bias_term) conv.bias_data = const_cast<Mat&>(bias_data);\n\n if (conv.create_pipeline(opt4) != 0) return -1;\n Mat top_pack4;\n if (conv.forward(bottom_pack4, top_pack4, opt4) != 0) return -1;\n\n Mat local_top;\n convert_packing(top_pack4, local_top, 1, opt);\n\n for (int c = 0; c < C; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n }\n\n // Fallback pack1 path for C not divisible by 4.\n ConvolutionDepthWise_arm conv;\n conv.num_output = C;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad; conv.pad_bottom = pad;\n conv.pad_left = pad; conv.pad_right = pad;\n conv.pad_value = 0.f;\n conv.bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n conv.group = C;\n conv.int8_scale_term = 0;\n conv.activation_type = 0;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n if (conv.bias_term) conv.bias_data = const_cast<Mat&>(bias_data);\n\n if (conv.create_pipeline(opt) != 0) return -1;\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n for (int c = 0; c < C; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_depthwise_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1",
|
| 3 |
+
"definition": "conv2d_depthwise_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_depthwise_w8a8ch_kh3_kw3_sh1_sw1_dh1_dw1_p1. binding.cpp bakes constexpr params and implements armbench_entry_conv2d_depthwise with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d_depthwise",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_depthwise_w8a8ch_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d_depthwise w8a8ch (int8) baseline.\n// Called by armbench_entry_conv2d_depthwise (binding.cpp); implemented by kernel.cpp.\n// num_output (== C, group == C) is encoded in top_blob.c (pre-allocated by\n// binding.cpp, elemsize=1u \u2014 int8 output).\n//\n// Unlike conv2d's scalar input_scale, this op's input_scales is a genuine\n// per-channel (shape=[C]) runtime tensor \u2014 ConvolutionDepthWise_arm's int8\n// path expects bottom_blob_int8_scales sized `group`, not a single scalar\n// like plain Convolution_arm \u2014 so it's passed as a real Mat, not baked.\nnamespace ncnn {\nint conv2d_depthwise_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& input_scales, const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_depthwise_w8a8ch_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 3;\nconstexpr int kernel_w = 3;\nconstexpr int stride_h = 1;\nconstexpr int stride_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad = 1;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d_depthwise(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* input_scales_v, void* weight_scales_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& input_scales = *reinterpret_cast<const ncnn::Mat*>(input_scales_v);\n const auto& weight_scales = *reinterpret_cast<const ncnn::Mat*>(weight_scales_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // Depthwise: num_output == input channels.\n const int C = bottom.c;\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad - ext_kw) / stride_w + 1;\n\n // Dequantized float32 output \u2014 same elemsize as the fp32 baseline. w8a8ch\n // only quantizes inputs; the task doesn't require requantizing the result.\n top.create(W_out, H_out, C, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::conv2d_depthwise_w8a8ch_kernel(\n bottom, top, weight, bias, input_scales, weight_scales,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_depthwise_w8a8ch_contract.h\"\n#include \"convolutiondepthwise_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::conv2d_depthwise_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& input_scales, const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad,\n const Option& opt)\n{\n const int C = top_blob.c; // pre-set by binding.cpp (== input channels == group)\n\n // Unlike plain Convolution_arm (where bottom/top int8 scales are a single\n // per-tensor scalar), ConvolutionDepthWise_arm expects ALL THREE scale Mats\n // sized `group` (== C here). ncnn's fields are *quantization* multipliers\n // (int8 = round(float*scale)); this baseline's weight_scales/input_scales\n // are *dequantization* multipliers (real = int8*scale) \u2014 invert them.\n Mat weight_int8_scales;\n weight_int8_scales.create(C, (size_t)4u);\n if (weight_int8_scales.empty()) return -1;\n const float* ws = (const float*)weight_scales.data;\n for (int g = 0; g < C; ++g)\n weight_int8_scales[g] = 1.0f / ws[g];\n\n Mat bottom_int8_scales;\n bottom_int8_scales.create(C, (size_t)4u);\n if (bottom_int8_scales.empty()) return -1;\n const float* is_ = (const float*)input_scales.data;\n for (int g = 0; g < C; ++g)\n bottom_int8_scales[g] = 1.0f / is_[g];\n\n ConvolutionDepthWise_arm conv;\n conv.num_output = C;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad; conv.pad_bottom = pad;\n conv.pad_left = pad; conv.pad_right = pad;\n conv.pad_value = 0.f;\n conv.bias_term = 1;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n conv.group = C;\n // Must be exactly 1 or 101 (not 2/102) to select the per-channel (size=group)\n // weight-scale branch \u2014 {2,102} would instead load a single scalar weight\n // scale broadcast to every channel, wrong for our per-channel weight_scales.\n // 1 (not 101) additionally keeps ncnn on the plain-dequantize branch\n // (out = acc*scale+bias, no rounding/clip) instead of requantizing to int8 \u2014\n // w8a8ch only quantizes inputs, the task doesn't require a quantized output.\n conv.int8_scale_term = 1;\n conv.activation_type = 0;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n conv.bias_data = const_cast<Mat&>(bias_data);\n conv.weight_data_int8_scales = weight_int8_scales;\n conv.bottom_blob_int8_scales = bottom_int8_scales;\n\n if (conv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n for (int c = 0; c < C; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_depthwise_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1",
|
| 3 |
+
"definition": "conv2d_depthwise_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_depthwise_w8a8ch_kh3_kw3_sh2_sw2_dh1_dw1_p1. binding.cpp bakes constexpr params and implements armbench_entry_conv2d_depthwise with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d_depthwise",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_depthwise_w8a8ch_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d_depthwise w8a8ch (int8) baseline.\n// Called by armbench_entry_conv2d_depthwise (binding.cpp); implemented by kernel.cpp.\n// num_output (== C, group == C) is encoded in top_blob.c (pre-allocated by\n// binding.cpp, elemsize=1u \u2014 int8 output).\n//\n// Unlike conv2d's scalar input_scale, this op's input_scales is a genuine\n// per-channel (shape=[C]) runtime tensor \u2014 ConvolutionDepthWise_arm's int8\n// path expects bottom_blob_int8_scales sized `group`, not a single scalar\n// like plain Convolution_arm \u2014 so it's passed as a real Mat, not baked.\nnamespace ncnn {\nint conv2d_depthwise_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& input_scales, const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_depthwise_w8a8ch_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 3;\nconstexpr int kernel_w = 3;\nconstexpr int stride_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad = 1;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d_depthwise(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* input_scales_v, void* weight_scales_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& input_scales = *reinterpret_cast<const ncnn::Mat*>(input_scales_v);\n const auto& weight_scales = *reinterpret_cast<const ncnn::Mat*>(weight_scales_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // Depthwise: num_output == input channels.\n const int C = bottom.c;\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad - ext_kw) / stride_w + 1;\n\n // Dequantized float32 output \u2014 same elemsize as the fp32 baseline. w8a8ch\n // only quantizes inputs; the task doesn't require requantizing the result.\n top.create(W_out, H_out, C, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::conv2d_depthwise_w8a8ch_kernel(\n bottom, top, weight, bias, input_scales, weight_scales,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_depthwise_w8a8ch_contract.h\"\n#include \"convolutiondepthwise_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::conv2d_depthwise_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& input_scales, const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad,\n const Option& opt)\n{\n const int C = top_blob.c; // pre-set by binding.cpp (== input channels == group)\n\n // Unlike plain Convolution_arm (where bottom/top int8 scales are a single\n // per-tensor scalar), ConvolutionDepthWise_arm expects ALL THREE scale Mats\n // sized `group` (== C here). ncnn's fields are *quantization* multipliers\n // (int8 = round(float*scale)); this baseline's weight_scales/input_scales\n // are *dequantization* multipliers (real = int8*scale) \u2014 invert them.\n Mat weight_int8_scales;\n weight_int8_scales.create(C, (size_t)4u);\n if (weight_int8_scales.empty()) return -1;\n const float* ws = (const float*)weight_scales.data;\n for (int g = 0; g < C; ++g)\n weight_int8_scales[g] = 1.0f / ws[g];\n\n Mat bottom_int8_scales;\n bottom_int8_scales.create(C, (size_t)4u);\n if (bottom_int8_scales.empty()) return -1;\n const float* is_ = (const float*)input_scales.data;\n for (int g = 0; g < C; ++g)\n bottom_int8_scales[g] = 1.0f / is_[g];\n\n ConvolutionDepthWise_arm conv;\n conv.num_output = C;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad; conv.pad_bottom = pad;\n conv.pad_left = pad; conv.pad_right = pad;\n conv.pad_value = 0.f;\n conv.bias_term = 1;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n conv.group = C;\n // Must be exactly 1 or 101 (not 2/102) to select the per-channel (size=group)\n // weight-scale branch \u2014 {2,102} would instead load a single scalar weight\n // scale broadcast to every channel, wrong for our per-channel weight_scales.\n // 1 (not 101) additionally keeps ncnn on the plain-dequantize branch\n // (out = acc*scale+bias, no rounding/clip) instead of requantizing to int8 \u2014\n // w8a8ch only quantizes inputs, the task doesn't require a quantized output.\n conv.int8_scale_term = 1;\n conv.activation_type = 0;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n conv.bias_data = const_cast<Mat&>(bias_data);\n conv.weight_data_int8_scales = weight_int8_scales;\n conv.bottom_blob_int8_scales = bottom_int8_scales;\n\n if (conv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n for (int c = 0; c < C; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh5_kw5_sh1_sw1_dh1_dw1_p2.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_depthwise_w8a8ch_kh5_kw5_sh1_sw1_dh1_dw1_p2",
|
| 3 |
+
"definition": "conv2d_depthwise_w8a8ch_kh5_kw5_sh1_sw1_dh1_dw1_p2",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_depthwise_w8a8ch_kh5_kw5_sh1_sw1_dh1_dw1_p2. binding.cpp bakes constexpr params and implements armbench_entry_conv2d_depthwise with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d_depthwise",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_depthwise_w8a8ch_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d_depthwise w8a8ch (int8) baseline.\n// Called by armbench_entry_conv2d_depthwise (binding.cpp); implemented by kernel.cpp.\n// num_output (== C, group == C) is encoded in top_blob.c (pre-allocated by\n// binding.cpp, elemsize=1u \u2014 int8 output).\n//\n// Unlike conv2d's scalar input_scale, this op's input_scales is a genuine\n// per-channel (shape=[C]) runtime tensor \u2014 ConvolutionDepthWise_arm's int8\n// path expects bottom_blob_int8_scales sized `group`, not a single scalar\n// like plain Convolution_arm \u2014 so it's passed as a real Mat, not baked.\nnamespace ncnn {\nint conv2d_depthwise_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& input_scales, const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_depthwise_w8a8ch_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 5;\nconstexpr int kernel_w = 5;\nconstexpr int stride_h = 1;\nconstexpr int stride_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad = 2;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d_depthwise(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* input_scales_v, void* weight_scales_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& input_scales = *reinterpret_cast<const ncnn::Mat*>(input_scales_v);\n const auto& weight_scales = *reinterpret_cast<const ncnn::Mat*>(weight_scales_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // Depthwise: num_output == input channels.\n const int C = bottom.c;\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad - ext_kw) / stride_w + 1;\n\n // Dequantized float32 output \u2014 same elemsize as the fp32 baseline. w8a8ch\n // only quantizes inputs; the task doesn't require requantizing the result.\n top.create(W_out, H_out, C, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::conv2d_depthwise_w8a8ch_kernel(\n bottom, top, weight, bias, input_scales, weight_scales,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_depthwise_w8a8ch_contract.h\"\n#include \"convolutiondepthwise_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::conv2d_depthwise_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& input_scales, const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad,\n const Option& opt)\n{\n const int C = top_blob.c; // pre-set by binding.cpp (== input channels == group)\n\n // Unlike plain Convolution_arm (where bottom/top int8 scales are a single\n // per-tensor scalar), ConvolutionDepthWise_arm expects ALL THREE scale Mats\n // sized `group` (== C here). ncnn's fields are *quantization* multipliers\n // (int8 = round(float*scale)); this baseline's weight_scales/input_scales\n // are *dequantization* multipliers (real = int8*scale) \u2014 invert them.\n Mat weight_int8_scales;\n weight_int8_scales.create(C, (size_t)4u);\n if (weight_int8_scales.empty()) return -1;\n const float* ws = (const float*)weight_scales.data;\n for (int g = 0; g < C; ++g)\n weight_int8_scales[g] = 1.0f / ws[g];\n\n Mat bottom_int8_scales;\n bottom_int8_scales.create(C, (size_t)4u);\n if (bottom_int8_scales.empty()) return -1;\n const float* is_ = (const float*)input_scales.data;\n for (int g = 0; g < C; ++g)\n bottom_int8_scales[g] = 1.0f / is_[g];\n\n ConvolutionDepthWise_arm conv;\n conv.num_output = C;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad; conv.pad_bottom = pad;\n conv.pad_left = pad; conv.pad_right = pad;\n conv.pad_value = 0.f;\n conv.bias_term = 1;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n conv.group = C;\n // Must be exactly 1 or 101 (not 2/102) to select the per-channel (size=group)\n // weight-scale branch \u2014 {2,102} would instead load a single scalar weight\n // scale broadcast to every channel, wrong for our per-channel weight_scales.\n // 1 (not 101) additionally keeps ncnn on the plain-dequantize branch\n // (out = acc*scale+bias, no rounding/clip) instead of requantizing to int8 \u2014\n // w8a8ch only quantizes inputs, the task doesn't require a quantized output.\n conv.int8_scale_term = 1;\n conv.activation_type = 0;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n conv.bias_data = const_cast<Mat&>(bias_data);\n conv.weight_data_int8_scales = weight_int8_scales;\n conv.bottom_blob_int8_scales = bottom_int8_scales;\n\n if (conv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n for (int c = 0; c < C; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_w8a8ch_kh5_kw5_sh2_sw2_dh1_dw1_p2.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_depthwise_w8a8ch_kh5_kw5_sh2_sw2_dh1_dw1_p2",
|
| 3 |
+
"definition": "conv2d_depthwise_w8a8ch_kh5_kw5_sh2_sw2_dh1_dw1_p2",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for conv2d_depthwise_w8a8ch_kh5_kw5_sh2_sw2_dh1_dw1_p2. binding.cpp bakes constexpr params and implements armbench_entry_conv2d_depthwise with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_conv2d_depthwise",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "conv2d_depthwise_w8a8ch_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for conv2d_depthwise w8a8ch (int8) baseline.\n// Called by armbench_entry_conv2d_depthwise (binding.cpp); implemented by kernel.cpp.\n// num_output (== C, group == C) is encoded in top_blob.c (pre-allocated by\n// binding.cpp, elemsize=1u \u2014 int8 output).\n//\n// Unlike conv2d's scalar input_scale, this op's input_scales is a genuine\n// per-channel (shape=[C]) runtime tensor \u2014 ConvolutionDepthWise_arm's int8\n// path expects bottom_blob_int8_scales sized `group`, not a single scalar\n// like plain Convolution_arm \u2014 so it's passed as a real Mat, not baked.\nnamespace ncnn {\nint conv2d_depthwise_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& input_scales, const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"conv2d_depthwise_w8a8ch_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 5;\nconstexpr int kernel_w = 5;\nconstexpr int stride_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\nconstexpr int pad = 2;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_conv2d_depthwise(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* input_scales_v, void* weight_scales_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& input_scales = *reinterpret_cast<const ncnn::Mat*>(input_scales_v);\n const auto& weight_scales = *reinterpret_cast<const ncnn::Mat*>(weight_scales_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // Depthwise: num_output == input channels.\n const int C = bottom.c;\n const int ext_kh = dilation_h * (kernel_h - 1) + 1;\n const int ext_kw = dilation_w * (kernel_w - 1) + 1;\n const int H_out = (bottom.h + 2 * pad - ext_kh) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad - ext_kw) / stride_w + 1;\n\n // Dequantized float32 output \u2014 same elemsize as the fp32 baseline. w8a8ch\n // only quantizes inputs; the task doesn't require requantizing the result.\n top.create(W_out, H_out, C, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::conv2d_depthwise_w8a8ch_kernel(\n bottom, top, weight, bias, input_scales, weight_scales,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w,\n pad, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"conv2d_depthwise_w8a8ch_contract.h\"\n#include \"convolutiondepthwise_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::conv2d_depthwise_w8a8ch_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n const Mat& input_scales, const Mat& weight_scales,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n int pad,\n const Option& opt)\n{\n const int C = top_blob.c; // pre-set by binding.cpp (== input channels == group)\n\n // Unlike plain Convolution_arm (where bottom/top int8 scales are a single\n // per-tensor scalar), ConvolutionDepthWise_arm expects ALL THREE scale Mats\n // sized `group` (== C here). ncnn's fields are *quantization* multipliers\n // (int8 = round(float*scale)); this baseline's weight_scales/input_scales\n // are *dequantization* multipliers (real = int8*scale) \u2014 invert them.\n Mat weight_int8_scales;\n weight_int8_scales.create(C, (size_t)4u);\n if (weight_int8_scales.empty()) return -1;\n const float* ws = (const float*)weight_scales.data;\n for (int g = 0; g < C; ++g)\n weight_int8_scales[g] = 1.0f / ws[g];\n\n Mat bottom_int8_scales;\n bottom_int8_scales.create(C, (size_t)4u);\n if (bottom_int8_scales.empty()) return -1;\n const float* is_ = (const float*)input_scales.data;\n for (int g = 0; g < C; ++g)\n bottom_int8_scales[g] = 1.0f / is_[g];\n\n ConvolutionDepthWise_arm conv;\n conv.num_output = C;\n conv.kernel_h = kernel_h; conv.kernel_w = kernel_w;\n conv.stride_h = stride_h; conv.stride_w = stride_w;\n conv.dilation_h = dilation_h; conv.dilation_w = dilation_w;\n conv.pad_top = pad; conv.pad_bottom = pad;\n conv.pad_left = pad; conv.pad_right = pad;\n conv.pad_value = 0.f;\n conv.bias_term = 1;\n conv.weight_data_size = static_cast<int>(weight_data.total());\n conv.group = C;\n // Must be exactly 1 or 101 (not 2/102) to select the per-channel (size=group)\n // weight-scale branch \u2014 {2,102} would instead load a single scalar weight\n // scale broadcast to every channel, wrong for our per-channel weight_scales.\n // 1 (not 101) additionally keeps ncnn on the plain-dequantize branch\n // (out = acc*scale+bias, no rounding/clip) instead of requantizing to int8 \u2014\n // w8a8ch only quantizes inputs, the task doesn't require a quantized output.\n conv.int8_scale_term = 1;\n conv.activation_type = 0;\n conv.activation_params = Mat();\n conv.dynamic_weight = 0;\n conv.weight_data = const_cast<Mat&>(weight_data);\n conv.bias_data = const_cast<Mat&>(bias_data);\n conv.weight_data_int8_scales = weight_int8_scales;\n conv.bottom_blob_int8_scales = bottom_int8_scales;\n\n if (conv.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n if (conv.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n for (int c = 0; c < C; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh1_sw1_cout256.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "baseline-ncnn-arm_deconv2d_kh3_kw3_sh1_sw1_cout256",
|
| 3 |
-
"definition": "deconv2d_kh3_kw3_sh1_sw1_cout256",
|
| 4 |
-
"dataset": "ncnn",
|
| 5 |
-
"author": "baseline-ncnn-arm",
|
| 6 |
-
"description": "ncnn::*_arm baseline for deconv2d_kh3_kw3_sh1_sw1_cout256. binding.cpp bakes constexpr params and implements armbench_entry_deconv2d with void* ncnn::Mat ABI; kernel.cpp delegates to libncnn.a. Timing baseline for speedup computation.",
|
| 7 |
-
"spec": {
|
| 8 |
-
"language": "cpp",
|
| 9 |
-
"target_hardware": [
|
| 10 |
-
"graviton3",
|
| 11 |
-
"aarch64-sve",
|
| 12 |
-
"graviton4",
|
| 13 |
-
"aarch64-sve2"
|
| 14 |
-
],
|
| 15 |
-
"entry_point": "binding.cpp::armbench_entry_deconv2d",
|
| 16 |
-
"dependencies": [],
|
| 17 |
-
"isa_features": [],
|
| 18 |
-
"compile_flags": [
|
| 19 |
-
"-O3",
|
| 20 |
-
"-std=c++17"
|
| 21 |
-
],
|
| 22 |
-
"link_flags": [
|
| 23 |
-
"-fopenmp"
|
| 24 |
-
]
|
| 25 |
-
},
|
| 26 |
-
"sources": [
|
| 27 |
-
{
|
| 28 |
-
"path": "deconv2d.h",
|
| 29 |
-
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for deconv2d baseline (transposed conv2d).\n// Called by armbench_entry_deconv2d (binding.cpp); implemented by kernel.cpp.\n// num_output is encoded in top_blob.c (pre-allocated by binding.cpp).\n// No input/output padding \u2014 all deconv2d definitions have pad=0.\nnamespace ncnn {\nint deconv2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n const Option& opt);\n}\n"
|
| 30 |
-
},
|
| 31 |
-
{
|
| 32 |
-
"path": "binding.cpp",
|
| 33 |
-
"content": "#include \"deconv2d.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int num_output = 256;\nconstexpr int kernel_h = 3;\nconstexpr int kernel_w = 3;\nconstexpr int stride_h = 1;\nconstexpr int stride_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_deconv2d(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* act_v, void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // Standard transposed-conv output size with pad=0, output_pad=0.\n const int H_out = (bottom.h - 1) * stride_h + kernel_h;\n const int W_out = (bottom.w - 1) * stride_w + kernel_w;\n\n top.create(W_out, H_out, num_output, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::deconv2d_kernel(\n bottom, top, weight, bias,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
-
},
|
| 35 |
-
{
|
| 36 |
-
"path": "kernel.cpp",
|
| 37 |
-
"content": "#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::deconv2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n const Option& opt)\n{\n const int num_output = top_blob.c; // pre-set by binding.cpp\n\n // Use heap allocation: stack-allocated ncnn ARM layers fail to populate\n // weight_data_tm in create_pipeline on AArch64 with -O3.\n Deconvolution_arm* deconv = new Deconvolution_arm();\n deconv->num_output = num_output;\n deconv->kernel_h = kernel_h; deconv->kernel_w = kernel_w;\n deconv->stride_h = stride_h; deconv->stride_w = stride_w;\n deconv->dilation_h = dilation_h; deconv->dilation_w = dilation_w;\n deconv->pad_top = 0; deconv->pad_bottom = 0;\n deconv->pad_left = 0; deconv->pad_right = 0;\n deconv->output_pad_right = 0; deconv->output_pad_bottom = 0;\n deconv->bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n deconv->weight_data_size = static_cast<int>(weight_data.total());\n deconv->activation_type = 0;\n deconv->activation_params = Mat();\n deconv->dynamic_weight = 0;\n deconv->weight_data = const_cast<Mat&>(weight_data);\n if (deconv->bias_term) deconv->bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv->create_pipeline(opt) != 0) { delete deconv; return -1; }\n\n Mat local_top;\n int ret = deconv->forward(bottom_blob, local_top, opt);\n delete deconv;\n if (ret != 0) return -1;\n\n for (int c = 0; c < num_output; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
-
}
|
| 39 |
-
]
|
| 40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh2_sw2_cout256.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "baseline-ncnn-arm_deconv2d_kh3_kw3_sh2_sw2_cout256",
|
| 3 |
-
"definition": "deconv2d_kh3_kw3_sh2_sw2_cout256",
|
| 4 |
-
"dataset": "ncnn",
|
| 5 |
-
"author": "baseline-ncnn-arm",
|
| 6 |
-
"description": "ncnn::*_arm baseline for deconv2d_kh3_kw3_sh2_sw2_cout256. binding.cpp bakes constexpr params and implements armbench_entry_deconv2d with void* ncnn::Mat ABI; kernel.cpp delegates to libncnn.a. Timing baseline for speedup computation.",
|
| 7 |
-
"spec": {
|
| 8 |
-
"language": "cpp",
|
| 9 |
-
"target_hardware": [
|
| 10 |
-
"graviton3",
|
| 11 |
-
"aarch64-sve",
|
| 12 |
-
"graviton4",
|
| 13 |
-
"aarch64-sve2"
|
| 14 |
-
],
|
| 15 |
-
"entry_point": "binding.cpp::armbench_entry_deconv2d",
|
| 16 |
-
"dependencies": [],
|
| 17 |
-
"isa_features": [],
|
| 18 |
-
"compile_flags": [
|
| 19 |
-
"-O3",
|
| 20 |
-
"-std=c++17"
|
| 21 |
-
],
|
| 22 |
-
"link_flags": [
|
| 23 |
-
"-fopenmp"
|
| 24 |
-
]
|
| 25 |
-
},
|
| 26 |
-
"sources": [
|
| 27 |
-
{
|
| 28 |
-
"path": "deconv2d.h",
|
| 29 |
-
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for deconv2d baseline (transposed conv2d).\n// Called by armbench_entry_deconv2d (binding.cpp); implemented by kernel.cpp.\n// num_output is encoded in top_blob.c (pre-allocated by binding.cpp).\n// No input/output padding \u2014 all deconv2d definitions have pad=0.\nnamespace ncnn {\nint deconv2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n const Option& opt);\n}\n"
|
| 30 |
-
},
|
| 31 |
-
{
|
| 32 |
-
"path": "binding.cpp",
|
| 33 |
-
"content": "#include \"deconv2d.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int num_output = 256;\nconstexpr int kernel_h = 3;\nconstexpr int kernel_w = 3;\nconstexpr int stride_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_deconv2d(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* act_v, void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // Standard transposed-conv output size with pad=0, output_pad=0.\n const int H_out = (bottom.h - 1) * stride_h + kernel_h;\n const int W_out = (bottom.w - 1) * stride_w + kernel_w;\n\n top.create(W_out, H_out, num_output, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::deconv2d_kernel(\n bottom, top, weight, bias,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
-
},
|
| 35 |
-
{
|
| 36 |
-
"path": "kernel.cpp",
|
| 37 |
-
"content": "#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::deconv2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n const Option& opt)\n{\n const int num_output = top_blob.c; // pre-set by binding.cpp\n\n // Use heap allocation: stack-allocated ncnn ARM layers fail to populate\n // weight_data_tm in create_pipeline on AArch64 with -O3.\n Deconvolution_arm* deconv = new Deconvolution_arm();\n deconv->num_output = num_output;\n deconv->kernel_h = kernel_h; deconv->kernel_w = kernel_w;\n deconv->stride_h = stride_h; deconv->stride_w = stride_w;\n deconv->dilation_h = dilation_h; deconv->dilation_w = dilation_w;\n deconv->pad_top = 0; deconv->pad_bottom = 0;\n deconv->pad_left = 0; deconv->pad_right = 0;\n deconv->output_pad_right = 0; deconv->output_pad_bottom = 0;\n deconv->bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n deconv->weight_data_size = static_cast<int>(weight_data.total());\n deconv->activation_type = 0;\n deconv->activation_params = Mat();\n deconv->dynamic_weight = 0;\n deconv->weight_data = const_cast<Mat&>(weight_data);\n if (deconv->bias_term) deconv->bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv->create_pipeline(opt) != 0) { delete deconv; return -1; }\n\n Mat local_top;\n int ret = deconv->forward(bottom_blob, local_top, opt);\n delete deconv;\n if (ret != 0) return -1;\n\n for (int c = 0; c < num_output; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
-
}
|
| 39 |
-
]
|
| 40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh1_sw1_cout128.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "baseline-ncnn-arm_deconv2d_kh4_kw4_sh1_sw1_cout128",
|
| 3 |
-
"definition": "deconv2d_kh4_kw4_sh1_sw1_cout128",
|
| 4 |
-
"dataset": "ncnn",
|
| 5 |
-
"author": "baseline-ncnn-arm",
|
| 6 |
-
"description": "ncnn::*_arm baseline for deconv2d_kh4_kw4_sh1_sw1_cout128. binding.cpp bakes constexpr params and implements armbench_entry_deconv2d with void* ncnn::Mat ABI; kernel.cpp delegates to libncnn.a. Timing baseline for speedup computation.",
|
| 7 |
-
"spec": {
|
| 8 |
-
"language": "cpp",
|
| 9 |
-
"target_hardware": [
|
| 10 |
-
"graviton3",
|
| 11 |
-
"aarch64-sve",
|
| 12 |
-
"graviton4",
|
| 13 |
-
"aarch64-sve2"
|
| 14 |
-
],
|
| 15 |
-
"entry_point": "binding.cpp::armbench_entry_deconv2d",
|
| 16 |
-
"dependencies": [],
|
| 17 |
-
"isa_features": [],
|
| 18 |
-
"compile_flags": [
|
| 19 |
-
"-O3",
|
| 20 |
-
"-std=c++17"
|
| 21 |
-
],
|
| 22 |
-
"link_flags": [
|
| 23 |
-
"-fopenmp"
|
| 24 |
-
]
|
| 25 |
-
},
|
| 26 |
-
"sources": [
|
| 27 |
-
{
|
| 28 |
-
"path": "deconv2d.h",
|
| 29 |
-
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for deconv2d baseline (transposed conv2d).\n// Called by armbench_entry_deconv2d (binding.cpp); implemented by kernel.cpp.\n// num_output is encoded in top_blob.c (pre-allocated by binding.cpp).\n// No input/output padding \u2014 all deconv2d definitions have pad=0.\nnamespace ncnn {\nint deconv2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n const Option& opt);\n}\n"
|
| 30 |
-
},
|
| 31 |
-
{
|
| 32 |
-
"path": "binding.cpp",
|
| 33 |
-
"content": "#include \"deconv2d.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int num_output = 128;\nconstexpr int kernel_h = 4;\nconstexpr int kernel_w = 4;\nconstexpr int stride_h = 1;\nconstexpr int stride_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_deconv2d(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* act_v, void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // Standard transposed-conv output size with pad=0, output_pad=0.\n const int H_out = (bottom.h - 1) * stride_h + kernel_h;\n const int W_out = (bottom.w - 1) * stride_w + kernel_w;\n\n top.create(W_out, H_out, num_output, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::deconv2d_kernel(\n bottom, top, weight, bias,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
-
},
|
| 35 |
-
{
|
| 36 |
-
"path": "kernel.cpp",
|
| 37 |
-
"content": "#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::deconv2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n const Option& opt)\n{\n const int num_output = top_blob.c; // pre-set by binding.cpp\n\n // Use heap allocation: stack-allocated ncnn ARM layers fail to populate\n // weight_data_tm in create_pipeline on AArch64 with -O3.\n Deconvolution_arm* deconv = new Deconvolution_arm();\n deconv->num_output = num_output;\n deconv->kernel_h = kernel_h; deconv->kernel_w = kernel_w;\n deconv->stride_h = stride_h; deconv->stride_w = stride_w;\n deconv->dilation_h = dilation_h; deconv->dilation_w = dilation_w;\n deconv->pad_top = 0; deconv->pad_bottom = 0;\n deconv->pad_left = 0; deconv->pad_right = 0;\n deconv->output_pad_right = 0; deconv->output_pad_bottom = 0;\n deconv->bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n deconv->weight_data_size = static_cast<int>(weight_data.total());\n deconv->activation_type = 0;\n deconv->activation_params = Mat();\n deconv->dynamic_weight = 0;\n deconv->weight_data = const_cast<Mat&>(weight_data);\n if (deconv->bias_term) deconv->bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv->create_pipeline(opt) != 0) { delete deconv; return -1; }\n\n Mat local_top;\n int ret = deconv->forward(bottom_blob, local_top, opt);\n delete deconv;\n if (ret != 0) return -1;\n\n for (int c = 0; c < num_output; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
-
}
|
| 39 |
-
]
|
| 40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh2_sw2_cout128.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "baseline-ncnn-arm_deconv2d_kh4_kw4_sh2_sw2_cout128",
|
| 3 |
-
"definition": "deconv2d_kh4_kw4_sh2_sw2_cout128",
|
| 4 |
-
"dataset": "ncnn",
|
| 5 |
-
"author": "baseline-ncnn-arm",
|
| 6 |
-
"description": "ncnn::*_arm baseline for deconv2d_kh4_kw4_sh2_sw2_cout128. binding.cpp bakes constexpr params and implements armbench_entry_deconv2d with void* ncnn::Mat ABI; kernel.cpp delegates to libncnn.a. Timing baseline for speedup computation.",
|
| 7 |
-
"spec": {
|
| 8 |
-
"language": "cpp",
|
| 9 |
-
"target_hardware": [
|
| 10 |
-
"graviton3",
|
| 11 |
-
"aarch64-sve",
|
| 12 |
-
"graviton4",
|
| 13 |
-
"aarch64-sve2"
|
| 14 |
-
],
|
| 15 |
-
"entry_point": "binding.cpp::armbench_entry_deconv2d",
|
| 16 |
-
"dependencies": [],
|
| 17 |
-
"isa_features": [],
|
| 18 |
-
"compile_flags": [
|
| 19 |
-
"-O3",
|
| 20 |
-
"-std=c++17"
|
| 21 |
-
],
|
| 22 |
-
"link_flags": [
|
| 23 |
-
"-fopenmp"
|
| 24 |
-
]
|
| 25 |
-
},
|
| 26 |
-
"sources": [
|
| 27 |
-
{
|
| 28 |
-
"path": "deconv2d.h",
|
| 29 |
-
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for deconv2d baseline (transposed conv2d).\n// Called by armbench_entry_deconv2d (binding.cpp); implemented by kernel.cpp.\n// num_output is encoded in top_blob.c (pre-allocated by binding.cpp).\n// No input/output padding \u2014 all deconv2d definitions have pad=0.\nnamespace ncnn {\nint deconv2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n const Option& opt);\n}\n"
|
| 30 |
-
},
|
| 31 |
-
{
|
| 32 |
-
"path": "binding.cpp",
|
| 33 |
-
"content": "#include \"deconv2d.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int num_output = 128;\nconstexpr int kernel_h = 4;\nconstexpr int kernel_w = 4;\nconstexpr int stride_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_deconv2d(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* act_v, void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // Standard transposed-conv output size with pad=0, output_pad=0.\n const int H_out = (bottom.h - 1) * stride_h + kernel_h;\n const int W_out = (bottom.w - 1) * stride_w + kernel_w;\n\n top.create(W_out, H_out, num_output, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::deconv2d_kernel(\n bottom, top, weight, bias,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
-
},
|
| 35 |
-
{
|
| 36 |
-
"path": "kernel.cpp",
|
| 37 |
-
"content": "#include \"deconv2d.h\"\n#include \"deconvolution_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::deconv2d_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n const Option& opt)\n{\n const int num_output = top_blob.c; // pre-set by binding.cpp\n\n // Use heap allocation: stack-allocated ncnn ARM layers fail to populate\n // weight_data_tm in create_pipeline on AArch64 with -O3.\n Deconvolution_arm* deconv = new Deconvolution_arm();\n deconv->num_output = num_output;\n deconv->kernel_h = kernel_h; deconv->kernel_w = kernel_w;\n deconv->stride_h = stride_h; deconv->stride_w = stride_w;\n deconv->dilation_h = dilation_h; deconv->dilation_w = dilation_w;\n deconv->pad_top = 0; deconv->pad_bottom = 0;\n deconv->pad_left = 0; deconv->pad_right = 0;\n deconv->output_pad_right = 0; deconv->output_pad_bottom = 0;\n deconv->bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n deconv->weight_data_size = static_cast<int>(weight_data.total());\n deconv->activation_type = 0;\n deconv->activation_params = Mat();\n deconv->dynamic_weight = 0;\n deconv->weight_data = const_cast<Mat&>(weight_data);\n if (deconv->bias_term) deconv->bias_data = const_cast<Mat&>(bias_data);\n\n if (deconv->create_pipeline(opt) != 0) { delete deconv; return -1; }\n\n Mat local_top;\n int ret = deconv->forward(bottom_blob, local_top, opt);\n delete deconv;\n if (ret != 0) return -1;\n\n for (int c = 0; c < num_output; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
-
}
|
| 39 |
-
]
|
| 40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "baseline-ncnn-arm_deconv2d_depthwise_kh2_kw2_sh2_sw2",
|
| 3 |
-
"definition": "deconv2d_depthwise_kh2_kw2_sh2_sw2",
|
| 4 |
-
"dataset": "ncnn",
|
| 5 |
-
"author": "baseline-ncnn-arm",
|
| 6 |
-
"description": "ncnn::*_arm baseline for deconv2d_depthwise_kh2_kw2_sh2_sw2. binding.cpp bakes constexpr params and implements armbench_entry_deconv2d_depthwise with void* ncnn::Mat ABI; kernel.cpp delegates to libncnn.a. Timing baseline for speedup computation.",
|
| 7 |
-
"spec": {
|
| 8 |
-
"language": "cpp",
|
| 9 |
-
"target_hardware": [
|
| 10 |
-
"graviton3",
|
| 11 |
-
"aarch64-sve",
|
| 12 |
-
"graviton4",
|
| 13 |
-
"aarch64-sve2"
|
| 14 |
-
],
|
| 15 |
-
"entry_point": "binding.cpp::armbench_entry_deconv2d_depthwise",
|
| 16 |
-
"dependencies": [],
|
| 17 |
-
"isa_features": [],
|
| 18 |
-
"compile_flags": [
|
| 19 |
-
"-O3",
|
| 20 |
-
"-std=c++17"
|
| 21 |
-
],
|
| 22 |
-
"link_flags": [
|
| 23 |
-
"-fopenmp"
|
| 24 |
-
]
|
| 25 |
-
},
|
| 26 |
-
"sources": [
|
| 27 |
-
{
|
| 28 |
-
"path": "deconv2d_depthwise.h",
|
| 29 |
-
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for deconv2d_depthwise baseline (depthwise transposed conv2d).\n// Called by armbench_entry_deconv2d_depthwise (binding.cpp); implemented by kernel.cpp.\n// num_output (== C, group == C) is encoded in top_blob.c (pre-allocated by binding.cpp).\n// No input/output padding \u2014 all deconv2d_depthwise definitions have pad=0.\nnamespace ncnn {\nint deconv2d_depthwise_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n const Option& opt);\n}\n"
|
| 30 |
-
},
|
| 31 |
-
{
|
| 32 |
-
"path": "binding.cpp",
|
| 33 |
-
"content": "#include \"deconv2d_depthwise.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 2;\nconstexpr int kernel_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_deconv2d_depthwise(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* act_v, void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // Depthwise: num_output == input channels, pad=0, output_pad=0.\n const int C = bottom.c;\n const int H_out = (bottom.h - 1) * stride_h + kernel_h;\n const int W_out = (bottom.w - 1) * stride_w + kernel_w;\n\n top.create(W_out, H_out, C, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::deconv2d_depthwise_kernel(\n bottom, top, weight, bias,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
-
},
|
| 35 |
-
{
|
| 36 |
-
"path": "kernel.cpp",
|
| 37 |
-
"content": "#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::deconv2d_depthwise_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n const Option& opt)\n{\n const int C = top_blob.c; // pre-set by binding.cpp (== input channels)\n\n // Use heap allocation: stack-allocated ncnn ARM layers fail to populate\n // weight_data_tm in create_pipeline on AArch64 with -O3.\n DeconvolutionDepthWise_arm* dconv = new DeconvolutionDepthWise_arm();\n dconv->num_output = C;\n dconv->kernel_h = kernel_h; dconv->kernel_w = kernel_w;\n dconv->stride_h = stride_h; dconv->stride_w = stride_w;\n dconv->dilation_h = dilation_h; dconv->dilation_w = dilation_w;\n dconv->pad_top = 0; dconv->pad_bottom = 0;\n dconv->pad_left = 0; dconv->pad_right = 0;\n dconv->output_pad_right = 0; dconv->output_pad_bottom = 0;\n dconv->bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n dconv->weight_data_size = static_cast<int>(weight_data.total());\n dconv->group = C;\n dconv->activation_type = 0;\n dconv->activation_params = Mat();\n dconv->dynamic_weight = 0;\n dconv->weight_data = const_cast<Mat&>(weight_data);\n if (dconv->bias_term) dconv->bias_data = const_cast<Mat&>(bias_data);\n\n if (dconv->create_pipeline(opt) != 0) { delete dconv; return -1; }\n\n Mat local_top;\n int ret = dconv->forward(bottom_blob, local_top, opt);\n delete dconv;\n if (ret != 0) return -1;\n\n for (int c = 0; c < C; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
-
}
|
| 39 |
-
]
|
| 40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh3_kw3_sh1_sw1.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "baseline-ncnn-arm_deconv2d_depthwise_kh3_kw3_sh1_sw1",
|
| 3 |
-
"definition": "deconv2d_depthwise_kh3_kw3_sh1_sw1",
|
| 4 |
-
"dataset": "ncnn",
|
| 5 |
-
"author": "baseline-ncnn-arm",
|
| 6 |
-
"description": "ncnn::*_arm baseline for deconv2d_depthwise_kh3_kw3_sh1_sw1. binding.cpp bakes constexpr params and implements armbench_entry_deconv2d_depthwise with void* ncnn::Mat ABI; kernel.cpp delegates to libncnn.a. Timing baseline for speedup computation.",
|
| 7 |
-
"spec": {
|
| 8 |
-
"language": "cpp",
|
| 9 |
-
"target_hardware": [
|
| 10 |
-
"graviton3",
|
| 11 |
-
"aarch64-sve",
|
| 12 |
-
"graviton4",
|
| 13 |
-
"aarch64-sve2"
|
| 14 |
-
],
|
| 15 |
-
"entry_point": "binding.cpp::armbench_entry_deconv2d_depthwise",
|
| 16 |
-
"dependencies": [],
|
| 17 |
-
"isa_features": [],
|
| 18 |
-
"compile_flags": [
|
| 19 |
-
"-O3",
|
| 20 |
-
"-std=c++17"
|
| 21 |
-
],
|
| 22 |
-
"link_flags": [
|
| 23 |
-
"-fopenmp"
|
| 24 |
-
]
|
| 25 |
-
},
|
| 26 |
-
"sources": [
|
| 27 |
-
{
|
| 28 |
-
"path": "deconv2d_depthwise.h",
|
| 29 |
-
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for deconv2d_depthwise baseline (depthwise transposed conv2d).\n// Called by armbench_entry_deconv2d_depthwise (binding.cpp); implemented by kernel.cpp.\n// num_output (== C, group == C) is encoded in top_blob.c (pre-allocated by binding.cpp).\n// No input/output padding \u2014 all deconv2d_depthwise definitions have pad=0.\nnamespace ncnn {\nint deconv2d_depthwise_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n const Option& opt);\n}\n"
|
| 30 |
-
},
|
| 31 |
-
{
|
| 32 |
-
"path": "binding.cpp",
|
| 33 |
-
"content": "#include \"deconv2d_depthwise.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 3;\nconstexpr int kernel_w = 3;\nconstexpr int stride_h = 1;\nconstexpr int stride_w = 1;\nconstexpr int dilation_h = 1;\nconstexpr int dilation_w = 1;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_deconv2d_depthwise(\n void* bottom_v, void* top_v,\n void* weight_v, void* bias_v,\n void* act_v, void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& weight = *reinterpret_cast<const ncnn::Mat*>(weight_v);\n const auto& bias = *reinterpret_cast<const ncnn::Mat*>(bias_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // Depthwise: num_output == input channels, pad=0, output_pad=0.\n const int C = bottom.c;\n const int H_out = (bottom.h - 1) * stride_h + kernel_h;\n const int W_out = (bottom.w - 1) * stride_w + kernel_w;\n\n top.create(W_out, H_out, C, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::deconv2d_depthwise_kernel(\n bottom, top, weight, bias,\n kernel_h, kernel_w,\n stride_h, stride_w,\n dilation_h, dilation_w, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
-
},
|
| 35 |
-
{
|
| 36 |
-
"path": "kernel.cpp",
|
| 37 |
-
"content": "#include \"deconv2d_depthwise.h\"\n#include \"deconvolutiondepthwise_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::deconv2d_depthwise_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data, const Mat& bias_data,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int dilation_h, int dilation_w,\n const Option& opt)\n{\n const int C = top_blob.c; // pre-set by binding.cpp (== input channels)\n\n // Use heap allocation: stack-allocated ncnn ARM layers fail to populate\n // weight_data_tm in create_pipeline on AArch64 with -O3.\n DeconvolutionDepthWise_arm* dconv = new DeconvolutionDepthWise_arm();\n dconv->num_output = C;\n dconv->kernel_h = kernel_h; dconv->kernel_w = kernel_w;\n dconv->stride_h = stride_h; dconv->stride_w = stride_w;\n dconv->dilation_h = dilation_h; dconv->dilation_w = dilation_w;\n dconv->pad_top = 0; dconv->pad_bottom = 0;\n dconv->pad_left = 0; dconv->pad_right = 0;\n dconv->output_pad_right = 0; dconv->output_pad_bottom = 0;\n dconv->bias_term = (!bias_data.empty() && bias_data.total() > 0) ? 1 : 0;\n dconv->weight_data_size = static_cast<int>(weight_data.total());\n dconv->group = C;\n dconv->activation_type = 0;\n dconv->activation_params = Mat();\n dconv->dynamic_weight = 0;\n dconv->weight_data = const_cast<Mat&>(weight_data);\n if (dconv->bias_term) dconv->bias_data = const_cast<Mat&>(bias_data);\n\n if (dconv->create_pipeline(opt) != 0) { delete dconv; return -1; }\n\n Mat local_top;\n int ret = dconv->forward(bottom_blob, local_top, opt);\n delete dconv;\n if (ret != 0) return -1;\n\n for (int c = 0; c < C; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
-
}
|
| 39 |
-
]
|
| 40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
solutions/ncnn/baseline-ncnn-arm/gemm/gemm_fp32_n1000_k1280.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_gemm_fp32_n1000_k1280",
|
| 3 |
+
"definition": "gemm_fp32_n1000_k1280",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for gemm_fp32_n1000_k1280. binding.cpp bakes constexpr params and implements armbench_entry_gemm with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_gemm",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "gemm_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for gemm baseline (C = A @ B^T).\n// Called by armbench_entry_gemm (binding.cpp); implemented by kernel.cpp.\n// A is a genuine 2D Mat (w=K, h=M); B is flat 1D (N*K, ncnn InnerProduct\n// weight_data layout); top is pre-allocated 2D (w=N, h=M) by binding.cpp.\nnamespace ncnn {\nint gemm_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"gemm_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int N = 1000;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_gemm(\n void* A_v, void* top_v,\n void* B_v, void* opt_v)\n{\n const auto& A = *reinterpret_cast<const ncnn::Mat*>(A_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& B = *reinterpret_cast<const ncnn::Mat*>(B_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // A arrives as a genuine 2D Mat (w=K, h=M) \u2014 M (rows) varies per workload.\n const int M = A.h;\n\n top.create(N, M, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::gemm_kernel(A, top, B, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"gemm_contract.h\"\n#include \"innerproduct_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nnamespace {\nconstexpr int N = 1000;\nconstexpr int K = 1280;\n} // namespace\n\nint ncnn::gemm_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data,\n const Option& opt)\n{\n InnerProduct_arm ip;\n ip.num_output = N;\n ip.bias_term = 0;\n ip.weight_data_size = N * K;\n ip.int8_scale_term = 0;\n ip.activation_type = 0;\n ip.activation_params = Mat();\n // weight_data is flat (N*K), row-major with K contiguous \u2014 exactly the\n // layout InnerProduct_arm expects (reshape(K, N) done in create_pipeline).\n ip.weight_data = const_cast<Mat&>(weight_data);\n\n if (ip.create_pipeline(opt) != 0) return -1;\n\n // bottom_blob is a genuine 2D Mat (w=K, h=M) \u2014 InnerProduct_arm handles the\n // full (M,K)->(M,N) gemm in one forward() call when dims==2.\n Mat local_top;\n if (ip.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n const int M = top_blob.h;\n for (int m = 0; m < M; ++m)\n std::memcpy(top_blob.row(m), local_top.row(m), N * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/gemm/gemm_fp32_n1000_k2048.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_gemm_fp32_n1000_k2048",
|
| 3 |
+
"definition": "gemm_fp32_n1000_k2048",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for gemm_fp32_n1000_k2048. binding.cpp bakes constexpr params and implements armbench_entry_gemm with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_gemm",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "gemm_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for gemm baseline (C = A @ B^T).\n// Called by armbench_entry_gemm (binding.cpp); implemented by kernel.cpp.\n// A is a genuine 2D Mat (w=K, h=M); B is flat 1D (N*K, ncnn InnerProduct\n// weight_data layout); top is pre-allocated 2D (w=N, h=M) by binding.cpp.\nnamespace ncnn {\nint gemm_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"gemm_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int N = 1000;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_gemm(\n void* A_v, void* top_v,\n void* B_v, void* opt_v)\n{\n const auto& A = *reinterpret_cast<const ncnn::Mat*>(A_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& B = *reinterpret_cast<const ncnn::Mat*>(B_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // A arrives as a genuine 2D Mat (w=K, h=M) \u2014 M (rows) varies per workload.\n const int M = A.h;\n\n top.create(N, M, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::gemm_kernel(A, top, B, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"gemm_contract.h\"\n#include \"innerproduct_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nnamespace {\nconstexpr int N = 1000;\nconstexpr int K = 2048;\n} // namespace\n\nint ncnn::gemm_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data,\n const Option& opt)\n{\n InnerProduct_arm ip;\n ip.num_output = N;\n ip.bias_term = 0;\n ip.weight_data_size = N * K;\n ip.int8_scale_term = 0;\n ip.activation_type = 0;\n ip.activation_params = Mat();\n // weight_data is flat (N*K), row-major with K contiguous \u2014 exactly the\n // layout InnerProduct_arm expects (reshape(K, N) done in create_pipeline).\n ip.weight_data = const_cast<Mat&>(weight_data);\n\n if (ip.create_pipeline(opt) != 0) return -1;\n\n // bottom_blob is a genuine 2D Mat (w=K, h=M) \u2014 InnerProduct_arm handles the\n // full (M,K)->(M,N) gemm in one forward() call when dims==2.\n Mat local_top;\n if (ip.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n const int M = top_blob.h;\n for (int m = 0; m < M; ++m)\n std::memcpy(top_blob.row(m), local_top.row(m), N * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/gemm/gemm_fp32_n1280_k960.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_gemm_fp32_n1280_k960",
|
| 3 |
+
"definition": "gemm_fp32_n1280_k960",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for gemm_fp32_n1280_k960. binding.cpp bakes constexpr params and implements armbench_entry_gemm with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_gemm",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "gemm_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for gemm baseline (C = A @ B^T).\n// Called by armbench_entry_gemm (binding.cpp); implemented by kernel.cpp.\n// A is a genuine 2D Mat (w=K, h=M); B is flat 1D (N*K, ncnn InnerProduct\n// weight_data layout); top is pre-allocated 2D (w=N, h=M) by binding.cpp.\nnamespace ncnn {\nint gemm_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"gemm_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int N = 1280;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_gemm(\n void* A_v, void* top_v,\n void* B_v, void* opt_v)\n{\n const auto& A = *reinterpret_cast<const ncnn::Mat*>(A_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& B = *reinterpret_cast<const ncnn::Mat*>(B_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // A arrives as a genuine 2D Mat (w=K, h=M) \u2014 M (rows) varies per workload.\n const int M = A.h;\n\n top.create(N, M, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::gemm_kernel(A, top, B, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"gemm_contract.h\"\n#include \"innerproduct_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nnamespace {\nconstexpr int N = 1280;\nconstexpr int K = 960;\n} // namespace\n\nint ncnn::gemm_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data,\n const Option& opt)\n{\n InnerProduct_arm ip;\n ip.num_output = N;\n ip.bias_term = 0;\n ip.weight_data_size = N * K;\n ip.int8_scale_term = 0;\n ip.activation_type = 0;\n ip.activation_params = Mat();\n // weight_data is flat (N*K), row-major with K contiguous \u2014 exactly the\n // layout InnerProduct_arm expects (reshape(K, N) done in create_pipeline).\n ip.weight_data = const_cast<Mat&>(weight_data);\n\n if (ip.create_pipeline(opt) != 0) return -1;\n\n // bottom_blob is a genuine 2D Mat (w=K, h=M) \u2014 InnerProduct_arm handles the\n // full (M,K)->(M,N) gemm in one forward() call when dims==2.\n Mat local_top;\n if (ip.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n const int M = top_blob.h;\n for (int m = 0; m < M; ++m)\n std::memcpy(top_blob.row(m), local_top.row(m), N * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/gemm/gemm_fp32_n29_k800.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_gemm_fp32_n29_k800",
|
| 3 |
+
"definition": "gemm_fp32_n29_k800",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for gemm_fp32_n29_k800. binding.cpp bakes constexpr params and implements armbench_entry_gemm with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_gemm",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "gemm_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for gemm baseline (C = A @ B^T).\n// Called by armbench_entry_gemm (binding.cpp); implemented by kernel.cpp.\n// A is a genuine 2D Mat (w=K, h=M); B is flat 1D (N*K, ncnn InnerProduct\n// weight_data layout); top is pre-allocated 2D (w=N, h=M) by binding.cpp.\nnamespace ncnn {\nint gemm_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"gemm_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int N = 29;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_gemm(\n void* A_v, void* top_v,\n void* B_v, void* opt_v)\n{\n const auto& A = *reinterpret_cast<const ncnn::Mat*>(A_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& B = *reinterpret_cast<const ncnn::Mat*>(B_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // A arrives as a genuine 2D Mat (w=K, h=M) \u2014 M (rows) varies per workload.\n const int M = A.h;\n\n top.create(N, M, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::gemm_kernel(A, top, B, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"gemm_contract.h\"\n#include \"innerproduct_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nnamespace {\nconstexpr int N = 29;\nconstexpr int K = 800;\n} // namespace\n\nint ncnn::gemm_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Mat& weight_data,\n const Option& opt)\n{\n InnerProduct_arm ip;\n ip.num_output = N;\n ip.bias_term = 0;\n ip.weight_data_size = N * K;\n ip.int8_scale_term = 0;\n ip.activation_type = 0;\n ip.activation_params = Mat();\n // weight_data is flat (N*K), row-major with K contiguous \u2014 exactly the\n // layout InnerProduct_arm expects (reshape(K, N) done in create_pipeline).\n ip.weight_data = const_cast<Mat&>(weight_data);\n\n if (ip.create_pipeline(opt) != 0) return -1;\n\n // bottom_blob is a genuine 2D Mat (w=K, h=M) \u2014 InnerProduct_arm handles the\n // full (M,K)->(M,N) gemm in one forward() call when dims==2.\n Mat local_top;\n if (ip.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n const int M = top_blob.h;\n for (int m = 0; m < M; ++m)\n std::memcpy(top_blob.row(m), local_top.row(m), N * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/gemm/gemm_w8a8ch_n1000_k1280.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_gemm_w8a8ch_n1000_k1280",
|
| 3 |
+
"definition": "gemm_w8a8ch_n1000_k1280",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for gemm_w8a8ch_n1000_k1280. binding.cpp bakes constexpr params and implements armbench_entry_gemm with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_gemm",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "gemm_w8a8ch_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for gemm w8a8ch (int8) baseline (C = A @ B^T, no bias).\n// Called by armbench_entry_gemm (binding.cpp); implemented by kernel.cpp.\n// A is a genuine 2D int8 Mat (w=K, h=M); B is flat int8 (N*K). top is\n// pre-allocated 2D int8 (w=N, h=M) by binding.cpp \u2014 InnerProduct_arm's int8\n// path never produces int8 output itself (only dequantizes to float32), so\n// kernel.cpp does the final round+clip+cast to int8 by hand.\nnamespace ncnn {\nint gemm_w8a8ch_kernel(\n const Mat& A, Mat& top,\n const Mat& B, const Mat& weight_scales,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"gemm_w8a8ch_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int N = 1000;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_gemm(\n void* A_v, void* top_v,\n void* B_v, void* weight_scales_v,\n void* opt_v)\n{\n const auto& A = *reinterpret_cast<const ncnn::Mat*>(A_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& B = *reinterpret_cast<const ncnn::Mat*>(B_v);\n const auto& weight_scales = *reinterpret_cast<const ncnn::Mat*>(weight_scales_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // A arrives as a genuine 2D Mat (w=K, h=M) \u2014 M (rows) varies per workload.\n const int M = A.h;\n\n // Dequantized float32 output \u2014 same elemsize as the fp32 baseline. w8a8ch\n // only quantizes inputs; the task doesn't require requantizing the result.\n top.create(N, M, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::gemm_w8a8ch_kernel(A, top, B, weight_scales, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"gemm_w8a8ch_contract.h\"\n#include \"innerproduct_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nnamespace {\nconstexpr int N = 1000;\nconstexpr int K = 1280;\n// input_scale is constant across every workload for this definition (checked\n// at generation time), so it's baked here rather than plumbed through the ABI.\nconstexpr float input_scale = 0.01;\n} // namespace\n\nint ncnn::gemm_w8a8ch_kernel(\n const Mat& A, Mat& top,\n const Mat& B, const Mat& weight_scales,\n const Option& opt)\n{\n // ncnn's int8 scale fields are *quantization* multipliers (int8 =\n // round(float*scale)); this baseline's weight_scales/input_scale are\n // *dequantization* multipliers (real = int8*scale) per the reference \u2014\n // invert them, or the output is silently wrong (not a crash).\n Mat weight_int8_scales;\n weight_int8_scales.create(N, (size_t)4u);\n if (weight_int8_scales.empty()) return -1;\n const float* ws = (const float*)weight_scales.data;\n for (int p = 0; p < N; ++p)\n weight_int8_scales[p] = 1.0f / ws[p];\n\n Mat bottom_int8_scales;\n bottom_int8_scales.create(1, (size_t)4u);\n if (bottom_int8_scales.empty()) return -1;\n bottom_int8_scales[0] = 1.0f / input_scale;\n\n InnerProduct_arm ip;\n ip.num_output = N;\n ip.bias_term = 0;\n ip.weight_data_size = N * K;\n // Plain truthy gate here (no >100 distinction like Convolution) \u2014 InnerProduct_arm\n // never produces int8 output itself regardless of this value, see below.\n ip.int8_scale_term = 1;\n ip.activation_type = 0;\n ip.activation_params = Mat();\n // B is flat (N*K), row-major with K contiguous \u2014 exactly the layout\n // InnerProduct_arm expects (reshape(K, N) done internally in create_pipeline).\n ip.weight_data = const_cast<Mat&>(B);\n ip.weight_data_int8_scales = weight_int8_scales;\n ip.bottom_blob_int8_scales = bottom_int8_scales;\n\n if (ip.create_pipeline(opt) != 0) return -1;\n\n // A is a genuine 2D Mat (w=K, h=M) \u2014 InnerProduct_arm handles the full\n // (M,K)->(M,N) gemm in one call when dims==2, no manual row loop needed.\n // InnerProduct_arm's int8 path only quantizes the *input*; it always\n // dequantizes the int32 accumulator back to float32 (never calls\n // Requantize/float2int8), which is exactly the plain dequantized result\n // this task wants \u2014 just copy it into the pre-allocated output Mat.\n Mat local_top_fp32;\n if (ip.forward(A, local_top_fp32, opt) != 0) return -1;\n\n const int M = top.h;\n for (int m = 0; m < M; ++m)\n std::memcpy((float*)top.row(m), local_top_fp32.row(m), N * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/gemm/gemm_w8a8ch_n1000_k2048.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_gemm_w8a8ch_n1000_k2048",
|
| 3 |
+
"definition": "gemm_w8a8ch_n1000_k2048",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for gemm_w8a8ch_n1000_k2048. binding.cpp bakes constexpr params and implements armbench_entry_gemm with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_gemm",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "gemm_w8a8ch_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for gemm w8a8ch (int8) baseline (C = A @ B^T, no bias).\n// Called by armbench_entry_gemm (binding.cpp); implemented by kernel.cpp.\n// A is a genuine 2D int8 Mat (w=K, h=M); B is flat int8 (N*K). top is\n// pre-allocated 2D int8 (w=N, h=M) by binding.cpp \u2014 InnerProduct_arm's int8\n// path never produces int8 output itself (only dequantizes to float32), so\n// kernel.cpp does the final round+clip+cast to int8 by hand.\nnamespace ncnn {\nint gemm_w8a8ch_kernel(\n const Mat& A, Mat& top,\n const Mat& B, const Mat& weight_scales,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"gemm_w8a8ch_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int N = 1000;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_gemm(\n void* A_v, void* top_v,\n void* B_v, void* weight_scales_v,\n void* opt_v)\n{\n const auto& A = *reinterpret_cast<const ncnn::Mat*>(A_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& B = *reinterpret_cast<const ncnn::Mat*>(B_v);\n const auto& weight_scales = *reinterpret_cast<const ncnn::Mat*>(weight_scales_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // A arrives as a genuine 2D Mat (w=K, h=M) \u2014 M (rows) varies per workload.\n const int M = A.h;\n\n // Dequantized float32 output \u2014 same elemsize as the fp32 baseline. w8a8ch\n // only quantizes inputs; the task doesn't require requantizing the result.\n top.create(N, M, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::gemm_w8a8ch_kernel(A, top, B, weight_scales, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"gemm_w8a8ch_contract.h\"\n#include \"innerproduct_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nnamespace {\nconstexpr int N = 1000;\nconstexpr int K = 2048;\n// input_scale is constant across every workload for this definition (checked\n// at generation time), so it's baked here rather than plumbed through the ABI.\nconstexpr float input_scale = 0.01;\n} // namespace\n\nint ncnn::gemm_w8a8ch_kernel(\n const Mat& A, Mat& top,\n const Mat& B, const Mat& weight_scales,\n const Option& opt)\n{\n // ncnn's int8 scale fields are *quantization* multipliers (int8 =\n // round(float*scale)); this baseline's weight_scales/input_scale are\n // *dequantization* multipliers (real = int8*scale) per the reference \u2014\n // invert them, or the output is silently wrong (not a crash).\n Mat weight_int8_scales;\n weight_int8_scales.create(N, (size_t)4u);\n if (weight_int8_scales.empty()) return -1;\n const float* ws = (const float*)weight_scales.data;\n for (int p = 0; p < N; ++p)\n weight_int8_scales[p] = 1.0f / ws[p];\n\n Mat bottom_int8_scales;\n bottom_int8_scales.create(1, (size_t)4u);\n if (bottom_int8_scales.empty()) return -1;\n bottom_int8_scales[0] = 1.0f / input_scale;\n\n InnerProduct_arm ip;\n ip.num_output = N;\n ip.bias_term = 0;\n ip.weight_data_size = N * K;\n // Plain truthy gate here (no >100 distinction like Convolution) \u2014 InnerProduct_arm\n // never produces int8 output itself regardless of this value, see below.\n ip.int8_scale_term = 1;\n ip.activation_type = 0;\n ip.activation_params = Mat();\n // B is flat (N*K), row-major with K contiguous \u2014 exactly the layout\n // InnerProduct_arm expects (reshape(K, N) done internally in create_pipeline).\n ip.weight_data = const_cast<Mat&>(B);\n ip.weight_data_int8_scales = weight_int8_scales;\n ip.bottom_blob_int8_scales = bottom_int8_scales;\n\n if (ip.create_pipeline(opt) != 0) return -1;\n\n // A is a genuine 2D Mat (w=K, h=M) \u2014 InnerProduct_arm handles the full\n // (M,K)->(M,N) gemm in one call when dims==2, no manual row loop needed.\n // InnerProduct_arm's int8 path only quantizes the *input*; it always\n // dequantizes the int32 accumulator back to float32 (never calls\n // Requantize/float2int8), which is exactly the plain dequantized result\n // this task wants \u2014 just copy it into the pre-allocated output Mat.\n Mat local_top_fp32;\n if (ip.forward(A, local_top_fp32, opt) != 0) return -1;\n\n const int M = top.h;\n for (int m = 0; m < M; ++m)\n std::memcpy((float*)top.row(m), local_top_fp32.row(m), N * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/gemm/gemm_w8a8ch_n1280_k960.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_gemm_w8a8ch_n1280_k960",
|
| 3 |
+
"definition": "gemm_w8a8ch_n1280_k960",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for gemm_w8a8ch_n1280_k960. binding.cpp bakes constexpr params and implements armbench_entry_gemm with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_gemm",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "gemm_w8a8ch_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for gemm w8a8ch (int8) baseline (C = A @ B^T, no bias).\n// Called by armbench_entry_gemm (binding.cpp); implemented by kernel.cpp.\n// A is a genuine 2D int8 Mat (w=K, h=M); B is flat int8 (N*K). top is\n// pre-allocated 2D int8 (w=N, h=M) by binding.cpp \u2014 InnerProduct_arm's int8\n// path never produces int8 output itself (only dequantizes to float32), so\n// kernel.cpp does the final round+clip+cast to int8 by hand.\nnamespace ncnn {\nint gemm_w8a8ch_kernel(\n const Mat& A, Mat& top,\n const Mat& B, const Mat& weight_scales,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"gemm_w8a8ch_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int N = 1280;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_gemm(\n void* A_v, void* top_v,\n void* B_v, void* weight_scales_v,\n void* opt_v)\n{\n const auto& A = *reinterpret_cast<const ncnn::Mat*>(A_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& B = *reinterpret_cast<const ncnn::Mat*>(B_v);\n const auto& weight_scales = *reinterpret_cast<const ncnn::Mat*>(weight_scales_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // A arrives as a genuine 2D Mat (w=K, h=M) \u2014 M (rows) varies per workload.\n const int M = A.h;\n\n // Dequantized float32 output \u2014 same elemsize as the fp32 baseline. w8a8ch\n // only quantizes inputs; the task doesn't require requantizing the result.\n top.create(N, M, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::gemm_w8a8ch_kernel(A, top, B, weight_scales, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"gemm_w8a8ch_contract.h\"\n#include \"innerproduct_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nnamespace {\nconstexpr int N = 1280;\nconstexpr int K = 960;\n// input_scale is constant across every workload for this definition (checked\n// at generation time), so it's baked here rather than plumbed through the ABI.\nconstexpr float input_scale = 0.01;\n} // namespace\n\nint ncnn::gemm_w8a8ch_kernel(\n const Mat& A, Mat& top,\n const Mat& B, const Mat& weight_scales,\n const Option& opt)\n{\n // ncnn's int8 scale fields are *quantization* multipliers (int8 =\n // round(float*scale)); this baseline's weight_scales/input_scale are\n // *dequantization* multipliers (real = int8*scale) per the reference \u2014\n // invert them, or the output is silently wrong (not a crash).\n Mat weight_int8_scales;\n weight_int8_scales.create(N, (size_t)4u);\n if (weight_int8_scales.empty()) return -1;\n const float* ws = (const float*)weight_scales.data;\n for (int p = 0; p < N; ++p)\n weight_int8_scales[p] = 1.0f / ws[p];\n\n Mat bottom_int8_scales;\n bottom_int8_scales.create(1, (size_t)4u);\n if (bottom_int8_scales.empty()) return -1;\n bottom_int8_scales[0] = 1.0f / input_scale;\n\n InnerProduct_arm ip;\n ip.num_output = N;\n ip.bias_term = 0;\n ip.weight_data_size = N * K;\n // Plain truthy gate here (no >100 distinction like Convolution) \u2014 InnerProduct_arm\n // never produces int8 output itself regardless of this value, see below.\n ip.int8_scale_term = 1;\n ip.activation_type = 0;\n ip.activation_params = Mat();\n // B is flat (N*K), row-major with K contiguous \u2014 exactly the layout\n // InnerProduct_arm expects (reshape(K, N) done internally in create_pipeline).\n ip.weight_data = const_cast<Mat&>(B);\n ip.weight_data_int8_scales = weight_int8_scales;\n ip.bottom_blob_int8_scales = bottom_int8_scales;\n\n if (ip.create_pipeline(opt) != 0) return -1;\n\n // A is a genuine 2D Mat (w=K, h=M) \u2014 InnerProduct_arm handles the full\n // (M,K)->(M,N) gemm in one call when dims==2, no manual row loop needed.\n // InnerProduct_arm's int8 path only quantizes the *input*; it always\n // dequantizes the int32 accumulator back to float32 (never calls\n // Requantize/float2int8), which is exactly the plain dequantized result\n // this task wants \u2014 just copy it into the pre-allocated output Mat.\n Mat local_top_fp32;\n if (ip.forward(A, local_top_fp32, opt) != 0) return -1;\n\n const int M = top.h;\n for (int m = 0; m < M; ++m)\n std::memcpy((float*)top.row(m), local_top_fp32.row(m), N * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/lstm/lstm_fp32_i322_h800.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_lstm_fp32_i322_h800",
|
| 3 |
+
"definition": "lstm_fp32_i322_h800",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for lstm_fp32_i322_h800. binding.cpp bakes constexpr params and implements armbench_entry_lstm with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_lstm",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "lstm_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for lstm baseline (single-layer, unidirectional, no\n// projection). Called by armbench_entry_lstm (binding.cpp); implemented by\n// kernel.cpp.\n//\n// x arrives as a genuine 2D Mat (w=input_size, h=T). h0/c0/W_ih/W_hh/b arrive\n// flat 1D (h0/c0 are already the right shape \u2014 plain hidden_size vectors;\n// W_ih/W_hh/b need reshaping + a gate-order permutation inside kernel.cpp,\n// see there for why). top is pre-allocated 2D (w=hidden_size, h=T) by\n// binding.cpp.\nnamespace ncnn {\nint lstm_kernel(\n const Mat& x, Mat& top,\n const Mat& h0, const Mat& c0,\n const Mat& W_ih, const Mat& W_hh, const Mat& b,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"lstm_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int hidden_size = 800;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_lstm(\n void* x_v, void* top_v,\n void* h0_v, void* c0_v,\n void* Wih_v, void* Whh_v, void* b_v,\n void* opt_v)\n{\n const auto& x = *reinterpret_cast<const ncnn::Mat*>(x_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& h0 = *reinterpret_cast<const ncnn::Mat*>(h0_v);\n const auto& c0 = *reinterpret_cast<const ncnn::Mat*>(c0_v);\n const auto& Wih = *reinterpret_cast<const ncnn::Mat*>(Wih_v);\n const auto& Whh = *reinterpret_cast<const ncnn::Mat*>(Whh_v);\n const auto& b = *reinterpret_cast<const ncnn::Mat*>(b_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n // x arrives as a genuine 2D Mat (w=input_size, h=T) \u2014 T varies per workload.\n const int T = x.h;\n\n top.create(hidden_size, T, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::lstm_kernel(x, top, h0, c0, Wih, Whh, b, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"lstm_contract.h\"\n#include \"lstm_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n#include <vector>\n\nnamespace {\nconstexpr int input_size = 322;\nconstexpr int hidden_size = 800;\n\n// PyTorch's nn.LSTM packs gates as [I, F, G, O] (chunk order 0,1,2,3); ncnn's\n// LSTM_arm internally computes/expects [I, F, O, G] \u2014 chunks 2 and 3 swapped.\n// src_chunk_for_dst[g] = which PyTorch chunk feeds ncnn gate slot g.\nconstexpr int src_chunk_for_dst[4] = {0, 1, 3, 2};\n} // namespace\n\nint ncnn::lstm_kernel(\n const Mat& x, Mat& top,\n const Mat& h0, const Mat& c0,\n const Mat& W_ih, const Mat& W_hh, const Mat& b,\n const Option& opt)\n{\n const float* Wih_ptr = (const float*)W_ih.data;\n const float* Whh_ptr = (const float*)W_hh.data;\n const float* b_ptr = (const float*)b.data;\n\n // Reshape + gate-permute the flat PyTorch-order weights into ncnn's\n // expected 3D-shaped (w, h=4*hidden_size, c=1) Mats.\n Mat weight_xc_data; // (w=input_size, h=hidden_size*4, c=1)\n Mat weight_hc_data; // (w=hidden_size, h=hidden_size*4, c=1)\n Mat bias_c_data; // (w=hidden_size, h=4, c=1)\n weight_xc_data.create(input_size, hidden_size * 4, 1, (size_t)4u);\n weight_hc_data.create(hidden_size, hidden_size * 4, 1, (size_t)4u);\n bias_c_data.create(hidden_size, 4, 1, (size_t)4u);\n if (weight_xc_data.empty() || weight_hc_data.empty() || bias_c_data.empty()) return -1;\n\n for (int g = 0; g < 4; ++g) {\n const int src_chunk = src_chunk_for_dst[g];\n for (int q = 0; q < hidden_size; ++q) {\n const int dst_row = g * hidden_size + q;\n const int src_row = src_chunk * hidden_size + q;\n std::memcpy(weight_xc_data.channel(0).row(dst_row),\n Wih_ptr + (size_t)src_row * input_size,\n input_size * sizeof(float));\n std::memcpy(weight_hc_data.channel(0).row(dst_row),\n Whh_ptr + (size_t)src_row * hidden_size,\n hidden_size * sizeof(float));\n }\n std::memcpy(bias_c_data.channel(0).row(g),\n b_ptr + (size_t)src_chunk * hidden_size,\n hidden_size * sizeof(float));\n }\n\n LSTM_arm lstm;\n lstm.num_output = hidden_size;\n lstm.hidden_size = hidden_size; // does NOT default from num_output here\n lstm.direction = 0; // forward, unidirectional\n lstm.weight_data_size = hidden_size * 4 * input_size;\n lstm.int8_scale_term = 0;\n lstm.weight_xc_data = weight_xc_data;\n lstm.weight_hc_data = weight_hc_data;\n lstm.bias_c_data = bias_c_data;\n // lstm.weight_hr_data left default-empty: no LSTMP projection (num_output == hidden_size).\n\n if (lstm.create_pipeline(opt) != 0) return -1;\n\n // Use the 3-blob overload so the given h0/c0 seed the initial state \u2014 the\n // 1-Mat overload always zero-inits internally and would ignore them.\n std::vector<Mat> bottom_blobs(3);\n bottom_blobs[0] = x;\n bottom_blobs[1] = h0;\n bottom_blobs[2] = c0;\n std::vector<Mat> top_blobs(1);\n if (lstm.forward(bottom_blobs, top_blobs, opt) != 0) return -1;\n\n const Mat& local_top = top_blobs[0];\n const int T = top.h;\n for (int t = 0; t < T; ++t)\n std::memcpy(top.row(t), local_top.row(t), hidden_size * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/pooling/pooling_fp32_global_avg.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_pooling_fp32_global_avg",
|
| 3 |
+
"definition": "pooling_fp32_global_avg",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for pooling_fp32_global_avg. binding.cpp bakes constexpr params and implements armbench_entry_pooling with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_pooling",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "pooling_global_avg_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for pooling baseline \u2014 global average pooling variant.\n// Called by armbench_entry_pooling (binding.cpp); implemented by kernel.cpp.\n// No kernel/stride/pad consts \u2014 output collapses each channel's full spatial\n// extent to a single scalar, so top_blob is a flat 1D Mat (w=C).\nnamespace ncnn {\nint pooling_global_avg_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"pooling_global_avg_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nextern \"C\" {\nint armbench_entry_pooling(\n void* bottom_v, void* top_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n const int C = bottom.c;\n top.create(C, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::pooling_global_avg_kernel(bottom, top, opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"pooling_global_avg_contract.h\"\n#include \"pooling_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::pooling_global_avg_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n const Option& opt)\n{\n Pooling_arm pool;\n pool.pooling_type = 1; // PoolMethod_AVE\n pool.kernel_w = 0;\n pool.kernel_h = 0;\n pool.stride_w = 1;\n pool.stride_h = 1;\n pool.pad_left = 0;\n pool.pad_right = 0;\n pool.pad_top = 0;\n pool.pad_bottom = 0;\n pool.global_pooling = 1;\n pool.pad_mode = 1;\n pool.avgpool_count_include_pad = 0;\n pool.adaptive_pooling = 0;\n pool.out_w = 0;\n pool.out_h = 0;\n\n if (pool.create_pipeline(opt) != 0) return -1;\n\n // ncnn's Pooling::forward global-pooling path creates top_blob as a flat\n // 1D Mat (w=C) directly (Mat::create(channels, elemsize, allocator)) \u2014 no\n // per-row/channel padding concern, unlike the windowed-pooling 3D case.\n Mat local_top;\n if (pool.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n std::memcpy((float*)top_blob.data, (const float*)local_top.data,\n top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/pooling/pooling_fp32_max_kh2_kw2_sh2_sw2_p0.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_pooling_fp32_max_kh2_kw2_sh2_sw2_p0",
|
| 3 |
+
"definition": "pooling_fp32_max_kh2_kw2_sh2_sw2_p0",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for pooling_fp32_max_kh2_kw2_sh2_sw2_p0. binding.cpp bakes constexpr params and implements armbench_entry_pooling with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_pooling",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "pooling_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for pooling baseline (max pool only).\n// Called by armbench_entry_pooling (binding.cpp); implemented by kernel.cpp.\n// C is encoded in top_blob.c (pre-allocated by binding.cpp).\nnamespace ncnn {\nint pooling_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int pad_top, int pad_left,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"pooling_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 2;\nconstexpr int kernel_w = 2;\nconstexpr int stride_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int pad_top = 0;\nconstexpr int pad_left = 0;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_pooling(\n void* bottom_v, void* top_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n const int C = bottom.c;\n const int H_out = (bottom.h + 2 * pad_top - kernel_h) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad_left - kernel_w) / stride_w + 1;\n\n top.create(W_out, H_out, C, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::pooling_kernel(\n bottom, top,\n kernel_h, kernel_w,\n stride_h, stride_w,\n pad_top, pad_left,\n opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"pooling_contract.h\"\n#include \"pooling_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::pooling_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int pad_top, int pad_left,\n const Option& opt)\n{\n const int C = top_blob.c; // pre-set by binding.cpp (== input channels)\n\n Pooling_arm pool;\n pool.pooling_type = 0; // PoolMethod_MAX\n pool.kernel_w = kernel_w;\n pool.kernel_h = kernel_h;\n pool.stride_w = stride_w;\n pool.stride_h = stride_h;\n pool.pad_left = pad_left;\n pool.pad_right = pad_left;\n pool.pad_top = pad_top;\n pool.pad_bottom = pad_top;\n pool.global_pooling = 0;\n pool.pad_mode = 1; // \"valid\" \u2014 plain floor output-size formula\n pool.avgpool_count_include_pad = 0;\n pool.adaptive_pooling = 0;\n pool.out_w = 0;\n pool.out_h = 0;\n\n if (pool.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n if (pool.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n for (int c = 0; c < C; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/pooling/pooling_fp32_max_kh3_kw3_sh1_sw1_p1.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_pooling_fp32_max_kh3_kw3_sh1_sw1_p1",
|
| 3 |
+
"definition": "pooling_fp32_max_kh3_kw3_sh1_sw1_p1",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for pooling_fp32_max_kh3_kw3_sh1_sw1_p1. binding.cpp bakes constexpr params and implements armbench_entry_pooling with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_pooling",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "pooling_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for pooling baseline (max pool only).\n// Called by armbench_entry_pooling (binding.cpp); implemented by kernel.cpp.\n// C is encoded in top_blob.c (pre-allocated by binding.cpp).\nnamespace ncnn {\nint pooling_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int pad_top, int pad_left,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"pooling_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 3;\nconstexpr int kernel_w = 3;\nconstexpr int stride_h = 1;\nconstexpr int stride_w = 1;\nconstexpr int pad_top = 1;\nconstexpr int pad_left = 1;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_pooling(\n void* bottom_v, void* top_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n const int C = bottom.c;\n const int H_out = (bottom.h + 2 * pad_top - kernel_h) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad_left - kernel_w) / stride_w + 1;\n\n top.create(W_out, H_out, C, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::pooling_kernel(\n bottom, top,\n kernel_h, kernel_w,\n stride_h, stride_w,\n pad_top, pad_left,\n opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"pooling_contract.h\"\n#include \"pooling_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::pooling_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int pad_top, int pad_left,\n const Option& opt)\n{\n const int C = top_blob.c; // pre-set by binding.cpp (== input channels)\n\n Pooling_arm pool;\n pool.pooling_type = 0; // PoolMethod_MAX\n pool.kernel_w = kernel_w;\n pool.kernel_h = kernel_h;\n pool.stride_w = stride_w;\n pool.stride_h = stride_h;\n pool.pad_left = pad_left;\n pool.pad_right = pad_left;\n pool.pad_top = pad_top;\n pool.pad_bottom = pad_top;\n pool.global_pooling = 0;\n pool.pad_mode = 1; // \"valid\" \u2014 plain floor output-size formula\n pool.avgpool_count_include_pad = 0;\n pool.adaptive_pooling = 0;\n pool.out_w = 0;\n pool.out_h = 0;\n\n if (pool.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n if (pool.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n for (int c = 0; c < C; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/pooling/pooling_fp32_max_kh3_kw3_sh2_sw2_p0.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_pooling_fp32_max_kh3_kw3_sh2_sw2_p0",
|
| 3 |
+
"definition": "pooling_fp32_max_kh3_kw3_sh2_sw2_p0",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "baseline-ncnn-arm baseline for pooling_fp32_max_kh3_kw3_sh2_sw2_p0. binding.cpp bakes constexpr params and implements armbench_entry_pooling with a void* ABI; kernel.cpp delegates to the backend library. Timing baseline for speedup computation.",
|
| 7 |
+
"spec": {
|
| 8 |
+
"language": "cpp",
|
| 9 |
+
"target_hardware": [
|
| 10 |
+
"graviton3",
|
| 11 |
+
"aarch64-sve",
|
| 12 |
+
"graviton4",
|
| 13 |
+
"aarch64-sve2"
|
| 14 |
+
],
|
| 15 |
+
"entry_point": "binding.cpp::armbench_entry_pooling",
|
| 16 |
+
"dependencies": [],
|
| 17 |
+
"isa_features": [],
|
| 18 |
+
"compile_flags": [
|
| 19 |
+
"-O3",
|
| 20 |
+
"-std=c++17"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": [
|
| 23 |
+
"-fopenmp"
|
| 24 |
+
]
|
| 25 |
+
},
|
| 26 |
+
"sources": [
|
| 27 |
+
{
|
| 28 |
+
"path": "pooling_contract.h",
|
| 29 |
+
"content": "#pragma once\n#include \"mat.h\"\n#include \"option.h\"\n\n// Harness contract for pooling baseline (max pool only).\n// Called by armbench_entry_pooling (binding.cpp); implemented by kernel.cpp.\n// C is encoded in top_blob.c (pre-allocated by binding.cpp).\nnamespace ncnn {\nint pooling_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int pad_top, int pad_left,\n const Option& opt);\n}\n"
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"path": "binding.cpp",
|
| 33 |
+
"content": "#include \"pooling_contract.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int kernel_h = 3;\nconstexpr int kernel_w = 3;\nconstexpr int stride_h = 2;\nconstexpr int stride_w = 2;\nconstexpr int pad_top = 0;\nconstexpr int pad_left = 0;\n} // namespace\n\nextern \"C\" {\nint armbench_entry_pooling(\n void* bottom_v, void* top_v,\n void* opt_v)\n{\n const auto& bottom = *reinterpret_cast<const ncnn::Mat*>(bottom_v);\n auto& top = *reinterpret_cast<ncnn::Mat*>(top_v);\n const auto& opt = *reinterpret_cast<const ncnn::Option*>(opt_v);\n\n const int C = bottom.c;\n const int H_out = (bottom.h + 2 * pad_top - kernel_h) / stride_h + 1;\n const int W_out = (bottom.w + 2 * pad_left - kernel_w) / stride_w + 1;\n\n top.create(W_out, H_out, C, (size_t)4u, opt.blob_allocator);\n if (top.empty()) return -1;\n\n return ncnn::pooling_kernel(\n bottom, top,\n kernel_h, kernel_w,\n stride_h, stride_w,\n pad_top, pad_left,\n opt);\n}\n} // extern \"C\"\n"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"path": "kernel.cpp",
|
| 37 |
+
"content": "#include \"pooling_contract.h\"\n#include \"pooling_arm.h\"\n#include \"mat.h\"\n#include \"option.h\"\n#include <cstring>\n\nint ncnn::pooling_kernel(\n const Mat& bottom_blob, Mat& top_blob,\n int kernel_h, int kernel_w,\n int stride_h, int stride_w,\n int pad_top, int pad_left,\n const Option& opt)\n{\n const int C = top_blob.c; // pre-set by binding.cpp (== input channels)\n\n Pooling_arm pool;\n pool.pooling_type = 0; // PoolMethod_MAX\n pool.kernel_w = kernel_w;\n pool.kernel_h = kernel_h;\n pool.stride_w = stride_w;\n pool.stride_h = stride_h;\n pool.pad_left = pad_left;\n pool.pad_right = pad_left;\n pool.pad_top = pad_top;\n pool.pad_bottom = pad_top;\n pool.global_pooling = 0;\n pool.pad_mode = 1; // \"valid\" \u2014 plain floor output-size formula\n pool.avgpool_count_include_pad = 0;\n pool.adaptive_pooling = 0;\n pool.out_w = 0;\n pool.out_h = 0;\n\n if (pool.create_pipeline(opt) != 0) return -1;\n\n Mat local_top;\n if (pool.forward(bottom_blob, local_top, opt) != 0) return -1;\n\n for (int c = 0; c < C; ++c)\n std::memcpy((float*)top_blob.channel(c), (const float*)local_top.channel(c),\n top_blob.h * top_blob.w * sizeof(float));\n return 0;\n}\n"
|
| 38 |
+
}
|
| 39 |
+
]
|
| 40 |
+
}
|