Skip to content
Closed
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
8 changes: 4 additions & 4 deletions packages/test/src/test/ai-provider-hft/HFT_Device.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ describe("resolveHftPipelineDevice", () => {
expect(resolveHftPipelineDevice("auto")).toBe("auto");
expect(resolveHftPipelineDevice("cpu")).toBe("cpu");
expect(resolveHftPipelineDevice("gpu")).toBe("gpu");
expect(resolveHftPipelineDevice(undefined)).toBeUndefined();
expect(resolveHftPipelineDevice(undefined)).toBe("auto");
});

it("strips browser-only devices on the server", () => {
expect(resolveHftPipelineDevice("webgpu")).toBeUndefined();
expect(resolveHftPipelineDevice("wasm")).toBeUndefined();
it("normalizes browser-only devices to auto on the server", () => {
expect(resolveHftPipelineDevice("webgpu")).toBe("auto");
expect(resolveHftPipelineDevice("wasm")).toBe("auto");
});

it("defaults auto to WebGPU in the browser", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export function isHftBrowserEnv(): boolean {
* Resolve the stored high-level HFT device into the concrete value passed to transformers.js.
*
* Browser builds only accept `wasm` or `webgpu`; `auto` is our cross-platform
* stored default, and should prefer WebGPU in the browser.
* stored default, and should prefer WebGPU in the browser. On the server,
* missing/browser-only inputs normalize to `"auto"`, which transformers.js
* delegates to onnxruntime-node for EP auto-selection.
*/
export function resolveHftPipelineDevice(raw: string | undefined): string {
if (isHftBrowserEnv()) {
Expand Down
Loading