onnxruntime/nodejs/lib/binding.ts
Yulong Wang 65bfece19d
[Node.js API] optimize prebuild (#3844)
* optimize prebuild

* fix base folder for prepack

* bump dev version
2020-05-06 15:48:13 -07:00

40 lines
1.5 KiB
TypeScript

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import {InferenceSession as InferenceSessionInterface} from './inference-session';
import {OnnxValue} from './onnx-value';
/**
* Binding exports a simple synchronized inference session object wrap.
*/
export declare namespace Binding {
export interface InferenceSession {
loadModel(modelPath: string, options: InferenceSessionInterface.SessionOptions): void;
loadModel(
buffer: ArrayBuffer, byteOffset: number, byteLength: number,
options: InferenceSessionInterface.SessionOptions): void;
readonly inputNames: string[];
readonly outputNames: string[];
run(feeds: InferenceSession.FeedsType, fetches: InferenceSession.FetchesType,
options: InferenceSession.RunOptions): InferenceSession.ReturnType;
}
export namespace InferenceSession {
type FeedsType = {[name: string]: OnnxValue};
type FetchesType = {[name: string]: OnnxValue | null};
type ReturnType = {[name: string]: OnnxValue};
type RunOptions = InferenceSessionInterface.RunOptions;
}
export interface InferenceSessionConstructor {
new(): InferenceSession;
}
}
// export native binding
export const binding =
// eslint-disable-next-line @typescript-eslint/no-require-imports, import/no-internal-modules
require(`../bin/napi-v3/${process.platform}/${process.arch}/onnxruntime_binding.node`) as
{InferenceSession: Binding.InferenceSessionConstructor};