Skip to content

Commit

Permalink
Refactor f16tof32GPU into an npm package, load it from unpkg
Browse files Browse the repository at this point in the history
  • Loading branch information
wpmed92 committed Dec 10, 2023
1 parent 8700a2b commit 5ae9c12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 75 deletions.
64 changes: 0 additions & 64 deletions f16_to_f32.js

This file was deleted.

16 changes: 5 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@
import ClipTokenizer from 'https://softwired.nyc3.cdn.digitaloceanspaces.com/sd/clip_tokenizer.js';
window.clipTokenizer = new ClipTokenizer();
</script>
<script src="./f16_to_f32.js"></script>
<script type="module">
import { f16tof32GPU } from 'https://unpkg.com/[email protected]/src/index.js';
window.f16tof32GPU = f16tof32GPU;
</script>
<script src="./net.js"></script>
</head>

Expand Down Expand Up @@ -351,16 +354,7 @@ <h1 id="sdTitle">StableDiffusion by <a href="https://github.com/tinygrad/tinygra
let chunkStartF16 = 8 + metadataLength + (decodeChunkSize * i);
let chunkEndF16 = chunkStartF16 + decodeChunkSize;
let chunk = combinedBuffer.subarray(chunkStartF16, chunkEndF16);

if (chunk.byteLength %4 != 0) {
const paddingBytes = 4 - (chunk.byteLength % 4);
const alignedBuffer = new ArrayBuffer(chunk.byteLength + paddingBytes);
const alignedView = new Uint8Array(alignedBuffer);
alignedView.set(new Uint8Array(chunk));
chunk = alignedView;
}

let result = await f16tof32GPU(device, chunk);
let result = await f16tof32GPU(chunk);
let resultUint8 = new Uint8Array(result.buffer);
let chunkStartF32 = 8 + metadataLength + (decodeChunkSize * i * 2);
let chunkEndF32 = chunkStartF32 + resultUint8.byteLength;
Expand Down

0 comments on commit 5ae9c12

Please sign in to comment.