MCPcopy Index your code
hub / github.com/tensorflow/tfjs / computeMaxSizePerColumn

Function computeMaxSizePerColumn

tfjs-core/src/tensor_format.ts:46–67  ·  view source on GitHub ↗
(
    vals: TypedArray|string[], shape: number[], dtype: DataType,
    strides: number[])

Source from the content-addressed store, hash-verified

44}
45
46function computeMaxSizePerColumn(
47 vals: TypedArray|string[], shape: number[], dtype: DataType,
48 strides: number[]): number[] {
49 const n = sizeFromShape(shape);
50 const numCols = strides[strides.length - 1];
51 const padPerCol = new Array(numCols).fill(0);
52 const rank = shape.length;
53 const valuesOrTuples =
54 dtype === 'complex64' ? createComplexTuples(vals) : vals;
55
56 if (rank > 1) {
57 for (let row = 0; row < n / numCols; row++) {
58 const offset = row * numCols;
59 for (let j = 0; j < numCols; j++) {
60 padPerCol[j] = Math.max(
61 padPerCol[j],
62 valToString(valuesOrTuples[offset + j], 0, dtype).length);
63 }
64 }
65 }
66 return padPerCol;
67}
68
69function valToString(
70 val: number|string|[number, number], pad: number, dtype: DataType) {

Callers 1

tensorToStringFunction · 0.85

Calls 4

sizeFromShapeFunction · 0.90
createComplexTuplesFunction · 0.85
valToStringFunction · 0.85
maxMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…