Skip to content

Commit

Permalink
enforced that loadParametersBuffer takes in a buffer that matches the…
Browse files Browse the repository at this point in the history
… number of parameters
  • Loading branch information
carzh committed Oct 25, 2023
1 parent c74112e commit cd2e4fa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions js/common/lib/training-session-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ export class TrainingSession implements TrainingSessionInterface {
}

async loadParametersBuffer(array: Float32Array, trainableOnly: boolean): Promise<void> {
const paramsSize = await this.getParametersSize(trainableOnly);
if (array.length !== paramsSize) {
throw new Error('Size of the buffer passed into loadParametersBuffer must match the number of parameters in ' +
'the model. Please use getParametersSize method to check.');
}
return this.handler.loadParametersBuffer(array, trainableOnly);
}

Expand Down

0 comments on commit cd2e4fa

Please sign in to comment.