(
vals: TypedArray|string[], shape: number[], dtype: DataType,
verbose: boolean)
| 26 | const FORMAT_NUM_SIG_DIGITS = 7; |
| 27 | |
| 28 | export 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 | |
| 46 | function computeMaxSizePerColumn( |
| 47 | vals: TypedArray|string[], shape: number[], dtype: DataType, |
no test coverage detected
searching dependent graphs…