vvchernov commented on a change in pull request #8709:
URL: https://github.com/apache/tvm/pull/8709#discussion_r697210306
##########
File path: python/tvm/relay/frontend/pytorch.py
##########
@@ -148,29 +146,13 @@ def infer_type(self, node, mod=None):
if node in self.types:
return self.types[node]
- if isinstance(node, tvm.relay.Var):
- return node.type_annotation
-
- tf = _TypeFinder(types=self.types)
- new_node = tf.visit(node)
- fn = _function.Function(list(tf.vars.values()), new_node)
- new_mod = IRModule({"main": fn})
- if mod is not None:
- new_mod.update(mod)
- new_mod = transform.RemoveUnusedFunctions()(new_mod)
- new_mod = transform.InferType()(new_mod)
- entry = new_mod["main"]
- ty = entry.body.checked_type
- self.types[node] = ty
- return self.types[node]
Review comment:
The quick answer is no. I understood the idea when I updated code and
kept it, but I tried to unify infer_type from common.py and use it instead of
duplicated code in pytorch frontend.
Thank you for good reference. I studied #6900,
https://discuss.tvm.apache.org/t/incremental-type-propagation/7446 and
references there (PRs #5755, #6080, #6008, #6007, #7008). I agree with ideas 1.
do graph pass once and save result (done), 2. unify it for all frontends not
only for pytorch (not done). My main doubt is I removed some code from infer
type implementation inside pytorch frontend, It seems that it does the same but
by another way. if not then why it is not used in infer type in common.py, if
yes then why we have excess functionality. May be @t-vi helps us.
I wanted to ask about current status of point 2 task, but found the
following answer
https://github.com/apache/tvm/issues/7008#issuecomment-739588404. Is it
correct? If unified approach of infer type, shape and others is done soon my PR
can be close, but please take into account idea to hide checked_type or
type_annotation inside infer_type. Seems it can be done and not need to think
about it by final client.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]