Skip to content

Commit

Permalink
Update onnx-metadata.json
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Apr 21, 2023
1 parent b026ba1 commit cd47d01
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions source/onnx-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5444,7 +5444,7 @@
"examples": [
{
"summary": "concat",
"code": "test_cases: Dict[str, Sequence[Any]] = {\n \"1d\": ([1, 2], [3, 4]),\n \"2d\": ([[1, 2], [3, 4]], [[5, 6], [7, 8]]),\n \"3d\": (\n [[[1, 2], [3, 4]], [[5, 6], [7, 8]]],\n [[[9, 10], [11, 12]], [[13, 14], [15, 16]]],\n ),\n}\n\nfor test_case, values_ in test_cases.items():\n values = [np.asarray(v, dtype=np.float32) for v in values_]\n for i in range(len(values[0].shape)):\n in_args = [\"value\" + str(k) for k in range(len(values))]\n node = onnx.helper.make_node(\n \"Concat\", inputs=[s for s in in_args], outputs=[\"output\"], axis=i\n )\n output = np.concatenate(values, i)\n expect(\n node,\n inputs=[v for v in values],\n outputs=[output],\n name=\"test_concat_\" + test_case + \"_axis_\" + str(i),\n )\n\n for i in range(-len(values[0].shape), 0):\n in_args = [\"value\" + str(k) for k in range(len(values))]\n node = onnx.helper.make_node(\n \"Concat\", inputs=[s for s in in_args], outputs=[\"output\"], axis=i\n )\n output = np.concatenate(values, i)\n expect(\n node,\n inputs=[v for v in values],\n outputs=[output],\n name=\"test_concat_\" + test_case + \"_axis_negative_\" + str(abs(i)),\n )"
"code": "test_cases: Dict[str, Sequence[Any]] = {\n \"1d\": ([1, 2], [3, 4]),\n \"2d\": ([[1, 2], [3, 4]], [[5, 6], [7, 8]]),\n \"3d\": (\n [[[1, 2], [3, 4]], [[5, 6], [7, 8]]],\n [[[9, 10], [11, 12]], [[13, 14], [15, 16]]],\n ),\n}\n\nfor test_case, values_ in test_cases.items():\n values = [np.asarray(v, dtype=np.float32) for v in values_]\n for i in range(len(values[0].shape)):\n in_args = [\"value\" + str(k) for k in range(len(values))]\n node = onnx.helper.make_node(\n \"Concat\", inputs=list(in_args), outputs=[\"output\"], axis=i\n )\n output = np.concatenate(values, i)\n expect(\n node,\n inputs=list(values),\n outputs=[output],\n name=\"test_concat_\" + test_case + \"_axis_\" + str(i),\n )\n\n for i in range(-len(values[0].shape), 0):\n in_args = [\"value\" + str(k) for k in range(len(values))]\n node = onnx.helper.make_node(\n \"Concat\", inputs=list(in_args), outputs=[\"output\"], axis=i\n )\n output = np.concatenate(values, i)\n expect(\n node,\n inputs=list(values),\n outputs=[output],\n name=\"test_concat_\" + test_case + \"_axis_negative_\" + str(abs(i)),\n )"
}
],
"category": "Tensor"
Expand Down Expand Up @@ -5509,7 +5509,7 @@
"examples": [
{
"summary": "concat",
"code": "test_cases: Dict[str, Sequence[Any]] = {\n \"1d\": ([1, 2], [3, 4]),\n \"2d\": ([[1, 2], [3, 4]], [[5, 6], [7, 8]]),\n \"3d\": (\n [[[1, 2], [3, 4]], [[5, 6], [7, 8]]],\n [[[9, 10], [11, 12]], [[13, 14], [15, 16]]],\n ),\n}\n\nfor test_case, values_ in test_cases.items():\n values = [np.asarray(v, dtype=np.float32) for v in values_]\n for i in range(len(values[0].shape)):\n in_args = [\"value\" + str(k) for k in range(len(values))]\n node = onnx.helper.make_node(\n \"Concat\", inputs=[s for s in in_args], outputs=[\"output\"], axis=i\n )\n output = np.concatenate(values, i)\n expect(\n node,\n inputs=[v for v in values],\n outputs=[output],\n name=\"test_concat_\" + test_case + \"_axis_\" + str(i),\n )\n\n for i in range(-len(values[0].shape), 0):\n in_args = [\"value\" + str(k) for k in range(len(values))]\n node = onnx.helper.make_node(\n \"Concat\", inputs=[s for s in in_args], outputs=[\"output\"], axis=i\n )\n output = np.concatenate(values, i)\n expect(\n node,\n inputs=[v for v in values],\n outputs=[output],\n name=\"test_concat_\" + test_case + \"_axis_negative_\" + str(abs(i)),\n )"
"code": "test_cases: Dict[str, Sequence[Any]] = {\n \"1d\": ([1, 2], [3, 4]),\n \"2d\": ([[1, 2], [3, 4]], [[5, 6], [7, 8]]),\n \"3d\": (\n [[[1, 2], [3, 4]], [[5, 6], [7, 8]]],\n [[[9, 10], [11, 12]], [[13, 14], [15, 16]]],\n ),\n}\n\nfor test_case, values_ in test_cases.items():\n values = [np.asarray(v, dtype=np.float32) for v in values_]\n for i in range(len(values[0].shape)):\n in_args = [\"value\" + str(k) for k in range(len(values))]\n node = onnx.helper.make_node(\n \"Concat\", inputs=list(in_args), outputs=[\"output\"], axis=i\n )\n output = np.concatenate(values, i)\n expect(\n node,\n inputs=list(values),\n outputs=[output],\n name=\"test_concat_\" + test_case + \"_axis_\" + str(i),\n )\n\n for i in range(-len(values[0].shape), 0):\n in_args = [\"value\" + str(k) for k in range(len(values))]\n node = onnx.helper.make_node(\n \"Concat\", inputs=list(in_args), outputs=[\"output\"], axis=i\n )\n output = np.concatenate(values, i)\n expect(\n node,\n inputs=list(values),\n outputs=[output],\n name=\"test_concat_\" + test_case + \"_axis_negative_\" + str(abs(i)),\n )"
}
],
"category": "Tensor"
Expand Down Expand Up @@ -5574,7 +5574,7 @@
"examples": [
{
"summary": "concat",
"code": "test_cases: Dict[str, Sequence[Any]] = {\n \"1d\": ([1, 2], [3, 4]),\n \"2d\": ([[1, 2], [3, 4]], [[5, 6], [7, 8]]),\n \"3d\": (\n [[[1, 2], [3, 4]], [[5, 6], [7, 8]]],\n [[[9, 10], [11, 12]], [[13, 14], [15, 16]]],\n ),\n}\n\nfor test_case, values_ in test_cases.items():\n values = [np.asarray(v, dtype=np.float32) for v in values_]\n for i in range(len(values[0].shape)):\n in_args = [\"value\" + str(k) for k in range(len(values))]\n node = onnx.helper.make_node(\n \"Concat\", inputs=[s for s in in_args], outputs=[\"output\"], axis=i\n )\n output = np.concatenate(values, i)\n expect(\n node,\n inputs=[v for v in values],\n outputs=[output],\n name=\"test_concat_\" + test_case + \"_axis_\" + str(i),\n )\n\n for i in range(-len(values[0].shape), 0):\n in_args = [\"value\" + str(k) for k in range(len(values))]\n node = onnx.helper.make_node(\n \"Concat\", inputs=[s for s in in_args], outputs=[\"output\"], axis=i\n )\n output = np.concatenate(values, i)\n expect(\n node,\n inputs=[v for v in values],\n outputs=[output],\n name=\"test_concat_\" + test_case + \"_axis_negative_\" + str(abs(i)),\n )"
"code": "test_cases: Dict[str, Sequence[Any]] = {\n \"1d\": ([1, 2], [3, 4]),\n \"2d\": ([[1, 2], [3, 4]], [[5, 6], [7, 8]]),\n \"3d\": (\n [[[1, 2], [3, 4]], [[5, 6], [7, 8]]],\n [[[9, 10], [11, 12]], [[13, 14], [15, 16]]],\n ),\n}\n\nfor test_case, values_ in test_cases.items():\n values = [np.asarray(v, dtype=np.float32) for v in values_]\n for i in range(len(values[0].shape)):\n in_args = [\"value\" + str(k) for k in range(len(values))]\n node = onnx.helper.make_node(\n \"Concat\", inputs=list(in_args), outputs=[\"output\"], axis=i\n )\n output = np.concatenate(values, i)\n expect(\n node,\n inputs=list(values),\n outputs=[output],\n name=\"test_concat_\" + test_case + \"_axis_\" + str(i),\n )\n\n for i in range(-len(values[0].shape), 0):\n in_args = [\"value\" + str(k) for k in range(len(values))]\n node = onnx.helper.make_node(\n \"Concat\", inputs=list(in_args), outputs=[\"output\"], axis=i\n )\n output = np.concatenate(values, i)\n expect(\n node,\n inputs=list(values),\n outputs=[output],\n name=\"test_concat_\" + test_case + \"_axis_negative_\" + str(abs(i)),\n )"
}
],
"category": "Tensor"
Expand Down Expand Up @@ -5640,7 +5640,7 @@
"examples": [
{
"summary": "concat",
"code": "test_cases: Dict[str, Sequence[Any]] = {\n \"1d\": ([1, 2], [3, 4]),\n \"2d\": ([[1, 2], [3, 4]], [[5, 6], [7, 8]]),\n \"3d\": (\n [[[1, 2], [3, 4]], [[5, 6], [7, 8]]],\n [[[9, 10], [11, 12]], [[13, 14], [15, 16]]],\n ),\n}\n\nfor test_case, values_ in test_cases.items():\n values = [np.asarray(v, dtype=np.float32) for v in values_]\n for i in range(len(values[0].shape)):\n in_args = [\"value\" + str(k) for k in range(len(values))]\n node = onnx.helper.make_node(\n \"Concat\", inputs=[s for s in in_args], outputs=[\"output\"], axis=i\n )\n output = np.concatenate(values, i)\n expect(\n node,\n inputs=[v for v in values],\n outputs=[output],\n name=\"test_concat_\" + test_case + \"_axis_\" + str(i),\n )\n\n for i in range(-len(values[0].shape), 0):\n in_args = [\"value\" + str(k) for k in range(len(values))]\n node = onnx.helper.make_node(\n \"Concat\", inputs=[s for s in in_args], outputs=[\"output\"], axis=i\n )\n output = np.concatenate(values, i)\n expect(\n node,\n inputs=[v for v in values],\n outputs=[output],\n name=\"test_concat_\" + test_case + \"_axis_negative_\" + str(abs(i)),\n )"
"code": "test_cases: Dict[str, Sequence[Any]] = {\n \"1d\": ([1, 2], [3, 4]),\n \"2d\": ([[1, 2], [3, 4]], [[5, 6], [7, 8]]),\n \"3d\": (\n [[[1, 2], [3, 4]], [[5, 6], [7, 8]]],\n [[[9, 10], [11, 12]], [[13, 14], [15, 16]]],\n ),\n}\n\nfor test_case, values_ in test_cases.items():\n values = [np.asarray(v, dtype=np.float32) for v in values_]\n for i in range(len(values[0].shape)):\n in_args = [\"value\" + str(k) for k in range(len(values))]\n node = onnx.helper.make_node(\n \"Concat\", inputs=list(in_args), outputs=[\"output\"], axis=i\n )\n output = np.concatenate(values, i)\n expect(\n node,\n inputs=list(values),\n outputs=[output],\n name=\"test_concat_\" + test_case + \"_axis_\" + str(i),\n )\n\n for i in range(-len(values[0].shape), 0):\n in_args = [\"value\" + str(k) for k in range(len(values))]\n node = onnx.helper.make_node(\n \"Concat\", inputs=list(in_args), outputs=[\"output\"], axis=i\n )\n output = np.concatenate(values, i)\n expect(\n node,\n inputs=list(values),\n outputs=[output],\n name=\"test_concat_\" + test_case + \"_axis_negative_\" + str(abs(i)),\n )"
}
],
"category": "Tensor"
Expand Down Expand Up @@ -35888,7 +35888,7 @@
"examples": [
{
"summary": "nokeepdims",
"code": "data = np.arange(18).reshape((3, 6)).astype(np.float32)\n\nnode = onnx.helper.make_node(\n \"SplitToSequence\",\n [\"data\"],\n [\"seq\"],\n axis=1,\n keepdims=0,\n)\n\nexpected_outputs = [list(data[:, i] for i in range(data.shape[1]))]\n\nexpect(\n node,\n inputs=[data],\n outputs=expected_outputs,\n name=\"test_split_to_sequence_nokeepdims\",\n)"
"code": "data = np.arange(18).reshape((3, 6)).astype(np.float32)\n\nnode = onnx.helper.make_node(\n \"SplitToSequence\",\n [\"data\"],\n [\"seq\"],\n axis=1,\n keepdims=0,\n)\n\nexpected_outputs = [[data[:, i] for i in range(data.shape[1])]]\n\nexpect(\n node,\n inputs=[data],\n outputs=expected_outputs,\n name=\"test_split_to_sequence_nokeepdims\",\n)"
},
{
"summary": "with_split_1",
Expand Down Expand Up @@ -38635,7 +38635,7 @@
"examples": [
{
"summary": "not_sorted_without_axis",
"code": "node_not_sorted = onnx.helper.make_node(\n \"Unique\",\n inputs=[\"X\"],\n outputs=[\"Y\", \"indices\", \"inverse_indices\", \"counts\"],\n sorted=0,\n)\n# numpy unique does not retain original order (it sorts the output unique values)\n# https://github.com/numpy/numpy/issues/8621\n# we need to recover unsorted output and indices\nx = np.array([2.0, 1.0, 1.0, 3.0, 4.0, 3.0], dtype=np.float32)\ny, indices, inverse_indices, counts = np.unique(x, True, True, True)\n\n# prepare index mapping from sorted to unsorted\nargsorted_indices = np.argsort(indices)\ninverse_indices_map = {\n i: si for i, si in zip(argsorted_indices, np.arange(len(argsorted_indices)))\n}\n\nindices = indices[argsorted_indices]\ny = np.take(x, indices, axis=0)\ninverse_indices = np.asarray(\n [inverse_indices_map[i] for i in inverse_indices], dtype=np.int64\n)\ncounts = counts[argsorted_indices]\nindices, inverse_indices, counts = specify_int64(\n indices, inverse_indices, counts\n)\n# print(y)\n# [2.0, 1.0, 3.0, 4.0]\n# print(indices)\n# [0 1 3 4]\n# print(inverse_indices)\n# [0, 1, 1, 2, 3, 2]\n# print(counts)\n# [1, 2, 2, 1]\n\nexpect(\n node_not_sorted,\n inputs=[x],\n outputs=[y, indices, inverse_indices, counts],\n name=\"test_unique_not_sorted_without_axis\",\n)"
"code": "node_not_sorted = onnx.helper.make_node(\n \"Unique\",\n inputs=[\"X\"],\n outputs=[\"Y\", \"indices\", \"inverse_indices\", \"counts\"],\n sorted=0,\n)\n# numpy unique does not retain original order (it sorts the output unique values)\n# https://github.com/numpy/numpy/issues/8621\n# we need to recover unsorted output and indices\nx = np.array([2.0, 1.0, 1.0, 3.0, 4.0, 3.0], dtype=np.float32)\ny, indices, inverse_indices, counts = np.unique(x, True, True, True)\n\n# prepare index mapping from sorted to unsorted\nargsorted_indices = np.argsort(indices)\ninverse_indices_map = dict(\n zip(argsorted_indices, np.arange(len(argsorted_indices)))\n)\n\nindices = indices[argsorted_indices]\ny = np.take(x, indices, axis=0)\ninverse_indices = np.asarray(\n [inverse_indices_map[i] for i in inverse_indices], dtype=np.int64\n)\ncounts = counts[argsorted_indices]\nindices, inverse_indices, counts = specify_int64(\n indices, inverse_indices, counts\n)\n# print(y)\n# [2.0, 1.0, 3.0, 4.0]\n# print(indices)\n# [0 1 3 4]\n# print(inverse_indices)\n# [0, 1, 1, 2, 3, 2]\n# print(counts)\n# [1, 2, 2, 1]\n\nexpect(\n node_not_sorted,\n inputs=[x],\n outputs=[y, indices, inverse_indices, counts],\n name=\"test_unique_not_sorted_without_axis\",\n)"
},
{
"summary": "sorted_with_axis",
Expand Down

0 comments on commit cd47d01

Please sign in to comment.