question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What does negative dimension imply

See original GitHub issue

Ask a Question

Question

I was toggling the node parameters for testing and I noticed that the ONNX checker doesn’t complain on the following model whose output has negative value for the last two dimensions. I am under the impression that the model is invalid and I wonder if negative value has special meaning.

Further information

Model gen script

from onnx import helper
from onnx import TensorProto as tp
from onnx import checker
from onnx import save
import sys
import argparse
import os

node = helper.make_node('MaxPool',
                        inputs=['input'],
                        outputs=['output'],
                        kernel_shape=[5, 5],
                        strides=[2, 2],
                        dilations=[2, 2])
graph = helper.make_graph(
    [node], 'test_graph',
    [helper.make_tensor_value_info('input', tp.FLOAT, [1, 1, 5, 5])],
    [helper.make_tensor_value_info('output', tp.FLOAT, [1, 1, -1, -1])])
model = helper.make_model(graph, producer_name='model')
checker.check_model(model, full_check=True)

Notes

Any additional information, code snippets.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
gramalingamcommented, Sep 3, 2021

Yes, in an ONNX ShapeProto, a negative value is not valid. Technically, it makes sense to have the checker catch and report an error for this case. However, some other frameworks use the special value -1 to indicate an unknown dimension. Hence, there may be some older models that incorrectly use -1 to indicate an unknown dimension. So, throwing an error could cause some compatibility issues for such models. I think it might make sense for us to have the notion of a “warning” and flag such issues with a “warning” instead of “error” to balance these requirements.

0reactions
askhadecommented, Sep 8, 2021

agree - another such violation is nodes are not sorted in topological order. I encountered 1 case where the model was valid but the nodes were not in the right order (mostly because some offline optimization script was run) … ORT allows this too

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could negative dimension ever make sense?
"Natural numbers are defined as cardinalities of finite sets, and sets cannot have less than 0 elements, so there is no such thing...
Read more >
Negative Dimensions - Infinity Theory
Those half-cycles are negative dimensional, so the vortices in those cycles are made of plasma. The negative dimensions is also where we find...
Read more >
Is there such thing as a 'negative dimension'? : r/math - Reddit
But let's say a negative dimensional sphere is just the desuspension of the sphere spectrum. An (–n)-sphere will have nontrivial homotopy ...
Read more >
Could a Negative Dimension exist | Physics Forums
This, too, is physically a dimension. The fact that it counts something per second is only of technical interest and doesn't affect what...
Read more >
Negative-dimensional space - HandWiki
In topology, a discipline within mathematics, a negative-dimensional space is an extension of the usual notion of space, allowing for negative ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found