MCPcopy Create free account
hub / github.com/tensorflow/tfjs / computeWorkPerThreadForConv2d

Function computeWorkPerThreadForConv2d

tfjs-backend-webgpu/src/webgpu_util.ts:120–140  ·  view source on GitHub ↗
(
    layout: {x: number[], y?: number[], z?: number[]}, outputShape: number[],
    isVec4 = false)

Source from the content-addressed store, hash-verified

118}
119
120export 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
142export function flatDispatchLayout(shape: number[]) {
143 return {x: shape.map((d, i) => i)};

Callers 2

constructorMethod · 0.90
constructorMethod · 0.90

Calls 1

arrayProductFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…