(embdOutputBuffer, posEmbdOutputBuffer, embdBuffers, posEmbdBuffer, idx, seq_length, n_embd, vocab_chunk_size)
| 755 | } |
| 756 | |
| 757 | staticLoad(embdOutputBuffer, posEmbdOutputBuffer, embdBuffers, posEmbdBuffer, idx, seq_length, n_embd, vocab_chunk_size) { |
| 758 | // Can build a cache later. |
| 759 | const embdCopyCommands = Array(seq_length) |
| 760 | .fill() |
| 761 | .map((_, i) => { |
| 762 | const chunkOffset = Math.floor(idx[i] / vocab_chunk_size); |
| 763 | const chunkIdx = idx[i] % vocab_chunk_size; |
| 764 | |
| 765 | return { |
| 766 | flag: "copy", |
| 767 | src: embdBuffers[chunkOffset], |
| 768 | srcOffset: this.bufferSize(n_embd) * chunkIdx, |
| 769 | dst: embdOutputBuffer, |
| 770 | dstOffset: this.bufferSize(n_embd) * i, |
| 771 | size: this.bufferSize(n_embd), |
| 772 | }; |
| 773 | }); |
| 774 | |
| 775 | // Also can be cached. |
| 776 | const posCopyCommand = { |
| 777 | flag: "copy", |
| 778 | src: posEmbdBuffer, |
| 779 | srcOffset: 0, |
| 780 | dst: posEmbdOutputBuffer, |
| 781 | dstOffset: 0, |
| 782 | size: this.bufferSize(seq_length, n_embd), |
| 783 | }; |
| 784 | |
| 785 | return { |
| 786 | passes: [...embdCopyCommands, posCopyCommand], |
| 787 | }; |
| 788 | } |
| 789 | |
| 790 | newInstance(idx, seq_length, n_embd, vocab_chunk_size, embdBuffers, posEmbdBuffer, ResidualBlock) { |
| 791 | const embdOutputBuffer = this.initBuffer(["storage", "copy_to"], [seq_length, n_embd]); |
nothing calls this directly
no test coverage detected