mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-29 20:14:01 +00:00
[WebNN EP] Fixed bug in usage of Array.reduce() (#22944)
In JS, reduce of empty array with no initial value will throw error. Fix it by checking the array length firstly.
This commit is contained in:
parent
c284a686f2
commit
fe749a88a5
1 changed files with 1 additions and 1 deletions
|
|
@ -78,7 +78,7 @@ const calculateByteLength = (dataType: MLOperandDataType, shape: readonly number
|
|||
if (!size) {
|
||||
throw new Error('Unsupported data type.');
|
||||
}
|
||||
return Math.ceil((shape.reduce((a, b) => a * b) * size) / 8);
|
||||
return shape.length > 0 ? Math.ceil((shape.reduce((a, b) => a * b) * size) / 8) : 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue