Skip to content
Open
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
2 changes: 1 addition & 1 deletion sdk_v2/js/script/install.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const CORE_FEED = useNightly ? ORT_NIGHTLY_FEED : NUGET_FEED;
const ARTIFACTS = [
{
name: useWinML ? 'Microsoft.AI.Foundry.Local.Core.WinML' : 'Microsoft.AI.Foundry.Local.Core',
version: useNightly ? undefined : useWinML ? '0.9.0.7-dev.20260209T090407.b5352143' : '0.9.0.8-dev.20260209T090216.b5352143', // Set later using resolveLatestVersion if undefined
version: useNightly ? undefined : useWinML ? '0.9.0.170-dev-20260219T211559-2c971802' : '0.9.0.8-dev.20260209T090216.b5352143', // Set later using resolveLatestVersion if undefined
feed: ORT_NIGHTLY_FEED
},
{
Expand Down
38 changes: 38 additions & 0 deletions sdk_v2/js/src/detail/coreInterop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,44 @@ export class CoreInterop {
if (process.platform === 'win32') {
koffi.load(path.join(coreDir, `onnxruntime${ext}`));
koffi.load(path.join(coreDir, `onnxruntime-genai${ext}`));

// Load WinML libraries only if they exist (needed for NPU execution providers)
const winAppRuntimePath = path.join(coreDir, `Microsoft.WindowsAppRuntime${ext}`);
if (fs.existsSync(winAppRuntimePath)) {
koffi.load(winAppRuntimePath);
} else {
console.warn(`Microsoft.WindowsAppRuntime${ext} not found at ${winAppRuntimePath}, NPU execution providers may not be available`);
}

const winAIMachineLearningPath = path.join(coreDir, `Microsoft.Windows.AI.MachineLearning${ext}`);
if (fs.existsSync(winAIMachineLearningPath)) {
koffi.load(winAIMachineLearningPath);
} else {
console.warn(`Microsoft.Windows.AI.MachineLearning${ext} not found at ${winAIMachineLearningPath}, NPU execution providers may not be available`);
}

// Initialize the Windows App SDK bootstrapper so WinRT APIs (e.g. ExecutionProviderCatalog)
// can discover and download NPU execution providers.
const bootstrapPath = path.join(coreDir, 'Microsoft.WindowsAppRuntime.Bootstrap.dll');
if (fs.existsSync(bootstrapPath)) {
const bootstrapLib = koffi.load(bootstrapPath);
const MddBootstrapInitialize2 = bootstrapLib.func(
'int32_t MddBootstrapInitialize2(uint32_t majorMinorVersion, str16 versionTag, uint64_t minVersion, uint32_t options)'
);

// Windows App SDK 1.8 → major=1, minor=8 → 0x00010008
const majorMinorVersion = 0x00010008;
const versionTag = null; // no tag
const minVersion = 0n; // accept any minimum version (BigInt for uint64)
const options = 0; // MddBootstrapInitializeOptions::None

const hr = MddBootstrapInitialize2(majorMinorVersion, versionTag, minVersion, options);
if (hr !== 0) {
console.warn(`MddBootstrapInitialize2 failed with HRESULT: 0x${(hr >>> 0).toString(16)}`);
}
} else {
console.warn(`Microsoft.WindowsAppRuntime.Bootstrap.dll not found at ${bootstrapPath}, NPU execution providers may not be available`);
}
}
this.lib = koffi.load(corePath);

Expand Down
Loading