(
val: TensorLike, shape: number[], indices: number[])
| 55 | } |
| 56 | |
| 57 | function deepAssertShapeConsistency( |
| 58 | val: TensorLike, shape: number[], indices: number[]) { |
| 59 | indices = indices || []; |
| 60 | if (!(Array.isArray(val)) && !isTypedArray(val)) { |
| 61 | assert( |
| 62 | shape.length === 0, |
| 63 | () => `Element arr[${indices.join('][')}] is a primitive, ` + |
| 64 | `but should be an array/TypedArray of ${shape[0]} elements`); |
| 65 | return; |
| 66 | } |
| 67 | assert( |
| 68 | shape.length > 0, |
| 69 | () => `Element arr[${indices.join('][')}] should be a primitive, ` + |
| 70 | `but is an array of ${val.length} elements`); |
| 71 | assert( |
| 72 | val.length === shape[0], |
| 73 | () => `Element arr[${indices.join('][')}] should have ${shape[0]} ` + |
| 74 | `elements, but has ${val.length} elements`); |
| 75 | const subShape = shape.slice(1); |
| 76 | for (let i = 0; i < val.length; ++i) { |
| 77 | deepAssertShapeConsistency(val[i], subShape, indices.concat(i)); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | function assertDtype( |
| 82 | expectedDtype: DataType|'numeric'|'string_or_numeric', |
no test coverage detected
searching dependent graphs…