Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify meaning of operator Constant #1799

Closed
Flamefire opened this issue Feb 8, 2019 · 3 comments
Closed

Clarify meaning of operator Constant #1799

Flamefire opened this issue Feb 8, 2019 · 3 comments
Labels
operator Issues related to ONNX operators stale

Comments

@Flamefire
Copy link
Contributor

https://github.com/onnx/onnx/blob/master/docs/Operators.md#constant defines the attribute of this operator as

value : tensor (required)
    The value for the elements of the output tensor. 

This is misleading as it sounds like it is a scalar. From the example code and the fact, that no shape is given as an input the specification should read:

value : T (required)
    The value of the output tensor. 

More general: In ConstantOfShape the same name tensor is used. Shouldn't it be always T<x> with an appropriate type constraint?

@skottmckay
Copy link
Contributor

A tensor always has a shape, and Constant returns a tensor. The tensor could contain a single scalar though. https://github.com/onnx/onnx/blob/master/docs/IR.md#tensor-shapes

The python example for Constant shows it returning a tensor of shape {5, 5}. https://github.com/onnx/onnx/blob/master/docs/Operators.md#examples-18

ConstantOfShape is generating a tensor of a given shape, filled with the default or provided value. As the documentation says, an empty shape will return what's considered a scalar. https://github.com/onnx/onnx/blob/master/docs/Operators.md#inputs-18

@Flamefire
Copy link
Contributor Author

That's how I understood it too especially with the Python example. But ONNX is a specification first and foremost and the specification is confusing/unclear ("The value [singular] for the elements [plural]..."). So the request is to make it more clear.

Additionally why is "tensor" used for the specification and not the more formal "T" with contraints as in most other places? This would also allow for automatic validation.

@stale
Copy link

stale bot commented Mar 29, 2022

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Mar 29, 2022
@stale stale bot closed this as completed Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
operator Issues related to ONNX operators stale
Projects
None yet
Development

No branches or pull requests

3 participants