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

Adding support to check if an attribute is present or not without having to get the value #3957

Merged
merged 3 commits into from
Sep 17, 2019

Conversation

shoubhik
Copy link
Contributor

There is a requirement in the parsing of pre-quantized mxnet model where; an attribute's value depends on another attribute being present or absent. The example can be found here

  1. https://github.com/apache/incubator-mxnet/blob/master/src/operator/quantization/quantize_v2.cc#L87-L90
  2. https://t.ly/AKMLm

Since there is no way for querying if an attribute is present or not in a very clean way possible I am adding a new method to check if an attribute is present.

Since the attribute in question is a float passing in a NAN or something equivalent is not right since i NAN could be a legal value of something gone wrong during quantization.
Another way could be to pass a String instead as a default value, but that will not be a clean solution since we have a api which is supposed to return a float is returning a string instead.

@shoubhik
Copy link
Contributor Author

@zhiics @vinx13 @anijain2305 Can you please review?

@@ -41,6 +41,20 @@ class StrAttrsDict(object):
def __init__(self, attrs):
self.attrs = attrs

def is_attr_present(self, key):
Copy link
Member

Choose a reason for hiding this comment

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

let's think about the name, shall we just name it has_attr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't have a problem with has_attr. i can submit a change with that name.

@shoubhik
Copy link
Contributor Author

@vinx13 can you take a look at it now.

@vinx13 vinx13 merged commit fc071da into apache:master Sep 17, 2019
wweic pushed a commit to wweic/tvm that referenced this pull request Sep 30, 2019
…ing to get the value (apache#3957)

* Adding support to check if an attribute is present or not without having to get the value.

* - Renaming the method to more appropriate name.
wweic pushed a commit to wweic/tvm that referenced this pull request Sep 30, 2019
…ing to get the value (apache#3957)

* Adding support to check if an attribute is present or not without having to get the value.

* - Renaming the method to more appropriate name.
wweic pushed a commit to neo-ai/tvm that referenced this pull request Oct 1, 2019
…ing to get the value (apache#3957)

* Adding support to check if an attribute is present or not without having to get the value.

* - Renaming the method to more appropriate name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants