(encoded, shape)
| 744 | } |
| 745 | |
| 746 | function decodeWeightMatrix(encoded, shape) { |
| 747 | const rows = Math.max(0, Number(shape?.[0]) || 0); |
| 748 | const cols = Math.max(0, Number(shape?.[1]) || 0); |
| 749 | if (rows === 0 || cols === 0) { |
| 750 | return []; |
| 751 | } |
| 752 | const flat = decodeFloat16Base64(encoded, rows * cols); |
| 753 | const result = []; |
| 754 | for (let row = 0; row < rows; row += 1) { |
| 755 | const start = row * cols; |
| 756 | const end = start + cols; |
| 757 | result.push(flat.slice(start, end)); |
| 758 | } |
| 759 | return result; |
| 760 | } |
| 761 | |
| 762 | function normaliseShape(shape, fallback = []) { |
| 763 | const source = Array.isArray(shape) ? shape : fallback; |
no test coverage detected