Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions tfjs-backend-wasm/scripts/create-worker-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,15 @@
*/

/**
* This file creates a TypeScript module that exports the contents of the
* Emscripten-generated WASM worker script so that it can be inlined by the
* tf-backend-wasm bundle.
* This file modifies the Emscripten-generated WASM worker script so that it can
* be inlined by the tf-backend-wasm bundle.
*/

const fs = require('fs');

const BASE_PATH = './wasm-out/';
const WORKER_PATH = `${BASE_PATH}tfjs-backend-wasm-threaded-simd.worker.js`;

// Write out a worker TypeScript module.
const workerContents = fs.readFileSync(WORKER_PATH, "utf8");
fs.writeFileSync(`${BASE_PATH}tfjs-backend-wasm-threaded-simd.worker.ts`,
fs.writeFileSync(`${WORKER_PATH}`,
`export const wasmWorkerContents = '${workerContents.trim()}';`);

// Delete the original worker file.
fs.unlinkSync(WORKER_PATH)
2 changes: 1 addition & 1 deletion tfjs-backend-wasm/src/backend_wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {backend_util, BackendTimingInfo, DataStorage, DataType, deprecationWarn,
import {BackendWasmModule, WasmFactoryConfig} from '../wasm-out/tfjs-backend-wasm';
import wasmFactoryThreadedSimd from '../wasm-out/tfjs-backend-wasm-threaded-simd.js';
// @ts-ignore
import {wasmWorkerContents} from '../wasm-out/tfjs-backend-wasm-threaded-simd.worker';
import {wasmWorkerContents} from '../wasm-out/tfjs-backend-wasm-threaded-simd.worker.js';
import wasmFactory from '../wasm-out/tfjs-backend-wasm.js';

const WASM_PRIORITY = 2;
Expand Down