[js] allow manually release inference session (#16169)

### Description
This change adds a new instance function (method) to type
`InferenceSession` to allow users to manually release an inference
session instance.

#16131 depends on this change to work correctly.
This commit is contained in:
Yulong Wang 2023-05-31 00:31:38 -07:00 committed by GitHub
parent 3dc5179a36
commit ba5f5e3198
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -115,6 +115,10 @@ export class InferenceSession implements InferenceSessionInterface {
return returnValue;
}
async release(): Promise<void> {
return this.handler.dispose();
}
static create(path: string, options?: SessionOptions): Promise<InferenceSessionInterface>;
static create(buffer: ArrayBufferLike, options?: SessionOptions): Promise<InferenceSessionInterface>;
static create(buffer: ArrayBufferLike, byteOffset: number, byteLength?: number, options?: SessionOptions):

View file

@ -306,6 +306,15 @@ export interface InferenceSession {
// #endregion
// #region release()
/**
* Release the inference session and the underlying resources.
*/
release(): Promise<void>;
// #endregion
// #region profiling
/**