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

Function tensorToString

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

Source from the content-addressed store, hash-verified

26const FORMAT_NUM_SIG_DIGITS = 7;
27
28export function tensorToString(
29 vals: TypedArray|string[], shape: number[], dtype: DataType,
30 verbose: boolean) {
31 const strides = computeStrides(shape);
32 const padPerCol = computeMaxSizePerColumn(vals, shape, dtype, strides);
33 const rank = shape.length;
34 const valsLines = subTensorToString(vals, shape, dtype, strides, padPerCol);
35 const lines = ['Tensor'];
36 if (verbose) {
37 lines.push(` dtype: ${dtype}`);
38 lines.push(` rank: ${rank}`);
39 lines.push(` shape: [${shape}]`);
40 lines.push(` values:`);
41 }
42 lines.push(valsLines.map(l => ' ' + l).join('\n'));
43 return lines.join('\n');
44}
45
46function computeMaxSizePerColumn(
47 vals: TypedArray|string[], shape: number[], dtype: DataType,

Callers 1

toStringMethod · 0.90

Calls 5

computeStridesFunction · 0.90
computeMaxSizePerColumnFunction · 0.85
subTensorToStringFunction · 0.85
joinMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…