Lutz Roeder 6 лет назад
Родитель
Сommit
ea6bf445d7
3 измененных файлов с 216 добавлено и 11 удалено
  1. 194 10
      src/pytorch-metadata.json
  2. 1 1
      src/pytorch.js
  3. 21 0
      test/models.json

+ 194 - 10
src/pytorch-metadata.json

@@ -1334,6 +1334,25 @@
       ]
     }
   },
+  {
+    "name": "torch.prelu",
+    "schema": {
+      "category": "Activation",
+      "inputs": [
+        {
+          "name": "input"
+        },
+        {
+          "name": "weight"
+        }
+      ],
+      "outputs": [
+        {
+          "name": "output"
+        }
+      ]
+    }
+  },
   {
     "name": "torch.hardtanh_",
     "schema": {
@@ -1487,6 +1506,44 @@
       ]
     }
   },
+  {
+    "name": "torch.tanh",
+    "schema": {
+      "category": "Activation",
+      "inputs": [
+        {
+          "name": "input"
+        }
+      ],
+      "outputs": [
+        {
+          "name": "output"
+        }
+      ]
+    }
+  },
+  {
+    "name": "torch.leaky_relu",
+    "schema": {
+      "attributes": [
+        {
+          "default": 0.01,
+          "name": "negative_slope"
+        }
+      ],
+      "category": "Activation",
+      "inputs": [
+        {
+          "name": "input"
+        }
+      ],
+      "outputs": [
+        {
+          "name": "output"
+        }
+      ]
+    }
+  },
   {
     "name": "torch.slice",
     "schema": {
@@ -1900,7 +1957,7 @@
       ],
       "inputs": [
         {
-          "name": "self"
+          "name": "input"
         }
       ],
       "outputs": [
@@ -1968,7 +2025,7 @@
       ],
       "inputs": [
         {
-          "name": "self"
+          "name": "input"
         }
       ],
       "outputs": [
@@ -1990,7 +2047,7 @@
       ],
       "inputs": [
         {
-          "name": "self"
+          "name": "input"
         },
         {
           "name": "src"
@@ -2154,6 +2211,61 @@
       ]
     }
   },
+  {
+    "name": "torch.gru",
+    "schema": {
+      "attributes": [
+        {
+          "name": "has_biases",
+          "type": "boolean"
+        },
+        {
+          "name": "num_layers",
+          "type": "int64"
+        },
+        {
+          "name": "dropout",
+          "type": "float64"
+        },
+        {
+          "name": "train",
+          "type": "boolean"
+        },
+        {
+          "name": "bidirectional",
+          "type": "boolean"
+        }
+      ],
+      "category": "Layer",
+      "inputs": [
+        {
+          "name": "data",
+          "type": "T"
+        },
+        {
+          "name": "batch_sizes",
+          "option": "optional",
+          "type": "T"
+        },
+        {
+          "name": "hx",
+          "type": "T[]"
+        },
+        {
+          "name": "params",
+          "type": "T[]"
+        }
+      ],
+      "outputs": [
+        {
+          "name": "output"
+        },
+        {
+          "name": "?"
+        }
+      ]
+    }
+  },
   {
     "name": "torch.contiguous",
     "schema": {
@@ -2554,7 +2666,7 @@
       "category": "Activation",
       "inputs": [
         {
-          "name": "self"
+          "name": "input"
         }
       ],
       "outputs": [
@@ -2682,7 +2794,7 @@
     "schema": {
       "inputs": [
         {
-          "name": "self"
+          "name": "input"
         },
         {
           "name": "other"
@@ -2705,7 +2817,7 @@
       ],
       "inputs": [
         {
-          "name": "self"
+          "name": "input"
         }
       ],
       "outputs": [
@@ -2720,7 +2832,7 @@
     "schema": {
       "inputs": [
         {
-          "name": "self"
+          "name": "input"
         },
         {
           "name": "other"
@@ -2743,7 +2855,7 @@
       ],
       "inputs": [
         {
-          "name": "self"
+          "name": "input"
         }
       ],
       "outputs": [
@@ -2758,7 +2870,7 @@
     "schema": {
       "inputs": [
         {
-          "name": "self"
+          "name": "input"
         },
         {
           "name": "other"
@@ -2781,7 +2893,79 @@
       ],
       "inputs": [
         {
-          "name": "self"
+          "name": "input"
+        }
+      ],
+      "outputs": [
+        {
+          "name": "output"
+        }
+      ]
+    }
+  },
+  {
+    "name": "torch.bmm",
+    "schema": {
+      "inputs": [
+        {
+          "name": "input"
+        },
+        {
+          "name": "mat2"
+        }
+      ],
+      "outputs": [
+        {
+          "name": "output"
+        }
+      ]
+    }
+  },
+  {
+    "name": "torch.constant_pad_nd",
+    "schema": {
+      "attributes": [
+        {
+          "name": "pad",
+          "type": "int64[]"
+        },
+        {
+          "default": 0,
+          "name": "value"
+        }
+      ],
+      "category": "Tensor",
+      "inputs": [
+        {
+          "name": "input"
+        }
+      ],
+      "outputs": [
+        {
+          "name": "output"
+        }
+      ]
+    }
+  },
+  {
+    "name": "torch.ones",
+    "schema": {
+      "attributes": [
+        {
+          "name": "size",
+          "type": "int64[]"
+        },
+        {
+          "name": "dtype"
+        },
+        {
+          "name": "layout"
+        },
+        {
+          "name": "device"
+        },
+        {
+          "name": "pin_memory"
         }
       ],
       "outputs": [

+ 1 - 1
src/pytorch.js

@@ -2967,7 +2967,7 @@ pytorch.Container.Zip.Execution = class extends pytorch.Execution {
                         outputs: []
                     };
                     let next = false;
-                    const inputSchemas = Array.prototype.slice.call(schema.inputs);
+                    const inputSchemas = Array.prototype.slice.call(schema.inputs || []);
                     while (inputSchemas.length > 0) {
                         let inputSchema = inputSchemas.shift();
                         const argument = this.expression(callArgs.shift(), context);

+ 21 - 0
test/models.json

@@ -4105,6 +4105,27 @@
     "format": "TorchScript v1.3",
     "link":   "https://github.com/lutzroeder/netron/issues/313"
   },
+  {
+    "type":   "pytorch",
+    "target": "netron_issue_432_activation.pth",
+    "source": "https://github.com/lutzroeder/netron/files/4226686/netron_issue_432_activation.pth.zip[netron_issue_432_activation.pth]",
+    "format": "TorchScript v1.3",
+    "link":   "https://github.com/lutzroeder/netron/issues/432"
+  },
+  {
+    "type":   "pytorch",
+    "target": "netron_issue_432_bmm.pth",
+    "source": "https://github.com/lutzroeder/netron/files/4226688/netron_issue_432_bmm.pth.zip[netron_issue_432_bmm.pth]",
+    "format": "TorchScript v1.3",
+    "link":   "https://github.com/lutzroeder/netron/issues/432"
+  },
+  {
+    "type":   "pytorch",
+    "target": "netron_issue_432_constant_pad_2d.pth",
+    "source": "https://github.com/lutzroeder/netron/files/4226690/netron_issue_432_constant_pad_2d.pth.zip[netron_issue_432_constant_pad_2d.pth]",
+    "format": "TorchScript v1.3",
+    "link":   "https://github.com/lutzroeder/netron/issues/432"
+  },
   {
     "type":   "pytorch",
     "target": "pedestrian_interaction_position_embedding.pt",