(state: IProgramState)
| 323 | } |
| 324 | |
| 325 | function renderOutputAtBottom(state: IProgramState) { |
| 326 | let layout = state.layout; |
| 327 | |
| 328 | let softmax = layout.logitsSoftmax; |
| 329 | |
| 330 | |
| 331 | let topMid = new Vec3(softmax.x + softmax.dx/2, softmax.y + softmax.dy + layout.margin); |
| 332 | |
| 333 | let outCellH = 10; |
| 334 | let outCellW = 6; |
| 335 | |
| 336 | let nCells = layout.shape.T; |
| 337 | let tl = new Vec3(topMid.x - outCellW * nCells / 2, topMid.y); |
| 338 | let br = new Vec3(topMid.x + outCellW * nCells / 2, topMid.y + outCellH); |
| 339 | |
| 340 | let lineOpts = makeLineOpts({ color: Vec4.fromHexColor("#000000", 0.2), mtx: new Mat4f(), thick: 1.5 }); |
| 341 | |
| 342 | renderOutputBoxes(state, layout, tl, br, outCellW, 4, lineOpts, { boldLast: true, tokMixes: state.display.tokenOutputColors }); |
| 343 | |
| 344 | for (let i = 0; i < nCells; i++) { |
| 345 | let tx = cellPosition(layout, softmax, Dim.X, i) + 0.5 * layout.cell; |
| 346 | let ty = softmax.y + softmax.dy + 0.5 * layout.cell; |
| 347 | let bx = tl.x + (i + 0.5) * outCellW; |
| 348 | let by = tl.y - layout.cell; |
| 349 | |
| 350 | let midY1 = lerp(ty, by, 1/6); |
| 351 | let midY2 = lerp(ty, by, 3/4); |
| 352 | |
| 353 | drawLine(state.render.lineRender, new Vec3(tx, ty), new Vec3(tx, midY1), lineOpts); |
| 354 | drawLine(state.render.lineRender, new Vec3(tx, midY1), new Vec3(bx, midY2), lineOpts); |
| 355 | drawLine(state.render.lineRender, new Vec3(bx, midY2), new Vec3(bx, by), lineOpts); |
| 356 | |
| 357 | let arrLen = 0.6; |
| 358 | let arrowLeft = new Vec3(bx - arrLen, by - arrLen); |
| 359 | let arrowRight = new Vec3(bx + arrLen, by - arrLen); |
| 360 | drawLine(state.render.lineRender, arrowLeft, new Vec3(bx, by), lineOpts); |
| 361 | drawLine(state.render.lineRender, arrowRight, new Vec3(bx, by), lineOpts); |
| 362 | } |
| 363 | |
| 364 | } |
no test coverage detected