Skip to content

Return a Status instead of throw an exception in GetAttrs - #10534

Merged
Changming Sun (snnn) merged 2 commits into
masterfrom
snnn/p99
Feb 14, 2022
Merged

Return a Status instead of throw an exception in GetAttrs#10534
Changming Sun (snnn) merged 2 commits into
masterfrom
snnn/p99

Conversation

@snnn

Copy link
Copy Markdown
Contributor

Description:

The return type of GetAttrs is Status, so it is better to return a Status instead of throwing an exception when errors happen.

It's very tricky that if you want to read a tensor shape from attrs, you can either use a std::vector or TensorShapeVector to store the data. However, if you use TensorShapeVector you must pre-compute the number of dimension before calling GetAttrs and resize the vector to the right size. std::vector doesn't have the restriction.

Motivation and Context

  • Why is this change required? What problem does it solve?

Make error message more readable.

  • If it fixes an open issue, please link to the issue here.

Comment thread onnxruntime/core/framework/op_node_proto_helper.cc Outdated
Comment thread onnxruntime/core/framework/op_node_proto_helper.cc Outdated

@yufenglee Yufeng Li (yufenglee) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@snnn
Changming Sun (snnn) merged commit 270dec7 into master Feb 14, 2022
@snnn
Changming Sun (snnn) deleted the snnn/p99 branch February 14, 2022 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants