-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor f16tof32GPU into an npm package, load it from unpkg
- Loading branch information
Showing
2 changed files
with
5 additions
and
75 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
|
||
|
@@ -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; | ||
|