-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
When converting ONNX transformer models like all-MiniLM-L6-v2 to WebNN graph builder JS code,
we discovered that some special case handling is required due to API design mismatches between
ONNX semantics and WebNN API conventions. For example:
- WebNN spec requires lowercase type names, but generated intermediate representations often use capitalized forms (Impact cast, constant ops):
// Required by WebNN
"float32", "float16", "int32"
// Generated from AST
"Float32", "Float16", "Int32"
- WebNN doesn't support negative axis indices, but ONNX commonly uses them (Impact concat, split, gather, reduceMean, reduceSum, softmax, layerNormalization ops):
# ONNX semantics
axis = -1 # means "last dimension"
# Must convert to WebNN
axis = rank - 1 # explicit positive index
- For
sliceoperation we must computesizes = ends - startsand expand sparse axes to full rank:
// ONNX: starts, ends, steps, axes (sparse - only specified dims)
slice(input, starts=[0], ends=[128], axes=[1])
// WebNN: starts, sizes, strides (dense - all dims required)
slice(input, [0,0], [1,128], {strides: [1,1]})
- For
constantoperation we need detect base64 encoded data and addsatob()to decode it into an ArrayBuffer.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels