Conversation
…pdate API surface The W3C WebNN CRD removed MLDeviceType (cpu/gpu/npu) in PR #809 to simplify device selection. Replace all deviceType references with the current API: - MLContextOptions now has powerPreference and accelerated (boolean, default true) - MLContext gains a readonly accelerated attribute - Add destroy() method documentation for MLContext, MLGraph, MLTensor - Add readTensor(tensor, outputData) overload for reading into existing buffers - Add createContext(gpuDevice: GPUDevice) WebGPU interop overload - Note that builder.build() can only be called once per builder Files changed: - references/webnn-reference.md: reflect current spec API surface - references/compatibility.md: replace cpu/gpu/npu guidance with accelerated+powerPreference - references/examples.md: update examples to use new context options - references/troubleshooting.md: update createContext failure guidance - SKILL.md: replace deviceType guidance with accelerated+powerPreference - assets/webnn-runtime.template.ts: remove WebNNDeviceType, add accelerated field Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The W3C WebNN Candidate Recommendation (CRD) removed
MLDeviceType(the"cpu" | "gpu" | "npu"enumeration) in PR #809 to simplify device selection. The current skill still referenceddeviceTypethroughout. This PR brings the skill in line with the current specification.Material Changes
MLDeviceTyperemoved ([spec §8.2]((www.w3.org/redacted), PR #809)MLContextOptionsno longer hasdeviceType. It now has:powerPreference:"default"|"high-performance"|"low-power"(unchanged)accelerated:boolean(defaulttrue) — replaces device-type enumeration;trueallows GPU/NPU hardware,falserequests CPU inferenceMLContext.accelerated— new read-only attribute reflecting actual acceleration state ([spec §8.3]((www.w3.org/redacted)deviceType: "cpu"/"gpu"/"npu"patterns must migrate toaccelerated+powerPreferenceAdditional spec surface now documented ([spec §8.3]((www.w3.org/redacted)
destroy()methods onMLContext,MLGraph, andMLTensor([spec §8.3.8]((www.w3.org/redacted), [§8.4.1]((www.w3.org/redacted), [§8.8.2]((www.w3.org/redacted) — template already used these; references now document them explicitlyreadTensor(tensor, outputData)overload ([spec §8.3]((www.w3.org/redacted) — reads into an existingAllowSharedBufferSourceinstead of returning a newArrayBuffercreateContext(gpuDevice: GPUDevice)overload ([spec §8.2.2]((www.w3.org/redacted) — creates a WebGPU-interop contextMLGraphBuilder.build()single-invocation restriction (spec PR #717)build()can only be called once per builder — noted inwebnn-reference.mdFiles Changed
skills/webnn/SKILL.mddeviceTypeguidance withaccelerated/powerPreference; update error handling and validation stepsskills/webnn/references/webnn-reference.mdaccelerated,destroy(),readTensoroverload,createContext(gpuDevice), deprecation note onMLDeviceTypeskills/webnn/references/compatibility.mdcpu/gpu/npudevice selection guidance withaccelerated+powerPreferencetable; add migration noteskills/webnn/references/examples.mdcreateContextcall to usepowerPreference: "high-performance"instead ofdeviceType: "gpu"skills/webnn/references/troubleshooting.mdgpuornpucontext failure text with accelerated/high-performance wordingskills/webnn/assets/webnn-runtime.template.tsWebNNDeviceType; replacedeviceTypefield withaccelerated: booleaninWebNNContextOptionsandnormalizedOptionsValidation
python .github/skills/skill-creator/scripts/validate-metadata.py --name "webnn" --description "..."→SUCCESS: Metadata is valid and optimized for discovery.deviceType,MLDeviceType, or"cpu"/"gpu"/"npu"device-type strings in the skill directorySource Citations per Update
Each update traces to its authoritative source:
MLDeviceTyperemoval: [(www.w3.org/redacted)(www.w3.org/redacted) and PR #809acceleratedoption: [(www.w3.org/redacted)(www.w3.org/redacted)MLContext.acceleratedattribute: [(www.w3.org/redacted)(www.w3.org/redacted)destroy()methods: [(www.w3.org/redacted)(www.w3.org/redacted), [#api-mlgraph-destroy]((www.w3.org/redacted), [#api-mltensor-destroy]((www.w3.org/redacted)readTensor(tensor, outputData)overload: [(www.w3.org/redacted)(www.w3.org/redacted)createContext(gpuDevice): [(www.w3.org/redacted)(www.w3.org/redacted)build()single-invocation: Allow MLGraphBuilder.build() to be called only once webmachinelearning/webnn#717Remaining Risks
deviceTypein their shipped versions (Chromium 112–131 era). Thecompatibility.mdmigration note covers this. The skill now correctly reflects what the spec defines, not historical implementation behavior.