Skip to content

Commit

Permalink
Add TorchScript test file (#1067)
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Apr 5, 2023
1 parent 0f72f8c commit d9e08c6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
12 changes: 0 additions & 12 deletions source/python.js
Original file line number Diff line number Diff line change
Expand Up @@ -4185,18 +4185,6 @@ python.Execution = class {
this.registerFunction('builtins.uninitialized', function(/* type */) {
return undefined;
});
this.registerFunction('ops.prepacked.linear_clamp_prepack', function(W, B, output_min, output_max) {
const params = self.invoke('__torch__.torch.classes.xnnpack.LinearOpContext', []);
params.weight = W;
params.bias = B;
if (output_min !== undefined) {
params.output_min = output_min;
}
if (output_max !== undefined) {
params.output_max = output_max;
}
return params;
});
this.registerFunction('ops.prim.data', function(tensor) {
return tensor;
});
Expand Down
10 changes: 10 additions & 0 deletions source/pytorch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2302,6 +2302,13 @@ pytorch.jit.Execution = class extends pytorch.Execution {
result.push(tensors);
break;
}
case '__torch__.torch.classes.xnnpack.Conv2dOpContext':
case '__torch__.torch.classes.xnnpack.LinearOpContext': {
const value = this.invoke(parameter.type, []);
this.variable(value, node);
result.push(value);
break;
}
default: {
const output = this.invoke('torch.Tensor', []);
output.resize_([]);
Expand Down Expand Up @@ -2466,6 +2473,9 @@ pytorch.jit.Execution = class extends pytorch.Execution {
case 'Tensor':
case 'Tensor[]':
break;
case '__torch__.torch.classes.xnnpack.Conv2dOpContext':
case '__torch__.torch.classes.xnnpack.LinearOpContext':
break;
default: {
if (!outputTypes || schema.outputs.length !== 1 || schema.outputs[0].type !== outputTypes[0]) {
next = true;
Expand Down
7 changes: 7 additions & 0 deletions test/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -4535,6 +4535,13 @@
"source": "https://github.com/lutzroeder/netron/files/6096623/mobilenet_v2_traced.pt.zip[mobilenet_v2_traced.pt]",
"link": "https://github.com/lutzroeder/netron/issues/281"
},
{
"type": "pytorch",
"target": "model.ptl",
"source": "https://github.com/lutzroeder/netron/files/11149538/model.ptl.zip[model.ptl]",
"format": "TorchScript v1.6",
"link": "https://github.com/lutzroeder/netron/issues/1067"
},
{
"type": "pytorch",
"target": "model_0_epochs.pt",
Expand Down

0 comments on commit d9e08c6

Please sign in to comment.