MasterJH5574 commented on code in PR #14348:
URL: https://github.com/apache/tvm/pull/14348#discussion_r1142847893
##########
tests/python/relax/test_frontend_from_fx.py:
##########
@@ -19,20 +19,51 @@
import tvm
from tvm import relax
import tvm.testing
-from tvm.script.parser import ir as I, relax as R, tir as T
+from tvm.script import ir as I
+from tvm.script import relax as R
+from tvm.script import tir as T
-def verify_model(torch_model, input_info, binding, expected):
+def verify_model(torch_model, input_info, binding, expected, use_dynamo=False):
+ import torch
+ import torch._dynamo as dynamo
from torch import fx
from tvm.relax.frontend.torch import from_fx
- graph_model = fx.symbolic_trace(torch_model)
- mod = from_fx(graph_model, input_info)
+ if use_dynamo:
+ args = []
+ for info in input_info:
+ args.append(torch.zeros(*info[0],
dtype=_convert_data_type(info[1])))
+ graph_model = dynamo.export(torch_model, *args)[0]
+ else:
+ graph_model = fx.symbolic_trace(torch_model)
+ print(graph_model.code)
+ mod = from_fx(graph_model, input_info, unwrap_unit_return_tuple=True)
Review Comment:
For `unwrap_unit_return_tuple=True` I think it depends. Usually for graph
from `dynamo.export`, you want to use `unwrap_unit_return_tuple=True`. But for
graphs from `fx.symbolic_trace`, it is not necessary to use True. We also want
to test the case of `unwrap_unit_return_tuple=False` in this file. Seems that
with this change it is untested.
##########
tests/python/relax/test_frontend_from_fx.py:
##########
@@ -19,20 +19,51 @@
import tvm
from tvm import relax
import tvm.testing
-from tvm.script.parser import ir as I, relax as R, tir as T
+from tvm.script import ir as I
+from tvm.script import relax as R
+from tvm.script import tir as T
-def verify_model(torch_model, input_info, binding, expected):
+def verify_model(torch_model, input_info, binding, expected, use_dynamo=False):
+ import torch
+ import torch._dynamo as dynamo
from torch import fx
from tvm.relax.frontend.torch import from_fx
- graph_model = fx.symbolic_trace(torch_model)
- mod = from_fx(graph_model, input_info)
+ if use_dynamo:
+ args = []
+ for info in input_info:
+ args.append(torch.zeros(*info[0],
dtype=_convert_data_type(info[1])))
+ graph_model = dynamo.export(torch_model, *args)[0]
+ else:
+ graph_model = fx.symbolic_trace(torch_model)
+ print(graph_model.code)
+ mod = from_fx(graph_model, input_info, unwrap_unit_return_tuple=True)
+ print(mod.script())
Review Comment:
Debugging lines to remove.
--
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]