Skip to content

Commit

Permalink
Fix the netInstance.dispose is not a function issue (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibelem committed Mar 27, 2024
1 parent abbdf25 commit 692b921
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions image_classification/resnet50v2_nchw.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ export class ResNet50V2Nchw {
this.graph_ = this.builder_.build({'output': outputOperand});
}

// Release the constant tensors of a model
dispose() {
// dispose() is only available in webnn-polyfill
if (this.graph_ !== null && 'dispose' in this.graph_) {
this.graph_.dispose();
}
}

// Release the constant tensors of a model
async compute(inputBuffer, outputBuffer) {
const inputs = {'input': inputBuffer};
Expand Down
8 changes: 8 additions & 0 deletions image_classification/resnet50v2_nhwc.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ export class ResNet50V2Nhwc {
this.graph_ = this.builder_.build({'output': outputOperand});
}

// Release the constant tensors of a model
dispose() {
// dispose() is only available in webnn-polyfill
if (this.graph_ !== null && 'dispose' in this.graph_) {
this.graph_.dispose();
}
}

// Release the constant tensors of a model
async compute(inputBuffer, outputBuffer) {
const inputs = {'input': inputBuffer};
Expand Down

0 comments on commit 692b921

Please sign in to comment.