chore: update node_modules with new binary files and dependencies
- Add new binary files for nodemon, onnxruntime-web, and xenova/transformers - Update various JavaScript and TypeScript files in node_modules - Remove unused files and dependencies - Add new test fixtures and documentation files
This commit is contained in:
71
node_modules/onnxruntime-node/lib/backend.ts
generated
vendored
Normal file
71
node_modules/onnxruntime-node/lib/backend.ts
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import {Backend, InferenceSession, SessionHandler} from 'onnxruntime-common';
|
||||
|
||||
import {Binding, binding} from './binding';
|
||||
|
||||
class OnnxruntimeSessionHandler implements SessionHandler {
|
||||
#inferenceSession: Binding.InferenceSession;
|
||||
|
||||
constructor(pathOrBuffer: string|Uint8Array, options: InferenceSession.SessionOptions) {
|
||||
this.#inferenceSession = new binding.InferenceSession();
|
||||
if (typeof pathOrBuffer === 'string') {
|
||||
this.#inferenceSession.loadModel(pathOrBuffer, options);
|
||||
} else {
|
||||
this.#inferenceSession.loadModel(pathOrBuffer.buffer, pathOrBuffer.byteOffset, pathOrBuffer.byteLength, options);
|
||||
}
|
||||
this.inputNames = this.#inferenceSession.inputNames;
|
||||
this.outputNames = this.#inferenceSession.outputNames;
|
||||
}
|
||||
|
||||
async dispose(): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
readonly inputNames: string[];
|
||||
readonly outputNames: string[];
|
||||
|
||||
startProfiling(): void {
|
||||
// TODO: implement profiling
|
||||
}
|
||||
endProfiling(): void {
|
||||
// TODO: implement profiling
|
||||
}
|
||||
|
||||
async run(feeds: SessionHandler.FeedsType, fetches: SessionHandler.FetchesType, options: InferenceSession.RunOptions):
|
||||
Promise<SessionHandler.ReturnType> {
|
||||
return new Promise((resolve, reject) => {
|
||||
process.nextTick(() => {
|
||||
try {
|
||||
resolve(this.#inferenceSession.run(feeds, fetches, options));
|
||||
} catch (e) {
|
||||
// reject if any error is thrown
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class OnnxruntimeBackend implements Backend {
|
||||
async init(): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
async createSessionHandler(pathOrBuffer: string|Uint8Array, options?: InferenceSession.SessionOptions):
|
||||
Promise<SessionHandler> {
|
||||
return new Promise((resolve, reject) => {
|
||||
process.nextTick(() => {
|
||||
try {
|
||||
resolve(new OnnxruntimeSessionHandler(pathOrBuffer, options || {}));
|
||||
} catch (e) {
|
||||
// reject if any error is thrown
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const onnxruntimeBackend = new OnnxruntimeBackend();
|
||||
43
node_modules/onnxruntime-node/lib/binding.ts
generated
vendored
Normal file
43
node_modules/onnxruntime-node/lib/binding.ts
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import {InferenceSession, OnnxValue} from 'onnxruntime-common';
|
||||
|
||||
type SessionOptions = InferenceSession.SessionOptions;
|
||||
type FeedsType = {
|
||||
[name: string]: OnnxValue;
|
||||
};
|
||||
type FetchesType = {
|
||||
[name: string]: OnnxValue|null;
|
||||
};
|
||||
type ReturnType = {
|
||||
[name: string]: OnnxValue;
|
||||
};
|
||||
type RunOptions = InferenceSession.RunOptions;
|
||||
|
||||
|
||||
/**
|
||||
* Binding exports a simple synchronized inference session object wrap.
|
||||
*/
|
||||
export declare namespace Binding {
|
||||
export interface InferenceSession {
|
||||
loadModel(modelPath: string, options: SessionOptions): void;
|
||||
loadModel(buffer: ArrayBuffer, byteOffset: number, byteLength: number, options: SessionOptions): void;
|
||||
|
||||
readonly inputNames: string[];
|
||||
readonly outputNames: string[];
|
||||
|
||||
run(feeds: FeedsType, fetches: FetchesType, options: RunOptions): ReturnType;
|
||||
}
|
||||
|
||||
export interface InferenceSessionConstructor {
|
||||
new(): InferenceSession;
|
||||
}
|
||||
}
|
||||
|
||||
// export native binding
|
||||
export const binding =
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
||||
require(`../bin/napi-v3/${process.platform}/${process.arch}/onnxruntime_binding.node`) as
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
{InferenceSession: Binding.InferenceSessionConstructor};
|
||||
8
node_modules/onnxruntime-node/lib/index.ts
generated
vendored
Normal file
8
node_modules/onnxruntime-node/lib/index.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
export * from 'onnxruntime-common';
|
||||
import {registerBackend} from 'onnxruntime-common';
|
||||
import {onnxruntimeBackend} from './backend';
|
||||
|
||||
registerBackend('cpu', onnxruntimeBackend, 100);
|
||||
Reference in New Issue
Block a user