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 Sep 28, 2024
1 parent 01044c6 commit fc49d39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 6 additions & 6 deletions source/onnx-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -7667,7 +7667,7 @@
"examples": [
{
"summary": "clip",
"code": "node = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nx = np.array([-2, 0, 2]).astype(np.float32)\nmin_val = np.float32(-1)\nmax_val = np.float32(1)\ny = np.clip(x, min_val, max_val) # expected output [-1., 0., 1.]\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_example\"\n)\n\nx = np.random.randn(3, 4, 5).astype(np.float32)\ny = np.clip(x, min_val, max_val)\nexpect(node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip\")\nnode = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nmin_val = np.float32(-5)\nmax_val = np.float32(5)\n\nx = np.array([-1, 0, 1]).astype(np.float32)\ny = np.array([-1, 0, 1]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_inbounds\"\n)\n\nx = np.array([-6, 0, 6]).astype(np.float32)\ny = np.array([-5, 0, 5]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_outbounds\"\n)\n\nx = np.array([-1, 0, 6]).astype(np.float32)\ny = np.array([-1, 0, 5]).astype(np.float32)\nexpect(\n node,\n inputs=[x, min_val, max_val],\n outputs=[y],\n name=\"test_clip_splitbounds\",\n)"
"code": "node = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nx = np.array([-2, 0, 2]).astype(np.float32)\nmin_val = np.float32(-1)\nmax_val = np.float32(1)\ny = np.clip(x, min_val, max_val) # expected output [-1., 0., 1.]\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_example\"\n)\n\nx = np.random.randn(3, 4, 5).astype(np.float32)\ny = np.clip(x, min_val, max_val)\nexpect(node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip\")\nnode = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nmin_val = np.float32(-5)\nmax_val = np.float32(5)\n\nx = np.array([-1, 0, 1]).astype(np.float32)\ny = np.array([-1, 0, 1]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_inbounds\"\n)\n\nx = np.array([-6, 0, 6]).astype(np.float32)\ny = np.array([-5, 0, 5]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_outbounds\"\n)\n\nx = np.array([-1, 0, 6]).astype(np.float32)\ny = np.array([-1, 0, 5]).astype(np.float32)\nexpect(\n node,\n inputs=[x, min_val, max_val],\n outputs=[y],\n name=\"test_clip_splitbounds\",\n)\n\nx = np.array([-2, 0, 6]).astype(np.float32)\ny = np.array([1, 1, 1]).astype(np.float32)\nmin_val = np.float32(2)\nmax_val = np.float32(1)\nexpect(\n node,\n inputs=[x, min_val, max_val],\n outputs=[y],\n name=\"test_clip_min_greater_than_max\",\n)"
},
{
"summary": "clip_default",
Expand Down Expand Up @@ -7733,7 +7733,7 @@
"examples": [
{
"summary": "clip",
"code": "node = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nx = np.array([-2, 0, 2]).astype(np.float32)\nmin_val = np.float32(-1)\nmax_val = np.float32(1)\ny = np.clip(x, min_val, max_val) # expected output [-1., 0., 1.]\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_example\"\n)\n\nx = np.random.randn(3, 4, 5).astype(np.float32)\ny = np.clip(x, min_val, max_val)\nexpect(node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip\")\nnode = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nmin_val = np.float32(-5)\nmax_val = np.float32(5)\n\nx = np.array([-1, 0, 1]).astype(np.float32)\ny = np.array([-1, 0, 1]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_inbounds\"\n)\n\nx = np.array([-6, 0, 6]).astype(np.float32)\ny = np.array([-5, 0, 5]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_outbounds\"\n)\n\nx = np.array([-1, 0, 6]).astype(np.float32)\ny = np.array([-1, 0, 5]).astype(np.float32)\nexpect(\n node,\n inputs=[x, min_val, max_val],\n outputs=[y],\n name=\"test_clip_splitbounds\",\n)"
"code": "node = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nx = np.array([-2, 0, 2]).astype(np.float32)\nmin_val = np.float32(-1)\nmax_val = np.float32(1)\ny = np.clip(x, min_val, max_val) # expected output [-1., 0., 1.]\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_example\"\n)\n\nx = np.random.randn(3, 4, 5).astype(np.float32)\ny = np.clip(x, min_val, max_val)\nexpect(node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip\")\nnode = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nmin_val = np.float32(-5)\nmax_val = np.float32(5)\n\nx = np.array([-1, 0, 1]).astype(np.float32)\ny = np.array([-1, 0, 1]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_inbounds\"\n)\n\nx = np.array([-6, 0, 6]).astype(np.float32)\ny = np.array([-5, 0, 5]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_outbounds\"\n)\n\nx = np.array([-1, 0, 6]).astype(np.float32)\ny = np.array([-1, 0, 5]).astype(np.float32)\nexpect(\n node,\n inputs=[x, min_val, max_val],\n outputs=[y],\n name=\"test_clip_splitbounds\",\n)\n\nx = np.array([-2, 0, 6]).astype(np.float32)\ny = np.array([1, 1, 1]).astype(np.float32)\nmin_val = np.float32(2)\nmax_val = np.float32(1)\nexpect(\n node,\n inputs=[x, min_val, max_val],\n outputs=[y],\n name=\"test_clip_min_greater_than_max\",\n)"
},
{
"summary": "clip_default",
Expand Down Expand Up @@ -7796,7 +7796,7 @@
"examples": [
{
"summary": "clip",
"code": "node = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nx = np.array([-2, 0, 2]).astype(np.float32)\nmin_val = np.float32(-1)\nmax_val = np.float32(1)\ny = np.clip(x, min_val, max_val) # expected output [-1., 0., 1.]\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_example\"\n)\n\nx = np.random.randn(3, 4, 5).astype(np.float32)\ny = np.clip(x, min_val, max_val)\nexpect(node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip\")\nnode = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nmin_val = np.float32(-5)\nmax_val = np.float32(5)\n\nx = np.array([-1, 0, 1]).astype(np.float32)\ny = np.array([-1, 0, 1]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_inbounds\"\n)\n\nx = np.array([-6, 0, 6]).astype(np.float32)\ny = np.array([-5, 0, 5]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_outbounds\"\n)\n\nx = np.array([-1, 0, 6]).astype(np.float32)\ny = np.array([-1, 0, 5]).astype(np.float32)\nexpect(\n node,\n inputs=[x, min_val, max_val],\n outputs=[y],\n name=\"test_clip_splitbounds\",\n)"
"code": "node = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nx = np.array([-2, 0, 2]).astype(np.float32)\nmin_val = np.float32(-1)\nmax_val = np.float32(1)\ny = np.clip(x, min_val, max_val) # expected output [-1., 0., 1.]\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_example\"\n)\n\nx = np.random.randn(3, 4, 5).astype(np.float32)\ny = np.clip(x, min_val, max_val)\nexpect(node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip\")\nnode = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nmin_val = np.float32(-5)\nmax_val = np.float32(5)\n\nx = np.array([-1, 0, 1]).astype(np.float32)\ny = np.array([-1, 0, 1]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_inbounds\"\n)\n\nx = np.array([-6, 0, 6]).astype(np.float32)\ny = np.array([-5, 0, 5]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_outbounds\"\n)\n\nx = np.array([-1, 0, 6]).astype(np.float32)\ny = np.array([-1, 0, 5]).astype(np.float32)\nexpect(\n node,\n inputs=[x, min_val, max_val],\n outputs=[y],\n name=\"test_clip_splitbounds\",\n)\n\nx = np.array([-2, 0, 6]).astype(np.float32)\ny = np.array([1, 1, 1]).astype(np.float32)\nmin_val = np.float32(2)\nmax_val = np.float32(1)\nexpect(\n node,\n inputs=[x, min_val, max_val],\n outputs=[y],\n name=\"test_clip_min_greater_than_max\",\n)"
},
{
"summary": "clip_default",
Expand Down Expand Up @@ -7867,7 +7867,7 @@
"examples": [
{
"summary": "clip",
"code": "node = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nx = np.array([-2, 0, 2]).astype(np.float32)\nmin_val = np.float32(-1)\nmax_val = np.float32(1)\ny = np.clip(x, min_val, max_val) # expected output [-1., 0., 1.]\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_example\"\n)\n\nx = np.random.randn(3, 4, 5).astype(np.float32)\ny = np.clip(x, min_val, max_val)\nexpect(node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip\")\nnode = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nmin_val = np.float32(-5)\nmax_val = np.float32(5)\n\nx = np.array([-1, 0, 1]).astype(np.float32)\ny = np.array([-1, 0, 1]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_inbounds\"\n)\n\nx = np.array([-6, 0, 6]).astype(np.float32)\ny = np.array([-5, 0, 5]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_outbounds\"\n)\n\nx = np.array([-1, 0, 6]).astype(np.float32)\ny = np.array([-1, 0, 5]).astype(np.float32)\nexpect(\n node,\n inputs=[x, min_val, max_val],\n outputs=[y],\n name=\"test_clip_splitbounds\",\n)"
"code": "node = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nx = np.array([-2, 0, 2]).astype(np.float32)\nmin_val = np.float32(-1)\nmax_val = np.float32(1)\ny = np.clip(x, min_val, max_val) # expected output [-1., 0., 1.]\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_example\"\n)\n\nx = np.random.randn(3, 4, 5).astype(np.float32)\ny = np.clip(x, min_val, max_val)\nexpect(node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip\")\nnode = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nmin_val = np.float32(-5)\nmax_val = np.float32(5)\n\nx = np.array([-1, 0, 1]).astype(np.float32)\ny = np.array([-1, 0, 1]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_inbounds\"\n)\n\nx = np.array([-6, 0, 6]).astype(np.float32)\ny = np.array([-5, 0, 5]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_outbounds\"\n)\n\nx = np.array([-1, 0, 6]).astype(np.float32)\ny = np.array([-1, 0, 5]).astype(np.float32)\nexpect(\n node,\n inputs=[x, min_val, max_val],\n outputs=[y],\n name=\"test_clip_splitbounds\",\n)\n\nx = np.array([-2, 0, 6]).astype(np.float32)\ny = np.array([1, 1, 1]).astype(np.float32)\nmin_val = np.float32(2)\nmax_val = np.float32(1)\nexpect(\n node,\n inputs=[x, min_val, max_val],\n outputs=[y],\n name=\"test_clip_min_greater_than_max\",\n)"
},
{
"summary": "clip_default",
Expand All @@ -7884,7 +7884,7 @@
"name": "Clip",
"module": "ai.onnx",
"version": 13,
"description": "Clip operator limits the given input within an interval. The interval is\nspecified by the inputs 'min' and 'max'. They default to\nnumeric_limits::lowest() and numeric_limits::max(), respectively.\n",
"description": "Clip operator limits the given input within an interval. The interval is\nspecified by the inputs 'min' and 'max'. They default to\nnumeric_limits::lowest() and numeric_limits::max(), respectively.\nWhen 'min' is greater than 'max', the clip operator sets all the 'input' values to\nthe value of 'max'. Thus, this is equivalent to 'Min(max, Max(input, min))'.\n",
"inputs": [
{
"name": "input",
Expand Down Expand Up @@ -7939,7 +7939,7 @@
"examples": [
{
"summary": "clip",
"code": "node = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nx = np.array([-2, 0, 2]).astype(np.float32)\nmin_val = np.float32(-1)\nmax_val = np.float32(1)\ny = np.clip(x, min_val, max_val) # expected output [-1., 0., 1.]\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_example\"\n)\n\nx = np.random.randn(3, 4, 5).astype(np.float32)\ny = np.clip(x, min_val, max_val)\nexpect(node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip\")\nnode = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nmin_val = np.float32(-5)\nmax_val = np.float32(5)\n\nx = np.array([-1, 0, 1]).astype(np.float32)\ny = np.array([-1, 0, 1]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_inbounds\"\n)\n\nx = np.array([-6, 0, 6]).astype(np.float32)\ny = np.array([-5, 0, 5]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_outbounds\"\n)\n\nx = np.array([-1, 0, 6]).astype(np.float32)\ny = np.array([-1, 0, 5]).astype(np.float32)\nexpect(\n node,\n inputs=[x, min_val, max_val],\n outputs=[y],\n name=\"test_clip_splitbounds\",\n)"
"code": "node = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nx = np.array([-2, 0, 2]).astype(np.float32)\nmin_val = np.float32(-1)\nmax_val = np.float32(1)\ny = np.clip(x, min_val, max_val) # expected output [-1., 0., 1.]\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_example\"\n)\n\nx = np.random.randn(3, 4, 5).astype(np.float32)\ny = np.clip(x, min_val, max_val)\nexpect(node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip\")\nnode = onnx.helper.make_node(\n \"Clip\",\n inputs=[\"x\", \"min\", \"max\"],\n outputs=[\"y\"],\n)\n\nmin_val = np.float32(-5)\nmax_val = np.float32(5)\n\nx = np.array([-1, 0, 1]).astype(np.float32)\ny = np.array([-1, 0, 1]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_inbounds\"\n)\n\nx = np.array([-6, 0, 6]).astype(np.float32)\ny = np.array([-5, 0, 5]).astype(np.float32)\nexpect(\n node, inputs=[x, min_val, max_val], outputs=[y], name=\"test_clip_outbounds\"\n)\n\nx = np.array([-1, 0, 6]).astype(np.float32)\ny = np.array([-1, 0, 5]).astype(np.float32)\nexpect(\n node,\n inputs=[x, min_val, max_val],\n outputs=[y],\n name=\"test_clip_splitbounds\",\n)\n\nx = np.array([-2, 0, 6]).astype(np.float32)\ny = np.array([1, 1, 1]).astype(np.float32)\nmin_val = np.float32(2)\nmax_val = np.float32(1)\nexpect(\n node,\n inputs=[x, min_val, max_val],\n outputs=[y],\n name=\"test_clip_min_greater_than_max\",\n)"
},
{
"summary": "clip_default",
Expand Down
6 changes: 4 additions & 2 deletions tools/onnx_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def _get_attr_default_value(self, attr_value):

def _update_attributes(self, value, schema):
target = value['attributes'] = []
for _ in collections.OrderedDict(schema.attributes.items()).values():
attributes = sorted(schema.attributes.items())
for _ in collections.OrderedDict(attributes).values():
value = {}
value['name'] = _.name
attribute_type = self._get_attr_type(_.type, _.name, schema.name, schema.domain)
Expand Down Expand Up @@ -192,7 +193,8 @@ def _get_attr_default_value(self, attr_value):

def _update_attributes(self, value, schema):
target = value['attributes'] = []
for _ in collections.OrderedDict(schema.attributes.items()).values():
attributes = sorted(schema.attributes.items())
for _ in collections.OrderedDict(attributes).values():
value = {}
value['name'] = _.name
attribute_type = self._get_attr_type(_.type)
Expand Down

0 comments on commit fc49d39

Please sign in to comment.