Fixed for decoder dl speed and mobile warnings on low memory devices.
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
pipeline,
|
||||
WhisperTextStreamer,
|
||||
type AutomaticSpeechRecognitionPipeline,
|
||||
type PretrainedModelOptions,
|
||||
type ProgressInfo,
|
||||
} from "@huggingface/transformers";
|
||||
import { resolveDefaultDtype } from "../lib/models";
|
||||
@@ -256,7 +257,7 @@ async function createPipeline(
|
||||
configureWasmThreads(device);
|
||||
const dtype = message.dtype ?? resolveDefaultDtype(message.modelId, device);
|
||||
try {
|
||||
const asr = await pipeline("automatic-speech-recognition", message.modelId, {
|
||||
const pipelineOptions: PretrainedModelOptions & { sequentialSessionLoad?: boolean } = {
|
||||
device,
|
||||
dtype,
|
||||
// WASM sessions cap graph optimization at "basic" (D-014): the level-2
|
||||
@@ -268,7 +269,12 @@ async function createPipeline(
|
||||
session_options: { graphOptimizationLevel: "basic" as const },
|
||||
}),
|
||||
progress_callback: forwardProgress,
|
||||
});
|
||||
// D-027/D-029: sequential sub-model session loading trades load speed
|
||||
// for a lower peak-memory footprint — only worth it where the UI
|
||||
// determined this load risks crashing a mobile tab.
|
||||
sequentialSessionLoad: message.sequentialSessionLoad ?? false,
|
||||
};
|
||||
const asr = await pipeline("automatic-speech-recognition", message.modelId, pipelineOptions);
|
||||
// What ort actually ended up with (it clamps to 1 without isolation) —
|
||||
// surfaced to the UI so degraded threading is visible in the field.
|
||||
const threads = env.backends.onnx.wasm?.numThreads ?? 1;
|
||||
|
||||
Reference in New Issue
Block a user