vinx13 commented on code in PR #16757:
URL: https://github.com/apache/tvm/pull/16757#discussion_r1534302459


##########
python/tvm/relax/frontend/nn/exporter.py:
##########
@@ -121,7 +122,6 @@ def _effects() -> typing.List[typing.Tuple[str, 
core.Effect]]:
                         outputs = _emit_effect_init(self.builder, effects)
                     self.builder.emit_func_output(outputs, params=[])
             for method_name, method_spec in zip(spec.method_names, 
spec.method_specs):
-                params = _params()  # Re-initialize so symbolic shapes not 
shared across methods

Review Comment:
   personally this is preferable given its explicitness and simplicity (we 
don't need to do copy the whole function)



##########
python/tvm/relax/frontend/nn/core.py:
##########
@@ -591,7 +591,22 @@ def wrap_nested(expr: rx.Expr, name: str) -> Union[Tensor, 
Sequence[Tensor]]:
         The computed result.
     """
     if not isinstance(expr, rx.DataflowVar):
-        expr = BlockBuilder.current().emit(expr, name)
+        block_builder = BlockBuilder.current()
+        if block_builder is None:
+            # Normalize to make sure we have valid StructInfo, but
+            # wait until we are actually building the function to
+            # flatten nested expressions.
+            #
+            # TODO(Lunderberg): Make this easier to call.  Infering
+            # struct info for a nested expression should be doable in
+            # a free function, without requiring an active
+            # BlockBuilder and an active FunctionFrame.
+            builder = BlockBuilder()
+            with builder.function("dummy_scope", params=[]):
+                expr = builder.normalize(expr)
+                builder.emit_func_output([])

Review Comment:
   do we have use case using it outside block builder? emitting a function is 
not equivalent to emitting the expression itself, unless the function is 
evaluated



-- 
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]

Reply via email to