Skip to content

Commit

Permalink
[web] Export onnxjs graph and onnxproto
Browse files Browse the repository at this point in the history
  • Loading branch information
axinging committed Oct 17, 2023
1 parent 209b6db commit b5d1d4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions js/web/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// So we import code inside the if-clause to allow bundler remove the code safely.

export * from 'onnxruntime-common';
export * from './onnxjs/model';
export * as onnxProto from './onnxjs/ort-schema/protobuf/onnx';
import {registerBackend, env} from 'onnxruntime-common';
import {version} from './version';

Expand Down
6 changes: 6 additions & 0 deletions js/web/lib/onnxjs/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,19 @@ class Node implements Graph.Node {
this.attributes = new Attribute(ProtoUtil.tensorAttributesFromORTFormat(_nodeProto));
}

this.inputNames = [];
this.inputs = [];
this.outputs = [];
this.outputNames = [];
this.executeNode = true;
}

name: string;
opType: string;
inputs: number[];
inputNames: string[];
outputs: number[];
outputNames: string[];
attributes: Attribute;
executeNode: boolean;
}
Expand Down Expand Up @@ -297,6 +301,7 @@ class GraphImpl implements Graph, Graph.Transformer {
dataIndices.set(output, dataIndex);
}
node.outputs.push(dataIndex);
node.outputNames.push(output);

if (this._allData[dataIndex]._from !== undefined) {
throw new Error(`multiple nodes output to one data value: ${dataIndex}`);
Expand Down Expand Up @@ -340,6 +345,7 @@ class GraphImpl implements Graph, Graph.Transformer {
throw new Error(`unrecognized input '${input}' for node: ${nodeProto.name}`);
}
node.inputs.push(dataIndex);
node.inputNames.push(input);

this._allData[dataIndex]._to.push(i);
}
Expand Down

0 comments on commit b5d1d4c

Please sign in to comment.