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

substitute variable-related ops #536

Closed
wants to merge 1 commit into from

Conversation

lucienwang1009
Copy link
Collaborator

#77

@lucienwang1009
Copy link
Collaborator Author

lucienwang1009 commented May 23, 2019

This PR only handles the case where variable-related ops' value depends on the referenced op:
image
In the graph above, the red frame shows where the Assign's value come from.
In this case, Assign updates Variable's value after the value has been read. So the Assign doesn't affect the final result.
However, there are a lot of more complex cases this PR cannot cover. For instance, if Assign is independent on the referenced op (see the graph below), the Variable's value should be set before flowing down into Add op. In this case, substituting Assign op with Identity will definitely lead to a wrong result.
More seriously, it's difficult for current converter that takes frozen graph as the input to tell the difference between these two cases. Since Variables are already frozen into Constants.
image

@nbcsm
Copy link
Collaborator

nbcsm commented May 24, 2019

if a variable is UPDATED in the inference part of a TF graph, then there is NO guarantee the frozen TF graph will behave exactly the same as the original TF graph. (variable is converted to const, not stateful anymore)

and even we can parse a TF training graph directly, there is still nothing we can do, because there is no variable concept in onnx, tensors are stateless...

so i think we should:

  • always let the converter fail on such case by default, give meaningful message to explain why and let user to modify his graph to avoid such variable usage.
    we may do this check at very early stage.

  • provide an option to enable substitute_variable_related_ops
    but need to print VERY conspicuous warning message to let user know the graph may not behave like what they want.
    but i am wondering do we really want to support this?

@guschmue for comments.

@nbcsm
Copy link
Collaborator

nbcsm commented May 24, 2019

We may need to take a look at the usage.
If it is created explicitly by the user script, we do not support it.
If it is from some common tf api, we can evaluate whether it is safe to update the graph.

@nbcsm
Copy link
Collaborator

nbcsm commented May 30, 2019

after discussion, we decided to NOT support this feature for now.
user should avoid to use variables in their script.
close this pr.

@nbcsm nbcsm closed this May 30, 2019
@lucienwang1009 lucienwang1009 deleted the assign branch July 3, 2019 03:54
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.

2 participants