mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-17 21:10:43 +00:00
### Description * based on design document & following InferenceSession's run implementation, implemented TrainingSession.runTrainStep ### Motivation and Context * Adding web bindings for training #### Related work * #16521 allowed for training artifacts to be built * #17333 added interfaces for training * #17474 allowed for training package to be built + added training backend to web package * #17891 implementation for createTrainingSession on the TypeScript side **[SHOULD BE MERGED IN BEFORE THIS PR]** --------- Co-authored-by: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Co-authored-by: Ashwini Khade <askhade@microsoft.com>
21 lines
1 KiB
TypeScript
21 lines
1 KiB
TypeScript
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
import {InferenceSession, TrainingSessionHandler} from 'onnxruntime-common';
|
|
|
|
import {OnnxruntimeWebAssemblyBackend} from './backend-wasm';
|
|
import {OnnxruntimeWebAssemblyTrainingSessionHandler} from './wasm/session-handler-training';
|
|
|
|
class OnnxruntimeTrainingWebAssemblyBackend extends OnnxruntimeWebAssemblyBackend {
|
|
async createTrainingSessionHandler(
|
|
checkpointStateUriOrBuffer: string|Uint8Array, trainModelUriOrBuffer: string|Uint8Array,
|
|
evalModelUriOrBuffer: string|Uint8Array, optimizerModelUriOrBuffer: string|Uint8Array,
|
|
options: InferenceSession.SessionOptions): Promise<TrainingSessionHandler> {
|
|
const handler = new OnnxruntimeWebAssemblyTrainingSessionHandler();
|
|
await handler.createTrainingSession(
|
|
checkpointStateUriOrBuffer, trainModelUriOrBuffer, evalModelUriOrBuffer, optimizerModelUriOrBuffer, options);
|
|
return Promise.resolve(handler);
|
|
}
|
|
}
|
|
|
|
export const wasmBackend = new OnnxruntimeTrainingWebAssemblyBackend();
|