(
layout: {x: number[], y?: number[], z?: number[]}, outputShape: number[],
isVec4 = false)
| 118 | } |
| 119 | |
| 120 | export function computeWorkPerThreadForConv2d( |
| 121 | layout: {x: number[], y?: number[], z?: number[]}, outputShape: number[], |
| 122 | isVec4 = false): [number, number, number] { |
| 123 | if (isVec4) { |
| 124 | return [4, 4, 1]; |
| 125 | } |
| 126 | |
| 127 | const dim0 = arrayProduct(layout.x.map(d => outputShape[d])); |
| 128 | const dim1 = arrayProduct(layout.y.map(d => outputShape[d])); |
| 129 | // TODO(jiajia.qin@intel.com): More fine tune based on outputShape. |
| 130 | // The following conditions correspond to the values set in |
| 131 | // computeWorkgroupSizeForConv2d. |
| 132 | if (dim0 <= 4) { |
| 133 | return [1, 2, 1]; |
| 134 | } |
| 135 | if (dim1 <= 4) { |
| 136 | return [2, 1, 1]; |
| 137 | } |
| 138 | |
| 139 | return [2, 2, 1]; |
| 140 | } |
| 141 | |
| 142 | export function flatDispatchLayout(shape: number[]) { |
| 143 | return {x: shape.map((d, i) => i)}; |
no test coverage detected
searching dependent graphs…