Переглянути джерело

Update onnx-operator.json

Lutz Roeder 8 роки тому
батько
коміт
53abb26fff
2 змінених файлів з 53 додано та 3 видалено
  1. 52 2
      src/onnx-operator.json
  2. 1 1
      tools/caffe2-generate

+ 52 - 2
src/onnx-operator.json

@@ -6308,11 +6308,11 @@
         }
       ],
       "category": "Shape",
-      "description": "Reshape the input tensor similar to numpy.reshape.\n\nIt takes a tensor as input and an argument `shape`. It outputs the reshaped tensor.\n\nAt most one dimension of the new shape can be -1. In this case, the value is\ninferred from the size of the tensor and the remaining dimensions. A dimension\ncould also be 0, in which case the actual dimension value is unchanged (i.e. taken\nfrom the input tensor).",
+      "description": "Reshape the input tensor similar to numpy.reshape.\nIt takes a tensor as input and an argument `shape`. It outputs the reshaped tensor.\nAt most one dimension of the new shape can be -1. In this case, the value is\ninferred from the size of the tensor and the remaining dimensions. A dimension\ncould also be 0, in which case the actual dimension value is unchanged (i.e. taken\nfrom the input tensor).",
       "domain": "ai.onnx",
       "examples": [
         {
-          "code": "original_shape = [2, 3, 4]\ntest_cases = {\n    'reordered_dims':[4, 2, 3],\n    'reduced_dims':[3, 8],\n    'extended_dims':[3, 2, 2, 2],\n    'one_dim':[24],\n    'negative_dim':[6, -1, 2]\n}\ndata = np.random.random_sample(original_shape).astype(np.float32)\n\nfor test_name,test_shape in test_cases.items():\n    node = onnx.helper.make_node(\n        'Reshape',\n        inputs=['data'],\n        outputs=['reshaped'],\n        shape=test_shape,\n    )\n\n    reshaped = np.reshape(data, test_shape)\n    expect(node, inputs=[data], outputs=[reshaped],\n       name='test_reshape_' + test_name)",
+          "code": "original_shape = [2, 3, 4]\ntest_cases = {\n    'reordered_dims': np.array([4, 2, 3], dtype=np.int64),\n    'reduced_dims': np.array([3, 8], dtype=np.int64),\n    'extended_dims': np.array([3, 2, 2, 2], dtype=np.int64),\n    'one_dim': np.array([24], dtype=np.int64),\n    'negative_dim': np.array([6, -1, 2], dtype=np.int64),\n}\ndata = np.random.random_sample(original_shape).astype(np.float32)\n\nfor test_name, shape in test_cases.items():\n    node = onnx.helper.make_node(\n        'Reshape',\n        inputs=['data', 'shape'],\n        outputs=['reshaped'],\n    )\n\n    reshaped = np.reshape(data, shape)\n    expect(node, inputs=[data, shape], outputs=[reshaped],\n       name='test_reshape_' + test_name)",
           "summary": "reshape"
         }
       ],
@@ -6349,6 +6349,56 @@
       ]
     }
   },
+  {
+    "name": "Reshape",
+    "schema": {
+      "category": "Shape",
+      "description": "Reshape the input tensor similar to numpy.reshape.\n\nFirst input is the data tensor, second input is a shape tensor which specifies the output shape. It outputs the reshaped tensor.\n\nAt most one dimension of the new shape can be -1. In this case, the value is\ninferred from the size of the tensor and the remaining dimensions. A dimension\ncould also be 0, in which case the actual dimension value is unchanged (i.e. taken\nfrom the input tensor).",
+      "domain": "ai.onnx",
+      "examples": [
+        {
+          "code": "original_shape = [2, 3, 4]\ntest_cases = {\n    'reordered_dims': np.array([4, 2, 3], dtype=np.int64),\n    'reduced_dims': np.array([3, 8], dtype=np.int64),\n    'extended_dims': np.array([3, 2, 2, 2], dtype=np.int64),\n    'one_dim': np.array([24], dtype=np.int64),\n    'negative_dim': np.array([6, -1, 2], dtype=np.int64),\n}\ndata = np.random.random_sample(original_shape).astype(np.float32)\n\nfor test_name, shape in test_cases.items():\n    node = onnx.helper.make_node(\n        'Reshape',\n        inputs=['data', 'shape'],\n        outputs=['reshaped'],\n    )\n\n    reshaped = np.reshape(data, shape)\n    expect(node, inputs=[data, shape], outputs=[reshaped],\n       name='test_reshape_' + test_name)",
+          "summary": "reshape"
+        }
+      ],
+      "inputs": [
+        {
+          "description": "An input tensor.",
+          "name": "data",
+          "type": "T"
+        },
+        {
+          "description": "Specified shape for output.",
+          "name": "shape",
+          "type": "tensor(int64)"
+        }
+      ],
+      "max_input": 2,
+      "max_output": 1,
+      "min_input": 2,
+      "min_output": 1,
+      "outputs": [
+        {
+          "description": "Reshaped data.",
+          "name": "reshaped",
+          "type": "T"
+        }
+      ],
+      "since_version": 5,
+      "support_level": "common",
+      "type_constraints": [
+        {
+          "allowed_type_strs": [
+            "tensor(float16)",
+            "tensor(float)",
+            "tensor(double)"
+          ],
+          "description": "Constrain input and output types to float tensors.",
+          "type_param_str": "T"
+        }
+      ]
+    }
+  },
   {
     "name": "SVMClassifier",
     "schema": {

+ 1 - 1
tools/caffe2-generate

@@ -28,7 +28,7 @@ sudo -H pip3 install future numpy protobuf pydot python-gflags pyyaml scikit-ima
 
 echo "Build Caffe2"
 pushd "../third_party/caffe2" > /dev/null
-mkdir build && cd build
+mkdir -p build && cd build
 cmake -DUSE_CUDA=OFF ..
 sudo make install
 popd > /dev/null