mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
[WebNN] Fix MLTensorUsage is undefined issue (#22831)
`MLTensorUsage` has been removed from Chromium: https://chromium-review.googlesource.com/c/chromium/src/+/6015318, but we still need to make it compatible with old Chrome versions, so just make it `undefined` for latest Chrome version.
This commit is contained in:
parent
f423b737a9
commit
82681205e4
3 changed files with 6 additions and 5 deletions
|
|
@ -195,7 +195,7 @@ class TensorIdTracker {
|
|||
}
|
||||
|
||||
// eslint-disable-next-line no-bitwise
|
||||
const usage = MLTensorUsage.READ | MLTensorUsage.WRITE;
|
||||
const usage = typeof MLTensorUsage == 'undefined' ? undefined : MLTensorUsage.READ | MLTensorUsage.WRITE;
|
||||
this.wrapper = await this.tensorManager.getCachedTensor(dataType, shape, usage, true, true);
|
||||
|
||||
if (copyOld && this.activeUpload) {
|
||||
|
|
@ -349,7 +349,7 @@ class TensorManagerImpl implements TensorManager {
|
|||
public async getCachedTensor(
|
||||
dataType: MLOperandDataType,
|
||||
shape: readonly number[],
|
||||
usage: MLTensorUsageFlags,
|
||||
usage: MLTensorUsageFlags | undefined,
|
||||
writable: boolean,
|
||||
readable: boolean,
|
||||
): Promise<TensorWrapper> {
|
||||
|
|
|
|||
3
js/web/lib/wasm/jsep/webnn/webnn.d.ts
vendored
3
js/web/lib/wasm/jsep/webnn/webnn.d.ts
vendored
|
|
@ -400,7 +400,8 @@ declare const MLTensorUsage: {
|
|||
};
|
||||
|
||||
interface MLTensorDescriptor extends MLOperandDescriptor {
|
||||
usage: MLTensorUsageFlags;
|
||||
/** @deprecated Use readable/writeable instead of usage */
|
||||
usage: MLTensorUsageFlags | undefined;
|
||||
importableToWebGPU?: boolean;
|
||||
readable?: boolean;
|
||||
writable?: boolean;
|
||||
|
|
|
|||
|
|
@ -661,7 +661,7 @@ async function createMLTensorForOutput(mlContext: MLContext, type: ort.Tensor.Ty
|
|||
shape: dims as number[],
|
||||
// Assign both shape and dimensions while transitioning to new API.
|
||||
dimensions: dims as number[],
|
||||
usage: MLTensorUsage.READ,
|
||||
usage: typeof MLTensorUsage == 'undefined' ? undefined : MLTensorUsage.READ,
|
||||
readable: true,
|
||||
});
|
||||
|
||||
|
|
@ -686,7 +686,7 @@ async function createMLTensorForInput(mlContext: MLContext, cpuTensor: ort.Tenso
|
|||
shape: cpuTensor.dims as number[],
|
||||
// Assign both shape and dimensions while transitioning to new API.
|
||||
dimensions: cpuTensor.dims as number[],
|
||||
usage: MLTensorUsage.WRITE,
|
||||
usage: typeof MLTensorUsage == 'undefined' ? undefined : MLTensorUsage.WRITE,
|
||||
writable: true,
|
||||
});
|
||||
mlContext.writeTensor(mlTensor, cpuTensor.data);
|
||||
|
|
|
|||
Loading…
Reference in a new issue