mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-26 19:52:38 +00:00
[WebNN] Fixed WebNN Module undefined issue (#22795)
`Module.jsepRegisterMLConstant` will be shorten by Closure Compiler in offical release, this would cause undefined error. Fix it by using `Module['jsepRegisterMLConstant']`.
This commit is contained in:
parent
0ad44d0f79
commit
cdc8db9984
3 changed files with 19 additions and 2 deletions
|
|
@ -226,7 +226,7 @@ export class WebNNBackend {
|
|||
return id;
|
||||
}
|
||||
|
||||
// Register WebNN Constant operands from external data.
|
||||
// Register a WebNN Constant operand from external data.
|
||||
public registerMLConstant(
|
||||
externalFilePath: string,
|
||||
dataOffset: number,
|
||||
|
|
|
|||
|
|
@ -232,6 +232,23 @@ export declare namespace JSEP {
|
|||
* @returns
|
||||
*/
|
||||
jsepCreateMLContext(optionsOrGpuDevice?: MLContextOptions | GPUDevice): Promise<MLContext>;
|
||||
|
||||
/**
|
||||
* [exported from pre-jsep.js] Register a WebNN Constant operand from external data.
|
||||
* @param externalFilePath - specify the external file path.
|
||||
* @param dataOffset - specify the external data offset.
|
||||
* @param dataLength - specify the external data length.
|
||||
* @param builder - specify the MLGraphBuilder used for constructing the Constant.
|
||||
* @param desc - specify the MLOperandDescriptor of the Constant.
|
||||
* @returns the WebNN Constant operand for the specified external data.
|
||||
*/
|
||||
jsepRegisterMLConstant(
|
||||
externalFilePath: string,
|
||||
dataOffset: number,
|
||||
dataLength: number,
|
||||
builder: MLGraphBuilder,
|
||||
desc: MLOperandDescriptor,
|
||||
): MLOperand;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ Module['jsepInit'] = (name, params) => {
|
|||
Module['jsepCreateMLContext'] = (optionsOrGpuDevice) => {
|
||||
return backend['createMLContext'](optionsOrGpuDevice);
|
||||
};
|
||||
Module.jsepRegisterMLConstant = (externalFilePath, dataOffset, dataLength, builder, desc) => {
|
||||
Module['jsepRegisterMLConstant'] = (externalFilePath, dataOffset, dataLength, builder, desc) => {
|
||||
return backend['registerMLConstant'](
|
||||
externalFilePath, dataOffset, dataLength, builder, desc, Module.MountedFiles);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue