Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- definitions/conv/conv2d_kh1_kw1_sh1_sw1_dh1_dw1_cout256.json +112 -0
- definitions/conv/conv2d_kh3_kw3_sh1_sw1_dh1_dw1_cout128.json +112 -0
- definitions/conv/conv2d_kh3_kw3_sh1_sw1_dh2_dw2_cout256.json +112 -0
- definitions/conv/conv2d_kh3_kw3_sh2_sw2_dh1_dw1_cout128.json +112 -0
- definitions/conv/conv2d_kh5_kw5_sh1_sw1_dh1_dw1_cout64.json +112 -0
- definitions/conv/conv2d_kh7_kw7_sh2_sw2_dh1_dw1_cout64.json +112 -0
- definitions/conv1d/conv1d_kw1_sw1_dw1_cout512_p0.json +75 -0
- definitions/conv1d/conv1d_kw3_sw1_dw1_cout512_p1.json +75 -0
- definitions/conv2d_depthwise/conv2d_depthwise_kh3_kw3_sh1_sw1_dh1_dw1_p1.json +101 -0
- definitions/conv2d_depthwise/conv2d_depthwise_kh3_kw3_sh2_sw2_dh1_dw1_p1.json +101 -0
- definitions/conv2d_depthwise/conv2d_depthwise_kh5_kw5_sh1_sw1_dh1_dw1_p2.json +101 -0
- definitions/deconv2d/deconv2d_kh3_kw3_sh1_sw1_cout256.json +102 -0
- definitions/deconv2d/deconv2d_kh3_kw3_sh2_sw2_cout256.json +102 -0
- definitions/deconv2d/deconv2d_kh4_kw4_sh1_sw1_cout128.json +102 -0
- definitions/deconv2d/deconv2d_kh4_kw4_sh2_sw2_cout128.json +102 -0
- definitions/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2.json +97 -0
- definitions/deconv2d_depthwise/deconv2d_depthwise_kh3_kw3_sh1_sw1.json +97 -0
- solutions/ncnn/baseline-ncnn-arm/conv1d/conv1d_kw1_sw1_dw1_cout512_p0.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv1d/conv1d_kw3_sw1_dw1_cout512_p1.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_kh1_kw1_sh1_sw1_dh1_dw1_cout256.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_kh3_kw3_sh1_sw1_dh1_dw1_cout128.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_kh3_kw3_sh1_sw1_dh2_dw2_cout256.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_kh3_kw3_sh2_sw2_dh1_dw1_cout128.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_kh5_kw5_sh1_sw1_dh1_dw1_cout64.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d/conv2d_kh7_kw7_sh2_sw2_dh1_dw1_cout64.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_kh3_kw3_sh1_sw1_dh1_dw1_p1.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_kh3_kw3_sh2_sw2_dh1_dw1_p1.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/conv2d_depthwise/conv2d_depthwise_kh5_kw5_sh1_sw1_dh1_dw1_p2.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh1_sw1_cout256.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh3_kw3_sh2_sw2_cout256.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh1_sw1_cout128.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/deconv2d/deconv2d_kh4_kw4_sh2_sw2_cout128.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2.json +40 -0
- solutions/ncnn/baseline-ncnn-arm/deconv2d_depthwise/deconv2d_depthwise_kh3_kw3_sh1_sw1.json +40 -0
- solutions/ncnn/claude-sonnet-4-6/conv1d/conv1d_kw1_sw1_dw1_cout512_p0.json +38 -0
- solutions/ncnn/claude-sonnet-4-6/conv1d/conv1d_kw3_sw1_dw1_cout512_p1.json +38 -0
- solutions/ncnn/claude-sonnet-4-6/conv2d/conv2d_kh1_kw1_sh1_sw1_dh1_dw1_cout256.json +38 -0
- solutions/ncnn/claude-sonnet-4-6/conv2d/conv2d_kh3_kw3_sh1_sw1_dh1_dw1_cout128.json +38 -0
- solutions/ncnn/claude-sonnet-4-6/conv2d/conv2d_kh3_kw3_sh1_sw1_dh2_dw2_cout256.json +38 -0
- solutions/ncnn/claude-sonnet-4-6/conv2d/conv2d_kh3_kw3_sh2_sw2_dh1_dw1_cout128.json +38 -0
- solutions/ncnn/claude-sonnet-4-6/conv2d/conv2d_kh5_kw5_sh1_sw1_dh1_dw1_cout64.json +38 -0
- solutions/ncnn/claude-sonnet-4-6/conv2d/conv2d_kh7_kw7_sh2_sw2_dh1_dw1_cout64.json +38 -0
- solutions/ncnn/claude-sonnet-4-6/conv2d_depthwise/conv2d_depthwise_kh3_kw3_sh1_sw1_dh1_dw1_p1.json +38 -0
- solutions/ncnn/claude-sonnet-4-6/conv2d_depthwise/conv2d_depthwise_kh3_kw3_sh2_sw2_dh1_dw1_p1.json +38 -0
- solutions/ncnn/claude-sonnet-4-6/conv2d_depthwise/conv2d_depthwise_kh5_kw5_sh1_sw1_dh1_dw1_p2.json +38 -0
- solutions/ncnn/claude-sonnet-4-6/deconv2d/deconv2d_kh3_kw3_sh1_sw1_cout256.json +38 -0
- solutions/ncnn/claude-sonnet-4-6/deconv2d/deconv2d_kh3_kw3_sh2_sw2_cout256.json +38 -0
- solutions/ncnn/claude-sonnet-4-6/deconv2d/deconv2d_kh4_kw4_sh1_sw1_cout128.json +38 -0
- solutions/ncnn/claude-sonnet-4-6/deconv2d/deconv2d_kh4_kw4_sh2_sw2_cout128.json +38 -0
- solutions/ncnn/claude-sonnet-4-6/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2.json +38 -0
definitions/conv/conv2d_kh1_kw1_sh1_sw1_dh1_dw1_cout256.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "conv2d_kh1_kw1_sh1_sw1_dh1_dw1_cout256",
|
| 3 |
+
"op_type": "conv2d",
|
| 4 |
+
"description": "2D conv 1x1 stride=(1,1) dilation=(1,1) pad=(0,0) C_out=256. C_in varies per workload.",
|
| 5 |
+
"tags": [
|
| 6 |
+
"status:active"
|
| 7 |
+
],
|
| 8 |
+
"axes": {
|
| 9 |
+
"N": {
|
| 10 |
+
"type": "var"
|
| 11 |
+
},
|
| 12 |
+
"H": {
|
| 13 |
+
"type": "var",
|
| 14 |
+
"parent": "N"
|
| 15 |
+
},
|
| 16 |
+
"W": {
|
| 17 |
+
"type": "var",
|
| 18 |
+
"parent": "N"
|
| 19 |
+
},
|
| 20 |
+
"H_out": {
|
| 21 |
+
"type": "var",
|
| 22 |
+
"parent": "N"
|
| 23 |
+
},
|
| 24 |
+
"W_out": {
|
| 25 |
+
"type": "var",
|
| 26 |
+
"parent": "N"
|
| 27 |
+
},
|
| 28 |
+
"C_in": {
|
| 29 |
+
"type": "var"
|
| 30 |
+
},
|
| 31 |
+
"C_out": {
|
| 32 |
+
"type": "const",
|
| 33 |
+
"value": 256
|
| 34 |
+
},
|
| 35 |
+
"Kh": {
|
| 36 |
+
"type": "const",
|
| 37 |
+
"value": 1
|
| 38 |
+
},
|
| 39 |
+
"Kw": {
|
| 40 |
+
"type": "const",
|
| 41 |
+
"value": 1
|
| 42 |
+
},
|
| 43 |
+
"Sh": {
|
| 44 |
+
"type": "const",
|
| 45 |
+
"value": 1
|
| 46 |
+
},
|
| 47 |
+
"Sw": {
|
| 48 |
+
"type": "const",
|
| 49 |
+
"value": 1
|
| 50 |
+
},
|
| 51 |
+
"Dh": {
|
| 52 |
+
"type": "const",
|
| 53 |
+
"value": 1
|
| 54 |
+
},
|
| 55 |
+
"Dw": {
|
| 56 |
+
"type": "const",
|
| 57 |
+
"value": 1
|
| 58 |
+
},
|
| 59 |
+
"pad_top": {
|
| 60 |
+
"type": "const",
|
| 61 |
+
"value": 0
|
| 62 |
+
},
|
| 63 |
+
"pad_left": {
|
| 64 |
+
"type": "const",
|
| 65 |
+
"value": 0
|
| 66 |
+
}
|
| 67 |
+
},
|
| 68 |
+
"inputs": {
|
| 69 |
+
"input": {
|
| 70 |
+
"shape": [
|
| 71 |
+
"N",
|
| 72 |
+
"C_in",
|
| 73 |
+
"H",
|
| 74 |
+
"W"
|
| 75 |
+
],
|
| 76 |
+
"dtype": "float32"
|
| 77 |
+
},
|
| 78 |
+
"weight": {
|
| 79 |
+
"shape": [
|
| 80 |
+
"C_out",
|
| 81 |
+
"C_in",
|
| 82 |
+
"Kh",
|
| 83 |
+
"Kw"
|
| 84 |
+
],
|
| 85 |
+
"dtype": "float32"
|
| 86 |
+
},
|
| 87 |
+
"activation_type": {
|
| 88 |
+
"shape": null,
|
| 89 |
+
"dtype": "int32"
|
| 90 |
+
},
|
| 91 |
+
"with_bias": {
|
| 92 |
+
"shape": null,
|
| 93 |
+
"dtype": "int32"
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
"outputs": {
|
| 97 |
+
"output": {
|
| 98 |
+
"shape": [
|
| 99 |
+
"N",
|
| 100 |
+
"C_out",
|
| 101 |
+
"H_out",
|
| 102 |
+
"W_out"
|
| 103 |
+
],
|
| 104 |
+
"dtype": "float32"
|
| 105 |
+
}
|
| 106 |
+
},
|
| 107 |
+
"constraints": [
|
| 108 |
+
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 109 |
+
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 110 |
+
],
|
| 111 |
+
"reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, activation_type, with_bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight)\n return F.conv2d(x, w, None, stride=(1, 1), padding=(0, 0), dilation=(1, 1)).numpy()\n"
|
| 112 |
+
}
|
definitions/conv/conv2d_kh3_kw3_sh1_sw1_dh1_dw1_cout128.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "conv2d_kh3_kw3_sh1_sw1_dh1_dw1_cout128",
|
| 3 |
+
"op_type": "conv2d",
|
| 4 |
+
"description": "2D conv 3x3 stride=(1,1) dilation=(1,1) pad=(1,1) C_out=128. C_in varies per workload.",
|
| 5 |
+
"tags": [
|
| 6 |
+
"status:active"
|
| 7 |
+
],
|
| 8 |
+
"axes": {
|
| 9 |
+
"N": {
|
| 10 |
+
"type": "var"
|
| 11 |
+
},
|
| 12 |
+
"H": {
|
| 13 |
+
"type": "var",
|
| 14 |
+
"parent": "N"
|
| 15 |
+
},
|
| 16 |
+
"W": {
|
| 17 |
+
"type": "var",
|
| 18 |
+
"parent": "N"
|
| 19 |
+
},
|
| 20 |
+
"H_out": {
|
| 21 |
+
"type": "var",
|
| 22 |
+
"parent": "N"
|
| 23 |
+
},
|
| 24 |
+
"W_out": {
|
| 25 |
+
"type": "var",
|
| 26 |
+
"parent": "N"
|
| 27 |
+
},
|
| 28 |
+
"C_in": {
|
| 29 |
+
"type": "var"
|
| 30 |
+
},
|
| 31 |
+
"C_out": {
|
| 32 |
+
"type": "const",
|
| 33 |
+
"value": 128
|
| 34 |
+
},
|
| 35 |
+
"Kh": {
|
| 36 |
+
"type": "const",
|
| 37 |
+
"value": 3
|
| 38 |
+
},
|
| 39 |
+
"Kw": {
|
| 40 |
+
"type": "const",
|
| 41 |
+
"value": 3
|
| 42 |
+
},
|
| 43 |
+
"Sh": {
|
| 44 |
+
"type": "const",
|
| 45 |
+
"value": 1
|
| 46 |
+
},
|
| 47 |
+
"Sw": {
|
| 48 |
+
"type": "const",
|
| 49 |
+
"value": 1
|
| 50 |
+
},
|
| 51 |
+
"Dh": {
|
| 52 |
+
"type": "const",
|
| 53 |
+
"value": 1
|
| 54 |
+
},
|
| 55 |
+
"Dw": {
|
| 56 |
+
"type": "const",
|
| 57 |
+
"value": 1
|
| 58 |
+
},
|
| 59 |
+
"pad_top": {
|
| 60 |
+
"type": "const",
|
| 61 |
+
"value": 1
|
| 62 |
+
},
|
| 63 |
+
"pad_left": {
|
| 64 |
+
"type": "const",
|
| 65 |
+
"value": 1
|
| 66 |
+
}
|
| 67 |
+
},
|
| 68 |
+
"inputs": {
|
| 69 |
+
"input": {
|
| 70 |
+
"shape": [
|
| 71 |
+
"N",
|
| 72 |
+
"C_in",
|
| 73 |
+
"H",
|
| 74 |
+
"W"
|
| 75 |
+
],
|
| 76 |
+
"dtype": "float32"
|
| 77 |
+
},
|
| 78 |
+
"weight": {
|
| 79 |
+
"shape": [
|
| 80 |
+
"C_out",
|
| 81 |
+
"C_in",
|
| 82 |
+
"Kh",
|
| 83 |
+
"Kw"
|
| 84 |
+
],
|
| 85 |
+
"dtype": "float32"
|
| 86 |
+
},
|
| 87 |
+
"activation_type": {
|
| 88 |
+
"shape": null,
|
| 89 |
+
"dtype": "int32"
|
| 90 |
+
},
|
| 91 |
+
"with_bias": {
|
| 92 |
+
"shape": null,
|
| 93 |
+
"dtype": "int32"
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
"outputs": {
|
| 97 |
+
"output": {
|
| 98 |
+
"shape": [
|
| 99 |
+
"N",
|
| 100 |
+
"C_out",
|
| 101 |
+
"H_out",
|
| 102 |
+
"W_out"
|
| 103 |
+
],
|
| 104 |
+
"dtype": "float32"
|
| 105 |
+
}
|
| 106 |
+
},
|
| 107 |
+
"constraints": [
|
| 108 |
+
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 109 |
+
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 110 |
+
],
|
| 111 |
+
"reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, activation_type, with_bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight)\n return F.conv2d(x, w, None, stride=(1, 1), padding=(1, 1), dilation=(1, 1)).numpy()\n"
|
| 112 |
+
}
|
definitions/conv/conv2d_kh3_kw3_sh1_sw1_dh2_dw2_cout256.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "conv2d_kh3_kw3_sh1_sw1_dh2_dw2_cout256",
|
| 3 |
+
"op_type": "conv2d",
|
| 4 |
+
"description": "2D conv 3x3 stride=(1,1) dilation=(2,2) pad=(2,2) C_out=256. C_in varies per workload.",
|
| 5 |
+
"tags": [
|
| 6 |
+
"status:active"
|
| 7 |
+
],
|
| 8 |
+
"axes": {
|
| 9 |
+
"N": {
|
| 10 |
+
"type": "var"
|
| 11 |
+
},
|
| 12 |
+
"H": {
|
| 13 |
+
"type": "var",
|
| 14 |
+
"parent": "N"
|
| 15 |
+
},
|
| 16 |
+
"W": {
|
| 17 |
+
"type": "var",
|
| 18 |
+
"parent": "N"
|
| 19 |
+
},
|
| 20 |
+
"H_out": {
|
| 21 |
+
"type": "var",
|
| 22 |
+
"parent": "N"
|
| 23 |
+
},
|
| 24 |
+
"W_out": {
|
| 25 |
+
"type": "var",
|
| 26 |
+
"parent": "N"
|
| 27 |
+
},
|
| 28 |
+
"C_in": {
|
| 29 |
+
"type": "var"
|
| 30 |
+
},
|
| 31 |
+
"C_out": {
|
| 32 |
+
"type": "const",
|
| 33 |
+
"value": 256
|
| 34 |
+
},
|
| 35 |
+
"Kh": {
|
| 36 |
+
"type": "const",
|
| 37 |
+
"value": 3
|
| 38 |
+
},
|
| 39 |
+
"Kw": {
|
| 40 |
+
"type": "const",
|
| 41 |
+
"value": 3
|
| 42 |
+
},
|
| 43 |
+
"Sh": {
|
| 44 |
+
"type": "const",
|
| 45 |
+
"value": 1
|
| 46 |
+
},
|
| 47 |
+
"Sw": {
|
| 48 |
+
"type": "const",
|
| 49 |
+
"value": 1
|
| 50 |
+
},
|
| 51 |
+
"Dh": {
|
| 52 |
+
"type": "const",
|
| 53 |
+
"value": 2
|
| 54 |
+
},
|
| 55 |
+
"Dw": {
|
| 56 |
+
"type": "const",
|
| 57 |
+
"value": 2
|
| 58 |
+
},
|
| 59 |
+
"pad_top": {
|
| 60 |
+
"type": "const",
|
| 61 |
+
"value": 2
|
| 62 |
+
},
|
| 63 |
+
"pad_left": {
|
| 64 |
+
"type": "const",
|
| 65 |
+
"value": 2
|
| 66 |
+
}
|
| 67 |
+
},
|
| 68 |
+
"inputs": {
|
| 69 |
+
"input": {
|
| 70 |
+
"shape": [
|
| 71 |
+
"N",
|
| 72 |
+
"C_in",
|
| 73 |
+
"H",
|
| 74 |
+
"W"
|
| 75 |
+
],
|
| 76 |
+
"dtype": "float32"
|
| 77 |
+
},
|
| 78 |
+
"weight": {
|
| 79 |
+
"shape": [
|
| 80 |
+
"C_out",
|
| 81 |
+
"C_in",
|
| 82 |
+
"Kh",
|
| 83 |
+
"Kw"
|
| 84 |
+
],
|
| 85 |
+
"dtype": "float32"
|
| 86 |
+
},
|
| 87 |
+
"activation_type": {
|
| 88 |
+
"shape": null,
|
| 89 |
+
"dtype": "int32"
|
| 90 |
+
},
|
| 91 |
+
"with_bias": {
|
| 92 |
+
"shape": null,
|
| 93 |
+
"dtype": "int32"
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
"outputs": {
|
| 97 |
+
"output": {
|
| 98 |
+
"shape": [
|
| 99 |
+
"N",
|
| 100 |
+
"C_out",
|
| 101 |
+
"H_out",
|
| 102 |
+
"W_out"
|
| 103 |
+
],
|
| 104 |
+
"dtype": "float32"
|
| 105 |
+
}
|
| 106 |
+
},
|
| 107 |
+
"constraints": [
|
| 108 |
+
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 109 |
+
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 110 |
+
],
|
| 111 |
+
"reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, activation_type, with_bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight)\n return F.conv2d(x, w, None, stride=(1, 1), padding=(2, 2), dilation=(2, 2)).numpy()\n"
|
| 112 |
+
}
|
definitions/conv/conv2d_kh3_kw3_sh2_sw2_dh1_dw1_cout128.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "conv2d_kh3_kw3_sh2_sw2_dh1_dw1_cout128",
|
| 3 |
+
"op_type": "conv2d",
|
| 4 |
+
"description": "2D conv 3x3 stride=(2,2) dilation=(1,1) pad=(1,1) C_out=128. C_in varies per workload.",
|
| 5 |
+
"tags": [
|
| 6 |
+
"status:active"
|
| 7 |
+
],
|
| 8 |
+
"axes": {
|
| 9 |
+
"N": {
|
| 10 |
+
"type": "var"
|
| 11 |
+
},
|
| 12 |
+
"H": {
|
| 13 |
+
"type": "var",
|
| 14 |
+
"parent": "N"
|
| 15 |
+
},
|
| 16 |
+
"W": {
|
| 17 |
+
"type": "var",
|
| 18 |
+
"parent": "N"
|
| 19 |
+
},
|
| 20 |
+
"H_out": {
|
| 21 |
+
"type": "var",
|
| 22 |
+
"parent": "N"
|
| 23 |
+
},
|
| 24 |
+
"W_out": {
|
| 25 |
+
"type": "var",
|
| 26 |
+
"parent": "N"
|
| 27 |
+
},
|
| 28 |
+
"C_in": {
|
| 29 |
+
"type": "var"
|
| 30 |
+
},
|
| 31 |
+
"C_out": {
|
| 32 |
+
"type": "const",
|
| 33 |
+
"value": 128
|
| 34 |
+
},
|
| 35 |
+
"Kh": {
|
| 36 |
+
"type": "const",
|
| 37 |
+
"value": 3
|
| 38 |
+
},
|
| 39 |
+
"Kw": {
|
| 40 |
+
"type": "const",
|
| 41 |
+
"value": 3
|
| 42 |
+
},
|
| 43 |
+
"Sh": {
|
| 44 |
+
"type": "const",
|
| 45 |
+
"value": 2
|
| 46 |
+
},
|
| 47 |
+
"Sw": {
|
| 48 |
+
"type": "const",
|
| 49 |
+
"value": 2
|
| 50 |
+
},
|
| 51 |
+
"Dh": {
|
| 52 |
+
"type": "const",
|
| 53 |
+
"value": 1
|
| 54 |
+
},
|
| 55 |
+
"Dw": {
|
| 56 |
+
"type": "const",
|
| 57 |
+
"value": 1
|
| 58 |
+
},
|
| 59 |
+
"pad_top": {
|
| 60 |
+
"type": "const",
|
| 61 |
+
"value": 1
|
| 62 |
+
},
|
| 63 |
+
"pad_left": {
|
| 64 |
+
"type": "const",
|
| 65 |
+
"value": 1
|
| 66 |
+
}
|
| 67 |
+
},
|
| 68 |
+
"inputs": {
|
| 69 |
+
"input": {
|
| 70 |
+
"shape": [
|
| 71 |
+
"N",
|
| 72 |
+
"C_in",
|
| 73 |
+
"H",
|
| 74 |
+
"W"
|
| 75 |
+
],
|
| 76 |
+
"dtype": "float32"
|
| 77 |
+
},
|
| 78 |
+
"weight": {
|
| 79 |
+
"shape": [
|
| 80 |
+
"C_out",
|
| 81 |
+
"C_in",
|
| 82 |
+
"Kh",
|
| 83 |
+
"Kw"
|
| 84 |
+
],
|
| 85 |
+
"dtype": "float32"
|
| 86 |
+
},
|
| 87 |
+
"activation_type": {
|
| 88 |
+
"shape": null,
|
| 89 |
+
"dtype": "int32"
|
| 90 |
+
},
|
| 91 |
+
"with_bias": {
|
| 92 |
+
"shape": null,
|
| 93 |
+
"dtype": "int32"
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
"outputs": {
|
| 97 |
+
"output": {
|
| 98 |
+
"shape": [
|
| 99 |
+
"N",
|
| 100 |
+
"C_out",
|
| 101 |
+
"H_out",
|
| 102 |
+
"W_out"
|
| 103 |
+
],
|
| 104 |
+
"dtype": "float32"
|
| 105 |
+
}
|
| 106 |
+
},
|
| 107 |
+
"constraints": [
|
| 108 |
+
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 109 |
+
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 110 |
+
],
|
| 111 |
+
"reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, activation_type, with_bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight)\n return F.conv2d(x, w, None, stride=(2, 2), padding=(1, 1), dilation=(1, 1)).numpy()\n"
|
| 112 |
+
}
|
definitions/conv/conv2d_kh5_kw5_sh1_sw1_dh1_dw1_cout64.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "conv2d_kh5_kw5_sh1_sw1_dh1_dw1_cout64",
|
| 3 |
+
"op_type": "conv2d",
|
| 4 |
+
"description": "2D conv 5x5 stride=(1,1) dilation=(1,1) pad=(2,2) C_out=64. C_in varies per workload.",
|
| 5 |
+
"tags": [
|
| 6 |
+
"status:active"
|
| 7 |
+
],
|
| 8 |
+
"axes": {
|
| 9 |
+
"N": {
|
| 10 |
+
"type": "var"
|
| 11 |
+
},
|
| 12 |
+
"H": {
|
| 13 |
+
"type": "var",
|
| 14 |
+
"parent": "N"
|
| 15 |
+
},
|
| 16 |
+
"W": {
|
| 17 |
+
"type": "var",
|
| 18 |
+
"parent": "N"
|
| 19 |
+
},
|
| 20 |
+
"H_out": {
|
| 21 |
+
"type": "var",
|
| 22 |
+
"parent": "N"
|
| 23 |
+
},
|
| 24 |
+
"W_out": {
|
| 25 |
+
"type": "var",
|
| 26 |
+
"parent": "N"
|
| 27 |
+
},
|
| 28 |
+
"C_in": {
|
| 29 |
+
"type": "var"
|
| 30 |
+
},
|
| 31 |
+
"C_out": {
|
| 32 |
+
"type": "const",
|
| 33 |
+
"value": 64
|
| 34 |
+
},
|
| 35 |
+
"Kh": {
|
| 36 |
+
"type": "const",
|
| 37 |
+
"value": 5
|
| 38 |
+
},
|
| 39 |
+
"Kw": {
|
| 40 |
+
"type": "const",
|
| 41 |
+
"value": 5
|
| 42 |
+
},
|
| 43 |
+
"Sh": {
|
| 44 |
+
"type": "const",
|
| 45 |
+
"value": 1
|
| 46 |
+
},
|
| 47 |
+
"Sw": {
|
| 48 |
+
"type": "const",
|
| 49 |
+
"value": 1
|
| 50 |
+
},
|
| 51 |
+
"Dh": {
|
| 52 |
+
"type": "const",
|
| 53 |
+
"value": 1
|
| 54 |
+
},
|
| 55 |
+
"Dw": {
|
| 56 |
+
"type": "const",
|
| 57 |
+
"value": 1
|
| 58 |
+
},
|
| 59 |
+
"pad_top": {
|
| 60 |
+
"type": "const",
|
| 61 |
+
"value": 2
|
| 62 |
+
},
|
| 63 |
+
"pad_left": {
|
| 64 |
+
"type": "const",
|
| 65 |
+
"value": 2
|
| 66 |
+
}
|
| 67 |
+
},
|
| 68 |
+
"inputs": {
|
| 69 |
+
"input": {
|
| 70 |
+
"shape": [
|
| 71 |
+
"N",
|
| 72 |
+
"C_in",
|
| 73 |
+
"H",
|
| 74 |
+
"W"
|
| 75 |
+
],
|
| 76 |
+
"dtype": "float32"
|
| 77 |
+
},
|
| 78 |
+
"weight": {
|
| 79 |
+
"shape": [
|
| 80 |
+
"C_out",
|
| 81 |
+
"C_in",
|
| 82 |
+
"Kh",
|
| 83 |
+
"Kw"
|
| 84 |
+
],
|
| 85 |
+
"dtype": "float32"
|
| 86 |
+
},
|
| 87 |
+
"activation_type": {
|
| 88 |
+
"shape": null,
|
| 89 |
+
"dtype": "int32"
|
| 90 |
+
},
|
| 91 |
+
"with_bias": {
|
| 92 |
+
"shape": null,
|
| 93 |
+
"dtype": "int32"
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
"outputs": {
|
| 97 |
+
"output": {
|
| 98 |
+
"shape": [
|
| 99 |
+
"N",
|
| 100 |
+
"C_out",
|
| 101 |
+
"H_out",
|
| 102 |
+
"W_out"
|
| 103 |
+
],
|
| 104 |
+
"dtype": "float32"
|
| 105 |
+
}
|
| 106 |
+
},
|
| 107 |
+
"constraints": [
|
| 108 |
+
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 109 |
+
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 110 |
+
],
|
| 111 |
+
"reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, activation_type, with_bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight)\n return F.conv2d(x, w, None, stride=(1, 1), padding=(2, 2), dilation=(1, 1)).numpy()\n"
|
| 112 |
+
}
|
definitions/conv/conv2d_kh7_kw7_sh2_sw2_dh1_dw1_cout64.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "conv2d_kh7_kw7_sh2_sw2_dh1_dw1_cout64",
|
| 3 |
+
"op_type": "conv2d",
|
| 4 |
+
"description": "2D conv 7x7 stride=(2,2) dilation=(1,1) pad=(3,3) C_out=64. C_in varies per workload.",
|
| 5 |
+
"tags": [
|
| 6 |
+
"status:active"
|
| 7 |
+
],
|
| 8 |
+
"axes": {
|
| 9 |
+
"N": {
|
| 10 |
+
"type": "var"
|
| 11 |
+
},
|
| 12 |
+
"H": {
|
| 13 |
+
"type": "var",
|
| 14 |
+
"parent": "N"
|
| 15 |
+
},
|
| 16 |
+
"W": {
|
| 17 |
+
"type": "var",
|
| 18 |
+
"parent": "N"
|
| 19 |
+
},
|
| 20 |
+
"H_out": {
|
| 21 |
+
"type": "var",
|
| 22 |
+
"parent": "N"
|
| 23 |
+
},
|
| 24 |
+
"W_out": {
|
| 25 |
+
"type": "var",
|
| 26 |
+
"parent": "N"
|
| 27 |
+
},
|
| 28 |
+
"C_in": {
|
| 29 |
+
"type": "var"
|
| 30 |
+
},
|
| 31 |
+
"C_out": {
|
| 32 |
+
"type": "const",
|
| 33 |
+
"value": 64
|
| 34 |
+
},
|
| 35 |
+
"Kh": {
|
| 36 |
+
"type": "const",
|
| 37 |
+
"value": 7
|
| 38 |
+
},
|
| 39 |
+
"Kw": {
|
| 40 |
+
"type": "const",
|
| 41 |
+
"value": 7
|
| 42 |
+
},
|
| 43 |
+
"Sh": {
|
| 44 |
+
"type": "const",
|
| 45 |
+
"value": 2
|
| 46 |
+
},
|
| 47 |
+
"Sw": {
|
| 48 |
+
"type": "const",
|
| 49 |
+
"value": 2
|
| 50 |
+
},
|
| 51 |
+
"Dh": {
|
| 52 |
+
"type": "const",
|
| 53 |
+
"value": 1
|
| 54 |
+
},
|
| 55 |
+
"Dw": {
|
| 56 |
+
"type": "const",
|
| 57 |
+
"value": 1
|
| 58 |
+
},
|
| 59 |
+
"pad_top": {
|
| 60 |
+
"type": "const",
|
| 61 |
+
"value": 3
|
| 62 |
+
},
|
| 63 |
+
"pad_left": {
|
| 64 |
+
"type": "const",
|
| 65 |
+
"value": 3
|
| 66 |
+
}
|
| 67 |
+
},
|
| 68 |
+
"inputs": {
|
| 69 |
+
"input": {
|
| 70 |
+
"shape": [
|
| 71 |
+
"N",
|
| 72 |
+
"C_in",
|
| 73 |
+
"H",
|
| 74 |
+
"W"
|
| 75 |
+
],
|
| 76 |
+
"dtype": "float32"
|
| 77 |
+
},
|
| 78 |
+
"weight": {
|
| 79 |
+
"shape": [
|
| 80 |
+
"C_out",
|
| 81 |
+
"C_in",
|
| 82 |
+
"Kh",
|
| 83 |
+
"Kw"
|
| 84 |
+
],
|
| 85 |
+
"dtype": "float32"
|
| 86 |
+
},
|
| 87 |
+
"activation_type": {
|
| 88 |
+
"shape": null,
|
| 89 |
+
"dtype": "int32"
|
| 90 |
+
},
|
| 91 |
+
"with_bias": {
|
| 92 |
+
"shape": null,
|
| 93 |
+
"dtype": "int32"
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
"outputs": {
|
| 97 |
+
"output": {
|
| 98 |
+
"shape": [
|
| 99 |
+
"N",
|
| 100 |
+
"C_out",
|
| 101 |
+
"H_out",
|
| 102 |
+
"W_out"
|
| 103 |
+
],
|
| 104 |
+
"dtype": "float32"
|
| 105 |
+
}
|
| 106 |
+
},
|
| 107 |
+
"constraints": [
|
| 108 |
+
"H_out == (H + 2*pad_top - Dh*(Kh-1) - 1) // Sh + 1",
|
| 109 |
+
"W_out == (W + 2*pad_left - Dw*(Kw-1) - 1) // Sw + 1"
|
| 110 |
+
],
|
| 111 |
+
"reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, activation_type, with_bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight)\n return F.conv2d(x, w, None, stride=(2, 2), padding=(3, 3), dilation=(1, 1)).numpy()\n"
|
| 112 |
+
}
|
definitions/conv1d/conv1d_kw1_sw1_dw1_cout512_p0.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "conv1d_kw1_sw1_dw1_cout512_p0",
|
| 3 |
+
"op_type": "conv1d",
|
| 4 |
+
"description": "1D conv kw=1 stride=1 dilation=1 pad=0 C_out=512. C_in varies per workload.",
|
| 5 |
+
"tags": [
|
| 6 |
+
"status:active"
|
| 7 |
+
],
|
| 8 |
+
"axes": {
|
| 9 |
+
"W": {
|
| 10 |
+
"type": "var"
|
| 11 |
+
},
|
| 12 |
+
"W_out": {
|
| 13 |
+
"type": "var"
|
| 14 |
+
},
|
| 15 |
+
"C_in": {
|
| 16 |
+
"type": "var"
|
| 17 |
+
},
|
| 18 |
+
"C_out": {
|
| 19 |
+
"type": "const",
|
| 20 |
+
"value": 512
|
| 21 |
+
},
|
| 22 |
+
"Kw": {
|
| 23 |
+
"type": "const",
|
| 24 |
+
"value": 1
|
| 25 |
+
},
|
| 26 |
+
"Sw": {
|
| 27 |
+
"type": "const",
|
| 28 |
+
"value": 1
|
| 29 |
+
},
|
| 30 |
+
"Dw": {
|
| 31 |
+
"type": "const",
|
| 32 |
+
"value": 1
|
| 33 |
+
},
|
| 34 |
+
"pad": {
|
| 35 |
+
"type": "const",
|
| 36 |
+
"value": 0
|
| 37 |
+
}
|
| 38 |
+
},
|
| 39 |
+
"inputs": {
|
| 40 |
+
"input": {
|
| 41 |
+
"shape": [
|
| 42 |
+
"C_in",
|
| 43 |
+
"W"
|
| 44 |
+
],
|
| 45 |
+
"dtype": "float32"
|
| 46 |
+
},
|
| 47 |
+
"weight": {
|
| 48 |
+
"shape": [
|
| 49 |
+
"C_out",
|
| 50 |
+
"C_in",
|
| 51 |
+
"Kw"
|
| 52 |
+
],
|
| 53 |
+
"dtype": "float32"
|
| 54 |
+
},
|
| 55 |
+
"bias": {
|
| 56 |
+
"shape": [
|
| 57 |
+
"C_out"
|
| 58 |
+
],
|
| 59 |
+
"dtype": "float32"
|
| 60 |
+
}
|
| 61 |
+
},
|
| 62 |
+
"outputs": {
|
| 63 |
+
"output": {
|
| 64 |
+
"shape": [
|
| 65 |
+
"C_out",
|
| 66 |
+
"W_out"
|
| 67 |
+
],
|
| 68 |
+
"dtype": "float32"
|
| 69 |
+
}
|
| 70 |
+
},
|
| 71 |
+
"constraints": [
|
| 72 |
+
"W_out == (W + 2*pad - Dw*(Kw-1) - 1) // Sw + 1"
|
| 73 |
+
],
|
| 74 |
+
"reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n x = torch.from_numpy(input).unsqueeze(0)\n w = torch.from_numpy(weight)\n b = torch.from_numpy(bias)\n return F.conv1d(x, w, b, stride=1, padding=0, dilation=1).squeeze(0).numpy()\n"
|
| 75 |
+
}
|
definitions/conv1d/conv1d_kw3_sw1_dw1_cout512_p1.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "conv1d_kw3_sw1_dw1_cout512_p1",
|
| 3 |
+
"op_type": "conv1d",
|
| 4 |
+
"description": "1D conv kw=3 stride=1 dilation=1 pad=1 C_out=512. C_in varies per workload.",
|
| 5 |
+
"tags": [
|
| 6 |
+
"status:active"
|
| 7 |
+
],
|
| 8 |
+
"axes": {
|
| 9 |
+
"W": {
|
| 10 |
+
"type": "var"
|
| 11 |
+
},
|
| 12 |
+
"W_out": {
|
| 13 |
+
"type": "var"
|
| 14 |
+
},
|
| 15 |
+
"C_in": {
|
| 16 |
+
"type": "var"
|
| 17 |
+
},
|
| 18 |
+
"C_out": {
|
| 19 |
+
"type": "const",
|
| 20 |
+
"value": 512
|
| 21 |
+
},
|
| 22 |
+
"Kw": {
|
| 23 |
+
"type": "const",
|
| 24 |
+
"value": 3
|
| 25 |
+
},
|
| 26 |
+
"Sw": {
|
| 27 |
+
"type": "const",
|
| 28 |
+
"value": 1
|
| 29 |
+
},
|
| 30 |
+
"Dw": {
|
| 31 |
+
"type": "const",
|
| 32 |
+
"value": 1
|
| 33 |
+
},
|
| 34 |
+
"pad": {
|
| 35 |
+
"type": "const",
|
| 36 |
+
"value": 1
|
| 37 |
+
}
|
| 38 |
+
},
|
| 39 |
+
"inputs": {
|
| 40 |
+
"input": {
|
| 41 |
+
"shape": [
|
| 42 |
+
"C_in",
|
| 43 |
+
"W"
|
| 44 |
+
],
|
| 45 |
+
"dtype": "float32"
|
| 46 |
+
},
|
| 47 |
+
"weight": {
|
| 48 |
+
"shape": [
|
| 49 |
+
"C_out",
|
| 50 |
+
"C_in",
|
| 51 |
+
"Kw"
|
| 52 |
+
],
|
| 53 |
+
"dtype": "float32"
|
| 54 |
+
},
|
| 55 |
+
"bias": {
|
| 56 |
+
"shape": [
|
| 57 |
+
"C_out"
|
| 58 |
+
],
|
| 59 |
+
"dtype": "float32"
|
| 60 |
+
}
|
| 61 |
+
},
|
| 62 |
+
"outputs": {
|
| 63 |
+
"output": {
|
| 64 |
+
"shape": [
|
| 65 |
+
"C_out",
|
| 66 |
+
"W_out"
|
| 67 |
+
],
|
| 68 |
+
"dtype": "float32"
|
| 69 |
+
}
|
| 70 |
+
},
|
| 71 |
+
"constraints": [
|
| 72 |
+
"W_out == (W + 2*pad - Dw*(Kw-1) - 1) // Sw + 1"
|
| 73 |
+
],
|
| 74 |
+
"reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n x = torch.from_numpy(input).unsqueeze(0)\n w = torch.from_numpy(weight)\n b = torch.from_numpy(bias)\n return F.conv1d(x, w, b, stride=1, padding=1, dilation=1).squeeze(0).numpy()\n"
|
| 75 |
+
}
|
definitions/conv2d_depthwise/conv2d_depthwise_kh3_kw3_sh1_sw1_dh1_dw1_p1.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "conv2d_depthwise_kh3_kw3_sh1_sw1_dh1_dw1_p1",
|
| 3 |
+
"op_type": "conv2d_depthwise",
|
| 4 |
+
"description": "Depthwise 2D conv 3x3 stride=(1,1) dilation=(1,1) pad=1. C varies per workload.",
|
| 5 |
+
"tags": [
|
| 6 |
+
"status:active"
|
| 7 |
+
],
|
| 8 |
+
"axes": {
|
| 9 |
+
"N": {
|
| 10 |
+
"type": "var"
|
| 11 |
+
},
|
| 12 |
+
"H": {
|
| 13 |
+
"type": "var",
|
| 14 |
+
"parent": "N"
|
| 15 |
+
},
|
| 16 |
+
"W": {
|
| 17 |
+
"type": "var",
|
| 18 |
+
"parent": "N"
|
| 19 |
+
},
|
| 20 |
+
"H_out": {
|
| 21 |
+
"type": "var",
|
| 22 |
+
"parent": "N"
|
| 23 |
+
},
|
| 24 |
+
"W_out": {
|
| 25 |
+
"type": "var",
|
| 26 |
+
"parent": "N"
|
| 27 |
+
},
|
| 28 |
+
"C": {
|
| 29 |
+
"type": "var"
|
| 30 |
+
},
|
| 31 |
+
"Kh": {
|
| 32 |
+
"type": "const",
|
| 33 |
+
"value": 3
|
| 34 |
+
},
|
| 35 |
+
"Kw": {
|
| 36 |
+
"type": "const",
|
| 37 |
+
"value": 3
|
| 38 |
+
},
|
| 39 |
+
"Sh": {
|
| 40 |
+
"type": "const",
|
| 41 |
+
"value": 1
|
| 42 |
+
},
|
| 43 |
+
"Sw": {
|
| 44 |
+
"type": "const",
|
| 45 |
+
"value": 1
|
| 46 |
+
},
|
| 47 |
+
"Dh": {
|
| 48 |
+
"type": "const",
|
| 49 |
+
"value": 1
|
| 50 |
+
},
|
| 51 |
+
"Dw": {
|
| 52 |
+
"type": "const",
|
| 53 |
+
"value": 1
|
| 54 |
+
},
|
| 55 |
+
"pad": {
|
| 56 |
+
"type": "const",
|
| 57 |
+
"value": 1
|
| 58 |
+
}
|
| 59 |
+
},
|
| 60 |
+
"inputs": {
|
| 61 |
+
"input": {
|
| 62 |
+
"shape": [
|
| 63 |
+
"N",
|
| 64 |
+
"C",
|
| 65 |
+
"H",
|
| 66 |
+
"W"
|
| 67 |
+
],
|
| 68 |
+
"dtype": "float32"
|
| 69 |
+
},
|
| 70 |
+
"weight": {
|
| 71 |
+
"shape": [
|
| 72 |
+
"C",
|
| 73 |
+
"Kh",
|
| 74 |
+
"Kw"
|
| 75 |
+
],
|
| 76 |
+
"dtype": "float32"
|
| 77 |
+
},
|
| 78 |
+
"bias": {
|
| 79 |
+
"shape": [
|
| 80 |
+
"C"
|
| 81 |
+
],
|
| 82 |
+
"dtype": "float32"
|
| 83 |
+
}
|
| 84 |
+
},
|
| 85 |
+
"outputs": {
|
| 86 |
+
"output": {
|
| 87 |
+
"shape": [
|
| 88 |
+
"N",
|
| 89 |
+
"C",
|
| 90 |
+
"H_out",
|
| 91 |
+
"W_out"
|
| 92 |
+
],
|
| 93 |
+
"dtype": "float32"
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
"constraints": [
|
| 97 |
+
"H_out == (H + 2*pad - Dh*(Kh-1) - 1) // Sh + 1",
|
| 98 |
+
"W_out == (W + 2*pad - Dw*(Kw-1) - 1) // Sw + 1"
|
| 99 |
+
],
|
| 100 |
+
"reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n c = input.shape[1]\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight).unsqueeze(1)\n b = torch.from_numpy(bias)\n return F.conv2d(x, w, b, stride=(1, 1), padding=(1, 1), dilation=(1, 1), groups=c).numpy()\n"
|
| 101 |
+
}
|
definitions/conv2d_depthwise/conv2d_depthwise_kh3_kw3_sh2_sw2_dh1_dw1_p1.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "conv2d_depthwise_kh3_kw3_sh2_sw2_dh1_dw1_p1",
|
| 3 |
+
"op_type": "conv2d_depthwise",
|
| 4 |
+
"description": "Depthwise 2D conv 3x3 stride=(2,2) dilation=(1,1) pad=1. C varies per workload.",
|
| 5 |
+
"tags": [
|
| 6 |
+
"status:active"
|
| 7 |
+
],
|
| 8 |
+
"axes": {
|
| 9 |
+
"N": {
|
| 10 |
+
"type": "var"
|
| 11 |
+
},
|
| 12 |
+
"H": {
|
| 13 |
+
"type": "var",
|
| 14 |
+
"parent": "N"
|
| 15 |
+
},
|
| 16 |
+
"W": {
|
| 17 |
+
"type": "var",
|
| 18 |
+
"parent": "N"
|
| 19 |
+
},
|
| 20 |
+
"H_out": {
|
| 21 |
+
"type": "var",
|
| 22 |
+
"parent": "N"
|
| 23 |
+
},
|
| 24 |
+
"W_out": {
|
| 25 |
+
"type": "var",
|
| 26 |
+
"parent": "N"
|
| 27 |
+
},
|
| 28 |
+
"C": {
|
| 29 |
+
"type": "var"
|
| 30 |
+
},
|
| 31 |
+
"Kh": {
|
| 32 |
+
"type": "const",
|
| 33 |
+
"value": 3
|
| 34 |
+
},
|
| 35 |
+
"Kw": {
|
| 36 |
+
"type": "const",
|
| 37 |
+
"value": 3
|
| 38 |
+
},
|
| 39 |
+
"Sh": {
|
| 40 |
+
"type": "const",
|
| 41 |
+
"value": 2
|
| 42 |
+
},
|
| 43 |
+
"Sw": {
|
| 44 |
+
"type": "const",
|
| 45 |
+
"value": 2
|
| 46 |
+
},
|
| 47 |
+
"Dh": {
|
| 48 |
+
"type": "const",
|
| 49 |
+
"value": 1
|
| 50 |
+
},
|
| 51 |
+
"Dw": {
|
| 52 |
+
"type": "const",
|
| 53 |
+
"value": 1
|
| 54 |
+
},
|
| 55 |
+
"pad": {
|
| 56 |
+
"type": "const",
|
| 57 |
+
"value": 1
|
| 58 |
+
}
|
| 59 |
+
},
|
| 60 |
+
"inputs": {
|
| 61 |
+
"input": {
|
| 62 |
+
"shape": [
|
| 63 |
+
"N",
|
| 64 |
+
"C",
|
| 65 |
+
"H",
|
| 66 |
+
"W"
|
| 67 |
+
],
|
| 68 |
+
"dtype": "float32"
|
| 69 |
+
},
|
| 70 |
+
"weight": {
|
| 71 |
+
"shape": [
|
| 72 |
+
"C",
|
| 73 |
+
"Kh",
|
| 74 |
+
"Kw"
|
| 75 |
+
],
|
| 76 |
+
"dtype": "float32"
|
| 77 |
+
},
|
| 78 |
+
"bias": {
|
| 79 |
+
"shape": [
|
| 80 |
+
"C"
|
| 81 |
+
],
|
| 82 |
+
"dtype": "float32"
|
| 83 |
+
}
|
| 84 |
+
},
|
| 85 |
+
"outputs": {
|
| 86 |
+
"output": {
|
| 87 |
+
"shape": [
|
| 88 |
+
"N",
|
| 89 |
+
"C",
|
| 90 |
+
"H_out",
|
| 91 |
+
"W_out"
|
| 92 |
+
],
|
| 93 |
+
"dtype": "float32"
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
"constraints": [
|
| 97 |
+
"H_out == (H + 2*pad - Dh*(Kh-1) - 1) // Sh + 1",
|
| 98 |
+
"W_out == (W + 2*pad - Dw*(Kw-1) - 1) // Sw + 1"
|
| 99 |
+
],
|
| 100 |
+
"reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n c = input.shape[1]\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight).unsqueeze(1)\n b = torch.from_numpy(bias)\n return F.conv2d(x, w, b, stride=(2, 2), padding=(1, 1), dilation=(1, 1), groups=c).numpy()\n"
|
| 101 |
+
}
|
definitions/conv2d_depthwise/conv2d_depthwise_kh5_kw5_sh1_sw1_dh1_dw1_p2.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "conv2d_depthwise_kh5_kw5_sh1_sw1_dh1_dw1_p2",
|
| 3 |
+
"op_type": "conv2d_depthwise",
|
| 4 |
+
"description": "Depthwise 2D conv 5x5 stride=(1,1) dilation=(1,1) pad=2. C varies per workload.",
|
| 5 |
+
"tags": [
|
| 6 |
+
"status:active"
|
| 7 |
+
],
|
| 8 |
+
"axes": {
|
| 9 |
+
"N": {
|
| 10 |
+
"type": "var"
|
| 11 |
+
},
|
| 12 |
+
"H": {
|
| 13 |
+
"type": "var",
|
| 14 |
+
"parent": "N"
|
| 15 |
+
},
|
| 16 |
+
"W": {
|
| 17 |
+
"type": "var",
|
| 18 |
+
"parent": "N"
|
| 19 |
+
},
|
| 20 |
+
"H_out": {
|
| 21 |
+
"type": "var",
|
| 22 |
+
"parent": "N"
|
| 23 |
+
},
|
| 24 |
+
"W_out": {
|
| 25 |
+
"type": "var",
|
| 26 |
+
"parent": "N"
|
| 27 |
+
},
|
| 28 |
+
"C": {
|
| 29 |
+
"type": "var"
|
| 30 |
+
},
|
| 31 |
+
"Kh": {
|
| 32 |
+
"type": "const",
|
| 33 |
+
"value": 5
|
| 34 |
+
},
|
| 35 |
+
"Kw": {
|
| 36 |
+
"type": "const",
|
| 37 |
+
"value": 5
|
| 38 |
+
},
|
| 39 |
+
"Sh": {
|
| 40 |
+
"type": "const",
|
| 41 |
+
"value": 1
|
| 42 |
+
},
|
| 43 |
+
"Sw": {
|
| 44 |
+
"type": "const",
|
| 45 |
+
"value": 1
|
| 46 |
+
},
|
| 47 |
+
"Dh": {
|
| 48 |
+
"type": "const",
|
| 49 |
+
"value": 1
|
| 50 |
+
},
|
| 51 |
+
"Dw": {
|
| 52 |
+
"type": "const",
|
| 53 |
+
"value": 1
|
| 54 |
+
},
|
| 55 |
+
"pad": {
|
| 56 |
+
"type": "const",
|
| 57 |
+
"value": 2
|
| 58 |
+
}
|
| 59 |
+
},
|
| 60 |
+
"inputs": {
|
| 61 |
+
"input": {
|
| 62 |
+
"shape": [
|
| 63 |
+
"N",
|
| 64 |
+
"C",
|
| 65 |
+
"H",
|
| 66 |
+
"W"
|
| 67 |
+
],
|
| 68 |
+
"dtype": "float32"
|
| 69 |
+
},
|
| 70 |
+
"weight": {
|
| 71 |
+
"shape": [
|
| 72 |
+
"C",
|
| 73 |
+
"Kh",
|
| 74 |
+
"Kw"
|
| 75 |
+
],
|
| 76 |
+
"dtype": "float32"
|
| 77 |
+
},
|
| 78 |
+
"bias": {
|
| 79 |
+
"shape": [
|
| 80 |
+
"C"
|
| 81 |
+
],
|
| 82 |
+
"dtype": "float32"
|
| 83 |
+
}
|
| 84 |
+
},
|
| 85 |
+
"outputs": {
|
| 86 |
+
"output": {
|
| 87 |
+
"shape": [
|
| 88 |
+
"N",
|
| 89 |
+
"C",
|
| 90 |
+
"H_out",
|
| 91 |
+
"W_out"
|
| 92 |
+
],
|
| 93 |
+
"dtype": "float32"
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
"constraints": [
|
| 97 |
+
"H_out == (H + 2*pad - Dh*(Kh-1) - 1) // Sh + 1",
|
| 98 |
+
"W_out == (W + 2*pad - Dw*(Kw-1) - 1) // Sw + 1"
|
| 99 |
+
],
|
| 100 |
+
"reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n c = input.shape[1]\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight).unsqueeze(1)\n b = torch.from_numpy(bias)\n return F.conv2d(x, w, b, stride=(1, 1), padding=(2, 2), dilation=(1, 1), groups=c).numpy()\n"
|
| 101 |
+
}
|
definitions/deconv2d/deconv2d_kh3_kw3_sh1_sw1_cout256.json
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "deconv2d_kh3_kw3_sh1_sw1_cout256",
|
| 3 |
+
"op_type": "deconv2d",
|
| 4 |
+
"description": "Transposed 2D conv 3x3 stride=(1,1) dilation=(1,1) pad=0 C_out=256. C_in varies per workload.",
|
| 5 |
+
"tags": [
|
| 6 |
+
"status:active"
|
| 7 |
+
],
|
| 8 |
+
"axes": {
|
| 9 |
+
"N": {
|
| 10 |
+
"type": "var"
|
| 11 |
+
},
|
| 12 |
+
"H": {
|
| 13 |
+
"type": "var",
|
| 14 |
+
"parent": "N"
|
| 15 |
+
},
|
| 16 |
+
"W": {
|
| 17 |
+
"type": "var",
|
| 18 |
+
"parent": "N"
|
| 19 |
+
},
|
| 20 |
+
"H_out": {
|
| 21 |
+
"type": "var",
|
| 22 |
+
"parent": "N"
|
| 23 |
+
},
|
| 24 |
+
"W_out": {
|
| 25 |
+
"type": "var",
|
| 26 |
+
"parent": "N"
|
| 27 |
+
},
|
| 28 |
+
"C_in": {
|
| 29 |
+
"type": "var"
|
| 30 |
+
},
|
| 31 |
+
"C_out": {
|
| 32 |
+
"type": "const",
|
| 33 |
+
"value": 256
|
| 34 |
+
},
|
| 35 |
+
"Kh": {
|
| 36 |
+
"type": "const",
|
| 37 |
+
"value": 3
|
| 38 |
+
},
|
| 39 |
+
"Kw": {
|
| 40 |
+
"type": "const",
|
| 41 |
+
"value": 3
|
| 42 |
+
},
|
| 43 |
+
"Sh": {
|
| 44 |
+
"type": "const",
|
| 45 |
+
"value": 1
|
| 46 |
+
},
|
| 47 |
+
"Sw": {
|
| 48 |
+
"type": "const",
|
| 49 |
+
"value": 1
|
| 50 |
+
},
|
| 51 |
+
"Dh": {
|
| 52 |
+
"type": "const",
|
| 53 |
+
"value": 1
|
| 54 |
+
},
|
| 55 |
+
"Dw": {
|
| 56 |
+
"type": "const",
|
| 57 |
+
"value": 1
|
| 58 |
+
}
|
| 59 |
+
},
|
| 60 |
+
"inputs": {
|
| 61 |
+
"input": {
|
| 62 |
+
"shape": [
|
| 63 |
+
"N",
|
| 64 |
+
"C_in",
|
| 65 |
+
"H",
|
| 66 |
+
"W"
|
| 67 |
+
],
|
| 68 |
+
"dtype": "float32"
|
| 69 |
+
},
|
| 70 |
+
"weight": {
|
| 71 |
+
"shape": [
|
| 72 |
+
"C_out",
|
| 73 |
+
"C_in",
|
| 74 |
+
"Kh",
|
| 75 |
+
"Kw"
|
| 76 |
+
],
|
| 77 |
+
"dtype": "float32"
|
| 78 |
+
},
|
| 79 |
+
"bias": {
|
| 80 |
+
"shape": [
|
| 81 |
+
"C_out"
|
| 82 |
+
],
|
| 83 |
+
"dtype": "float32"
|
| 84 |
+
}
|
| 85 |
+
},
|
| 86 |
+
"outputs": {
|
| 87 |
+
"output": {
|
| 88 |
+
"shape": [
|
| 89 |
+
"N",
|
| 90 |
+
"C_out",
|
| 91 |
+
"H_out",
|
| 92 |
+
"W_out"
|
| 93 |
+
],
|
| 94 |
+
"dtype": "float32"
|
| 95 |
+
}
|
| 96 |
+
},
|
| 97 |
+
"constraints": [
|
| 98 |
+
"H_out == (H - 1) * Sh + Kh",
|
| 99 |
+
"W_out == (W - 1) * Sw + Kw"
|
| 100 |
+
],
|
| 101 |
+
"reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight).permute(1, 0, 2, 3)\n b = torch.from_numpy(bias)\n return F.conv_transpose2d(x, w, b, stride=(1, 1), padding=(0, 0), dilation=(1, 1)).numpy()\n"
|
| 102 |
+
}
|
definitions/deconv2d/deconv2d_kh3_kw3_sh2_sw2_cout256.json
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "deconv2d_kh3_kw3_sh2_sw2_cout256",
|
| 3 |
+
"op_type": "deconv2d",
|
| 4 |
+
"description": "Transposed 2D conv 3x3 stride=(2,2) dilation=(1,1) pad=0 C_out=256. C_in varies per workload.",
|
| 5 |
+
"tags": [
|
| 6 |
+
"status:active"
|
| 7 |
+
],
|
| 8 |
+
"axes": {
|
| 9 |
+
"N": {
|
| 10 |
+
"type": "var"
|
| 11 |
+
},
|
| 12 |
+
"H": {
|
| 13 |
+
"type": "var",
|
| 14 |
+
"parent": "N"
|
| 15 |
+
},
|
| 16 |
+
"W": {
|
| 17 |
+
"type": "var",
|
| 18 |
+
"parent": "N"
|
| 19 |
+
},
|
| 20 |
+
"H_out": {
|
| 21 |
+
"type": "var",
|
| 22 |
+
"parent": "N"
|
| 23 |
+
},
|
| 24 |
+
"W_out": {
|
| 25 |
+
"type": "var",
|
| 26 |
+
"parent": "N"
|
| 27 |
+
},
|
| 28 |
+
"C_in": {
|
| 29 |
+
"type": "var"
|
| 30 |
+
},
|
| 31 |
+
"C_out": {
|
| 32 |
+
"type": "const",
|
| 33 |
+
"value": 256
|
| 34 |
+
},
|
| 35 |
+
"Kh": {
|
| 36 |
+
"type": "const",
|
| 37 |
+
"value": 3
|
| 38 |
+
},
|
| 39 |
+
"Kw": {
|
| 40 |
+
"type": "const",
|
| 41 |
+
"value": 3
|
| 42 |
+
},
|
| 43 |
+
"Sh": {
|
| 44 |
+
"type": "const",
|
| 45 |
+
"value": 2
|
| 46 |
+
},
|
| 47 |
+
"Sw": {
|
| 48 |
+
"type": "const",
|
| 49 |
+
"value": 2
|
| 50 |
+
},
|
| 51 |
+
"Dh": {
|
| 52 |
+
"type": "const",
|
| 53 |
+
"value": 1
|
| 54 |
+
},
|
| 55 |
+
"Dw": {
|
| 56 |
+
"type": "const",
|
| 57 |
+
"value": 1
|
| 58 |
+
}
|
| 59 |
+
},
|
| 60 |
+
"inputs": {
|
| 61 |
+
"input": {
|
| 62 |
+
"shape": [
|
| 63 |
+
"N",
|
| 64 |
+
"C_in",
|
| 65 |
+
"H",
|
| 66 |
+
"W"
|
| 67 |
+
],
|
| 68 |
+
"dtype": "float32"
|
| 69 |
+
},
|
| 70 |
+
"weight": {
|
| 71 |
+
"shape": [
|
| 72 |
+
"C_out",
|
| 73 |
+
"C_in",
|
| 74 |
+
"Kh",
|
| 75 |
+
"Kw"
|
| 76 |
+
],
|
| 77 |
+
"dtype": "float32"
|
| 78 |
+
},
|
| 79 |
+
"bias": {
|
| 80 |
+
"shape": [
|
| 81 |
+
"C_out"
|
| 82 |
+
],
|
| 83 |
+
"dtype": "float32"
|
| 84 |
+
}
|
| 85 |
+
},
|
| 86 |
+
"outputs": {
|
| 87 |
+
"output": {
|
| 88 |
+
"shape": [
|
| 89 |
+
"N",
|
| 90 |
+
"C_out",
|
| 91 |
+
"H_out",
|
| 92 |
+
"W_out"
|
| 93 |
+
],
|
| 94 |
+
"dtype": "float32"
|
| 95 |
+
}
|
| 96 |
+
},
|
| 97 |
+
"constraints": [
|
| 98 |
+
"H_out == (H - 1) * Sh + Kh",
|
| 99 |
+
"W_out == (W - 1) * Sw + Kw"
|
| 100 |
+
],
|
| 101 |
+
"reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight).permute(1, 0, 2, 3)\n b = torch.from_numpy(bias)\n return F.conv_transpose2d(x, w, b, stride=(2, 2), padding=(0, 0), dilation=(1, 1)).numpy()\n"
|
| 102 |
+
}
|
definitions/deconv2d/deconv2d_kh4_kw4_sh1_sw1_cout128.json
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "deconv2d_kh4_kw4_sh1_sw1_cout128",
|
| 3 |
+
"op_type": "deconv2d",
|
| 4 |
+
"description": "Transposed 2D conv 4x4 stride=(1,1) dilation=(1,1) pad=0 C_out=128. C_in varies per workload.",
|
| 5 |
+
"tags": [
|
| 6 |
+
"status:active"
|
| 7 |
+
],
|
| 8 |
+
"axes": {
|
| 9 |
+
"N": {
|
| 10 |
+
"type": "var"
|
| 11 |
+
},
|
| 12 |
+
"H": {
|
| 13 |
+
"type": "var",
|
| 14 |
+
"parent": "N"
|
| 15 |
+
},
|
| 16 |
+
"W": {
|
| 17 |
+
"type": "var",
|
| 18 |
+
"parent": "N"
|
| 19 |
+
},
|
| 20 |
+
"H_out": {
|
| 21 |
+
"type": "var",
|
| 22 |
+
"parent": "N"
|
| 23 |
+
},
|
| 24 |
+
"W_out": {
|
| 25 |
+
"type": "var",
|
| 26 |
+
"parent": "N"
|
| 27 |
+
},
|
| 28 |
+
"C_in": {
|
| 29 |
+
"type": "var"
|
| 30 |
+
},
|
| 31 |
+
"C_out": {
|
| 32 |
+
"type": "const",
|
| 33 |
+
"value": 128
|
| 34 |
+
},
|
| 35 |
+
"Kh": {
|
| 36 |
+
"type": "const",
|
| 37 |
+
"value": 4
|
| 38 |
+
},
|
| 39 |
+
"Kw": {
|
| 40 |
+
"type": "const",
|
| 41 |
+
"value": 4
|
| 42 |
+
},
|
| 43 |
+
"Sh": {
|
| 44 |
+
"type": "const",
|
| 45 |
+
"value": 1
|
| 46 |
+
},
|
| 47 |
+
"Sw": {
|
| 48 |
+
"type": "const",
|
| 49 |
+
"value": 1
|
| 50 |
+
},
|
| 51 |
+
"Dh": {
|
| 52 |
+
"type": "const",
|
| 53 |
+
"value": 1
|
| 54 |
+
},
|
| 55 |
+
"Dw": {
|
| 56 |
+
"type": "const",
|
| 57 |
+
"value": 1
|
| 58 |
+
}
|
| 59 |
+
},
|
| 60 |
+
"inputs": {
|
| 61 |
+
"input": {
|
| 62 |
+
"shape": [
|
| 63 |
+
"N",
|
| 64 |
+
"C_in",
|
| 65 |
+
"H",
|
| 66 |
+
"W"
|
| 67 |
+
],
|
| 68 |
+
"dtype": "float32"
|
| 69 |
+
},
|
| 70 |
+
"weight": {
|
| 71 |
+
"shape": [
|
| 72 |
+
"C_out",
|
| 73 |
+
"C_in",
|
| 74 |
+
"Kh",
|
| 75 |
+
"Kw"
|
| 76 |
+
],
|
| 77 |
+
"dtype": "float32"
|
| 78 |
+
},
|
| 79 |
+
"bias": {
|
| 80 |
+
"shape": [
|
| 81 |
+
"C_out"
|
| 82 |
+
],
|
| 83 |
+
"dtype": "float32"
|
| 84 |
+
}
|
| 85 |
+
},
|
| 86 |
+
"outputs": {
|
| 87 |
+
"output": {
|
| 88 |
+
"shape": [
|
| 89 |
+
"N",
|
| 90 |
+
"C_out",
|
| 91 |
+
"H_out",
|
| 92 |
+
"W_out"
|
| 93 |
+
],
|
| 94 |
+
"dtype": "float32"
|
| 95 |
+
}
|
| 96 |
+
},
|
| 97 |
+
"constraints": [
|
| 98 |
+
"H_out == (H - 1) * Sh + Kh",
|
| 99 |
+
"W_out == (W - 1) * Sw + Kw"
|
| 100 |
+
],
|
| 101 |
+
"reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight).permute(1, 0, 2, 3)\n b = torch.from_numpy(bias)\n return F.conv_transpose2d(x, w, b, stride=(1, 1), padding=(0, 0), dilation=(1, 1)).numpy()\n"
|
| 102 |
+
}
|
definitions/deconv2d/deconv2d_kh4_kw4_sh2_sw2_cout128.json
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "deconv2d_kh4_kw4_sh2_sw2_cout128",
|
| 3 |
+
"op_type": "deconv2d",
|
| 4 |
+
"description": "Transposed 2D conv 4x4 stride=(2,2) dilation=(1,1) pad=0 C_out=128. C_in varies per workload.",
|
| 5 |
+
"tags": [
|
| 6 |
+
"status:active"
|
| 7 |
+
],
|
| 8 |
+
"axes": {
|
| 9 |
+
"N": {
|
| 10 |
+
"type": "var"
|
| 11 |
+
},
|
| 12 |
+
"H": {
|
| 13 |
+
"type": "var",
|
| 14 |
+
"parent": "N"
|
| 15 |
+
},
|
| 16 |
+
"W": {
|
| 17 |
+
"type": "var",
|
| 18 |
+
"parent": "N"
|
| 19 |
+
},
|
| 20 |
+
"H_out": {
|
| 21 |
+
"type": "var",
|
| 22 |
+
"parent": "N"
|
| 23 |
+
},
|
| 24 |
+
"W_out": {
|
| 25 |
+
"type": "var",
|
| 26 |
+
"parent": "N"
|
| 27 |
+
},
|
| 28 |
+
"C_in": {
|
| 29 |
+
"type": "var"
|
| 30 |
+
},
|
| 31 |
+
"C_out": {
|
| 32 |
+
"type": "const",
|
| 33 |
+
"value": 128
|
| 34 |
+
},
|
| 35 |
+
"Kh": {
|
| 36 |
+
"type": "const",
|
| 37 |
+
"value": 4
|
| 38 |
+
},
|
| 39 |
+
"Kw": {
|
| 40 |
+
"type": "const",
|
| 41 |
+
"value": 4
|
| 42 |
+
},
|
| 43 |
+
"Sh": {
|
| 44 |
+
"type": "const",
|
| 45 |
+
"value": 2
|
| 46 |
+
},
|
| 47 |
+
"Sw": {
|
| 48 |
+
"type": "const",
|
| 49 |
+
"value": 2
|
| 50 |
+
},
|
| 51 |
+
"Dh": {
|
| 52 |
+
"type": "const",
|
| 53 |
+
"value": 1
|
| 54 |
+
},
|
| 55 |
+
"Dw": {
|
| 56 |
+
"type": "const",
|
| 57 |
+
"value": 1
|
| 58 |
+
}
|
| 59 |
+
},
|
| 60 |
+
"inputs": {
|
| 61 |
+
"input": {
|
| 62 |
+
"shape": [
|
| 63 |
+
"N",
|
| 64 |
+
"C_in",
|
| 65 |
+
"H",
|
| 66 |
+
"W"
|
| 67 |
+
],
|
| 68 |
+
"dtype": "float32"
|
| 69 |
+
},
|
| 70 |
+
"weight": {
|
| 71 |
+
"shape": [
|
| 72 |
+
"C_out",
|
| 73 |
+
"C_in",
|
| 74 |
+
"Kh",
|
| 75 |
+
"Kw"
|
| 76 |
+
],
|
| 77 |
+
"dtype": "float32"
|
| 78 |
+
},
|
| 79 |
+
"bias": {
|
| 80 |
+
"shape": [
|
| 81 |
+
"C_out"
|
| 82 |
+
],
|
| 83 |
+
"dtype": "float32"
|
| 84 |
+
}
|
| 85 |
+
},
|
| 86 |
+
"outputs": {
|
| 87 |
+
"output": {
|
| 88 |
+
"shape": [
|
| 89 |
+
"N",
|
| 90 |
+
"C_out",
|
| 91 |
+
"H_out",
|
| 92 |
+
"W_out"
|
| 93 |
+
],
|
| 94 |
+
"dtype": "float32"
|
| 95 |
+
}
|
| 96 |
+
},
|
| 97 |
+
"constraints": [
|
| 98 |
+
"H_out == (H - 1) * Sh + Kh",
|
| 99 |
+
"W_out == (W - 1) * Sw + Kw"
|
| 100 |
+
],
|
| 101 |
+
"reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight).permute(1, 0, 2, 3)\n b = torch.from_numpy(bias)\n return F.conv_transpose2d(x, w, b, stride=(2, 2), padding=(0, 0), dilation=(1, 1)).numpy()\n"
|
| 102 |
+
}
|
definitions/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2.json
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "deconv2d_depthwise_kh2_kw2_sh2_sw2",
|
| 3 |
+
"op_type": "deconv2d_depthwise",
|
| 4 |
+
"description": "Depthwise transposed 2D conv 2x2 stride=(2,2) dilation=(1,1) pad=0. C varies per workload.",
|
| 5 |
+
"tags": [
|
| 6 |
+
"status:active"
|
| 7 |
+
],
|
| 8 |
+
"axes": {
|
| 9 |
+
"N": {
|
| 10 |
+
"type": "var"
|
| 11 |
+
},
|
| 12 |
+
"H": {
|
| 13 |
+
"type": "var",
|
| 14 |
+
"parent": "N"
|
| 15 |
+
},
|
| 16 |
+
"W": {
|
| 17 |
+
"type": "var",
|
| 18 |
+
"parent": "N"
|
| 19 |
+
},
|
| 20 |
+
"H_out": {
|
| 21 |
+
"type": "var",
|
| 22 |
+
"parent": "N"
|
| 23 |
+
},
|
| 24 |
+
"W_out": {
|
| 25 |
+
"type": "var",
|
| 26 |
+
"parent": "N"
|
| 27 |
+
},
|
| 28 |
+
"C": {
|
| 29 |
+
"type": "var"
|
| 30 |
+
},
|
| 31 |
+
"Kh": {
|
| 32 |
+
"type": "const",
|
| 33 |
+
"value": 2
|
| 34 |
+
},
|
| 35 |
+
"Kw": {
|
| 36 |
+
"type": "const",
|
| 37 |
+
"value": 2
|
| 38 |
+
},
|
| 39 |
+
"Sh": {
|
| 40 |
+
"type": "const",
|
| 41 |
+
"value": 2
|
| 42 |
+
},
|
| 43 |
+
"Sw": {
|
| 44 |
+
"type": "const",
|
| 45 |
+
"value": 2
|
| 46 |
+
},
|
| 47 |
+
"Dh": {
|
| 48 |
+
"type": "const",
|
| 49 |
+
"value": 1
|
| 50 |
+
},
|
| 51 |
+
"Dw": {
|
| 52 |
+
"type": "const",
|
| 53 |
+
"value": 1
|
| 54 |
+
}
|
| 55 |
+
},
|
| 56 |
+
"inputs": {
|
| 57 |
+
"input": {
|
| 58 |
+
"shape": [
|
| 59 |
+
"N",
|
| 60 |
+
"C",
|
| 61 |
+
"H",
|
| 62 |
+
"W"
|
| 63 |
+
],
|
| 64 |
+
"dtype": "float32"
|
| 65 |
+
},
|
| 66 |
+
"weight": {
|
| 67 |
+
"shape": [
|
| 68 |
+
"C",
|
| 69 |
+
"Kh",
|
| 70 |
+
"Kw"
|
| 71 |
+
],
|
| 72 |
+
"dtype": "float32"
|
| 73 |
+
},
|
| 74 |
+
"bias": {
|
| 75 |
+
"shape": [
|
| 76 |
+
"C"
|
| 77 |
+
],
|
| 78 |
+
"dtype": "float32"
|
| 79 |
+
}
|
| 80 |
+
},
|
| 81 |
+
"outputs": {
|
| 82 |
+
"output": {
|
| 83 |
+
"shape": [
|
| 84 |
+
"N",
|
| 85 |
+
"C",
|
| 86 |
+
"H_out",
|
| 87 |
+
"W_out"
|
| 88 |
+
],
|
| 89 |
+
"dtype": "float32"
|
| 90 |
+
}
|
| 91 |
+
},
|
| 92 |
+
"constraints": [
|
| 93 |
+
"H_out == (H - 1) * Sh + Kh",
|
| 94 |
+
"W_out == (W - 1) * Sw + Kw"
|
| 95 |
+
],
|
| 96 |
+
"reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n c = input.shape[1]\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight).unsqueeze(1)\n b = torch.from_numpy(bias)\n return F.conv_transpose2d(x, w, b, stride=(2, 2), padding=(0, 0), dilation=(1, 1), groups=c).numpy()\n"
|
| 97 |
+
}
|
definitions/deconv2d_depthwise/deconv2d_depthwise_kh3_kw3_sh1_sw1.json
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "deconv2d_depthwise_kh3_kw3_sh1_sw1",
|
| 3 |
+
"op_type": "deconv2d_depthwise",
|
| 4 |
+
"description": "Depthwise transposed 2D conv 3x3 stride=(1,1) dilation=(1,1) pad=0. C varies per workload.",
|
| 5 |
+
"tags": [
|
| 6 |
+
"status:active"
|
| 7 |
+
],
|
| 8 |
+
"axes": {
|
| 9 |
+
"N": {
|
| 10 |
+
"type": "var"
|
| 11 |
+
},
|
| 12 |
+
"H": {
|
| 13 |
+
"type": "var",
|
| 14 |
+
"parent": "N"
|
| 15 |
+
},
|
| 16 |
+
"W": {
|
| 17 |
+
"type": "var",
|
| 18 |
+
"parent": "N"
|
| 19 |
+
},
|
| 20 |
+
"H_out": {
|
| 21 |
+
"type": "var",
|
| 22 |
+
"parent": "N"
|
| 23 |
+
},
|
| 24 |
+
"W_out": {
|
| 25 |
+
"type": "var",
|
| 26 |
+
"parent": "N"
|
| 27 |
+
},
|
| 28 |
+
"C": {
|
| 29 |
+
"type": "var"
|
| 30 |
+
},
|
| 31 |
+
"Kh": {
|
| 32 |
+
"type": "const",
|
| 33 |
+
"value": 3
|
| 34 |
+
},
|
| 35 |
+
"Kw": {
|
| 36 |
+
"type": "const",
|
| 37 |
+
"value": 3
|
| 38 |
+
},
|
| 39 |
+
"Sh": {
|
| 40 |
+
"type": "const",
|
| 41 |
+
"value": 1
|
| 42 |
+
},
|
| 43 |
+
"Sw": {
|
| 44 |
+
"type": "const",
|
| 45 |
+
"value": 1
|
| 46 |
+
},
|
| 47 |
+
"Dh": {
|
| 48 |
+
"type": "const",
|
| 49 |
+
"value": 1
|
| 50 |
+
},
|
| 51 |
+
"Dw": {
|
| 52 |
+
"type": "const",
|
| 53 |
+
"value": 1
|
| 54 |
+
}
|
| 55 |
+
},
|
| 56 |
+
"inputs": {
|
| 57 |
+
"input": {
|
| 58 |
+
"shape": [
|
| 59 |
+
"N",
|
| 60 |
+
"C",
|
| 61 |
+
"H",
|
| 62 |
+
"W"
|
| 63 |
+
],
|
| 64 |
+
"dtype": "float32"
|
| 65 |
+
},
|
| 66 |
+
"weight": {
|
| 67 |
+
"shape": [
|
| 68 |
+
"C",
|
| 69 |
+
"Kh",
|
| 70 |
+
"Kw"
|
| 71 |
+
],
|
| 72 |
+
"dtype": "float32"
|
| 73 |
+
},
|
| 74 |
+
"bias": {
|
| 75 |
+
"shape": [
|
| 76 |
+
"C"
|
| 77 |
+
],
|
| 78 |
+
"dtype": "float32"
|
| 79 |
+
}
|
| 80 |
+
},
|
| 81 |
+
"outputs": {
|
| 82 |
+
"output": {
|
| 83 |
+
"shape": [
|
| 84 |
+
"N",
|
| 85 |
+
"C",
|
| 86 |
+
"H_out",
|
| 87 |
+
"W_out"
|
| 88 |
+
],
|
| 89 |
+
"dtype": "float32"
|
| 90 |
+
}
|
| 91 |
+
},
|
| 92 |
+
"constraints": [
|
| 93 |
+
"H_out == (H - 1) * Sh + Kh",
|
| 94 |
+
"W_out == (W - 1) * Sw + Kw"
|
| 95 |
+
],
|
| 96 |
+
"reference": "import torch\nimport torch.nn.functional as F\n\ndef run(input, weight, bias):\n c = input.shape[1]\n x = torch.from_numpy(input)\n w = torch.from_numpy(weight).unsqueeze(1)\n b = torch.from_numpy(bias)\n return F.conv_transpose2d(x, w, b, stride=(1, 1), padding=(0, 0), dilation=(1, 1), groups=c).numpy()\n"
|
| 97 |
+
}
|
solutions/ncnn/baseline-ncnn-arm/conv1d/conv1d_kw1_sw1_dw1_cout512_p0.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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_kh1_kw1_sh1_sw1_dh1_dw1_cout256.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_kh1_kw1_sh1_sw1_dh1_dw1_cout256",
|
| 3 |
+
"definition": "conv2d_kh1_kw1_sh1_sw1_dh1_dw1_cout256",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "ncnn::*_arm baseline for conv2d_kh1_kw1_sh1_sw1_dh1_dw1_cout256. binding.cpp bakes constexpr params and implements armbench_entry_conv2d 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_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.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.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int num_output = 256;\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* 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 // 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, num_output, (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.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_kh3_kw3_sh1_sw1_dh1_dw1_cout128.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_kh3_kw3_sh1_sw1_dh1_dw1_cout128",
|
| 3 |
+
"definition": "conv2d_kh3_kw3_sh1_sw1_dh1_dw1_cout128",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "ncnn::*_arm baseline for conv2d_kh3_kw3_sh1_sw1_dh1_dw1_cout128. binding.cpp bakes constexpr params and implements armbench_entry_conv2d 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_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.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.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int num_output = 128;\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* 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 // 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, num_output, (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.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_kh3_kw3_sh1_sw1_dh2_dw2_cout256.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_kh3_kw3_sh1_sw1_dh2_dw2_cout256",
|
| 3 |
+
"definition": "conv2d_kh3_kw3_sh1_sw1_dh2_dw2_cout256",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "ncnn::*_arm baseline for conv2d_kh3_kw3_sh1_sw1_dh2_dw2_cout256. binding.cpp bakes constexpr params and implements armbench_entry_conv2d 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_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.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.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 = 2;\nconstexpr int dilation_w = 2;\nconstexpr int pad_top = 2;\nconstexpr int pad_left = 2;\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* 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 // 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, num_output, (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.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_kh3_kw3_sh2_sw2_dh1_dw1_cout128.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_kh3_kw3_sh2_sw2_dh1_dw1_cout128",
|
| 3 |
+
"definition": "conv2d_kh3_kw3_sh2_sw2_dh1_dw1_cout128",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "ncnn::*_arm baseline for conv2d_kh3_kw3_sh2_sw2_dh1_dw1_cout128. binding.cpp bakes constexpr params and implements armbench_entry_conv2d 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_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.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.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int num_output = 128;\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* 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 // 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, num_output, (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.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_kh5_kw5_sh1_sw1_dh1_dw1_cout64.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_kh5_kw5_sh1_sw1_dh1_dw1_cout64",
|
| 3 |
+
"definition": "conv2d_kh5_kw5_sh1_sw1_dh1_dw1_cout64",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "ncnn::*_arm baseline for conv2d_kh5_kw5_sh1_sw1_dh1_dw1_cout64. binding.cpp bakes constexpr params and implements armbench_entry_conv2d 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_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.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.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int num_output = 64;\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_top = 2;\nconstexpr int pad_left = 2;\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* 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 // 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, num_output, (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.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_kh7_kw7_sh2_sw2_dh1_dw1_cout64.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_kh7_kw7_sh2_sw2_dh1_dw1_cout64",
|
| 3 |
+
"definition": "conv2d_kh7_kw7_sh2_sw2_dh1_dw1_cout64",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "ncnn::*_arm baseline for conv2d_kh7_kw7_sh2_sw2_dh1_dw1_cout64. binding.cpp bakes constexpr params and implements armbench_entry_conv2d 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_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.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.h\"\n#include \"mat.h\"\n#include \"option.h\"\n\nnamespace {\nconstexpr int num_output = 64;\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* 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 // 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, num_output, (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.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_depthwise/conv2d_depthwise_kh3_kw3_sh1_sw1_dh1_dw1_p1.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_depthwise_kh3_kw3_sh1_sw1_dh1_dw1_p1",
|
| 3 |
+
"definition": "conv2d_depthwise_kh3_kw3_sh1_sw1_dh1_dw1_p1",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "ncnn::*_arm baseline for conv2d_depthwise_kh3_kw3_sh1_sw1_dh1_dw1_p1. binding.cpp bakes constexpr params and implements armbench_entry_conv2d_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_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.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.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* 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.\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.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_kh3_kw3_sh2_sw2_dh1_dw1_p1.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_depthwise_kh3_kw3_sh2_sw2_dh1_dw1_p1",
|
| 3 |
+
"definition": "conv2d_depthwise_kh3_kw3_sh2_sw2_dh1_dw1_p1",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "ncnn::*_arm baseline for conv2d_depthwise_kh3_kw3_sh2_sw2_dh1_dw1_p1. binding.cpp bakes constexpr params and implements armbench_entry_conv2d_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_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.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.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* 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.\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.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_kh5_kw5_sh1_sw1_dh1_dw1_p2.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "baseline-ncnn-arm_conv2d_depthwise_kh5_kw5_sh1_sw1_dh1_dw1_p2",
|
| 3 |
+
"definition": "conv2d_depthwise_kh5_kw5_sh1_sw1_dh1_dw1_p2",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "baseline-ncnn-arm",
|
| 6 |
+
"description": "ncnn::*_arm baseline for conv2d_depthwise_kh5_kw5_sh1_sw1_dh1_dw1_p2. binding.cpp bakes constexpr params and implements armbench_entry_conv2d_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_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.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.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* 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.\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.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/deconv2d/deconv2d_kh3_kw3_sh1_sw1_cout256.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/claude-sonnet-4-6/conv1d/conv1d_kw1_sw1_dw1_cout512_p0.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "claude-sonnet-4-6_conv1d_kw1_sw1_dw1_cout512_p0",
|
| 3 |
+
"definition": "conv1d_kw1_sw1_dw1_cout512_p0",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "claude-sonnet-4-6",
|
| 6 |
+
"spec": {
|
| 7 |
+
"language": "cpp",
|
| 8 |
+
"target_hardware": [
|
| 9 |
+
"graviton3",
|
| 10 |
+
"aarch64-sve"
|
| 11 |
+
],
|
| 12 |
+
"entry_point": "conv1d.cpp::armbench_entry_conv1d",
|
| 13 |
+
"dependencies": [],
|
| 14 |
+
"isa_features": [
|
| 15 |
+
"sve"
|
| 16 |
+
],
|
| 17 |
+
"compile_flags": [
|
| 18 |
+
"-O3",
|
| 19 |
+
"-march=armv8.2-a+sve",
|
| 20 |
+
"-std=c++14"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": []
|
| 23 |
+
},
|
| 24 |
+
"sources": [
|
| 25 |
+
{
|
| 26 |
+
"path": "conv1d.h",
|
| 27 |
+
"content": "#pragma once\n\n// Per-definition constants for this conv1d specialisation.\nnamespace conv1d_def {\nconstexpr int Cout = 512;\nconstexpr int Kw = 1;\nconstexpr int Sw = 1;\nconstexpr int Dw = 1;\nconstexpr int pad = 0;\n} // namespace conv1d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// C_in, W, W_out are var dims; W_out is pre-computed by the binding harness.\n// Input layout: (C_in, W), output layout: (Cout, W_out).\nvoid inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int C_in, int W, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "conv1d.cpp",
|
| 31 |
+
"content": "// Binding harness: computes W_out from constexpr params, calls inner_conv1d.\n// ABI: armbench_entry_conv1d(input*, output*, weight*, bias*, C_in, W)\n// Input layout: (C_in, W); output layout: (Cout, W_out).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" int armbench_entry_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int C_in, int W)\n{\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int W_out = (W + 2 * pad - ext_kw) / Sw + 1;\n inner_conv1d(input, output, weight, bias, C_in, W, W_out);\n return 0;\n}\n"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "kernel.cpp",
|
| 35 |
+
"content": "// Optimized conv1d kernel for Kw=1, Sw=1, Dw=1, Cout=512, pad=0\n// Since Kw=1, this reduces to a matrix multiplication:\n// output[oc, ow] = bias[oc] + sum_ic(weight[oc, ic] * input[ic, ow])\n//\n// Strategy: GEMM with OC_TILE=16, vectorize over W_out with SVE.\n// Each ic iteration: load 1 input vector, FMA into 16 output rows.\n// This maximizes register reuse of the input vector and amortizes weight loads.\n// Use 2 SVE vectors per OC row to increase ILP.\n\n#include \"conv1d.h\"\n#include <arm_sve.h>\n\nusing namespace conv1d_def;\n\n// Process 16 output channels at a time, vectorizing over W_out\n// This is a GEMM: output(Cout x W_out) += weight(Cout x C_in) * input(C_in x W_out)\n// For each ic: broadcast weight[oc+i, ic] and FMA with input[ic, ow:ow+vl]\nstatic void __attribute__((noinline)) gemm_oc16(\n const float* __restrict__ input,\n float* __restrict__ output,\n const float* __restrict__ weight,\n int C_in, int W_out,\n int oc_base)\n{\n svbool_t pg = svptrue_b32();\n const int vl = svcntw();\n\n // Pointers to 16 output rows\n float* o0 = output + (long)(oc_base+ 0) * W_out;\n float* o1 = output + (long)(oc_base+ 1) * W_out;\n float* o2 = output + (long)(oc_base+ 2) * W_out;\n float* o3 = output + (long)(oc_base+ 3) * W_out;\n float* o4 = output + (long)(oc_base+ 4) * W_out;\n float* o5 = output + (long)(oc_base+ 5) * W_out;\n float* o6 = output + (long)(oc_base+ 6) * W_out;\n float* o7 = output + (long)(oc_base+ 7) * W_out;\n float* o8 = output + (long)(oc_base+ 8) * W_out;\n float* o9 = output + (long)(oc_base+ 9) * W_out;\n float* o10 = output + (long)(oc_base+10) * W_out;\n float* o11 = output + (long)(oc_base+11) * W_out;\n float* o12 = output + (long)(oc_base+12) * W_out;\n float* o13 = output + (long)(oc_base+13) * W_out;\n float* o14 = output + (long)(oc_base+14) * W_out;\n float* o15 = output + (long)(oc_base+15) * W_out;\n\n // Pointers to 16 weight rows\n const float* w0 = weight + (long)(oc_base+ 0) * C_in;\n const float* w1 = weight + (long)(oc_base+ 1) * C_in;\n const float* w2 = weight + (long)(oc_base+ 2) * C_in;\n const float* w3 = weight + (long)(oc_base+ 3) * C_in;\n const float* w4 = weight + (long)(oc_base+ 4) * C_in;\n const float* w5 = weight + (long)(oc_base+ 5) * C_in;\n const float* w6 = weight + (long)(oc_base+ 6) * C_in;\n const float* w7 = weight + (long)(oc_base+ 7) * C_in;\n const float* w8 = weight + (long)(oc_base+ 8) * C_in;\n const float* w9 = weight + (long)(oc_base+ 9) * C_in;\n const float* w10 = weight + (long)(oc_base+10) * C_in;\n const float* w11 = weight + (long)(oc_base+11) * C_in;\n const float* w12 = weight + (long)(oc_base+12) * C_in;\n const float* w13 = weight + (long)(oc_base+13) * C_in;\n const float* w14 = weight + (long)(oc_base+14) * C_in;\n const float* w15 = weight + (long)(oc_base+15) * C_in;\n\n for (int ic = 0; ic < C_in; ++ic) {\n const float* in_row = input + (long)ic * W_out;\n\n // Load 16 weight scalars\n svfloat32_t vw0 = svdup_f32(w0[ic]);\n svfloat32_t vw1 = svdup_f32(w1[ic]);\n svfloat32_t vw2 = svdup_f32(w2[ic]);\n svfloat32_t vw3 = svdup_f32(w3[ic]);\n svfloat32_t vw4 = svdup_f32(w4[ic]);\n svfloat32_t vw5 = svdup_f32(w5[ic]);\n svfloat32_t vw6 = svdup_f32(w6[ic]);\n svfloat32_t vw7 = svdup_f32(w7[ic]);\n svfloat32_t vw8 = svdup_f32(w8[ic]);\n svfloat32_t vw9 = svdup_f32(w9[ic]);\n svfloat32_t vw10 = svdup_f32(w10[ic]);\n svfloat32_t vw11 = svdup_f32(w11[ic]);\n svfloat32_t vw12 = svdup_f32(w12[ic]);\n svfloat32_t vw13 = svdup_f32(w13[ic]);\n svfloat32_t vw14 = svdup_f32(w14[ic]);\n svfloat32_t vw15 = svdup_f32(w15[ic]);\n\n int ow = 0;\n // Main loop: process 2 SVE vectors at a time\n for (; ow + 2*vl <= W_out; ow += 2*vl) {\n svfloat32_t vin0 = svld1_f32(pg, in_row + ow);\n svfloat32_t vin1 = svld1_f32(pg, in_row + ow + vl);\n\n #define FMA2(op, vw) \\\n do { \\\n svfloat32_t va = svld1_f32(pg, op + ow); \\\n svfloat32_t vb = svld1_f32(pg, op + ow + vl); \\\n va = svmla_f32_x(pg, va, vin0, vw); \\\n vb = svmla_f32_x(pg, vb, vin1, vw); \\\n svst1_f32(pg, op + ow, va); \\\n svst1_f32(pg, op + ow + vl, vb); \\\n } while(0)\n\n FMA2(o0, vw0);\n FMA2(o1, vw1);\n FMA2(o2, vw2);\n FMA2(o3, vw3);\n FMA2(o4, vw4);\n FMA2(o5, vw5);\n FMA2(o6, vw6);\n FMA2(o7, vw7);\n FMA2(o8, vw8);\n FMA2(o9, vw9);\n FMA2(o10, vw10);\n FMA2(o11, vw11);\n FMA2(o12, vw12);\n FMA2(o13, vw13);\n FMA2(o14, vw14);\n FMA2(o15, vw15);\n #undef FMA2\n }\n\n // Handle remaining full vectors\n for (; ow + vl <= W_out; ow += vl) {\n svfloat32_t vin = svld1_f32(pg, in_row + ow);\n\n #define FMA1(op, vw) \\\n do { \\\n svfloat32_t va = svld1_f32(pg, op + ow); \\\n va = svmla_f32_x(pg, va, vin, vw); \\\n svst1_f32(pg, op + ow, va); \\\n } while(0)\n\n FMA1(o0, vw0);\n FMA1(o1, vw1);\n FMA1(o2, vw2);\n FMA1(o3, vw3);\n FMA1(o4, vw4);\n FMA1(o5, vw5);\n FMA1(o6, vw6);\n FMA1(o7, vw7);\n FMA1(o8, vw8);\n FMA1(o9, vw9);\n FMA1(o10, vw10);\n FMA1(o11, vw11);\n FMA1(o12, vw12);\n FMA1(o13, vw13);\n FMA1(o14, vw14);\n FMA1(o15, vw15);\n #undef FMA1\n }\n\n // Handle tail\n if (ow < W_out) {\n svbool_t ptail = svwhilelt_b32(ow, W_out);\n svfloat32_t vin = svld1_f32(ptail, in_row + ow);\n\n #define FMAT(op, vw) \\\n do { \\\n svfloat32_t va = svld1_f32(ptail, op + ow); \\\n va = svmla_f32_x(ptail, va, vin, vw); \\\n svst1_f32(ptail, op + ow, va); \\\n } while(0)\n\n FMAT(o0, vw0);\n FMAT(o1, vw1);\n FMAT(o2, vw2);\n FMAT(o3, vw3);\n FMAT(o4, vw4);\n FMAT(o5, vw5);\n FMAT(o6, vw6);\n FMAT(o7, vw7);\n FMAT(o8, vw8);\n FMAT(o9, vw9);\n FMAT(o10, vw10);\n FMAT(o11, vw11);\n FMAT(o12, vw12);\n FMAT(o13, vw13);\n FMAT(o14, vw14);\n FMAT(o15, vw15);\n #undef FMAT\n }\n }\n}\n\nextern \"C\" void inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int C_in, int W, int W_out)\n{\n const int vl = svcntw();\n svbool_t pg = svptrue_b32();\n\n // Initialize output with bias\n for (int oc = 0; oc < Cout; ++oc) {\n float* out_c = output + (long)oc * W_out;\n svfloat32_t vb = svdup_f32(bias[oc]);\n int ow = 0;\n for (; ow + vl <= W_out; ow += vl) {\n svst1_f32(pg, out_c + ow, vb);\n }\n if (ow < W_out) {\n svbool_t ptail = svwhilelt_b32(ow, W_out);\n svst1_f32(ptail, out_c + ow, vb);\n }\n }\n\n // Main GEMM loop: output += weight * input\n // Cout=512 is divisible by 16\n for (int oc = 0; oc < Cout; oc += 16) {\n gemm_oc16(input, output, weight, C_in, W_out, oc);\n }\n}\n"
|
| 36 |
+
}
|
| 37 |
+
]
|
| 38 |
+
}
|
solutions/ncnn/claude-sonnet-4-6/conv1d/conv1d_kw3_sw1_dw1_cout512_p1.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "claude-sonnet-4-6_conv1d_kw3_sw1_dw1_cout512_p1",
|
| 3 |
+
"definition": "conv1d_kw3_sw1_dw1_cout512_p1",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "claude-sonnet-4-6",
|
| 6 |
+
"spec": {
|
| 7 |
+
"language": "cpp",
|
| 8 |
+
"target_hardware": [
|
| 9 |
+
"graviton3",
|
| 10 |
+
"aarch64-sve"
|
| 11 |
+
],
|
| 12 |
+
"entry_point": "conv1d.cpp::armbench_entry_conv1d",
|
| 13 |
+
"dependencies": [],
|
| 14 |
+
"isa_features": [
|
| 15 |
+
"sve"
|
| 16 |
+
],
|
| 17 |
+
"compile_flags": [
|
| 18 |
+
"-O3",
|
| 19 |
+
"-march=armv8.2-a+sve",
|
| 20 |
+
"-std=c++14"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": []
|
| 23 |
+
},
|
| 24 |
+
"sources": [
|
| 25 |
+
{
|
| 26 |
+
"path": "conv1d.h",
|
| 27 |
+
"content": "#pragma once\n\n// Per-definition constants for this conv1d specialisation.\nnamespace conv1d_def {\nconstexpr int Cout = 512;\nconstexpr int Kw = 3;\nconstexpr int Sw = 1;\nconstexpr int Dw = 1;\nconstexpr int pad = 1;\n} // namespace conv1d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// C_in, W, W_out are var dims; W_out is pre-computed by the binding harness.\n// Input layout: (C_in, W), output layout: (Cout, W_out).\nvoid inner_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int C_in, int W, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "conv1d.cpp",
|
| 31 |
+
"content": "// Binding harness: computes W_out from constexpr params, calls inner_conv1d.\n// ABI: armbench_entry_conv1d(input*, output*, weight*, bias*, C_in, W)\n// Input layout: (C_in, W); output layout: (Cout, W_out).\n#include \"conv1d.h\"\nusing namespace conv1d_def;\n\nextern \"C\" int armbench_entry_conv1d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int C_in, int W)\n{\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int W_out = (W + 2 * pad - ext_kw) / Sw + 1;\n inner_conv1d(input, output, weight, bias, C_in, W, W_out);\n return 0;\n}\n"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "kernel.cpp",
|
| 35 |
+
"content": "#include \"conv1d.h\"\n#include <arm_sve.h>\n#include <cstring>\n#include <algorithm>\n\nusing namespace conv1d_def;\n\n// Observation: v3 achieves ~1.4x cycle speedup with 4-OC tiling.\n// Key bottleneck: IPC ~2.6, cache misses are low (good).\n// The inner loop does scalar weight loads (mov z.s, s) which is inefficient.\n// Strategy: Increase OC tile to 8, and also tile over ow (multiple SVE vectors per oc group).\n// This increases register reuse and hides FMA latency (4 cycles on Graviton3).\n// With 8 accumulators per ow position and 2 ow positions, we have 16 FMA chains.\n\nextern \"C\" void inner_conv1d(\n const float* __restrict__ input, float* __restrict__ output,\n const float* __restrict__ weight, const float* __restrict__ bias,\n int C_in, int W, int W_out)\n{\n const int vl = svcntw(); // SVE vector length in floats (8 for 256-bit)\n svbool_t pg_all = svptrue_b32();\n \n // Process 8 output channels at a time\n const int OC_TILE = 8;\n \n for (int oc_base = 0; oc_base < Cout; oc_base += OC_TILE) {\n // Output pointers for 8 channels\n float* out0 = output + (long)(oc_base + 0) * W_out;\n float* out1 = output + (long)(oc_base + 1) * W_out;\n float* out2 = output + (long)(oc_base + 2) * W_out;\n float* out3 = output + (long)(oc_base + 3) * W_out;\n float* out4 = output + (long)(oc_base + 4) * W_out;\n float* out5 = output + (long)(oc_base + 5) * W_out;\n float* out6 = output + (long)(oc_base + 6) * W_out;\n float* out7 = output + (long)(oc_base + 7) * W_out;\n \n // Weight pointers for 8 channels\n const float* w0 = weight + (long)(oc_base + 0) * C_in * Kw;\n const float* w1 = weight + (long)(oc_base + 1) * C_in * Kw;\n const float* w2 = weight + (long)(oc_base + 2) * C_in * Kw;\n const float* w3 = weight + (long)(oc_base + 3) * C_in * Kw;\n const float* w4 = weight + (long)(oc_base + 4) * C_in * Kw;\n const float* w5 = weight + (long)(oc_base + 5) * C_in * Kw;\n const float* w6 = weight + (long)(oc_base + 6) * C_in * Kw;\n const float* w7 = weight + (long)(oc_base + 7) * C_in * Kw;\n \n // Bias values\n float b0 = bias[oc_base + 0];\n float b1 = bias[oc_base + 1];\n float b2 = bias[oc_base + 2];\n float b3 = bias[oc_base + 3];\n float b4 = bias[oc_base + 4];\n float b5 = bias[oc_base + 5];\n float b6 = bias[oc_base + 6];\n float b7 = bias[oc_base + 7];\n \n svfloat32_t vb0 = svdup_f32(b0);\n svfloat32_t vb1 = svdup_f32(b1);\n svfloat32_t vb2 = svdup_f32(b2);\n svfloat32_t vb3 = svdup_f32(b3);\n svfloat32_t vb4 = svdup_f32(b4);\n svfloat32_t vb5 = svdup_f32(b5);\n svfloat32_t vb6 = svdup_f32(b6);\n svfloat32_t vb7 = svdup_f32(b7);\n \n // Process ow in blocks of vl\n // W_out = W (since pad=1, Kw=3, Sw=1)\n int ow = 0;\n for (; ow + vl <= W_out; ow += vl) {\n svfloat32_t acc0 = vb0;\n svfloat32_t acc1 = vb1;\n svfloat32_t acc2 = vb2;\n svfloat32_t acc3 = vb3;\n svfloat32_t acc4 = vb4;\n svfloat32_t acc5 = vb5;\n svfloat32_t acc6 = vb6;\n svfloat32_t acc7 = vb7;\n \n bool left_boundary = (ow == 0);\n bool right_boundary = (ow + vl == W_out);\n \n for (int ic = 0; ic < C_in; ++ic) {\n const float* in_c = input + (long)ic * W;\n int woff = ic * Kw;\n \n float wv00 = w0[woff], wv01 = w0[woff+1], wv02 = w0[woff+2];\n float wv10 = w1[woff], wv11 = w1[woff+1], wv12 = w1[woff+2];\n float wv20 = w2[woff], wv21 = w2[woff+1], wv22 = w2[woff+2];\n float wv30 = w3[woff], wv31 = w3[woff+1], wv32 = w3[woff+2];\n float wv40 = w4[woff], wv41 = w4[woff+1], wv42 = w4[woff+2];\n float wv50 = w5[woff], wv51 = w5[woff+1], wv52 = w5[woff+2];\n float wv60 = w6[woff], wv61 = w6[woff+1], wv62 = w6[woff+2];\n float wv70 = w7[woff], wv71 = w7[woff+1], wv72 = w7[woff+2];\n \n // kw=0: iw = ow - 1 + lane\n if (!left_boundary) {\n svfloat32_t vin = svld1_f32(pg_all, in_c + ow - 1);\n acc0 = svmla_n_f32_m(pg_all, acc0, vin, wv00);\n acc1 = svmla_n_f32_m(pg_all, acc1, vin, wv10);\n acc2 = svmla_n_f32_m(pg_all, acc2, vin, wv20);\n acc3 = svmla_n_f32_m(pg_all, acc3, vin, wv30);\n acc4 = svmla_n_f32_m(pg_all, acc4, vin, wv40);\n acc5 = svmla_n_f32_m(pg_all, acc5, vin, wv50);\n acc6 = svmla_n_f32_m(pg_all, acc6, vin, wv60);\n acc7 = svmla_n_f32_m(pg_all, acc7, vin, wv70);\n } else {\n svbool_t pg_k0 = svnot_b_z(pg_all, svwhilelt_b32(0, 1));\n svfloat32_t vin = svld1_f32(pg_k0, in_c - 1);\n acc0 = svmla_n_f32_m(pg_k0, acc0, vin, wv00);\n acc1 = svmla_n_f32_m(pg_k0, acc1, vin, wv10);\n acc2 = svmla_n_f32_m(pg_k0, acc2, vin, wv20);\n acc3 = svmla_n_f32_m(pg_k0, acc3, vin, wv30);\n acc4 = svmla_n_f32_m(pg_k0, acc4, vin, wv40);\n acc5 = svmla_n_f32_m(pg_k0, acc5, vin, wv50);\n acc6 = svmla_n_f32_m(pg_k0, acc6, vin, wv60);\n acc7 = svmla_n_f32_m(pg_k0, acc7, vin, wv70);\n }\n \n // kw=1: iw = ow + lane, always valid\n {\n svfloat32_t vin = svld1_f32(pg_all, in_c + ow);\n acc0 = svmla_n_f32_m(pg_all, acc0, vin, wv01);\n acc1 = svmla_n_f32_m(pg_all, acc1, vin, wv11);\n acc2 = svmla_n_f32_m(pg_all, acc2, vin, wv21);\n acc3 = svmla_n_f32_m(pg_all, acc3, vin, wv31);\n acc4 = svmla_n_f32_m(pg_all, acc4, vin, wv41);\n acc5 = svmla_n_f32_m(pg_all, acc5, vin, wv51);\n acc6 = svmla_n_f32_m(pg_all, acc6, vin, wv61);\n acc7 = svmla_n_f32_m(pg_all, acc7, vin, wv71);\n }\n \n // kw=2: iw = ow + 1 + lane\n if (!right_boundary) {\n svfloat32_t vin = svld1_f32(pg_all, in_c + ow + 1);\n acc0 = svmla_n_f32_m(pg_all, acc0, vin, wv02);\n acc1 = svmla_n_f32_m(pg_all, acc1, vin, wv12);\n acc2 = svmla_n_f32_m(pg_all, acc2, vin, wv22);\n acc3 = svmla_n_f32_m(pg_all, acc3, vin, wv32);\n acc4 = svmla_n_f32_m(pg_all, acc4, vin, wv42);\n acc5 = svmla_n_f32_m(pg_all, acc5, vin, wv52);\n acc6 = svmla_n_f32_m(pg_all, acc6, vin, wv62);\n acc7 = svmla_n_f32_m(pg_all, acc7, vin, wv72);\n } else {\n svbool_t pg_k2 = svwhilelt_b32(0, vl - 1);\n svfloat32_t vin = svld1_f32(pg_k2, in_c + ow + 1);\n acc0 = svmla_n_f32_m(pg_k2, acc0, vin, wv02);\n acc1 = svmla_n_f32_m(pg_k2, acc1, vin, wv12);\n acc2 = svmla_n_f32_m(pg_k2, acc2, vin, wv22);\n acc3 = svmla_n_f32_m(pg_k2, acc3, vin, wv32);\n acc4 = svmla_n_f32_m(pg_k2, acc4, vin, wv42);\n acc5 = svmla_n_f32_m(pg_k2, acc5, vin, wv52);\n acc6 = svmla_n_f32_m(pg_k2, acc6, vin, wv62);\n acc7 = svmla_n_f32_m(pg_k2, acc7, vin, wv72);\n }\n }\n \n svst1_f32(pg_all, out0 + ow, acc0);\n svst1_f32(pg_all, out1 + ow, acc1);\n svst1_f32(pg_all, out2 + ow, acc2);\n svst1_f32(pg_all, out3 + ow, acc3);\n svst1_f32(pg_all, out4 + ow, acc4);\n svst1_f32(pg_all, out5 + ow, acc5);\n svst1_f32(pg_all, out6 + ow, acc6);\n svst1_f32(pg_all, out7 + ow, acc7);\n }\n \n // Handle remaining output positions (scalar)\n for (; ow < W_out; ++ow) {\n float sum0 = b0, sum1 = b1, sum2 = b2, sum3 = b3;\n float sum4 = b4, sum5 = b5, sum6 = b6, sum7 = b7;\n for (int ic = 0; ic < C_in; ++ic) {\n const float* in_c = input + (long)ic * W;\n int woff = ic * Kw;\n for (int kw = 0; kw < Kw; ++kw) {\n int iw = ow - pad + kw;\n if (iw >= 0 && iw < W) {\n float inv = in_c[iw];\n sum0 += inv * w0[woff + kw];\n sum1 += inv * w1[woff + kw];\n sum2 += inv * w2[woff + kw];\n sum3 += inv * w3[woff + kw];\n sum4 += inv * w4[woff + kw];\n sum5 += inv * w5[woff + kw];\n sum6 += inv * w6[woff + kw];\n sum7 += inv * w7[woff + kw];\n }\n }\n }\n out0[ow] = sum0; out1[ow] = sum1; out2[ow] = sum2; out3[ow] = sum3;\n out4[ow] = sum4; out5[ow] = sum5; out6[ow] = sum6; out7[ow] = sum7;\n }\n }\n}\n"
|
| 36 |
+
}
|
| 37 |
+
]
|
| 38 |
+
}
|
solutions/ncnn/claude-sonnet-4-6/conv2d/conv2d_kh1_kw1_sh1_sw1_dh1_dw1_cout256.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "claude-sonnet-4-6_conv2d_kh1_kw1_sh1_sw1_dh1_dw1_cout256",
|
| 3 |
+
"definition": "conv2d_kh1_kw1_sh1_sw1_dh1_dw1_cout256",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "claude-sonnet-4-6",
|
| 6 |
+
"spec": {
|
| 7 |
+
"language": "cpp",
|
| 8 |
+
"target_hardware": [
|
| 9 |
+
"graviton3",
|
| 10 |
+
"aarch64-sve"
|
| 11 |
+
],
|
| 12 |
+
"entry_point": "conv2d.cpp::armbench_entry_conv2d",
|
| 13 |
+
"dependencies": [],
|
| 14 |
+
"isa_features": [
|
| 15 |
+
"sve"
|
| 16 |
+
],
|
| 17 |
+
"compile_flags": [
|
| 18 |
+
"-O3",
|
| 19 |
+
"-march=armv8.2-a+sve",
|
| 20 |
+
"-std=c++14"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": []
|
| 23 |
+
},
|
| 24 |
+
"sources": [
|
| 25 |
+
{
|
| 26 |
+
"path": "conv2d.h",
|
| 27 |
+
"content": "// Auto-generated by scripts/gen_candidate_solution.py — do not hand-edit.\n#pragma once\n\n// Per-definition constants for this conv2d specialisation.\nnamespace conv2d_def {\nconstexpr int Cout = 256;\nconstexpr int Kh = 1;\nconstexpr int Kw = 1;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad_top = 0;\nconstexpr int pad_left = 0;\nconstexpr int activation_type = 0;\n} // namespace conv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, C_in, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\nvoid inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int C_in, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "conv2d.cpp",
|
| 31 |
+
"content": "// Binding harness: computes output dims from constexpr params, calls inner_conv2d.\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight,\n int N, int C_in, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n inner_conv2d(input, output, weight, N, C_in, H, W, H_out, W_out);\n return 0;\n}\n"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "kernel.cpp",
|
| 35 |
+
"content": "// Optimized conv2d kernel for Kh=1, Kw=1, Sh=1, Sw=1, Dh=1, Dw=1, Cout=256\n// This is a GEMM: output[n, oc, hw] = sum_ic input[n, ic, hw] * weight[oc, ic]\n// Key insight: The bottleneck is memory bandwidth for large HW (224x224).\n// Strategy: Reorder loops to (ic, oc_tile, hw) so input is read once per ic,\n// and use large OC tiles (16) with multiple HW vectors to maximize FMA throughput.\n// The key problem with v2 is that for large HW, we're reading/writing output \n// C_in times each - this is very cache-unfriendly.\n// Better: tile over HW so output fits in L1/L2 cache.\n\n#include \"conv2d.h\"\n#include <arm_sve.h>\n#include <cstring>\n\nusing namespace conv2d_def;\n\n// HW tile size: process this many spatial elements at once\n// For 256-bit SVE, vl=8 floats. Use 4 vectors = 32 elements per OC.\n// With 16 OC and 4 HW vectors: 16*4 = 64 accumulators (too many registers)\n// Use 8 OC and 4 HW vectors: 32 accumulators - fits in 32 SVE registers\n\nextern \"C\" void inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int C_in, int H, int W, int H_out, int W_out)\n{\n const int HW = H_out * W_out;\n const int vl = (int)svcntw(); // 8 for 256-bit SVE\n \n // HW tile: process HW_TILE spatial positions at once\n // This keeps output tiles in registers while iterating over IC\n const int HW_TILE = 4 * vl; // 4 SVE vectors = 32 floats\n \n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * C_in * HW;\n float* out_n = output + (long)n * Cout * HW;\n \n // Tile over HW dimension\n for (int hw_start = 0; hw_start < HW; hw_start += HW_TILE) {\n int hw_end = hw_start + HW_TILE;\n if (hw_end > HW) hw_end = HW;\n int hw_len = hw_end - hw_start;\n \n // Process 8 output channels at a time\n for (int oc = 0; oc < Cout; oc += 8) {\n // Accumulator registers: 8 OC x 4 HW vectors = 32 registers\n svfloat32_t acc00, acc01, acc02, acc03;\n svfloat32_t acc10, acc11, acc12, acc13;\n svfloat32_t acc20, acc21, acc22, acc23;\n svfloat32_t acc30, acc31, acc32, acc33;\n svfloat32_t acc40, acc41, acc42, acc43;\n svfloat32_t acc50, acc51, acc52, acc53;\n svfloat32_t acc60, acc61, acc62, acc63;\n svfloat32_t acc70, acc71, acc72, acc73;\n \n svbool_t pg = svptrue_b32();\n svfloat32_t zero = svdup_f32(0.0f);\n \n // Determine predicates for each of the 4 HW vectors\n int hw0 = hw_start;\n int hw1 = hw_start + vl;\n int hw2 = hw_start + 2*vl;\n int hw3 = hw_start + 3*vl;\n \n svbool_t pg0 = svwhilelt_b32(hw0, HW);\n svbool_t pg1 = svwhilelt_b32(hw1, HW);\n svbool_t pg2 = svwhilelt_b32(hw2, HW);\n svbool_t pg3 = svwhilelt_b32(hw3, HW);\n \n // Initialize accumulators to zero\n acc00 = acc01 = acc02 = acc03 = zero;\n acc10 = acc11 = acc12 = acc13 = zero;\n acc20 = acc21 = acc22 = acc23 = zero;\n acc30 = acc31 = acc32 = acc33 = zero;\n acc40 = acc41 = acc42 = acc43 = zero;\n acc50 = acc51 = acc52 = acc53 = zero;\n acc60 = acc61 = acc62 = acc63 = zero;\n acc70 = acc71 = acc72 = acc73 = zero;\n \n // Accumulate over input channels\n for (int ic = 0; ic < C_in; ++ic) {\n const float* in_ic = in_n + (long)ic * HW + hw_start;\n \n // Load 4 HW vectors of input\n svfloat32_t vin0 = svld1_f32(pg0, in_ic + 0);\n svfloat32_t vin1 = svld1_f32(pg1, in_ic + vl);\n svfloat32_t vin2 = svld1_f32(pg2, in_ic + 2*vl);\n svfloat32_t vin3 = svld1_f32(pg3, in_ic + 3*vl);\n \n // Load 8 weight values\n const float* wbase = weight + (long)oc * C_in + ic;\n float w0 = wbase[0 * C_in];\n float w1 = wbase[1 * C_in];\n float w2 = wbase[2 * C_in];\n float w3 = wbase[3 * C_in];\n float w4 = wbase[4 * C_in];\n float w5 = wbase[5 * C_in];\n float w6 = wbase[6 * C_in];\n float w7 = wbase[7 * C_in];\n \n // FMA: acc[oc_i][hw_j] += vin[hw_j] * w[oc_i]\n acc00 = svmla_n_f32_x(pg, acc00, vin0, w0);\n acc01 = svmla_n_f32_x(pg, acc01, vin1, w0);\n acc02 = svmla_n_f32_x(pg, acc02, vin2, w0);\n acc03 = svmla_n_f32_x(pg, acc03, vin3, w0);\n \n acc10 = svmla_n_f32_x(pg, acc10, vin0, w1);\n acc11 = svmla_n_f32_x(pg, acc11, vin1, w1);\n acc12 = svmla_n_f32_x(pg, acc12, vin2, w1);\n acc13 = svmla_n_f32_x(pg, acc13, vin3, w1);\n \n acc20 = svmla_n_f32_x(pg, acc20, vin0, w2);\n acc21 = svmla_n_f32_x(pg, acc21, vin1, w2);\n acc22 = svmla_n_f32_x(pg, acc22, vin2, w2);\n acc23 = svmla_n_f32_x(pg, acc23, vin3, w2);\n \n acc30 = svmla_n_f32_x(pg, acc30, vin0, w3);\n acc31 = svmla_n_f32_x(pg, acc31, vin1, w3);\n acc32 = svmla_n_f32_x(pg, acc32, vin2, w3);\n acc33 = svmla_n_f32_x(pg, acc33, vin3, w3);\n \n acc40 = svmla_n_f32_x(pg, acc40, vin0, w4);\n acc41 = svmla_n_f32_x(pg, acc41, vin1, w4);\n acc42 = svmla_n_f32_x(pg, acc42, vin2, w4);\n acc43 = svmla_n_f32_x(pg, acc43, vin3, w4);\n \n acc50 = svmla_n_f32_x(pg, acc50, vin0, w5);\n acc51 = svmla_n_f32_x(pg, acc51, vin1, w5);\n acc52 = svmla_n_f32_x(pg, acc52, vin2, w5);\n acc53 = svmla_n_f32_x(pg, acc53, vin3, w5);\n \n acc60 = svmla_n_f32_x(pg, acc60, vin0, w6);\n acc61 = svmla_n_f32_x(pg, acc61, vin1, w6);\n acc62 = svmla_n_f32_x(pg, acc62, vin2, w6);\n acc63 = svmla_n_f32_x(pg, acc63, vin3, w6);\n \n acc70 = svmla_n_f32_x(pg, acc70, vin0, w7);\n acc71 = svmla_n_f32_x(pg, acc71, vin1, w7);\n acc72 = svmla_n_f32_x(pg, acc72, vin2, w7);\n acc73 = svmla_n_f32_x(pg, acc73, vin3, w7);\n }\n \n // Store results\n float* out0 = out_n + (long)(oc + 0) * HW + hw_start;\n float* out1 = out_n + (long)(oc + 1) * HW + hw_start;\n float* out2 = out_n + (long)(oc + 2) * HW + hw_start;\n float* out3 = out_n + (long)(oc + 3) * HW + hw_start;\n float* out4 = out_n + (long)(oc + 4) * HW + hw_start;\n float* out5 = out_n + (long)(oc + 5) * HW + hw_start;\n float* out6 = out_n + (long)(oc + 6) * HW + hw_start;\n float* out7 = out_n + (long)(oc + 7) * HW + hw_start;\n \n svst1_f32(pg0, out0 + 0, acc00);\n svst1_f32(pg1, out0 + vl, acc01);\n svst1_f32(pg2, out0 + 2*vl, acc02);\n svst1_f32(pg3, out0 + 3*vl, acc03);\n \n svst1_f32(pg0, out1 + 0, acc10);\n svst1_f32(pg1, out1 + vl, acc11);\n svst1_f32(pg2, out1 + 2*vl, acc12);\n svst1_f32(pg3, out1 + 3*vl, acc13);\n \n svst1_f32(pg0, out2 + 0, acc20);\n svst1_f32(pg1, out2 + vl, acc21);\n svst1_f32(pg2, out2 + 2*vl, acc22);\n svst1_f32(pg3, out2 + 3*vl, acc23);\n \n svst1_f32(pg0, out3 + 0, acc30);\n svst1_f32(pg1, out3 + vl, acc31);\n svst1_f32(pg2, out3 + 2*vl, acc32);\n svst1_f32(pg3, out3 + 3*vl, acc33);\n \n svst1_f32(pg0, out4 + 0, acc40);\n svst1_f32(pg1, out4 + vl, acc41);\n svst1_f32(pg2, out4 + 2*vl, acc42);\n svst1_f32(pg3, out4 + 3*vl, acc43);\n \n svst1_f32(pg0, out5 + 0, acc50);\n svst1_f32(pg1, out5 + vl, acc51);\n svst1_f32(pg2, out5 + 2*vl, acc52);\n svst1_f32(pg3, out5 + 3*vl, acc53);\n \n svst1_f32(pg0, out6 + 0, acc60);\n svst1_f32(pg1, out6 + vl, acc61);\n svst1_f32(pg2, out6 + 2*vl, acc62);\n svst1_f32(pg3, out6 + 3*vl, acc63);\n \n svst1_f32(pg0, out7 + 0, acc70);\n svst1_f32(pg1, out7 + vl, acc71);\n svst1_f32(pg2, out7 + 2*vl, acc72);\n svst1_f32(pg3, out7 + 3*vl, acc73);\n }\n }\n }\n}\n"
|
| 36 |
+
}
|
| 37 |
+
]
|
| 38 |
+
}
|
solutions/ncnn/claude-sonnet-4-6/conv2d/conv2d_kh3_kw3_sh1_sw1_dh1_dw1_cout128.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "claude-sonnet-4-6_conv2d_kh3_kw3_sh1_sw1_dh1_dw1_cout128",
|
| 3 |
+
"definition": "conv2d_kh3_kw3_sh1_sw1_dh1_dw1_cout128",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "claude-sonnet-4-6",
|
| 6 |
+
"spec": {
|
| 7 |
+
"language": "cpp",
|
| 8 |
+
"target_hardware": [
|
| 9 |
+
"graviton3",
|
| 10 |
+
"aarch64-sve"
|
| 11 |
+
],
|
| 12 |
+
"entry_point": "conv2d.cpp::armbench_entry_conv2d",
|
| 13 |
+
"dependencies": [],
|
| 14 |
+
"isa_features": [
|
| 15 |
+
"sve"
|
| 16 |
+
],
|
| 17 |
+
"compile_flags": [
|
| 18 |
+
"-O3",
|
| 19 |
+
"-march=armv8.2-a+sve",
|
| 20 |
+
"-std=c++14"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": []
|
| 23 |
+
},
|
| 24 |
+
"sources": [
|
| 25 |
+
{
|
| 26 |
+
"path": "conv2d.h",
|
| 27 |
+
"content": "// Auto-generated by scripts/gen_candidate_solution.py — do not hand-edit.\n#pragma once\n\n// Per-definition constants for this conv2d specialisation.\nnamespace conv2d_def {\nconstexpr int Cout = 128;\nconstexpr int Kh = 3;\nconstexpr int Kw = 3;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad_top = 1;\nconstexpr int pad_left = 1;\nconstexpr int activation_type = 0;\n} // namespace conv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, C_in, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\nvoid inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int C_in, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "conv2d.cpp",
|
| 31 |
+
"content": "// Binding harness: computes output dims from constexpr params, calls inner_conv2d.\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight,\n int N, int C_in, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n inner_conv2d(input, output, weight, N, C_in, H, W, H_out, W_out);\n return 0;\n}\n"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "kernel.cpp",
|
| 35 |
+
"content": "// Optimized conv2d kernel for Graviton3 (SVE, 256-bit = 8 floats per vector)\n// Strategy: im2col-free direct convolution with:\n// - Outer loop over output channels (oc) in blocks of 8 (register tiling)\n// - Inner loop vectorized over output width (ow) using SVE\n// - Multiple SVE accumulators per oc to hide FMA latency (4 cycles)\n// - Weight broadcast, input loaded contiguously\n// - Accumulate over (ic, kh, kw) with pre-computed valid ranges\n// - Tiling over oh to improve cache reuse\n\n#include \"conv2d.h\"\n#include <arm_sve.h>\n#include <cstring>\n\nusing namespace conv2d_def;\n\nextern \"C\" void inner_conv2d(\n const float* __restrict__ input,\n float* __restrict__ output,\n const float* __restrict__ weight,\n int N, int C_in, int H, int W, int H_out, int W_out)\n{\n // Weight shape: [Cout=128, C_in, Kh=3, Kw=3]\n // Input shape: [N, C_in, H, W]\n // Output shape: [N, Cout=128, H_out, W_out]\n\n const int KhKw = Kh * Kw;\n const long HW = (long)H * W;\n const long H_out_W_out = (long)H_out * W_out;\n const int vl = svcntw(); // SVE vector length in floats (8 for 256-bit)\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * C_in * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n\n // Initialize output to zero\n memset(out_n, 0, sizeof(float) * Cout * H_out * W_out);\n\n // Process output channels in blocks of 8\n const int OC_BLOCK = 8;\n for (int oc_base = 0; oc_base < Cout; oc_base += OC_BLOCK) {\n int oc_end = oc_base + OC_BLOCK;\n if (oc_end > Cout) oc_end = Cout;\n int oc_count = oc_end - oc_base;\n\n // Pointers to output for each oc in block\n float* out_oc[OC_BLOCK];\n for (int i = 0; i < oc_count; i++) {\n out_oc[i] = out_n + (long)(oc_base + i) * H_out_W_out;\n }\n\n for (int ic = 0; ic < C_in; ++ic) {\n const float* in_ic = in_n + (long)ic * HW;\n\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n // Load weights for all oc in block\n float wvals[OC_BLOCK];\n for (int i = 0; i < oc_count; i++) {\n int widx = ((oc_base + i) * C_in + ic) * KhKw + kh * Kw + kw;\n wvals[i] = weight[widx];\n }\n\n // Compute valid output row range\n int ow_start = pad_left - kw;\n if (ow_start < 0) ow_start = 0;\n int ow_end = W - kw + pad_left;\n if (ow_end > W_out) ow_end = W_out;\n\n if (ow_start >= ow_end) continue;\n\n for (int oh = 0; oh < H_out; ++oh) {\n int ih = oh - pad_top + kh;\n if (ih < 0 || ih >= H) continue;\n\n const float* in_row = in_ic + ih * W + (kw - pad_left);\n\n // Process each oc in block with SVE\n // Use 2 accumulators per oc to hide FMA latency\n if (oc_count == OC_BLOCK) {\n svfloat32_t vw0 = svdup_f32(wvals[0]);\n svfloat32_t vw1 = svdup_f32(wvals[1]);\n svfloat32_t vw2 = svdup_f32(wvals[2]);\n svfloat32_t vw3 = svdup_f32(wvals[3]);\n svfloat32_t vw4 = svdup_f32(wvals[4]);\n svfloat32_t vw5 = svdup_f32(wvals[5]);\n svfloat32_t vw6 = svdup_f32(wvals[6]);\n svfloat32_t vw7 = svdup_f32(wvals[7]);\n\n float* out_row0 = out_oc[0] + oh * W_out;\n float* out_row1 = out_oc[1] + oh * W_out;\n float* out_row2 = out_oc[2] + oh * W_out;\n float* out_row3 = out_oc[3] + oh * W_out;\n float* out_row4 = out_oc[4] + oh * W_out;\n float* out_row5 = out_oc[5] + oh * W_out;\n float* out_row6 = out_oc[6] + oh * W_out;\n float* out_row7 = out_oc[7] + oh * W_out;\n\n int ow = ow_start;\n while (ow < ow_end) {\n svbool_t pg = svwhilelt_b32(ow, ow_end);\n svfloat32_t vin = svld1_f32(pg, in_row + ow);\n\n svfloat32_t vout0 = svld1_f32(pg, out_row0 + ow);\n svfloat32_t vout1 = svld1_f32(pg, out_row1 + ow);\n svfloat32_t vout2 = svld1_f32(pg, out_row2 + ow);\n svfloat32_t vout3 = svld1_f32(pg, out_row3 + ow);\n svfloat32_t vout4 = svld1_f32(pg, out_row4 + ow);\n svfloat32_t vout5 = svld1_f32(pg, out_row5 + ow);\n svfloat32_t vout6 = svld1_f32(pg, out_row6 + ow);\n svfloat32_t vout7 = svld1_f32(pg, out_row7 + ow);\n\n vout0 = svmla_f32_m(pg, vout0, vin, vw0);\n vout1 = svmla_f32_m(pg, vout1, vin, vw1);\n vout2 = svmla_f32_m(pg, vout2, vin, vw2);\n vout3 = svmla_f32_m(pg, vout3, vin, vw3);\n vout4 = svmla_f32_m(pg, vout4, vin, vw4);\n vout5 = svmla_f32_m(pg, vout5, vin, vw5);\n vout6 = svmla_f32_m(pg, vout6, vin, vw6);\n vout7 = svmla_f32_m(pg, vout7, vin, vw7);\n\n svst1_f32(pg, out_row0 + ow, vout0);\n svst1_f32(pg, out_row1 + ow, vout1);\n svst1_f32(pg, out_row2 + ow, vout2);\n svst1_f32(pg, out_row3 + ow, vout3);\n svst1_f32(pg, out_row4 + ow, vout4);\n svst1_f32(pg, out_row5 + ow, vout5);\n svst1_f32(pg, out_row6 + ow, vout6);\n svst1_f32(pg, out_row7 + ow, vout7);\n\n ow += vl;\n }\n } else {\n for (int i = 0; i < oc_count; i++) {\n svfloat32_t vw = svdup_f32(wvals[i]);\n float* out_row = out_oc[i] + oh * W_out;\n int ow = ow_start;\n while (ow < ow_end) {\n svbool_t pg = svwhilelt_b32(ow, ow_end);\n svfloat32_t vin = svld1_f32(pg, in_row + ow);\n svfloat32_t vout = svld1_f32(pg, out_row + ow);\n vout = svmla_f32_m(pg, vout, vin, vw);\n svst1_f32(pg, out_row + ow, vout);\n ow += vl;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}\n"
|
| 36 |
+
}
|
| 37 |
+
]
|
| 38 |
+
}
|
solutions/ncnn/claude-sonnet-4-6/conv2d/conv2d_kh3_kw3_sh1_sw1_dh2_dw2_cout256.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "claude-sonnet-4-6_conv2d_kh3_kw3_sh1_sw1_dh2_dw2_cout256",
|
| 3 |
+
"definition": "conv2d_kh3_kw3_sh1_sw1_dh2_dw2_cout256",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "claude-sonnet-4-6",
|
| 6 |
+
"spec": {
|
| 7 |
+
"language": "cpp",
|
| 8 |
+
"target_hardware": [
|
| 9 |
+
"graviton3",
|
| 10 |
+
"aarch64-sve"
|
| 11 |
+
],
|
| 12 |
+
"entry_point": "conv2d.cpp::armbench_entry_conv2d",
|
| 13 |
+
"dependencies": [],
|
| 14 |
+
"isa_features": [
|
| 15 |
+
"sve"
|
| 16 |
+
],
|
| 17 |
+
"compile_flags": [
|
| 18 |
+
"-O3",
|
| 19 |
+
"-march=armv8.2-a+sve",
|
| 20 |
+
"-std=c++14"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": []
|
| 23 |
+
},
|
| 24 |
+
"sources": [
|
| 25 |
+
{
|
| 26 |
+
"path": "conv2d.h",
|
| 27 |
+
"content": "// Auto-generated by scripts/gen_candidate_solution.py — do not hand-edit.\n#pragma once\n\n// Per-definition constants for this conv2d specialisation.\nnamespace conv2d_def {\nconstexpr int Cout = 256;\nconstexpr int Kh = 3;\nconstexpr int Kw = 3;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 2;\nconstexpr int Dw = 2;\nconstexpr int pad_top = 2;\nconstexpr int pad_left = 2;\nconstexpr int activation_type = 0;\n} // namespace conv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, C_in, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\nvoid inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int C_in, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "conv2d.cpp",
|
| 31 |
+
"content": "// Binding harness: computes output dims from constexpr params, calls inner_conv2d.\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight,\n int N, int C_in, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n inner_conv2d(input, output, weight, N, C_in, H, W, H_out, W_out);\n return 0;\n}\n"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "kernel.cpp",
|
| 35 |
+
"content": "#include \"conv2d.h\"\n#include <arm_sve.h>\n#include <cstring>\n#include <algorithm>\n\nusing namespace conv2d_def;\n\n// Optimized conv2d for:\n// Kh=3, Kw=3, Sh=1, Sw=1, Dh=2, Dw=2\n// pad_top=2, pad_left=2\n// Cout=256\n//\n// Key insight: The reference scalar is fast because it uses NEON auto-vectorization.\n// Our v2 was slower because it vectorizes over ow (W_out), but W_out can be small.\n//\n// Better strategy: im2col + GEMM approach\n// - Precompute im2col buffer: shape [C_in*Kh*Kw, H_out*W_out]\n// - Then do GEMM: weight[Cout, C_in*Kh*Kw] x im2col[C_in*Kh*Kw, H_out*W_out]\n// - Vectorize over Cout (output channels) using SVE\n//\n// Weight layout: [Cout, C_in, Kh, Kw] = [Cout, C_in*Kh*Kw]\n// im2col layout: [C_in*Kh*Kw, H_out*W_out]\n// Output layout: [Cout, H_out*W_out]\n//\n// GEMM: for each oc, dot product of weight row with each im2col column\n// Vectorize over oc: load 8 weight values (one per oc), broadcast im2col value, FMA\n// Actually better: vectorize over H_out*W_out (output pixels)\n//\n// For each (oc, k) where k = ic*Kh*Kw + kh*Kw + kw:\n// output[oc, :] += weight[oc, k] * im2col[k, :]\n// Vectorize over output pixels (H_out*W_out)\n//\n// This is the same as v2 but with im2col precomputed to avoid boundary checks in inner loop.\n\n// im2col buffer size: C_in * Kh * Kw * H_out * W_out\n// For C_in=256, Kh=3, Kw=3, H_out=14, W_out=14: 256*9*196 = 451584 floats = 1.8MB\n// For C_in=64, H_out=56, W_out=56: 64*9*3136 = 1806336 floats = 7.2MB - too large for L2\n// So im2col may not be cache-friendly for large inputs.\n//\n// Alternative: tile over output pixels to keep im2col in cache.\n// Process output pixels in tiles of T, so im2col tile = C_in*Kh*Kw*T floats\n// T=64: 64*9*64 = 36864 floats = 144KB - fits in L2\n//\n// Actually, let's try a different approach:\n// Loop order: oc_block (8), oh_tile, ow_tile, ic, kh, kw\n// For each oc_block of 8 output channels:\n// For each output tile (oh_tile, ow_tile):\n// Accumulate over ic, kh, kw\n// Weight: weight[oc_block:oc_block+8, ic, kh, kw] - need to load 8 values with stride C_in*Kh*Kw\n// Input: input[ic, ih, iw] - scalar broadcast\n// Output: output[oc_block:oc_block+8, oh, ow] - strided store\n//\n// This still has gather/scatter issues.\n//\n// Let's try the most cache-friendly approach:\n// Repack weights to [C_in*Kh*Kw, Cout] layout (transposed)\n// Then for each output pixel (oh, ow):\n// Accumulate over k = ic*Kh*Kw + kh*Kw + kw:\n// output[0:Cout] += weight_T[k, 0:Cout] * im2col[k, oh*W_out+ow]\n// This is a GEMV: output_vec += weight_T_row * scalar\n// Vectorize over Cout (contiguous in weight_T)\n//\n// Weight repacking: [Cout, C_in*Kh*Kw] -> [C_in*Kh*Kw, Cout]\n// This is a transpose. We do it once per call.\n// Then inner loop: for each output pixel, for each k, FMA into output[0:Cout]\n// This is very cache-friendly: weight_T rows are contiguous, output is contiguous.\n\n// Stack-allocate weight transpose buffer (max size: 256 * 256 * 9 = 589824 floats = 2.3MB)\n// Too large for stack. Use static or heap.\n\n// Actually, let's think about the sizes:\n// Cout=256, C_in*Kh*Kw = C_in*9\n// For C_in=256: 256*9*256 = 589824 floats = 2.3MB\n// For C_in=128: 128*9*256 = 294912 floats = 1.2MB\n// For C_in=64: 64*9*256 = 147456 floats = 576KB\n// For C_in=11: 11*9*256 = 25344 floats = 99KB\n//\n// The weight_T buffer fits in L3 but not L2 for large C_in.\n// However, we only need to load each weight once per output pixel.\n// The output buffer (256 * H_out * W_out) is also large.\n//\n// Let's try a blocked approach:\n// - Process output pixels in blocks of OW_TILE\n// - For each block, accumulate over all k\n// - This keeps the output block in registers/L1\n\n// Approach: tile over output pixels (ow_tile), vectorize over Cout\n// For each ow_tile of size T:\n// Initialize output[0:Cout, ow_tile] = 0\n// For each k (ic, kh, kw):\n// For each ow in ow_tile:\n// output[0:Cout, ow] += weight[0:Cout, k] * input[ic, ih, iw+ow]\n// Store output[0:Cout, ow_tile]\n//\n// This requires weight[0:Cout, k] to be contiguous - but weight is [Cout, C_in, Kh, Kw]\n// so weight[oc, k] has stride C_in*Kh*Kw between oc values.\n// We need to transpose weight first.\n\n// Let's just try the simplest approach that should work well:\n// Reorder loops to maximize cache reuse:\n// N, oh, ow_block (tile), oc_block (tile), ic, kh, kw\n// With oc vectorized using SVE\n\n// Actually, let me try a completely different approach:\n// Use the im2col + GEMM pattern but with the GEMM vectorized over Cout.\n// The key is to precompute im2col once, then do the GEMM.\n// For the GEMM, we vectorize over Cout (the M dimension).\n\n// im2col: [K, P] where K = C_in*Kh*Kw, P = H_out*W_out\n// weight: [Cout, K] (M x K)\n// output: [Cout, P] (M x P)\n// GEMM: output = weight * im2col\n\n// For the GEMM, we can use a standard blocked GEMM:\n// - Block over P (output pixels): p_tile\n// - Block over K: k_tile \n// - Vectorize over M (Cout): use SVE to process 8 output channels at once\n\n// Let's implement this with a simple but effective approach:\n// For each output pixel p:\n// For each k:\n// output[0:Cout, p] += weight[0:Cout, k] * im2col[k, p]\n// Vectorize over Cout.\n// This requires weight to be in [K, Cout] layout (transposed).\n\n// We'll precompute the transposed weight once.\n\nstatic float weight_T_buf[256 * 256 * 9]; // [K, Cout] = [C_in*Kh*Kw, Cout]\n\nextern \"C\" void inner_conv2d(\n const float* __restrict__ input, float* __restrict__ output, const float* __restrict__ weight,\n int N, int C_in, int H, int W, int H_out, int W_out)\n{\n const int vl = svcntw(); // 8 for 256-bit SVE\n const int K = C_in * Kh * Kw; // number of weight elements per output channel\n const int P = H_out * W_out; // number of output pixels per channel\n\n // Transpose weight: [Cout, K] -> [K, Cout]\n // weight_T[k, oc] = weight[oc, k]\n float* weight_T = weight_T_buf;\n for (int oc = 0; oc < Cout; ++oc) {\n const float* w_oc = weight + (long)oc * K;\n for (int k = 0; k < K; ++k) {\n weight_T[k * Cout + oc] = w_oc[k];\n }\n }\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * C_in * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n\n // Initialize output to zero\n long out_size = (long)Cout * H_out * W_out;\n memset(out_n, 0, out_size * sizeof(float));\n\n // For each output pixel (oh, ow), accumulate over k = (ic, kh, kw)\n // output[oc, oh*W_out+ow] += weight_T[k, oc] * im2col[k, oh*W_out+ow]\n //\n // Loop order: k (outer), p (inner), vectorize over Cout\n // For each k:\n // For each p = (oh, ow):\n // val = im2col[k, p] = input[ic, ih, iw]\n // output[0:Cout, p] += weight_T[k, 0:Cout] * val\n //\n // This is: for each k, do a rank-1 update of output matrix\n // weight_T[k, 0:Cout] is contiguous (Cout=256 floats = 1KB)\n // output[0:Cout, p] is strided (stride = P)\n //\n // Better: swap loops: for each p, for each k\n // output[0:Cout, p] += weight_T[k, 0:Cout] * val(k, p)\n // This is a GEMV for each p: output_col = weight_T * im2col_col\n // weight_T is [K, Cout], im2col_col is [K], output_col is [Cout]\n // But output is [Cout, P] so output_col[oc] = output[oc*P + p] - strided!\n //\n // To avoid strided access, we need output in [P, Cout] layout.\n // Let's use a temporary output buffer in [P, Cout] layout, then transpose.\n\n // Actually, let's think differently.\n // The most cache-friendly GEMM for [Cout, K] x [K, P] = [Cout, P]:\n // - Vectorize over Cout (M dimension)\n // - For each p (output pixel), for each k:\n // output[0:Cout, p] += weight[0:Cout, k] * im2col[k, p]\n // But output[0:Cout, p] is strided (stride P).\n //\n // Alternative: use output in [P, Cout] layout temporarily\n // Then for each p, for each k:\n // out_tmp[p, 0:Cout] += weight_T[k, 0:Cout] * im2col[k, p]\n // This is contiguous in Cout for both out_tmp and weight_T!\n // Then at the end, transpose out_tmp back to [Cout, P].\n\n // out_tmp size: P * Cout = H_out * W_out * 256 floats\n // For H_out=W_out=56: 56*56*256 = 802816 floats = 3.2MB - too large for stack\n // For H_out=W_out=28: 28*28*256 = 200704 floats = 784KB\n // For H_out=W_out=14: 14*14*256 = 50176 floats = 196KB\n //\n // We need to tile over P to keep things in cache.\n // Let's use a tile of P_TILE output pixels.\n // P_TILE * Cout = P_TILE * 256 floats\n // For P_TILE=64: 64*256 = 16384 floats = 64KB (fits in L1/L2)\n // For P_TILE=256: 256*256 = 65536 floats = 256KB (fits in L2)\n\n // Use a stack buffer for the output tile\n // P_TILE=64: 64*256*4 = 65536 bytes = 64KB - too large for stack\n // Use static buffer\n // Actually let's use P_TILE=32: 32*256*4 = 32768 bytes = 32KB\n\n // For now, let's try the direct approach without im2col:\n // Loop: k (ic, kh, kw), oh, ow, vectorize over Cout\n // For each (ic, kh, kw, oh, ow):\n // val = input[ic, ih, iw] (scalar)\n // w_row = weight_T[k, 0:Cout] (contiguous)\n // out_col = output[0:Cout, oh*W_out+ow] (strided by P)\n // out_col += w_row * val\n //\n // The strided output access is the problem.\n // But if we process multiple ow at once (ow_tile), we can keep\n // multiple output columns in registers.\n\n // Let's try: for each (ic, kh, kw, oh), process ow in tiles of OW_TILE\n // For each ow in tile:\n // val[ow] = input[ic, ih, iw+ow]\n // output[0:Cout, oh*W_out+ow] += weight_T[k, 0:Cout] * val[ow]\n // This still has strided output.\n\n // The fundamental issue: output is [Cout, H_out, W_out] and we want to\n // vectorize over Cout, but output pixels are not contiguous in Cout.\n\n // Best approach for this layout: vectorize over output pixels (ow),\n // which is what v2 does. The issue is that W_out can be small (14).\n // For W_out=14, we only get 1-2 SVE vectors per row.\n\n // Let's try a different tiling: process multiple oh rows simultaneously.\n // For each (ic, kh, kw, oc), process multiple (oh, ow) at once.\n // This is the approach of v2 but with oc as outer loop.\n\n // Actually, let me try the approach of tiling over oc AND ow:\n // Process OC_TILE output channels and OW_TILE output pixels simultaneously.\n // This requires OC_TILE * OW_TILE accumulators.\n // With SVE (8 floats), OC_TILE=8, OW_TILE=4: 32 accumulators (z0-z31)\n\n // For each (oc_block, oh, ow_block):\n // acc[0:OC_TILE, 0:OW_TILE] = 0\n // For each (ic, kh, kw):\n // For each ow in ow_block:\n // val = input[ic, ih, iw+ow]\n // w_vec = weight[oc_block:oc_block+OC_TILE, ic, kh, kw] (gather, stride K)\n // acc[:, ow] += w_vec * val\n // Store acc[0:OC_TILE, 0:OW_TILE] to output (strided)\n\n // The weight gather is expensive. Let's use weight_T instead:\n // w_vec = weight_T[k, oc_block:oc_block+OC_TILE] (contiguous!)\n // This is the key insight: with transposed weights, we get contiguous access.\n\n // Let's implement this:\n // OC_TILE = vl (8 for 256-bit SVE)\n // OW_TILE = 4 (process 4 output pixels simultaneously)\n // For each (oc_block, oh, ow_block):\n // acc[0:4] = {z0, z1, z2, z3} (each is a vector of OC_TILE floats)\n // For each k = (ic, kh, kw):\n // w_vec = weight_T[k, oc_block:oc_block+OC_TILE] (8 floats, contiguous)\n // For each ow in [0, OW_TILE):\n // val = input[ic, ih, iw+ow] (scalar)\n // acc[ow] += w_vec * val\n // Store acc[0:4] to output[oc_block:oc_block+OC_TILE, oh, ow_block:ow_block+OW_TILE]\n // (strided store: stride = H_out*W_out)\n\n // This approach:\n // - Weight access: contiguous (weight_T[k, oc_block:oc_block+OC_TILE])\n // - Input access: scalar (one value per k per ow)\n // - Output access: strided store (stride = P = H_out*W_out)\n // - Arithmetic intensity: OC_TILE * OW_TILE FMAs per weight load + OW_TILE input loads\n // - For OC_TILE=8, OW_TILE=4: 32 FMAs per 8 weight floats = 4 FMAs/float\n\n // The strided output store is still a concern, but it's only done once per (oc_block, oh, ow_block).\n // The inner loop (over k) has no strided access.\n\n // Let's implement this approach.\n // We'll use OW_TILE=4 accumulators per oc_block.\n\n const int OW_TILE = 4;\n\n for (int oc_base = 0; oc_base < Cout; oc_base += vl) {\n svbool_t pg_oc = svwhilelt_b32(oc_base, Cout);\n const float* wT_oc = weight_T + oc_base; // weight_T[0, oc_base:oc_base+vl]\n\n for (int oh = 0; oh < H_out; ++oh) {\n // Output pointers for this (oc_base, oh)\n // output[oc, oh, ow] = out_n[oc * P + oh * W_out + ow]\n // For oc in [oc_base, oc_base+vl), stride between oc = P\n\n int ow = 0;\n for (; ow + OW_TILE <= W_out; ow += OW_TILE) {\n // 4 accumulators, each holding OC_TILE values\n svfloat32_t acc0 = svdup_f32(0.0f);\n svfloat32_t acc1 = svdup_f32(0.0f);\n svfloat32_t acc2 = svdup_f32(0.0f);\n svfloat32_t acc3 = svdup_f32(0.0f);\n\n for (int ic = 0; ic < C_in; ++ic) {\n const float* in_ic = in_n + (long)ic * H * W;\n const float* wT_ic = wT_oc + (long)ic * Kh * Kw * Cout;\n\n for (int kh = 0; kh < Kh; ++kh) {\n int ih = oh * Sh - pad_top + kh * Dh;\n if (ih < 0 || ih >= H) continue;\n const float* in_row = in_ic + ih * W;\n\n for (int kw = 0; kw < Kw; ++kw) {\n int iw_base = ow * Sw - pad_left + kw * Dw;\n // Load weight vector for this k\n const float* wT_k = wT_ic + (kh * Kw + kw) * Cout;\n svfloat32_t vw = svld1_f32(pg_oc, wT_k);\n\n // Process 4 output pixels\n auto fma_if_valid = [&](svfloat32_t& acc, int iw) {\n if (iw >= 0 && iw < W) {\n svfloat32_t vpx = svdup_f32(in_row[iw]);\n acc = svmla_f32_m(pg_oc, acc, vw, vpx);\n }\n };\n fma_if_valid(acc0, iw_base);\n fma_if_valid(acc1, iw_base + Sw);\n fma_if_valid(acc2, iw_base + 2*Sw);\n fma_if_valid(acc3, iw_base + 3*Sw);\n }\n }\n }\n\n // Store accumulators to output (strided by P)\n long p_base = (long)oh * W_out + ow;\n auto store_acc = [&](svfloat32_t acc, int ow_off) {\n long p = p_base + ow_off;\n // output[oc, p] for oc in [oc_base, oc_base+vl)\n // These are at out_n[oc*P + p] for oc in [oc_base, oc_base+vl)\n // Stride between consecutive oc = P\n // Use scatter store\n svuint64_t idx = svindex_u64(0, (uint64_t)P);\n // Actually, use scatter with 32-bit indices\n // idx[i] = i * P (in elements)\n // But P can be large (56*56=3136), so 32-bit index is fine\n svuint32_t idx32 = svindex_u32(0, (uint32_t)P);\n float* out_base = out_n + (long)oc_base * P + p;\n svst1_scatter_u32index_f32(pg_oc, out_base, idx32, acc);\n };\n store_acc(acc0, 0);\n store_acc(acc1, 1);\n store_acc(acc2, 2);\n store_acc(acc3, 3);\n }\n\n // Handle remaining ow\n for (; ow < W_out; ++ow) {\n svfloat32_t acc = svdup_f32(0.0f);\n\n for (int ic = 0; ic < C_in; ++ic) {\n const float* in_ic = in_n + (long)ic * H * W;\n const float* wT_ic = wT_oc + (long)ic * Kh * Kw * Cout;\n\n for (int kh = 0; kh < Kh; ++kh) {\n int ih = oh * Sh - pad_top + kh * Dh;\n if (ih < 0 || ih >= H) continue;\n const float* in_row = in_ic + ih * W;\n\n for (int kw = 0; kw < Kw; ++kw) {\n int iw = ow * Sw - pad_left + kw * Dw;\n if (iw < 0 || iw >= W) continue;\n\n const float* wT_k = wT_ic + (kh * Kw + kw) * Cout;\n svfloat32_t vw = svld1_f32(pg_oc, wT_k);\n svfloat32_t vpx = svdup_f32(in_row[iw]);\n acc = svmla_f32_m(pg_oc, acc, vw, vpx);\n }\n }\n }\n\n // Scatter store\n long p = (long)oh * W_out + ow;\n svuint32_t idx32 = svindex_u32(0, (uint32_t)P);\n float* out_base = out_n + (long)oc_base * P + p;\n svst1_scatter_u32index_f32(pg_oc, out_base, idx32, acc);\n }\n }\n }\n }\n}\n"
|
| 36 |
+
}
|
| 37 |
+
]
|
| 38 |
+
}
|
solutions/ncnn/claude-sonnet-4-6/conv2d/conv2d_kh3_kw3_sh2_sw2_dh1_dw1_cout128.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "claude-sonnet-4-6_conv2d_kh3_kw3_sh2_sw2_dh1_dw1_cout128",
|
| 3 |
+
"definition": "conv2d_kh3_kw3_sh2_sw2_dh1_dw1_cout128",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "claude-sonnet-4-6",
|
| 6 |
+
"spec": {
|
| 7 |
+
"language": "cpp",
|
| 8 |
+
"target_hardware": [
|
| 9 |
+
"graviton3",
|
| 10 |
+
"aarch64-sve"
|
| 11 |
+
],
|
| 12 |
+
"entry_point": "conv2d.cpp::armbench_entry_conv2d",
|
| 13 |
+
"dependencies": [],
|
| 14 |
+
"isa_features": [
|
| 15 |
+
"sve"
|
| 16 |
+
],
|
| 17 |
+
"compile_flags": [
|
| 18 |
+
"-O3",
|
| 19 |
+
"-march=armv8.2-a+sve",
|
| 20 |
+
"-std=c++14"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": []
|
| 23 |
+
},
|
| 24 |
+
"sources": [
|
| 25 |
+
{
|
| 26 |
+
"path": "conv2d.h",
|
| 27 |
+
"content": "// Auto-generated by scripts/gen_candidate_solution.py — do not hand-edit.\n#pragma once\n\n// Per-definition constants for this conv2d specialisation.\nnamespace conv2d_def {\nconstexpr int Cout = 128;\nconstexpr int Kh = 3;\nconstexpr int Kw = 3;\nconstexpr int Sh = 2;\nconstexpr int Sw = 2;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad_top = 1;\nconstexpr int pad_left = 1;\nconstexpr int activation_type = 0;\n} // namespace conv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, C_in, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\nvoid inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int C_in, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "conv2d.cpp",
|
| 31 |
+
"content": "// Binding harness: computes output dims from constexpr params, calls inner_conv2d.\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight,\n int N, int C_in, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n inner_conv2d(input, output, weight, N, C_in, H, W, H_out, W_out);\n return 0;\n}\n"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "kernel.cpp",
|
| 35 |
+
"content": "// Optimized conv2d kernel for:\n// Cout=128, Kh=3, Kw=3, Sh=2, Sw=2, Dh=1, Dw=1, pad_top=1, pad_left=1\n//\n// Key strategy: \n// 1. Transpose weight to [ksize, Cout] layout for contiguous access over Cout\n// 2. For each output pixel, do a GEMV: acc[0..127] += px * weight_T[w_offset * 128 + 0..127]\n// 3. SVE vectorizes the inner loop over Cout (contiguous 128 floats)\n// 4. Process multiple output pixels (ow) simultaneously to amortize weight loads\n\n#include \"conv2d.h\"\n#include <arm_sve.h>\n#include <cstring>\n#include <algorithm>\n#include <cstdlib>\n#include <new>\n\nusing namespace conv2d_def;\n\nstatic float* g_weight_T = nullptr;\nstatic int g_weight_T_ksize = 0;\nstatic int g_weight_T_cin = 0;\n\n// Transpose weight from [Cout, C_in, Kh, Kw] to [C_in, Kh, Kw, Cout]\n// so that for a given (ic, kh, kw), all Cout weights are contiguous\nstatic void transpose_weight(const float* weight, float* weight_T, int C_in) {\n int ksize = C_in * Kh * Kw;\n // weight[oc * ksize + k] -> weight_T[k * Cout + oc]\n for (int oc = 0; oc < Cout; ++oc) {\n const float* w_oc = weight + (long)oc * ksize;\n for (int k = 0; k < ksize; ++k) {\n weight_T[(long)k * Cout + oc] = w_oc[k];\n }\n }\n}\n\nextern \"C\" void inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int C_in, int H, int W, int H_out, int W_out)\n{\n int ksize = C_in * Kh * Kw;\n \n // Allocate and build transposed weight if needed\n // (In practice weight is constant across calls with same C_in)\n float* weight_T = (float*)aligned_alloc(64, (long)ksize * Cout * sizeof(float));\n if (!weight_T) return;\n \n transpose_weight(weight, weight_T, C_in);\n \n // Process multiple output pixels at once (tile over ow)\n // For each tile of OW_TILE output pixels, we accumulate into OW_TILE * 128 accumulators\n // This amortizes the weight_T load cost\n \n const int OW_TILE = 4; // process 4 output pixels at a time\n \n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * C_in * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n \n for (int oh = 0; oh < H_out; ++oh) {\n int ih_base = oh * Sh - pad_top;\n \n // Allocate tile accumulators on stack\n // OW_TILE * 128 floats = 4 * 128 * 4 = 2048 bytes\n float acc[OW_TILE][128] __attribute__((aligned(64)));\n \n int ow = 0;\n for (; ow + OW_TILE <= W_out; ow += OW_TILE) {\n // Zero accumulators\n memset(acc, 0, sizeof(float) * OW_TILE * 128);\n \n // Precompute iw_base for each pixel in tile\n int iw_bases[OW_TILE];\n for (int t = 0; t < OW_TILE; ++t) {\n iw_bases[t] = (ow + t) * Sw - pad_left;\n }\n \n // Accumulate over ic, kh, kw\n for (int ic = 0; ic < C_in; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n int w_ic_base = ic * Kh * Kw;\n \n for (int kh = 0; kh < Kh; ++kh) {\n int ih = ih_base + kh;\n if (ih < 0 || ih >= H) continue;\n const float* in_row = inc + ih * W;\n \n for (int kw = 0; kw < Kw; ++kw) {\n int k = w_ic_base + kh * Kw + kw;\n const float* wT_row = weight_T + (long)k * Cout;\n \n // For each pixel in tile\n for (int t = 0; t < OW_TILE; ++t) {\n int iw = iw_bases[t] + kw;\n if (iw < 0 || iw >= W) continue;\n float px = in_row[iw];\n \n // SVE: acc[t][0..127] += px * wT_row[0..127]\n svfloat32_t vpx = svdup_f32(px);\n float* acc_t = acc[t];\n \n // 128 floats = 16 SVE vectors of 8 floats (256-bit)\n // Unroll 4x\n for (int oc = 0; oc < 128; oc += 32) {\n svbool_t pg = svptrue_b32();\n \n svfloat32_t va0 = svld1_f32(pg, acc_t + oc);\n svfloat32_t vw0 = svld1_f32(pg, wT_row + oc);\n va0 = svmla_f32_m(pg, va0, vpx, vw0);\n svst1_f32(pg, acc_t + oc, va0);\n \n svfloat32_t va1 = svld1_f32(pg, acc_t + oc + 8);\n svfloat32_t vw1 = svld1_f32(pg, wT_row + oc + 8);\n va1 = svmla_f32_m(pg, va1, vpx, vw1);\n svst1_f32(pg, acc_t + oc + 8, va1);\n \n svfloat32_t va2 = svld1_f32(pg, acc_t + oc + 16);\n svfloat32_t vw2 = svld1_f32(pg, wT_row + oc + 16);\n va2 = svmla_f32_m(pg, va2, vpx, vw2);\n svst1_f32(pg, acc_t + oc + 16, va2);\n \n svfloat32_t va3 = svld1_f32(pg, acc_t + oc + 24);\n svfloat32_t vw3 = svld1_f32(pg, wT_row + oc + 24);\n va3 = svmla_f32_m(pg, va3, vpx, vw3);\n svst1_f32(pg, acc_t + oc + 24, va3);\n }\n }\n }\n }\n }\n \n // Write tile results to output\n for (int t = 0; t < OW_TILE; ++t) {\n long out_pixel_offset = (long)oh * W_out + (ow + t);\n for (int oc = 0; oc < Cout; ++oc) {\n out_n[(long)oc * H_out * W_out + out_pixel_offset] = acc[t][oc];\n }\n }\n }\n \n // Handle remaining output pixels\n for (; ow < W_out; ++ow) {\n float acc1[128] __attribute__((aligned(64)));\n memset(acc1, 0, sizeof(float) * 128);\n int iw_base = ow * Sw - pad_left;\n \n for (int ic = 0; ic < C_in; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n int w_ic_base = ic * Kh * Kw;\n \n for (int kh = 0; kh < Kh; ++kh) {\n int ih = ih_base + kh;\n if (ih < 0 || ih >= H) continue;\n const float* in_row = inc + ih * W;\n \n for (int kw = 0; kw < Kw; ++kw) {\n int iw = iw_base + kw;\n if (iw < 0 || iw >= W) continue;\n float px = in_row[iw];\n int k = w_ic_base + kh * Kw + kw;\n const float* wT_row = weight_T + (long)k * Cout;\n \n svfloat32_t vpx = svdup_f32(px);\n for (int oc = 0; oc < 128; oc += 8) {\n svbool_t pg = svptrue_b32();\n svfloat32_t va = svld1_f32(pg, acc1 + oc);\n svfloat32_t vw = svld1_f32(pg, wT_row + oc);\n va = svmla_f32_m(pg, va, vpx, vw);\n svst1_f32(pg, acc1 + oc, va);\n }\n }\n }\n }\n \n long out_pixel_offset = (long)oh * W_out + ow;\n for (int oc = 0; oc < Cout; ++oc) {\n out_n[(long)oc * H_out * W_out + out_pixel_offset] = acc1[oc];\n }\n }\n }\n }\n \n free(weight_T);\n}\n"
|
| 36 |
+
}
|
| 37 |
+
]
|
| 38 |
+
}
|
solutions/ncnn/claude-sonnet-4-6/conv2d/conv2d_kh5_kw5_sh1_sw1_dh1_dw1_cout64.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "claude-sonnet-4-6_conv2d_kh5_kw5_sh1_sw1_dh1_dw1_cout64",
|
| 3 |
+
"definition": "conv2d_kh5_kw5_sh1_sw1_dh1_dw1_cout64",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "claude-sonnet-4-6",
|
| 6 |
+
"spec": {
|
| 7 |
+
"language": "cpp",
|
| 8 |
+
"target_hardware": [
|
| 9 |
+
"graviton3",
|
| 10 |
+
"aarch64-sve"
|
| 11 |
+
],
|
| 12 |
+
"entry_point": "conv2d.cpp::armbench_entry_conv2d",
|
| 13 |
+
"dependencies": [],
|
| 14 |
+
"isa_features": [
|
| 15 |
+
"sve"
|
| 16 |
+
],
|
| 17 |
+
"compile_flags": [
|
| 18 |
+
"-O3",
|
| 19 |
+
"-march=armv8.2-a+sve",
|
| 20 |
+
"-std=c++14"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": []
|
| 23 |
+
},
|
| 24 |
+
"sources": [
|
| 25 |
+
{
|
| 26 |
+
"path": "conv2d.h",
|
| 27 |
+
"content": "// Auto-generated by scripts/gen_candidate_solution.py — do not hand-edit.\n#pragma once\n\n// Per-definition constants for this conv2d specialisation.\nnamespace conv2d_def {\nconstexpr int Cout = 64;\nconstexpr int Kh = 5;\nconstexpr int Kw = 5;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad_top = 2;\nconstexpr int pad_left = 2;\nconstexpr int activation_type = 0;\n} // namespace conv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, C_in, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\nvoid inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int C_in, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "conv2d.cpp",
|
| 31 |
+
"content": "// Binding harness: computes output dims from constexpr params, calls inner_conv2d.\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight,\n int N, int C_in, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n inner_conv2d(input, output, weight, N, C_in, H, W, H_out, W_out);\n return 0;\n}\n"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "kernel.cpp",
|
| 35 |
+
"content": "// Optimized conv2d kernel for AArch64 SVE (Graviton3, 256-bit = 8 floats)\n// conv2d_kh5_kw5_sh1_sw1_dh1_dw1_cout64\n//\n// Strategy: Im2col-free direct convolution with aggressive tiling.\n// Key insight: The reference scalar is FASTER than v1 (speedup=0.3x).\n// v1 was loading input pixels one-by-one into a stack buffer — terrible.\n//\n// New approach:\n// - Loop order: N, oh, ow_tile(8), oc_tile(8), ic, kh, kw\n// - 8 output channels (oc) x 8 output widths (ow) = 64 accumulators\n// - For each (ic, kh, kw): load 8 input pixels as SVE vector,\n// broadcast 8 weights (one per oc), do 8 fmla ops\n// - Handle boundary rows/cols by pre-padding or masking\n// - Pre-compute which rows/cols are in-bounds to avoid per-pixel checks\n//\n// Weight layout: [Cout=64, Cin, Kh=5, Kw=5]\n// Input layout: [N, Cin, H, W]\n// Output layout: [N, Cout=64, H_out, W_out]\n\n#include \"conv2d.h\"\n#include <arm_sve.h>\n#include <cstring>\n#include <algorithm>\n#include <cstdlib>\n\nusing namespace conv2d_def;\n\n// Tile sizes\nstatic constexpr int OC_TILE = 8; // process 8 output channels at once\nstatic constexpr int OW_TILE = 8; // process 8 output widths at once (= SVE vector width for float32 at 256-bit)\n\nextern \"C\" void inner_conv2d(\n const float* __restrict__ input,\n float* __restrict__ output,\n const float* __restrict__ weight,\n int N, int C_in, int H, int W, int H_out, int W_out)\n{\n const int OC = Cout; // 64\n const int KH = Kh; // 5\n const int KW = Kw; // 5\n const int PAD_TOP = pad_top; // 2\n const int PAD_LEFT = pad_left; // 2\n\n // SVE predicate for 8 floats (256-bit / 32-bit = 8 lanes)\n const svbool_t ptrue = svptrue_b32();\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * C_in * H * W;\n float* out_n = output + (long)n * OC * H_out * W_out;\n\n // Tile over output channels (8 at a time)\n for (int oc_base = 0; oc_base < OC; oc_base += OC_TILE) {\n // Pointers to weight rows for each of the 8 output channels\n // weight[oc, ic, kh, kw] = weight + ((oc*C_in + ic)*KH + kh)*KW + kw\n // stride between consecutive oc: C_in * KH * KW floats\n const long w_oc_stride = (long)C_in * KH * KW;\n\n // Tile over output rows\n for (int oh = 0; oh < H_out; ++oh) {\n // Tile over output columns (8 at a time)\n int ow = 0;\n for (; ow + OW_TILE <= W_out; ow += OW_TILE) {\n // 8 accumulators for 8 output channels, each holding 8 output widths\n svfloat32_t acc0 = svdup_f32(0.0f);\n svfloat32_t acc1 = svdup_f32(0.0f);\n svfloat32_t acc2 = svdup_f32(0.0f);\n svfloat32_t acc3 = svdup_f32(0.0f);\n svfloat32_t acc4 = svdup_f32(0.0f);\n svfloat32_t acc5 = svdup_f32(0.0f);\n svfloat32_t acc6 = svdup_f32(0.0f);\n svfloat32_t acc7 = svdup_f32(0.0f);\n\n for (int ic = 0; ic < C_in; ++ic) {\n const float* in_ic = in_n + (long)ic * H * W;\n // Weight pointer for this (oc_base, ic) combination\n // weight[(oc_base+o)*C_in*KH*KW + ic*KH*KW + kh*KW + kw]\n const float* w_base = weight + ((long)(oc_base) * C_in + ic) * KH * KW;\n\n for (int kh = 0; kh < KH; ++kh) {\n int ih = oh - PAD_TOP + kh;\n if (ih < 0 || ih >= H) continue;\n const float* in_row = in_ic + ih * W;\n\n for (int kw = 0; kw < KW; ++kw) {\n int iw_base = ow - PAD_LEFT + kw;\n // iw_base + 0..7 are the input column indices\n // For the main tile (ow + OW_TILE <= W_out), check boundaries:\n // iw_base can be negative (left pad) or >= W (right pad)\n // iw_base + 7 can be >= W\n\n svfloat32_t vin;\n if (iw_base >= 0 && iw_base + OW_TILE <= W) {\n // Fully in-bounds: load 8 consecutive floats\n vin = svld1_f32(ptrue, in_row + iw_base);\n } else {\n // Boundary case: load with masking\n // Create index vector [iw_base, iw_base+1, ..., iw_base+7]\n // and mask out-of-bounds\n float tmp[8];\n for (int i = 0; i < 8; ++i) {\n int iw = iw_base + i;\n tmp[i] = (iw >= 0 && iw < W) ? in_row[iw] : 0.0f;\n }\n vin = svld1_f32(ptrue, tmp);\n }\n\n // Weight pointer for this (ic, kh, kw)\n const float* wp = w_base + (kh * KW + kw);\n // Load 8 weights (one per output channel), broadcast each\n float w0 = wp[0 * w_oc_stride];\n float w1 = wp[1 * w_oc_stride];\n float w2 = wp[2 * w_oc_stride];\n float w3 = wp[3 * w_oc_stride];\n float w4 = wp[4 * w_oc_stride];\n float w5 = wp[5 * w_oc_stride];\n float w6 = wp[6 * w_oc_stride];\n float w7 = wp[7 * w_oc_stride];\n\n acc0 = svmla_n_f32_m(ptrue, acc0, vin, w0);\n acc1 = svmla_n_f32_m(ptrue, acc1, vin, w1);\n acc2 = svmla_n_f32_m(ptrue, acc2, vin, w2);\n acc3 = svmla_n_f32_m(ptrue, acc3, vin, w3);\n acc4 = svmla_n_f32_m(ptrue, acc4, vin, w4);\n acc5 = svmla_n_f32_m(ptrue, acc5, vin, w5);\n acc6 = svmla_n_f32_m(ptrue, acc6, vin, w6);\n acc7 = svmla_n_f32_m(ptrue, acc7, vin, w7);\n }\n }\n }\n\n // Store 8 output channels x 8 output widths\n long out_off = (long)oh * W_out + ow;\n svst1_f32(ptrue, out_n + (long)(oc_base+0) * H_out * W_out + out_off, acc0);\n svst1_f32(ptrue, out_n + (long)(oc_base+1) * H_out * W_out + out_off, acc1);\n svst1_f32(ptrue, out_n + (long)(oc_base+2) * H_out * W_out + out_off, acc2);\n svst1_f32(ptrue, out_n + (long)(oc_base+3) * H_out * W_out + out_off, acc3);\n svst1_f32(ptrue, out_n + (long)(oc_base+4) * H_out * W_out + out_off, acc4);\n svst1_f32(ptrue, out_n + (long)(oc_base+5) * H_out * W_out + out_off, acc5);\n svst1_f32(ptrue, out_n + (long)(oc_base+6) * H_out * W_out + out_off, acc6);\n svst1_f32(ptrue, out_n + (long)(oc_base+7) * H_out * W_out + out_off, acc7);\n }\n\n // Handle remaining output widths (scalar)\n for (; ow < W_out; ++ow) {\n float sums[OC_TILE] = {};\n for (int ic = 0; ic < C_in; ++ic) {\n const float* in_ic = in_n + (long)ic * H * W;\n const float* w_base = weight + ((long)(oc_base) * C_in + ic) * KH * KW;\n for (int kh = 0; kh < KH; ++kh) {\n int ih = oh - PAD_TOP + kh;\n if (ih < 0 || ih >= H) continue;\n for (int kw = 0; kw < KW; ++kw) {\n int iw = ow - PAD_LEFT + kw;\n if (iw < 0 || iw >= W) continue;\n float px = in_ic[ih * W + iw];\n const float* wp = w_base + (kh * KW + kw);\n for (int o = 0; o < OC_TILE; ++o) {\n sums[o] += px * wp[o * w_oc_stride];\n }\n }\n }\n }\n long out_off = (long)oh * W_out + ow;\n for (int o = 0; o < OC_TILE; ++o) {\n out_n[(long)(oc_base+o) * H_out * W_out + out_off] = sums[o];\n }\n }\n }\n }\n }\n}\n"
|
| 36 |
+
}
|
| 37 |
+
]
|
| 38 |
+
}
|
solutions/ncnn/claude-sonnet-4-6/conv2d/conv2d_kh7_kw7_sh2_sw2_dh1_dw1_cout64.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "claude-sonnet-4-6_conv2d_kh7_kw7_sh2_sw2_dh1_dw1_cout64",
|
| 3 |
+
"definition": "conv2d_kh7_kw7_sh2_sw2_dh1_dw1_cout64",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "claude-sonnet-4-6",
|
| 6 |
+
"spec": {
|
| 7 |
+
"language": "cpp",
|
| 8 |
+
"target_hardware": [
|
| 9 |
+
"graviton3",
|
| 10 |
+
"aarch64-sve"
|
| 11 |
+
],
|
| 12 |
+
"entry_point": "conv2d.cpp::armbench_entry_conv2d",
|
| 13 |
+
"dependencies": [],
|
| 14 |
+
"isa_features": [
|
| 15 |
+
"sve"
|
| 16 |
+
],
|
| 17 |
+
"compile_flags": [
|
| 18 |
+
"-O3",
|
| 19 |
+
"-march=armv8.2-a+sve",
|
| 20 |
+
"-std=c++14"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": []
|
| 23 |
+
},
|
| 24 |
+
"sources": [
|
| 25 |
+
{
|
| 26 |
+
"path": "conv2d.h",
|
| 27 |
+
"content": "// Auto-generated by scripts/gen_candidate_solution.py — do not hand-edit.\n#pragma once\n\n// Per-definition constants for this conv2d specialisation.\nnamespace conv2d_def {\nconstexpr int Cout = 64;\nconstexpr int Kh = 7;\nconstexpr int Kw = 7;\nconstexpr int Sh = 2;\nconstexpr int Sw = 2;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad_top = 3;\nconstexpr int pad_left = 3;\nconstexpr int activation_type = 0;\n} // namespace conv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, C_in, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\nvoid inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int C_in, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "conv2d.cpp",
|
| 31 |
+
"content": "// Binding harness: computes output dims from constexpr params, calls inner_conv2d.\n#include \"conv2d.h\"\nusing namespace conv2d_def;\n\nextern \"C\" int armbench_entry_conv2d(\n const float* input, float* output,\n const float* weight,\n int N, int C_in, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad_top - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad_left - ext_kw) / Sw + 1;\n inner_conv2d(input, output, weight, N, C_in, H, W, H_out, W_out);\n return 0;\n}\n"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "kernel.cpp",
|
| 35 |
+
"content": "\n// Optimized conv2d kernel for conv2d_kh7_kw7_sh2_sw2_dh1_dw1_cout64\n// Strategy: vectorize over output channels (Cout=64)\n// Weight layout: [Cout=64, C_in, Kh=7, Kw=7]\n// For each (oh, ow), compute all 64 output channels using SVE\n// SVE 256-bit = 8 floats per vector, so 8 vectors cover all 64 oc\n// Key fix: weight[oc, ic, kh, kw] = weight[oc * C_in * Kh * Kw + ic * Kh * Kw + kh * Kw + kw]\n// For fixed (ic, kh, kw), consecutive oc values are C_in*Kh*Kw apart (strided)\n// We need to load 8 consecutive oc at a time from strided locations\n// Better approach: reorder weight to [C_in, Kh, Kw, Cout] for contiguous Cout access\n\n#include \"conv2d.h\"\n#include <arm_sve.h>\n#include <cstring>\n#include <cstdlib>\n#include <algorithm>\n\nusing namespace conv2d_def;\n\n// Repack weight from [Cout, C_in, Kh, Kw] to [C_in, Kh, Kw, Cout]\n// so that for fixed (ic, kh, kw), all Cout values are contiguous\nstatic void repack_weight(const float* __restrict__ src, float* __restrict__ dst,\n int C_in)\n{\n // src[oc, ic, kh, kw] = src[oc * C_in * Kh * Kw + ic * Kh * Kw + kh * Kw + kw]\n // dst[ic, kh, kw, oc] = dst[(ic * Kh * Kw + kh * Kw + kw) * Cout + oc]\n for (int oc = 0; oc < Cout; ++oc) {\n for (int ic = 0; ic < C_in; ++ic) {\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n int src_idx = ((oc * C_in + ic) * Kh + kh) * Kw + kw;\n int dst_idx = ((ic * Kh + kh) * Kw + kw) * Cout + oc;\n dst[dst_idx] = src[src_idx];\n }\n }\n }\n }\n}\n\nextern \"C\" void inner_conv2d(\n const float* input, float* output, const float* weight,\n int N, int C_in, int H, int W, int H_out, int W_out)\n{\n const int KhKw = Kh * Kw;\n const int total_w = C_in * KhKw * Cout;\n\n // Repack weight to [C_in, Kh, Kw, Cout=64] layout\n float* w_packed = (float*)malloc(total_w * sizeof(float));\n repack_weight(weight, w_packed, C_in);\n\n svbool_t ptrue = svptrue_b32();\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * C_in * H * W;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n\n for (int oh = 0; oh < H_out; ++oh) {\n int ih_base = oh * Sh - pad_top;\n for (int ow = 0; ow < W_out; ++ow) {\n int iw_base = ow * Sw - pad_left;\n\n // 8 accumulators for 64 output channels (8 floats each)\n svfloat32_t acc0 = svdup_f32(0.0f);\n svfloat32_t acc1 = svdup_f32(0.0f);\n svfloat32_t acc2 = svdup_f32(0.0f);\n svfloat32_t acc3 = svdup_f32(0.0f);\n svfloat32_t acc4 = svdup_f32(0.0f);\n svfloat32_t acc5 = svdup_f32(0.0f);\n svfloat32_t acc6 = svdup_f32(0.0f);\n svfloat32_t acc7 = svdup_f32(0.0f);\n\n for (int ic = 0; ic < C_in; ++ic) {\n const float* inc = in_n + (long)ic * H * W;\n // w_packed[ic, kh, kw, :] starts at w_packed + (ic * KhKw) * Cout\n const float* wp_ic = w_packed + (long)ic * KhKw * Cout;\n\n for (int kh = 0; kh < Kh; ++kh) {\n int ih = ih_base + kh;\n if (ih < 0 || ih >= H) continue;\n const float* in_row = inc + ih * W;\n\n for (int kw = 0; kw < Kw; ++kw) {\n int iw = iw_base + kw;\n if (iw < 0 || iw >= W) continue;\n float px = in_row[iw];\n svfloat32_t vpx = svdup_f32(px);\n\n // w_packed[ic, kh, kw, 0..63] is contiguous\n const float* wp = wp_ic + (kh * Kw + kw) * Cout;\n\n acc0 = svmla_f32_x(ptrue, acc0, vpx, svld1_f32(ptrue, wp + 0));\n acc1 = svmla_f32_x(ptrue, acc1, vpx, svld1_f32(ptrue, wp + 8));\n acc2 = svmla_f32_x(ptrue, acc2, vpx, svld1_f32(ptrue, wp + 16));\n acc3 = svmla_f32_x(ptrue, acc3, vpx, svld1_f32(ptrue, wp + 24));\n acc4 = svmla_f32_x(ptrue, acc4, vpx, svld1_f32(ptrue, wp + 32));\n acc5 = svmla_f32_x(ptrue, acc5, vpx, svld1_f32(ptrue, wp + 40));\n acc6 = svmla_f32_x(ptrue, acc6, vpx, svld1_f32(ptrue, wp + 48));\n acc7 = svmla_f32_x(ptrue, acc7, vpx, svld1_f32(ptrue, wp + 56));\n }\n }\n }\n\n // Store: output[oc, oh, ow] for oc=0..63\n // output layout: [Cout, H_out, W_out]\n long out_pos = (long)oh * W_out + ow;\n long oc_stride = (long)H_out * W_out;\n\n // Store 8 floats per vector to non-contiguous output locations\n // Each group of 8 oc values goes to consecutive oc channels\n // out_n[oc * oc_stride + out_pos] for oc=0..7, 8..15, etc.\n // These are strided stores - use scatter or scalar store\n // For simplicity, use scalar store from SVE vector\n float tmp[64];\n svst1_f32(ptrue, tmp + 0, acc0);\n svst1_f32(ptrue, tmp + 8, acc1);\n svst1_f32(ptrue, tmp + 16, acc2);\n svst1_f32(ptrue, tmp + 24, acc3);\n svst1_f32(ptrue, tmp + 32, acc4);\n svst1_f32(ptrue, tmp + 40, acc5);\n svst1_f32(ptrue, tmp + 48, acc6);\n svst1_f32(ptrue, tmp + 56, acc7);\n\n for (int oc = 0; oc < Cout; ++oc) {\n out_n[oc * oc_stride + out_pos] = tmp[oc];\n }\n }\n }\n }\n\n free(w_packed);\n}\n"
|
| 36 |
+
}
|
| 37 |
+
]
|
| 38 |
+
}
|
solutions/ncnn/claude-sonnet-4-6/conv2d_depthwise/conv2d_depthwise_kh3_kw3_sh1_sw1_dh1_dw1_p1.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "claude-sonnet-4-6_conv2d_depthwise_kh3_kw3_sh1_sw1_dh1_dw1_p1",
|
| 3 |
+
"definition": "conv2d_depthwise_kh3_kw3_sh1_sw1_dh1_dw1_p1",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "claude-sonnet-4-6",
|
| 6 |
+
"spec": {
|
| 7 |
+
"language": "cpp",
|
| 8 |
+
"target_hardware": [
|
| 9 |
+
"graviton3",
|
| 10 |
+
"aarch64-sve"
|
| 11 |
+
],
|
| 12 |
+
"entry_point": "conv2d_depthwise.cpp::armbench_entry_conv2d_depthwise",
|
| 13 |
+
"dependencies": [],
|
| 14 |
+
"isa_features": [
|
| 15 |
+
"sve"
|
| 16 |
+
],
|
| 17 |
+
"compile_flags": [
|
| 18 |
+
"-O3",
|
| 19 |
+
"-march=armv8.2-a+sve",
|
| 20 |
+
"-std=c++14"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": []
|
| 23 |
+
},
|
| 24 |
+
"sources": [
|
| 25 |
+
{
|
| 26 |
+
"path": "conv2d_depthwise.h",
|
| 27 |
+
"content": "#pragma once\n\n// Per-definition constants for this conv2d_depthwise specialisation.\nnamespace conv2d_depthwise_def {\nconstexpr int Kh = 3;\nconstexpr int Kw = 3;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad = 1;\n} // namespace conv2d_depthwise_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, C, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\n// Input layout: (N, C, H, W), output layout: (N, C, H_out, W_out).\nvoid inner_conv2d_depthwise(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "conv2d_depthwise.cpp",
|
| 31 |
+
"content": "// Binding harness: computes H_out/W_out from constexpr params, calls inner_conv2d_depthwise.\n// ABI: armbench_entry_conv2d_depthwise(input*, output*, weight*, bias*, N, C, H, W)\n// Input layout: (N, C, H, W); output layout: (N, C, H_out, W_out).\n#include \"conv2d_depthwise.h\"\nusing namespace conv2d_depthwise_def;\n\nextern \"C\" int armbench_entry_conv2d_depthwise(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad - ext_kw) / Sw + 1;\n inner_conv2d_depthwise(input, output, weight, bias, N, C, H, W, H_out, W_out);\n return 0;\n}\n"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "kernel.cpp",
|
| 35 |
+
"content": "\n#include \"conv2d_depthwise.h\"\n#include <arm_sve.h>\n#include <cstring>\n\nusing namespace conv2d_depthwise_def;\n\n// Optimized depthwise conv2d with SVE intrinsics\n// Strategy:\n// - For each (n, c), process the output row by row\n// - For each output row, vectorize over output width (ow) using SVE\n// - Preload the 9 weights for the 3x3 kernel\n// - Handle padding by zeroing out-of-bounds input accesses\n// - Use fused multiply-add for efficiency\n\nextern \"C\" void inner_conv2d_depthwise(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C, int H, int W, int H_out, int W_out)\n{\n const int vl = svcntw(); // SVE vector length in floats\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * C * H * W;\n float* out_n = output + (long)n * C * H_out * W_out;\n\n for (int c = 0; c < C; ++c) {\n const float* in_c = in_n + (long)c * H * W;\n float* out_c = out_n + (long)c * H_out * W_out;\n const float* w_c = weight + (long)c * Kh * Kw;\n\n // Load all 9 weights\n float w00 = w_c[0], w01 = w_c[1], w02 = w_c[2];\n float w10 = w_c[3], w11 = w_c[4], w12 = w_c[5];\n float w20 = w_c[6], w21 = w_c[7], w22 = w_c[8];\n float b = bias[c];\n\n svfloat32_t vw00 = svdup_f32(w00), vw01 = svdup_f32(w01), vw02 = svdup_f32(w02);\n svfloat32_t vw10 = svdup_f32(w10), vw11 = svdup_f32(w11), vw12 = svdup_f32(w12);\n svfloat32_t vw20 = svdup_f32(w20), vw21 = svdup_f32(w21), vw22 = svdup_f32(w22);\n svfloat32_t vbias = svdup_f32(b);\n\n for (int oh = 0; oh < H_out; ++oh) {\n // ih0, ih1, ih2 are the three input rows\n int ih0 = oh - 1; // oh*Sh - pad + 0*Dh\n int ih1 = oh; // oh*Sh - pad + 1*Dh\n int ih2 = oh + 1; // oh*Sh - pad + 2*Dh\n\n const float* row0 = (ih0 >= 0 && ih0 < H) ? in_c + ih0 * W : nullptr;\n const float* row1 = (ih1 >= 0 && ih1 < H) ? in_c + ih1 * W : nullptr;\n const float* row2 = (ih2 >= 0 && ih2 < H) ? in_c + ih2 * W : nullptr;\n\n float* out_row = out_c + oh * W_out;\n\n // Process output width in SVE vector chunks\n // For each output pixel ow, input pixel iw = ow - 1, ow, ow+1\n // We need to handle left/right padding carefully\n // \n // Strategy: process interior pixels (ow=1..W_out-2) with full SVE,\n // handle boundary pixels (ow=0 and ow=W_out-1) separately.\n //\n // For interior: iw ranges from 0 to W-1 (no padding needed)\n // We load row[ow-1..ow+1] for each kernel column\n\n // Handle ow=0 (left boundary) scalar\n {\n int ow = 0;\n float sum = b;\n // kw=0: iw = -1 (out of bounds)\n // kw=1: iw = 0\n // kw=2: iw = 1\n if (row0) { sum += row0[0] * w01; if (W > 1) sum += row0[1] * w02; }\n if (row1) { sum += row1[0] * w11; if (W > 1) sum += row1[1] * w12; }\n if (row2) { sum += row2[0] * w21; if (W > 1) sum += row2[1] * w22; }\n out_row[0] = sum;\n }\n\n // Interior: ow = 1 .. W_out-2 (vectorized)\n // For these, iw-1 = ow-2 >= 0 and iw+1 = ow <= W-1 (since ow <= W_out-2 = W-2 when pad=1, sh=1)\n // Actually W_out = H (same spatial), so ow goes 0..W-1\n // Interior: ow=1..W-2, iw ranges 0..W-1\n {\n int ow_start = 1;\n int ow_end = W_out - 1; // exclusive\n\n for (int ow = ow_start; ow < ow_end; ) {\n svbool_t pg = svwhilelt_b32(ow, ow_end);\n int64_t ow64 = (int64_t)ow;\n\n svfloat32_t acc = vbias;\n\n // For interior pixels, iw = ow - 1, ow, ow + 1 are all valid\n // Load row0 contributions\n if (row0) {\n // col 0: row0[ow-1]\n svfloat32_t v = svld1(pg, row0 + ow - 1);\n acc = svmla_f32_m(pg, acc, v, vw00);\n // col 1: row0[ow]\n v = svld1(pg, row0 + ow);\n acc = svmla_f32_m(pg, acc, v, vw01);\n // col 2: row0[ow+1]\n v = svld1(pg, row0 + ow + 1);\n acc = svmla_f32_m(pg, acc, v, vw02);\n }\n\n if (row1) {\n svfloat32_t v = svld1(pg, row1 + ow - 1);\n acc = svmla_f32_m(pg, acc, v, vw10);\n v = svld1(pg, row1 + ow);\n acc = svmla_f32_m(pg, acc, v, vw11);\n v = svld1(pg, row1 + ow + 1);\n acc = svmla_f32_m(pg, acc, v, vw12);\n }\n\n if (row2) {\n svfloat32_t v = svld1(pg, row2 + ow - 1);\n acc = svmla_f32_m(pg, acc, v, vw20);\n v = svld1(pg, row2 + ow);\n acc = svmla_f32_m(pg, acc, v, vw21);\n v = svld1(pg, row2 + ow + 1);\n acc = svmla_f32_m(pg, acc, v, vw22);\n }\n\n svst1(pg, out_row + ow, acc);\n ow += vl;\n }\n }\n\n // Handle ow=W_out-1 (right boundary) scalar\n if (W_out > 1) {\n int ow = W_out - 1;\n float sum = b;\n // kw=0: iw = ow-1 = W-2 (valid if W>=2)\n // kw=1: iw = ow = W-1 (valid)\n // kw=2: iw = ow+1 = W (out of bounds)\n if (row0) { if (W >= 2) sum += row0[ow-1] * w00; sum += row0[ow] * w01; }\n if (row1) { if (W >= 2) sum += row1[ow-1] * w10; sum += row1[ow] * w11; }\n if (row2) { if (W >= 2) sum += row2[ow-1] * w20; sum += row2[ow] * w21; }\n out_row[ow] = sum;\n }\n }\n }\n }\n}\n"
|
| 36 |
+
}
|
| 37 |
+
]
|
| 38 |
+
}
|
solutions/ncnn/claude-sonnet-4-6/conv2d_depthwise/conv2d_depthwise_kh3_kw3_sh2_sw2_dh1_dw1_p1.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "claude-sonnet-4-6_conv2d_depthwise_kh3_kw3_sh2_sw2_dh1_dw1_p1",
|
| 3 |
+
"definition": "conv2d_depthwise_kh3_kw3_sh2_sw2_dh1_dw1_p1",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "claude-sonnet-4-6",
|
| 6 |
+
"spec": {
|
| 7 |
+
"language": "cpp",
|
| 8 |
+
"target_hardware": [
|
| 9 |
+
"graviton3",
|
| 10 |
+
"aarch64-sve"
|
| 11 |
+
],
|
| 12 |
+
"entry_point": "conv2d_depthwise.cpp::armbench_entry_conv2d_depthwise",
|
| 13 |
+
"dependencies": [],
|
| 14 |
+
"isa_features": [
|
| 15 |
+
"sve"
|
| 16 |
+
],
|
| 17 |
+
"compile_flags": [
|
| 18 |
+
"-O3",
|
| 19 |
+
"-march=armv8.2-a+sve",
|
| 20 |
+
"-std=c++14"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": []
|
| 23 |
+
},
|
| 24 |
+
"sources": [
|
| 25 |
+
{
|
| 26 |
+
"path": "conv2d_depthwise.h",
|
| 27 |
+
"content": "#pragma once\n\n// Per-definition constants for this conv2d_depthwise specialisation.\nnamespace conv2d_depthwise_def {\nconstexpr int Kh = 3;\nconstexpr int Kw = 3;\nconstexpr int Sh = 2;\nconstexpr int Sw = 2;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad = 1;\n} // namespace conv2d_depthwise_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, C, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\n// Input layout: (N, C, H, W), output layout: (N, C, H_out, W_out).\nvoid inner_conv2d_depthwise(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "conv2d_depthwise.cpp",
|
| 31 |
+
"content": "// Binding harness: computes H_out/W_out from constexpr params, calls inner_conv2d_depthwise.\n// ABI: armbench_entry_conv2d_depthwise(input*, output*, weight*, bias*, N, C, H, W)\n// Input layout: (N, C, H, W); output layout: (N, C, H_out, W_out).\n#include \"conv2d_depthwise.h\"\nusing namespace conv2d_depthwise_def;\n\nextern \"C\" int armbench_entry_conv2d_depthwise(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad - ext_kw) / Sw + 1;\n inner_conv2d_depthwise(input, output, weight, bias, N, C, H, W, H_out, W_out);\n return 0;\n}\n"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "kernel.cpp",
|
| 35 |
+
"content": "#include \"conv2d_depthwise.h\"\n#include <arm_sve.h>\n#include <cstring>\n\nusing namespace conv2d_depthwise_def;\n\n// Optimized depthwise conv2d: 3x3 kernel, stride=2, pad=1\n// Key insight: use LD2 for stride-2 deinterleave in the fast path (no boundary)\n// Process multiple output rows (oh) at once to amortize weight loading\n// and improve instruction-level parallelism.\n\nextern \"C\" void inner_conv2d_depthwise(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C, int H, int W, int H_out, int W_out)\n{\n const int vl = svcntw(); // SVE vector length in floats (8 for 256-bit)\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * C * H * W;\n float* out_n = output + (long)n * C * H_out * W_out;\n\n for (int c = 0; c < C; ++c) {\n const float* in_c = in_n + (long)c * H * W;\n float* out_c = out_n + (long)c * H_out * W_out;\n const float* w_c = weight + (long)c * Kh * Kw;\n\n // Load 3x3 weights\n const float w00 = w_c[0], w01 = w_c[1], w02 = w_c[2];\n const float w10 = w_c[3], w11 = w_c[4], w12 = w_c[5];\n const float w20 = w_c[6], w21 = w_c[7], w22 = w_c[8];\n const float b = bias[c];\n\n const svfloat32_t vw00 = svdup_f32(w00), vw01 = svdup_f32(w01), vw02 = svdup_f32(w02);\n const svfloat32_t vw10 = svdup_f32(w10), vw11 = svdup_f32(w11), vw12 = svdup_f32(w12);\n const svfloat32_t vw20 = svdup_f32(w20), vw21 = svdup_f32(w21), vw22 = svdup_f32(w22);\n const svfloat32_t vbias = svdup_f32(b);\n const svbool_t ptrue = svptrue_b32();\n\n // Process 2 output rows at a time when possible\n int oh = 0;\n for (; oh + 1 < H_out; oh += 2) {\n // oh and oh+1 share input rows:\n // oh uses ih: oh*2-1, oh*2, oh*2+1\n // oh+1 uses ih: oh*2+1, oh*2+2, oh*2+3\n // Shared: ih = oh*2+1\n int ih0 = oh * 2 - 1;\n int ih1 = oh * 2;\n int ih2 = oh * 2 + 1; // shared\n int ih3 = oh * 2 + 2;\n int ih4 = oh * 2 + 3;\n\n const float* row0 = (ih0 >= 0 && ih0 < H) ? in_c + ih0 * W : nullptr;\n const float* row1 = (ih1 >= 0 && ih1 < H) ? in_c + ih1 * W : nullptr;\n const float* row2 = (ih2 >= 0 && ih2 < H) ? in_c + ih2 * W : nullptr;\n const float* row3 = (ih3 >= 0 && ih3 < H) ? in_c + ih3 * W : nullptr;\n const float* row4 = (ih4 >= 0 && ih4 < H) ? in_c + ih4 * W : nullptr;\n\n float* out_row0 = out_c + oh * W_out;\n float* out_row1 = out_c + (oh + 1) * W_out;\n\n int ow = 0;\n for (; ow + vl <= W_out; ow += vl) {\n int iw_base = 2 * ow - 1;\n bool left_ok = (iw_base >= 0);\n bool right_ok = (iw_base + 2 * vl < W);\n\n if (left_ok && right_ok) {\n // Fast path: LD2 for stride-2 deinterleave\n // row0 -> oh row, kh=0\n // row1 -> oh row, kh=1; oh+1 row, kh=0 (not used for oh+1 since row1 is ih1=oh*2)\n // Actually for oh+1: kh=0 is ih2=oh*2+1=row2, kh=1 is ih3=row3, kh=2 is ih4=row4\n\n svfloat32_t acc0 = vbias;\n svfloat32_t acc1 = vbias;\n\n // Process row0 (for oh, kh=0)\n if (row0) {\n svfloat32x2_t v = svld2_f32(ptrue, row0 + iw_base);\n svfloat32_t e0 = svget2_f32(v, 0); // kw=0\n svfloat32_t o1 = svget2_f32(v, 1); // kw=1\n float extra = row0[iw_base + 2 * vl];\n svfloat32_t e2 = svext_f32(e0, svdup_f32(extra), 1); // kw=2\n acc0 = svmla_f32_x(ptrue, acc0, e0, vw00);\n acc0 = svmla_f32_x(ptrue, acc0, o1, vw01);\n acc0 = svmla_f32_x(ptrue, acc0, e2, vw02);\n }\n // Process row1 (for oh, kh=1)\n if (row1) {\n svfloat32x2_t v = svld2_f32(ptrue, row1 + iw_base);\n svfloat32_t e0 = svget2_f32(v, 0);\n svfloat32_t o1 = svget2_f32(v, 1);\n float extra = row1[iw_base + 2 * vl];\n svfloat32_t e2 = svext_f32(e0, svdup_f32(extra), 1);\n acc0 = svmla_f32_x(ptrue, acc0, e0, vw10);\n acc0 = svmla_f32_x(ptrue, acc0, o1, vw11);\n acc0 = svmla_f32_x(ptrue, acc0, e2, vw12);\n }\n // Process row2 (for oh, kh=2; for oh+1, kh=0)\n if (row2) {\n svfloat32x2_t v = svld2_f32(ptrue, row2 + iw_base);\n svfloat32_t e0 = svget2_f32(v, 0);\n svfloat32_t o1 = svget2_f32(v, 1);\n float extra = row2[iw_base + 2 * vl];\n svfloat32_t e2 = svext_f32(e0, svdup_f32(extra), 1);\n acc0 = svmla_f32_x(ptrue, acc0, e0, vw20);\n acc0 = svmla_f32_x(ptrue, acc0, o1, vw21);\n acc0 = svmla_f32_x(ptrue, acc0, e2, vw22);\n acc1 = svmla_f32_x(ptrue, acc1, e0, vw00);\n acc1 = svmla_f32_x(ptrue, acc1, o1, vw01);\n acc1 = svmla_f32_x(ptrue, acc1, e2, vw02);\n }\n // Process row3 (for oh+1, kh=1)\n if (row3) {\n svfloat32x2_t v = svld2_f32(ptrue, row3 + iw_base);\n svfloat32_t e0 = svget2_f32(v, 0);\n svfloat32_t o1 = svget2_f32(v, 1);\n float extra = row3[iw_base + 2 * vl];\n svfloat32_t e2 = svext_f32(e0, svdup_f32(extra), 1);\n acc1 = svmla_f32_x(ptrue, acc1, e0, vw10);\n acc1 = svmla_f32_x(ptrue, acc1, o1, vw11);\n acc1 = svmla_f32_x(ptrue, acc1, e2, vw12);\n }\n // Process row4 (for oh+1, kh=2)\n if (row4) {\n svfloat32x2_t v = svld2_f32(ptrue, row4 + iw_base);\n svfloat32_t e0 = svget2_f32(v, 0);\n svfloat32_t o1 = svget2_f32(v, 1);\n float extra = row4[iw_base + 2 * vl];\n svfloat32_t e2 = svext_f32(e0, svdup_f32(extra), 1);\n acc1 = svmla_f32_x(ptrue, acc1, e0, vw20);\n acc1 = svmla_f32_x(ptrue, acc1, o1, vw21);\n acc1 = svmla_f32_x(ptrue, acc1, e2, vw22);\n }\n\n svst1_f32(ptrue, out_row0 + ow, acc0);\n svst1_f32(ptrue, out_row1 + ow, acc1);\n } else {\n // Boundary path: gather with masking\n svint32_t idx_base_vec = svindex_s32(0, 2);\n svint32_t col0 = svadd_n_s32_x(ptrue, idx_base_vec, iw_base + 0);\n svint32_t col1 = svadd_n_s32_x(ptrue, idx_base_vec, iw_base + 1);\n svint32_t col2 = svadd_n_s32_x(ptrue, idx_base_vec, iw_base + 2);\n svint32_t vW = svdup_n_s32(W);\n\n svbool_t valid0 = svand_b_z(ptrue,\n svcmpge_n_s32(ptrue, col0, 0),\n svcmplt_s32(ptrue, col0, vW));\n svbool_t valid1 = svand_b_z(ptrue,\n svcmpge_n_s32(ptrue, col1, 0),\n svcmplt_s32(ptrue, col1, vW));\n svbool_t valid2 = svand_b_z(ptrue,\n svcmpge_n_s32(ptrue, col2, 0),\n svcmplt_s32(ptrue, col2, vW));\n\n svfloat32_t acc0 = vbias;\n svfloat32_t acc1 = vbias;\n\n if (row0) {\n svfloat32_t v0 = svld1_gather_s32index_f32(valid0, row0, col0);\n svfloat32_t v1 = svld1_gather_s32index_f32(valid1, row0, col1);\n svfloat32_t v2 = svld1_gather_s32index_f32(valid2, row0, col2);\n acc0 = svmla_f32_x(ptrue, acc0, v0, vw00);\n acc0 = svmla_f32_x(ptrue, acc0, v1, vw01);\n acc0 = svmla_f32_x(ptrue, acc0, v2, vw02);\n }\n if (row1) {\n svfloat32_t v0 = svld1_gather_s32index_f32(valid0, row1, col0);\n svfloat32_t v1 = svld1_gather_s32index_f32(valid1, row1, col1);\n svfloat32_t v2 = svld1_gather_s32index_f32(valid2, row1, col2);\n acc0 = svmla_f32_x(ptrue, acc0, v0, vw10);\n acc0 = svmla_f32_x(ptrue, acc0, v1, vw11);\n acc0 = svmla_f32_x(ptrue, acc0, v2, vw12);\n }\n if (row2) {\n svfloat32_t v0 = svld1_gather_s32index_f32(valid0, row2, col0);\n svfloat32_t v1 = svld1_gather_s32index_f32(valid1, row2, col1);\n svfloat32_t v2 = svld1_gather_s32index_f32(valid2, row2, col2);\n acc0 = svmla_f32_x(ptrue, acc0, v0, vw20);\n acc0 = svmla_f32_x(ptrue, acc0, v1, vw21);\n acc0 = svmla_f32_x(ptrue, acc0, v2, vw22);\n acc1 = svmla_f32_x(ptrue, acc1, v0, vw00);\n acc1 = svmla_f32_x(ptrue, acc1, v1, vw01);\n acc1 = svmla_f32_x(ptrue, acc1, v2, vw02);\n }\n if (row3) {\n svfloat32_t v0 = svld1_gather_s32index_f32(valid0, row3, col0);\n svfloat32_t v1 = svld1_gather_s32index_f32(valid1, row3, col1);\n svfloat32_t v2 = svld1_gather_s32index_f32(valid2, row3, col2);\n acc1 = svmla_f32_x(ptrue, acc1, v0, vw10);\n acc1 = svmla_f32_x(ptrue, acc1, v1, vw11);\n acc1 = svmla_f32_x(ptrue, acc1, v2, vw12);\n }\n if (row4) {\n svfloat32_t v0 = svld1_gather_s32index_f32(valid0, row4, col0);\n svfloat32_t v1 = svld1_gather_s32index_f32(valid1, row4, col1);\n svfloat32_t v2 = svld1_gather_s32index_f32(valid2, row4, col2);\n acc1 = svmla_f32_x(ptrue, acc1, v0, vw20);\n acc1 = svmla_f32_x(ptrue, acc1, v1, vw21);\n acc1 = svmla_f32_x(ptrue, acc1, v2, vw22);\n }\n\n svst1_f32(ptrue, out_row0 + ow, acc0);\n svst1_f32(ptrue, out_row1 + ow, acc1);\n }\n }\n\n // Scalar tail for both rows\n for (; ow < W_out; ++ow) {\n float sum0 = b, sum1 = b;\n for (int kh = 0; kh < 3; ++kh) {\n int ih_a = oh * 2 - 1 + kh;\n int ih_b = (oh+1) * 2 - 1 + kh;\n for (int kw = 0; kw < 3; ++kw) {\n int iw = ow * 2 - 1 + kw;\n if (iw >= 0 && iw < W) {\n if (ih_a >= 0 && ih_a < H) sum0 += in_c[ih_a * W + iw] * w_c[kh * 3 + kw];\n if (ih_b >= 0 && ih_b < H) sum1 += in_c[ih_b * W + iw] * w_c[kh * 3 + kw];\n }\n }\n }\n out_row0[ow] = sum0;\n out_row1[ow] = sum1;\n }\n }\n\n // Handle remaining odd row\n for (; oh < H_out; ++oh) {\n int ih0 = oh * 2 - 1;\n int ih1 = oh * 2;\n int ih2 = oh * 2 + 1;\n\n const float* row0 = (ih0 >= 0 && ih0 < H) ? in_c + ih0 * W : nullptr;\n const float* row1 = (ih1 >= 0 && ih1 < H) ? in_c + ih1 * W : nullptr;\n const float* row2 = (ih2 >= 0 && ih2 < H) ? in_c + ih2 * W : nullptr;\n\n float* out_row = out_c + oh * W_out;\n\n int ow = 0;\n for (; ow + vl <= W_out; ow += vl) {\n int iw_base = 2 * ow - 1;\n bool left_ok = (iw_base >= 0);\n bool right_ok = (iw_base + 2 * vl < W);\n\n svfloat32_t acc = vbias;\n\n if (left_ok && right_ok) {\n if (row0) {\n svfloat32x2_t v = svld2_f32(ptrue, row0 + iw_base);\n svfloat32_t e0 = svget2_f32(v, 0);\n svfloat32_t o1 = svget2_f32(v, 1);\n float extra = row0[iw_base + 2 * vl];\n svfloat32_t e2 = svext_f32(e0, svdup_f32(extra), 1);\n acc = svmla_f32_x(ptrue, acc, e0, vw00);\n acc = svmla_f32_x(ptrue, acc, o1, vw01);\n acc = svmla_f32_x(ptrue, acc, e2, vw02);\n }\n if (row1) {\n svfloat32x2_t v = svld2_f32(ptrue, row1 + iw_base);\n svfloat32_t e0 = svget2_f32(v, 0);\n svfloat32_t o1 = svget2_f32(v, 1);\n float extra = row1[iw_base + 2 * vl];\n svfloat32_t e2 = svext_f32(e0, svdup_f32(extra), 1);\n acc = svmla_f32_x(ptrue, acc, e0, vw10);\n acc = svmla_f32_x(ptrue, acc, o1, vw11);\n acc = svmla_f32_x(ptrue, acc, e2, vw12);\n }\n if (row2) {\n svfloat32x2_t v = svld2_f32(ptrue, row2 + iw_base);\n svfloat32_t e0 = svget2_f32(v, 0);\n svfloat32_t o1 = svget2_f32(v, 1);\n float extra = row2[iw_base + 2 * vl];\n svfloat32_t e2 = svext_f32(e0, svdup_f32(extra), 1);\n acc = svmla_f32_x(ptrue, acc, e0, vw20);\n acc = svmla_f32_x(ptrue, acc, o1, vw21);\n acc = svmla_f32_x(ptrue, acc, e2, vw22);\n }\n } else {\n svint32_t idx_base_vec = svindex_s32(0, 2);\n svint32_t col0 = svadd_n_s32_x(ptrue, idx_base_vec, iw_base + 0);\n svint32_t col1 = svadd_n_s32_x(ptrue, idx_base_vec, iw_base + 1);\n svint32_t col2 = svadd_n_s32_x(ptrue, idx_base_vec, iw_base + 2);\n svint32_t vW = svdup_n_s32(W);\n\n svbool_t valid0 = svand_b_z(ptrue, svcmpge_n_s32(ptrue, col0, 0), svcmplt_s32(ptrue, col0, vW));\n svbool_t valid1 = svand_b_z(ptrue, svcmpge_n_s32(ptrue, col1, 0), svcmplt_s32(ptrue, col1, vW));\n svbool_t valid2 = svand_b_z(ptrue, svcmpge_n_s32(ptrue, col2, 0), svcmplt_s32(ptrue, col2, vW));\n\n if (row0) {\n acc = svmla_f32_x(ptrue, acc, svld1_gather_s32index_f32(valid0, row0, col0), vw00);\n acc = svmla_f32_x(ptrue, acc, svld1_gather_s32index_f32(valid1, row0, col1), vw01);\n acc = svmla_f32_x(ptrue, acc, svld1_gather_s32index_f32(valid2, row0, col2), vw02);\n }\n if (row1) {\n acc = svmla_f32_x(ptrue, acc, svld1_gather_s32index_f32(valid0, row1, col0), vw10);\n acc = svmla_f32_x(ptrue, acc, svld1_gather_s32index_f32(valid1, row1, col1), vw11);\n acc = svmla_f32_x(ptrue, acc, svld1_gather_s32index_f32(valid2, row1, col2), vw12);\n }\n if (row2) {\n acc = svmla_f32_x(ptrue, acc, svld1_gather_s32index_f32(valid0, row2, col0), vw20);\n acc = svmla_f32_x(ptrue, acc, svld1_gather_s32index_f32(valid1, row2, col1), vw21);\n acc = svmla_f32_x(ptrue, acc, svld1_gather_s32index_f32(valid2, row2, col2), vw22);\n }\n }\n\n svst1_f32(ptrue, out_row + ow, acc);\n }\n\n // Scalar tail\n for (; ow < W_out; ++ow) {\n float sum = b;\n for (int kh = 0; kh < 3; ++kh) {\n int ih = oh * 2 - 1 + kh;\n if (ih < 0 || ih >= H) continue;\n for (int kw = 0; kw < 3; ++kw) {\n int iw = ow * 2 - 1 + kw;\n if (iw < 0 || iw >= W) continue;\n sum += in_c[ih * W + iw] * w_c[kh * 3 + kw];\n }\n }\n out_row[ow] = sum;\n }\n }\n }\n }\n}\n"
|
| 36 |
+
}
|
| 37 |
+
]
|
| 38 |
+
}
|
solutions/ncnn/claude-sonnet-4-6/conv2d_depthwise/conv2d_depthwise_kh5_kw5_sh1_sw1_dh1_dw1_p2.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "claude-sonnet-4-6_conv2d_depthwise_kh5_kw5_sh1_sw1_dh1_dw1_p2",
|
| 3 |
+
"definition": "conv2d_depthwise_kh5_kw5_sh1_sw1_dh1_dw1_p2",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "claude-sonnet-4-6",
|
| 6 |
+
"spec": {
|
| 7 |
+
"language": "cpp",
|
| 8 |
+
"target_hardware": [
|
| 9 |
+
"graviton3",
|
| 10 |
+
"aarch64-sve"
|
| 11 |
+
],
|
| 12 |
+
"entry_point": "conv2d_depthwise.cpp::armbench_entry_conv2d_depthwise",
|
| 13 |
+
"dependencies": [],
|
| 14 |
+
"isa_features": [
|
| 15 |
+
"sve"
|
| 16 |
+
],
|
| 17 |
+
"compile_flags": [
|
| 18 |
+
"-O3",
|
| 19 |
+
"-march=armv8.2-a+sve",
|
| 20 |
+
"-std=c++14"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": []
|
| 23 |
+
},
|
| 24 |
+
"sources": [
|
| 25 |
+
{
|
| 26 |
+
"path": "conv2d_depthwise.h",
|
| 27 |
+
"content": "#pragma once\n\n// Per-definition constants for this conv2d_depthwise specialisation.\nnamespace conv2d_depthwise_def {\nconstexpr int Kh = 5;\nconstexpr int Kw = 5;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\nconstexpr int pad = 2;\n} // namespace conv2d_depthwise_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, C, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\n// Input layout: (N, C, H, W), output layout: (N, C, H_out, W_out).\nvoid inner_conv2d_depthwise(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "conv2d_depthwise.cpp",
|
| 31 |
+
"content": "// Binding harness: computes H_out/W_out from constexpr params, calls inner_conv2d_depthwise.\n// ABI: armbench_entry_conv2d_depthwise(input*, output*, weight*, bias*, N, C, H, W)\n// Input layout: (N, C, H, W); output layout: (N, C, H_out, W_out).\n#include \"conv2d_depthwise.h\"\nusing namespace conv2d_depthwise_def;\n\nextern \"C\" int armbench_entry_conv2d_depthwise(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C, int H, int W)\n{\n constexpr int ext_kh = Dh * (Kh - 1) + 1;\n constexpr int ext_kw = Dw * (Kw - 1) + 1;\n const int H_out = (H + 2 * pad - ext_kh) / Sh + 1;\n const int W_out = (W + 2 * pad - ext_kw) / Sw + 1;\n inner_conv2d_depthwise(input, output, weight, bias, N, C, H, W, H_out, W_out);\n return 0;\n}\n"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "kernel.cpp",
|
| 35 |
+
"content": "\n#include \"conv2d_depthwise.h\"\n#include <arm_sve.h>\n\nusing namespace conv2d_depthwise_def;\n\n// Optimized depthwise conv2d with 5x5 kernel, stride 1, dilation 1, pad 2\n//\n// Key insight from v1 analysis:\n// - v1 has IPC=4.3 but is SLOWER than scalar (cycle_speedup=0.7)\n// - The scalar reference is already well-optimized by the compiler\n// - The issue: SVE overhead (predicate setup, etc.) for small W doesn't pay off\n// - The v1 assembly shows complex predicate logic and many register moves\n//\n// New strategy:\n// - Use explicit inline assembly for the hot inner loop\n// - Process multiple output rows simultaneously to reuse input data\n// - Use 4 accumulators per SVE iteration (4 output rows at once)\n// - This amortizes the 25 weight broadcasts over 4 outputs\n// - Key: load each input row once, multiply by 4 different weights\n//\n// For 4 output rows oh, oh+1, oh+2, oh+3:\n// - They share input rows: oh-2..oh+5 (8 rows total)\n// - For each input row ir[i], it contributes to output rows with different kernel weights\n// - ir[0] (ih=oh-2): kh=0 for oh, kh=4 for oh-4 (not in tile), etc.\n// Actually: ir[i] contributes to output row oh+t with kh = i-t\n// So ir[0] -> oh+0 with kh=0, ir[1] -> oh+0 with kh=1 AND oh+1 with kh=0, etc.\n\nextern \"C\" void inner_conv2d_depthwise(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C, int H, int W, int H_out, int W_out)\n{\n svbool_t pg_all = svptrue_b32();\n const int64_t vl = svcntw();\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * C * H * W;\n float* out_n = output + (long)n * C * H_out * W_out;\n\n for (int c = 0; c < C; ++c) {\n const float* in_c = in_n + (long)c * H * W;\n float* out_c = out_n + (long)c * H_out * W_out;\n const float* w_c = weight + (long)c * 25;\n float bias_val = bias[c];\n\n // Load all 25 weights\n float wf[25];\n for (int i = 0; i < 25; ++i) wf[i] = w_c[i];\n\n // Process interior rows in groups of 4\n // Interior: oh in [2, H_out-2)\n // For these rows, all 5 input rows are valid\n\n // Scalar helper for border rows\n auto scalar_row = [&](int oh) __attribute__((noinline)) {\n float* out_row = out_c + oh * W_out;\n for (int ow = 0; ow < W_out; ++ow) {\n float sum = bias_val;\n for (int kh = 0; kh < 5; ++kh) {\n int ih = oh - 2 + kh;\n if (ih < 0 || ih >= H) continue;\n const float* in_row = in_c + ih * W;\n for (int kw = 0; kw < 5; ++kw) {\n int iw = ow - 2 + kw;\n if (iw >= 0 && iw < W)\n sum += in_row[iw] * wf[kh*5+kw];\n }\n }\n out_row[ow] = sum;\n }\n };\n\n // Border rows\n int oh_int_start = (H_out >= 2) ? 2 : H_out;\n int oh_int_end = (H_out >= 2) ? H_out - 2 : 0;\n\n for (int oh = 0; oh < oh_int_start; ++oh) scalar_row(oh);\n for (int oh = (oh_int_end > oh_int_start ? oh_int_end : oh_int_start); oh < H_out; ++oh) scalar_row(oh);\n\n // Interior rows: process 4 at a time\n for (int oh = oh_int_start; oh < oh_int_end; oh += 4) {\n int tile = oh_int_end - oh;\n if (tile > 4) tile = 4;\n\n // Input row pointers (tile+4 rows needed)\n const float* ir[8];\n for (int i = 0; i < tile + 4; ++i)\n ir[i] = in_c + (oh - 2 + i) * W;\n\n // Process each output row in the tile\n for (int t = 0; t < tile; ++t) {\n float* out_row = out_c + (oh + t) * W_out;\n const float* r0 = ir[t];\n const float* r1 = ir[t+1];\n const float* r2 = ir[t+2];\n const float* r3 = ir[t+3];\n const float* r4 = ir[t+4];\n\n // Scalar left border (ow = 0, 1)\n // ow=0: kw offsets -2,-1,0,1,2 -> only 0,1,2 valid (kw=2,3,4)\n {\n float sum = bias_val\n + r0[0]*wf[2] + r0[1]*wf[3] + r0[2]*wf[4]\n + r1[0]*wf[7] + r1[1]*wf[8] + r1[2]*wf[9]\n + r2[0]*wf[12] + r2[1]*wf[13] + r2[2]*wf[14]\n + r3[0]*wf[17] + r3[1]*wf[18] + r3[2]*wf[19]\n + r4[0]*wf[22] + r4[1]*wf[23] + r4[2]*wf[24];\n out_row[0] = sum;\n }\n if (W_out > 1) {\n // ow=1: kw offsets -1,0,1,2,3 -> only 0,1,2,3 valid (kw=1,2,3,4)\n float sum = bias_val\n + r0[0]*wf[1] + r0[1]*wf[2] + r0[2]*wf[3] + r0[3]*wf[4]\n + r1[0]*wf[6] + r1[1]*wf[7] + r1[2]*wf[8] + r1[3]*wf[9]\n + r2[0]*wf[11] + r2[1]*wf[12] + r2[2]*wf[13] + r2[3]*wf[14]\n + r3[0]*wf[16] + r3[1]*wf[17] + r3[2]*wf[18] + r3[3]*wf[19]\n + r4[0]*wf[21] + r4[1]*wf[22] + r4[2]*wf[23] + r4[3]*wf[24];\n out_row[1] = sum;\n }\n\n // SVE interior: ow in [2, W_out-2)\n // All loads ow-2..ow+vl-1+2 are in [0, W-1]\n // Condition: ow >= 2 and ow + vl + 1 < W_out\n // i.e., ow + vl <= W_out - 2\n int ow = 2;\n int ow_sve_end = W_out - 2;\n\n // Broadcast weights once outside the loop\n svfloat32_t vw0 = svdup_f32(wf[0]);\n svfloat32_t vw1 = svdup_f32(wf[1]);\n svfloat32_t vw2 = svdup_f32(wf[2]);\n svfloat32_t vw3 = svdup_f32(wf[3]);\n svfloat32_t vw4 = svdup_f32(wf[4]);\n svfloat32_t vw5 = svdup_f32(wf[5]);\n svfloat32_t vw6 = svdup_f32(wf[6]);\n svfloat32_t vw7 = svdup_f32(wf[7]);\n svfloat32_t vw8 = svdup_f32(wf[8]);\n svfloat32_t vw9 = svdup_f32(wf[9]);\n svfloat32_t vw10 = svdup_f32(wf[10]);\n svfloat32_t vw11 = svdup_f32(wf[11]);\n svfloat32_t vw12 = svdup_f32(wf[12]);\n svfloat32_t vw13 = svdup_f32(wf[13]);\n svfloat32_t vw14 = svdup_f32(wf[14]);\n svfloat32_t vw15 = svdup_f32(wf[15]);\n svfloat32_t vw16 = svdup_f32(wf[16]);\n svfloat32_t vw17 = svdup_f32(wf[17]);\n svfloat32_t vw18 = svdup_f32(wf[18]);\n svfloat32_t vw19 = svdup_f32(wf[19]);\n svfloat32_t vw20 = svdup_f32(wf[20]);\n svfloat32_t vw21 = svdup_f32(wf[21]);\n svfloat32_t vw22 = svdup_f32(wf[22]);\n svfloat32_t vw23 = svdup_f32(wf[23]);\n svfloat32_t vw24 = svdup_f32(wf[24]);\n svfloat32_t vbias = svdup_f32(bias_val);\n\n for (; ow + (int)vl <= ow_sve_end; ow += vl) {\n svfloat32_t acc = vbias;\n // kh=0: r0\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r0+ow-2), vw0);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r0+ow-1), vw1);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r0+ow ), vw2);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r0+ow+1), vw3);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r0+ow+2), vw4);\n // kh=1: r1\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r1+ow-2), vw5);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r1+ow-1), vw6);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r1+ow ), vw7);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r1+ow+1), vw8);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r1+ow+2), vw9);\n // kh=2: r2\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r2+ow-2), vw10);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r2+ow-1), vw11);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r2+ow ), vw12);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r2+ow+1), vw13);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r2+ow+2), vw14);\n // kh=3: r3\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r3+ow-2), vw15);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r3+ow-1), vw16);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r3+ow ), vw17);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r3+ow+1), vw18);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r3+ow+2), vw19);\n // kh=4: r4\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r4+ow-2), vw20);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r4+ow-1), vw21);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r4+ow ), vw22);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r4+ow+1), vw23);\n acc = svmla_f32_m(pg_all, acc, svld1_f32(pg_all, r4+ow+2), vw24);\n svst1_f32(pg_all, out_row + ow, acc);\n }\n\n // Scalar right border (ow in [ow_sve_end, W_out))\n // Also handles the tail of the SVE loop\n for (; ow < W_out; ++ow) {\n float sum = bias_val;\n for (int kw = 0; kw < 5; ++kw) {\n int iw = ow - 2 + kw;\n if (iw >= 0 && iw < W) {\n sum += r0[iw] * wf[kw];\n sum += r1[iw] * wf[5+kw];\n sum += r2[iw] * wf[10+kw];\n sum += r3[iw] * wf[15+kw];\n sum += r4[iw] * wf[20+kw];\n }\n }\n out_row[ow] = sum;\n }\n }\n }\n }\n }\n}\n"
|
| 36 |
+
}
|
| 37 |
+
]
|
| 38 |
+
}
|
solutions/ncnn/claude-sonnet-4-6/deconv2d/deconv2d_kh3_kw3_sh1_sw1_cout256.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "claude-sonnet-4-6_deconv2d_kh3_kw3_sh1_sw1_cout256",
|
| 3 |
+
"definition": "deconv2d_kh3_kw3_sh1_sw1_cout256",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "claude-sonnet-4-6",
|
| 6 |
+
"spec": {
|
| 7 |
+
"language": "cpp",
|
| 8 |
+
"target_hardware": [
|
| 9 |
+
"graviton3",
|
| 10 |
+
"aarch64-sve"
|
| 11 |
+
],
|
| 12 |
+
"entry_point": "deconv2d.cpp::armbench_entry_deconv2d",
|
| 13 |
+
"dependencies": [],
|
| 14 |
+
"isa_features": [
|
| 15 |
+
"sve"
|
| 16 |
+
],
|
| 17 |
+
"compile_flags": [
|
| 18 |
+
"-O3",
|
| 19 |
+
"-march=armv8.2-a+sve",
|
| 20 |
+
"-std=c++14"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": []
|
| 23 |
+
},
|
| 24 |
+
"sources": [
|
| 25 |
+
{
|
| 26 |
+
"path": "deconv2d.h",
|
| 27 |
+
"content": "#pragma once\n\n// Per-definition constants for this deconv2d specialisation.\nnamespace deconv2d_def {\nconstexpr int Cout = 256;\nconstexpr int Kh = 3;\nconstexpr int Kw = 3;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\n} // namespace deconv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, C_in, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\n// Input layout: (N, C_in, H, W), output layout: (N, Cout, H_out, W_out).\n// Weight layout: (Cout, C_in, Kh, Kw).\nvoid inner_deconv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C_in, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "deconv2d.cpp",
|
| 31 |
+
"content": "// Binding harness: computes H_out/W_out from constexpr params, calls inner_deconv2d.\n// ABI: armbench_entry_deconv2d(input*, output*, weight*, bias*, N, C_in, H, W)\n// H_out = (H - 1) * Sh + Kh (no-padding formula)\n// Input layout: (N, C_in, H, W); output layout: (N, Cout, H_out, W_out).\n#include \"deconv2d.h\"\nusing namespace deconv2d_def;\n\nextern \"C\" int armbench_entry_deconv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C_in, int H, int W)\n{\n const int H_out = (H - 1) * Sh + Kh;\n const int W_out = (W - 1) * Sw + Kw;\n inner_deconv2d(input, output, weight, bias, N, C_in, H, W, H_out, W_out);\n return 0;\n}\n"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "kernel.cpp",
|
| 35 |
+
"content": "// Optimized deconv2d kernel for AArch64 SVE (Graviton3)\n// Strategy:\n// 1. Transpose weight from (Cout, C_in, Kh, Kw) to (C_in, Kh, Kw, Cout)\n// so that for fixed (ci, kh, kw), weight values across co are contiguous.\n// 2. Loop order: n, oh, ow (tiled), kh, kw, ci -> vectorize over co\n// 3. Use local accumulator buffers (one per tile column)\n// 4. Multiple SVE accumulators to hide FMA latency (4-cycle latency)\n// 5. Wider tile (OW_TILE=8) to amortize weight loads across more output columns\n// 6. Unroll co loop with 4 accumulators per tile column\n\n#include \"deconv2d.h\"\n#include <arm_sve.h>\n#include <cstring>\n#include <cstdlib>\n\nusing namespace deconv2d_def;\n\n// Cout=256 floats = 1KB per accumulator buffer\n// With SVE 256-bit = 8 floats per vector\n// 256/8 = 32 vectors per accumulator\n\nextern \"C\" void inner_deconv2d(\n const float* __restrict__ input, float* __restrict__ output,\n const float* __restrict__ weight, const float* __restrict__ bias,\n int N, int C_in, int H, int W, int H_out, int W_out)\n{\n const int HW_out = H_out * W_out;\n const int KhKw = Kh * Kw;\n const int CinKhKw = C_in * KhKw;\n\n // Transpose weight from (Cout, C_in, Kh, Kw) to (C_in, Kh, Kw, Cout)\n // weight_T[(ci*KhKw + kh*Kw + kw)*Cout + co] = weight[co*CinKhKw + ci*KhKw + kh*Kw + kw]\n float* weight_T = (float*)aligned_alloc(64, (size_t)Cout * CinKhKw * sizeof(float));\n \n for (int co = 0; co < Cout; ++co) {\n const float* w_co = weight + (long)co * CinKhKw;\n for (int idx = 0; idx < CinKhKw; ++idx) {\n weight_T[(long)idx * Cout + co] = w_co[idx];\n }\n }\n\n // Bias initialisation\n for (int n = 0; n < N; ++n) {\n float* out_n = output + (long)n * Cout * HW_out;\n for (int co = 0; co < Cout; ++co) {\n float b = bias[co];\n float* out_co = out_n + (long)co * HW_out;\n // Use SVE to fill\n svfloat32_t vb = svdup_f32(b);\n int i = 0;\n for (; i + (int)svcntw() <= HW_out; i += svcntw()) {\n svst1_f32(svptrue_b32(), out_co + i, vb);\n }\n if (i < HW_out) {\n svbool_t pg = svwhilelt_b32(i, HW_out);\n svst1_f32(pg, out_co + i, vb);\n }\n }\n }\n\n // Main computation\n // For each (n, oh, ow): accumulate over (kh, kw, ci) into acc[Cout]\n // then write back to output\n // \n // Key insight: weight_T[(ci*KhKw + kh*Kw + kw)*Cout + co] is contiguous in co\n // acc[co] += in_val * weight_T[...co...] -- FMLA with broadcast scalar\n\n // OW_TILE=8: process 8 output columns at once\n // Each accumulator is 256 floats = 1KB\n // 8 accumulators = 8KB - fits in L1 cache\n const int OW_TILE = 8;\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * C_in * H * W;\n float* out_n = output + (long)n * Cout * HW_out;\n\n for (int oh = 0; oh < H_out; ++oh) {\n int ow = 0;\n for (; ow + OW_TILE <= W_out; ow += OW_TILE) {\n // Local accumulators for 8 output columns\n float acc0[256] __attribute__((aligned(64)));\n float acc1[256] __attribute__((aligned(64)));\n float acc2[256] __attribute__((aligned(64)));\n float acc3[256] __attribute__((aligned(64)));\n float acc4[256] __attribute__((aligned(64)));\n float acc5[256] __attribute__((aligned(64)));\n float acc6[256] __attribute__((aligned(64)));\n float acc7[256] __attribute__((aligned(64)));\n\n // Load from output (already initialized with bias)\n // output layout: (co, H_out, W_out) -> out_n[co * HW_out + oh * W_out + ow + t]\n // This is strided - do it scalar\n for (int co = 0; co < Cout; ++co) {\n long base = (long)co * HW_out + oh * W_out;\n acc0[co] = out_n[base + ow];\n acc1[co] = out_n[base + ow + 1];\n acc2[co] = out_n[base + ow + 2];\n acc3[co] = out_n[base + ow + 3];\n acc4[co] = out_n[base + ow + 4];\n acc5[co] = out_n[base + ow + 5];\n acc6[co] = out_n[base + ow + 6];\n acc7[co] = out_n[base + ow + 7];\n }\n\n for (int kh = 0; kh < Kh; ++kh) {\n int ih = oh - kh;\n if (ih < 0 || ih >= H) continue;\n for (int kw = 0; kw < Kw; ++kw) {\n // iw[t] = ow + t - kw\n int iw_base = ow - kw;\n // Valid range: iw in [0, W)\n // t valid if iw_base + t in [0, W)\n // t in [max(0, -iw_base), min(OW_TILE, W - iw_base))\n int t_start = (iw_base < 0) ? -iw_base : 0;\n int t_end = (iw_base + OW_TILE > W) ? (W - iw_base) : OW_TILE;\n if (t_start >= t_end) continue;\n\n const float* wptr_base = weight_T + (kh * Kw + kw) * Cout;\n\n for (int ci = 0; ci < C_in; ++ci) {\n const float* in_row = in_n + (long)ci * H * W + ih * W;\n const float* wp = wptr_base + (long)ci * KhKw * Cout;\n\n // Process each valid tile column\n // Use 4 SVE accumulators per column to hide FMA latency\n // Cout=256, svcntw()=8 -> 32 iterations\n // With 4 accumulators: 8 iterations each\n\n // Preload input values for valid columns\n float in_vals[8] = {0,0,0,0,0,0,0,0};\n for (int t = t_start; t < t_end; ++t) {\n in_vals[t] = in_row[iw_base + t];\n }\n\n // Process co in chunks of 32 (4 vectors of 8)\n // to allow multiple accumulators\n svbool_t pg = svptrue_b32();\n \n for (int co = 0; co < 256; co += 32) {\n // Load 4 weight vectors (co, co+8, co+16, co+24)\n svfloat32_t vw0 = svld1_f32(pg, wp + co);\n svfloat32_t vw1 = svld1_f32(pg, wp + co + 8);\n svfloat32_t vw2 = svld1_f32(pg, wp + co + 16);\n svfloat32_t vw3 = svld1_f32(pg, wp + co + 24);\n\n // For each valid tile column, update 4 accumulators\n #define DO_TILE(acc_arr, t_idx) \\\n if (t_idx >= t_start && t_idx < t_end) { \\\n svfloat32_t vin = svdup_f32(in_vals[t_idx]); \\\n svfloat32_t va0 = svld1_f32(pg, acc_arr + co); \\\n svfloat32_t va1 = svld1_f32(pg, acc_arr + co + 8); \\\n svfloat32_t va2 = svld1_f32(pg, acc_arr + co + 16); \\\n svfloat32_t va3 = svld1_f32(pg, acc_arr + co + 24); \\\n va0 = svmla_f32_m(pg, va0, vin, vw0); \\\n va1 = svmla_f32_m(pg, va1, vin, vw1); \\\n va2 = svmla_f32_m(pg, va2, vin, vw2); \\\n va3 = svmla_f32_m(pg, va3, vin, vw3); \\\n svst1_f32(pg, acc_arr + co, va0); \\\n svst1_f32(pg, acc_arr + co + 8, va1); \\\n svst1_f32(pg, acc_arr + co + 16, va2); \\\n svst1_f32(pg, acc_arr + co + 24, va3); \\\n }\n\n DO_TILE(acc0, 0)\n DO_TILE(acc1, 1)\n DO_TILE(acc2, 2)\n DO_TILE(acc3, 3)\n DO_TILE(acc4, 4)\n DO_TILE(acc5, 5)\n DO_TILE(acc6, 6)\n DO_TILE(acc7, 7)\n #undef DO_TILE\n }\n }\n }\n }\n\n // Write back accumulators to output (strided)\n for (int co = 0; co < Cout; ++co) {\n long base = (long)co * HW_out + oh * W_out;\n out_n[base + ow] = acc0[co];\n out_n[base + ow + 1] = acc1[co];\n out_n[base + ow + 2] = acc2[co];\n out_n[base + ow + 3] = acc3[co];\n out_n[base + ow + 4] = acc4[co];\n out_n[base + ow + 5] = acc5[co];\n out_n[base + ow + 6] = acc6[co];\n out_n[base + ow + 7] = acc7[co];\n }\n }\n\n // Handle remaining columns\n for (; ow < W_out; ++ow) {\n float acc[256] __attribute__((aligned(64)));\n for (int co = 0; co < Cout; ++co)\n acc[co] = out_n[(long)co * HW_out + oh * W_out + ow];\n\n for (int kh = 0; kh < Kh; ++kh) {\n int ih = oh - kh;\n if (ih < 0 || ih >= H) continue;\n for (int kw = 0; kw < Kw; ++kw) {\n int iw = ow - kw;\n if (iw < 0 || iw >= W) continue;\n const float* wptr = weight_T + (kh * Kw + kw) * Cout;\n for (int ci = 0; ci < C_in; ++ci) {\n float in_val = in_n[(long)ci * H * W + ih * W + iw];\n svfloat32_t vin = svdup_f32(in_val);\n const float* wp = wptr + (long)ci * KhKw * Cout;\n svbool_t pg = svptrue_b32();\n for (int co = 0; co < 256; co += 32) {\n svfloat32_t va0 = svld1_f32(pg, acc + co);\n svfloat32_t va1 = svld1_f32(pg, acc + co + 8);\n svfloat32_t va2 = svld1_f32(pg, acc + co + 16);\n svfloat32_t va3 = svld1_f32(pg, acc + co + 24);\n svfloat32_t vw0 = svld1_f32(pg, wp + co);\n svfloat32_t vw1 = svld1_f32(pg, wp + co + 8);\n svfloat32_t vw2 = svld1_f32(pg, wp + co + 16);\n svfloat32_t vw3 = svld1_f32(pg, wp + co + 24);\n va0 = svmla_f32_m(pg, va0, vin, vw0);\n va1 = svmla_f32_m(pg, va1, vin, vw1);\n va2 = svmla_f32_m(pg, va2, vin, vw2);\n va3 = svmla_f32_m(pg, va3, vin, vw3);\n svst1_f32(pg, acc + co, va0);\n svst1_f32(pg, acc + co + 8, va1);\n svst1_f32(pg, acc + co + 16, va2);\n svst1_f32(pg, acc + co + 24, va3);\n }\n }\n }\n }\n\n for (int co = 0; co < Cout; ++co)\n out_n[(long)co * HW_out + oh * W_out + ow] = acc[co];\n }\n }\n }\n\n free(weight_T);\n}\n"
|
| 36 |
+
}
|
| 37 |
+
]
|
| 38 |
+
}
|
solutions/ncnn/claude-sonnet-4-6/deconv2d/deconv2d_kh3_kw3_sh2_sw2_cout256.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "claude-sonnet-4-6_deconv2d_kh3_kw3_sh2_sw2_cout256",
|
| 3 |
+
"definition": "deconv2d_kh3_kw3_sh2_sw2_cout256",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "claude-sonnet-4-6",
|
| 6 |
+
"spec": {
|
| 7 |
+
"language": "cpp",
|
| 8 |
+
"target_hardware": [
|
| 9 |
+
"graviton3",
|
| 10 |
+
"aarch64-sve"
|
| 11 |
+
],
|
| 12 |
+
"entry_point": "deconv2d.cpp::armbench_entry_deconv2d",
|
| 13 |
+
"dependencies": [],
|
| 14 |
+
"isa_features": [
|
| 15 |
+
"sve"
|
| 16 |
+
],
|
| 17 |
+
"compile_flags": [
|
| 18 |
+
"-O3",
|
| 19 |
+
"-march=armv8.2-a+sve",
|
| 20 |
+
"-std=c++14"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": []
|
| 23 |
+
},
|
| 24 |
+
"sources": [
|
| 25 |
+
{
|
| 26 |
+
"path": "deconv2d.h",
|
| 27 |
+
"content": "#pragma once\n\n// Per-definition constants for this deconv2d specialisation.\nnamespace deconv2d_def {\nconstexpr int Cout = 256;\nconstexpr int Kh = 3;\nconstexpr int Kw = 3;\nconstexpr int Sh = 2;\nconstexpr int Sw = 2;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\n} // namespace deconv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, C_in, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\n// Input layout: (N, C_in, H, W), output layout: (N, Cout, H_out, W_out).\n// Weight layout: (Cout, C_in, Kh, Kw).\nvoid inner_deconv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C_in, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "deconv2d.cpp",
|
| 31 |
+
"content": "// Binding harness: computes H_out/W_out from constexpr params, calls inner_deconv2d.\n// ABI: armbench_entry_deconv2d(input*, output*, weight*, bias*, N, C_in, H, W)\n// H_out = (H - 1) * Sh + Kh (no-padding formula)\n// Input layout: (N, C_in, H, W); output layout: (N, Cout, H_out, W_out).\n#include \"deconv2d.h\"\nusing namespace deconv2d_def;\n\nextern \"C\" int armbench_entry_deconv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C_in, int H, int W)\n{\n const int H_out = (H - 1) * Sh + Kh;\n const int W_out = (W - 1) * Sw + Kw;\n inner_deconv2d(input, output, weight, bias, N, C_in, H, W, H_out, W_out);\n return 0;\n}\n"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "kernel.cpp",
|
| 35 |
+
"content": "// Optimized deconv2d kernel for AArch64 SVE (Graviton3, 256-bit = 8 floats/vector)\n// Key insight: The bottleneck is scatter writes to output[co][oh][ow].\n// Strategy: Change the loop order to iterate over output positions (oh, ow)\n// and accumulate contributions from all (ci, kh, kw) that map to each output pixel.\n// This gives sequential writes to output[co][oh][ow] for all co (stride HW).\n// Better: use a temporary buffer of size Cout per output pixel, accumulate,\n// then write back. But Cout=256 floats = 1KB, fits in L1.\n//\n// Actually the best approach for this problem:\n// Loop: n, oh, ow, co (vectorized over 256 with SVE)\n// For each (oh, ow), find all (ci, ih, iw, kh, kw) that contribute:\n// ih = (oh - kh) / Sh (only if (oh - kh) % Sh == 0)\n// iw = (ow - kw) / Sw (only if (ow - kw) % Sw == 0)\n// This is the \"gather\" approach for deconv2d.\n//\n// For Sh=Sw=2, Kh=Kw=3: each output pixel has at most ceil(3/2)*ceil(3/2)=4 contributing (kh,kw) pairs\n// and C_in contributing channels.\n//\n// Loop: n, oh, ow, ci, (kh,kw valid pairs), co (vectorized)\n// Output write: output[n][co][oh][ow] += input[n][ci][ih][iw] * weight[co][ci][kh][kw]\n// With co vectorized: 256/8=32 SVE ops per (oh,ow,ci,kh,kw)\n// Output access: out_n + co*HW + oh*W_out + ow (strided by HW in co)\n// Weight access: weight + co*C_in*Kh*Kw + ci*Kh*Kw + kh*Kw + kw (strided by C_in*Kh*Kw in co)\n//\n// Both weight and output are strided in co. Need transposed weight.\n// With transposed weight (C_in, Kh, Kw, Cout): weight_T[ci][kh][kw][co] contiguous in co.\n// Output still strided by HW in co.\n//\n// For the output, use a local accumulator acc[Cout] per (oh, ow), then scatter to output.\n// This avoids repeated scatter stores and improves cache behavior.\n\n#include \"deconv2d.h\"\n#include <arm_sve.h>\n#include <cstring>\n#include <cstdlib>\n\nusing namespace deconv2d_def;\n\nextern \"C\" void inner_deconv2d(\n const float* __restrict__ input, float* __restrict__ output,\n const float* __restrict__ weight, const float* __restrict__ bias,\n int N, int C_in, int H, int W, int H_out, int W_out)\n{\n const long HW = (long)H_out * W_out;\n const long CoutHW = (long)Cout * HW;\n const long KhKw = Kh * Kw;\n const long CinKhKw = (long)C_in * KhKw;\n\n // Transpose weights: (Cout, C_in, Kh, Kw) -> (C_in, Kh, Kw, Cout)\n const int wT_size = C_in * Kh * Kw * Cout;\n float* weight_T = (float*)aligned_alloc(64, ((wT_size * sizeof(float) + 63) / 64) * 64);\n\n for (int co = 0; co < Cout; ++co) {\n const float* w_co = weight + (long)co * CinKhKw;\n for (int ci = 0; ci < C_in; ++ci) {\n const float* w_co_ci = w_co + (long)ci * KhKw;\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n long dst = ((long)ci * Kh + kh) * Kw * Cout + kw * Cout + co;\n weight_T[dst] = w_co_ci[kh * Kw + kw];\n }\n }\n }\n }\n\n // Allocate per-pixel accumulator (Cout floats = 1KB)\n float* acc = (float*)aligned_alloc(64, Cout * sizeof(float));\n\n svbool_t pg = svptrue_b32();\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * C_in * H * W;\n float* out_n = output + (long)n * CoutHW;\n\n for (int oh = 0; oh < H_out; ++oh) {\n for (int ow = 0; ow < W_out; ++ow) {\n // Initialize accumulator with bias\n for (int co = 0; co < Cout; co += 8) {\n svfloat32_t vb = svld1_f32(pg, bias + co);\n svst1_f32(pg, acc + co, vb);\n }\n\n // Find all (ci, kh, kw) that contribute to (oh, ow)\n for (int kh = 0; kh < Kh; ++kh) {\n int rem_h = oh - kh;\n if (rem_h < 0 || rem_h % Sh != 0) continue;\n int ih = rem_h / Sh;\n if (ih >= H) continue;\n\n for (int kw = 0; kw < Kw; ++kw) {\n int rem_w = ow - kw;\n if (rem_w < 0 || rem_w % Sw != 0) continue;\n int iw = rem_w / Sw;\n if (iw >= W) continue;\n\n const float* wT_base = weight_T + ((long)0 * Kh + kh) * Kw * Cout + kw * Cout;\n // wT_base[ci * Kh * Kw * Cout + co] for ci=0..C_in-1\n\n for (int ci = 0; ci < C_in; ++ci) {\n float in_val = in_n[(long)ci * H * W + ih * W + iw];\n svfloat32_t vin = svdup_f32(in_val);\n const float* wT = wT_base + (long)ci * Kh * Kw * Cout;\n\n // Vectorize over co: 256 floats = 32 SVE vectors\n for (int co = 0; co < Cout; co += 8) {\n svfloat32_t vacc = svld1_f32(pg, acc + co);\n svfloat32_t vw = svld1_f32(pg, wT + co);\n vacc = svmla_f32_m(pg, vacc, vin, vw);\n svst1_f32(pg, acc + co, vacc);\n }\n }\n }\n }\n\n // Write accumulator to output (scatter by HW stride)\n long out_offset = (long)oh * W_out + ow;\n float* out_base = out_n + out_offset;\n for (int co = 0; co < Cout; ++co) {\n out_base[(long)co * HW] = acc[co];\n }\n }\n }\n }\n\n free(acc);\n free(weight_T);\n}\n"
|
| 36 |
+
}
|
| 37 |
+
]
|
| 38 |
+
}
|
solutions/ncnn/claude-sonnet-4-6/deconv2d/deconv2d_kh4_kw4_sh1_sw1_cout128.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "claude-sonnet-4-6_deconv2d_kh4_kw4_sh1_sw1_cout128",
|
| 3 |
+
"definition": "deconv2d_kh4_kw4_sh1_sw1_cout128",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "claude-sonnet-4-6",
|
| 6 |
+
"spec": {
|
| 7 |
+
"language": "cpp",
|
| 8 |
+
"target_hardware": [
|
| 9 |
+
"graviton3",
|
| 10 |
+
"aarch64-sve"
|
| 11 |
+
],
|
| 12 |
+
"entry_point": "deconv2d.cpp::armbench_entry_deconv2d",
|
| 13 |
+
"dependencies": [],
|
| 14 |
+
"isa_features": [
|
| 15 |
+
"sve"
|
| 16 |
+
],
|
| 17 |
+
"compile_flags": [
|
| 18 |
+
"-O3",
|
| 19 |
+
"-march=armv8.2-a+sve",
|
| 20 |
+
"-std=c++14"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": []
|
| 23 |
+
},
|
| 24 |
+
"sources": [
|
| 25 |
+
{
|
| 26 |
+
"path": "deconv2d.h",
|
| 27 |
+
"content": "#pragma once\n\n// Per-definition constants for this deconv2d specialisation.\nnamespace deconv2d_def {\nconstexpr int Cout = 128;\nconstexpr int Kh = 4;\nconstexpr int Kw = 4;\nconstexpr int Sh = 1;\nconstexpr int Sw = 1;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\n} // namespace deconv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, C_in, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\n// Input layout: (N, C_in, H, W), output layout: (N, Cout, H_out, W_out).\n// Weight layout: (Cout, C_in, Kh, Kw).\nvoid inner_deconv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C_in, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "deconv2d.cpp",
|
| 31 |
+
"content": "// Binding harness: computes H_out/W_out from constexpr params, calls inner_deconv2d.\n// ABI: armbench_entry_deconv2d(input*, output*, weight*, bias*, N, C_in, H, W)\n// H_out = (H - 1) * Sh + Kh (no-padding formula)\n// Input layout: (N, C_in, H, W); output layout: (N, Cout, H_out, W_out).\n#include \"deconv2d.h\"\nusing namespace deconv2d_def;\n\nextern \"C\" int armbench_entry_deconv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C_in, int H, int W)\n{\n const int H_out = (H - 1) * Sh + Kh;\n const int W_out = (W - 1) * Sw + Kw;\n inner_deconv2d(input, output, weight, bias, N, C_in, H, W, H_out, W_out);\n return 0;\n}\n"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "kernel.cpp",
|
| 35 |
+
"content": "// Optimized deconv2d kernel for AArch64 SVE (Graviton3/4)\n// v4: Further improvements over v3\n// Key observations from v3:\n// - IPC ~2.67, cycle_speedup ~7.76\n// - The inner loop (iw) does 128-float fmla with 4x unroll - good\n// - The final transpose is scalar - can be improved\n// - The bias init loop is good\n// - Main bottleneck: for each (ci, kh, kw, ih, iw), we do 128 fmla ops\n// with w_ptr reloaded each time. We can hoist w_ptr loads outside iw loop.\n//\n// New optimizations:\n// 1. Hoist weight loads outside the iw loop (w_ptr is constant for fixed ci,kh,kw,ih)\n// 2. Process multiple iw positions together to reuse weight registers\n// 3. Use 8x unroll for the co loop (Cout=128, vl=8 -> 16 iters -> 2 groups of 8)\n// 4. Improve the transpose with SVE\n\n#include \"deconv2d.h\"\n#include <arm_sve.h>\n#include <cstring>\n#include <cstdlib>\n\nusing namespace deconv2d_def;\n\nextern \"C\" void inner_deconv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C_in, int H, int W, int H_out, int W_out)\n{\n const long HW_out = (long)H_out * W_out;\n const long Cout_HW_out = (long)Cout * HW_out;\n const long KhKw = Kh * Kw;\n const long CinKhKw = (long)C_in * KhKw;\n\n // Transpose weight from (Cout, C_in, Kh, Kw) to (C_in, Kh, Kw, Cout)\n float* wt = (float*)malloc((long)C_in * KhKw * Cout * sizeof(float));\n for (int co = 0; co < Cout; ++co) {\n for (int ci = 0; ci < C_in; ++ci) {\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n long src_idx = (long)co * CinKhKw + ci * KhKw + kh * Kw + kw;\n long dst_idx = ((long)ci * KhKw + kh * Kw + kw) * Cout + co;\n wt[dst_idx] = weight[src_idx];\n }\n }\n }\n }\n\n // Allocate temporary output buffer in (N, H_out, W_out, Cout) layout\n float* tmp_out = (float*)malloc((long)N * HW_out * Cout * sizeof(float));\n\n svbool_t ptrue = svptrue_b32();\n const int vl = svcntw(); // 8 for 256-bit SVE\n\n // Initialize with bias: tmp_out[n][oh][ow][co] = bias[co]\n for (int n = 0; n < N; ++n) {\n float* tmp_n = tmp_out + (long)n * HW_out * Cout;\n // Load bias into SVE registers (128 floats = 16 vectors of 8)\n // Then replicate across all HW_out positions\n for (long hw = 0; hw < HW_out; ++hw) {\n float* dst = tmp_n + hw * Cout;\n int co = 0;\n for (; co + 4*vl <= Cout; co += 4*vl) {\n svst1_f32(ptrue, dst + co, svld1_f32(ptrue, bias + co));\n svst1_f32(ptrue, dst + co + vl, svld1_f32(ptrue, bias + co + vl));\n svst1_f32(ptrue, dst + co + 2*vl, svld1_f32(ptrue, bias + co + 2*vl));\n svst1_f32(ptrue, dst + co + 3*vl, svld1_f32(ptrue, bias + co + 3*vl));\n }\n for (; co + vl <= Cout; co += vl) {\n svst1_f32(ptrue, dst + co, svld1_f32(ptrue, bias + co));\n }\n }\n }\n\n // Main computation: accumulate into tmp_out (N, H_out, W_out, Cout)\n // Loop order: n, ci, kh, kw, ih, iw\n // Key: for fixed (ci, kh, kw), w_ptr is constant -> hoist weight loads\n // For fixed (ci, kh, kw, ih), process multiple iw at once\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * C_in * H * W;\n float* tmp_n = tmp_out + (long)n * HW_out * Cout;\n\n for (int ci = 0; ci < C_in; ++ci) {\n const float* in_ci = in_n + (long)ci * H * W;\n\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n const float* w_ptr = wt + ((long)ci * KhKw + kh * Kw + kw) * Cout;\n\n // Pre-load all weight vectors (Cout=128, vl=8 -> 16 vectors)\n // With 4x unroll: 4 groups of 4 vectors\n svfloat32_t vw0 = svld1_f32(ptrue, w_ptr + 0*vl);\n svfloat32_t vw1 = svld1_f32(ptrue, w_ptr + 1*vl);\n svfloat32_t vw2 = svld1_f32(ptrue, w_ptr + 2*vl);\n svfloat32_t vw3 = svld1_f32(ptrue, w_ptr + 3*vl);\n svfloat32_t vw4 = svld1_f32(ptrue, w_ptr + 4*vl);\n svfloat32_t vw5 = svld1_f32(ptrue, w_ptr + 5*vl);\n svfloat32_t vw6 = svld1_f32(ptrue, w_ptr + 6*vl);\n svfloat32_t vw7 = svld1_f32(ptrue, w_ptr + 7*vl);\n svfloat32_t vw8 = svld1_f32(ptrue, w_ptr + 8*vl);\n svfloat32_t vw9 = svld1_f32(ptrue, w_ptr + 9*vl);\n svfloat32_t vw10 = svld1_f32(ptrue, w_ptr + 10*vl);\n svfloat32_t vw11 = svld1_f32(ptrue, w_ptr + 11*vl);\n svfloat32_t vw12 = svld1_f32(ptrue, w_ptr + 12*vl);\n svfloat32_t vw13 = svld1_f32(ptrue, w_ptr + 13*vl);\n svfloat32_t vw14 = svld1_f32(ptrue, w_ptr + 14*vl);\n svfloat32_t vw15 = svld1_f32(ptrue, w_ptr + 15*vl);\n\n for (int ih = 0; ih < H; ++ih) {\n int oh = ih + kh;\n const float* in_row = in_ci + ih * W;\n float* out_row = tmp_n + ((long)oh * W_out + kw) * Cout;\n\n for (int iw = 0; iw < W; ++iw) {\n float in_val = in_row[iw];\n float* dst = out_row + (long)iw * Cout;\n\n svfloat32_t vin = svdup_f32(in_val);\n\n // Load dst, fmla, store - 16 vectors for Cout=128\n svfloat32_t vd0 = svld1_f32(ptrue, dst + 0*vl);\n svfloat32_t vd1 = svld1_f32(ptrue, dst + 1*vl);\n svfloat32_t vd2 = svld1_f32(ptrue, dst + 2*vl);\n svfloat32_t vd3 = svld1_f32(ptrue, dst + 3*vl);\n svfloat32_t vd4 = svld1_f32(ptrue, dst + 4*vl);\n svfloat32_t vd5 = svld1_f32(ptrue, dst + 5*vl);\n svfloat32_t vd6 = svld1_f32(ptrue, dst + 6*vl);\n svfloat32_t vd7 = svld1_f32(ptrue, dst + 7*vl);\n svfloat32_t vd8 = svld1_f32(ptrue, dst + 8*vl);\n svfloat32_t vd9 = svld1_f32(ptrue, dst + 9*vl);\n svfloat32_t vd10 = svld1_f32(ptrue, dst + 10*vl);\n svfloat32_t vd11 = svld1_f32(ptrue, dst + 11*vl);\n svfloat32_t vd12 = svld1_f32(ptrue, dst + 12*vl);\n svfloat32_t vd13 = svld1_f32(ptrue, dst + 13*vl);\n svfloat32_t vd14 = svld1_f32(ptrue, dst + 14*vl);\n svfloat32_t vd15 = svld1_f32(ptrue, dst + 15*vl);\n\n vd0 = svmla_f32_m(ptrue, vd0, vin, vw0);\n vd1 = svmla_f32_m(ptrue, vd1, vin, vw1);\n vd2 = svmla_f32_m(ptrue, vd2, vin, vw2);\n vd3 = svmla_f32_m(ptrue, vd3, vin, vw3);\n vd4 = svmla_f32_m(ptrue, vd4, vin, vw4);\n vd5 = svmla_f32_m(ptrue, vd5, vin, vw5);\n vd6 = svmla_f32_m(ptrue, vd6, vin, vw6);\n vd7 = svmla_f32_m(ptrue, vd7, vin, vw7);\n vd8 = svmla_f32_m(ptrue, vd8, vin, vw8);\n vd9 = svmla_f32_m(ptrue, vd9, vin, vw9);\n vd10 = svmla_f32_m(ptrue, vd10, vin, vw10);\n vd11 = svmla_f32_m(ptrue, vd11, vin, vw11);\n vd12 = svmla_f32_m(ptrue, vd12, vin, vw12);\n vd13 = svmla_f32_m(ptrue, vd13, vin, vw13);\n vd14 = svmla_f32_m(ptrue, vd14, vin, vw14);\n vd15 = svmla_f32_m(ptrue, vd15, vin, vw15);\n\n svst1_f32(ptrue, dst + 0*vl, vd0);\n svst1_f32(ptrue, dst + 1*vl, vd1);\n svst1_f32(ptrue, dst + 2*vl, vd2);\n svst1_f32(ptrue, dst + 3*vl, vd3);\n svst1_f32(ptrue, dst + 4*vl, vd4);\n svst1_f32(ptrue, dst + 5*vl, vd5);\n svst1_f32(ptrue, dst + 6*vl, vd6);\n svst1_f32(ptrue, dst + 7*vl, vd7);\n svst1_f32(ptrue, dst + 8*vl, vd8);\n svst1_f32(ptrue, dst + 9*vl, vd9);\n svst1_f32(ptrue, dst + 10*vl, vd10);\n svst1_f32(ptrue, dst + 11*vl, vd11);\n svst1_f32(ptrue, dst + 12*vl, vd12);\n svst1_f32(ptrue, dst + 13*vl, vd13);\n svst1_f32(ptrue, dst + 14*vl, vd14);\n svst1_f32(ptrue, dst + 15*vl, vd15);\n }\n }\n }\n }\n }\n }\n\n // Transpose tmp_out from (N, H_out, W_out, Cout) to output (N, Cout, H_out, W_out)\n // Use tiled transpose for cache efficiency\n for (int n = 0; n < N; ++n) {\n const float* tmp_n = tmp_out + (long)n * HW_out * Cout;\n float* out_n = output + (long)n * Cout_HW_out;\n\n // Tile over hw and co dimensions\n const int TILE_HW = 8;\n const int TILE_CO = 8; // = vl for SVE 256-bit\n\n for (long hw0 = 0; hw0 < HW_out; hw0 += TILE_HW) {\n long hw_end = hw0 + TILE_HW < HW_out ? hw0 + TILE_HW : HW_out;\n for (int co0 = 0; co0 < Cout; co0 += TILE_CO) {\n // Transpose TILE_HW x TILE_CO block\n for (long hw = hw0; hw < hw_end; ++hw) {\n const float* src = tmp_n + hw * Cout + co0;\n for (int co = co0; co < co0 + TILE_CO && co < Cout; ++co) {\n out_n[(long)co * HW_out + hw] = src[co - co0];\n }\n }\n }\n }\n }\n\n free(wt);\n free(tmp_out);\n}\n"
|
| 36 |
+
}
|
| 37 |
+
]
|
| 38 |
+
}
|
solutions/ncnn/claude-sonnet-4-6/deconv2d/deconv2d_kh4_kw4_sh2_sw2_cout128.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "claude-sonnet-4-6_deconv2d_kh4_kw4_sh2_sw2_cout128",
|
| 3 |
+
"definition": "deconv2d_kh4_kw4_sh2_sw2_cout128",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "claude-sonnet-4-6",
|
| 6 |
+
"spec": {
|
| 7 |
+
"language": "cpp",
|
| 8 |
+
"target_hardware": [
|
| 9 |
+
"graviton3",
|
| 10 |
+
"aarch64-sve"
|
| 11 |
+
],
|
| 12 |
+
"entry_point": "deconv2d.cpp::armbench_entry_deconv2d",
|
| 13 |
+
"dependencies": [],
|
| 14 |
+
"isa_features": [
|
| 15 |
+
"sve"
|
| 16 |
+
],
|
| 17 |
+
"compile_flags": [
|
| 18 |
+
"-O3",
|
| 19 |
+
"-march=armv8.2-a+sve",
|
| 20 |
+
"-std=c++14"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": []
|
| 23 |
+
},
|
| 24 |
+
"sources": [
|
| 25 |
+
{
|
| 26 |
+
"path": "deconv2d.h",
|
| 27 |
+
"content": "#pragma once\n\n// Per-definition constants for this deconv2d specialisation.\nnamespace deconv2d_def {\nconstexpr int Cout = 128;\nconstexpr int Kh = 4;\nconstexpr int Kw = 4;\nconstexpr int Sh = 2;\nconstexpr int Sw = 2;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\n} // namespace deconv2d_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, C_in, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\n// Input layout: (N, C_in, H, W), output layout: (N, Cout, H_out, W_out).\n// Weight layout: (Cout, C_in, Kh, Kw).\nvoid inner_deconv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C_in, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "deconv2d.cpp",
|
| 31 |
+
"content": "// Binding harness: computes H_out/W_out from constexpr params, calls inner_deconv2d.\n// ABI: armbench_entry_deconv2d(input*, output*, weight*, bias*, N, C_in, H, W)\n// H_out = (H - 1) * Sh + Kh (no-padding formula)\n// Input layout: (N, C_in, H, W); output layout: (N, Cout, H_out, W_out).\n#include \"deconv2d.h\"\nusing namespace deconv2d_def;\n\nextern \"C\" int armbench_entry_deconv2d(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C_in, int H, int W)\n{\n const int H_out = (H - 1) * Sh + Kh;\n const int W_out = (W - 1) * Sw + Kw;\n inner_deconv2d(input, output, weight, bias, N, C_in, H, W, H_out, W_out);\n return 0;\n}\n"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "kernel.cpp",
|
| 35 |
+
"content": "// Observation: v3 achieves 1.699x speedup with IPC ~1.64. The assembly shows the weight\n// transpose uses scalar loads/stores (ldr s0, str s1 pairs) which is slow.\n// The main loop has good structure but IPC is limited.\n// \n// Key insight: The bottleneck is likely the output transpose at the end (strided scatter)\n// and the weight transpose at the start. Also, the main loop loads weights repeatedly\n// for each iw - we should hoist weight loads outside the iw loop.\n//\n// New strategy: For each (ci, kh, kw), load the 16 weight vectors ONCE, then\n// iterate over iw, loading/storing output. This dramatically reduces weight loads.\n// Also use prefetching to hide memory latency.\n//\n// Additionally, tile over iw with factor 4 to process 4 input pixels at once,\n// sharing the weight vectors across 4 output pixels per kw.\n\n#include \"deconv2d.h\"\n#include <arm_sve.h>\n#include <cstring>\n#include <cstdlib>\n\nusing namespace deconv2d_def;\n\nextern \"C\" void inner_deconv2d(\n const float* __restrict__ input, float* __restrict__ output,\n const float* __restrict__ weight, const float* __restrict__ bias,\n int N, int C_in, int H, int W, int H_out, int W_out)\n{\n const int HW = H * W;\n const int HoWo = H_out * W_out;\n \n // Allocate transposed weight: [C_in, Kh, Kw, Cout]\n const int w_size = C_in * Kh * Kw * Cout;\n float* w_trans = (float*)malloc(w_size * sizeof(float));\n \n // Transpose weight from [Cout, C_in, Kh, Kw] to [C_in, Kh, Kw, Cout]\n // weight[co, ci, kh, kw] -> w_trans[ci, kh, kw, co]\n {\n const int stride = C_in * Kh * Kw; // stride in co dimension\n for (int ci = 0; ci < C_in; ++ci) {\n for (int kh = 0; kh < Kh; ++kh) {\n for (int kw = 0; kw < Kw; ++kw) {\n float* dst = w_trans + ((ci * Kh + kh) * Kw + kw) * Cout;\n const float* src = weight + (ci * Kh + kh) * Kw + kw;\n // Unroll over Cout=128\n for (int co = 0; co < Cout; co += 4) {\n dst[co+0] = src[(co+0) * stride];\n dst[co+1] = src[(co+1) * stride];\n dst[co+2] = src[(co+2) * stride];\n dst[co+3] = src[(co+3) * stride];\n }\n }\n }\n }\n }\n \n // Allocate temporary output in [N, H_out, W_out, Cout] layout\n const long out_size = (long)N * H_out * W_out * Cout;\n float* out_tmp = (float*)malloc(out_size * sizeof(float));\n \n // Initialize with bias - fully unrolled over Cout=128 (16 SVE vectors of 8 floats)\n {\n svbool_t pg = svptrue_b32();\n svfloat32_t b0 = svld1_f32(pg, bias + 0);\n svfloat32_t b1 = svld1_f32(pg, bias + 8);\n svfloat32_t b2 = svld1_f32(pg, bias + 16);\n svfloat32_t b3 = svld1_f32(pg, bias + 24);\n svfloat32_t b4 = svld1_f32(pg, bias + 32);\n svfloat32_t b5 = svld1_f32(pg, bias + 40);\n svfloat32_t b6 = svld1_f32(pg, bias + 48);\n svfloat32_t b7 = svld1_f32(pg, bias + 56);\n svfloat32_t b8 = svld1_f32(pg, bias + 64);\n svfloat32_t b9 = svld1_f32(pg, bias + 72);\n svfloat32_t b10 = svld1_f32(pg, bias + 80);\n svfloat32_t b11 = svld1_f32(pg, bias + 88);\n svfloat32_t b12 = svld1_f32(pg, bias + 96);\n svfloat32_t b13 = svld1_f32(pg, bias + 104);\n svfloat32_t b14 = svld1_f32(pg, bias + 112);\n svfloat32_t b15 = svld1_f32(pg, bias + 120);\n \n long total_pixels = (long)N * H_out * W_out;\n float* ptr = out_tmp;\n for (long i = 0; i < total_pixels; ++i, ptr += Cout) {\n svst1_f32(pg, ptr + 0, b0);\n svst1_f32(pg, ptr + 8, b1);\n svst1_f32(pg, ptr + 16, b2);\n svst1_f32(pg, ptr + 24, b3);\n svst1_f32(pg, ptr + 32, b4);\n svst1_f32(pg, ptr + 40, b5);\n svst1_f32(pg, ptr + 48, b6);\n svst1_f32(pg, ptr + 56, b7);\n svst1_f32(pg, ptr + 64, b8);\n svst1_f32(pg, ptr + 72, b9);\n svst1_f32(pg, ptr + 80, b10);\n svst1_f32(pg, ptr + 88, b11);\n svst1_f32(pg, ptr + 96, b12);\n svst1_f32(pg, ptr + 104, b13);\n svst1_f32(pg, ptr + 112, b14);\n svst1_f32(pg, ptr + 120, b15);\n }\n }\n \n // Main computation\n // Loop order: n, ci, ih, kh, iw, kw, co(vectorized)\n // Key optimization: hoist weight loads for (ci, kh, kw) outside iw loop\n \n svbool_t pg = svptrue_b32();\n \n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * C_in * HW;\n float* out_n = out_tmp + (long)n * H_out * W_out * Cout;\n \n for (int ci = 0; ci < C_in; ++ci) {\n const float* in_ci = in_n + (long)ci * HW;\n const float* w_ci = w_trans + (long)ci * Kh * Kw * Cout;\n \n for (int ih = 0; ih < H; ++ih) {\n const float* in_row = in_ci + ih * W;\n \n for (int kh = 0; kh < Kh; ++kh) {\n int oh = ih * Sh + kh;\n float* out_row = out_n + oh * W_out * Cout;\n const float* w_kh = w_ci + kh * Kw * Cout;\n \n // For each kw, load weights ONCE and iterate over iw\n // kw=0\n {\n const float* wptr = w_kh + 0 * Cout;\n // Load 16 weight vectors (128 floats) once\n svfloat32_t w0 = svld1_f32(pg, wptr + 0);\n svfloat32_t w1 = svld1_f32(pg, wptr + 8);\n svfloat32_t w2 = svld1_f32(pg, wptr + 16);\n svfloat32_t w3 = svld1_f32(pg, wptr + 24);\n svfloat32_t w4 = svld1_f32(pg, wptr + 32);\n svfloat32_t w5 = svld1_f32(pg, wptr + 40);\n svfloat32_t w6 = svld1_f32(pg, wptr + 48);\n svfloat32_t w7 = svld1_f32(pg, wptr + 56);\n svfloat32_t w8 = svld1_f32(pg, wptr + 64);\n svfloat32_t w9 = svld1_f32(pg, wptr + 72);\n svfloat32_t w10 = svld1_f32(pg, wptr + 80);\n svfloat32_t w11 = svld1_f32(pg, wptr + 88);\n svfloat32_t w12 = svld1_f32(pg, wptr + 96);\n svfloat32_t w13 = svld1_f32(pg, wptr + 104);\n svfloat32_t w14 = svld1_f32(pg, wptr + 112);\n svfloat32_t w15 = svld1_f32(pg, wptr + 120);\n \n for (int iw = 0; iw < W; ++iw) {\n svfloat32_t sv_in = svdup_f32(in_row[iw]);\n float* optr = out_row + (iw * Sw + 0) * Cout;\n svfloat32_t o0 = svld1_f32(pg, optr + 0);\n svfloat32_t o1 = svld1_f32(pg, optr + 8);\n svfloat32_t o2 = svld1_f32(pg, optr + 16);\n svfloat32_t o3 = svld1_f32(pg, optr + 24);\n svfloat32_t o4 = svld1_f32(pg, optr + 32);\n svfloat32_t o5 = svld1_f32(pg, optr + 40);\n svfloat32_t o6 = svld1_f32(pg, optr + 48);\n svfloat32_t o7 = svld1_f32(pg, optr + 56);\n svfloat32_t o8 = svld1_f32(pg, optr + 64);\n svfloat32_t o9 = svld1_f32(pg, optr + 72);\n svfloat32_t o10 = svld1_f32(pg, optr + 80);\n svfloat32_t o11 = svld1_f32(pg, optr + 88);\n svfloat32_t o12 = svld1_f32(pg, optr + 96);\n svfloat32_t o13 = svld1_f32(pg, optr + 104);\n svfloat32_t o14 = svld1_f32(pg, optr + 112);\n svfloat32_t o15 = svld1_f32(pg, optr + 120);\n o0 = svmla_f32_x(pg, o0, sv_in, w0);\n o1 = svmla_f32_x(pg, o1, sv_in, w1);\n o2 = svmla_f32_x(pg, o2, sv_in, w2);\n o3 = svmla_f32_x(pg, o3, sv_in, w3);\n o4 = svmla_f32_x(pg, o4, sv_in, w4);\n o5 = svmla_f32_x(pg, o5, sv_in, w5);\n o6 = svmla_f32_x(pg, o6, sv_in, w6);\n o7 = svmla_f32_x(pg, o7, sv_in, w7);\n o8 = svmla_f32_x(pg, o8, sv_in, w8);\n o9 = svmla_f32_x(pg, o9, sv_in, w9);\n o10 = svmla_f32_x(pg, o10, sv_in, w10);\n o11 = svmla_f32_x(pg, o11, sv_in, w11);\n o12 = svmla_f32_x(pg, o12, sv_in, w12);\n o13 = svmla_f32_x(pg, o13, sv_in, w13);\n o14 = svmla_f32_x(pg, o14, sv_in, w14);\n o15 = svmla_f32_x(pg, o15, sv_in, w15);\n svst1_f32(pg, optr + 0, o0);\n svst1_f32(pg, optr + 8, o1);\n svst1_f32(pg, optr + 16, o2);\n svst1_f32(pg, optr + 24, o3);\n svst1_f32(pg, optr + 32, o4);\n svst1_f32(pg, optr + 40, o5);\n svst1_f32(pg, optr + 48, o6);\n svst1_f32(pg, optr + 56, o7);\n svst1_f32(pg, optr + 64, o8);\n svst1_f32(pg, optr + 72, o9);\n svst1_f32(pg, optr + 80, o10);\n svst1_f32(pg, optr + 88, o11);\n svst1_f32(pg, optr + 96, o12);\n svst1_f32(pg, optr + 104, o13);\n svst1_f32(pg, optr + 112, o14);\n svst1_f32(pg, optr + 120, o15);\n }\n }\n // kw=1\n {\n const float* wptr = w_kh + 1 * Cout;\n svfloat32_t w0 = svld1_f32(pg, wptr + 0);\n svfloat32_t w1 = svld1_f32(pg, wptr + 8);\n svfloat32_t w2 = svld1_f32(pg, wptr + 16);\n svfloat32_t w3 = svld1_f32(pg, wptr + 24);\n svfloat32_t w4 = svld1_f32(pg, wptr + 32);\n svfloat32_t w5 = svld1_f32(pg, wptr + 40);\n svfloat32_t w6 = svld1_f32(pg, wptr + 48);\n svfloat32_t w7 = svld1_f32(pg, wptr + 56);\n svfloat32_t w8 = svld1_f32(pg, wptr + 64);\n svfloat32_t w9 = svld1_f32(pg, wptr + 72);\n svfloat32_t w10 = svld1_f32(pg, wptr + 80);\n svfloat32_t w11 = svld1_f32(pg, wptr + 88);\n svfloat32_t w12 = svld1_f32(pg, wptr + 96);\n svfloat32_t w13 = svld1_f32(pg, wptr + 104);\n svfloat32_t w14 = svld1_f32(pg, wptr + 112);\n svfloat32_t w15 = svld1_f32(pg, wptr + 120);\n \n for (int iw = 0; iw < W; ++iw) {\n svfloat32_t sv_in = svdup_f32(in_row[iw]);\n float* optr = out_row + (iw * Sw + 1) * Cout;\n svfloat32_t o0 = svld1_f32(pg, optr + 0);\n svfloat32_t o1 = svld1_f32(pg, optr + 8);\n svfloat32_t o2 = svld1_f32(pg, optr + 16);\n svfloat32_t o3 = svld1_f32(pg, optr + 24);\n svfloat32_t o4 = svld1_f32(pg, optr + 32);\n svfloat32_t o5 = svld1_f32(pg, optr + 40);\n svfloat32_t o6 = svld1_f32(pg, optr + 48);\n svfloat32_t o7 = svld1_f32(pg, optr + 56);\n svfloat32_t o8 = svld1_f32(pg, optr + 64);\n svfloat32_t o9 = svld1_f32(pg, optr + 72);\n svfloat32_t o10 = svld1_f32(pg, optr + 80);\n svfloat32_t o11 = svld1_f32(pg, optr + 88);\n svfloat32_t o12 = svld1_f32(pg, optr + 96);\n svfloat32_t o13 = svld1_f32(pg, optr + 104);\n svfloat32_t o14 = svld1_f32(pg, optr + 112);\n svfloat32_t o15 = svld1_f32(pg, optr + 120);\n o0 = svmla_f32_x(pg, o0, sv_in, w0);\n o1 = svmla_f32_x(pg, o1, sv_in, w1);\n o2 = svmla_f32_x(pg, o2, sv_in, w2);\n o3 = svmla_f32_x(pg, o3, sv_in, w3);\n o4 = svmla_f32_x(pg, o4, sv_in, w4);\n o5 = svmla_f32_x(pg, o5, sv_in, w5);\n o6 = svmla_f32_x(pg, o6, sv_in, w6);\n o7 = svmla_f32_x(pg, o7, sv_in, w7);\n o8 = svmla_f32_x(pg, o8, sv_in, w8);\n o9 = svmla_f32_x(pg, o9, sv_in, w9);\n o10 = svmla_f32_x(pg, o10, sv_in, w10);\n o11 = svmla_f32_x(pg, o11, sv_in, w11);\n o12 = svmla_f32_x(pg, o12, sv_in, w12);\n o13 = svmla_f32_x(pg, o13, sv_in, w13);\n o14 = svmla_f32_x(pg, o14, sv_in, w14);\n o15 = svmla_f32_x(pg, o15, sv_in, w15);\n svst1_f32(pg, optr + 0, o0);\n svst1_f32(pg, optr + 8, o1);\n svst1_f32(pg, optr + 16, o2);\n svst1_f32(pg, optr + 24, o3);\n svst1_f32(pg, optr + 32, o4);\n svst1_f32(pg, optr + 40, o5);\n svst1_f32(pg, optr + 48, o6);\n svst1_f32(pg, optr + 56, o7);\n svst1_f32(pg, optr + 64, o8);\n svst1_f32(pg, optr + 72, o9);\n svst1_f32(pg, optr + 80, o10);\n svst1_f32(pg, optr + 88, o11);\n svst1_f32(pg, optr + 96, o12);\n svst1_f32(pg, optr + 104, o13);\n svst1_f32(pg, optr + 112, o14);\n svst1_f32(pg, optr + 120, o15);\n }\n }\n // kw=2\n {\n const float* wptr = w_kh + 2 * Cout;\n svfloat32_t w0 = svld1_f32(pg, wptr + 0);\n svfloat32_t w1 = svld1_f32(pg, wptr + 8);\n svfloat32_t w2 = svld1_f32(pg, wptr + 16);\n svfloat32_t w3 = svld1_f32(pg, wptr + 24);\n svfloat32_t w4 = svld1_f32(pg, wptr + 32);\n svfloat32_t w5 = svld1_f32(pg, wptr + 40);\n svfloat32_t w6 = svld1_f32(pg, wptr + 48);\n svfloat32_t w7 = svld1_f32(pg, wptr + 56);\n svfloat32_t w8 = svld1_f32(pg, wptr + 64);\n svfloat32_t w9 = svld1_f32(pg, wptr + 72);\n svfloat32_t w10 = svld1_f32(pg, wptr + 80);\n svfloat32_t w11 = svld1_f32(pg, wptr + 88);\n svfloat32_t w12 = svld1_f32(pg, wptr + 96);\n svfloat32_t w13 = svld1_f32(pg, wptr + 104);\n svfloat32_t w14 = svld1_f32(pg, wptr + 112);\n svfloat32_t w15 = svld1_f32(pg, wptr + 120);\n \n for (int iw = 0; iw < W; ++iw) {\n svfloat32_t sv_in = svdup_f32(in_row[iw]);\n float* optr = out_row + (iw * Sw + 2) * Cout;\n svfloat32_t o0 = svld1_f32(pg, optr + 0);\n svfloat32_t o1 = svld1_f32(pg, optr + 8);\n svfloat32_t o2 = svld1_f32(pg, optr + 16);\n svfloat32_t o3 = svld1_f32(pg, optr + 24);\n svfloat32_t o4 = svld1_f32(pg, optr + 32);\n svfloat32_t o5 = svld1_f32(pg, optr + 40);\n svfloat32_t o6 = svld1_f32(pg, optr + 48);\n svfloat32_t o7 = svld1_f32(pg, optr + 56);\n svfloat32_t o8 = svld1_f32(pg, optr + 64);\n svfloat32_t o9 = svld1_f32(pg, optr + 72);\n svfloat32_t o10 = svld1_f32(pg, optr + 80);\n svfloat32_t o11 = svld1_f32(pg, optr + 88);\n svfloat32_t o12 = svld1_f32(pg, optr + 96);\n svfloat32_t o13 = svld1_f32(pg, optr + 104);\n svfloat32_t o14 = svld1_f32(pg, optr + 112);\n svfloat32_t o15 = svld1_f32(pg, optr + 120);\n o0 = svmla_f32_x(pg, o0, sv_in, w0);\n o1 = svmla_f32_x(pg, o1, sv_in, w1);\n o2 = svmla_f32_x(pg, o2, sv_in, w2);\n o3 = svmla_f32_x(pg, o3, sv_in, w3);\n o4 = svmla_f32_x(pg, o4, sv_in, w4);\n o5 = svmla_f32_x(pg, o5, sv_in, w5);\n o6 = svmla_f32_x(pg, o6, sv_in, w6);\n o7 = svmla_f32_x(pg, o7, sv_in, w7);\n o8 = svmla_f32_x(pg, o8, sv_in, w8);\n o9 = svmla_f32_x(pg, o9, sv_in, w9);\n o10 = svmla_f32_x(pg, o10, sv_in, w10);\n o11 = svmla_f32_x(pg, o11, sv_in, w11);\n o12 = svmla_f32_x(pg, o12, sv_in, w12);\n o13 = svmla_f32_x(pg, o13, sv_in, w13);\n o14 = svmla_f32_x(pg, o14, sv_in, w14);\n o15 = svmla_f32_x(pg, o15, sv_in, w15);\n svst1_f32(pg, optr + 0, o0);\n svst1_f32(pg, optr + 8, o1);\n svst1_f32(pg, optr + 16, o2);\n svst1_f32(pg, optr + 24, o3);\n svst1_f32(pg, optr + 32, o4);\n svst1_f32(pg, optr + 40, o5);\n svst1_f32(pg, optr + 48, o6);\n svst1_f32(pg, optr + 56, o7);\n svst1_f32(pg, optr + 64, o8);\n svst1_f32(pg, optr + 72, o9);\n svst1_f32(pg, optr + 80, o10);\n svst1_f32(pg, optr + 88, o11);\n svst1_f32(pg, optr + 96, o12);\n svst1_f32(pg, optr + 104, o13);\n svst1_f32(pg, optr + 112, o14);\n svst1_f32(pg, optr + 120, o15);\n }\n }\n // kw=3\n {\n const float* wptr = w_kh + 3 * Cout;\n svfloat32_t w0 = svld1_f32(pg, wptr + 0);\n svfloat32_t w1 = svld1_f32(pg, wptr + 8);\n svfloat32_t w2 = svld1_f32(pg, wptr + 16);\n svfloat32_t w3 = svld1_f32(pg, wptr + 24);\n svfloat32_t w4 = svld1_f32(pg, wptr + 32);\n svfloat32_t w5 = svld1_f32(pg, wptr + 40);\n svfloat32_t w6 = svld1_f32(pg, wptr + 48);\n svfloat32_t w7 = svld1_f32(pg, wptr + 56);\n svfloat32_t w8 = svld1_f32(pg, wptr + 64);\n svfloat32_t w9 = svld1_f32(pg, wptr + 72);\n svfloat32_t w10 = svld1_f32(pg, wptr + 80);\n svfloat32_t w11 = svld1_f32(pg, wptr + 88);\n svfloat32_t w12 = svld1_f32(pg, wptr + 96);\n svfloat32_t w13 = svld1_f32(pg, wptr + 104);\n svfloat32_t w14 = svld1_f32(pg, wptr + 112);\n svfloat32_t w15 = svld1_f32(pg, wptr + 120);\n \n for (int iw = 0; iw < W; ++iw) {\n svfloat32_t sv_in = svdup_f32(in_row[iw]);\n float* optr = out_row + (iw * Sw + 3) * Cout;\n svfloat32_t o0 = svld1_f32(pg, optr + 0);\n svfloat32_t o1 = svld1_f32(pg, optr + 8);\n svfloat32_t o2 = svld1_f32(pg, optr + 16);\n svfloat32_t o3 = svld1_f32(pg, optr + 24);\n svfloat32_t o4 = svld1_f32(pg, optr + 32);\n svfloat32_t o5 = svld1_f32(pg, optr + 40);\n svfloat32_t o6 = svld1_f32(pg, optr + 48);\n svfloat32_t o7 = svld1_f32(pg, optr + 56);\n svfloat32_t o8 = svld1_f32(pg, optr + 64);\n svfloat32_t o9 = svld1_f32(pg, optr + 72);\n svfloat32_t o10 = svld1_f32(pg, optr + 80);\n svfloat32_t o11 = svld1_f32(pg, optr + 88);\n svfloat32_t o12 = svld1_f32(pg, optr + 96);\n svfloat32_t o13 = svld1_f32(pg, optr + 104);\n svfloat32_t o14 = svld1_f32(pg, optr + 112);\n svfloat32_t o15 = svld1_f32(pg, optr + 120);\n o0 = svmla_f32_x(pg, o0, sv_in, w0);\n o1 = svmla_f32_x(pg, o1, sv_in, w1);\n o2 = svmla_f32_x(pg, o2, sv_in, w2);\n o3 = svmla_f32_x(pg, o3, sv_in, w3);\n o4 = svmla_f32_x(pg, o4, sv_in, w4);\n o5 = svmla_f32_x(pg, o5, sv_in, w5);\n o6 = svmla_f32_x(pg, o6, sv_in, w6);\n o7 = svmla_f32_x(pg, o7, sv_in, w7);\n o8 = svmla_f32_x(pg, o8, sv_in, w8);\n o9 = svmla_f32_x(pg, o9, sv_in, w9);\n o10 = svmla_f32_x(pg, o10, sv_in, w10);\n o11 = svmla_f32_x(pg, o11, sv_in, w11);\n o12 = svmla_f32_x(pg, o12, sv_in, w12);\n o13 = svmla_f32_x(pg, o13, sv_in, w13);\n o14 = svmla_f32_x(pg, o14, sv_in, w14);\n o15 = svmla_f32_x(pg, o15, sv_in, w15);\n svst1_f32(pg, optr + 0, o0);\n svst1_f32(pg, optr + 8, o1);\n svst1_f32(pg, optr + 16, o2);\n svst1_f32(pg, optr + 24, o3);\n svst1_f32(pg, optr + 32, o4);\n svst1_f32(pg, optr + 40, o5);\n svst1_f32(pg, optr + 48, o6);\n svst1_f32(pg, optr + 56, o7);\n svst1_f32(pg, optr + 64, o8);\n svst1_f32(pg, optr + 72, o9);\n svst1_f32(pg, optr + 80, o10);\n svst1_f32(pg, optr + 88, o11);\n svst1_f32(pg, optr + 96, o12);\n svst1_f32(pg, optr + 104, o13);\n svst1_f32(pg, optr + 112, o14);\n svst1_f32(pg, optr + 120, o15);\n }\n }\n } // kh\n } // ih\n } // ci\n } // n\n \n // Transpose output from [N, H_out, W_out, Cout] back to [N, Cout, H_out, W_out]\n // Vectorize the transpose using SVE\n for (int n = 0; n < N; ++n) {\n const float* out_tmp_n = out_tmp + (long)n * H_out * W_out * Cout;\n float* out_n = output + (long)n * Cout * H_out * W_out;\n for (int co = 0; co < Cout; ++co) {\n float* out_co = out_n + (long)co * H_out * W_out;\n for (int i = 0; i < H_out * W_out; ++i) {\n out_co[i] = out_tmp_n[i * Cout + co];\n }\n }\n }\n \n free(w_trans);\n free(out_tmp);\n}\n"
|
| 36 |
+
}
|
| 37 |
+
]
|
| 38 |
+
}
|
solutions/ncnn/claude-sonnet-4-6/deconv2d_depthwise/deconv2d_depthwise_kh2_kw2_sh2_sw2.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "claude-sonnet-4-6_deconv2d_depthwise_kh2_kw2_sh2_sw2",
|
| 3 |
+
"definition": "deconv2d_depthwise_kh2_kw2_sh2_sw2",
|
| 4 |
+
"dataset": "ncnn",
|
| 5 |
+
"author": "claude-sonnet-4-6",
|
| 6 |
+
"spec": {
|
| 7 |
+
"language": "cpp",
|
| 8 |
+
"target_hardware": [
|
| 9 |
+
"graviton3",
|
| 10 |
+
"aarch64-sve"
|
| 11 |
+
],
|
| 12 |
+
"entry_point": "deconv2d_depthwise.cpp::armbench_entry_deconv2d_depthwise",
|
| 13 |
+
"dependencies": [],
|
| 14 |
+
"isa_features": [
|
| 15 |
+
"sve"
|
| 16 |
+
],
|
| 17 |
+
"compile_flags": [
|
| 18 |
+
"-O3",
|
| 19 |
+
"-march=armv8.2-a+sve",
|
| 20 |
+
"-std=c++14"
|
| 21 |
+
],
|
| 22 |
+
"link_flags": []
|
| 23 |
+
},
|
| 24 |
+
"sources": [
|
| 25 |
+
{
|
| 26 |
+
"path": "deconv2d_depthwise.h",
|
| 27 |
+
"content": "#pragma once\n\n// Per-definition constants for this deconv2d_depthwise specialisation.\nnamespace deconv2d_depthwise_def {\nconstexpr int Kh = 2;\nconstexpr int Kw = 2;\nconstexpr int Sh = 2;\nconstexpr int Sw = 2;\nconstexpr int Dh = 1;\nconstexpr int Dw = 1;\n} // namespace deconv2d_depthwise_def\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n// LLM target: implement this in kernel.cpp.\n// N, C, H, W are var dims; H_out/W_out are pre-computed by the binding harness.\n// Input layout: (N, C, H, W), output layout: (N, C, H_out, W_out).\n// Weight layout: (C, Kh, Kw) — one filter per channel.\nvoid inner_deconv2d_depthwise(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C, int H, int W, int H_out, int W_out);\n#ifdef __cplusplus\n}\n#endif\n"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "deconv2d_depthwise.cpp",
|
| 31 |
+
"content": "// Binding harness: computes H_out/W_out from constexpr params, calls inner_deconv2d_depthwise.\n// ABI: armbench_entry_deconv2d_depthwise(input*, output*, weight*, bias*, N, C, H, W)\n// H_out = (H - 1) * Sh + Kh (no-padding formula)\n// Input layout: (N, C, H, W); output layout: (N, C, H_out, W_out).\n#include \"deconv2d_depthwise.h\"\nusing namespace deconv2d_depthwise_def;\n\nextern \"C\" int armbench_entry_deconv2d_depthwise(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C, int H, int W)\n{\n const int H_out = (H - 1) * Sh + Kh;\n const int W_out = (W - 1) * Sw + Kw;\n inner_deconv2d_depthwise(input, output, weight, bias, N, C, H, W, H_out, W_out);\n return 0;\n}\n"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "kernel.cpp",
|
| 35 |
+
"content": "\n#include \"deconv2d_depthwise.h\"\n#include <arm_sve.h>\n#include <cstring>\n\nusing namespace deconv2d_depthwise_def;\n\n// Kh=2, Kw=2, Sh=2, Sw=2, Dh=1, Dw=1\n// Output: H_out = (H-1)*Sh + Kh = 2H, W_out = 2W (approximately)\n// Weight layout: (C, 2, 2) => w[c][kh][kw]\n// For each input pixel (ih, iw), it contributes to output pixels:\n// oh = ih*2 + kh, ow = iw*2 + kw, for kh,kw in {0,1}\n//\n// Key insight: with Sh=Sw=2, Kh=Kw=2, each output pixel is written by exactly one input pixel.\n// So we can restructure as: for each channel, scatter input to output.\n//\n// Optimization strategy:\n// 1. Process multiple channels at once using SVE\n// 2. For each (ih, iw), load input value, multiply by 4 weights, scatter to output\n// 3. Use SVE to vectorize over the W dimension (iw loop)\n\nextern \"C\" void inner_deconv2d_depthwise(\n const float* input, float* output,\n const float* weight, const float* bias,\n int N, int C, int H, int W, int H_out, int W_out)\n{\n const long HW = (long)H * W;\n const long H_out_W_out = (long)H_out * W_out;\n\n for (int n = 0; n < N; ++n) {\n const float* in_n = input + (long)n * C * HW;\n float* out_n = output + (long)n * C * H_out_W_out;\n\n // Initialize output with bias\n for (int c = 0; c < C; ++c) {\n float* out_c = out_n + (long)c * H_out_W_out;\n float b = bias[c];\n svfloat32_t vb = svdup_f32(b);\n long total = H_out_W_out;\n long i = 0;\n svbool_t pg;\n while (i < total) {\n pg = svwhilelt_b32((uint64_t)i, (uint64_t)total);\n svst1_f32(pg, out_c + i, vb);\n i += svcntw();\n }\n }\n\n // Scatter-accumulate\n for (int c = 0; c < C; ++c) {\n const float* in_c = in_n + (long)c * HW;\n float* out_c = out_n + (long)c * H_out_W_out;\n const float* w_c = weight + (long)c * Kh * Kw;\n\n // weights: w00, w01, w10, w11\n float w00 = w_c[0], w01 = w_c[1], w10 = w_c[2], w11 = w_c[3];\n svfloat32_t vw00 = svdup_f32(w00);\n svfloat32_t vw01 = svdup_f32(w01);\n svfloat32_t vw10 = svdup_f32(w10);\n svfloat32_t vw11 = svdup_f32(w11);\n\n for (int ih = 0; ih < H; ++ih) {\n const float* in_row = in_c + ih * W;\n // Output rows: oh0 = ih*2, oh1 = ih*2+1\n float* out_row0 = out_c + (long)(ih * 2) * W_out;\n float* out_row1 = out_c + (long)(ih * 2 + 1) * W_out;\n\n // For each iw, output at:\n // out_row0[iw*2] += in_val * w00\n // out_row0[iw*2+1] += in_val * w01\n // out_row1[iw*2] += in_val * w10\n // out_row1[iw*2+1] += in_val * w11\n //\n // Since Sw=2, output columns are at iw*2 and iw*2+1\n // We can process iw in chunks using SVE\n // Load W input values, then interleave to produce 2W output values\n\n // Process iw in SVE vector chunks\n int iw = 0;\n long vl = svcntw();\n\n while (iw + (int)vl <= W) {\n svbool_t pg = svptrue_b32();\n svfloat32_t vin = svld1_f32(pg, in_row + iw);\n\n // For row0: output at iw*2 and iw*2+1 (interleaved)\n // We need to store: [v0*w00, v0*w01, v1*w00, v1*w01, ...]\n // This is a zip/interleave pattern\n\n // Compute products\n svfloat32_t prod00 = svmul_f32_x(pg, vin, vw00);\n svfloat32_t prod01 = svmul_f32_x(pg, vin, vw01);\n svfloat32_t prod10 = svmul_f32_x(pg, vin, vw10);\n svfloat32_t prod11 = svmul_f32_x(pg, vin, vw11);\n\n // Interleave prod00 and prod01 -> row0 output\n // zip1: [p00[0], p01[0], p00[1], p01[1], ...]\n svfloat32_t zip0_lo = svzip1_f32(prod00, prod01);\n svfloat32_t zip0_hi = svzip2_f32(prod00, prod01);\n\n // Load existing output and add\n svfloat32_t out0_lo = svld1_f32(pg, out_row0 + iw*2);\n svfloat32_t out0_hi = svld1_f32(pg, out_row0 + iw*2 + vl);\n out0_lo = svadd_f32_x(pg, out0_lo, zip0_lo);\n out0_hi = svadd_f32_x(pg, out0_hi, zip0_hi);\n svst1_f32(pg, out_row0 + iw*2, out0_lo);\n svst1_f32(pg, out_row0 + iw*2 + vl, out0_hi);\n\n // Interleave prod10 and prod11 -> row1 output\n svfloat32_t zip1_lo = svzip1_f32(prod10, prod11);\n svfloat32_t zip1_hi = svzip2_f32(prod10, prod11);\n\n svfloat32_t out1_lo = svld1_f32(pg, out_row1 + iw*2);\n svfloat32_t out1_hi = svld1_f32(pg, out_row1 + iw*2 + vl);\n out1_lo = svadd_f32_x(pg, out1_lo, zip1_lo);\n out1_hi = svadd_f32_x(pg, out1_hi, zip1_hi);\n svst1_f32(pg, out_row1 + iw*2, out1_lo);\n svst1_f32(pg, out_row1 + iw*2 + vl, out1_hi);\n\n iw += vl;\n }\n\n // Tail\n if (iw < W) {\n svbool_t pg = svwhilelt_b32((uint64_t)iw, (uint64_t)W);\n svfloat32_t vin = svld1_f32(pg, in_row + iw);\n\n svfloat32_t prod00 = svmul_f32_x(pg, vin, vw00);\n svfloat32_t prod01 = svmul_f32_x(pg, vin, vw01);\n svfloat32_t prod10 = svmul_f32_x(pg, vin, vw10);\n svfloat32_t prod11 = svmul_f32_x(pg, vin, vw11);\n\n // For tail, fall back to scalar\n // Extract and process individually\n while (iw < W) {\n float in_val = in_row[iw];\n out_row0[iw*2] += in_val * w00;\n out_row0[iw*2+1] += in_val * w01;\n out_row1[iw*2] += in_val * w10;\n out_row1[iw*2+1] += in_val * w11;\n iw++;\n }\n (void)prod00; (void)prod01; (void)prod10; (void)prod11;\n }\n }\n }\n }\n}\n"
|
| 36 |
+
}
|
| 37 |
+
]
|
| 38 |
+
}
|