Skip to content

Commit

Permalink
Remove unused getBroadcastDims
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangzhaoming committed Nov 1, 2024
1 parent d30b5b5 commit 54ac622
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions js/web/lib/wasm/jsep/webgpu/ops/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -996,27 +996,3 @@ class ShaderHelperImpl implements ShaderHelper {

export const createShaderHelper = (dispatchGroup: [number, number, number], limits: GPUSupportedLimits) =>
new ShaderHelperImpl(dispatchGroup, limits);

/**
* This function comes from https://github.com/tensorflow/tfjs/blob/master/tfjs-core/src/ops/broadcast_util.ts#L18-L40
* Returns the dimensions in the input shape that are broadcasted to
* produce the provided output shape.
*
* The returned dimensions are 0-indexed and sorted. An example:
* inShape = [4, 1, 3]
* outShape = [5, 4, 3, 3]
* result = [1]. Dimension 1 (2nd dimension of input) gets broadcasted 1 => 3.
*/
export const getBroadcastDims = (inShape: readonly number[], outShape: readonly number[]): number[] => {
const inRank = inShape.length;
const dims: number[] = [];
for (let i = 0; i < inRank; i++) {
const dim = inRank - 1 - i;
const a = inShape[dim] || 1;
const b = outShape[outShape.length - 1 - i] || 1;
if (b > 1 && a === 1) {
dims.unshift(dim);
}
}
return dims;
};

0 comments on commit 54ac622

Please sign in to comment.