onnxruntime/js/common/lib/backend.ts
Yulong Wang 4ebc9c3b5e
[JS] onnxruntime-web (#7394)
* add web

* add script and test

* fix lint

* add test/data/ops

* add test/data/node/ to gitignore

* modify scripts

* add onnxjs

* fix tests

* fix test-runner

* fix sourcemap

* fix onnxjs profiling

* update test list

* update README

* resolve comments

* set wasm as default backend

* rename package

* update copyright header

* do not use class "Buffer" in browser context

* revise readme
2021-04-27 00:04:25 -07:00

42 lines
1.2 KiB
TypeScript

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import {InferenceSession} from './inference-session';
import {OnnxValue} from './onnx-value';
export declare namespace SessionHandler {
type FeedsType = {[name: string]: OnnxValue};
type FetchesType = {[name: string]: OnnxValue | null};
type ReturnType = {[name: string]: OnnxValue};
}
/**
* Represent a handler instance of an inference session.
*/
export interface SessionHandler {
dispose(): Promise<void>;
readonly inputNames: readonly string[];
readonly outputNames: readonly string[];
startProfiling(): void;
endProfiling(): void;
run(feeds: SessionHandler.FeedsType, fetches: SessionHandler.FetchesType,
options: InferenceSession.RunOptions): Promise<SessionHandler.ReturnType>;
}
/**
* Represent a backend that provides implementation of model inferencing.
*/
export interface Backend {
/**
* Initialize the backend asynchronously. Should throw when failed.
*/
init(): Promise<void>;
createSessionHandler(uriOrBuffer: string|Uint8Array, options?: InferenceSession.SessionOptions):
Promise<SessionHandler>;
}
export {registerBackend} from './backend-impl';